mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 12:16:39 +00:00
Merge pull request #8818 from dotCooCoo/fix/selection-widget-double-click-transform
Live Corners: a Selection tool double-click on a corner widget shows the Transform panel
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
//! sharpens) the corners whose widgets show together, on every selected path (#938): every corner
|
||||
//! of a path selected whole, those with a selected anchor when Direct Selection picked some. Alt-clicking a widget cycles their corner
|
||||
//! kind (round, inverted round, chamfer), as the Up and Down arrows do while one is dragged
|
||||
//! (#2898); double-clicking one opens the Corners dialog. The
|
||||
//! (#2898); double-clicking one opens the Corners dialog with Direct Selection and shows the
|
||||
//! Transform panel with the Selection tool. The
|
||||
//! Selection and Direct Selection tools share this, and the canvas draws the widgets from the same
|
||||
//! geometry.
|
||||
|
||||
@@ -217,7 +218,8 @@ pub fn over_widget(cx: &ToolContext, p: Point, any_path: bool) -> bool {
|
||||
CornerWidgets::for_tool(cx, any_path).and_then(|w| w.hit(p, cx.tol(5.0))).is_some()
|
||||
}
|
||||
|
||||
/// A double-click on a corner widget opens the Corners dialog for the shown corners of its path.
|
||||
/// A double-click on a corner widget opens the Corners dialog for the shown corners of its path
|
||||
/// (Direct Selection; the Selection tool shows the Transform panel instead).
|
||||
pub fn double_click(cx: &ToolContext, p: Point, any_path: bool) -> Option<Action> {
|
||||
let w = CornerWidgets::for_tool(cx, any_path)?;
|
||||
let (i, _) = w.hit(p, cx.tol(5.0))?;
|
||||
|
||||
@@ -355,13 +355,24 @@ fn alt_click_cycles_the_kind_and_double_click_opens_the_dialog() {
|
||||
assert_eq!(a, vec![Action::Exec("object.setLiveShape".into(), want.clone())], "{tool}");
|
||||
}
|
||||
}
|
||||
// A double-click on a widget opens Corners for the shown corners; elsewhere it doesn't.
|
||||
// With Direct Selection, a double-click on a widget opens Corners for the shown corners;
|
||||
// elsewhere it doesn't.
|
||||
let cx1 = cx(&d, &part, &p);
|
||||
let a = crate::create("directSelection").pointer(&cx1, &PointerEvent::new(PointerKind::DoubleClick, 110.0, 110.0));
|
||||
assert_eq!(a, vec![Action::Dialog(DIALOG.into(), json!({"id": id.0, "corners": [0]}))]);
|
||||
let cx2 = cx(&d, &whole, &p);
|
||||
let a = crate::create("selection").pointer(&cx2, &PointerEvent::new(PointerKind::DoubleClick, 190.0, 110.0));
|
||||
let a = crate::create("directSelection").pointer(&cx2, &PointerEvent::new(PointerKind::DoubleClick, 190.0, 110.0));
|
||||
assert_eq!(a, vec![Action::Dialog(DIALOG.into(), json!({"id": id.0, "corners": [0, 1, 2, 3]}))]);
|
||||
// With the Selection tool, it shows the Transform panel instead, on any of the widgets.
|
||||
for at in [(110.0, 110.0), (190.0, 110.0), (190.0, 190.0), (110.0, 190.0)] {
|
||||
let a = crate::create("selection").pointer(&cx2, &PointerEvent::new(PointerKind::DoubleClick, at.0, at.1));
|
||||
assert_eq!(a, vec![Action::Panel("transform".into())], "{at:?}");
|
||||
}
|
||||
// With the shape widgets hidden, the same double-click isolates the shape, as off the widgets.
|
||||
let mut hidden = cx(&d, &whole, &p);
|
||||
hidden.shape_widgets = false;
|
||||
let a = crate::create("selection").pointer(&hidden, &PointerEvent::new(PointerKind::DoubleClick, 190.0, 110.0));
|
||||
assert_eq!(a, vec![Action::Exec("object.isolate".into(), json!({"id": id.0}))]);
|
||||
// Off the widgets, the Selection tool's double-click isolates the shape (Double Click To
|
||||
// Isolate) instead.
|
||||
let a = crate::create("selection").pointer(&cx2, &PointerEvent::new(PointerKind::DoubleClick, 150.0, 150.0));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! bounding-box scale (Shift proportional, Alt from center; Snap to Grid, Snap to Pixel, Smart
|
||||
//! Guides and Snap to Point snap what the handle moves) and rotate (outside corners, Shift 45°),
|
||||
//! drag a live rectangle's or polygon's corner widget to round its corners (Alt-click cycles their kind,
|
||||
//! double-click opens the Corners dialog), drag a live ellipse's pie widgets to set its pie angles
|
||||
//! double-click shows the Transform panel), drag a live ellipse's pie widgets to set its pie angles
|
||||
//! (double-click makes it whole again: [`crate::pie`]), double-click a group or an object to enter isolation
|
||||
//! mode (Double Click To Isolate), Cmd/Ctrl-click to select the object behind (Command Click to Select Objects Behind),
|
||||
//! click or drag a ruler guide ([`crate::rulerguide`]), Cmd/Ctrl+Shift-double-click a ruler guide or
|
||||
@@ -1634,7 +1634,12 @@ impl SelectionTool {
|
||||
}
|
||||
return vec![];
|
||||
}
|
||||
if let Some(a) = corners::double_click(cx, p, false).or_else(|| pie::double_click(cx, p)).or_else(|| typewidget::double_click(cx, p)) {
|
||||
// A corner widget of a selected live shape shows the Transform panel, as with the shape
|
||||
// tools; the tool and the selection stay as they are. Direct Selection opens Corners.
|
||||
if corners::over_widget(cx, p, false) {
|
||||
return vec![Action::Panel("transform".into())];
|
||||
}
|
||||
if let Some(a) = pie::double_click(cx, p).or_else(|| typewidget::double_click(cx, p)) {
|
||||
return vec![a];
|
||||
}
|
||||
if let Some(a) = release_guide_at(cx, p, m) {
|
||||
|
||||
Reference in New Issue
Block a user