mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-06 14:03:16 -05:00
Selection: Cmd/Ctrl lends Direct Selection until it is released
With the Selection tool chosen, holding Cmd (Ctrl on Windows and Linux) now lends Direct Selection, or Group Selection when that was chosen last, for each press; the Selection tool is back on the release. With Group Selection chosen, Cmd lends the Selection tool, as it already did with Direct Selection. Selection & Anchor Display > Command Click to Select Objects Behind keeps a Cmd press on a selected object, away from its anchors, handles, mesh points and spine, for selecting the object behind it. A wide stroke's painted area counts as on the object there. - The double-click or triple-click after Cmd-clicks goes to the tool the clicks went to. - Cmd pressed once a drag is under way lends nothing, and the pointer stays the active tool's. - While Cmd is held, the status bar's Current Tool and the help bar name the lent tool, and the canvas shows the lent tool's marks and widgets (blend, Shaper, mirror, trace divider and repeat handles) for the pointer's position in the same frame. - The help bar has hints for Group Selection. The helper that finds a selected object's editable parts under the pointer follows the one in pull request 6597 by SofiaAFigueredo. Docs: docs/ui-parity.md, docs/control-protocol.md (ui.pointer). Co-authored-by: SofiaAFigueredo <[email protected]>
This commit is contained in:
1 parent
9fff48d88f
commit
dcff4edc3d
19 files changed
+532
-76
No files matched your search
@@ -518,6 +518,10 @@ struct Measured {
|
||||
bounds: Option<Option<Rect>>,
|
||||
oriented: Option<Option<OrientedBox>>,
|
||||
by_object: HashMap<NodeId, Option<Option<Rect>>>,
|
||||
/// [`painted_bounds`].
|
||||
painted: Option<Option<Rect>>,
|
||||
/// [`selected_part_boxes`].
|
||||
part_boxes: Option<std::sync::Arc<[(NodeId, Rect)]>>,
|
||||
}
|
||||
|
||||
impl Measured {
|
||||
@@ -549,6 +553,8 @@ impl PreviewMemo {
|
||||
bounds: None,
|
||||
oriented: None,
|
||||
by_object: HashMap::new(),
|
||||
painted: None,
|
||||
part_boxes: None,
|
||||
};
|
||||
if !st.entry.as_ref().is_some_and(|m| m.is_for(cx)) {
|
||||
st.entry = Some(fresh());
|
||||
@@ -594,6 +600,19 @@ pub fn selection_box(cx: &ToolContext) -> Option<OrientedBox> {
|
||||
remembered(cx, |m| &mut m.oriented, || vectorcraft_effects::preview::oriented_bounds_with(cx.doc, &cx.selection.objects, cx.bounds_measure()))
|
||||
}
|
||||
|
||||
/// The selection's visual bounds as drawn, its strokes and effects included, whatever Use Preview
|
||||
/// Bounds says: every point where a hit test finds a selected object is inside them.
|
||||
fn painted_bounds(cx: &ToolContext) -> Option<Rect> {
|
||||
remembered(cx, |m| &mut m.painted, || vectorcraft_effects::preview::bounds_of(cx.doc, &cx.selection.objects, true))
|
||||
}
|
||||
|
||||
/// `measure`'s list of the selected objects' editable paths with their control bounds, kept in the
|
||||
/// session's [`PreviewMemo`] while the document and the selection stay as they are
|
||||
/// ([`crate::direct::over_selected_part`]).
|
||||
pub(crate) fn selected_part_boxes(cx: &ToolContext, measure: impl FnOnce() -> std::sync::Arc<[(NodeId, Rect)]>) -> std::sync::Arc<[(NodeId, Rect)]> {
|
||||
remembered(cx, |m| &mut m.part_boxes, measure)
|
||||
}
|
||||
|
||||
/// [`selection_box`] while the canvas shows it (View › Show Bounding Box, and no anchors selected
|
||||
/// on their own): its handles take a press only then. A path the Pen is drawing keeps its end
|
||||
/// anchor selected, so Cmd/Ctrl lending the Selection tool doesn't scale it by hidden handles (#4980).
|
||||
@@ -1499,6 +1518,21 @@ impl Tool for SelectionTool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Does a Cmd/Ctrl press at `p` with the Selection tool select behind: is Select Behind on and a
|
||||
/// selected object under the pointer, away from the anchors, handles and segments Direct
|
||||
/// Selection edits ([`crate::direct::over_selected_part`])? Elsewhere Cmd lends the press to
|
||||
/// Direct Selection or Group Selection.
|
||||
pub fn selects_behind_at(cx: &ToolContext, p: Point) -> bool {
|
||||
let tol = cx.pick_tol();
|
||||
// The selection's painted bounds come first: away from them, no document walk is needed. They
|
||||
// take in a wide stroke's outer half, which the bounding box leaves out without Use Preview
|
||||
// Bounds.
|
||||
cx.select_behind
|
||||
&& painted_bounds(cx).is_some_and(|b| b.inflate(tol, tol).contains(p))
|
||||
&& objects_at(cx.doc, p, cx.selection_hit_options(), cx.isolation).iter().any(|id| cx.selection.contains(*id))
|
||||
&& !crate::direct::over_selected_part(cx, p)
|
||||
}
|
||||
|
||||
/// Select Behind: of the objects under `p` (topmost first), the one below the lowest selected
|
||||
/// one, back to the topmost after the bottom one; the topmost when none is selected.
|
||||
fn object_behind(cx: &ToolContext, p: Point) -> Option<NodeId> {
|
||||
|
||||
Reference in new issue
Block a user