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:
co-authored by
Claude Opus 5.5
parent
0f44588bbd
commit
1afeb9d5c6
@@ -1259,8 +1259,16 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
p.with_clip_rect(wa_row).rect_filled(wa, 0.0, WORK_AREA_BAR);
|
||||
let shift = ui.input(|i| i.modifiers.shift);
|
||||
let bar = wa.intersect(wa_row);
|
||||
let bresp = ui.interact(bar, egui::Id::new("wa-bar"), Sense::drag());
|
||||
let bresp = ui.interact(bar, egui::Id::new("wa-bar"), Sense::click_and_drag());
|
||||
app.auto.add("timeline.workArea.bar", bar, "Work area");
|
||||
// Right-click: the work area's commands (After Effects).
|
||||
bresp.context_menu(|ui| {
|
||||
let mut chosen = None;
|
||||
for id in ["comp.trimToWorkArea", "edit.liftWorkArea", "edit.extractWorkArea"] {
|
||||
crate::menus::entry_for(app, ui, id, &mut chosen);
|
||||
}
|
||||
actions.extend(chosen);
|
||||
});
|
||||
let bar_start = egui::Id::new("wa-bar-start");
|
||||
if bresp.drag_started() {
|
||||
ctx.data_mut(|d| d.insert_temp(bar_start, wa0));
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user