From cfbb1cdf67c30d6d1fb52ea40fac66cbd01d9573 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 10:40:07 -0800 Subject: [PATCH] Selection: pie widgets hide while Cmd lends Direct Selection With a shape tool active and Direct Selection chosen last, Cmd held lends Direct Selection, which does not press a live ellipse's pie widgets. The canvas now draws them for a shape tool only while that tool is the one shown, as the bounding box already does. --- crates/ui-egui/src/canvas/overlays.rs | 8 ++++---- crates/ui-egui/src/canvas/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index 02318ad688..b79206662d 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -276,10 +276,10 @@ pub(super) fn selection_overlay( p.add(Shape::convex_polygon(diamond, Color32::WHITE, Stroke::new(1.0, color))); } } - // Pie widgets (Selection tool, with View › Show Bounding Box and Show Shape Widgets, on live - // ellipses): each joined by a line to the outline's point at its angle. They stay while one is - // dragged. - if (tool == "selection" || (shape_tool && !drawing)) && app.ui.view.bounding_box && shape_widgets { + // Pie widgets (Selection tool and the shape tools while no other tool is lent, with View › Show + // Bounding Box and Show Shape Widgets, on live ellipses): each joined by a line to the outline's + // point at its angle. They stay while one is dragged. + if (tool == "selection" || (shape_tool && own && !drawing)) && app.ui.view.bounding_box && shape_widgets { for w in vectorcraft_tools::pie::PieWidget::of(&st.doc, &st.selection, xf.zoom) { let (on, c, r, color) = (xf.to_screen(w.on), xf.to_screen(w.at), vectorcraft_tools::pie::RADIUS_PX, c32(st.doc.layer_color(w.id))); p.line_segment([on, c], Stroke::new(1.0, color)); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 21dd33b715..963bbc3289 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -7264,6 +7264,27 @@ fn the_widgets_follow_the_pointer_in_the_frame_it_moves() { assert!(away + 2 <= plain, "away from it, hidden in the same frame: {away} of {plain}"); } +/// With a shape tool, Cmd held lends the selection tool chosen last; when that is Direct +/// Selection, which does not press them, a selected live ellipse's pie widgets hide while the key +/// is down. +#[test] +fn pie_widgets_hide_while_cmd_lends_direct_selection() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + app.session.execute("shape.ellipse", &json!({"x": 100, "y": 100, "width": 200, "height": 100})).unwrap(); + app.session.execute("object.setLiveShape", &json!({"pieStart": 0, "pieEnd": 90})).unwrap(); + app.select_tool("directSelection"); + app.select_tool("ellipse"); + let ctx = egui::Context::default(); + let r = vectorcraft_tools::pie::RADIUS_PX; + let widgets = |app: &mut VectorcraftApp, modifiers: egui::Modifiers| { + drawn_with(app, &ctx, modifiers, None).iter().filter(|s| matches!(s, Shape::Circle(c) if c.radius == r && c.fill == Color32::WHITE)).count() + }; + assert_eq!(widgets(&mut app, egui::Modifiers::NONE), 2, "the Ellipse tool shows them"); + assert_eq!(widgets(&mut app, egui::Modifiers::COMMAND), 0, "hidden while Cmd lends Direct Selection"); + assert_eq!(widgets(&mut app, egui::Modifiers::NONE), 2, "back when the key is let go"); +} + /// A selected Objects on Path group shows its Rotate All widget with the Selection and Objects on /// Path tools. #[test]