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
@@ -83,6 +83,12 @@ pub fn timecode(session: &Session, comp: &Comp, t: Tick) -> String {
|
||||
effectcraft_engine::commands::time::display_time(session, comp, t)
|
||||
}
|
||||
|
||||
/// Spacebar held outside a text field: the Hand tool (drags pan the viewer and scroll the
|
||||
/// Timeline).
|
||||
pub(crate) fn space_hand(ctx: &egui::Context) -> bool {
|
||||
ctx.input(|i| i.key_down(egui::Key::Space)) && !ctx.egui_wants_keyboard_input()
|
||||
}
|
||||
|
||||
pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: PanelKind, rect: Rect) {
|
||||
match p {
|
||||
PanelKind::Composition => viewers::show(app, ui, 0, rect),
|
||||
|
||||
@@ -2403,6 +2403,22 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let mrows = rows_rect.intersect(Rect::from_min_max(pos2(graph_x0, rows_rect.min.y), rows_rect.max));
|
||||
super::markers_ui::comp_markers(app, ui, &comp, tm, mstrip, mrows);
|
||||
|
||||
// Spacebar held: the Hand tool. Dragging the ruler or the time graph scrolls it in time when
|
||||
// zoomed in (registered last, so it takes the drag from the bars, keys and markers there).
|
||||
if super::space_hand(&ctx) {
|
||||
let area = Rect::from_min_max(pos2(graph_x0, ruler.min.y), pos2(rect.max.x, rows_rect.max.y));
|
||||
let hand = ui.interact(area, egui::Id::new("tl-hand"), Sense::drag());
|
||||
app.auto.add("timeline.hand", area, "Hand (hold Spacebar)");
|
||||
if hand.hovered() || hand.dragged() {
|
||||
ctx.set_cursor_icon(if hand.dragged() { egui::CursorIcon::Grabbing } else { egui::CursorIcon::Grab });
|
||||
}
|
||||
if hand.dragged() && app.ui.timeline.pps.is_some() {
|
||||
let start = app.ui.timeline.start;
|
||||
let last = (comp.duration.seconds() - (tm.t(graph_x1) - tm.start)).max(start).max(0.0);
|
||||
app.ui.timeline.start = (start - hand.drag_delta().x as f64 / pps).clamp(0.0, last);
|
||||
}
|
||||
}
|
||||
|
||||
// Drop targets: effects from Effects & Presets go on the layer under the pointer. Footage and
|
||||
// comps from the Project panel and files from the Media Browser go where they are dropped: a
|
||||
// line shows the place in the stack, and over the time graph a marker shows the In point too
|
||||
|
||||
@@ -991,7 +991,7 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
}
|
||||
app.ui.viewer.interacting = resp.dragged();
|
||||
let mods = ui.input(|i| i.modifiers);
|
||||
let space_pan = ui.input(|i| i.key_down(egui::Key::Space)) && !ctx.egui_wants_keyboard_input();
|
||||
let space_pan = super::space_hand(&ctx);
|
||||
// Pen tool: each press places a vertex (dragging pulls Bezier tangents); pressing on the
|
||||
// first vertex closes the path.
|
||||
if app.ui.tool == Tool::Pen
|
||||
|
||||
Reference in New Issue
Block a user