Skip to content

Fix #1372: Dimension tool - #1788

Merged
bflatastic merged 3 commits into
storytold:mainfrom
osamaamin2011:dimension-tool
Oct 15, 2026
Merged

bflatastic merged 3 commits into
storytold:mainfrom
osamaamin2011:dimension-tool

Conversation

@osamaamin2011

@osamaamin2011 osamaamin2011 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Closes #1372. Adds the Dimension tool (Modify section of the toolbar) for linked measurement
annotations, following the documented tool:

  • Linear: hover a path segment and drag outwards; releasing places the dimension. Or click two
    points (anchors snap, Shift constrains to 45°), then click to place. A curved segment is measured
    end to end.
  • Angular: hover a corner where two straight segments meet and drag outwards. Or click two
    straight lines, then click to place.
  • Radial: hover a circle, or a segment that is a perfect arc, and drag: outwards gives the
    radius, inwards the diameter; a click gives the radius. Ellipses are refused.
  • Tool Options (the strip's button, or double-clicking the tool): units — inches, millimetres,
    points, picas, pixels, plus centimetres, metres, feet and yards — precision, scale
    (drawing:real), dimension and extension lines, arrows, and the text: font, size, colour,
    Position (Away from the Line / Between Line and Object) and Alignment (Left / Center /
    Right along the line). Save sets the style of new dimensions.
  • Properties: a selected dimension shows its units, precision, line, arrows, text size, colour,
    position and alignment, with Apply to All (dimension.applyToAll) and Set as Default.

A dimension is an ordinary group whose recipe lives in NodeExtras (the node's dimension field).
Linked dimensions follow their art through moves, scaling and anchor/handle edits: they refresh
inside Session::edit, before Shaper, so they share the edit's undo step. Deleting the art, or
changing its topology, removes its dimensions in the same step. Pasted dimensions keep their
geometry and drop their links. Exports see plain paths and text.

Commands: dimension.create, dimension.update, dimension.applyToAll, plus
tool.setOption {tool: "dimension"} and the dimensionOptions dialog. Docs: docs/dimensions.md.
Strings are translated in every complete catalogue; the PR also adds my entry to
contributors/people.toml.

How it was tested

  • crates/engine/tests/dimensions.rs (16 tests): the drag gesture on a segment (and Escape
    cancelling it), two clicked points then a placing click, dragging out from a rectangle's corner,
    radius and diameter by dragging out of and into a circle; arcs and non-arcs; picas; Apply to All
    in one undo step; a linked dimension moved on its own keeping its place, and moved with its art
    keeping its distance; documents without dimensions skipping the refresh; length, scale, live
    edits, undo/redo and file round trips; bad input rejected without changing the document.
  • dialogs::dimension tests: the options dialog and the Properties section.
  • cargo xtask ci end to end (92c1300, Windows 11): all 7 steps passed.
  • A release build driven over the control channel: linear, vertical and angular dimensions on a
    rectangle, and the Properties section, checked in a screenshot.

Checklist

  • cargo xtask ci passes: all 7 steps (fmt, clippy, test, assets, brands, layers, wasm) on 92c1300, Windows 11.
  • No panics in shipped code.
  • Clean-room: behaviour from the public documentation linked in the review; nothing copied
    from Adobe products or GPL/AGPL code.
  • Every new asset has a row in ASSETS.md (assets/icons/dc-dimension.svg, original).

@Messhias Messhias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo xtask ci is unchecked (or incomplete) on this PR body. Run it end to end (fmt, clippy, tests, assets, brands, layers, wasm), tick the box when green, and reply here with the outcome. That is required before any approve from here.

@bflatastic

Copy link
Copy Markdown
Member

Thanks @osamaamin2011 — this is careful work: the recipe on the group, the refresh inside the edit so undo stays in step, and input checked before anything changes. I can't merge it as it stands, though: it differs from the documented tool in more ways than a follow-up commit should paper over, and a few things are new decisions for the project owner. I read the code and the tests; I did not build or run it.

Reference: Measure and add dimensions using the Dimension tool and Dimension tool options and settings.

Behaviour against the documentation

  1. Gesture. Documented: hover a path segment and drag outwards; or pick two points. Here: click, move, click, and Alt-click to pick points. Please make the drag the main gesture (press on the highlighted segment, drag, release places it) and plain clicks pick points.
  2. Radial. Documented for "any circle or perfect arc". Here only a closed circular path is accepted (dimension::circle wants one closed subpath), so an arc can't be dimensioned.
  3. Angular. Documented: hover an angle (a corner) and drag outwards, or two points on two intersecting lines. Here: two segments, or three Alt-clicked points.
  4. Units. Documented: inches, millimetres, points, picas, pixels. Picas is missing; cm, m, ft and yd are extra (fine to keep, but picas has to be there).
  5. Position. Documented: away from the dimension line and object, between the dimension line and object, and left, centre or right along the line. Here: above / centre / below and aligned / horizontal.
  6. Existing dimensions are changed from the Properties panel, with Apply to All and Set as Default. Here it is an Update button in the options dialog; the panel section and the two buttons are missing.

Not in the documentation: the owner decides, not this PR
7. Object › Dimensions › Dimension Selected Paths and the "All selected edges" button.
8. A curved segment measured by its arc length and labelled "Arc", and the "R" / "Ø" prefixes.
9. The defaults: centimetres, one decimal, red lines and text, Arial 14 pt (a font that isn't on every system).

Code
10. dimension::refresh walks the whole document on every edit, and so on every frame of a drag, also when the document has no dimension. The other refreshers in Session::edit return at once when there is nothing of theirs; this one needs the same.
11. A linked dimension moved with the Selection tool stays where it is dropped only until its source next changes, then jumps back: Dimension::transform ignores linked recipes and refresh sees nothing to do. Either the move changes offset, or a linked dimension doesn't move on its own.
12. mode, units, the line types, arrow style and text position are strings checked at each use. Enums would let serde refuse a bad value and remove the lists in validate.
13. The tool uses the Measure tool's icon, so the toolbar and the All Tools drawer show two tools that look the same. It needs its own (original, with a row in ASSETS.md).
14. The PR says the wasm, layers and assets steps of cargo xtask ci weren't run. Please run the whole of it.

With 1–6 as documented, 10–14 fixed and 7–9 left out (or taken to an issue for the owner), this can land.

If you'd like to talk it through, we're on Discord: https://discord.gg/artcraft

@lewandowskit

Copy link
Copy Markdown
Contributor

Tested this locally on macOS (Mac mini M4), built from this branch with cargo xtask bundle — works well for me. 👍

What I tried:

  • Length dimensions on straight edges and between two points
  • Angle dimensions between two segments (a right angle shows 90°)
  • Radius / Diameter on a circle
  • Dimension Selected Paths on a whole drawing
  • Moving and scaling the source object — dimensions follow it
  • Units (mm/cm) and drawing scale (e.g. 1:10) in Options
  • Export to PDF and printing — dimensions come out as regular lines and text
  • Polish interface: all the new Dimension tool strings show in Polish

This is exactly what I need for technical drawings. Thanks @osamaamin2011!

lewandowskit added a commit to lewandowskit/vectorcraft that referenced this pull request Oct 14, 2026
Double-click a dimension (Selection, Direct Selection, Group Selection or
the Dimension tool), or choose Object › Dimensions › Edit Dimension
Text…, to type what the dimension shows instead of its measurement, as
drawings that are not to scale or that need tolerances call for. `<>`
stands for the measured value (`<> ±0.5`, `ok. <>`); an empty field shows
the measurement again. The measurement keeps following the measured art,
so `<>` stays live.

- `Dimension.text` (saved in native files only when set) and
  `measured_label()`; `label()` applies the text.
- `dimension.create` and `dimension.update` take `text` (string, or ""
  / null for the measurement); one line of at most 256 characters.
- The Edit Dimension Text dialog shows the measurement, the text field
  and a live preview, with Use Measured Value; UI command
  `dimension.editText {id?}`.
- Strings translated into every catalog; the new message into every
  complete one.

Closes storytold#1916. Builds on storytold#1788 (Dimension tool).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DukHNvUY45rjRnvtz91x33

@Messhias Messhias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo xtask ci is incomplete or unchecked on this PR. Run it end to end (fmt, clippy, tests, assets, brands, layers, wasm), tick the checklist when green, and reply here with the outcome. That is required before any approve from here.

lewandowskit added a commit to lewandowskit/vectorcraft that referenced this pull request Oct 14, 2026
Double-click a dimension (Selection, Direct Selection, Group Selection or
the Dimension tool), or choose Object › Dimensions › Edit Dimension
Text…, to type what the dimension shows instead of its measurement, as
drawings that are not to scale or that need tolerances call for. `<>`
stands for the measured value (`<> ±0.5`, `ok. <>`); an empty field shows
the measurement again. The measurement keeps following the measured art,
so `<>` stays live.

- `Dimension.text` (saved in native files only when set) and
  `measured_label()`; `label()` applies the text.
- `dimension.create` and `dimension.update` take `text` (string, or ""
  / null for the measurement); one line of at most 256 characters.
- The Edit Dimension Text dialog shows the measurement, the text field
  and a live preview, with Use Measured Value; UI command
  `dimension.editText {id?}`.
- Strings translated into every catalog; the new message into every
  complete one.

Closes storytold#1916. Builds on storytold#1788 (Dimension tool).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DukHNvUY45rjRnvtz91x33
@osamaamin2011 osamaamin2011 changed the title Fix #1372: Dimension tool and Object › Dimensions Fix #1372: Dimension tool Oct 14, 2026
@osamaamin2011

Copy link
Copy Markdown
Contributor Author

Thanks @bflatastic for the careful review. Rebased on today's main and reworked in 92c1300; cargo xtask ci passes end to end (all 7 steps, Windows 11), and the PR description is updated.

  1. Gesture: press on the highlighted segment, drag, release places it. Plain clicks pick two points, then a click places it.
  2. Radial: circles and perfect arcs (a segment that follows one circle, DimensionSource::Arc). Dragging outwards gives the radius, inwards the diameter.
  3. Angular: hover a corner of two straight segments and drag outwards; or click two straight lines, then place it. It measures the interior angle; dragging inward vs outward doesn't switch to the exterior one yet.
  4. Units: picas added. Inches, millimetres, points, picas and pixels come first; cm, m, ft and yd are kept.
  5. Position: Away from the Line / Between Line and Object, and Left / Center / Right along the line. The old above/centre/below and horizontal orientation are gone.
  6. Properties: a Dimension section for the selected dimension, with Apply to All (dimension.applyToAll, one undo step) and Set as Default. The Update button and "apply to selected" checkbox in the options dialog are gone.
  7. Left out: Dimension Selected Paths and All selected edges.
  8. Left out: arc length and the "Arc", "R" and "Ø" prefixes. A curved segment is measured end to end.
  9. Defaults: taken from the document's type defaults (the same font as new type), black, points, two decimals.
  10. Refresh: Document::dimensions is set when a dimension is inserted, saved with the document, and cleared by the refresh when none are left; dimension::refresh returns at once without it.
  11. Moving a linked dimension: the move is recorded on the recipe (Dimension::moved, not saved). The refresh turns it into a new placement when the measured art didn't move, and drops it when the art moved too, so it neither jumps back nor drifts when moved together with its art.
  12. Enums: DimensionMode, LengthUnit, LineType, ArrowStyle, TextPosition and TextAlignment. Serde refuses bad values; the string lists in validate are gone.
  13. Icon: its own original dc-dimension.svg (a dimension line between two extension lines), with its row in ASSETS.md.
  14. CI: cargo xtask ci passes end to end, as above.

@Messhias: the checklist is ticked with the run above.

osamaamin2011 and others added 3 commits October 16, 2026 01:36
…ngth, angle, radius and diameter annotations
…ns; Properties section; review fixes

Drag out from a segment, corner, circle or arc to place a dimension; plain clicks pick two points or two lines. Radial dimensions on perfect arcs, picas, Away/Between and Left/Center/Right text placement. The Properties panel edits a selected dimension, with Apply to All (dimension.applyToAll) and Set as Default. Dimension Selected Paths, the Arc/R/Ø prefixes and the custom defaults are left out. The refresh returns at once in documents without dimensions (Document::dimensions); a linked dimension moved on its own keeps its place; modes, units, line types, arrows and text placement are enums; the tool has its own icon.
…t know still opens; commands still refuse unknown options
@bflatastic
bflatastic merged commit cc0aec1 into storytold:main Oct 15, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Thanks @osamaamin2011, the rework follows the documented tool closely. Merged after a full gate. One commit of ours on top: the saved dimension data no longer refuses unknown fields, so a file from a later version that adds a dimension option still opens. Commands and tool options still refuse unknown keys (Unknown dimension option …, translated in every complete catalog). Checked live: a drag off a rectangle's edge places a 200 pt dimension with its arrows and extension lines, the Properties panel shows the Dimension section, and scaling the rectangle to 150% updates it to 300 pt. Also checked over MCP. Thanks @lewandowskit for testing it on macOS too.

@anuvindeljooffice-alt

Copy link
Copy Markdown

#1372

Please add this. The Stroke tool has Arrowheads details (for example, all the arrow styles are in it). Please add the same Arrowheads details to Arrow Style in the Dimension tool options as well. The Dimension tool options currently show only 4 arrow options.
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Dimension Tool

5 participants