From 5ea1c60f2fad875fbed2a321db891869136f465b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Gregorio=20Rinc=C3=B3n?= Date: Mon, 30 Nov 2026 15:54:15 -0500 Subject: [PATCH 01/10] feat(layout): lay a legend in one row --- crates/assistant/skills/print-layout/SKILL.md | 2 +- crates/engine/command-surface.txt | 4 +- crates/engine/src/cmd/layout.rs | 6 +- crates/engine/src/cmd/layout/elements.rs | 8 +- crates/engine/src/cmd/layout/legend.rs | 51 +++++-- .../engine/src/cmd/layout/publication/mod.rs | 1 + .../src/cmd/layout/publication/parts.rs | 1 + crates/engine/src/cmd/layout/update.rs | 13 +- crates/engine/src/project.rs | 1 + crates/engine/src/project_capabilities.rs | 19 +++ crates/engine/src/tests.rs | 6 + crates/engine/src/tests/layout_files.rs | 1 + crates/engine/src/tests/layout_legend_row.rs | 131 +++++++++++++++++ crates/map/src/layout.rs | 11 ++ crates/map/src/layout/elements.rs | 5 + crates/map/src/layout/tests.rs | 21 +++ crates/render/src/layout.rs | 3 + crates/render/src/layout/legend.rs | 84 ++++++++++- .../render/src/layout/legend/count_tests.rs | 3 + .../render/src/layout/legend/nested/tests.rs | 1 + crates/render/src/layout/tests.rs | 37 +++++ crates/render/src/layout/tests/legend_row.rs | 135 ++++++++++++++++++ crates/render/src/stream_tests.rs | 1 + crates/render/src/svg.rs | 2 + .../ui-egui/src/layoutview/format/legend.rs | 30 ++-- .../src/layoutview/format/legend_breaks.rs | 63 ++++++-- crates/ui-egui/src/layoutview/tests.rs | 22 +++ docs/maintaining.md | 7 + docs/user-guide/layouts.md | 7 + schema/fixtures/layout_legend_one_row.rgis | 25 ++++ schema/project.schema.json | 2 + 31 files changed, 657 insertions(+), 46 deletions(-) create mode 100644 crates/engine/src/tests/layout_legend_row.rs create mode 100644 crates/render/src/layout/tests/legend_row.rs create mode 100644 schema/fixtures/layout_legend_one_row.rgis diff --git a/crates/assistant/skills/print-layout/SKILL.md b/crates/assistant/skills/print-layout/SKILL.md index dc333973c8..3202009068 100644 --- a/crates/assistant/skills/print-layout/SKILL.md +++ b/crates/assistant/skills/print-layout/SKILL.md @@ -27,7 +27,7 @@ description: Make a printable page layout — map frame, title, legend, north ar labels' size) and `"fit"` (`"adjustDivisionValue"`, `"adjustDivision"`, `"adjustWidth"`). A `"legend"` can take `"columns"` (1–6), `"fit"` (`"manual"`, `"adjustSize"`, `"adjustColumns"`, `"adjustColumnsAndSize"`: shrink its text or add columns to fit its box), `"subtitle"` (one line under its title), `"sizes": "nested"` (a point layer's marker sizes one inside another on a common base), `"showCounts": true` (each class row ends in its number of features; none for a layer read from a database, over the web or a view at a time from other files), - `"showLayerNames": false`, `"layerOrder": [""]` (those layers first, the map unchanged), `"columnBreaks": [""]` (each starts a column; no `"columns"` above 1 beside them) and `"classLabels"` (`{"": {"": ""}}`: its own text for a + `"showLayerNames": false`, `"layerOrder": [""]` (those layers first, the map unchanged), `"columnBreaks": [""]` (each starts a column; no `"columns"` above 1 beside them), `"oneRow": true` (every entry side by side in one row, however many; no `"columns"` above 1 or `"columnBreaks"` beside it) and `"classLabels"` (`{"": {"": ""}}`: its own text for a class, the layer keeping its label). A `"picture"` takes a `"path"` (a PNG or JPEG file; it remembers the file) or an `"image"` (base64); `layout.update` with `"path"` reads it again. A `"text"` or `"dynamicText"` can take diff --git a/crates/engine/command-surface.txt b/crates/engine/command-surface.txt index 01c6a4e3ea..dc56ffa2af 100644 --- a/crates/engine/command-surface.txt +++ b/crates/engine/command-surface.txt @@ -284,7 +284,7 @@ layer.transparency layer? value layer.visibility layer? visible? layer.zoomTo layer? layout.activate name layout -layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? columns? textSize? classLabels? sizes? showCounts? showLayerNames? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? fields? header? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? section? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background? +layout.addElement layout? kind frame? of? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? oneRow? columns? textSize? classLabels? sizes? showCounts? showLayerNames? orientation? ticks? tickSide? reverse? fill? width? radius? dash? dir? head? angle? length? image? path? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? hideLabels? barOutline? rows? fields? header? step? type? crs? short? mgrs? labels? style? tickLength? format? hemisphere? edges? labelOrientation? labelSize? off? name? direction? at? section? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? outline? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? x? y? w? h? background? layout.addFrame layout? shape? points? map? x? y? w? h? layout.arrange layout? element to layout.arrangement favourite? save? arrangement? remove? @@ -306,7 +306,7 @@ layout.save layout? path layout.series layout? layer nameField? frame? margin? off? layout.seriesPage layout? page layout.seriesRefresh layout? -layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? labels? classLabels? columns? textSize? showLayerNames? sizes? showCounts? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? extentNumbers? border? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? barOutline? hideLabels? rows? fields? header? image? path? background? +layout.update layout? element x? y? w? h? name? visible? locked? text? size? color? bold? italic? align? letterSpacing? rotation? wrap? valign? lineSpacing? case? font? fallback? title? subtitle? allClasses? hideOther? showNoData? exclude? layerOrder? columnBreaks? labels? classLabels? oneRow? columns? textSize? showLayerNames? sizes? showCounts? orientation? ticks? tickSide? reverse? style? fill? outline? radius? width? dash? dir? head? angle? length? units? divisions? subdivisions? divisionsBeforeZero? labelPosition? unitLabel? unitLabelPosition? fit? map? scale? center? bearing? pitch? grid? extentIndicator? extentNumbers? border? section? layer? field? label? group? statistic? order? bars? other? stack? values? decimals? barColor? classes? labelAlign? mirror? max? band? side? gap? thickness? unit? lineColor? lineWidth? min? guides? barOutline? hideLabels? rows? fields? header? image? path? background? locator.find locator? text limit? zoom? map.activate name map.addTiles url kind? name? bounds? attribution? minZoom? maxZoom? tileSize? singleImage? tms? subdomains? layers? styleLayers? opacity? blend? resampling? overlay? top? replace? id? view? start? end? unit? interval? dates? legend? connection? anonymous? diff --git a/crates/engine/src/cmd/layout.rs b/crates/engine/src/cmd/layout.rs index e7c1c11699..7adf0ce996 100644 --- a/crates/engine/src/cmd/layout.rs +++ b/crates/engine/src/cmd/layout.rs @@ -44,7 +44,8 @@ mod legend; pub(in crate::cmd) use legend::say_unfitted_legends_in; use legend::*; pub(crate) use legend::{ - legend_columns_param, legend_counts_param, legend_fit_param, legend_names_param, legend_sizes_param, legend_subtitle_param, + legend_columns_param, legend_counts_param, legend_fit_param, legend_names_param, legend_one_row_param, legend_sizes_param, + legend_subtitle_param, }; mod picture; pub(crate) use picture::gives_picture; @@ -220,6 +221,7 @@ pub fn commands() -> Vec { r##""exclude"?: [layer names] (legend: layers it leaves out though the map draws them), "##, r##""layerOrder"?: [layer names] (legend: these layers first, in this order, the others after them as the map draws them; the map is not changed), "##, r##""columnBreaks"?: [layer names] (legend: each of these layers starts a column, 5 at most, so "columns" above 1 and the fits that add columns are refused beside them), "##, + r##""oneRow"?: bool (legend: every entry side by side in one row, however many, the layers' names on a line over their classes; "columns" above 1, "columnBreaks" and the fits that add columns are refused beside it; default false), "##, r##""columns"?: 1..6 (legend: the columns its rows are laid in; default 1; with a fit that adds columns, the fewest it starts from), "##, r##""textSize"?: points, 4 to 100 (legend: its layers' names and classes' labels, its title, rows, swatches and gaps following in proportion and a point symbol keeping the size the map draws it at; default 9; scaleBar: its labels, the room over the bar and between them following, the bar keeping its size; default 8; table: its text, its rows and columns following; default 8; colorbar: its labels, the bar making room for them; default 8; refused outside that range, and for other kinds unless null, as showNoData is), "##, r##""classLabels"?: {"": {"": ""}} (legend: its own text for a class, by the label the layer shows for it, up to 200 characters; the layer keeps its label; a layer or class it can't find is refused), "##, @@ -339,6 +341,7 @@ pub fn commands() -> Vec { r##""columnBreaks"?: [layer names] (legend, as in layout.addElement; [] takes them off), "##, r##""labels"?: {"": "