mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 11:51:05 +01: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 <223278896+SofiaAFigueredo@users.noreply.github.com>
This commit is contained in:
1 parent
9fff48d88f
commit
dcff4edc3d
19 files changed
+532
-76
No files matched your search
@@ -106,6 +106,16 @@ pub struct Session {
|
||||
/// The selection tool chosen last (Selection, Direct Selection or Group Selection): the one Cmd
|
||||
/// lends the other tools. None until one is chosen.
|
||||
pub(crate) last_selection_tool: Option<&'static str>,
|
||||
/// Direct Selection or Group Selection, whichever was chosen last: the one Cmd lends the
|
||||
/// Selection tool. None until one is chosen.
|
||||
pub(crate) last_part_selection_tool: Option<&'static str>,
|
||||
/// The selection tool Cmd lent the last press, which also takes the double-click or
|
||||
/// triple-click that follows it. None when the press was not lent.
|
||||
pub(crate) press_lent: Option<&'static str>,
|
||||
/// The selection tool a Cmd press would borrow at the pointer, as [`Session::hover_tool_at`]
|
||||
/// or [`Session::cursor`] last found it with Cmd held (None inside when it found none). None when it was last asked
|
||||
/// without Cmd.
|
||||
pub(crate) hover_lent: Option<Option<&'static str>>,
|
||||
pub(crate) last_view: ViewInfo,
|
||||
/// The selection tools' measurements for the active document as it is: a pointer move or a
|
||||
/// cursor asked for again over an unchanged document and selection measures nothing again.
|
||||
|
||||
@@ -65,6 +65,9 @@ impl Session {
|
||||
selection_at_lend: None,
|
||||
lent_selection: None,
|
||||
last_selection_tool: None,
|
||||
last_part_selection_tool: None,
|
||||
press_lent: None,
|
||||
hover_lent: None,
|
||||
last_view: ViewInfo::default(),
|
||||
preview_memo: Default::default(),
|
||||
depth: 0,
|
||||
|
||||
@@ -4698,6 +4698,161 @@ fn cmd_alt_lends_group_selection_while_direct_selection_is_active() {
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 80.0, 80.0).with_mods(cmd_alt), v).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_lends_the_selection_tool_direct_selection_or_group_selection_chosen_last() {
|
||||
// Cmd held with the Selection tool: Direct Selection takes the press until the release, so a
|
||||
// Cmd-click picks one path inside a group where a plain click picks the group.
|
||||
let (none, cmd) = (Mods::default(), Mods { cmd: true, ..Mods::default() });
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 100.0, 100.0, 100.0, 100.0);
|
||||
let b = rect(&mut s, 300.0, 100.0, 100.0, 100.0);
|
||||
let group = NodeId(s.execute("object.group", &json!({"ids": [a.0, b.0]})).unwrap()["id"].as_u64().unwrap());
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
s.select_tool("selection", v).unwrap();
|
||||
assert_eq!(s.lent_tool_id(&none), None);
|
||||
assert_eq!(s.lent_tool_id(&cmd), Some("directSelection"));
|
||||
assert_eq!(s.shown_tool_id(&cmd), "directSelection");
|
||||
assert_eq!(s.shown_tool_id(&none), "selection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 150.0, 150.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 150.0, 150.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
let picked = &s.active().unwrap().selection;
|
||||
assert!(picked.contains(a) && !picked.contains(group), "the Cmd-click picks the path, not its group");
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 150.0, 150.0), v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 150.0, 150.0), v).unwrap();
|
||||
assert!(s.active().unwrap().selection.contains(group), "a plain click picks the group");
|
||||
// Cmd pressed once a drag is under way lends nothing: the pointer and the named tool stay.
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 600.0, 500.0), v).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Drag, 650.0, 550.0), v).unwrap();
|
||||
assert_eq!(s.cursor(Point::new(650.0, 550.0), cmd, v), s.cursor(Point::new(650.0, 550.0), none, v));
|
||||
assert_eq!(s.shown_tool_id(&cmd), "selection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 650.0, 550.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
// Group Selection lends the Selection tool, and once chosen, is what the Selection tool borrows.
|
||||
s.select_tool("groupSelection", v).unwrap();
|
||||
assert_eq!(s.lent_tool_id(&cmd), Some("selection"));
|
||||
s.select_tool("selection", v).unwrap();
|
||||
assert_eq!(s.lent_tool_id(&cmd), Some("groupSelection"));
|
||||
s.select_tool("directSelection", v).unwrap();
|
||||
s.select_tool("selection", v).unwrap();
|
||||
assert_eq!(s.lent_tool_id(&cmd), Some("directSelection"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cmd_double_click_goes_to_the_tool_the_clicks_went_to() {
|
||||
// With the Selection tool, Cmd-clicks go to Direct Selection, and so does the double-click
|
||||
// after them: it does not isolate the group as the Selection tool's double-click would.
|
||||
let cmd = Mods { cmd: true, ..Mods::default() };
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 100.0, 100.0, 100.0, 100.0);
|
||||
let b = rect(&mut s, 300.0, 100.0, 100.0, 100.0);
|
||||
s.execute("object.group", &json!({"ids": [a.0, b.0]})).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
s.select_tool("selection", v).unwrap();
|
||||
for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] {
|
||||
s.pointer(&PointerEvent::new(kind, 150.0, 150.0).with_mods(cmd), v).unwrap();
|
||||
}
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
assert_eq!(s.doc().unwrap().isolation, None, "Direct Selection's double-click does not isolate the group");
|
||||
// With Group Selection chosen last, the second click selects the group, and the double-click
|
||||
// still goes to Group Selection, as both clicks did.
|
||||
s.select_tool("groupSelection", v).unwrap();
|
||||
s.select_tool("selection", v).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] {
|
||||
s.pointer(&PointerEvent::new(kind, 150.0, 150.0).with_mods(cmd), v).unwrap();
|
||||
}
|
||||
assert_eq!(s.doc().unwrap().isolation, None, "Group Selection's double-click does not isolate the group");
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
// A plain double-click is the Selection tool's: it isolates the group.
|
||||
for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] {
|
||||
s.pointer(&PointerEvent::new(kind, 150.0, 150.0), v).unwrap();
|
||||
}
|
||||
assert!(s.doc().unwrap().isolation.is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cmd_press_on_a_selected_object_keeps_select_behind() {
|
||||
// Over a selected object, a Cmd-click with the Selection tool selects the object behind it;
|
||||
// with Select Behind off, Direct Selection takes the press there too.
|
||||
let cmd = Mods { cmd: true, ..Mods::default() };
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
let back = rect(&mut s, 100.0, 100.0, 200.0, 200.0);
|
||||
let front = rect(&mut s, 150.0, 150.0, 100.0, 100.0);
|
||||
s.select_tool("selection", v).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [front.0]})).unwrap();
|
||||
// The canvas shows the marks of the tool a press at the pointer takes.
|
||||
s.cursor(Point::new(200.0, 200.0), cmd, v);
|
||||
assert_eq!(s.hover_tool_id(&cmd), "selection");
|
||||
s.cursor(Point::new(500.0, 500.0), cmd, v);
|
||||
assert_eq!(s.hover_tool_id(&cmd), "directSelection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 200.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 200.0, 200.0).with_mods(cmd), v).unwrap();
|
||||
let picked = &s.active().unwrap().selection;
|
||||
assert!(picked.contains(back) && !picked.contains(front), "the Cmd-click selects the object behind");
|
||||
// On a selected object's anchor, Direct Selection takes the press.
|
||||
s.execute("select.set", &json!({"ids": [front.0]})).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 250.0, 250.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 250.0, 250.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
s.prefs.ctrl_click_selects_behind = false;
|
||||
s.execute("select.set", &json!({"ids": [front.0]})).unwrap();
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, 200.0, 200.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "directSelection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, 200.0, 200.0).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cmd_press_on_a_wide_strokes_outer_half_selects_behind() {
|
||||
// Without Use Preview Bounds the bounding box leaves out the outer half of a wide stroke, which
|
||||
// the Selection tool still hits: a Cmd press there selects the object behind.
|
||||
let cmd = Mods { cmd: true, ..Mods::default() };
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
assert!(!s.prefs.use_preview_bounds);
|
||||
let back = rect(&mut s, 50.0, 50.0, 300.0, 300.0);
|
||||
let front = rect(&mut s, 150.0, 150.0, 100.0, 100.0);
|
||||
s.execute("stroke.set", &json!({"ids": [front.0], "weight": 40})).unwrap();
|
||||
s.select_tool("selection", v).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [front.0]})).unwrap();
|
||||
// 15 pt outside the path, on its stroke.
|
||||
let at = Point::new(200.0, 135.0);
|
||||
assert_eq!(s.hover_tool_at(Some(at), &cmd, v), "selection", "the press selects behind");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Down, at.x, at.y).with_mods(cmd), v).unwrap();
|
||||
assert_eq!(s.tool_id(), "selection");
|
||||
s.pointer(&PointerEvent::new(PointerKind::Up, at.x, at.y).with_mods(cmd), v).unwrap();
|
||||
let picked = &s.active().unwrap().selection;
|
||||
assert!(picked.contains(back) && !picked.contains(front), "the Cmd-click selects the object behind");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_marks_follow_this_frames_pointer_with_cmd_held() {
|
||||
// The canvas asks which tool's marks to draw before it asks for the cursor: the answer is for
|
||||
// the pointer where it is now, and with the pointer off the canvas, the tool Cmd lends.
|
||||
let cmd = Mods { cmd: true, ..Mods::default() };
|
||||
let v = view();
|
||||
let mut s = session();
|
||||
rect(&mut s, 100.0, 100.0, 200.0, 200.0);
|
||||
let front = rect(&mut s, 150.0, 150.0, 100.0, 100.0);
|
||||
s.select_tool("selection", v).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [front.0]})).unwrap();
|
||||
s.cursor(Point::new(200.0, 200.0), cmd, v);
|
||||
assert_eq!(s.hover_tool_id(&cmd), "selection");
|
||||
assert_eq!(s.hover_tool_at(Some(Point::new(500.0, 500.0)), &cmd, v), "directSelection", "away from the selection");
|
||||
assert_eq!(s.hover_tool_at(Some(Point::new(200.0, 200.0)), &cmd, v), "selection", "over the selection");
|
||||
assert_eq!(s.hover_tool_at(None, &cmd, v), "directSelection", "off the canvas");
|
||||
assert_eq!(s.hover_tool_id(&cmd), "directSelection", "kept while the view moves");
|
||||
assert_eq!(s.hover_tool_at(None, &Mods::default(), v), "selection", "without Cmd");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_lends_the_selection_tool_and_its_bounding_box_to_direct_selection() {
|
||||
// #3901: with Direct Selection, Cmd held gives the Selection tool for the press: its cursor,
|
||||
|
||||
@@ -204,6 +204,9 @@ impl Session {
|
||||
}
|
||||
if vectorcraft_tools::catalog::is_selection_tool(id) {
|
||||
self.last_selection_tool = Some(self.tool.id());
|
||||
if id != "selection" {
|
||||
self.last_part_selection_tool = Some(self.tool.id());
|
||||
}
|
||||
self.select_whole_instance(id);
|
||||
}
|
||||
Ok(())
|
||||
@@ -247,8 +250,10 @@ impl Session {
|
||||
/// selection tool from other tools (Alt on the lent Direct Selection gesture stays copy/subtract).
|
||||
/// Cmd alone lends Direct Selection the Selection tool, whose bounding box transforms the
|
||||
/// object (#3901; <https://community.adobe.com/t5/illustrator-discussions/handles-disappar-on-shape-with-direct-selection-tool/m-p/14848662>).
|
||||
/// Group Selection lends the Selection tool, and the Selection tool lends Direct Selection or
|
||||
/// Group Selection, whichever was chosen last (Direct Selection until one is).
|
||||
/// Perspective Selection keeps Cmd+Alt drags to copy objects on their perspective plane.
|
||||
/// None for the other selection tools and the view tools.
|
||||
/// None for the view tools.
|
||||
fn lent_tool(&self, id: &str, mods: &Mods) -> Option<&'static str> {
|
||||
use vectorcraft_tools::catalog::{edits_anchors, is_selection_tool};
|
||||
if matches!(id, "hand" | "zoom" | "rotateView") {
|
||||
@@ -257,6 +262,12 @@ impl Session {
|
||||
if id == "directSelection" && mods.cmd {
|
||||
return Some(if mods.alt { "groupSelection" } else { "selection" });
|
||||
}
|
||||
if id == "groupSelection" && mods.cmd {
|
||||
return Some("selection");
|
||||
}
|
||||
if id == "selection" && mods.cmd {
|
||||
return Some(self.last_part_selection_tool.unwrap_or("directSelection"));
|
||||
}
|
||||
if id == "perspectiveSelection" && mods.cmd && mods.alt {
|
||||
return None;
|
||||
}
|
||||
@@ -276,15 +287,80 @@ impl Session {
|
||||
self.lent_tool(self.tool.id(), mods)
|
||||
}
|
||||
|
||||
/// A press with Cmd held (Ctrl elsewhere) and any other tool than a selection tool: the
|
||||
/// selection tool [`Self::lent_tool`] takes the gesture, pressing without Cmd (a plain click,
|
||||
/// not Select Behind). The tool lent to stays as it was, unaware, until the release. → the event
|
||||
/// for the tool, and the warnings of a preview that keeping the typing applied.
|
||||
fn lend_selection_tool(&mut self, ev: &PointerEvent) -> Result<(PointerEvent, Vec<String>)> {
|
||||
if ev.kind != PointerKind::Down || !ev.mods.cmd || self.lender.is_some() {
|
||||
/// The tool the status bar and the help bar name with `mods` held: the selection tool Cmd
|
||||
/// lends ([`Self::lent_tool_id`]) while the button is up, Space does not lend a view tool and
|
||||
/// the active tool is not computing an edit, else the active tool. Over a selected object where
|
||||
/// a Cmd press selects behind, it still names the tool Cmd lends elsewhere.
|
||||
pub fn shown_tool_id(&self, mods: &Mods) -> &'static str {
|
||||
match self.lent_tool_id(mods) {
|
||||
Some(id) if !mods.space && !self.tool_editing() && !self.pointer_held => id,
|
||||
_ => self.tool.id(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The tool whose marks the canvas shows with `mods` held: the selection tool a Cmd press at
|
||||
/// the pointer would borrow, as [`Self::hover_tool_at`] or [`Self::cursor`] last found it
|
||||
/// (before either has, the one [`Self::lent_tool_id`] names), else the active tool. The canvas
|
||||
/// asks this while the view moves, when it does not hit-test the art under the pointer.
|
||||
pub fn hover_tool_id(&self, mods: &Mods) -> &'static str {
|
||||
let lent = self.hover_lent.unwrap_or_else(|| self.lent_tool_id(mods));
|
||||
match lent {
|
||||
Some(id) if mods.cmd && !mods.space && self.lender.is_none() && !self.tool_editing() && !self.pointer_held => id,
|
||||
_ => self.tool.id(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The tool whose marks and widgets the canvas draws this frame with `mods` held and the
|
||||
/// pointer at `p` (None off the canvas): the selection tool a Cmd press there would borrow
|
||||
/// ([`Self::lent_tool_at`]; off the canvas, the one [`Self::lent_tool_id`] names), else the
|
||||
/// active tool. [`Self::hover_tool_id`] then answers the same until the pointer or the keys move.
|
||||
pub fn hover_tool_at(&mut self, p: Option<Point>, mods: &Mods, view: ViewInfo) -> &'static str {
|
||||
let lends = mods.cmd && !mods.space && self.lender.is_none() && !self.tool_editing() && !self.pointer_held;
|
||||
let lent = match p {
|
||||
_ if !lends => None,
|
||||
Some(p) => self.lent_tool_at(p, mods, view),
|
||||
None => self.lent_tool_id(mods),
|
||||
};
|
||||
self.hover_lent = lends.then_some(lent);
|
||||
lent.unwrap_or(self.tool.id())
|
||||
}
|
||||
|
||||
/// The selection tool a press at `p` with `mods` borrows ([`Self::lent_tool`]): none when
|
||||
/// the Selection tool keeps a Cmd press on a selected object to select the object behind it
|
||||
/// (Selection & Anchor Display › Command Click to Select Objects Behind).
|
||||
fn lent_tool_at(&mut self, p: Point, mods: &Mods, view: ViewInfo) -> Option<&'static str> {
|
||||
let id = self.lent_tool(self.tool.id(), mods)?;
|
||||
let behind = self.tool.id() == "selection" && self.with_tool_cx(view, |_, cx| vectorcraft_tools::select::selects_behind_at(cx, p));
|
||||
(!behind).then_some(id)
|
||||
}
|
||||
|
||||
/// Is the press `ev` lent a selection tool ([`Self::lend_selection_tool`])? The frontend asks
|
||||
/// before the press, to tell a gesture of the tool in hand from one of a lent tool.
|
||||
pub fn press_lends_tool(&mut self, ev: &PointerEvent, view: ViewInfo) -> bool {
|
||||
ev.kind == PointerKind::Down && ev.mods.cmd && self.lender.is_none() && self.lent_tool_at(ev.pos, &ev.mods, view).is_some()
|
||||
}
|
||||
|
||||
/// A press with Cmd held (Ctrl elsewhere): the selection tool [`Self::lent_tool_at`] names
|
||||
/// takes the gesture, pressing without Cmd (a plain click, not Select Behind). The tool lent to
|
||||
/// stays as it was, unaware, until the release. With a selection tool active, the double-click
|
||||
/// or triple-click that follows Cmd-clicks goes to the tool the clicks went to, with Cmd kept
|
||||
/// (Cmd+Shift releases a guide), and that tool is given back after it. → the event for the tool,
|
||||
/// and the warnings of a preview that keeping the typing applied.
|
||||
fn lend_selection_tool(&mut self, ev: &PointerEvent, view: ViewInfo) -> Result<(PointerEvent, Vec<String>)> {
|
||||
let follow_up =
|
||||
matches!(ev.kind, PointerKind::DoubleClick | PointerKind::TripleClick) && vectorcraft_tools::catalog::is_selection_tool(self.tool.id());
|
||||
if ev.kind == PointerKind::Down {
|
||||
self.press_lent = None;
|
||||
}
|
||||
if (ev.kind != PointerKind::Down && !follow_up) || !ev.mods.cmd || self.lender.is_some() {
|
||||
return Ok((*ev, vec![]));
|
||||
}
|
||||
let Some(id) = self.lent_tool(self.tool.id(), &ev.mods) else { return Ok((*ev, vec![])) };
|
||||
// A follow-up goes where the press before it went, whatever that press selected.
|
||||
let id = if follow_up { self.press_lent } else { self.lent_tool_at(ev.pos, &ev.mods, view) };
|
||||
let Some(id) = id else { return Ok((*ev, vec![])) };
|
||||
if !follow_up {
|
||||
self.press_lent = Some(id);
|
||||
}
|
||||
// Typing in progress is kept as its own step first: the lent tool's drag previews from the
|
||||
// document its interaction started from, which would drop the typing (#1881). When it
|
||||
// can't be kept, the press is not lent.
|
||||
@@ -312,7 +388,8 @@ impl Session {
|
||||
}
|
||||
self.selection_at_lend = self.active().map(|d| (d.uid, d.selection.clone()));
|
||||
self.lender = Some(std::mem::replace(&mut self.tool, lent));
|
||||
Ok((PointerEvent { mods: Mods { cmd: false, ..ev.mods }, ..*ev }, settled))
|
||||
let cmd = follow_up && ev.mods.cmd;
|
||||
Ok((PointerEvent { mods: Mods { cmd, ..ev.mods }, ..*ev }, settled))
|
||||
}
|
||||
|
||||
/// The lent selection tool's gesture is over: the tool it was lent to is back as it was (the
|
||||
@@ -331,6 +408,9 @@ impl Session {
|
||||
let r = self.deactivate_tool(view);
|
||||
self.keep_tool_settings();
|
||||
self.tool = lender;
|
||||
// Back with the Selection or Group Selection tool, a symbol part the lent Direct
|
||||
// Selection picked gives way to its instance, as choosing the tool does.
|
||||
self.select_whole_instance(self.tool.id());
|
||||
if let Some(points) = mesh_points {
|
||||
self.tool.set_option("meshPoints", &points);
|
||||
}
|
||||
@@ -754,7 +834,7 @@ impl Session {
|
||||
}
|
||||
self.leave_draw_inside(ev, view)?;
|
||||
self.tell_tool_history_moved();
|
||||
let (ev, settled) = self.lend_selection_tool(ev)?;
|
||||
let (ev, settled) = self.lend_selection_tool(ev, view)?;
|
||||
let ev = &ev;
|
||||
let lent = self.lender.is_some();
|
||||
let mut acts = self.with_tool_cx(view, |t, cx| t.pointer(cx, ev));
|
||||
@@ -778,7 +858,7 @@ impl Session {
|
||||
PointerKind::Up => self.press_point = None,
|
||||
_ => {}
|
||||
}
|
||||
if ev.kind == PointerKind::Up {
|
||||
if ev.kind == PointerKind::Up || (lent && matches!(ev.kind, PointerKind::DoubleClick | PointerKind::TripleClick)) {
|
||||
self.give_back_tool(view)?;
|
||||
}
|
||||
r
|
||||
@@ -1321,7 +1401,10 @@ impl Session {
|
||||
/// press would borrow ([`Self::lend_selection_tool`]).
|
||||
pub fn cursor(&mut self, p: Point, mods: Mods, view: ViewInfo) -> Cursor {
|
||||
// While an edit is computed, a Cmd press is held for the active tool, which shows it is busy.
|
||||
let lent = if mods.cmd && self.lender.is_none() && !self.tool_editing() { self.lent_tool(self.tool.id(), &mods) } else { None };
|
||||
// Cmd pressed once a drag is under way lends nothing, so the tool keeps its pointer.
|
||||
let lends = mods.cmd && self.lender.is_none() && !self.tool_editing() && !self.pointer_held;
|
||||
let lent = if lends { self.lent_tool_at(p, &mods, view) } else { None };
|
||||
self.hover_lent = lends.then_some(lent);
|
||||
let c = match lent {
|
||||
Some(id) => {
|
||||
let lent = self.make_tool(id);
|
||||
|
||||
Reference in new issue
Block a user