mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
Viewer: Ctrl/Cmd draws a shape from its centre, as in After Effects (#443 follow-up)
Also keeps #442's newest-completed-revision lookup for the live drag, so Frames has one way to pick the frame shown while an edit renders. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
2 files changed
+7
-7
No files matched your search
@@ -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()),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user