mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Smart Guides: Distance Guides follow what lies under a still pointer
One rule for the hover's context (PR review follow-ups): the target is recomputed where the pointer is, or cleared, whenever what lies under it can change while Alt is held. - The tool hovers only where the pointer is on the canvas itself (`on_canvas`): under a floating panel, a menu, a popup or a dialog its hover ends (Tool::hover_ended), as when the pointer leaves the canvas or a pan, zoom or view-rotation press starts. - The canvas keeps the hover's context: its rect, the view's centre, zoom and rotation, and the active document's id and revision (which moves with every edit, undo and selection change). When it changes under a still pointer, a tool that asks (Tool::wants_rehover; the Selection tool after an Alt hover) is hovered again at the pointer, so wheel, gesture, key or command scrolling and zooming, tab switches, edits and undos re-measure. - Coming back onto the canvas re-hovers the tool. canvas::tests::distance_guides_follow_what_lies_under_a_still_pointer: a floating window over the pointer (fails without the on_canvas filter), a 150 pt scroll that leaves empty artboard under it (fails without the re-hover), a square made under it. select::tests::distance_guides_need_ alt_a_selection_and_smart_guides checks wants_rehover.
This commit is contained in:
committed by
bflatastic
parent
26bf324c81
commit
7693aeb508
@@ -444,6 +444,12 @@ impl Session {
|
||||
self.with_tool_cx(view, |t, cx| t.hover_ended(cx));
|
||||
}
|
||||
|
||||
/// Whether the active tool's hover depends on what lies under a still pointer
|
||||
/// ([`vectorcraft_tools::Tool::wants_rehover`]).
|
||||
pub fn tool_wants_rehover(&self) -> bool {
|
||||
self.tool.wants_rehover()
|
||||
}
|
||||
|
||||
pub fn tool_busy(&self) -> bool {
|
||||
self.tool.busy()
|
||||
}
|
||||
|
||||
@@ -814,9 +814,16 @@ pub trait Tool: Send {
|
||||
}
|
||||
fn notify(&mut self, _cx: &ToolContext, _what: &str) {}
|
||||
/// The pointer stopped hovering for the tool while it holds no press: it left the canvas (for a
|
||||
/// panel or out of the window), or a press started panning, zooming or turning the view. Drop
|
||||
/// what shows only for the hover (the Selection tool's Distance Guides).
|
||||
/// panel or out of the window), went under a floating panel, menu, popup or dialog, or a press
|
||||
/// started panning, zooming or turning the view. Drop what shows only for the hover (the
|
||||
/// Selection tool's Distance Guides).
|
||||
fn hover_ended(&mut self, _cx: &ToolContext) {}
|
||||
/// Whether what the tool shows for the hover depends on what lies under a still pointer: then
|
||||
/// the canvas hovers it again where the pointer is when the view, the document or the
|
||||
/// selection changes (the Selection tool while Alt shows Distance Guides).
|
||||
fn wants_rehover(&self) -> bool {
|
||||
false
|
||||
}
|
||||
/// Called when the user switches away (finish pending work).
|
||||
fn deactivate(&mut self, _cx: &ToolContext) -> Vec<Action> {
|
||||
vec![]
|
||||
|
||||
@@ -113,6 +113,9 @@ pub struct SelectionTool {
|
||||
hover: Option<(Point, &'static str)>,
|
||||
/// Distance Guides: what Alt held over it measures the selection to ([`distance_target`]).
|
||||
distance: Option<DistanceTo>,
|
||||
/// The last hover had Alt held: what it measures depends on what lies under the pointer
|
||||
/// ([`Tool::wants_rehover`]).
|
||||
alt_hover: bool,
|
||||
}
|
||||
|
||||
/// What Distance Guides measure the selection to.
|
||||
@@ -564,6 +567,11 @@ impl Tool for SelectionTool {
|
||||
fn hover_ended(&mut self, _cx: &ToolContext) {
|
||||
self.hover = None;
|
||||
self.distance = None;
|
||||
self.alt_hover = false;
|
||||
}
|
||||
|
||||
fn wants_rehover(&self) -> bool {
|
||||
self.alt_hover
|
||||
}
|
||||
|
||||
fn transforming(&self) -> bool {
|
||||
@@ -578,7 +586,9 @@ impl Tool for SelectionTool {
|
||||
}
|
||||
|
||||
fn pointer(&mut self, cx: &ToolContext, ev: &PointerEvent) -> Vec<Action> {
|
||||
self.distance = (ev.kind == PointerKind::Move && matches!(self.state, State::Idle)).then(|| distance_target(cx, ev.pos, ev.mods)).flatten();
|
||||
let hovering = ev.kind == PointerKind::Move && matches!(self.state, State::Idle);
|
||||
self.alt_hover = hovering && ev.mods.alt;
|
||||
self.distance = hovering.then(|| distance_target(cx, ev.pos, ev.mods)).flatten();
|
||||
if let State::Loaded { from, press } = self.state
|
||||
&& let Some(out) = self.loaded(cx, ev, from, press)
|
||||
{
|
||||
@@ -1305,8 +1315,12 @@ mod tests {
|
||||
// So does the hover ending (the pointer leaving the canvas) with Alt still held.
|
||||
t.pointer(&cx, &alt(PointerKind::Move, 350.0, 150.0));
|
||||
assert!(!distances(&t, &cx).0.is_empty());
|
||||
assert!(t.wants_rehover(), "an Alt hover is hovered again when what lies under it changes");
|
||||
t.hover_ended(&cx);
|
||||
assert!(distances(&t, &cx).0.is_empty());
|
||||
assert!(!t.wants_rehover());
|
||||
t.pointer(&cx, &ev(PointerKind::Move, 350.0, 150.0));
|
||||
assert!(!t.wants_rehover(), "nor without Alt");
|
||||
// A press ends them too.
|
||||
t.pointer(&cx, &alt(PointerKind::Move, 350.0, 150.0));
|
||||
t.pointer(&cx, &alt(PointerKind::Down, 350.0, 150.0));
|
||||
|
||||
@@ -108,6 +108,10 @@ fn tool_holds(d: Drag) -> bool {
|
||||
matches!(d, Drag::Tool | Drag::Art)
|
||||
}
|
||||
|
||||
/// What a hover depends on besides the pointer's screen position: the canvas, the view's centre,
|
||||
/// zoom and rotation, and the active document's id and revision (which moves with the selection).
|
||||
type HoverContext = (egui::Rect, Point, f64, f64, Option<(u64, u64)>);
|
||||
|
||||
/// Clear canvas interaction state before a tab transfer takes ownership of the artwork drag.
|
||||
pub(crate) fn end_document_drag(ctx: &egui::Context) {
|
||||
ctx.data_mut(|d| {
|
||||
@@ -961,14 +965,28 @@ fn handle_input(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Response, rect:
|
||||
d.insert_temp(id, m);
|
||||
prev.is_some_and(|prev| prev != m)
|
||||
});
|
||||
// Whether the pointer was over the canvas last frame: coming onto it re-hovers the tool, even
|
||||
// after a single jump egui doesn't count as moving, and leaving it tells the tool (below).
|
||||
// Where the tool hovers: the pointer over the canvas itself, not over a floating panel, a menu,
|
||||
// a popup or a dialog drawn on top of it ([`on_canvas`]).
|
||||
let hover_tool = hover.filter(|p| on_canvas(ui, resp, *p));
|
||||
// Whether the tool hovered last frame: coming onto the canvas re-hovers it, even after a single
|
||||
// jump egui doesn't count as moving, and leaving it ends the tool's hover (below).
|
||||
let was_over = ui.data_mut(|d| {
|
||||
let id = egui::Id::new("canvas-hovered");
|
||||
let prev = d.get_temp::<bool>(id).unwrap_or(false);
|
||||
d.insert_temp(id, hover.is_some());
|
||||
d.insert_temp(id, hover_tool.is_some());
|
||||
prev
|
||||
});
|
||||
// What a hover means besides where the pointer is on screen: the canvas, the view (scrolled,
|
||||
// zoomed or turned by the wheel, a gesture, keys or a command) and the document and selection
|
||||
// as they are (another tab, an edit, an undo). When it changes under a still pointer, a tool
|
||||
// that asks for it ([`Session::tool_wants_rehover`]) is hovered again where the pointer is.
|
||||
let context = (rect, v.center, v.zoom, v.rotation, app.session.active().map(|st| (st.uid, st.revision)));
|
||||
let context_changed = ui.data_mut(|d| {
|
||||
let id = egui::Id::new("canvas-hover-context");
|
||||
let prev = d.get_temp::<HoverContext>(id);
|
||||
d.insert_temp(id, context);
|
||||
prev.is_some_and(|prev| prev != context)
|
||||
});
|
||||
|
||||
// In Presentation Mode a click anywhere goes to the next artboard. The tool receives no press,
|
||||
// drag or hover, and a drag does not pan the view. A drag that began before the mode was turned
|
||||
@@ -1208,16 +1226,16 @@ fn handle_input(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Response, rect:
|
||||
Drag::Pan { .. } | Drag::RotateView { .. } => {}
|
||||
}
|
||||
}
|
||||
} else if let Some(p) = hover
|
||||
&& (pointer.is_moving() || mods_changed || !was_over)
|
||||
} else if let Some(p) = hover_tool
|
||||
&& (pointer.is_moving() || mods_changed || !was_over || (context_changed && app.session.tool_wants_rehover()))
|
||||
{
|
||||
let ev = PointerEvent { kind: PointerKind::Move, pos: xf.to_doc(p), mods: mods(m, space), pressure: 1.0 };
|
||||
dispatch(app, &ev, view);
|
||||
}
|
||||
// The pointer left the canvas (for a panel, or out of the window) with no press the tool holds:
|
||||
// the tool drops what it showed for the hover, which no hover event would clear (Alt's
|
||||
// Distance Guides).
|
||||
if was_over && hover.is_none() && !drag.is_some_and(tool_holds) {
|
||||
// The pointer left the canvas (for a panel, or out of the window) or went under a floating
|
||||
// panel, menu, popup or dialog, with no press the tool holds: the tool's hover ends, which no
|
||||
// hover event would clear (Alt's Distance Guides).
|
||||
if was_over && hover_tool.is_none() && !drag.is_some_and(tool_holds) {
|
||||
app.session.tool_hover_ended(view);
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
@@ -9523,13 +9541,16 @@ mod tests {
|
||||
}
|
||||
|
||||
/// Distance Guides on a canvas at 100%: a 400 × 300 pt document with a 50 pt square at (50, 50),
|
||||
/// selected, and another 100 pt to its right, the Selection tool and Smart Guides on → the app,
|
||||
/// its context, the view and the screen point over the middle of the other square.
|
||||
fn distance_scene() -> (VectorcraftApp, egui::Context, Xf, Pos2) {
|
||||
/// selected, and with `other` another 100 pt to its right, the Selection tool and Smart Guides
|
||||
/// on → the app, its context, the view, the screen point over the middle of where the other
|
||||
/// square is (or would be) and the selected square's id.
|
||||
fn distance_scene(other: bool) -> (VectorcraftApp, egui::Context, Xf, Pos2, serde_json::Value) {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
let a = app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 50, "height": 50})).unwrap()["id"].clone();
|
||||
app.run("shape.rectangle", json!({"x": 200, "y": 50, "width": 50, "height": 50})).unwrap();
|
||||
if other {
|
||||
app.run("shape.rectangle", json!({"x": 200, "y": 50, "width": 50, "height": 50})).unwrap();
|
||||
}
|
||||
app.run("select.set", json!({"ids": [a]})).unwrap();
|
||||
app.ui.view.smart_guides = true;
|
||||
app.select_tool("selection");
|
||||
@@ -9542,14 +9563,27 @@ mod tests {
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
let xf = Xf::new(app.canvas_rect.unwrap(), app.view().unwrap());
|
||||
let over = xf.to_screen(Point::new(225.0, 75.0));
|
||||
(app, ctx, xf, over)
|
||||
(app, ctx, xf, over, a)
|
||||
}
|
||||
|
||||
/// One frame with `events` → the shapes drawn, flattened. The modifiers held stay from one
|
||||
/// frame to the next until an `Event::ModifiersChanged`.
|
||||
fn distance_frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>) -> Vec<Shape> {
|
||||
distance_frame_covered(app, ctx, events, None)
|
||||
}
|
||||
|
||||
/// [`distance_frame`] with a floating window over the canvas at `cover`, as a floating panel,
|
||||
/// a menu or a dialog would be.
|
||||
fn distance_frame_covered(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<egui::Event>, cover: Option<egui::Rect>) -> Vec<Shape> {
|
||||
let raw = egui::RawInput { screen_rect: Some(WINDOW), events, ..Default::default() };
|
||||
let mut out = ctx.run_ui(raw, |ui| show(app, ui));
|
||||
let mut out = ctx.run_ui(raw, |ui| {
|
||||
show(app, ui);
|
||||
if let Some(r) = cover {
|
||||
egui::Area::new(egui::Id::new("test-floating-panel")).order(egui::Order::Foreground).fixed_pos(r.min).show(ui.ctx(), |ui| {
|
||||
ui.allocate_space(r.size());
|
||||
});
|
||||
}
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
fn flat(s: Shape, out: &mut Vec<Shape>) {
|
||||
match s {
|
||||
@@ -9562,6 +9596,11 @@ mod tests {
|
||||
v
|
||||
}
|
||||
|
||||
/// The texts drawn in `s`.
|
||||
fn texts(s: &[Shape]) -> Vec<String> {
|
||||
s.iter().filter_map(|s| if let Shape::Text(t) = s { Some(t.galley.text().to_string()) } else { None }).collect()
|
||||
}
|
||||
|
||||
/// The label "100.00 pt" drawn in `s` and the pill of the smart guide colour it sits in, if any.
|
||||
fn gap_label(s: &[Shape]) -> Option<(egui::Rect, Option<egui::Rect>)> {
|
||||
let magenta = c32(vectorcraft_tools::guides::MAGENTA);
|
||||
@@ -9579,7 +9618,7 @@ mod tests {
|
||||
#[test]
|
||||
fn alt_over_another_object_draws_the_distance_guide_label() {
|
||||
use egui::{Event, Modifiers};
|
||||
let (mut app, ctx, xf, over) = distance_scene();
|
||||
let (mut app, ctx, xf, over, _) = distance_scene(true);
|
||||
let mut run = |events| distance_frame(&mut app, &ctx, events);
|
||||
run(vec![Event::PointerMoved(over)]);
|
||||
assert_eq!(gap_label(&run(vec![])), None, "without Alt");
|
||||
@@ -9603,7 +9642,7 @@ mod tests {
|
||||
#[test]
|
||||
fn distance_guides_go_when_the_hover_ends() {
|
||||
use egui::{Event, Modifiers};
|
||||
let (mut app, ctx, xf, over) = distance_scene();
|
||||
let (mut app, ctx, xf, over, _) = distance_scene(true);
|
||||
let outside = pos2(xf.rect.max.x + 10.0, xf.rect.center().y);
|
||||
assert!(WINDOW.contains(outside) && !xf.rect.contains(outside), "a panel beside the canvas");
|
||||
let mut run = |events| distance_frame(&mut app, &ctx, events);
|
||||
@@ -9630,6 +9669,46 @@ mod tests {
|
||||
run(vec![button(outside, false), space(false)]);
|
||||
}
|
||||
|
||||
/// With Alt held and the pointer still, the Distance Guides follow what lies under it: they go
|
||||
/// under a floating panel (or menu, popup, dialog) and come back when it goes; scrolled so that
|
||||
/// empty artboard lies under the pointer, they measure to the artboard; and when an edit puts
|
||||
/// an object under the pointer, they measure to it.
|
||||
#[test]
|
||||
fn distance_guides_follow_what_lies_under_a_still_pointer() {
|
||||
use egui::{Event, Modifiers};
|
||||
let (mut app, ctx, _, over, _) = distance_scene(true);
|
||||
let cover = Some(egui::Rect::from_center_size(over, vec2(120.0, 120.0)));
|
||||
let mut run = |app: &mut VectorcraftApp, events, cover| distance_frame_covered(app, &ctx, events, cover);
|
||||
run(&mut app, vec![Event::ModifiersChanged(Modifiers::ALT), Event::PointerMoved(over)], None);
|
||||
assert!(gap_label(&run(&mut app, vec![], None)).is_some(), "shown over the other square");
|
||||
// A floating panel opens under the still pointer.
|
||||
run(&mut app, vec![], cover);
|
||||
run(&mut app, vec![], cover);
|
||||
assert_eq!(gap_label(&run(&mut app, vec![], cover)), None, "gone under a floating panel");
|
||||
// A frame for egui to drop the closed panel's area, one for the hover to come back.
|
||||
run(&mut app, vec![], None);
|
||||
run(&mut app, vec![], None);
|
||||
assert!(gap_label(&run(&mut app, vec![], None)).is_some(), "back once it closes");
|
||||
// The view scrolls 150 pt (the wheel, a gesture, the keys): empty artboard is under the
|
||||
// pointer, and the selected square is 300 pt from the artboard's right edge.
|
||||
app.view_mut().unwrap().center.x += 150.0;
|
||||
run(&mut app, vec![], None);
|
||||
let s = run(&mut app, vec![], None);
|
||||
assert_eq!(gap_label(&s), None, "no longer over the other square");
|
||||
assert!(texts(&s).iter().any(|t| t == "300.00 pt"), "to the artboard: {:?}", texts(&s));
|
||||
|
||||
// A square made under the still pointer, the first selected again (an edit, an undo).
|
||||
let (mut app, ctx, _, over, a) = distance_scene(false);
|
||||
let mut run = |app: &mut VectorcraftApp, events| distance_frame(app, &ctx, events);
|
||||
run(&mut app, vec![Event::ModifiersChanged(Modifiers::ALT), Event::PointerMoved(over)]);
|
||||
let s = run(&mut app, vec![]);
|
||||
assert!(gap_label(&s).is_none() && texts(&s).iter().any(|t| t == "300.00 pt"), "to the artboard: {:?}", texts(&s));
|
||||
app.run("shape.rectangle", json!({"x": 200, "y": 50, "width": 50, "height": 50})).unwrap();
|
||||
app.run("select.set", json!({"ids": [a]})).unwrap();
|
||||
run(&mut app, vec![]);
|
||||
assert!(gap_label(&run(&mut app, vec![])).is_some(), "to the new square");
|
||||
}
|
||||
|
||||
/// The 800 × 600 window [`frame`] draws the canvas in.
|
||||
const WINDOW: egui::Rect = egui::Rect { min: Pos2::ZERO, max: Pos2 { x: 800.0, y: 600.0 } };
|
||||
|
||||
|
||||
@@ -689,7 +689,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
Panel Options › Locate Selected Objects (beyond Illustrator, off by default): when the last selected object changes on the canvas or by a command, the panel opens the layers and groups around it and scrolls to its row, as Locate Object does, without highlighting the row; when Show Layers Only, a search or the filter leaves the object without a row, the panel opens no rows for it and scrolls as with the option off.
|
||||
- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't).
|
||||
A move that Shift keeps level, upright or diagonal stays on that line when it snaps, with the Selection, Group Selection or Direct Selection tool. It slides along the line until the selection lands on the grid or on whole pixels, lines up with the other objects or is spaced evenly with them, or until the line passes an anchor or crosses a ruler guide near the point the selection was grabbed by. A level or upright move snaps along its own axis only.
|
||||
Distance Guides: with Smart Guides on (View › Smart Guides and Preferences › Smart Guides › Invoke Distance Guides, on by default), something selected and the Selection tool, holding Alt/Option over another object shows the distances between the selection's bounds and that object's: on an axis on which they lie apart, one line across the gap between their facing edges; on one on which they overlap, the offsets of their left and right (top and bottom) edges, each line running across the middle of where they overlap, with a dashed line out to the other object's edge when it passes beside it. Over an empty part of an artboard it shows the selection's distances from the artboard's left, right, top and bottom edges. Each line has ticks at its ends and its length in a pill of the smart guide colour, in the General unit; letting Alt go, pressing (a pan or zoom press too), moving off them or leaving the canvas takes them away. Behaviour from the public [Use Distance Guides for accurate placement](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/use-distance-guides-for-accurate-placement.html) and [Smart Guides options](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html) pages, which describe hovering only: nothing shows while moving or nudging. Tests: `select::tests::alt_over_*`, `select::tests::distance_guides_need_alt_a_selection_and_smart_guides`, `tests_prefs::invoke_distance_guides_measures_the_selection_to_the_object_under_alt`, `canvas::tests::alt_over_another_object_draws_the_distance_guide_label`, `canvas::tests::distance_guides_go_when_the_hover_ends`.
|
||||
Distance Guides: with Smart Guides on (View › Smart Guides and Preferences › Smart Guides › Invoke Distance Guides, on by default), something selected and the Selection tool, holding Alt/Option over another object shows the distances between the selection's bounds and that object's: on an axis on which they lie apart, one line across the gap between their facing edges; on one on which they overlap, the offsets of their left and right (top and bottom) edges, each line running across the middle of where they overlap, with a dashed line out to the other object's edge when it passes beside it. Over an empty part of an artboard it shows the selection's distances from the artboard's left, right, top and bottom edges. Each line has ticks at its ends and its length in a pill of the smart guide colour, in the General unit; letting Alt go, pressing (a pan or zoom press too), moving off them, leaving the canvas or a floating panel, menu or dialog over the pointer takes them away, and with the pointer still they follow what lies under it as the view scrolls, zooms or turns and as the document or the selection changes. Behaviour from the public [Use Distance Guides for accurate placement](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/use-distance-guides-for-accurate-placement.html) and [Smart Guides options](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html) pages, which describe hovering only: nothing shows while moving or nudging. Tests: `select::tests::alt_over_*`, `select::tests::distance_guides_need_alt_a_selection_and_smart_guides`, `tests_prefs::invoke_distance_guides_measures_the_selection_to_the_object_under_alt`, `canvas::tests::alt_over_another_object_draws_the_distance_guide_label`, `canvas::tests::distance_guides_go_when_the_hover_ends`, `canvas::tests::distance_guides_follow_what_lies_under_a_still_pointer`.
|
||||
A move pressed on a path's stroke, or within 6 px of its outline away from its anchors and center, is held by the nearest point of that path, with the Selection, Group Selection or Direct Selection tool, and a straight segment Direct Selection drags is held by its own nearest point. That point is what snaps, so the path lands exactly on a ruler guide (with "align") instead of the pressed spot landing there and the path a few pixels beside it, an offset that showed only zoomed far in (#3701). A press in the middle of a fill still snaps the pressed spot: the public [Align objects with guides](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/align-graphic-objects-with-guides.html) page has Snap to Point align the point under the pointer, which is placed exactly where the object should meet the guide.
|
||||
A bounding-box handle dragged with the Selection or Free Transform tool snaps what it moves as a dragged point snaps (#2054). With View › Snap to Grid on, it snaps to the nearest gridline, and with Snap to Pixel on, it snaps to whole pixels. With Smart Guides off and Snap to Point on, it snaps to the other objects' anchors and the ruler guides within the Snap to Point distance. With Smart Guides and Snap to Point both on, it lines up with the ruler guides as well as the other objects. Shift still keeps the proportions, and Alt still scales about the center.
|
||||
A user slice's edge or corner handle dragged with the Slice Selection tool snaps as the Slice tool's drag does. With View › Snap to Grid on, it snaps to the nearest gridline, and with Snap to Pixel on, it snaps to whole pixels. Otherwise, with Smart Guides on, it lands on or lines up with the anchors, centers and edges of the art and the artboards, and with Smart Guides off and Snap to Point on, it snaps to the art's anchors and the ruler guides within the Snap to Point distance. Then a ruler guide within 5 px, shown and unlocked, moves the side or corner onto it. Shift still keeps the proportions, and Alt still resizes about the center.
|
||||
|
||||
Reference in New Issue
Block a user