collective

Browse / github.com/storytold/photocraft / patch

fix(move): one click accepts a resized transform box and picks the layer under it (#8208)

[Improve] After resizing, clicking another object should select it - Have "Display transformation controls" enabled with the V-key selection tool - Select an item and resize it - Try to select another one - You need to click twice because it first needs to close the previous resize context - Could be nice to instantly close it and switch to the new object selection in one click This does only happen when resizing, switching between objects with no modifications doesn't trigger this friction.

Status
open
Score
0.00
Adopters
0 other operators
Author
Higgs32584 (imported from pull request #9862, open)
Base
07bd794686ea4db0b557c978d58173a62760e4ca
Size
+26 −0 in 2 files
Review
pending
Shared
2026-10-28
Id
411fe4d449df24b5056a1eb5

How it went

No other operator has reported using it yet.

Diff

raw · crates/ui-egui/src/move_auto_select_tests.rs crates/ui-egui/src/tools/transform_tool/pointer.rs

diff --git a/crates/ui-egui/src/move_auto_select_tests.rs b/crates/ui-egui/src/move_auto_select_tests.rs--- a/crates/ui-egui/src/move_auto_select_tests.rs+++ b/crates/ui-egui/src/move_auto_select_tests.rs@@ -257,3 +257,23 @@ fn shift_click_adds_shape_layers_one_after_another() {     selected.sort_by_key(|l| l.0);     assert_eq!(selected, ids); }++/// #8208: with Show Transform Controls on, one click outside a resized box both commits the+/// resize and Auto-Selects the layer under the pointer; it no longer takes a second click.+#[test]+fn one_click_accepts_a_resized_box_and_picks_the_layer_under_it() {+    let (mut app, a, b) = app();+    app.ui.tool_options.move_show_transform = true;+    crate::transform_tool::begin(&mut app, &egui::Context::default()).unwrap();+    // Resize B's box to twice its size from its top-left corner.+    let t = app.ui.transform.as_mut().unwrap();+    t.quad[2] = [t.quad[2][0] + 16.0, t.quad[2][1] + 16.0];+    t.quad[1][0] += 16.0;+    t.quad[3][1] += 16.0;+    let click = egui::Modifiers::NONE;+    crate::canvas::tool_event(&mut app, ToolEvent::Down { x: 16.0, y: 16.0, pressure: 1.0 }, click);+    crate::canvas::tool_event(&mut app, ToolEvent::Up { x: 16.0, y: 16.0 }, click);+    assert!(app.ui.transform.is_none(), "the click accepted the box");+    assert_eq!(bounds(&app, b), Rect::new(40, 40, 72, 72), "B keeps its resize");+    assert_eq!(active(&app), Some(a), "and the same click selected A");+}diff --git a/crates/ui-egui/src/tools/transform_tool/pointer.rs b/crates/ui-egui/src/tools/transform_tool/pointer.rs--- a/crates/ui-egui/src/tools/transform_tool/pointer.rs+++ b/crates/ui-egui/src/tools/transform_tool/pointer.rs@@ -97,6 +97,12 @@ pub fn pointer(app: &mut PhotocraftApp, ev: ToolEvent, mods: egui::Modifiers) ->             // keep their existing behavior.             if matches!(ev, ToolEvent::Up { .. }) && g.is_some_and(|g| accepts_outside_click(g, [x, y], tol)) {                 commit(app);+                // The Move tool's click that accepted the box also picks what is under it+                // (Auto-Select), rather than needing a second click (#8208).+                if app.ui.transform.is_none() && app.ui.tool == crate::state::Tool::Move {+                    crate::canvas::tool_event(app, ToolEvent::Down { x, y, pressure: 1.0 }, mods);+                    crate::canvas::tool_event(app, ToolEvent::Up { x, y }, mods);+                }                 return true;             }             let type_layer = moves_type(app, &t);