Files
soundcraft/crates/ui-egui/tests/track_name_menu.rs
grovebit edf4fc59f6 Right-click a track's name for the track menu, in Edit and Mix
From #186 and #305: right-clicking a track's name did nothing. In the
Edit window the track menu (Rename, Duplicate, Make Inactive, Hide,
Delete, height, colour…) was only on the header's background, and the
name plate drawn over it took the click. The Mix window had no track
menu at all. Pro Tools opens it from the name in both windows.

Both name plates now open the same track menu on a right-click. Clicks,
double-click to rename and dragging to reorder are unchanged.
2026-10-12 18:07:47 +01:00

41 lines
1.6 KiB
Rust

//! Right-clicking a track's name opens the track menu, in the Edit and in the Mix window.
use egui::{Event, Modifiers, PointerButton, Pos2, pos2, vec2};
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use soundcraft_ui_egui::{MainWindow, Services, SoundApp};
fn right_click(h: &mut Harness<SoundApp>, at: Pos2) {
h.hover_at(at);
for pressed in [true, false] {
h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE });
}
h.run_steps(3);
}
#[test]
fn right_click_on_a_track_name_opens_the_track_menu() {
let mut engine = soundcraft_engine::Engine::default();
engine.execute("track.new", &serde_json::json!({"name": "Voice"})).unwrap();
let app = SoundApp::new(engine, None, Services::default());
let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_ui_state(
|ui, app: &mut SoundApp| {
app.logic(&ui.ctx().clone());
app.ui(ui);
},
app,
);
h.run_steps(4);
let row = h.state().edit_layout.rows[0].1;
right_click(&mut h, pos2(row[0] + 60.0, row[1] + 10.0));
assert!(h.query_by_label("Make Inactive").is_some(), "the Edit window's name plate");
h.key_press(egui::Key::Escape);
h.state_mut().ui.window = MainWindow::Mix;
h.run_steps(4);
assert!(h.query_by_label("Make Inactive").is_none());
let strip = h.get_by_label("Record enable").rect();
right_click(&mut h, pos2(strip.center().x, 900.0 - 17.0));
assert!(h.query_by_label("Make Inactive").is_some(), "the Mix strip's name plate");
}