Repository navigation
feat(layout): a legend in up to three columns, and publication layouts use them for long legends (#1379) #1494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bb1b4cd
ce23017
10e3804
6c88eae
2543260
24327c0
7874bd9
3022127
6cc7330
95981f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -793,6 +793,17 @@ fn divisions() -> usize { | |
| 4 | ||
| } | ||
|
|
||
| /// The most columns a legend lays its rows in. | ||
| pub const MAX_LEGEND_COLUMNS: usize = 3; | ||
|
|
||
| fn one_column() -> usize { | ||
| 1 | ||
| } | ||
|
|
||
| fn is_one_column(columns: &usize) -> bool { | ||
| *columns == 1 | ||
| } | ||
|
|
||
| fn ink() -> Rgba { | ||
| Rgba::rgb(0x22, 0x22, 0x22) | ||
| } | ||
|
|
@@ -912,6 +923,10 @@ pub enum ElementKind { | |
| /// highlight, a basemap-like layer. Empty, it lists every layer it would otherwise. | ||
| #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
| exclude: Vec<String>, | ||
| /// The columns its rows are laid in, 1 to [`MAX_LEGEND_COLUMNS`], under its title: as even | ||
| /// as they can be, a layer's name staying with the row under it. | ||
| #[serde(default = "one_column", skip_serializing_if = "is_one_column")] | ||
| columns: usize, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AGENTS.md / policy question (about 35% confidence, for maintainers): a new saved field without a format version change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change here: this is for a maintainer, as you say. The field follows 🤖 Addressed by Claude Code |
||
| }, | ||
| /// The colour scale of a raster layer in a frame's map: a gradient bar for a stretch, steps | ||
| /// for classes, a block per value for unique values and colour tables (#326). | ||
|
|
@@ -1318,10 +1333,11 @@ impl Layout { | |
| g.width = finite_or(g.width, grid_width()).clamp(0.0, MAX_GRID_WIDTH); | ||
| } | ||
| } | ||
| ElementKind::Legend { exclude, .. } => { | ||
| ElementKind::Legend { exclude, columns, .. } => { | ||
| // Names stay whole: a layer's own name isn't cut, and a cut one would no | ||
| // longer match it. | ||
| exclude.truncate(MAX_LEGEND_EXCLUDED); | ||
| *columns = (*columns).clamp(1, MAX_LEGEND_COLUMNS); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never silent (AGENTS.md, about 45% confidence): an out-of-range The PR text says a value out of range in a hand-edited file "draws as the nearest". The other clamps in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change here: as you say, this is a question for maintainers. Every clamp in 🤖 Addressed by Claude Code |
||
| } | ||
| ElementKind::Text { text, size, letter_spacing, .. } => { | ||
| *size = finite_or(*size, 12.0).clamp(*crate::graphics::FONT_SIZE.start(), *crate::graphics::FONT_SIZE.end()); | ||
|
|
||
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.