Rulers: the origin dragged out of the rulers' corner snaps as a drawn point does

The zero point dragged out of the box where the rulers meet snaps as a
Pen or shape tool's point does: with Smart Guides onto the anchors,
centres, edges and paths of the art and the artboards or into line with
them, with Snap to Point onto the anchors and along the ruler guides,
else onto whole pixels or the grid. The guides showing what it snapped
to show during the drag and go when it is released or cancelled
(Escape, focus loss, another document). The origin is still set once,
on release (document.setRulerOrigin, one undo step).

The engine snaps it (Session::ruler_origin_drag, with the tools crate's
rulerguide::OriginDrag over PointSnap::drawn), as it does a guide
dragged out of a ruler.
This commit is contained in:
Dan Green
2026-11-11 22:33:36 -08:00
parent 5eefe7d1c5
commit 949553b6ce
10 changed files with 147 additions and 9 deletions
+2
View File
@@ -306,6 +306,8 @@ pub struct Session {
pub(crate) press_point: Option<Option<(usize, cmd::gradient::StopOwner)>>,
/// A guide being dragged out of a ruler ([`Session::ruler_guide`]).
pub(crate) ruler_guide: Option<vectorcraft_tools::rulerguide::NewGuide>,
/// The rulers' origin being dragged out of their corner ([`Session::ruler_origin_drag`]).
pub(crate) ruler_origin: Option<vectorcraft_tools::rulerguide::OriginDrag>,
/// Which selected type overflows its frame, for the ports every tool but the Type tools shows.
pub(crate) port_marks: vectorcraft_tools::text::PortMarks,
/// The last search for the files of missing fonts (`text.findFontFiles`), until another
+1
View File
@@ -124,6 +124,7 @@ impl Session {
press_type_selection: None,
press_point: None,
ruler_guide: None,
ruler_origin: None,
port_marks: Default::default(),
font_search: None,
link_search: None,
+35
View File
@@ -4489,6 +4489,41 @@ fn cmd_ruler_drags_make_guides_of_the_active_artboard_when_the_preference_is_on(
assert_eq!(owners(&mut s)[4..], [Value::Null, json!(1)]);
}
/// The rulers' origin dragged out of their corner snaps as a drawn point does: onto a shape's
/// corner and edge, the artboard's centre, and with Snap to Point along a ruler guide; with
/// nothing on it stays at the pointer. The drag changes nothing, and its guides go when it ends.
#[test]
fn the_ruler_origin_dragged_from_the_corner_snaps_as_a_drawn_point() {
use vectorcraft_geom::Point;
let mut s = session();
rect(&mut s, 100.0, 100.0, 100.0, 100.0);
s.execute("guide.add", &json!({"vertical": true, "pos": 300})).unwrap();
let (n, doc) = (undo_len(&s), s.doc().unwrap().doc.clone());
let v = ViewInfo::default();
let at = |s: &mut Session, x, y| s.ruler_origin_drag(Some(Point::new(x, y)), v).unwrap();
assert_eq!(at(&mut s, 101.5, 98.5), Point::new(100.0, 100.0), "the corner");
assert!(!s.overlays(v).is_empty(), "the guide showing it");
assert_eq!(at(&mut s, 130.0, 202.0), Point::new(130.0, 200.0), "the bottom edge");
assert_eq!(at(&mut s, 398.0, 301.5), Point::new(400.0, 300.0), "the artboard's centre");
assert_eq!(at(&mut s, 302.0, 50.0).x, 300.0, "along the ruler guide");
assert_eq!(s.ruler_origin_drag(None, v), None, "off the canvas");
assert!(s.overlays(v).is_empty());
assert_eq!(at(&mut s, 101.5, 98.5), Point::new(100.0, 100.0));
s.end_ruler_origin_drag();
assert!(s.overlays(v).is_empty());
assert_eq!((undo_len(&s), &*s.doc().unwrap().doc), (n, &*doc), "nothing changed");
// Nothing on: it stays at the pointer.
let off = ViewInfo { smart_guides: false, snap_to_point: false, ..v };
assert_eq!(s.ruler_origin_drag(Some(Point::new(101.5, 98.5)), off), Some(Point::new(101.5, 98.5)));
s.end_ruler_origin_drag();
// Snap to Grid: onto a gridline crossing.
let grid = ViewInfo { snap_to_grid: true, ..v };
let p = s.ruler_origin_drag(Some(Point::new(101.5, 98.5)), grid).unwrap();
s.end_ruler_origin_drag();
assert_eq!(p, Point::new(p.x.round(), p.y.round()), "{p:?}");
assert_ne!(p, Point::new(101.5, 98.5));
}
/// Guides saved before guides had layers are put on a layer when the document opens.
#[test]
fn guides_from_older_files_are_put_on_a_layer() {
+24
View File
@@ -751,6 +751,27 @@ impl Session {
self.apply_actions(acts).map(drop)
}
/// The rulers' origin dragged out of their corner, whatever the tool, with the pointer at `p` in
/// document space (none off the canvas): where it goes, snapped as a drawn point is
/// ([`vectorcraft_tools::rulerguide::OriginDrag`]), the targets gathered on the drag's first
/// call. It changes nothing: the caller sets the origin where the button is released
/// (`document.setRulerOrigin`) and ends the drag ([`Session::end_ruler_origin_drag`]).
pub fn ruler_origin_drag(&mut self, p: Option<Point>, view: ViewInfo) -> Option<Point> {
let drag = match self.ruler_origin.take() {
Some(d) => Some(d),
None => self.with_tool_cx(view, |_, cx| Some(vectorcraft_tools::rulerguide::OriginDrag::new(cx))),
};
let Some(mut drag) = drag else { return p };
let at = self.with_tool_cx(view, |_, cx| drag.pointer(cx, p));
self.ruler_origin = Some(drag);
at
}
/// The drag of the rulers' origin ended, released or cancelled: its guides go.
pub fn end_ruler_origin_drag(&mut self) {
self.ruler_origin = None;
}
/// Time passed while the pointer button is held (`dt` seconds; see [`Tool::tick`]): the
/// desktop app ticks every frame of a press, agents with `holdMs` on a pointer event.
pub fn tool_tick(&mut self, dt: f64, view: ViewInfo) -> Result<Vec<UiRequest>> {
@@ -1112,6 +1133,9 @@ impl Session {
v.extend(self.with_tool_cx(view, |_, cx| g.overlays(cx)));
self.ruler_guide = Some(g);
}
if let Some(d) = &self.ruler_origin {
v.extend(d.overlays());
}
let deferred_preview = self.unapplied_interaction_preview();
if let Some(d) = self.active() {
let w = self.prefs.perspective_widget;
+7
View File
@@ -119,6 +119,13 @@ impl PointSnap {
Self { targets }
}
/// Snapping for a point placed anywhere, as a drawing tool's ([`DrawSnap`]) is: the art in the
/// window as targets ([`Targets::for_drawing`]), live text as Snap to Glyph asks.
pub fn drawn(cx: &ToolContext) -> Self {
let glyphs = (cx.snap_to_glyph && cx.smart_guides && cx.alignment_guides).then_some(cx.glyph_snap);
Self::new(cx, || Targets::for_drawing(cx.doc, &[], visible(cx), glyphs))
}
/// Where `p` goes, and the guides showing why.
pub fn snap(&self, cx: &ToolContext, p: Point) -> (Point, Vec<Overlay>) {
self.snap_from(cx, p, None)
+36 -2
View File
@@ -9,13 +9,14 @@
//! ruler's ticks, else to whole pixels, the grid, with Smart Guides the art's and the artboards'
//! edges, centres and anchors, or with Snap to Point the anchors. Dropped off the canvas onto its
//! ruler, a moved guide is deleted. Hidden or locked guides (View › Guides), and guides on a hidden
//! or locked layer, can't be picked.
//! or locked layer, can't be picked. The rulers' origin, dragged out of their corner
//! ([`OriginDrag`]), snaps as a drawn point does.
use serde_json::json;
use vectorcraft_doc::{Guide, NodeId};
use vectorcraft_geom::{Point, Rect};
use crate::guides::Targets;
use crate::guides::{PointSnap, Targets};
use crate::{Action, Cursor, Overlay, PointerEvent, PointerKind, ToolContext};
/// The ruler guide under `p`, by its index in `guide.list`: the nearest within the selection
@@ -247,6 +248,39 @@ impl NewGuide {
}
}
/// The rulers' origin dragged out of the box where they meet, with any tool: it snaps as a drawn
/// point does ([`PointSnap::drawn`]), with Smart Guides onto the anchors, centres, edges and paths
/// of the art and the artboards or into line with them, with Snap to Point onto the anchors and
/// along the ruler guides, else onto whole pixels or the grid. The targets are gathered when the
/// drag begins. It changes nothing: the origin is set where the button is released.
pub struct OriginDrag {
snap: PointSnap,
/// The guides showing what the origin snapped to.
guides: Vec<Overlay>,
}
impl OriginDrag {
pub fn new(cx: &ToolContext) -> Self {
Self { snap: PointSnap::drawn(cx), guides: vec![] }
}
/// Where the origin goes with the pointer at `p` (none off the canvas).
pub fn pointer(&mut self, cx: &ToolContext, p: Option<Point>) -> Option<Point> {
let Some(p) = p else {
self.guides.clear();
return None;
};
let (at, guides) = self.snap.snap(cx, p);
self.guides = guides;
Some(at)
}
/// The guides showing what the origin snapped to.
pub fn overlays(&self) -> Vec<Overlay> {
self.guides.clone()
}
}
/// A selection tool's ruler-guide handling: [`Self::press`] on a press, [`Self::pointer`] for
/// the rest of the gesture.
#[derive(Default)]
+14 -3
View File
@@ -181,8 +181,9 @@ pub(super) fn ruler_rects(full: egui::Rect) -> [egui::Rect; 3] {
/// it makes none. A double-click on a ruler (both clicks on that ruler) makes a guide at the
/// pointer, across the ruler's axis (a vertical one on the top ruler, a horizontal one on the
/// left; swapped in a view turned 90°, where the rulers read the other document axis, and the
/// nearer axis in between), unsnapped, as one `guide.add` and so one undo step. The corner drags the rulers' origin or resets it on a
/// double-click.
/// nearer axis in between), unsnapped, as one `guide.add` and so one undo step. The corner drags
/// the rulers' origin, snapped as a drawn point is (`Session::ruler_origin_drag`), or resets it on
/// a double-click.
pub(super) fn ruler_input(app: &mut VectorcraftApp, ui: &Ui, full: egui::Rect, canvas: egui::Rect, xf: &Xf) -> Option<Point> {
let [top, left, corner] = ruler_rects(full);
// Right-click on a ruler or the origin box: the document units, to swap between them as
@@ -274,9 +275,18 @@ pub(super) fn ruler_input(app: &mut VectorcraftApp, ui: &Ui, full: egui::Rect, c
let mut preview = None;
if let Some((started_in, mut cancelled)) = ui.data(|d| d.get_temp::<(Option<u64>, bool)>(drag_id)) {
cancelled |= started_in != uid || ui.input(|i| !i.focused || i.key_pressed(egui::Key::Escape));
let at = corner.interact_pointer_pos().or_else(|| ui.input(|i| i.pointer.latest_pos())).filter(|p| canvas.contains(*p)).map(|p| xf.to_doc(p));
let pointer =
corner.interact_pointer_pos().or_else(|| ui.input(|i| i.pointer.latest_pos())).filter(|p| canvas.contains(*p)).map(|p| xf.to_doc(p));
// The origin snaps as a drawn point does (Smart Guides, Snap to Point, pixels, the grid).
let at = if cancelled {
app.session.end_ruler_origin_drag();
None
} else {
app.session.ruler_origin_drag(pointer, app.view_info())
};
if corner.drag_stopped_by(egui::PointerButton::Primary) {
ui.data_mut(|d| d.remove::<(Option<u64>, bool)>(drag_id));
app.session.end_ruler_origin_drag();
if !cancelled
&& let Some(at) = at
&& let Err(e) = app.run("document.setRulerOrigin", json!({"x": at.x, "y": at.y, "artboard": app.view().map_or(0, |v| v.artboard)}))
@@ -285,6 +295,7 @@ pub(super) fn ruler_input(app: &mut VectorcraftApp, ui: &Ui, full: egui::Rect, c
}
} else if !ui.input(|i| i.pointer.primary_down()) {
ui.data_mut(|d| d.remove::<(Option<u64>, bool)>(drag_id));
app.session.end_ruler_origin_drag();
} else {
ui.data_mut(|d| d.insert_temp(drag_id, (started_in, cancelled)));
if !cancelled {
+22
View File
@@ -88,6 +88,27 @@ fn ruler_origin_drag_uses_the_rotated_zoomed_view_and_commits_only_on_release()
assert_eq!(app.ruler_origin(), origin);
}
/// The origin snaps as a drawn point does: dragged next to a rectangle's corner, it is set on it.
#[test]
fn ruler_origin_drag_snaps_onto_the_art() {
let mut app = app();
app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 100, "height": 100})).unwrap();
app.run("select.none", json!({})).unwrap();
// The Hand tool shows no smart guides of its own as the pointer passes over the corner.
app.select_tool("hand");
let ctx = context();
frame(&mut app, &ctx, vec![], canvas::show);
let to = canvas::Xf::new(app.canvas_rect.unwrap(), app.view().unwrap()).to_screen(Point::new(100.4, 99.6));
frame(&mut app, &ctx, vec![Event::PointerMoved(to)], canvas::show);
assert!(app.session.overlays(app.view_info()).is_empty());
start_drag(&mut app, &ctx, to);
frame(&mut app, &ctx, vec![], canvas::show);
assert!(!app.session.overlays(app.view_info()).is_empty(), "the guide showing what it snapped to");
frame(&mut app, &ctx, vec![press(to, false)], canvas::show);
assert_eq!(app.ruler_origin(), Point::new(100.0, 100.0));
assert!(app.session.overlays(app.view_info()).is_empty());
}
#[test]
fn ruler_origin_double_click_resets_to_the_active_artboard() {
let mut app = app();
@@ -146,6 +167,7 @@ fn ruler_origin_cancelled_drags_do_not_modify_either_document() {
Cancel::Outside => pos2(4.0, 4.0),
Cancel::Escape => {
frame(&mut app, &ctx, vec![key(Key::Escape)], canvas::show);
assert!(app.session.overlays(app.view_info()).is_empty(), "the snapping guides go too");
to
}
Cancel::Focus => {
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -1,6 +1,6 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-12 · **Change:** minor (Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-12 · **Change:** minor (Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged)
>
> Vector Halftone preview update (2026-11-10): temporary dot selection marks are hidden, and the bounding box stays available (#6369).
>
@@ -240,7 +240,7 @@ tools, never checked side by side) isn't captured row by row.
| Ruler guides: drag out, select, move, delete, lock, Make/Release Guides | done | #414, #451; marquee selects unlocked ruler guides |
| A double-click on a ruler adds a guide at the pointer: a vertical one on the top ruler, a horizontal one on the left ruler (swapped in a view turned 90°, where the rulers read the other document axis; the nearer axis in between), exactly where the pointer is (no snapping), shown even with guides hidden, one undo step (`guide.add`); both clicks of the pair must be on that ruler, and the first adds nothing. The [public page on rulers](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/use-rulers.html) doesn't describe this gesture, so it follows the request in #5239 | done | #5239; an artboard guide with the Artboard tool, as a drag from a ruler makes one; `canvas/tests.rs` `double_clicking_a_ruler_adds_a_guide_at_that_position`, `a_canvas_click_then_a_ruler_click_adds_no_guide`, `a_ruler_double_click_follows_a_rotated_view` |
| Escape cancels an existing ruler-guide press, move or copy | done | Selection and Direct/Group Selection; app-input regressions cover preselected guides, document/interaction-start selection, Undo/Redo and saved state, later on-canvas motion/release and temporary borrowing from idle Pen. All eight checks and the Direct Selection Escape control passed in current full CI. [Validation evidence](target-app-parity.md#evidence-what-ships-today-by-area) |
| Ruler origin: corner drag with preview, double-click reset to the active artboard, relative X/Y fields, native save/reopen | done | #1212; `document.setRulerOrigin`, `document.resetRulerOrigin`; geometry and command coordinates stay absolute |
| Ruler origin: corner drag with preview, snapped as a drawn point is (Smart Guides, Snap to Point and the ruler guides, pixels, the grid), double-click reset to the active artboard, relative X/Y fields, native save/reopen | done | #1212; `document.setRulerOrigin`, `document.resetRulerOrigin`; geometry and command coordinates stay absolute |
| Ruler guides as Layers rows: shown, hidden, locked and deleted with their layer; rows dragged to another layer | done | `guide.setLayer`; guides from older files go on a layer |
| Objects made into guides: drawn in the guide colour and style of Preferences; Lock Guides locks them too (no select, move or delete); a dragged selection snaps to ruler guides with Smart Guides on, by the nearest point of the path when pressed on its stroke or beside its edge, so the path lands exactly on the guide | done | #1534 (#1543, #1583); #3701 |
| A selected ruler guide's X or Y in the Transform panel; typing a value moves it | not scored | #1659 (part of #1597); several guides move together; not in Properties or the Control bar. Not established by the documentation we could find: the help pages on guides, rulers and the Transform, Control and Properties panels (read again on 2026-10-14) don't describe it, and the one public statement is a user's [community answer](https://community.adobe.com/questions-652/adding-a-new-custom-guide-785586), which is not documentation. Kept as a convenience pending the owner's decision; no parity claim |
@@ -520,6 +520,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
| Date | Change | Summary |
|---|---|---|
| 2026-11-12 | minor | Live Paint Bucket fills faces crossed in one drag (#6373). Scores and estimates unchanged. |
| 2026-11-11 | minor | Ruler origin: the corner drag snaps as a drawn point does, onto the art's and the artboards' anchors, centres, edges and paths, and with Snap to Point along the ruler guides; scores and estimates unchanged |
| 2026-11-11 | minor | Eyedropper copies effective character dimensions between transformed text objects (#6404); scores and estimates unchanged. |
| 2026-11-11 | minor | Outline view: a click on a path's outline selects it through an image or a gradient mesh in front, which Outline draws as a frame or mesh lines (#6437). |
| 2026-11-11 | minor | A middle-click on a document tab (or its ×) closes it as the × does; closing a document's last view with unsaved changes asks to save first (#6506). VectorCraft addition; scores and estimates unchanged. |