Skip to content

fix(layout): measure and edge a nested legend's markers as the map shows them - #3373

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3370-legend-nested-marks
Nov 29, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:fix/3370-legend-nested-marks

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A layout legend with "sizes": "nested" misplaced or mis-edged some stacked markers.

  • The block measures a marker's ink from the outline as it is stroked. A "+" of hash marks was measured longer than drawn by its width, so it floated above the base and its leader started above its top; a hash of width 0, drawn as a hairline, was measured as no ink.
  • The legend's thin edge goes to each marker that shows and has no outline of its own. A fully transparent mark no longer gets a ring the map doesn't draw.
  • This also changes the earlier rule that a stack outlining any of its marks was drawn as it is: its marks without an outline are now edged too, because nested markers of one fill merged into one shape. Marks with their own outline are unchanged.

Only the nested legend block changes; the map and legend rows draw as before. No project format or command change: the fix is in the layout renderer, so it shows wherever layouts are drawn (desktop, web and touch views, exports from the command line, Python, the assistant and plugins).

Testing

  • Tests in render/src/layout/legend/nested/tests.rs: every mark stands on the base with its top where its leader starts (circle, triangle, character, offset mark, hash "+"; at two reference scales, opaque and half see-through), the length of a wide and a hairline hash, which marks get the edge, and that a see-through block is composited as one. The ones for the fixed behaviour failed before the change.
  • cargo fmt --check, cargo clippy --workspace, cargo nextest run (11053 passed, 29 skipped), doctests, layer check and cargo xtask schema --check pass.
  • ui_shot replay before and after on the sample project.

UI evidence

Cities sized by a field, before (left) and after (right).

A "+" of two hash marks: the leader of the largest started above the cross.

3370-hash-before-after.png

A transparent mark under a red dot: it was edged and the block sized to it.

3370-spacer-before-after.png

A red disc with an outlined white dot: the discs merged into one.

3370-mixed-before-after.png

Related issue

Closes #3370

Summary by CodeRabbit

  • Bug Fixes
    • Nested legends now add a thin outline to each visible marker that lacks its own, even when other markers in the stack already have outlines.
    • Marker outlines and shapes render with more accurate bounds, including thin strokes and hash marks.
  • Documentation
    • Updated the nested-legend guide to describe how outlines are applied to individual markers.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change updates point-mark ink measurement and stroke configuration. Nested legends now add legend-ink outlines to eligible markers individually. Tests cover marker bounds, transparency, and outline handling.

Changes: Nested legend marker rendering

Layer / File(s) Summary
Measure and draw point-mark ink
crates/render/src/point_marks.rs, crates/render/src/layout/legend/nested/tests.rs
Point-mark bounds now use transformed fill paths and stroked outlines. Stroke caps vary by mark type. Tests cover marker dimensions, placement, and transparency.
Apply outlines to eligible markers
crates/render/src/layout/legend/nested.rs, crates/render/src/layout/legend/nested/tests.rs, docs/user-guide/layouts.md
Nested legends add legend-ink outlines to visible markers that lack an effective outline. Tests and documentation cover mixed outlines and non-rendering marks.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • opengeos/RustGIS#3347 — This change updates marker measurement and outline handling in the nested legend feature described by the issue.

Possibly related PRs

  • opengeos/RustGIS#3355 — This PR adds the sizes: "nested" legend option whose marker rendering this change updates.
  • opengeos/RustGIS#1442 — This PR introduces marker drawing and reach logic used by layout legends; this change updates point-mark measurement and drawing.

Suggested reviewers: pick2510, giswqs

Merge Risk: Minimal · up to 3232f

The change fixes marker measurement and edging in nested-size legends and keeps drawing elsewhere unchanged. No concrete merge-blocking risk was found, and the tests added with it cover the changed behavior.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (measuring and edging nested legend markers as the map draws them) and the area (layout legend). It matches the main changes: ink measurement from the stroked outline, and edge…
Description check Passed The description follows the template. It has a Summary that explains the problem and the fix, a Testing section with the test file, the commands run, and the ui_shot replay, and a UI evidence section …
Linked Issues check Passed Issue #3370 has four coding objectives. (1) Markers stand on the base with leaders at their tops: nested.rs draw sets each marker centre to base - ink_box.down * ppp and each leader start to `base…
Out of Scope Changes check Passed The changes are in the nested legend renderer (nested.rs), its tests, the shared point-mark helpers in point_marks.rs, and the layouts user guide. The nested.rs changes implement the #3370 objectives.…
Full details: Title check

Explanation

The title names the fix (measuring and edging nested legend markers as the map draws them) and the area (layout legend). It matches the main changes: ink measurement from the stroked outline, and edge eligibility for visible unoutlined marks. It is specific and follows the conventional-commit style. No unrelated content.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the problem and the fix, a Testing section with the test file, the commands run, and the ui_shot replay, and a UI evidence section with before/after screenshots for the visible change. The Related issue section says Closes #3370. The template's UI evidence section says to attach before and after images for visible changes. The author provides them. The template's 'No visible UI change' line is not used, which fits because this PR does change visible output.

Full details: Linked Issues check

Explanation

