Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Viewer: Ctrl/Cmd draws a shape from its centre, as in After Effects (#443 follow-up)

Claude0ce5063d9f92
diff --git a/crates/ui-egui/src/panels/viewer.rs b/crates/ui-egui/src/panels/viewer.rs
index 89f46d7e5..9adf007f8 100644
--- a/crates/ui-egui/src/panels/viewer.rs
+++ b/crates/ui-egui/src/panels/viewer.rs
@@ -1968,8 +1968,8 @@ fn shape_drag(app: &EffectcraftApp, tool: Tool, start: [f64; 2], end: [f64; 2],
let (target, layer) = target;
let mask_index = if target == ShapeTarget::Mask { layer.and_then(|l| l.masks()).map_or(0, |m| m.groups().count()) } else { 0 };
let (mut w, mut h) = ((end[0] - start[0]).abs(), (end[1] - start[1]).abs());
- // Alt doubles the box about the press point, which is then its centre.
- if mods.alt {
+ // Ctrl/Cmd draws from the press point as the centre, as in After Effects.
+ if mods.command {
w *= 2.0;
h *= 2.0;
}
@@ -1983,7 +1983,7 @@ fn shape_drag(app: &EffectcraftApp, tool: Tool, start: [f64; 2], end: [f64; 2],
}
Some(ShapeDrag {
kind: shape_kind(tool),
- centre: if mods.alt { start } else { [start[0].min(end[0]) + w / 2.0, start[1].min(end[1]) + h / 2.0] },
+ centre: if mods.command { start } else { [start[0].min(end[0]) + w / 2.0, start[1].min(end[1]) + h / 2.0] },
size: [w, h],
target,
layer_name: layer.map_or_else(String::new, |l| l.name.clone()),
diff --git a/crates/ui-egui/tests/ui_viewer.rs b/crates/ui-egui/tests/ui_viewer.rs
index 54618dc31..6b535b6cc 100644
--- a/crates/ui-egui/tests/ui_viewer.rs
+++ b/crates/ui-egui/tests/ui_viewer.rs
@@ -456,17 +456,17 @@ fn shape_drag_ghost_shows_the_tools_own_shape_while_dragging() {
}
/// The ghost and the shape the release commits share one normalisation, so nothing it shows is a
-/// lie: Shift squares the box and Alt (Option) draws it from the press point, both live.
+/// lie: Shift squares the box and Ctrl/Cmd draws it from the press point (as in After Effects), both live.
#[test]
fn shape_drag_ghost_normalises_the_same_way_as_the_release() {
let from = [140.0f64, 100.0];
let to = [400.0f64, 260.0];
- // (mods, centre, size): Shift squares the box from its top-left, Alt centres it on the press.
+ // (mods, centre, size): Shift squares the box from its top-left, Ctrl/Cmd centres it on the press.
for (mods, centre, size) in [
(egui::Modifiers::default(), [270.0, 180.0], [260.0, 160.0]),
(egui::Modifiers::SHIFT, [270.0, 230.0], [260.0, 260.0]),
- (egui::Modifiers::ALT, [140.0, 100.0], [520.0, 320.0]),
- (egui::Modifiers { alt: true, shift: true, ..Default::default() }, [140.0, 100.0], [520.0, 520.0]),
+ (egui::Modifiers::COMMAND, [140.0, 100.0], [520.0, 320.0]),
+ (egui::Modifiers { shift: true, ..egui::Modifiers::COMMAND }, [140.0, 100.0], [520.0, 520.0]),
] {
let mut h = harness();
h.state_mut().ui.tool = Tool::Ellipse;