Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Integration: merge main (#6254)

David Mannb7eabd49900e
diff --cc crates/ui-egui/src/move_mods.rs
index 32bd9e2f0,a5be52036..24457f52d
--- a/crates/ui-egui/src/move_mods.rs
+++ b/crates/ui-egui/src/move_mods.rs
@@@ -152,22 -152,11 +152,27 @@@ fn drag_to(app: &mut PhotocraftApp, p:
[start[0] + d[0], start[1] + d[1]]
}
+/// ⇧ while a selection tool drags the selection (#6231): lock the move to the dominant axis, as
+/// the Move tool's layer drags do. The caller skips this when [`filter_event`] has already
+/// rewritten the event (the Move tool itself); it covers the `sel_move` drags the marquee and
+/// lasso tools start, including ⌘-drags of the selected pixels. The locked offset is kept on the
+/// drag between events so the axis doesn't flicker near 45°.
+pub(crate) fn selection_drag_to(d: &mut crate::canvas::Drag, p: [f64; 2], shift: bool) -> [f64; 2] {
+ if d.sel_move.is_none() || !shift {
+ d.sel_axis = None;
+ return p;
+ }
+ let delta = [p[0] - d.start[0], p[1] - d.start[1]];
+ let locked = constrain(delta, d.sel_axis, MOVE_DIRECTIONS);
+ d.sel_axis = Some(locked);
+ [d.start[0] + locked[0], d.start[1] + locked[1]]
+}
+
+ /// The Move drag in progress is an ⌥-drag that has duplicated the layers (it now moves the copies).
+ pub(crate) fn duplicated(app: &PhotocraftApp) -> bool {
+ moving(app) && app.move_mods.dup_from.is_some()
+ }
+
/// Call after the Move tool finished its drag: an ⌥-drag's copy and move become one step.
pub fn finish(app: &mut PhotocraftApp) {
let st = std::mem::take(&mut app.move_mods);