Repository navigation
feat(layout): a legend takes the size of its line and polygon patches (#3559) - #3564
jgregoriorincon wants to merge 10 commits into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Code reviewNo bugs, security problems, or performance problems found. Static review only: I did not run the build or tests. Tests the PR describes as passing were not re-run here. Bugs
Security
Performance
Quality
AGENTS.md
No prior review threads existed, so I left none alone. Change sizeCompared: the whole PR against main (merge base 342ebb8 to PR head 04f9e7b).
|
📖 Docs preview
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 |
| /// the widest point symbol, so the labels line up. | ||
| pub(super) fn swatch_column(sides: impl IntoIterator<Item = f32>, size: f32) -> f32 { | ||
| sides.into_iter().fold(LEGEND_SWATCH * size, f32::max) | ||
| pub(super) fn swatch_column(sides: impl IntoIterator<Item = f32>, (patch, size): (Patch, f32)) -> f32 { |
There was a problem hiding this comment.
Question on the design, not a defect: the column is widened to patch.width * size even when the legend has no line or polygon row. A legend of point layers only, with patchWidth set to 100, therefore gets a 100 pt column of blank space in front of its labels, and the patch it reserves is never drawn. The tests and the docs describe this behaviour, so it may be intended. If it is, a short note in the patchWidth doc would say so. If not, the fold could start from the default width unless a line or polygon row is present.
Category: quality
Code reviewI reviewed the whole diff (29 files), the PR metadata, and the prior review threads. I did not build or run the tests; the findings below come from reading the code. BugsNone found. I checked these paths:
SecurityNone found. The new parameters are range-checked through PerformanceNone found. The new work is a few comparisons per element and one extra parse of Quality
AGENTS.mdNo violations found. Checked:
Other notes
Prior threadsI left 4 earlier points alone, in 2 threads, as already raised and answered: the constant naming and duplication, the Change sizeCompared with
|
Summary
A layout legend draws every line and polygon patch at one size, 16 × 9 pt at the default text size. This lets a legend set it:
layout.addElementandlayout.updatetakepatchWidth(4 to 100) andpatchHeight(3 to 100) for a legend, in points at the default text size, so they grow and shrink withtextSizelike the rest of the legend.fit, columns,columnBreaks,oneRow) and the notices about a legend that doesn't fit measure with the patch, in the app, inlayout.update's check and in an export.layout-legend-patch-size, wherever it is saved (project, layout file,layout.import,report.existingTemplate, task step, script, model), so an older release refuses the project instead of drawing the default patch and saving it again without the size. A file's value outside the range is brought into it when it is read.layout.publication, its wizard and the QGIS importer are not touched. The Format pane's boxes come in the next pull request.It reaches the desktop app, the browser, the command line, Python and the Assistant through the commands (the Assistant's layout skill lists the parameters); nothing is undone differently: a change is one undo step. Strings for the Format pane wait for that pull request. The MCP tool descriptions come from the same command parameters, so they list the two new ones with no separate change; the phone interface (
ui-touch), the ribbon and command search have no legend settings to add them to, since the Format pane is where a legend is set in the app.Testing
crates/engine/src/tests/layout_legend_patch.rs: setting, adding, limits, refusals that change nothing, the capability in every place it is saved, a file's out-of-range value, and the fit saying a taller or wider patch needs more room. Seen failing before the code, then passing.crates/render/src/layout/tests/legend_patch.rs: the default is what it was, the patch drawn at its width and height (and at twice the pixels, and at a legend's other text size), row heights for lines and polygons but not points, the column's width, and the fit. Breaking the patch's height on purpose fails five of its seven.schema/fixtures/layout_legend_patch_size.rgisis in the layout file round trip, and the schema and the command surface are regenerated.upstream/main:cargo fmt,cargo clippy -D warnings(whole workspace, all targets),cargo xtask layers,cargo xtask schema --check,cargo xtask test-hygiene, and the render and engine layout and legend tests (909 passed), all green. The full nextest run has 8 failures that are not in this diff and also fail without it: seven inrustgis-geolibreandsmoke line_strokes_editor_edits_one_class.UI evidence
No visible UI change: a legend draws as before unless it is given
patchWidthorpatchHeightthrough a command. The Format pane's boxes, with before and after captures, come in the next pull request.Related issue
Part of #3559