Timeline: right-clicking the work area offers Trim Comp to Work Area, Lift and Extract (#290)

The work area bar had no context menu. Right-clicking it now offers the
work area's commands from the menu bar: Trim Comp to Work Area, Lift
Work Area and Extract Work Area (After Effects).

Test: work_area_context_menu_trims_the_comp (ui_timeline_zoom).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-09 17:21:13 +07:00
co-authored by Claude Opus 5.5
parent 0f44588bbd
commit 1afeb9d5c6
2 changed files with 39 additions and 1 deletions
+30
View File
@@ -6,6 +6,7 @@ use effectcraft_engine::Session;
use effectcraft_ui_egui::EffectcraftApp;
use egui::{Event, Modifiers, MouseWheelUnit, Pos2, pos2, vec2};
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use serde_json::json;
/// A 10-minute comp with one solid, zoomed in on its start.
@@ -170,6 +171,35 @@ fn spacebar_drag_scrolls_the_time_graph() {
assert!(in_point(&h) < -1.0, "{}", in_point(&h));
}
/// #290: right-clicking the work area bar offers its commands; Trim Comp to Work Area trims.
#[test]
fn work_area_context_menu_trims_the_comp() {
let (mut h, _) = harness();
h.state_mut().ui.timeline.pps = None;
h.state_mut().session.execute("comp.workArea", json!({"start": 60.0, "end": 180.0})).unwrap();
h.run_steps(3);
let at = rect(&h, "timeline.workArea.bar").center();
h.event(Event::PointerMoved(at));
h.step();
for pressed in [true, false] {
h.event(Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: Modifiers::NONE });
h.step();
}
h.run_steps(2);
for label in ["Lift Work Area", "Extract Work Area"] {
assert!(h.query_by_label_contains(label).is_some(), "{label}");
}
let trim = h.query_by_label_contains("Trim Comp to Work Area").expect("Trim Comp to Work Area").rect().center();
h.event(Event::PointerMoved(trim));
h.step();
for pressed in [true, false] {
h.event(Event::PointerButton { pos: trim, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE });
h.step();
}
h.run_steps(2);
assert_eq!(h.state().session.active_comp().unwrap().duration.seconds(), 120.0);
}
/// #252: Shift-dragging a work area end, or the whole work area bar, snaps to the current-time
/// indicator when it comes within reach; without Shift it lands where the pointer is.
#[test]