Issue #3370 has four coding objectives. (1) Markers stand on the base with leaders at their tops: nested.rs draw sets each marker centre to base - ink_box.down * ppp and each leader start to base - ink_box.height() * ppp. The height comes from point_marks::ink_reach at head, which takes tight bounds of the stroked outline, so hash marks are measured as drawn. (2) Width-0 hairlines have ink: ink_reach uses w.max(0.01) for the stroke width, so a hairline hash is measured. (3) Only shown marks are edged: edged/bare requires size > 0 and fill.a() > 0, so a transparent mark gets no edge and no block size. (4) Each shown, unoutlined mark gets the edge: the stack-wide early return is removed, and the per-mark loop in edged edges each Marker that is bare. Marks with their own effective outline are left unchanged. The see-through block is composited as one in draw via composited. The unit tests in tests.rs were not readable in this review (the diff tool was unavailable), so the test coverage claim rests on the PR description. The source logic at head supports each objective.

Full details: Out of Scope Changes check

Explanation

The changes are in the nested legend renderer (nested.rs), its tests, the shared point-mark helpers in point_marks.rs, and the layouts user guide. The nested.rs changes implement the #3370 objectives. The point_marks.rs changes (pen with flat caps for hash marks, ink_reach using stroked bounds, and a 0.5 device-pixel minimum in draw) support the hash-length objective, because the legend swatch draws through the same point_marks::draw path. The PR states that map drawing is unchanged. The base revision could not be read, so this unchanged-map claim is not verified. Hash outline caps and minimum width in the shared draw path could affect map hash marks. No change was shown to be unrelated to #3370.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each marker’s place,
And measures ink with careful grace.
A hidden mark gets no new ring,
An unedged mark gets outlining.
Hashes meet the baseline true,
While nested circles show through.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8f21353e-34ae-4297-9d2a-13697e51c2c4
Commits

Reviewing files that changed from the base of the PR and between 713d33a and 3232f97.

Files selected for processing: 4

  • crates/render/src/layout/legend/nested.rs
  • crates/render/src/layout/legend/nested/tests.rs
  • crates/render/src/point_marks.rs
  • docs/user-guide/layouts.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I read the full diff, the base-branch AGENTS.md, and the surrounding code in nested.rs, point_marks.rs and the nested tests. I could not build or run the tests here (no shell), so the findings below come from reading the code. There were no prior review threads, so no earlier concerns were skipped.

Bugs

None found. Confidence: moderate-high, from reading only.

  • Removing the k <= 0.0 early return in edged is safe. Layer::size_factor clamps to SIZE_FACTORS.0 = 0.01, so EDGE / k can't divide by zero. The only other value is NaN, which behaves as it did before.
  • ink_reach is called only from nested.rs, so the rows legend and the map are unaffected, as the PR says.
  • The outlined gate is removed on purpose and documented in both the PR body and layouts.md.

Security

None found.

Performance

  • ink_reach now strokes each marker path (path.stroke) once per legend entry. The count is legend-sized, so the cost is negligible. Confidence: high.

Quality

  • point_marks.rs:110: filled shapes move from bounds() to compute_tight_bounds(). This changes nested-block heights for character glyphs, and the PR body doesn't mention it. Inline comment posted. Confidence: high.
  • nested/tests.rs:273: the layout test passes a transparent ink, so the 0.5 pt edge it measures is never drawn. The 2 px tolerance hides about 1 px per side. Inline comment posted. Confidence: moderate.
  • Nit: ink_reach floors a hairline outline at 0.01 pt, while draw floors it at 0.5 px. For butt-capped hashes this has no effect, and for round outlines it is under 0.25 px. Confidence: high that the floors differ; low that it matters.

AGENTS.md

No rule breaks found.

  • The only new unwrap/panic! calls are in test code, the same as the file's existing tests.
  • No new panic paths, and no new Session::notify cases (none apply).
  • No wasm-only or desktop-only code paths changed, and no assets or command surface changed.
  • Twins checked: reach() (culling) in the same file is unchanged and still reads the outline width. draw() and ink_reach() share the new pen helper, which keeps the cap and join rules in one place. The rows legend has no edged-style logic to update (edged is used only in nested.rs).

Change size

Compared with the base branch (main, merge base 92594ee, PR head 3232f97). The PR touches 4 files, all modified.

Measure Value
Files changed 4 (added 0, modified 4, removed 0, renamed 0)
Size before 127.2 KB
Size after 133.2 KB
Total size change +6.0 KB
File Before After Change
crates/render/src/layout/legend/nested/tests.rs 11.3 KB 16.9 KB +5.6 KB
crates/render/src/point_marks.rs 14.3 KB 14.7 KB +392 B
crates/render/src/layout/legend/nested.rs 7.6 KB 7.5 KB −32 B
docs/user-guide/layouts.md 94.0 KB 94.0 KB +5 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3373/
Web app https://preview.rustgis.app/pr-3373/app/
Commit 3232f97

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 29, 2026
Merged via the queue into opengeos:main with commit 8c8da52 Nov 29, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3370-legend-nested-marks branch November 29, 2026 20:39
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.

[Bug]: Layout: nested legend sizes misplace or mis-edge some stacked markers

1 participant