mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 11:51:05 +01:00
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.
This commit is contained in:
1 parent
210fc900d5
commit
cfbb1cdf67
2 files changed
+25
-4
No files matched your search
@@ -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));
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user