Spacebar: a tap previews on release, held it is the Hand tool (#227)
Spacebar started or stopped the preview on its press, so holding it to pan the Composition panel (Space+drag already panned there) also toggled playback. As in After Effects, plain Spacebar now runs its shortcut when it is released, and only if no mouse button went down while it was held and the press didn't go to a text field; key auto-repeat toggles nothing more. Shift+Spacebar and the numpad preview shortcuts still run on the press. Holding Spacebar over the Timeline's ruler and time graph is the Hand tool there too: dragging scrolls the time graph (when zoomed in, never before the comp's start or past its end) instead of moving bars, keys or markers. Test: spacebar_taps_preview_and_held_spacebar_pans_the_viewer, spacebar_drag_scrolls_the_time_graph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e1062ab81b
commit
e008085a93
@@ -124,3 +124,40 @@ fn semicolon_toggles_frame_level_and_the_whole_comp() {
|
||||
effectcraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "timeline.zoomFrameToggle", json!({})).unwrap();
|
||||
assert_eq!(h.state().ui.timeline.pps, None);
|
||||
}
|
||||
|
||||
fn space(h: &mut Harness<'_, EffectcraftApp>, pressed: bool) {
|
||||
h.event(Event::Key { key: egui::Key::Space, physical_key: None, pressed, repeat: false, modifiers: Modifiers::NONE });
|
||||
h.step();
|
||||
}
|
||||
|
||||
/// #227: with Spacebar held, a drag over the time graph scrolls it in time (the Hand tool)
|
||||
/// instead of moving the layer bar under the pointer, and the release doesn't preview.
|
||||
#[test]
|
||||
fn spacebar_drag_scrolls_the_time_graph() {
|
||||
let (mut h, layer) = harness();
|
||||
// (Opening the comp showed all of it.)
|
||||
h.state_mut().ui.timeline.pps = Some(200.0);
|
||||
h.state_mut().ui.timeline.start = 10.0;
|
||||
h.run_steps(2);
|
||||
let in_point = |h: &Harness<'_, EffectcraftApp>| h.state().session.active_comp().unwrap().layers[0].in_point.seconds();
|
||||
let from = pos2(rect(&h, "timeline.ruler").center().x, over_bar(&h, layer).y);
|
||||
// 400 px to the left at 200 px/s: 2 s later.
|
||||
space(&mut h, true);
|
||||
drag(&mut h, from, from - vec2(400.0, 0.0));
|
||||
space(&mut h, false);
|
||||
let (a, _) = visible(&h);
|
||||
assert!((a - 12.0).abs() < 0.01, "starts at {a}");
|
||||
assert_eq!(in_point(&h), 0.0, "the bar didn't move");
|
||||
assert!(!h.state().playback.playing, "a Spacebar drag doesn't preview");
|
||||
// To the right, at most back to the comp's start.
|
||||
space(&mut h, true);
|
||||
for _ in 0..6 {
|
||||
drag(&mut h, from, from + vec2(500.0, 0.0));
|
||||
}
|
||||
space(&mut h, false);
|
||||
assert_eq!(visible(&h).0, 0.0);
|
||||
assert_eq!(in_point(&h), 0.0);
|
||||
// Without Spacebar the same drag moves the bar.
|
||||
drag(&mut h, from, from - vec2(400.0, 0.0));
|
||||
assert!(in_point(&h) < -1.0, "{}", in_point(&h));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user