Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

UI library, tokens, fonts and icons (step 5 of #2016, after #2287)

Nathan Dane1122cd44b8f7
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md
index 4b936d05ed..c4afb4b30d 100644
--- a/ATTRIBUTION.md
+++ b/ATTRIBUTION.md
@@ -52,6 +52,8 @@ Editable drawing code, native projects and shipped exports are collected under `
| docs/book/src/generated/enclosure.png | SolidCraft contributors | rendered by `cargo xtask book` (`solidcraft-cli snapshot docs/book/scripts/enclosure.json`; gitignored) | MIT OR Apache-2.0 |
| docs/book/src/generated/revolve.png | SolidCraft contributors | rendered by `cargo xtask book` (`solidcraft-cli snapshot docs/book/scripts/revolve.json`; gitignored) | MIT OR Apache-2.0 |
| docs/book/src/generated/sheet-metal.png | SolidCraft contributors | rendered by `cargo xtask book` (`solidcraft-cli snapshot docs/book/scripts/sheet-metal.json`; gitignored) | MIT OR Apache-2.0 |
+| assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf | IBM Corp. (IBM Plex Mono) | https://github.com/IBM/plex (via google/fonts), unmodified; licence text in assets/fonts/ibm-plex-mono/OFL.txt; the interface monospace font | SIL OFL 1.1 |
+| assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf | IBM Corp. (IBM Plex Sans, variable wdth and wght) | https://github.com/IBM/plex (via google/fonts), unmodified; licence text in assets/fonts/ibm-plex-sans/OFL.txt; the default interface font | SIL OFL 1.1 |
| docs/book/src/generated/tool-preview.png | SolidCraft contributors | rendered by `cargo xtask book` (`solidcraft-cli snapshot docs/book/scripts/tool-preview.json`; gitignored) | MIT OR Apache-2.0 |
| assets/fonts/liberation-sans/LiberationSans-Regular.ttf | Red Hat, Inc. (Liberation Fonts 2.x; digitized data Google) | https://github.com/liberationfonts (Debian fonts-liberation), unmodified; licence text in assets/fonts/liberation-sans/OFL.txt; used for sketch Text outlines | SIL OFL 1.1 |
| assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf | The BIZ UDGothic Project Authors | https://github.com/googlefonts/morisawa-biz-ud-gothic (Google Fonts), unmodified; licence text in assets/fonts/biz-udp-gothic/OFL.txt; used for web UI Japanese font | SIL OFL 1.1 |
@@ -78,6 +80,8 @@ Editable drawing code, native projects and shipped exports are collected under `
| assets/appearances/library.rs | SolidCraft contributors | Original SolidCraft resource data or drawing code, collected without redesign | MIT OR Apache-2.0 |
| assets/fonts/biz-udp-gothic/OFL.txt | The BIZ UDGothic Project Authors | Unmodified accompanying font licence | SIL OFL 1.1 |
+| assets/fonts/ibm-plex-mono/OFL.txt | IBM Corp. | Unmodified accompanying font licence | SIL OFL 1.1 |
+| assets/fonts/ibm-plex-sans/OFL.txt | IBM Corp. | Unmodified accompanying font licence | SIL OFL 1.1 |
| assets/fonts/liberation-sans/OFL.txt | Red Hat, Inc.; Liberation Fonts contributors | Unmodified accompanying font licence | SIL OFL 1.1 |
| assets/icons/app/linux/exports/hicolor/128x128/apps/ai.storyteller.solidcraft.png | SolidCraft contributors | Generated from assets/icons/app/shared/source/app_icon.rs with the original CLI/ICO encoders | MIT OR Apache-2.0 |
| assets/icons/app/linux/exports/hicolor/16x16/apps/ai.storyteller.solidcraft.png | SolidCraft contributors | Generated from assets/icons/app/shared/source/app_icon.rs with the original CLI/ICO encoders | MIT OR Apache-2.0 |
@@ -137,6 +141,7 @@ Editable drawing code, native projects and shipped exports are collected under `
| assets/icons/ui/design/palette.toml | SolidCraft contributors | icon colour roles (light and dark) and accents, original SolidCraft data | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/bug_report.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/chevron.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
+| assets/icons/ui/design/svg/flat/chevron_right.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/close.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/disclosure_closed.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/disclosure_open.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
@@ -287,6 +292,8 @@ Editable drawing code, native projects and shipped exports are collected under `
| assets/icons/ui/design/svg/model/silhouette.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/assistant.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/flat/agent_link.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
+| assets/icons/ui/design/svg/model/offset_two_sides.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
+| assets/icons/ui/design/svg/model/offset_symmetric.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/model/placeholder.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/model/plane.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
| assets/icons/ui/design/svg/model/plane_angle.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
@@ -422,6 +429,7 @@ Editable drawing code, native projects and shipped exports are collected under `
| assets/icons/ui/design/tools/lint_icons.py | SolidCraft contributors | icon lint, status page or preview tool (standard-library Python), original SolidCraft code | MIT OR Apache-2.0 |
| assets/icons/ui/design/tools/preview.py | SolidCraft contributors | icon lint, status page or preview tool (standard-library Python), original SolidCraft code | MIT OR Apache-2.0 |
| assets/icons/ui/design/tools/review_state.py | SolidCraft contributors | icon review state helper (standard-library Python), original SolidCraft code | MIT OR Apache-2.0 |
+| assets/icons/ui/design/requested_icons.txt | SolidCraft contributors | Runtime icon requests collected by the headless menu audit, original SolidCraft data | MIT OR Apache-2.0 |
| assets/icons/ui/design/review.json | SolidCraft contributors | icon review state (accepted icons and notes), original SolidCraft data | MIT OR Apache-2.0 |
| assets/icons/ui/design/tools/author/lib.py | SolidCraft contributors | icon authoring script (standard-library Python), original SolidCraft code | MIT OR Apache-2.0 |
diff --git a/Cargo.lock b/Cargo.lock
index f3891452ce..3860bdafc5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4379,6 +4379,7 @@ dependencies = [
"solidcraft-engine",
"solidcraft-gpu",
"solidcraft-space-mouse",
+ "syn 2.0.119",
"tiny-skia",
"toml",
"ttf-parser",
diff --git a/assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf b/assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf
new file mode 100644
index 0000000000..0c9770d518
Binary files /dev/null and b/assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf differ
diff --git a/assets/fonts/ibm-plex-mono/OFL.txt b/assets/fonts/ibm-plex-mono/OFL.txt
new file mode 100644
index 0000000000..c35c4c618f
--- /dev/null
+++ b/assets/fonts/ibm-plex-mono/OFL.txt
@@ -0,0 +1,93 @@
+Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf b/assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf
new file mode 100644
index 0000000000..30f837e8b0
Binary files /dev/null and b/assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf differ
diff --git a/assets/fonts/ibm-plex-sans/OFL.txt b/assets/fonts/ibm-plex-sans/OFL.txt
new file mode 100644
index 0000000000..c35c4c618f
--- /dev/null
+++ b/assets/fonts/ibm-plex-sans/OFL.txt
@@ -0,0 +1,93 @@
+Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/assets/icons/ui/AGENTS.md b/assets/icons/ui/AGENTS.md
index 29f0973f72..e88a8d7dfd 100644
--- a/assets/icons/ui/AGENTS.md
+++ b/assets/icons/ui/AGENTS.md
@@ -29,3 +29,9 @@ request files under target, and do not retry them. The server never invokes a mo
Canonical paths, launch command and export schema: [README.md](README.md).
There are no numbered bulk authoring scripts or generated inventory files to maintain.
+
+Runtime discovery is also checked by `crates/ui-egui/tests/icon_audit.rs`. New menu
+surfaces must extend that Harness traversal. Regenerate the committed
+`design/requested_icons.txt` with `UPDATE_ICON_MANIFEST=1 cargo test -p
+solidcraft-ui-egui --test icon_audit`; review the sorted id/placeholder diff. The
+review tool reads this fixture in addition to source scans, masters and aliases.
diff --git a/assets/icons/ui/README.md b/assets/icons/ui/README.md
index 28cb8c8304..8e4aede022 100644
--- a/assets/icons/ui/README.md
+++ b/assets/icons/ui/README.md
@@ -18,8 +18,8 @@ artwork changes trigger the live revision check. The server binds only to loopba
Every opening scans SVG masters, aliases and source references. New, unused,
missing and changed icons are discoverable. **All discovered icons without a valid
-acceptance are Open, including those with notes.** No inventory file or allowlist
-is needed. Rescan sees additions immediately; a running page also polls revisions.
+acceptance are Open, including those with notes.** Discovery also reads `design/requested_icons.txt`, the sorted runtime audit
+manifest; it supplements source scans and never restricts discovery. Rescan sees additions immediately; a running page also polls revisions.
The internal placeholder glyph is the only excluded card. Shared masters are shown
separately even when an accepted alias already uses them; reopen that alias before
requesting a redraw of its protected artwork. Unassigned commands
@@ -82,6 +82,7 @@ Palette changes preserve accepted artwork and never update review hashes.
| `design/palette.toml`, `aliases.toml` | Shared theme roles, weights and semantic aliases |
| `design/review.json` | Owner acceptance hashes and current notes |
| `design/references.toml` | Curated style references; does not control discovery |
+| `design/requested_icons.txt` | Sorted runtime requests and placeholder flags, checked by the Harness audit |
| `design/tools/author/{lib,bases}.py` | Reusable geometry and canonical cube/slab/arrow bases |
| `design/tools/author/new_icon.py` | Safe new-master scaffold, never overwrites an id |
| `design/tools/icon_status.py`, `review_state.py` | Discovery, review backend and state |
@@ -104,5 +105,25 @@ python3 -B assets/icons/ui/design/tools/icon_status.py --csv
```
Reports, screenshots, requests, generated contact sheets and previews stay under
-ignored `target/`. Do not commit generated inventories or historical authoring
-batches. Every non-Markdown resource has an exact row in `ATTRIBUTION.md`.
+ignored `target/`. The runtime request manifest is a committed regression fixture; other generated
+inventories and historical authoring batches do not belong in the repository. Every non-Markdown resource has an exact row in `ATTRIBUTION.md`.
+
+## Runtime menu audit
+
+`cargo test -p solidcraft-ui-egui --test icon_audit` drives the real UI through the
+headless scenario Harness and rejects placeholder requests and unexpected blank
+context-menu icons. It compares sorted requested ids with
+`design/requested_icons.txt` (`id<TAB>placeholder`, one per line). After deliberately
+changing menu coverage or assignments, regenerate and review its diff:
+
+```sh
+UPDATE_ICON_MANIFEST=1 cargo test -p solidcraft-ui-egui --test icon_audit
+```
+
+The review page includes every manifest id, even ids used only in tables or helper
+arguments. A true placeholder flag, missing master or broken alias is reported as
+missing; runtime collection never changes acceptance hashes. The live control
+method `ui.icon_audit` can diagnose requests in a running UI (see
+[control protocol](../../../docs/control-protocol.md)). Keep the Harness traversal
+current when adding menus. A successful traversal covers only the contexts it
+actually opens; document unreachable or untested contexts in the audit report.
diff --git a/assets/icons/ui/STYLE_GUIDE.md b/assets/icons/ui/STYLE_GUIDE.md
index 00fa94798e..33c91585af 100644
--- a/assets/icons/ui/STYLE_GUIDE.md
+++ b/assets/icons/ui/STYLE_GUIDE.md
@@ -207,3 +207,9 @@ All artwork must be original SolidCraft work or an explicitly licensed resource
with provenance. Commercial CAD artwork, screenshots and extracted assets are
forbidden even as hidden references. This guide and the local finished set provide
all required visual context for future agents.
+
+Runtime discovery is also checked by `crates/ui-egui/tests/icon_audit.rs`. New menu
+surfaces must extend that Harness traversal. Regenerate the committed
+`design/requested_icons.txt` with `UPDATE_ICON_MANIFEST=1 cargo test -p
+solidcraft-ui-egui --test icon_audit`; review the sorted id/placeholder diff. The
+review tool reads this fixture in addition to source scans, masters and aliases.
diff --git a/assets/icons/ui/design/aliases.toml b/assets/icons/ui/design/aliases.toml
index f3443077c4..adb998138c 100644
--- a/assets/icons/ui/design/aliases.toml
+++ b/assets/icons/ui/design/aliases.toml
@@ -35,4 +35,12 @@ sketch_scale = { master = "scale", accent = "sketch" }
sketch_text = { master = "text", accent = "sketch" }
surface_fair = { master = "spline_cv", accent = "surface" }
mesh_export = { master = "export", accent = "mesh" }
+
+# Legacy feature-history id for the same Split Body operation.
+split = "split_body"
+
+# Sketch dialog choices share the corresponding finished tool artwork.
+sketch_chamfer_equal = { master = "sketch_chamfer", accent = "sketch" }
+sketch_chamfer_two = { master = "sketch_chamfer_two_distances", accent = "sketch" }
+offset_one_side = { master = "offset", accent = "sketch" }
bom = "list"
diff --git a/assets/icons/ui/design/palette.toml b/assets/icons/ui/design/palette.toml
index e648a81282..aaed95b248 100644
--- a/assets/icons/ui/design/palette.toml
+++ b/assets/icons/ui/design/palette.toml
@@ -10,7 +10,7 @@
[roles.ink] # outlines and details drawn over a face
source = "#34465b"
light = "#34465b"
-dark = "#d8dfeb"
+dark = "#1f2021"
[roles.line] # line art that sits directly on the UI background (SVG: currentColor)
source = "#34465b"
light = "#34465b"
@@ -66,13 +66,13 @@ parameters = 4.2
[accents.surface.active-1]
light = "#f1d2af"
-dark = "#ba8f6a"
+dark = "#cc9362"
[accents.surface.active-2]
light = "#c06f00"
-dark = "#b86f04"
+dark = "#bd750d"
[accents.surface.active-3]
light = "#a45000"
-dark = "#95682d"
+dark = "#955a0e"
[accents.form.active-1]
light = "#decff8"
@@ -85,41 +85,41 @@ light = "#7349cd"
dark = "#7b63a6"
[accents.mesh.active-1]
-light = "#e5d99b"
-dark = "#a9985f"
+light = "#ffec8e"
+dark = "#ffe282"
[accents.mesh.active-2]
-light = "#a28200"
-dark = "#9a8100"
+light = "#bb9600"
+dark = "#ab8f00"
[accents.mesh.active-3]
-light = "#826700"
-dark = "#857100"
+light = "#e0b200"
+dark = "#c6a800"
[accents.sketch.active-1]
light = "#bfe2cc"
-dark = "#81a28e"
+dark = "#7ab792"
[accents.sketch.active-2]
light = "#439a65"
-dark = "#459665"
+dark = "#3a965e"
[accents.sketch.active-3]
light = "#057f45"
-dark = "#27864e"
+dark = "#128d45"
[accents.constraint.active-1]
light = "#f0cfca"
dark = "#b98c88"
[accents.constraint.active-2]
light = "#c1685f"
-dark = "#b66b61"
+dark = "#c27267"
[accents.constraint.active-3]
-light = "#af4038"
-dark = "#a05c54"
+light = "#ca473d"
+dark = "#c16358"
[accents.construction.active-1]
light = "#ecd3b6"
-dark = "#b19373"
+dark = "#b99a78"
[accents.construction.active-2]
light = "#b8741f"
-dark = "#b4711c"
+dark = "#ad7023"
[accents.construction.active-3]
light = "#9c5600"
dark = "#a75d00"
@@ -134,12 +134,16 @@ dark = "#1d7f89"
[variants.red-green.construction.active-3]
light = "#b97300"
dark = "#a75d00"
+# The constraint red stays darker than the sketch green for a weak red sense.
+[variants.red-green.constraint.active-3]
+light = "#af4038"
+dark = "#c16358"
[variants.blue-yellow.construction.active-3]
light = "#b97300"
dark = "#c37d00"
[variants.blue-yellow.constraint.active-3]
light = "#af4038"
-dark = "#986255"
+dark = "#85554a"
# Default accent by requested icon id. Explicit alias accents in aliases.toml win.
# Deliberately not inherited from a master: ground reuses c_fix but is not a constraint.
@@ -153,9 +157,9 @@ sketch = [
"arc3", "arc_center", "arc_slot", "arc_slot_center", "arc_tangent",
"blend", "circle", "circle2", "circle3", "circle_tt",
"circle_ttt", "conic", "constrainer", "dimension", "ellipse",
- "extend", "finish", "fit_section", "include", "infinite",
+ "extend", "finish", "fit_section", "include",
"intersect", "intersection_curve", "iso_curve", "line", "line_mid",
- "offset", "point", "polygon", "polygon_circumscribed", "polygon_edge",
+ "offset", "offset_two_sides", "offset_symmetric", "point", "polygon", "polygon_circumscribed", "polygon_edge",
"project", "project_surface", "rect", "rect3", "rect_center",
"rect_rounded", "sketch", "sketch_chamfer", "sketch_chamfer_angle", "sketch_chamfer_two_distances",
"sketch_fillet", "sketch_mirror", "slot", "slot_center", "slot_overall",
@@ -168,5 +172,5 @@ constraint = [
"c_polygon", "c_smooth", "c_symmetry", "c_tangent",
]
construction = [
- "centerline", "construction",
+ "centerline", "construction", "infinite",
]
diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt
new file mode 100644
index 0000000000..57761b34ec
--- /dev/null
+++ b/assets/icons/ui/design/requested_icons.txt
@@ -0,0 +1,282 @@
+accessibility false
+activate false
+align false
+appearance false
+arc3 false
+arc_center false
+arc_slot false
+arc_slot_center false
+arc_tangent false
+as_built false
+assistant false
+auto_constrain false
+axis false
+axis_edge false
+axis_normal_to_face false
+axis_through_cylinder false
+axis_two_planes false
+axis_two_points false
+bendtable false
+blend false
+body false
+bom false
+boss false
+boundary_fill false
+bounding_solid false
+box false
+break false
+bug_report false
+c_coincident false
+c_collinear false
+c_concentric false
+c_equal false
+c_fix false
+c_hv false
+c_midpoint false
+c_parallel false
+c_perpendicular false
+c_polygon false
+c_smooth false
+c_symmetry false
+c_tangent false
+cam false
+camera false
+canvas false
+capture false
+center_of_mass false
+centerline false
+chain false
+chamfer false
+checkpoint false
+chevron false
+chevron_right false
+circle false
+circle2 false
+circle3 false
+circle_tt false
+circle_ttt false
+close false
+coil false
+combine false
+compare false
+component false
+compute false
+configuration_table false
+conic false
+constrainer false
+construction false
+contact_all false
+contact_new false
+contact_off false
+contact_sets false
+continuity false
+convert_sheet false
+copy false
+curvature_comb false
+curvature_map false
+cut false
+cylinder false
+decal false
+delete false
+delete_face false
+dimension false
+disclosure_closed false
+disclosure_open false
+draft false
+draft_analysis false
+drive false
+dxf false
+edit false
+ellipse false
+emboss false
+environment_map false
+error false
+explode false
+export false
+extend false
+extrude false
+eye false
+fastener false
+fillet false
+finish false
+fit false
+fit_section false
+flange false
+flat false
+fold false
+folder false
+gear false
+graph false
+ground false
+help false
+hem false
+hole false
+home false
+import false
+include false
+infinite false
+inspect false
+interference false
+intersect false
+intersection_curve false
+iso_analysis false
+iso_curve false
+joint false
+joint_origin false
+library false
+line false
+line_mid false
+lip false
+list false
+loft false
+lookat false
+material false
+measure false
+mesh_export false
+min_radius false
+mirror false
+motion_link false
+move false
+new false
+normal false
+offset false
+offset_face false
+offset_one_side false
+offset_symmetric false
+offset_two_sides false
+open false
+orbit false
+origin false
+pan false
+params false
+paste false
+pattern_center false
+pattern_circ false
+pattern_flip false
+pattern_path false
+pattern_rect false
+perforate false
+perspective false
+pipe false
+plane false
+plane_along_path false
+plane_angle false
+plane_midplane false
+plane_perpendicular false
+plane_tangent false
+plane_three_points false
+plane_two_edges false
+plastic_assign false
+plastic_rule false
+play false
+plus false
+point false
+point_along_path false
+point_center false
+point_edge_plane false
+point_three_planes false
+point_two_edges false
+point_vertex false
+polygon false
+polygon_circumscribed false
+polygon_edge false
+presspull false
+project false
+project_surface false
+rack_pinion false
+reach false
+rect false
+rect3 false
+rect_center false
+rect_rounded false
+redo false
+refold false
+rename false
+render_image false
+render_scene false
+reorder false
+replace_face false
+rest false
+restore false
+revert false
+revolve false
+rib false
+rigid_group false
+rollback false
+save false
+scale false
+screw false
+section false
+select false
+settings false
+sheet_rules false
+shell false
+silhouette false
+sketch false
+sketch_break false
+sketch_chamfer false
+sketch_chamfer_angle false
+sketch_chamfer_equal false
+sketch_chamfer_two false
+sketch_chamfer_two_distances false
+sketch_circ_pattern false
+sketch_dxf false
+sketch_fillet false
+sketch_mirror false
+sketch_move false
+sketch_rect_pattern false
+sketch_scale false
+sketch_text false
+slot false
+slot_center false
+slot_overall false
+snap false
+snap_fit false
+sphere false
+spin false
+spline false
+spline_cv false
+split false
+split_body false
+split_face false
+spun false
+star false
+status_error false
+style false
+suppress false
+surface_blend false
+surface_boundary false
+surface_extend false
+surface_extrude false
+surface_fair false
+surface_fillet false
+surface_loft false
+surface_offset false
+surface_patch false
+surface_reverse_normal false
+surface_revolve false
+surface_ruled false
+surface_stitch false
+surface_sweep false
+surface_thicken false
+surface_trim false
+surface_unstitch false
+surface_untrim false
+svg false
+sweep false
+text false
+thread false
+torus false
+trace false
+trim false
+undo false
+unfold false
+update false
+warning false
+web false
+ws_animate false
+ws_design false
+ws_drawing false
+ws_render false
+zebra false
+zoom false
diff --git a/assets/icons/ui/design/review.json b/assets/icons/ui/design/review.json
index 784b14c3a6..eb886ca08b 100644
--- a/assets/icons/ui/design/review.json
+++ b/assets/icons/ui/design/review.json
@@ -15,9 +15,9 @@
"as_built": "0f481932deca5586a8a8ea3d707efca0747f5c59559d53830b694d3458531013",
"assistant": "8fac392b16b4f13c6a399c59962b97c1912282e0ec909976496959472f1d642d",
"auto_constrain": "012e5da4ff83449f6a3a92ee2d9924998cbeea545281bdf97873710b7436183d",
- "axis": "66ebabe43a7b1b73b59a3a03b7bd92ab54d899947d0cc2d93ad6e6aac4d76501",
+ "axis": "acdab0eb7b99b1579d64ae190082df48b65174e7b8ad3104967bcc59f6154206",
"axis_edge": "5a65898bc38bdaaaf5b04f2c2f7556915b5b7b1fdc4de9708fcc30f64aa1ab18",
- "axis_normal_to_face": "0824bb37e80928e9ac880af5ca5fdb3b52084af9e73db73a5a5a7bc8f1f899f7",
+ "axis_normal_to_face": "597b5b96ce787b70791133267108c5196aca09d5e3f94e7dc92199a63fe49ca6",
"axis_through_cylinder": "804eb75631f4ee71ac8db51209237bb19d82bafd326abdc81b124b875c0874b4",
"axis_two_planes": "80162aa79ca7baf6d60490414a4fb53d87e6f2b85e901c452875a5f3ed86d35a",
"axis_two_points": "5064f7544ce41ae7c1f05a90c958222bbcee03723df67d34cd3e209d25a1f71f",
@@ -30,36 +30,38 @@
"boundary_fill": "17ccb419a46c04a44ec864af968a32984dc81f6b3196a821bfff7f54141dfdd1",
"bounding_solid": "e2deb6fff292f0f295022583ba7ddb86896eb79d9dd7268e653713b9c62f0580",
"box": "72cd44c3c4fc5ae71242fca8c60af47371930201276df5b7db9d2f16a2739c31",
- "break": "430582243311f304dbab397ce58c8c9aef9c78ed88d3e921a57e584ddb95d94c",
+ "break": "67a5fab332616e6d6a9aeae3bedc04ee0768179143ba34b795bdd98cea04bb24",
"bug_report": "8cf7afbe0d3c34988fd2748de148f56a7e939fd8273ba01a79a976f879c74831",
- "c_coincident": "32fb535b3dd7631dc2e9ea284f445ad54ea0e5c8b0e1bb27a9984c849746917d",
+ "c_coincident": "a93cc58acc5090c24c973cb558920bff4e35c8f99071135f16a115256d41bf98",
"c_collinear": "3bcf1dc6b221a1fa9a4445ee8afc7d858dc28a5270d22d10fef86fa4997f1bdf",
"c_concentric": "90e9b35b6186ea4fcb3debc24808f302c0bf7354b7afae86e339574ef8e5103a",
"c_equal": "c0f50c02db7d15a6392d2178e28df5c100e67fab7732f8e8474b888d218d0673",
- "c_fix": "b91c6af7ea9740efb8cf196409b11d16fad52c51b732a356e5f844bd4e2f08e0",
+ "c_fix": "23e2471a9d6872e83028e0e219e330cef1930a4d89456a0fefa1bda8a7e3eb81",
"c_hv": "b5c44d60a4b03b9942fbcf3c706f797ce4dbddf9a67eb1c98d6aaf3234e9bc18",
- "c_midpoint": "fd4efc26da1336f811a9016b02d7675af2a7c95cd1ffa2f091507b22434f5435",
+ "c_midpoint": "aaea530b8a04aa80efc99ed2cf42347a91c65b160286bae3e2882f5a0bd09a51",
"c_parallel": "aaa80258502af091b596511662aca392546dd0d7bf69cec4db98b6e0ae7591f0",
- "c_perpendicular": "692ba7a77cd77108c33c101386b60b7c957ce7d2202937d9696d18dcf3d4cf8e",
- "c_polygon": "defac40b4c6ef323494f49acbb94b896502f78f6a99e750975693c602164a44b",
- "c_smooth": "dccf5effdb8977ac04e6c437c280c83ed0f117d81b64c57fae03f5f7f7f2b9c0",
+ "c_perpendicular": "0ccf0383176ace2d4ab30c2efe853815ca1df20f2537020f369f496d8bf124b5",
+ "c_polygon": "02c76b288b42d6be8eb77f502af95bb840557f43fed3def2b1a381f6ac920375",
+ "c_smooth": "87aeb504aa330a191a8680d9eab3e86844f6d7be0a9caa10fdf0a657e76f45ee",
"c_symmetry": "8646a7deb7447514bcc455562d8639f8b4c482df8c971fd2870c05965ce71f78",
- "c_tangent": "a011f5d43d5e09f68de332c60c5acee737a3ebc94d107f521871225c3841a064",
+ "c_tangent": "ef8b1e502c2a939958b5e8de9ef2716442e32b2a394555eb7b51101c415b966e",
"cam": "a35342e36ca4deae55e98c54df630b5c2da591c06d979eb2b8ce6a13f6db66d0",
"camera": "fcd867877ea4984318dbff36a166b48682f26bb9d44e70383dde63d9a7ab87c8",
"canvas": "512d7721f0b8b14a46f22b9588b437b0cd8c2c425330d31b3b156c0d1334bcef",
"capture": "23ef84e50b45c06532b3e842b72f6da5498d0e6b8391e1bff55e84afa8359f37",
"center_of_mass": "24401b1a19cb45ddb028de0acf3c9815b47abecbde9e133f473adac3d27ae346",
- "centerline": "a1889b9092ef5a7aa9592df994b6541b53ea9afb03b2c56c7678a61df335f4d7",
+ "centerline": "850283497bad77e233f934e8effc0d0d7b01ccde83fa66f6abb539a33a8a2c80",
"chain": "9cdc78486b5c4b5b2a378e09bbd41733eb167513f9f2bc4b1aad629dd6c4c753",
"chamfer": "487c90ae65e87b74d7ddee7d9ce9f088b63e9b5b85c2a390364855a2649f17e8",
"checkpoint": "a3bc0700a40b791b5f3bf176d820bdabd2cf94a526908609d50136c8d0918d6a",
"chevron": "61887736af4b1e6bef857c4d2e3846657824e84f1c8026a56525ddba2d2a8083",
+ "chevron_right": "d28a52dcc51fd9eb988f8f83e89d74370a31100049c910a886732a48ec1342ca",
"circle": "145544ff1cd133971f537dd247092126ef8d91a88fe31b795222e76840d0c4d0",
"circle2": "f1b6e8e2157279cfe1e608f913b377e44a70f7555f5010298138de8a887bf586",
"circle3": "aaf6b914e630688675abf4dcbf7d43096317881ced0e22520a4ef229013e0de2",
"circle_tt": "94996320b671c8c48f239b8c48f1b2f1cd5cc33a7d8ea1daaa61aa9203803cae",
"circle_ttt": "ac3c211a6fe17c3625060f695ecd93937730e2bc2dd57921bcbbcaa984b9badf",
+ "close": "5833954dfba3d70a9a3a7519f2796a7213899548b0345bd8fe8ea9a321d82be2",
"coil": "4c549fd63506457165f53a7940cc0f3dcacdbe075e935ea299edbf4985104411",
"combine": "f9d4211f0153779369c9da68b266c2c9a857d11bc033ff4a96ede794e470e38e",
"compare": "c24b6c18f18413ae6f3344aaa6e04b42fae8b63e7cd1552a81398462eb68eb96",
@@ -68,7 +70,7 @@
"configuration_table": "1a142e76b9e4cd47412a307cc0ad9b8c589bb97c8930fc445dd5bb8d74ecf707",
"conic": "808445fd697ff76f9074e7bbf877146e634995c295dce045604991fa4cec26a0",
"constrainer": "774cb158897eb91767541b5b1a25a46f3a731cbea0661006ce5472634ab6b0e3",
- "construction": "ad962cbcd0aaef9167744abfd0bfe1d7ef55e48b4ff42f2b4b05f66204b58acb",
+ "construction": "f13e3851cdf7b30a7118802a1c17e8852fcb9893fd1d65c7098a5c3fc35c8396",
"contact_all": "6ad4d245592815a3e38e70ae324ad3971ab614daba7ca3cf8fcb64cb8e2be077",
"contact_new": "603410785fff408cc12dc72bef2f09885b694c5ddb2571c7819ae1301fb89dc6",
"contact_off": "54dc3bd2267ebb084d8dc7efee85e9f21d8c59a57ad37b96d78095bc75e73fa0",
@@ -83,8 +85,10 @@
"decal": "acc258e40b29ffb6b6007057f0b70f487995f573704c7ef4e4f08f209d52bddd",
"delete": "d14203f06b8b1b87328e7f198c7aa41595e9a66b5d8a7fbd2a3ec2e35cd99afd",
"delete_face": "dcbf8ab59bd37bd5a0cdd7a528b29c2d19daa5f3fc130ef5cff0c20034f061a4",
- "dimension": "8246dde8b0a140d1f533c1e45f2e8b5af35c05d3504dccf50bd7e7726a93389e",
- "dots": "aa38423c547594462f49cc355f3c9f5b41e28a7515f466a6a8cffda487ba1715",
+ "dimension": "a926b7c64bc8ca99d8d6dcbb81b95235bd3fc34fbed049aca8b01b4d1147c15d",
+ "disclosure_closed": "49a350c6f2efae78de0be96c524ebee1fd1291ea449a84224b88d37164a4e807",
+ "disclosure_open": "d13ce3f97e3e362a9904fa2bf3412f3f00e4136bc23538b92d41483961d280de",
+ "dots": "600f7ff209d93145fc938bc4f6a1e34473e6b9ee22a5b4718f133bc7da5ee58d",
"draft": "9c0fc361cacd0ad95ccd54794f4825dfc9901a83a3de752a588faec365d0ee09",
"draft_analysis": "eb39c0f90e9cf226da6307365a76015e900dd692dc3f0fdc8f02fe717226261f",
"drive": "cf9e924acb2531efd5a1b90915d59f0cb532c844b754fd3a0e376ef6f706c47d",
@@ -99,6 +103,7 @@
"export": "c8c2abf007e43e896479d78798e3976ba9eda809507c820bb38538f77db696ac",
"extend": "28c63df352c77d02feffe44cf09fb0fc1d48f7905aaabbfa6dba601dbb70f8e8",
"extrude": "9cc1538971c5d25467aaed23f739899d9d102fd07f86472ac3197c54ca2e1144",
+ "eye": "2449167c8410826dc1106b687c12a309d5bea8f7817b897943e80f182a163c2d",
"fastener": "fcff4e4be50907f712e527b373771afafd92e50096fc7a4b8aba5d86448e1e42",
"fillet": "11ec232dc111597211e3a4fe61b69616b5d28b4b1b2732052ddcd486cdfc6129",
"filter": "4d456a56416089574bd3732fa44c0c1b27fd2478b369448808a27f0144d15d8a",
@@ -110,15 +115,15 @@
"fold": "90344fb5e5799378117fbd79ef28a84f27fba5723af5414c4ea30a2ac3a4f21e",
"folder": "c19f5230df45a1bda1e92e89de38bba21c91e6eca0517eb15847a7712012d1e5",
"gear": "25a1ca48a587850da1104a46005a330873ed196246e3d04e12cf61f26ad2b0d5",
- "graph": "25646bdf4d1a534c51e1897a8ae641a21f871ed70b24ff25652e1fe957c9fa00",
- "ground": "b91c6af7ea9740efb8cf196409b11d16fad52c51b732a356e5f844bd4e2f08e0",
+ "graph": "7156caedd2dbfa2ae53da18b7a2204b8db66c45126859d36caf049a3fd4335a4",
+ "ground": "23e2471a9d6872e83028e0e219e330cef1930a4d89456a0fefa1bda8a7e3eb81",
"help": "8ce4060577483dbdb510be147d2827de50ac20029354008fca55abc0c7edf05d",
"hem": "f9b1aafbedcf3dc90c26be308814638e0095fbe31b0647092507343fa60af011",
"hole": "f82d47751f826e08682db847a270897474661bfe9f35b6d3678f49a203172563",
"home": "ab5f1c41d377687e4c5a808dfdccf2757b33dd43f934d44df43d6e9118176853",
"import": "e343540eb49fdb1e53c4d54b9e60ae513b3103df6c9133048bed878e58067455",
"include": "f5b80ad3e06e3b863fcfbe415ec912e4e09653dd519f9ac207819339fe34730f",
- "infinite": "bff57a1c56d9b47131d7c8ff85f008a53c612c63706052e7e19d7aaea93cf5b1",
+ "infinite": "53fb781131078d2f8e71be23aa610d9f9d9c8bb79ba5f97fa397475e9ff8c3bd",
"inspect": "d2b4644b2d5f1aa50cb576b9265e275fa91201e296c2bc79865f810067d538e9",
"interference": "b3d729d0e822e8d95485c8ef50649847572def10d4c713fff0e073b8031c5f5d",
"intersect": "9ab4f6551848a2be546f55502a77075bed2d3994f89d91b721eab92bcee61d61",
@@ -126,7 +131,7 @@
"iso_analysis": "dacd34ac254ec4fbb6932350f62d4d92626d922a2bfc62d2caecdeb17303e896",
"iso_curve": "015ff2e26346ccaf149f75cf6a0652d9201c1b23a14e6bb62625acfa599dc002",
"joint": "72b71a608e713f6cf51a1cb84edb011d4ccbd8bfe41d917fa2a1d13345dc0b2b",
- "joint_origin": "5b0761122eb4295ea220314e8db1efd1251e3482653d6cdcc47252d0268864a8",
+ "joint_origin": "e12529af1fce8c5ffdf746e71ce2f5db5eb170e53778469cea8fd30344291574",
"library": "ac0b1798e4c94340f9c854daa3829371c1a9f3ffea7679d955e6cfa139cafdc8",
"line": "cd1177ea659548f03d43c7fa7dcc209a0542b1ba4bd0153c5113576cb7a96a81",
"line_mid": "edb8ebc463479ae9878e54b930c124153ca880270b7cf6c0e4edba6336ba2854",
@@ -140,17 +145,20 @@
"min_radius": "92bd79b7d557aba6ddfccc76a4c6d0cfb579061b3c57172f9171d28af675711c",
"mirror": "56637068a319dc2972c5552b25e4f43151aa9bd5055c2fef08204dd7cc0829cf",
"moon": "3ba5adb92bf0f49e92d46682dbf6905e555aa6eebc8e2b3c5288f949cda29322",
- "motion_link": "19698bbe15b7c2d2601208bbcdc26627d1aa7724aee017b7da8874ad87fb9d1f",
+ "motion_link": "27832f827146446557609336a9b9e48e649ed84e58c45bd9032a93abbd454104",
"move": "4132e270ada8d0c79b477095c84d656d6d354e200c1748ce7fc425f36d0b7031",
"nav_settings": "b93dd46d3a3d074e0d8834167f977dab417fbc1a721bc4db5e840732304e4193",
"new": "c64c78fd8445bc7b2aa8765d0507b9adf23e35cbf52828d3f1987edccce0389f",
- "normal": "1148cef2d60a858b69406a2e2527d4ea126f45846de7cc2fb3a96640e9ee226f",
+ "normal": "3c000d707837d4e9c865aefa43c1e610bfce5a06a38510f82e4db11fc13ab31f",
"offset": "094607afcfdcb9c1410114d9f8d22ca367f8e32ab4c61f71affe44ad5d09adbe",
"offset_face": "83d39308ec9f3ead78329c62841c8899bbc76ce08e17d539016d18c91d9d4ea7",
+ "offset_one_side": "094607afcfdcb9c1410114d9f8d22ca367f8e32ab4c61f71affe44ad5d09adbe",
"offset_surface": "b501cfb56b8404cdb2275935d780ce7dbb67e87e29ade3782f0859c59070a2b1",
+ "offset_symmetric": "67f3489402af3afa055181bbdb2a32b9fe2e0d96dccbe0f28df087577978ac9c",
+ "offset_two_sides": "ef69f955c5bef15471e9d77a4498e9337bf938ad75dcbc1e95af2515b6fd13da",
"open": "f1880d25489753f7e40390902037bbd3195fbd099a5e9dd175797d832abff727",
"orbit": "4adcd400cdde909139386e78579433354f65f5a77a0594447bf6dda663b3b1b4",
- "origin": "9b9360edc16ef9f059bff7d863f1bc0e3abac6acf559d76c4ea39dc374ab2844",
+ "origin": "636f9f41654a6da7a5a708bcddef85672f2d77bfec2267b0134e8c5a59768b40",
"pan": "2465eda7a39d4458d7818f2eb2b033992a68f80d9505bff538b41eb4511bb632",
"params": "d0d9d0b3e786880e59b985dc2e3a7d593cf3771484a8fd2924d69155195c230f",
"paste": "e1b3c089adafacb6f7b78b86ec7aba0876b189c81d01031045dfee2c47ae8edc",
@@ -165,22 +173,23 @@
"perspective": "5fa45ba9b75dbe9fdad9eae331ca7ff35c6ad018b8a1fc4c8ae7bcfc13ed0c3f",
"pipe": "b9ecf1ae9f6790e2ae6c677f290446f70eba1773a10247fe33d5283b360b0403",
"plane": "3e7fa0a9d57891f3c1ec03d7422bdb29353d3487deed12e8ec5737aeb33c2f3a",
- "plane_along_path": "020e25969a7f4e7e3358003addee7df8b1991cde8401df0b4df8295b19497994",
+ "plane_along_path": "db4686ea02c3c3b8ad0d9eac203cc050c395cff6358358922a79c00e955e6852",
"plane_angle": "2f0914955663b393a377fda080bc03dc5a2133d42c506c1908c53b2fd609b156",
"plane_midplane": "66bd880821e7b122f130824313b7070d72d79168a52df6a126106b6eb5816474",
- "plane_perpendicular": "90e1d9b8e75743821aa1082596d9c3f288ab3baddf087fbae3f2025481e58a6e",
+ "plane_perpendicular": "0055fb18ee39044bfc9f2ac53ba55fe73d8fe59e8f4cf225ee2c723a883d3085",
"plane_tangent": "c3872b9f1d0f0b2493a5488dfdad50049c3422c29023250088eeda9bbcc6e795",
"plane_three_points": "08e2dbaf606d165ef4f788869fc794a4fbbbb2ee86a60017b76e467af6da338a",
- "plane_two_edges": "1588b8d4741382d9e8fec38212419ac1c05b1bc6036f276d3b5c62db66f8ebdb",
+ "plane_two_edges": "21de401ec5bab8ae37510da6fa0a6910325f858c17460da0041fd26897338d30",
"plastic_assign": "bbfdb2d2c07629c047e8e671c7c032654668a67b4b8a934f74cbb3d7a00cc5fe",
"plastic_rule": "51b8591d92907a3ffb76a47a0503d7ba86706d129dd990515a364dbf1ab8cb48",
"play": "d1c17ebc16e9a4ee5ae2a8cc37b515ffcc8c53a2ab17117959e9b21278df8def",
+ "plus": "4f324157bb2348ac9f09346b669b08d66ed96cb1c694f33db6f21134f18904b5",
"point": "fd19dbcd26e2a898267bab54b9d89779d97894209c1771317d7debef5a6f8f5d",
- "point_along_path": "1fd58d45285fb5cabeddbd35bc8485af1b6d7f1414e302202b4e73de593d1b7a",
+ "point_along_path": "17abd16dec5f70e9f8449c927aa995cfed10fca552ec7cd8f51b209c52012595",
"point_center": "0ad755896f7d0154a854bda16d3059da78d1fae57962e13a3bb1b31e284b7e79",
- "point_edge_plane": "548a6c1c944caabe44ab0318e85ae82f39c11f74fbedda35f57bc6615755f249",
+ "point_edge_plane": "a277bc0b87f2dd39eb613835d0f961b3372483e22053e6a522a06c535ad530c4",
"point_three_planes": "b33c7508ffa67b66a57b72c6ea7900e93ff16362a29d0b2688e0b1db9bfad041",
- "point_two_edges": "35dcb67b36c8e41041cc836b01056731ab6f14c5e3b4bdd836fbee2a1dd897e3",
+ "point_two_edges": "da329241706e405b877cec20639dc0a78505ca7212c7c47ad1f1f34aa26f4666",
"point_vertex": "649bb63caf65a3fbc00a1222cc642294832b5e5d8c4d33f812e09a70684c4abe",
"polygon": "4919268cca7d21ce98dbf4ca01ee832350e793afe4213e257d3c46e94ea88ad1",
"polygon_circumscribed": "7e4ad16cc1f42c599287b186f26f4ff3c108736877a571a5513bfc72d0cbb23f",
@@ -214,17 +223,19 @@
"scale": "a66f69d9a1d46c8be30da0a15827bc7e38cba72d6271537763b888c2c7e2b3fa",
"screw": "5e30570785360d6a591ea22862a82f1cf62228385c1e96382536db8a453ac791",
"section": "cdd13f99f15f6d59bfa21c747810608d6afd00cb8207faf0337928c8521e7eae",
- "select": "a0c716234ef1d599be9a7654d6b2911ebe4b2de479383ba33aeab14992443a2f",
+ "select": "fdf6431270006ca7409c60c37cfed59572de04229f104ec723e6010ffa2b7163",
"settings": "9193dd3a1007c43660d0d47b6499cb2571338b67949e1a99df112057b9bf2b8a",
"sheet": "774e30923ef6f37dd9c0b2bc3e45705e83b3a76700bf071cd41155a365d0daa4",
- "sheet_rules": "b8c3a67c82be20fc00c109decc566e8755d70167e04e0a9fb92941f7b27aa993",
+ "sheet_rules": "5d3a2f37d3b4a4262b3ddbdae53d61f29e0f8e284dd54006da25a7acebfa1114",
"shell": "a1959ea0d0441a479bf654b6e549e2e44a0bfdc9cda4eb46fe1fbfd884de7e38",
"silhouette": "2a848aed2f247b1c0439f830a34a513c93bc5493c40044c821d493d863ad996e",
"sketch": "b52e5862b1709a9a7e3ca00d7436d126fbfc01b38080006fa4e17dc581dfa103",
- "sketch_break": "430582243311f304dbab397ce58c8c9aef9c78ed88d3e921a57e584ddb95d94c",
+ "sketch_break": "67a5fab332616e6d6a9aeae3bedc04ee0768179143ba34b795bdd98cea04bb24",
"sketch_chamfer": "80ab27a9929f9cf0ab2f827757e007173d74ddca6c19af238931c40d4cd874b4",
- "sketch_chamfer_angle": "b853f5e7c3b008c0d56ac445a9a28f713987c919ea284945113ad35e7665e2a7",
- "sketch_chamfer_two_distances": "2b70d658e341f4388838f3c8c579ec5f4f3a7fddcfa2ce7a3f89fc3db6422d6e",
+ "sketch_chamfer_angle": "6750268d05e0b0fd74c2d0368bf4703b09da825def668dc3dfd05deef3ba9adb",
+ "sketch_chamfer_equal": "80ab27a9929f9cf0ab2f827757e007173d74ddca6c19af238931c40d4cd874b4",
+ "sketch_chamfer_two": "1f5ecf1283e2b021e067ed2e4e2e97aa4e1ad3c7c98d8609bb81c5f811988f78",
+ "sketch_chamfer_two_distances": "1f5ecf1283e2b021e067ed2e4e2e97aa4e1ad3c7c98d8609bb81c5f811988f78",
"sketch_circ_pattern": "c5ff904237a3072f858f66c2777febc4facd2fee630bbf979047c5685d9a05ce",
"sketch_dxf": "dddce44d4dd10f75a221208fcf431b36b3f0cafce6611fc695ac73afb4bf5789",
"sketch_fillet": "e8fa170e5f6899abf75788b9384d49f2b9d77ba9b644f79309284a9e65629fe1",
@@ -242,6 +253,7 @@
"spin": "a5bebeff8276dd12ab7e42ddf0051370b9063fb602607298acf22e77044434d1",
"spline": "a0dcb25614e5fe1a8f17bc3bddbb11b61cf82b461dd46443ab28cddd6e4e32e3",
"spline_cv": "353f6e411c0ce611f660cef2e4fc4f8f55edc2c82288de91948dc638cd2b5f15",
+ "split": "eb9619e74c6ee1b1989d35a2e31d2d33a7adac210c4cd424e5382902945ac68b",
"split_body": "eb9619e74c6ee1b1989d35a2e31d2d33a7adac210c4cd424e5382902945ac68b",
"split_face": "c8b89072118bb7a28b243d38e26b81a796781a631f30b3b1fc296ba23e4d908d",
"spun": "b4cfa093ffb43611ee124f4a39fb44c609deb9cde5e05e4dfbaf893fe197c27b",
@@ -250,6 +262,7 @@
"status_warning": "1ac4f0ccfac2c01f6f66cb42188f9ae053c4aef9c5bbd249f1fb09611eb4d825",
"stitch": "6c3205d64007b771ed78d6f8055867578439fb25d591563b32dbd3343c98732d",
"style": "6c2b04234b82ea4858c80190cc7208c60f549358253005afc35ab4e29506b578",
+ "suppress": "c54fbc01c12c0175d78cd63f692e8aaf73fc2cac79752b2a3ad821ac32734343",
"surface": "ba0e839ce0ee03e7ff95a2389a5ecb20bd80c713064d9b1bd5f461f4a80d1921",
"surface_blend": "0642f3b4af7d22f379a3c74f54c7b1c9eef0bdda19372ce4df73c0e56bdd7bbc",
"surface_boundary": "fb8501bae192e2416118cc2e88f544e0e29197f6720bccc541c967ca0848d8d3",
@@ -265,14 +278,14 @@
"surface_ruled": "c3f0202d3beaacef0368765ce771eb9e3b0e3e157f86564c72d81f0fad9a3cab",
"surface_stitch": "6c3205d64007b771ed78d6f8055867578439fb25d591563b32dbd3343c98732d",
"surface_sweep": "6d7f18c12b2e4c1dbe3632fe08239687f6f027b29b6dddbf8c8e2d9151c7baf3",
- "surface_thicken": "676eb73a99d708214e8951ebe2c4d88d60de2d752c725d8106d12fbd812e461a",
+ "surface_thicken": "35aaa8e4fdbcd220a3a05165d5230a7ce576fbf5a6a5772d27162ab61bb71538",
"surface_trim": "ae269721b386bd1264184b9838df3240b5b6ba02b99c9993384ef21200fb7398",
"surface_unstitch": "bd8302fe95a89eb6f9bbf35ef0ee98c8a2186e160cff3d091f8cf2a0a75d4473",
"surface_untrim": "24de5d558519e0629280d11919ba5661c92ccdccdce03f8f3d83f2d7867c2173",
"svg": "7da77d53c84db18ce95737ad633c105d1009444b3192a5e0aae76873cfc9cc12",
"sweep": "6d7f18c12b2e4c1dbe3632fe08239687f6f027b29b6dddbf8c8e2d9151c7baf3",
"text": "9d31b72b16644681c8a86ac257511847ad69ce4351cf6960442222e94b168c4a",
- "thicken": "676eb73a99d708214e8951ebe2c4d88d60de2d752c725d8106d12fbd812e461a",
+ "thicken": "35aaa8e4fdbcd220a3a05165d5230a7ce576fbf5a6a5772d27162ab61bb71538",
"thread": "158728c3dcf6623bb1584d162398bb12c28d18770e0d47f5e6328355ce31b37c",
"torus": "5ae13fc213582e0844118b910a3a26efd9e4b177d21500363fbae230803cb4fd",
"trace": "5f2ecc61d4591d3c3b0ecccd35296b8613fce7beb2ae214fb906160c31d89187",
@@ -284,7 +297,7 @@
"update": "c675e16df4c78589a00be4a34f98627500681672ee8a668e929aec50982da3cc",
"warning": "1ac4f0ccfac2c01f6f66cb42188f9ae053c4aef9c5bbd249f1fb09611eb4d825",
"web": "be5cd95bebcd0ebe257f9eb862112124429b381ef4a2f0849938fac7c9ccc619",
- "ws_animate": "d36a0834ad989a6e16e2b0db493ad8867c590caedf0442c51eff19e934c887f8",
+ "ws_animate": "f34f187850789cc4f141b1ace114082be04edec8e7771d6730fec1cef19c7f64",
"ws_design": "7b1dd678a2d018892b965a78932c047bbfff6b4439d7bd9fe85c09a995f97581",
"ws_drawing": "61e99c7179f3448a31b8c76392334352ec3d5e39b0b92fe5244940146d0986cb",
"ws_render": "1bfe474d1742623ad2142129e4d6a40015e674813eb1db401d2e88e55b1f2a03",
@@ -292,6 +305,9 @@
"zoom": "89c121fa85df034d70bd9f06e20cbd54d163691d4df03b13a9ac5372e951aeda"
},
"notes": {
- "pattern_flip": "This feels sparse. Improve the composition"
+ "construction": "Fix the bottom dot's position",
+ "infinite": "Make the infinity symbol use the 'Line art' colour",
+ "pattern_flip": "This feels sparse. Improve the composition",
+ "sheet_rules": "Make the top line also blue"
}
}
diff --git a/assets/icons/ui/design/svg/flat/chevron_right.svg b/assets/icons/ui/design/svg/flat/chevron_right.svg
new file mode 100644
index 0000000000..e07c0d022f
--- /dev/null
+++ b/assets/icons/ui/design/svg/flat/chevron_right.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
+ <title>Chevron right</title>
+ <path d="M24 16L40 32L24 48" fill="none" stroke="currentColor" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"/>
+</svg>
diff --git a/assets/icons/ui/design/svg/model/axis.svg b/assets/icons/ui/design/svg/model/axis.svg
index 79434aeb90..6090eb91f6 100644
--- a/assets/icons/ui/design/svg/model/axis.svg
+++ b/assets/icons/ui/design/svg/model/axis.svg
@@ -4,5 +4,5 @@
<path d="M12 52L52 52" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M12 8L16.5 17L7.5 17Z" fill="#236ead"/>
<path d="M56 52L47 56.5L47 47.5Z" fill="#236ead"/>
- <circle cx="12" cy="52" r="4" fill="#34465b"/>
+ <circle cx="12" cy="52" r="4" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/axis_normal_to_face.svg b/assets/icons/ui/design/svg/model/axis_normal_to_face.svg
index efddcd5677..aa60b7a8da 100644
--- a/assets/icons/ui/design/svg/model/axis_normal_to_face.svg
+++ b/assets/icons/ui/design/svg/model/axis_normal_to_face.svg
@@ -6,5 +6,5 @@
<path d="M32 6L32 33" fill="none" stroke="#ffffff" stroke-width="6.45" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 6L32 33" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 27.6L36.68 30.3L36.68 35.7" fill="none" stroke="#ffffff" stroke-width="4.05" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 27.6L36.68 30.3L36.68 35.7" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 27.6L36.68 30.3L36.68 35.7" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/break.svg b/assets/icons/ui/design/svg/model/break.svg
index 614bed30dc..43d5f0a88c 100644
--- a/assets/icons/ui/design/svg/model/break.svg
+++ b/assets/icons/ui/design/svg/model/break.svg
@@ -3,5 +3,5 @@
<path d="M7 32L23 32M41 32L57 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="23" cy="32" r="3.07" fill="#236ead"/>
<circle cx="41" cy="32" r="3.07" fill="#236ead"/>
- <path d="M32 22L32 42" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 22L32 42" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_coincident.svg b/assets/icons/ui/design/svg/model/c_coincident.svg
index 01bc385e4c..23712c129a 100644
--- a/assets/icons/ui/design/svg/model/c_coincident.svg
+++ b/assets/icons/ui/design/svg/model/c_coincident.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Coincident</title>
- <path d="M10.4 42.32L32 27.92" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 27.92L53.6 37.52" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10.4 42.32L32 27.92" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 27.92L53.6 37.52" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M25.76 27.92A6.24 6.24 0 1 0 38.24 27.92A6.24 6.24 0 1 0 25.76 27.92Z" fill="#b9ddf8" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_fix.svg b/assets/icons/ui/design/svg/model/c_fix.svg
index 7de87c238d..fce9b3ce30 100644
--- a/assets/icons/ui/design/svg/model/c_fix.svg
+++ b/assets/icons/ui/design/svg/model/c_fix.svg
@@ -2,5 +2,5 @@
<title>Fixed</title>
<path d="M22.4 22.4A9.6 9.6 0 1 0 41.6 22.4A9.6 9.6 0 1 0 22.4 22.4Z" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 32L32 51.2" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M24.8 51.2L39.2 51.2" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M24.8 51.2L39.2 51.2" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_midpoint.svg b/assets/icons/ui/design/svg/model/c_midpoint.svg
index e2a504a6ea..37e0989829 100644
--- a/assets/icons/ui/design/svg/model/c_midpoint.svg
+++ b/assets/icons/ui/design/svg/model/c_midpoint.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Midpoint</title>
- <path d="M10.4 39.2L53.6 24.8" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10.4 39.2L53.6 24.8" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="32" cy="32" r="7.3" fill="#ffffff"/>
<circle cx="32" cy="32" r="5.6" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_perpendicular.svg b/assets/icons/ui/design/svg/model/c_perpendicular.svg
index 56bfc50ce2..8b7280e040 100644
--- a/assets/icons/ui/design/svg/model/c_perpendicular.svg
+++ b/assets/icons/ui/design/svg/model/c_perpendicular.svg
@@ -2,5 +2,5 @@
<title>Perpendicular</title>
<path d="M12.8 48.8L51.2 48.8" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 48.8L32 15.2" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 39.2L41.6 39.2L41.6 48.8" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 39.2L41.6 39.2L41.6 48.8" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_polygon.svg b/assets/icons/ui/design/svg/model/c_polygon.svg
index 918d59de22..fa36be4067 100644
--- a/assets/icons/ui/design/svg/model/c_polygon.svg
+++ b/assets/icons/ui/design/svg/model/c_polygon.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Regular polygon</title>
<path d="M52.4 32L42.2 49.67L21.8 49.67L11.6 32L21.8 14.33L42.2 14.33Z" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 32L52.4 32" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <circle cx="32" cy="32" r="3.4" fill="#34465b"/>
+ <path d="M32 32L52.4 32" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <circle cx="32" cy="32" r="3.4" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_smooth.svg b/assets/icons/ui/design/svg/model/c_smooth.svg
index 972a625e23..999f01d21d 100644
--- a/assets/icons/ui/design/svg/model/c_smooth.svg
+++ b/assets/icons/ui/design/svg/model/c_smooth.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Curvature</title>
- <path d="M10.4 32L12.2 27.65L14 23.6L15.8 20.12L17.6 17.45L19.4 15.77L21.2 15.2L23 15.77L24.8 17.45L26.6 20.12L28.4 23.6L30.2 27.65L32 32" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10.4 32L12.2 27.65L14 23.6L15.8 20.12L17.6 17.45L19.4 15.77L21.2 15.2L23 15.77L24.8 17.45L26.6 20.12L28.4 23.6L30.2 27.65L32 32" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 32L33.8 36.35L35.6 40.4L37.4 43.88L39.2 46.55L41 48.23L42.8 48.8L44.6 48.23L46.4 46.55L48.2 43.88L50 40.4L51.8 36.35L53.6 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <circle cx="32" cy="32" r="3.4" fill="#34465b"/>
+ <circle cx="32" cy="32" r="3.4" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/c_tangent.svg b/assets/icons/ui/design/svg/model/c_tangent.svg
index 8965660299..5bd8392e8c 100644
--- a/assets/icons/ui/design/svg/model/c_tangent.svg
+++ b/assets/icons/ui/design/svg/model/c_tangent.svg
@@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Tangent</title>
- <path d="M17.6 32A14.4 14.4 0 1 0 46.4 32A14.4 14.4 0 1 0 17.6 32Z" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M17.6 32A14.4 14.4 0 1 0 46.4 32A14.4 14.4 0 1 0 17.6 32Z" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M10.4 17.6L53.6 17.6" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/centerline.svg b/assets/icons/ui/design/svg/model/centerline.svg
index d839cff649..bd1b7b06d5 100644
--- a/assets/icons/ui/design/svg/model/centerline.svg
+++ b/assets/icons/ui/design/svg/model/centerline.svg
@@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Centerline</title>
- <path d="M10 32L23 32M41 32L54 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M11 53L23.41 40.59M40.59 23.41L53 11" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="32" cy="32" r="3.6" fill="#236ead"/>
- <circle cx="10" cy="32" r="5.8" fill="#ffffff"/>
- <circle cx="10" cy="32" r="3.4" fill="#236ead"/>
- <circle cx="54" cy="32" r="5.8" fill="#ffffff"/>
- <circle cx="54" cy="32" r="3.4" fill="#236ead"/>
+ <circle cx="11" cy="53" r="5.8" fill="#ffffff"/>
+ <circle cx="11" cy="53" r="3.4" fill="#236ead"/>
+ <circle cx="53" cy="11" r="5.8" fill="#ffffff"/>
+ <circle cx="53" cy="11" r="3.4" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/construction.svg b/assets/icons/ui/design/svg/model/construction.svg
index 76d509885b..bae8ebc36b 100644
--- a/assets/icons/ui/design/svg/model/construction.svg
+++ b/assets/icons/ui/design/svg/model/construction.svg
@@ -1,7 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Construction</title>
- <path d="M13 51L19 45M25 39L31 33M37 27L43 21M49 15L51 13" fill="none" stroke="#6f879c" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M10 54L12 52" fill="none" stroke="#6f879c" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <circle cx="12" cy="52" r="3.07" fill="#6f879c"/>
- <circle cx="52" cy="12" r="3.07" fill="#6f879c"/>
+ <path d="M17 47L23 41M29 35L35 29M41 23L47 17" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <circle cx="11" cy="53" r="3.07" fill="#236ead"/>
+ <circle cx="53" cy="11" r="3.07" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/dimension.svg b/assets/icons/ui/design/svg/model/dimension.svg
index fb51381dbc..a54f43b823 100644
--- a/assets/icons/ui/design/svg/model/dimension.svg
+++ b/assets/icons/ui/design/svg/model/dimension.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Dimension</title>
- <path d="M10 12L10 52M54 12L54 52" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10 12L10 52M54 12L54 52" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M19 32L45 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M13 32L24 26L24 38Z" fill="#236ead"/>
<path d="M51 32L40 38L40 26Z" fill="#236ead"/>
diff --git a/assets/icons/ui/design/svg/model/dots.svg b/assets/icons/ui/design/svg/model/dots.svg
index 0aa05f3105..3e8f0a1363 100644
--- a/assets/icons/ui/design/svg/model/dots.svg
+++ b/assets/icons/ui/design/svg/model/dots.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>More</title>
- <circle cx="13" cy="32" r="5" fill="#34465b"/>
- <circle cx="32" cy="32" r="5" fill="#34465b"/>
- <circle cx="51" cy="32" r="5" fill="#34465b"/>
+ <circle cx="13" cy="32" r="5" fill="currentColor"/>
+ <circle cx="32" cy="32" r="5" fill="currentColor"/>
+ <circle cx="51" cy="32" r="5" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/graph.svg b/assets/icons/ui/design/svg/model/graph.svg
index 215ce75530..2de6c208fd 100644
--- a/assets/icons/ui/design/svg/model/graph.svg
+++ b/assets/icons/ui/design/svg/model/graph.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Dependency graph</title>
- <path d="M16.5 17L47.5 32L16.5 47" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M16.5 17L47.5 32L16.5 47" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M8.6 12.44L16.5 17L16.5 26.12L8.6 21.56Z" fill="#b8c3cf"/>
<path d="M24.4 12.44L16.5 17L16.5 26.12L24.4 21.56Z" fill="#8e9faf"/>
<path d="M16.5 7.88L24.4 12.44L16.5 17L8.6 12.44Z" fill="#e2e8ef"/>
diff --git a/assets/icons/ui/design/svg/model/infinite.svg b/assets/icons/ui/design/svg/model/infinite.svg
index 55bca1e955..20619d8d79 100644
--- a/assets/icons/ui/design/svg/model/infinite.svg
+++ b/assets/icons/ui/design/svg/model/infinite.svg
@@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Infinite line</title>
- <path d="M32 32L15.66 48.34" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M10 54L13.18 44.45L19.55 50.82Z" fill="#34465b"/>
- <path d="M32 32L48.34 15.66" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M54 10L50.82 19.55L44.45 13.18Z" fill="#34465b"/>
+ <path d="M32 32L15.66 48.34" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10 54L13.18 44.45L19.55 50.82Z" fill="#236ead"/>
+ <path d="M32 32L48.34 15.66" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M54 10L50.82 19.55L44.45 13.18Z" fill="#236ead"/>
<path d="M32 32C26.86 22.57 20 23.43 20 32C20 40.57 26.86 41.43 32 32C37.14 22.57 44 23.43 44 32C44 40.57 37.14 41.43 32 32" fill="none" stroke="#ffffff" stroke-width="10.5" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 32C26.86 22.57 20 23.43 20 32C20 40.57 26.86 41.43 32 32C37.14 22.57 44 23.43 44 32C44 40.57 37.14 41.43 32 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 32C26.86 22.57 20 23.43 20 32C20 40.57 26.86 41.43 32 32C37.14 22.57 44 23.43 44 32C44 40.57 37.14 41.43 32 32" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/joint_origin.svg b/assets/icons/ui/design/svg/model/joint_origin.svg
index aa8114d0c5..24799a9ef0 100644
--- a/assets/icons/ui/design/svg/model/joint_origin.svg
+++ b/assets/icons/ui/design/svg/model/joint_origin.svg
@@ -13,5 +13,5 @@
<path d="M26.03 34.5L17.85 53.09" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M15.03 59.5L13.97 47.02L24.95 51.85Z" fill="#236ead"/>
<circle cx="26.03" cy="34.5" r="9" fill="#ffffff"/>
- <circle cx="26.03" cy="34.5" r="6.3" fill="#34465b"/>
+ <circle cx="26.03" cy="34.5" r="6.3" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/motion_link.svg b/assets/icons/ui/design/svg/model/motion_link.svg
index 5fa9c62663..e48e5eaa01 100644
--- a/assets/icons/ui/design/svg/model/motion_link.svg
+++ b/assets/icons/ui/design/svg/model/motion_link.svg
@@ -14,6 +14,6 @@
<path d="M44.97 12.22L40.5 14.72L41.55 8.4Z" fill="#236ead" />
<path d="M30.8 33.02L30.38 32.94L29.95 32.91L29.51 32.9L29.05 32.94L28.59 33.01L28.11 33.12L27.63 33.27L27.14 33.45L26.64 33.67L26.15 33.93L25.65 34.21L25.16 34.53L24.66 34.88L24.17 35.26L23.69 35.68L23.21 36.12L22.75 36.58L22.29 37.07L21.85 37.59L21.42 38.12L21 38.68L20.6 39.25L20.22 39.84L19.86 40.44L19.52 41.05L19.2 41.68L18.91 42.31L18.63 42.94L18.38 43.58L18.16 44.23L17.96 44.87L17.8 45.5L17.65 46.13L17.54 46.76L17.45 47.37L17.39 47.98L17.37 48.57L17.37 49.14L17.39 49.69L17.45 50.23L17.54 50.75L17.65 51.24L17.8 51.71L17.96 52.15L18.16 52.56L18.38 52.94L18.63 53.3L18.91 53.62" fill="none" stroke="#ffffff" stroke-width="4.8" stroke-linejoin="round" stroke-linecap="round" />
<path d="M20.23 55.13L15.18 54.22L20 50.01Z" fill="#ffffff" stroke="#ffffff" stroke-width="2" stroke-linejoin="round" stroke-linecap="round" />
- <path d="M30.8 33.02L30.38 32.94L29.95 32.91L29.51 32.9L29.05 32.94L28.59 33.01L28.11 33.12L27.63 33.27L27.14 33.45L26.64 33.67L26.15 33.93L25.65 34.21L25.16 34.53L24.66 34.88L24.17 35.26L23.69 35.68L23.21 36.12L22.75 36.58L22.29 37.07L21.85 37.59L21.42 38.12L21 38.68L20.6 39.25L20.22 39.84L19.86 40.44L19.52 41.05L19.2 41.68L18.91 42.31L18.63 42.94L18.38 43.58L18.16 44.23L17.96 44.87L17.8 45.5L17.65 46.13L17.54 46.76L17.45 47.37L17.39 47.98L17.37 48.57L17.37 49.14L17.39 49.69L17.45 50.23L17.54 50.75L17.65 51.24L17.8 51.71L17.96 52.15L18.16 52.56L18.38 52.94L18.63 53.3L18.91 53.62" fill="none" stroke="#34465b" stroke-width="2.6" stroke-linejoin="round" stroke-linecap="round" />
- <path d="M20.23 55.13L15.18 54.22L20 50.01Z" fill="#34465b" />
+ <path d="M30.8 33.02L30.38 32.94L29.95 32.91L29.51 32.9L29.05 32.94L28.59 33.01L28.11 33.12L27.63 33.27L27.14 33.45L26.64 33.67L26.15 33.93L25.65 34.21L25.16 34.53L24.66 34.88L24.17 35.26L23.69 35.68L23.21 36.12L22.75 36.58L22.29 37.07L21.85 37.59L21.42 38.12L21 38.68L20.6 39.25L20.22 39.84L19.86 40.44L19.52 41.05L19.2 41.68L18.91 42.31L18.63 42.94L18.38 43.58L18.16 44.23L17.96 44.87L17.8 45.5L17.65 46.13L17.54 46.76L17.45 47.37L17.39 47.98L17.37 48.57L17.37 49.14L17.39 49.69L17.45 50.23L17.54 50.75L17.65 51.24L17.8 51.71L17.96 52.15L18.16 52.56L18.38 52.94L18.63 53.3L18.91 53.62" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linejoin="round" stroke-linecap="round" />
+ <path d="M20.23 55.13L15.18 54.22L20 50.01Z" fill="currentColor" />
</svg>
diff --git a/assets/icons/ui/design/svg/model/normal.svg b/assets/icons/ui/design/svg/model/normal.svg
index 97f3d7fb10..84d15407e1 100644
--- a/assets/icons/ui/design/svg/model/normal.svg
+++ b/assets/icons/ui/design/svg/model/normal.svg
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Normal line</title>
- <path d="M11 53L53 11" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M11 53L53 11" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/offset_symmetric.svg b/assets/icons/ui/design/svg/model/offset_symmetric.svg
new file mode 100644
index 0000000000..e767ce99d7
--- /dev/null
+++ b/assets/icons/ui/design/svg/model/offset_symmetric.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
+ <title>Symmetric offset</title>
+ <path d="M8 56L8 40A32 32 0 0 1 40 8L56 8" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M20 56L20 40A20 20 0 0 1 40 20L56 20" fill="none" stroke="#8e9faf" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 56L32 40A8 8 0 0 1 40 32L56 32" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+</svg>
diff --git a/assets/icons/ui/design/svg/model/offset_two_sides.svg b/assets/icons/ui/design/svg/model/offset_two_sides.svg
new file mode 100644
index 0000000000..75f9555eeb
--- /dev/null
+++ b/assets/icons/ui/design/svg/model/offset_two_sides.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
+ <title>Two independent offset sides</title>
+ <path d="M8 56L8 40A32 32 0 0 1 40 8L56 8" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M24 56L24 40A16 16 0 0 1 40 24L56 24" fill="none" stroke="#8e9faf" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M34 56L34 40A6 6 0 0 1 40 34L56 34" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+</svg>
diff --git a/assets/icons/ui/design/svg/model/origin.svg b/assets/icons/ui/design/svg/model/origin.svg
index 1379189ce9..23af9e99ff 100644
--- a/assets/icons/ui/design/svg/model/origin.svg
+++ b/assets/icons/ui/design/svg/model/origin.svg
@@ -2,10 +2,10 @@
<title>Origin</title>
<path d="M32 39L32 19" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 11L37 20L27 20Z" fill="#236ead"/>
- <path d="M32 39L49.09 48.97" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M56 53L45.71 52.78L50.75 44.15Z" fill="#34465b"/>
- <path d="M32 39L14.91 48.97" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M8 53L13.25 44.15L18.29 52.78Z" fill="#34465b"/>
+ <path d="M32 39L49.09 48.97" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M56 53L45.71 52.78L50.75 44.15Z" fill="currentColor"/>
+ <path d="M32 39L14.91 48.97" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M8 53L13.25 44.15L18.29 52.78Z" fill="currentColor"/>
<path d="M26.3 35.71L32 39L32 45.58L26.3 42.29Z" fill="#b8c3cf"/>
<path d="M37.7 35.71L32 39L32 45.58L37.7 42.29Z" fill="#8e9faf"/>
<path d="M32 32.42L37.7 35.71L32 39L26.3 35.71Z" fill="#e2e8ef"/>
diff --git a/assets/icons/ui/design/svg/model/plane_along_path.svg b/assets/icons/ui/design/svg/model/plane_along_path.svg
index 193935e43c..36ea58973a 100644
--- a/assets/icons/ui/design/svg/model/plane_along_path.svg
+++ b/assets/icons/ui/design/svg/model/plane_along_path.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Plane along path</title>
- <path d="M7 48C18 48 19 32 32 32C45 32 46 16 57 16" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M7 48C18 48 19 32 32 32C45 32 46 16 57 16" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M22 13L42 25L42 51L22 39Z" fill="#b9ddf8" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round" stroke-dasharray="0.1 5"/>
- <path d="M32 32C45 32 46 16 57 16" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 32C45 32 46 16 57 16" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/plane_perpendicular.svg b/assets/icons/ui/design/svg/model/plane_perpendicular.svg
index d205e87da5..1e9abb9f6b 100644
--- a/assets/icons/ui/design/svg/model/plane_perpendicular.svg
+++ b/assets/icons/ui/design/svg/model/plane_perpendicular.svg
@@ -3,5 +3,5 @@
<path d="M28.71 27.48L56.68 43.63L35.29 55.98L7.32 39.84Z" fill="#b8c3cf" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M18.01 33.66L45.99 49.81L45.99 24.16L18.01 8.01Z" fill="#b9ddf8" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round" stroke-dasharray="0.1 5"/>
<path d="M25.42 45.53L25.42 37.94L32 34.13" fill="none" stroke="#ffffff" stroke-width="4.05" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M25.42 45.53L25.42 37.94L32 34.13" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M25.42 45.53L25.42 37.94L32 34.13" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/plane_two_edges.svg b/assets/icons/ui/design/svg/model/plane_two_edges.svg
index 89e80fe6d4..cd6c34b9d8 100644
--- a/assets/icons/ui/design/svg/model/plane_two_edges.svg
+++ b/assets/icons/ui/design/svg/model/plane_two_edges.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Plane through two edges</title>
<path d="M25.9 17.92L56.39 35.52L38.1 46.08L7.61 28.48Z" fill="#b9ddf8" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round" stroke-dasharray="0.1 5"/>
- <path d="M18.28 17.92L56.39 39.92" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M7.61 24.08L45.72 46.08" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M18.28 17.92L56.39 39.92" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M7.61 24.08L45.72 46.08" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/point_along_path.svg b/assets/icons/ui/design/svg/model/point_along_path.svg
index 37b4bd66ac..53acd98e45 100644
--- a/assets/icons/ui/design/svg/model/point_along_path.svg
+++ b/assets/icons/ui/design/svg/model/point_along_path.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Point along path</title>
- <path d="M8 48.8C16 48.8 17 19.8 32 19.8C47 19.8 48 44.8 56 44.8" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M8 48.8C16 48.8 17 19.8 32 19.8C47 19.8 48 44.8 56 44.8" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="32" cy="19.8" r="6.2" fill="#ffffff"/>
<circle cx="32" cy="19.8" r="4.5" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/point_edge_plane.svg b/assets/icons/ui/design/svg/model/point_edge_plane.svg
index 8b8b93035b..ec94d02ecd 100644
--- a/assets/icons/ui/design/svg/model/point_edge_plane.svg
+++ b/assets/icons/ui/design/svg/model/point_edge_plane.svg
@@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Point at edge and plane</title>
- <path d="M22 6.55L40 58.55" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M22 6.55L40 58.55" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M29.66 21.6L56.16 36.9L34.34 49.5L7.84 34.2Z" fill="#e2e8ef" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M22 6.55L32 35.44" fill="none" stroke="#ffffff" stroke-width="5.4" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M22 6.55L32 35.44" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M22 6.55L32 35.44" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="32" cy="35.44" r="6.2" fill="#ffffff"/>
<circle cx="32" cy="35.44" r="4.5" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/point_two_edges.svg b/assets/icons/ui/design/svg/model/point_two_edges.svg
index b4844e8845..9f81d196f2 100644
--- a/assets/icons/ui/design/svg/model/point_two_edges.svg
+++ b/assets/icons/ui/design/svg/model/point_two_edges.svg
@@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Point through two edges</title>
- <path d="M9 39L55 25M15 13L49 51" fill="none" stroke="#34465b" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M9 39L55 25M15 13L49 51" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="32" cy="32" r="6.2" fill="#ffffff"/>
<circle cx="32" cy="32" r="4.5" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/select.svg b/assets/icons/ui/design/svg/model/select.svg
index 461b436e74..b9528a63d9 100644
--- a/assets/icons/ui/design/svg/model/select.svg
+++ b/assets/icons/ui/design/svg/model/select.svg
@@ -1,4 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Select</title>
- <path d="M18 7L18 50L28.5 40.5L35.5 56L43 52.5L36 37.5L50 37.5Z" fill="#34465b" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M18 7L18 50L28.5 40.5L35.5 56L43 52.5L36 37.5L50 37.5Z" fill="currentColor" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/sheet_rules.svg b/assets/icons/ui/design/svg/model/sheet_rules.svg
index bc73919939..b72d7bce35 100644
--- a/assets/icons/ui/design/svg/model/sheet_rules.svg
+++ b/assets/icons/ui/design/svg/model/sheet_rules.svg
@@ -6,7 +6,7 @@
<path d="M27.98 26L58.77 43.77L58.77 46.86L36.02 60L5.23 42.23L5.23 39.14Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M5.23 39.14L36.02 56.91L58.77 43.77" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M36.02 56.91L36.02 60" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M10 12L54 12" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10 12L54 12" fill="none" stroke="#236ead" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M14 12L14 20" fill="none" stroke="#236ead" stroke-width="2.97" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M22 12L22 17" fill="none" stroke="#236ead" stroke-width="2.97" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M30 12L30 20" fill="none" stroke="#236ead" stroke-width="2.97" stroke-linejoin="round" stroke-linecap="round"/>
diff --git a/assets/icons/ui/design/svg/model/sketch_chamfer_angle.svg b/assets/icons/ui/design/svg/model/sketch_chamfer_angle.svg
index bcebd81aff..b38ccb1dfb 100644
--- a/assets/icons/ui/design/svg/model/sketch_chamfer_angle.svg
+++ b/assets/icons/ui/design/svg/model/sketch_chamfer_angle.svg
@@ -2,7 +2,7 @@
<title>Distance and angle sketch chamfer</title>
<path d="M12 36L12 12L42 12" fill="none" stroke="#6f879c" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M12 54L12 36L42 12L54 12" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M12 25A11 11 0 0 1 20.59 29.13" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M12 25A11 11 0 0 1 20.59 29.13" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="12" cy="54" r="3.07" fill="#236ead"/>
<circle cx="54" cy="12" r="3.07" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/sketch_chamfer_two_distances.svg b/assets/icons/ui/design/svg/model/sketch_chamfer_two_distances.svg
index 323fbd9ea8..76d5f717c6 100644
--- a/assets/icons/ui/design/svg/model/sketch_chamfer_two_distances.svg
+++ b/assets/icons/ui/design/svg/model/sketch_chamfer_two_distances.svg
@@ -2,7 +2,7 @@
<title>Two distance sketch chamfer</title>
<path d="M12 43L12 12L31 12" fill="none" stroke="#6f879c" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M12 54L12 43L31 12L54 12" fill="none" stroke="#236ead" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M18 9L18 15M9 25L15 25M9 31L15 31" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M18 9L18 15M9 25L15 25M9 31L15 31" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<circle cx="12" cy="54" r="3.07" fill="#236ead"/>
<circle cx="54" cy="12" r="3.07" fill="#236ead"/>
</svg>
diff --git a/assets/icons/ui/design/svg/model/thicken.svg b/assets/icons/ui/design/svg/model/thicken.svg
index e72ea9e498..089485534f 100644
--- a/assets/icons/ui/design/svg/model/thicken.svg
+++ b/assets/icons/ui/design/svg/model/thicken.svg
@@ -2,8 +2,8 @@
<title>Thicken</title>
<path d="M32 40L32 53" fill="none" stroke="#ffffff" stroke-width="6.45" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 60L27 51.5L37 51.5Z" fill="#ffffff" stroke="#ffffff" stroke-width="2.2" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 40L32 53" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 60L27 51.5L37 51.5Z" fill="#34465b"/>
+ <path d="M32 40L32 53" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 60L27 51.5L37 51.5Z" fill="currentColor"/>
<path d="M7.75 23L32 37L32 53L7.75 39Z" fill="#328bd3"/>
<path d="M56.25 23L32 37L32 53L56.25 39Z" fill="#236ead"/>
<path d="M32 9L56.25 23L32 37L7.75 23Z" fill="#b9ddf8"/>
@@ -11,9 +11,9 @@
<path d="M7.75 23L32 37L56.25 23" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 37L32 53" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M7.75 31L32 45L56.25 31" fill="none" stroke="#ffffff" stroke-width="4.75" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M7.75 31L32 45L56.25 31" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M7.75 31L32 45L56.25 31" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 20.88L32 11" fill="none" stroke="#ffffff" stroke-width="6.45" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M32 4L37 12.5L27 12.5Z" fill="#ffffff" stroke="#ffffff" stroke-width="2.2" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 20.88L32 11" fill="none" stroke="#34465b" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M32 4L37 12.5L27 12.5Z" fill="#34465b"/>
+ <path d="M32 20.88L32 11" fill="none" stroke="currentColor" stroke-width="4.25" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M32 4L37 12.5L27 12.5Z" fill="currentColor"/>
</svg>
diff --git a/assets/icons/ui/design/svg/workspace/ws_animate.svg b/assets/icons/ui/design/svg/workspace/ws_animate.svg
index d53cfbb81a..048485c9c2 100644
--- a/assets/icons/ui/design/svg/workspace/ws_animate.svg
+++ b/assets/icons/ui/design/svg/workspace/ws_animate.svg
@@ -1,9 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<title>Animate workspace</title>
<path d="M10.46 24.87L3.55 28.86L3.55 47.86L10.46 51.85M3.55 28.86L10.46 32.85" fill="none" stroke="#ffffff" stroke-width="7.55" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M10.46 24.87L3.55 28.86L3.55 47.86L10.46 51.85M3.55 28.86L10.46 32.85" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M10.46 24.87L3.55 28.86L3.55 47.86L10.46 51.85M3.55 28.86L10.46 32.85" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M22.46 24.87L15.55 28.86L15.55 47.86L22.46 51.85M15.55 28.86L22.46 32.85" fill="none" stroke="#ffffff" stroke-width="7.55" stroke-linejoin="round" stroke-linecap="round"/>
- <path d="M22.46 24.87L15.55 28.86L15.55 47.86L22.46 51.85M15.55 28.86L22.46 32.85" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
+ <path d="M22.46 24.87L15.55 28.86L15.55 47.86L22.46 51.85M15.55 28.86L22.46 32.85" fill="none" stroke="currentColor" stroke-width="2.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M44 19.36L60.45 28.86L44 38.36L44 57.36L27.55 47.86L27.55 28.86Z" fill="#ffffff" stroke="#ffffff" stroke-width="7.55" stroke-linejoin="round" stroke-linecap="round"/>
<path d="M27.55 28.86L44 38.36L44 57.36L27.55 47.86Z" fill="#b8c3cf"/>
<path d="M60.45 28.86L44 38.36L44 57.36L60.45 47.86Z" fill="#8e9faf"/>
diff --git a/assets/icons/ui/design/tools/icon_status.py b/assets/icons/ui/design/tools/icon_status.py
index f0c9fbaab0..f2c08d1cd0 100644
--- a/assets/icons/ui/design/tools/icon_status.py
+++ b/assets/icons/ui/design/tools/icon_status.py
@@ -9,7 +9,7 @@
--out FILE Self-contained static review page (default target/icon-status.html)
Read assets/icons/ui/STYLE_GUIDE.md before editing artwork. SVGs are authoritative.
-Every discovered non-final icon is Open; no inventory file controls discovery.
+Every discovered non-final icon is Open; artwork, source and runtime requests are discovery sources.
"""
import sys, os, re, glob, html, json, hashlib, collections, tomllib, uuid, datetime
@@ -36,6 +36,7 @@ def art_rev():
paths += glob.glob(ROOT + '/crates/ui-egui/src/**/*.rs', recursive=True)
paths += glob.glob(HERE + '/*.py')
paths += [D + '/palette.toml', D + '/aliases.toml', __file__]
+ paths += glob.glob(D + '/requested_icons.txt')
for path in sorted(paths):
# Equal-length edits can share an mtime. Only the content identifies what
# the reviewer saw; file metadata must never authorize stale acceptance.
@@ -58,6 +59,24 @@ def ui_icon_names(source):
names.update(re.findall(r'\("[^"]*",\s*"([a-z][a-z0-9_]*)",\s*"[^"]*"\)', table.group(1)))
return names
+def requested_icons():
+ """Runtime ids recorded by the Harness audit; flags describe its last actual render."""
+ path = os.path.join(D, 'requested_icons.txt')
+ if not os.path.exists(path):
+ return {}
+ requested = {}
+ with open(path, encoding='utf-8') as manifest:
+ for number, line in enumerate(manifest, 1):
+ if not line.strip() or line.startswith('#'):
+ continue
+ fields = line.strip().split('\t')
+ if len(fields) != 2 or not re.fullmatch(r'[a-z][a-z0-9_]*', fields[0]) or fields[1] not in ('true', 'false'):
+ raise ValueError(f'{path}:{number}: expected icon_id<TAB>true|false')
+ if fields[0] in requested:
+ raise ValueError(f'{path}:{number}: duplicate requested icon {fields[0]}')
+ requested[fields[0]] = fields[1] == 'true'
+ return requested
+
def scan():
"""Everything derived from the repo: rows, summary."""
pal = tomllib.load(open(D + '/palette.toml', 'rb'))
@@ -86,6 +105,9 @@ def scan():
t = open(f, encoding='utf-8').read()
for name in ui_icon_names(t):
uses[name].append('ui:' + os.path.relpath(f, ROOT + '/crates/ui-egui/src').replace(os.sep, '/'))
+ runtime = requested_icons()
+ for name in runtime:
+ uses[name].append('ui:runtime audit')
mk = ROOT + '/assets/icons/ui/source/markers.rs'
if os.path.exists(mk):
for name in re.findall(r'=> "(c_[a-z_]+)"', open(mk, encoding='utf-8').read()): uses[name].append('ui:sketch constraint glyph')
@@ -95,7 +117,7 @@ def scan():
rows = []
for n in sorted(set(uses) | set(masters) | set(alias_raw)):
m, acc = alias_of(n)
- if m in masters and n != 'placeholder': status = 'done'
+ if m in masters and n != 'placeholder' and not runtime.get(n, False): status = 'done'
else: status, m = 'placeholder', 'placeholder'
cmds = [u for u in uses.get(n, []) if not u.startswith('ui:')]
rows.append(dict(id=n, status=status, master=m, accent=acc, commands=len(cmds), example=cmds[0] if cmds else '',
diff --git a/assets/icons/ui/design/tools/lint_icons.py b/assets/icons/ui/design/tools/lint_icons.py
index 6c7fe532cd..fd95ad704d 100644
--- a/assets/icons/ui/design/tools/lint_icons.py
+++ b/assets/icons/ui/design/tools/lint_icons.py
@@ -15,7 +15,7 @@ files = sorted(glob.glob(d + '/svg/*/*.svg'))
for path in Path(d).rglob('*'):
if not path.is_file(): continue
rel = path.relative_to(d).as_posix()
- allowed = (rel in {'palette.toml', 'aliases.toml', 'review.json', 'references.toml'}
+ allowed = (rel in {'palette.toml', 'aliases.toml', 'review.json', 'references.toml', 'requested_icons.txt'}
or path.suffix == '.md'
or (rel.startswith('svg/') and path.suffix == '.svg')
or (path.parent in {Path(d) / 'tools', Path(d) / 'tools/author'} and path.suffix == '.py')
@@ -79,6 +79,36 @@ if os.path.exists(references):
if name not in names and name not in al: err(references, name + ': reference artwork is missing')
for message in icon_palette.validation_errors(pal, names | set(al)):
err(d + '/palette.toml', message)
+# the review page lies its icons on the real app surfaces: its colours must be the app's tokens
+def app_tokens():
+ src = open(os.path.join(d, '..', '..', '..', 'styles', 'ui', 'palettes.rs'), encoding='utf-8').read()
+ lo, hi = src.index('pub const fn light'), src.index('pub const fn dark')
+ light_src, dark_src = src[lo:hi], src[hi:]
+ def pick(block, name, dark):
+ pat = (r'\bt\.%s = Color32::from_rgb\((\d+), (\d+), (\d+)\)' if dark else r'\b%s: Color32::from_rgb\((\d+), (\d+), (\d+)\)') % name
+ m = re.search(pat, block)
+ return None if not m else '#%02x%02x%02x' % tuple(int(x) for x in m.groups())
+ out = {}
+ for name in ('toolbar', 'panel', 'border', 'text', 'text_dim', 'viewport_top'):
+ out[name] = (pick(light_src, name, False), pick(dark_src, name, True) or pick(light_src, name, False))
+ return out
+css_path = os.path.join(d, 'tools', 'review', 'review.css')
+if os.path.exists(css_path):
+ try:
+ tok = app_tokens()
+ css = open(css_path, encoding='utf-8').read()
+ want = {
+ ':root{': {'--bg': tok['panel'][0], '--fg': tok['text'][0], '--card': tok['toolbar'][0], '--line': tok['border'][0], '--mut': tok['text_dim'][0]},
+ 'body.dark{': {'--bg': tok['viewport_top'][1], '--fg': tok['text'][1], '--card': tok['toolbar'][1], '--line': tok['border'][1], '--mut': tok['text_dim'][1]},
+ }
+ for block, values in want.items():
+ line = next((l for l in css.split('\n') if l.startswith(block)), '')
+ for var, hexv in values.items():
+ m = re.search(re.escape(var) + r':(#[0-9a-fA-F]{6})', line)
+ if not m or m.group(1).lower() != hexv:
+ err(css_path, '%s%s is %s, the app token is %s (palettes.rs)' % (block, var, m.group(1) if m else 'missing', hexv))
+ except (OSError, ValueError) as e:
+ err(css_path, 'cannot compare with palettes.rs: %s' % e)
# an icon accepted as final on the review page must not change (un-accept it there to work on it again)
import json, review_state
rp = d + '/review.json'
diff --git a/assets/icons/ui/design/tools/preview.py b/assets/icons/ui/design/tools/preview.py
index 400fe8df1b..82da8936f1 100644
--- a/assets/icons/ui/design/tools/preview.py
+++ b/assets/icons/ui/design/tools/preview.py
@@ -9,7 +9,7 @@ aliases = tomllib.load(open(d + '/aliases.toml', 'rb')).get('alias', {})
def themed(svg, theme, icon, family, size):
_, accent = icon_palette.resolve(palette, aliases, icon)
return icon_palette.themed(svg, palette, theme, accent, namespace='preview-' + family + '-' + icon + '-' + theme + '-' + str(size))
-h = '<meta charset=utf-8><style>body{margin:0;font:10px sans-serif}.p{padding:8px}.light{background:#fff;color:#222}.dark{background:#1e2530;color:#ddd}.c{display:inline-block;width:92px;text-align:center;margin:3px 2px;vertical-align:top}.s{display:flex;gap:6px;justify-content:center;align-items:center;margin-top:2px}h3{margin:4px}</style>'
+h = '<meta charset=utf-8><style>body{margin:0;font:10px sans-serif}.p{padding:8px}.light{background:#f6f7f9;color:#262a32}.dark{background:#272b34;color:#dee2e8}.c{display:inline-block;width:92px;text-align:center;margin:3px 2px;vertical-align:top}.s{display:flex;gap:6px;justify-content:center;align-items:center;margin-top:2px}h3{margin:4px}</style>'
for theme in ('light', 'dark'):
for fam in sorted(os.listdir(d + '/svg')):
h += '<div class="p %s"><h3>%s - %s</h3>' % (theme, fam, theme)
diff --git a/assets/icons/ui/design/tools/review/guide.html b/assets/icons/ui/design/tools/review/guide.html
index 062199381c..7719b42f40 100644
--- a/assets/icons/ui/design/tools/review/guide.html
+++ b/assets/icons/ui/design/tools/review/guide.html
@@ -1,6 +1,6 @@
<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>SolidCraft icon style references</title>
-<style>body{font:14px/1.5 system-ui;margin:24px auto;max-width:1100px;padding:0 20px;background:#f4f6f9;color:#34465b}h1{font-size:24px}h2{font-size:18px;margin-top:28px}.examples{display:flex;flex-wrap:wrap;gap:10px}article{display:flex;flex-wrap:wrap;width:180px;border:1px solid #d5dbe3;border-radius:8px;overflow:hidden;background:white}b{font-size:11px;width:100%;padding:7px 10px}.light,.dark{width:50%;display:flex;justify-content:center}.dark{background:#1e2530}svg{width:80px;height:80px;display:block;margin:4px auto}code{font-size:12px}a{color:#236ead}</style>
+<style>body{font:14px/1.5 system-ui;margin:24px auto;max-width:1100px;padding:0 20px;background:#fafbfc;color:#262a32}h1{font-size:24px}h2{font-size:18px;margin-top:28px}.examples{display:flex;flex-wrap:wrap;gap:10px}article{display:flex;flex-wrap:wrap;width:180px;border:1px solid #d0d4dc;border-radius:8px;overflow:hidden;background:#f6f7f9}b{font-size:11px;width:100%;padding:7px 10px}.light,.dark{width:50%;display:flex;justify-content:center}.dark{background:#272b34}svg{width:80px;height:80px;display:block;margin:4px auto}code{font-size:12px}a{color:#236ead}</style>
<h1>Icon style references</h1><p><a href="/">Return to review</a>. The binding specification is <code>assets/icons/ui/STYLE_GUIDE.md</code>.
Read it before editing. These are original SolidCraft bases and finished visual references, shown directly from the current SVG masters.</p>
<p>64-unit grid · 2.55 outlines · 4.25 action strokes · round caps and joins · standard 30° isometric axes · top light, left medium, right dark.</p>
diff --git a/assets/icons/ui/design/tools/review/review.css b/assets/icons/ui/design/tools/review/review.css
index f6aa119e96..6c3fe03177 100644
--- a/assets/icons/ui/design/tools/review/review.css
+++ b/assets/icons/ui/design/tools/review/review.css
@@ -1,5 +1,6 @@
-:root{--bg:#f4f6f9;--fg:#1d2733;--card:#fff;--line:#d5dbe3;--mut:#6b7a8a;--sz:48px}
-body.dark{--bg:#1e2530;--fg:#dbe4ee;--card:#262f3c;--line:#3a4657;--mut:#8a9db0}
+/* App surfaces (keep in sync with assets/styles/ui/palettes.rs; lint_icons.py checks): --card is the ribbon surface `toolbar` the icons lie on, --bg the page (`panel` in light, `viewport_top` in dark), --line `border`, --fg `text`, --mut `text_dim`. */
+:root{--bg:#fafbfc;--fg:#262a32;--card:#f6f7f9;--line:#d0d4dc;--mut:#6e7480;--sz:48px}
+body.dark{--bg:#2e3440;--fg:#dee2e8;--card:#272b34;--line:#3f4552;--mut:#949ba8}
body{font:12px system-ui,sans-serif;margin:0;background:var(--bg);color:var(--fg)}
header{position:sticky;top:0;background:var(--card);border-bottom:1px solid var(--line);padding:6px 12px;z-index:5;display:flex;flex-wrap:wrap;gap:4px 10px;align-items:center}
h1{font-size:14px;margin:0}.sum{color:var(--mut)}
diff --git a/assets/icons/ui/source/markers.rs b/assets/icons/ui/source/markers.rs
index 1cf8ec8436..3560a31351 100644
--- a/assets/icons/ui/source/markers.rs
+++ b/assets/icons/ui/source/markers.rs
@@ -49,7 +49,7 @@ pub(crate) fn snap(painter: &egui::Painter, c: Pos2, tip: Option<Pos2>, kind: Sn
// What it snaps to (hovered), or which component it is (picked): a small label.
if let Some(tag) = tag {
let t = Tokens::get();
- let font = egui::FontId::proportional(11.5);
+ let font = egui::FontId::proportional(crate::theme::Tokens::get().font_caption);
let g = painter.layout_no_wrap(tag.to_string(), font, t.text);
let at = c + vec2(12.0, 10.0);
let r = egui::Rect::from_min_size(at, g.size()).expand2(vec2(5.0, 2.0));
diff --git a/assets/icons/ui/source/navigation.rs b/assets/icons/ui/source/navigation.rs
index 7192a18148..611c3f558a 100644
--- a/assets/icons/ui/source/navigation.rs
+++ b/assets/icons/ui/source/navigation.rs
@@ -1,6 +1,6 @@
//! Navigation drawing definitions. Camera projection and picking remain in the UI widgets.
use crate::theme::Tokens;
-use egui::{Align2, Color32, FontId, Pos2, Rect, Shape, Stroke, pos2, vec2};
+use egui::{Color32, FontId, Pos2, Rect, Shape, Stroke, pos2, vec2};
use solidcraft_engine::geom::{Ring, Vec3};
pub(crate) struct Facet {
pub(crate) direction: Vec3,
@@ -120,7 +120,7 @@ pub(crate) fn paint_cube(painter: &egui::Painter, faces: &[Facet], hovered: Opti
}
if labels {
for face in faces {
- face_text(painter, face, t.cube_text, 14.0 * scale);
+ face_text(painter, face, t.cube_text, t.font_heading * scale);
}
}
}
@@ -187,13 +187,14 @@ pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, a
}
}
if positive {
- // The letters are heavy: egui's regular face gets a small overstrike for weight. On a
- // hovered (white) disc the letter takes the axis colour.
+ // On a hovered (white) disc the letter takes the axis colour.
let letter = if hovered { col } else { t.on_accent };
let label = name.to_uppercase();
- for dx in [-0.45, 0.45] {
- painter.text(at + vec2(dx, 0.0), Align2::CENTER_CENTER, &label, FontId::proportional(13.5), letter);
- }
+ let galley = painter.layout_no_wrap(label, crate::fonts::bold(crate::theme::Tokens::get().font_compass), letter);
+ let origin = at - galley.size() / 2.0;
+ let ppp = painter.ctx().pixels_per_point().max(0.5);
+ let origin = pos2((origin.x * ppp).round() / ppp, (origin.y * ppp).round() / ppp);
+ painter.galley(origin, galley, letter);
}
if !positive {
painter.circle_stroke(
diff --git a/assets/icons/ui/source/pointer.rs b/assets/icons/ui/source/pointer.rs
index b637f75340..dd16e2d4da 100644
--- a/assets/icons/ui/source/pointer.rs
+++ b/assets/icons/ui/source/pointer.rs
@@ -11,7 +11,7 @@ pub(crate) fn paint(painter: &egui::Painter, p: Pos2) {
[(0.0, 0.0), (0.0, 17.0), (4.5, 13.0), (7.5, 20.0), (10.5, 18.8), (7.5, 12.0), (13.0, 12.0)].iter().map(|(x, y)| p + vec2(*x, *y)).collect();
painter.add(Shape::convex_polygon(pts.clone(), ic.agent, Stroke::NONE));
painter.add(Shape::closed_line(pts, Stroke::new(1.5, ic.highlight)));
- let label = painter.layout_no_wrap("Agent".into(), FontId::proportional(11.0), ic.highlight);
+ let label = painter.layout_no_wrap("Agent".into(), FontId::proportional(crate::theme::Tokens::get().font_small), ic.highlight);
let r = egui::Rect::from_min_size(p + vec2(15.0, 18.0), label.size() + vec2(10.0, 4.0));
painter.rect_filled(r, 4.0, ic.agent);
painter.galley(r.min + vec2(5.0, 2.0), label, ic.highlight);
diff --git a/assets/locales/cs.json b/assets/locales/cs.json
index a90c4b2f24..b7e183ada4 100644
--- a/assets/locales/cs.json
+++ b/assets/locales/cs.json
@@ -816,8 +816,18 @@
"settings.reset_title": "Nastavení byla změněna",
"settings.supersampling_note": "Vykresluje pohled ve vyšším rozlišení a poté jej zmenšuje: hladší hrany, čáry a mřížka na obrazovkách pod 4K. Stojí výkon GPU: asi 2,25× více pixelů při 1,5× a 4× při 2×.",
"sketch.degrees_of_freedom": "Stupně volnosti: {count}",
+ "sketch.dof_left": "Zbývající stupně volnosti: {count}",
+ "sketch.dof_left_one": "Zbývá {count} stupeň volnosti",
"sketch.draw_curves": "Kreslit jako {linetype}",
"sketch.make_selection": "Převést výběr na {linetype}",
+ "sketch_panel.attached": "Připojeno k {body} / {path}",
+ "sketch_panel.author": "Umístění autora: {path}",
+ "sketch_panel.dimension_hint": "Zadejte hodnotu nebo výraz a poté stiskněte OK.",
+ "sketch_panel.move_hint": "Zadejte vzdálenosti a úhel a poté stiskněte OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Připojeno k rovinné ploše plechového tělesa; při změně plechu sleduje tento panel.",
+ "sketch_panel.text_hint": "Upravte text a jeho umístění a poté stiskněte OK.",
+ "sketch_panel.use_plane": "Použít rovinu {plane}",
"sketch_text.align_center": "Na střed",
"sketch_text.align_left": "Vlevo",
"sketch_text.align_right": "Vpravo",
@@ -1073,6 +1083,7 @@
"ui.combine": "Kombinovat",
"ui.coming_later": "připravujeme",
"ui.command_done": "{command} hotovo",
+ "ui.command_palette_hint": "Zadejte příkaz, např. {example} — nebo stiskněte S pro hledání",
"ui.concentric": "Soustřednost",
"ui.configurations": "Konfigurace",
"ui.conic_curve": "Kuželosečka",
@@ -1328,8 +1339,11 @@
"ui.orbit_around": "Otáčet kolem",
"ui.orientation": "Orientace",
"ui.origin": "Počátek",
+ "ui.palette_construction_mode": "Konstrukční režim (X)",
+ "ui.palette_more": "Další",
"ui.palette_points": "Body",
"ui.palette_profile": "Profil",
+ "ui.palette_sketch_options": "Možnosti náčrtu",
"ui.pan": "Posun",
"ui.pan_zoom_orbit": "Posun, přiblížení, otáčení",
"ui.parallel": "Rovnoběžnost",
diff --git a/assets/locales/de.json b/assets/locales/de.json
index 0a5d325322..a9b92f76fd 100644
--- a/assets/locales/de.json
+++ b/assets/locales/de.json
@@ -623,8 +623,18 @@
"settings.reset_title": "Einstellungen wurden geändert",
"settings.supersampling_note": "Zeichnet die Ansicht in höherer Auflösung und rechnet sie herunter: glattere Kanten, Linien und Raster auf Bildschirmen unter 4K. Kostet GPU-Zeit: etwa 2,25-mal so viele Pixel bei 1,5× und 4-mal bei 2×.",
"sketch.degrees_of_freedom": "{count} Freiheitsgrade",
+ "sketch.dof_left": "{count} Freiheitsgrade übrig",
+ "sketch.dof_left_one": "{count} Freiheitsgrad übrig",
"sketch.draw_curves": "Als {linetype} zeichnen",
"sketch.make_selection": "Auswahl als {linetype} markieren",
+ "sketch_panel.attached": "Angehängt an {body} / {path}",
+ "sketch_panel.author": "Autorenplatzierung: {path}",
+ "sketch_panel.dimension_hint": "Einen Wert oder Ausdruck eingeben, dann OK drücken.",
+ "sketch_panel.move_hint": "Abstände und einen Winkel eingeben, dann OK drücken.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "An eine ebene Fläche eines Blechkörpers angehängt; folgt diesem Bereich bei Änderungen am Blech.",
+ "sketch_panel.text_hint": "Text und Platzierung bearbeiten, dann OK drücken.",
+ "sketch_panel.use_plane": "Ebene {plane} verwenden",
"sketch_text.align_center": "Mitte",
"sketch_text.align_left": "Links",
"sketch_text.align_right": "Rechts",
@@ -861,6 +871,7 @@
"ui.combine": "Kombinieren",
"ui.coming_later": "bald verfügbar",
"ui.command_done": "{command} fertig",
+ "ui.command_palette_hint": "Befehl eingeben, z. B. {example} — oder S drücken, um zu suchen",
"ui.concentric": "Konzentrisch",
"ui.configurations": "Konfigurationen",
"ui.conic_curve": "Kegelschnitt",
@@ -1115,8 +1126,11 @@
"ui.orbit_around": "Umkreisen um",
"ui.orientation": "Ausrichtung",
"ui.origin": "Ursprung",
+ "ui.palette_construction_mode": "Konstruktionsmodus (X)",
+ "ui.palette_more": "Mehr",
"ui.palette_points": "Punkte",
"ui.palette_profile": "Profil",
+ "ui.palette_sketch_options": "Skizzenoptionen",
"ui.pan": "Verschieben",
"ui.pan_zoom_orbit": "Verschieben, zoomen, umkreisen",
"ui.parallel": "Parallel",
diff --git a/assets/locales/en.json b/assets/locales/en.json
index 932f107ed2..3adf554da0 100644
--- a/assets/locales/en.json
+++ b/assets/locales/en.json
@@ -905,10 +905,20 @@
"settings.reset_title": "Settings were changed",
"settings.supersampling_note": "Draws the view at a higher resolution and filters it down: smoother edges, lines and grid on screens below 4K. It costs GPU time: about 2.25× the pixels at 1.5× and 4× at 2×.",
"sketch.degrees_of_freedom": "{count} degrees of freedom",
+ "sketch.dof_left": "{count} degrees of freedom left",
+ "sketch.dof_left_one": "{count} degree of freedom left",
"sketch.draw_curves": "Draw as {linetype}",
"sketch.make_selection": "Convert the selection to {linetype}",
"sketch.open_ends": "Open {count}",
"sketch.untied_ends": "Untied {count}",
+ "sketch_panel.attached": "Attached to {body} / {path}",
+ "sketch_panel.author": "Author placement: {path}",
+ "sketch_panel.dimension_hint": "Enter a value or expression, then press OK.",
+ "sketch_panel.move_hint": "Enter distances and an angle, then press OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Attached to a flat face of a sheet metal body; it follows that panel when the sheet changes.",
+ "sketch_panel.text_hint": "Edit the text and its placement, then press OK.",
+ "sketch_panel.use_plane": "Use {plane} plane",
"sketch_text.align_center": "Center",
"sketch_text.align_left": "Left",
"sketch_text.align_right": "Right",
@@ -1205,6 +1215,7 @@
"ui.combine": "Combine",
"ui.coming_later": "coming later",
"ui.command_done": "{command} done",
+ "ui.command_palette_hint": "Type a command, e.g. {example} — or press S to search",
"ui.concentric": "Concentric",
"ui.configurations": "Configurations",
"ui.conic_curve": "Conic Curve",
@@ -1475,8 +1486,11 @@
"ui.orbit_around": "Orbit around",
"ui.orientation": "Orientation",
"ui.origin": "Origin",
+ "ui.palette_construction_mode": "Construction mode (X)",
+ "ui.palette_more": "More",
"ui.palette_points": "Points",
"ui.palette_profile": "Profile",
+ "ui.palette_sketch_options": "Sketch options",
"ui.pan": "Pan",
"ui.pan_zoom_orbit": "Pan, zoom, orbit",
"ui.parallel": "Parallel",
diff --git a/assets/locales/es.json b/assets/locales/es.json
index a98c609dc2..1d815a4db1 100644
--- a/assets/locales/es.json
+++ b/assets/locales/es.json
@@ -831,8 +831,18 @@
"settings.reset_title": "Se han cambiado los ajustes",
"settings.supersampling_note": "Dibuja la vista a mayor resolución y después la reduce: bordes, líneas y cuadrícula más suaves en pantallas inferiores a 4K. Consume recursos de GPU: unos 2,25× píxeles a 1,5× y 4× a 2×.",
"sketch.degrees_of_freedom": "{count} grados de libertad",
+ "sketch.dof_left": "Quedan {count} grados de libertad",
+ "sketch.dof_left_one": "Queda {count} grado de libertad",
"sketch.draw_curves": "Dibujar como {linetype}",
"sketch.make_selection": "Convertir la selección a {linetype}",
+ "sketch_panel.attached": "Vinculado a {body} / {path}",
+ "sketch_panel.author": "Ubicación de autoría: {path}",
+ "sketch_panel.dimension_hint": "Introduzca un valor o una expresión y pulse Aceptar.",
+ "sketch_panel.move_hint": "Introduzca las distancias y un ángulo y pulse Aceptar.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Vinculado a una cara plana de un cuerpo de chapa; sigue ese panel cuando cambia la chapa.",
+ "sketch_panel.text_hint": "Edite el texto y su posición y pulse Aceptar.",
+ "sketch_panel.use_plane": "Usar plano {plane}",
"sketch_text.align_center": "Centrar",
"sketch_text.align_left": "Alinear a la izquierda",
"sketch_text.align_right": "Alinear a la derecha",
@@ -1092,6 +1102,7 @@
"ui.combine": "Combinar",
"ui.coming_later": "próximamente",
"ui.command_done": "{command} completado",
+ "ui.command_palette_hint": "Escribe un comando, p. ej., {example}, o pulsa S para buscar",
"ui.concentric": "Concéntrico",
"ui.configurations": "Configuraciones",
"ui.conic_curve": "Curva cónica",
@@ -1352,8 +1363,11 @@
"ui.orbit_around": "Orbitar alrededor de",
"ui.orientation": "Orientación",
"ui.origin": "Origen",
+ "ui.palette_construction_mode": "Modo de construcción (X)",
+ "ui.palette_more": "Más",
"ui.palette_points": "Puntos",
"ui.palette_profile": "Perfil",
+ "ui.palette_sketch_options": "Opciones de croquis",
"ui.pan": "Desplazar",
"ui.pan_zoom_orbit": "Desplazar, zoom y orbitar",
"ui.parallel": "Paralelo",
diff --git a/assets/locales/fr.json b/assets/locales/fr.json
index 2c748ac630..93ccd9f1b5 100644
--- a/assets/locales/fr.json
+++ b/assets/locales/fr.json
@@ -845,10 +845,20 @@
"settings.reset_title": "Des réglages ont été modifiés",
"settings.supersampling_note": "Dessine la vue à une résolution plus élevée puis la réduit : arêtes, lignes et grille plus lisses sur les écrans de définition inférieure à la 4K. Cela coûte du temps GPU : environ 2,25× plus de pixels à 1,5× et 4× plus à 2×.",
"sketch.degrees_of_freedom": "{count} degrés de liberté",
+ "sketch.dof_left": "{count} degrés de liberté restants",
+ "sketch.dof_left_one": "{count} degré de liberté restant",
"sketch.draw_curves": "Dessiner en {linetype}",
"sketch.make_selection": "Convertir la sélection en {linetype}",
"sketch.open_ends": "{count} ouvertes",
"sketch.untied_ends": "{count} sans coïncidence",
+ "sketch_panel.attached": "Attaché à {body} / {path}",
+ "sketch_panel.author": "Placement d’origine : {path}",
+ "sketch_panel.dimension_hint": "Saisissez une valeur ou une expression, puis appuyez sur OK.",
+ "sketch_panel.move_hint": "Saisissez les distances et un angle, puis appuyez sur OK.",
+ "sketch_panel.redefine_title": "{command} : {name}",
+ "sketch_panel.sheet_attachment": "Attaché à une face plane d’un corps de tôlerie ; suit ce panneau lorsque la tôle change.",
+ "sketch_panel.text_hint": "Modifiez le texte et son placement, puis appuyez sur OK.",
+ "sketch_panel.use_plane": "Utiliser le plan {plane}",
"sketch_text.align_center": "Centre",
"sketch_text.align_left": "Gauche",
"sketch_text.align_right": "Droite",
@@ -1143,6 +1153,7 @@
"ui.combine": "Combiner",
"ui.coming_later": "bientôt disponible",
"ui.command_done": "{command} terminé",
+ "ui.command_palette_hint": "Tapez une commande, ex. {example} — ou S pour chercher",
"ui.concentric": "Concentricité",
"ui.configurations": "Configurations",
"ui.conic_curve": "Courbe conique",
@@ -1411,8 +1422,11 @@
"ui.orbit_around": "Orbite autour de",
"ui.orientation": "Orientation",
"ui.origin": "Origine",
+ "ui.palette_construction_mode": "Mode construction (X)",
+ "ui.palette_more": "Plus",
"ui.palette_points": "Points",
"ui.palette_profile": "Profil",
+ "ui.palette_sketch_options": "Options d’esquisse",
"ui.pan": "Panoramique",
"ui.pan_zoom_orbit": "Panoramique, zoom, orbite",
"ui.parallel": "Parallélisme",
diff --git a/assets/locales/gl.json b/assets/locales/gl.json
index 1f5e26f3b6..5d4efc3bcf 100644
--- a/assets/locales/gl.json
+++ b/assets/locales/gl.json
@@ -807,8 +807,18 @@
"settings.reset_title": "Cambiáronse os axustes",
"settings.supersampling_note": "Debuxa a vista a unha resolución maior e fíltraa cara abaixo: arestas, liñas e grella máis suaves en pantallas por debaixo de 4K. Consome tempo de GPU: uns 2,25× píxeles a 1,5× e 4× a 2×.",
"sketch.degrees_of_freedom": "{count} graos de liberdade",
+ "sketch.dof_left": "Quedan {count} graos de liberdade",
+ "sketch.dof_left_one": "Queda {count} grao de liberdade",
"sketch.draw_curves": "Debuxar como {linetype}",
"sketch.make_selection": "Converter a selección en {linetype}",
+ "sketch_panel.attached": "Ligado a {body} / {path}",
+ "sketch_panel.author": "Localización de autoría: {path}",
+ "sketch_panel.dimension_hint": "Introduza un valor ou unha expresión e prema Aceptar.",
+ "sketch_panel.move_hint": "Introduza as distancias e un ángulo e prema Aceptar.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Ligado a unha cara plana dun corpo de chapa; segue ese panel cando cambia a chapa.",
+ "sketch_panel.text_hint": "Edite o texto e a súa posición e prema Aceptar.",
+ "sketch_panel.use_plane": "Usar plano {plane}",
"sketch_text.align_center": "Centro",
"sketch_text.align_left": "Esquerda",
"sketch_text.align_right": "Dereita",
@@ -1064,6 +1074,7 @@
"ui.combine": "Combinar",
"ui.coming_later": "máis adiante",
"ui.command_done": "{command} feito",
+ "ui.command_palette_hint": "Escribe unha orde, p. ex. {example} — ou preme S para buscar",
"ui.concentric": "Concéntrica",
"ui.configurations": "Configuracións",
"ui.conic_curve": "Curva cónica",
@@ -1319,8 +1330,11 @@
"ui.orbit_around": "Orbitar arredor de",
"ui.orientation": "Orientación",
"ui.origin": "Orixe",
+ "ui.palette_construction_mode": "Modo de construción (X)",
+ "ui.palette_more": "Máis",
"ui.palette_points": "Puntos",
"ui.palette_profile": "Perfil",
+ "ui.palette_sketch_options": "Opcións do esbozo",
"ui.pan": "Desprazar",
"ui.pan_zoom_orbit": "Desprazar, zoom, orbitar",
"ui.parallel": "Paralela",
diff --git a/assets/locales/it.json b/assets/locales/it.json
index 62cbd03b16..3bbdd118a7 100644
--- a/assets/locales/it.json
+++ b/assets/locales/it.json
@@ -168,7 +168,6 @@
"No matching appearances": "Nessun aspetto corrispondente",
"No visible bodies to export.": "Nessun corpo visibile da esportare.",
"None": "Nessuno",
- "Normal to sketch": "Normale allo schizzo",
"Not available yet": "Non ancora disponibile",
"Notch": "Intaglio",
"Opacity": "Opacità",
@@ -812,10 +811,20 @@
"settings.reset_title": "Le impostazioni sono state modificate",
"settings.supersampling_note": "Disegna la vista a una risoluzione maggiore e la riduce tramite filtro: spigoli, linee e griglia più uniformi sugli schermi sotto il 4K. Richiede tempo GPU: circa 2.25× i pixel a 1.5× e 4× a 2×.",
"sketch.degrees_of_freedom": "{count} gradi di libertà",
+ "sketch.dof_left": "{count} gradi di libertà rimanenti",
+ "sketch.dof_left_one": "{count} grado di libertà rimanente",
"sketch.draw_curves": "Disegna come {linetype}",
"sketch.make_selection": "Converti la selezione in {linetype}",
"sketch.open_ends": "Aperte {count}",
"sketch.untied_ends": "Non vincolate {count}",
+ "sketch_panel.attached": "Collegato a {body} / {path}",
+ "sketch_panel.author": "Posizionamento originale: {path}",
+ "sketch_panel.dimension_hint": "Inserisci un valore o un’espressione, poi premi OK.",
+ "sketch_panel.move_hint": "Inserisci distanze e angolo, poi premi OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Collegato a una faccia piana di un corpo in lamiera; segue il pannello quando la lamiera cambia.",
+ "sketch_panel.text_hint": "Modifica il testo e la sua posizione, poi premi OK.",
+ "sketch_panel.use_plane": "Usa il piano {plane}",
"sketch_text.align_center": "Centro",
"sketch_text.align_left": "Sinistra",
"sketch_text.align_right": "Destra",
@@ -1075,6 +1084,7 @@
"ui.combine": "Combina",
"ui.coming_later": "in arrivo",
"ui.command_done": "{command} completato",
+ "ui.command_palette_hint": "Digita un comando, ad es. {example} — oppure premi S per cercare",
"ui.concentric": "Concentrico",
"ui.configurations": "Configurazioni",
"ui.conic_curve": "Curva conica",
@@ -1336,8 +1346,11 @@
"ui.orbit_around": "Orbita attorno a",
"ui.orientation": "Orientamento",
"ui.origin": "Origine",
+ "ui.palette_construction_mode": "Modalità costruzione (X)",
+ "ui.palette_more": "Altro",
"ui.palette_points": "Punti",
"ui.palette_profile": "Profilo",
+ "ui.palette_sketch_options": "Opzioni schizzo",
"ui.pan": "Panoramica",
"ui.pan_zoom_orbit": "Panoramica, zoom, orbita",
"ui.parallel": "Parallelo",
diff --git a/assets/locales/ja.json b/assets/locales/ja.json
index feec1edefd..0c8a593d6b 100644
--- a/assets/locales/ja.json
+++ b/assets/locales/ja.json
@@ -905,10 +905,20 @@
"settings.reset_title": "設定が変更されました",
"settings.supersampling_note": "ビューを高い解像度で描画してから縮小します。4K 未満の画面でエッジ、線、グリッドが滑らかになります。GPU の負荷が増えます(1.5× で約 2.25 倍、2× で 4 倍のピクセル)。",
"sketch.degrees_of_freedom": "自由度 {count}",
+ "sketch.dof_left": "残り自由度 {count}",
+ "sketch.dof_left_one": "残り自由度 {count}",
"sketch.draw_curves": "{linetype}として描く",
"sketch.make_selection": "選択を{linetype}にする",
"sketch.open_ends": "開放 {count}",
"sketch.untied_ends": "未拘束 {count}",
+ "sketch_panel.attached": "接続先: {body} / {path}",
+ "sketch_panel.author": "作成時の配置: {path}",
+ "sketch_panel.dimension_hint": "値または式を入力し、OK を押してください。",
+ "sketch_panel.move_hint": "距離と角度を入力し、OK を押してください。",
+ "sketch_panel.redefine_title": "{command}:{name}",
+ "sketch_panel.sheet_attachment": "板金ボディの平面に接続されています。板金が変更されると、そのパネルに追従します。",
+ "sketch_panel.text_hint": "テキストと配置を編集し、OK を押してください。",
+ "sketch_panel.use_plane": "{plane} 平面を使用",
"sketch_text.align_center": "中央",
"sketch_text.align_left": "左",
"sketch_text.align_right": "右",
@@ -1205,6 +1215,7 @@
"ui.combine": "結合",
"ui.coming_later": "準備中",
"ui.command_done": "{command} 完了",
+ "ui.command_palette_hint": "コマンドを入力(例: {example})— または S キーで検索",
"ui.concentric": "同心",
"ui.configurations": "構成",
"ui.conic_curve": "円錐曲線",
@@ -1475,8 +1486,11 @@
"ui.orbit_around": "回転中心",
"ui.orientation": "向き",
"ui.origin": "原点",
+ "ui.palette_construction_mode": "補助線モード (X)",
+ "ui.palette_more": "その他",
"ui.palette_points": "点",
"ui.palette_profile": "プロファイル",
+ "ui.palette_sketch_options": "スケッチオプション",
"ui.pan": "パン",
"ui.pan_zoom_orbit": "パン、ズーム、オービット",
"ui.parallel": "平行",
diff --git a/assets/locales/ko.json b/assets/locales/ko.json
index a4f225dc32..5b008cc2e6 100644
--- a/assets/locales/ko.json
+++ b/assets/locales/ko.json
@@ -623,8 +623,18 @@
"settings.reset_title": "설정이 변경되었습니다",
"settings.supersampling_note": "뷰를 더 높은 해상도로 그린 뒤 축소합니다. 4K 미만 화면에서 모서리, 선, 그리드가 더 매끄러워집니다. GPU 시간이 듭니다: 1.5×에서 약 2.25배, 2×에서 4배의 픽셀.",
"sketch.degrees_of_freedom": "자유도 {count}개",
+ "sketch.dof_left": "남은 자유도 {count}개",
+ "sketch.dof_left_one": "남은 자유도 {count}개",
"sketch.draw_curves": "{linetype}(으)로 그리기",
"sketch.make_selection": "선택 항목을 {linetype}(으)로 변경",
+ "sketch_panel.attached": "부착 대상: {body} / {path}",
+ "sketch_panel.author": "작성 배치: {path}",
+ "sketch_panel.dimension_hint": "값이나 수식을 입력한 다음 확인을 누르세요.",
+ "sketch_panel.move_hint": "거리와 각도를 입력한 다음 확인을 누르세요.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "판금 바디의 평평한 면에 부착되어 있으며 판금이 변경되면 해당 패널을 따릅니다.",
+ "sketch_panel.text_hint": "텍스트와 배치를 편집한 다음 확인을 누르세요.",
+ "sketch_panel.use_plane": "{plane} 평면 사용",
"sketch_text.align_center": "가운데",
"sketch_text.align_left": "왼쪽",
"sketch_text.align_right": "오른쪽",
@@ -861,6 +871,7 @@
"ui.combine": "결합",
"ui.coming_later": "추후 지원 예정",
"ui.command_done": "{command} 완료",
+ "ui.command_palette_hint": "명령 입력(예: {example}) — 또는 S 키를 눌러 검색",
"ui.concentric": "동심",
"ui.configurations": "구성",
"ui.conic_curve": "원뿔 곡선",
@@ -1115,8 +1126,11 @@
"ui.orbit_around": "궤도 회전 기준",
"ui.orientation": "배향",
"ui.origin": "원점",
+ "ui.palette_construction_mode": "보조선 모드 (X)",
+ "ui.palette_more": "더 보기",
"ui.palette_points": "점",
"ui.palette_profile": "프로파일",
+ "ui.palette_sketch_options": "스케치 옵션",
"ui.pan": "이동",
"ui.pan_zoom_orbit": "이동, 확대/축소, 궤도 회전",
"ui.parallel": "평행",
diff --git a/assets/locales/ms.json b/assets/locales/ms.json
index 1767deb878..510fea6c2f 100644
--- a/assets/locales/ms.json
+++ b/assets/locales/ms.json
@@ -1060,6 +1060,7 @@
"ui.combine": "Gabung",
"ui.coming_later": "akan datang",
"ui.command_done": "{command} selesai",
+ "ui.command_palette_hint": "Taip arahan, cth. {example} — atau tekan S untuk mencari",
"ui.concentric": "Sepusat",
"ui.configurations": "Konfigurasi",
"ui.conic_curve": "Lengkung Kon",
diff --git a/assets/locales/pl.json b/assets/locales/pl.json
index a42500712b..3b8c02fc04 100644
--- a/assets/locales/pl.json
+++ b/assets/locales/pl.json
@@ -798,10 +798,20 @@
"settings.reset_title": "Zmieniono ustawienia",
"settings.supersampling_note": "Rysuje widok w wyższej rozdzielczości i go zmniejsza: gładsze krawędzie, linie i siatka na ekranach poniżej 4K. Kosztuje czas GPU: ok. 2,25× więcej pikseli przy 1,5× i 4× przy 2×.",
"sketch.degrees_of_freedom": "Stopnie swobody: {count}",
+ "sketch.dof_left": "Pozostałe stopnie swobody: {count}",
+ "sketch.dof_left_one": "Pozostał {count} stopień swobody",
"sketch.draw_curves": "Rysuj jako {linetype}",
"sketch.make_selection": "Zamień zaznaczenie na {linetype}",
"sketch.open_ends": "Otwarte: {count}",
"sketch.untied_ends": "Niezwiązane: {count}",
+ "sketch_panel.attached": "Dołączony do {body} / {path}",
+ "sketch_panel.author": "Pierwotne położenie: {path}",
+ "sketch_panel.dimension_hint": "Wprowadź wartość lub wyrażenie, a następnie naciśnij OK.",
+ "sketch_panel.move_hint": "Wprowadź odległości i kąt, a następnie naciśnij OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Dołączony do płaskiej ściany bryły blaszanej; podąża za tym panelem przy zmianach blachy.",
+ "sketch_panel.text_hint": "Edytuj tekst i jego położenie, a następnie naciśnij OK.",
+ "sketch_panel.use_plane": "Użyj płaszczyzny {plane}",
"sketch_text.align_center": "Do środka",
"sketch_text.align_left": "Do lewej",
"sketch_text.align_right": "Do prawej",
@@ -1063,6 +1073,7 @@
"ui.combine": "Kombinacja",
"ui.coming_later": "wkrótce",
"ui.command_done": "Wykonano: {command}",
+ "ui.command_palette_hint": "Wpisz polecenie, np. {example} — lub naciśnij S, aby wyszukać",
"ui.concentric": "Współśrodkowość",
"ui.configurations": "Konfiguracje",
"ui.conic_curve": "Krzywa stożkowa",
@@ -1324,8 +1335,11 @@
"ui.orbit_around": "Obracaj wokół",
"ui.orientation": "Orientacja",
"ui.origin": "Początek układu",
+ "ui.palette_construction_mode": "Tryb konstrukcyjny (X)",
+ "ui.palette_more": "Więcej",
"ui.palette_points": "Punkty",
"ui.palette_profile": "Profil",
+ "ui.palette_sketch_options": "Opcje szkicu",
"ui.pan": "Przesuwanie",
"ui.pan_zoom_orbit": "Przesuwanie, powiększanie, obracanie",
"ui.parallel": "Równoległość",
diff --git a/assets/locales/pt-BR.json b/assets/locales/pt-BR.json
index 4dae07958f..5ae9a02802 100644
--- a/assets/locales/pt-BR.json
+++ b/assets/locales/pt-BR.json
@@ -790,8 +790,18 @@
"settings.reset_title": "As configurações foram alteradas",
"settings.supersampling_note": "Desenha a vista em resolução maior e a filtra para baixo: arestas, linhas e grade mais suaves em telas abaixo de 4K. Custa tempo de GPU: cerca de 2,25× os pixels em 1,5× e 4× em 2×.",
"sketch.degrees_of_freedom": "{count} graus de liberdade",
+ "sketch.dof_left": "{count} graus de liberdade restantes",
+ "sketch.dof_left_one": "{count} grau de liberdade restante",
"sketch.draw_curves": "Desenhar como {linetype}",
"sketch.make_selection": "Converter a seleção em {linetype}",
+ "sketch_panel.attached": "Anexado a {body} / {path}",
+ "sketch_panel.author": "Posicionamento de autoria: {path}",
+ "sketch_panel.dimension_hint": "Insira um valor ou uma expressão e pressione OK.",
+ "sketch_panel.move_hint": "Insira as distâncias e um ângulo e pressione OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Anexado a uma face plana de um corpo de chapa; acompanha esse painel quando a chapa muda.",
+ "sketch_panel.text_hint": "Edite o texto e seu posicionamento e pressione OK.",
+ "sketch_panel.use_plane": "Usar plano {plane}",
"sketch_text.align_center": "Centro",
"sketch_text.align_left": "Esquerda",
"sketch_text.align_right": "Direita",
@@ -1047,6 +1057,7 @@
"ui.combine": "Combinar",
"ui.coming_later": "em breve",
"ui.command_done": "{command} concluído",
+ "ui.command_palette_hint": "Digite um comando, p. ex. {example} — ou pressione S para pesquisar",
"ui.concentric": "Concêntrico",
"ui.configurations": "Configurações",
"ui.conic_curve": "Curva cônica",
@@ -1302,8 +1313,11 @@
"ui.orbit_around": "Orbitar em torno de",
"ui.orientation": "Orientação",
"ui.origin": "Origem",
+ "ui.palette_construction_mode": "Modo de construção (X)",
+ "ui.palette_more": "Mais",
"ui.palette_points": "Pontos",
"ui.palette_profile": "Perfil",
+ "ui.palette_sketch_options": "Opções de esboço",
"ui.pan": "Deslocar",
"ui.pan_zoom_orbit": "Deslocar, zoom, orbitar",
"ui.parallel": "Paralelo",
diff --git a/assets/locales/ru.json b/assets/locales/ru.json
index 9e94cd002a..3a7d82f0f3 100644
--- a/assets/locales/ru.json
+++ b/assets/locales/ru.json
@@ -752,8 +752,18 @@
"settings.reset_intro": "Эти настройки не работают на этом компьютере и могли бы помешать запуску SolidCraft, поэтому они были изменены:",
"settings.reset_title": "Настройки были изменены",
"sketch.degrees_of_freedom": "Степеней свободы: {count}",
+ "sketch.dof_left": "Осталось степеней свободы: {count}",
+ "sketch.dof_left_one": "Осталась {count} степень свободы",
"sketch.draw_curves": "Рисовать как {linetype}",
"sketch.make_selection": "Преобразовать выделение в {linetype}",
+ "sketch_panel.attached": "Привязано к {body} / {path}",
+ "sketch_panel.author": "Исходное размещение: {path}",
+ "sketch_panel.dimension_hint": "Введите значение или выражение, затем нажмите OK.",
+ "sketch_panel.move_hint": "Введите расстояния и угол, затем нажмите OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Привязано к плоской грани листового тела; следует за этой панелью при изменении листа.",
+ "sketch_panel.text_hint": "Измените текст и его размещение, затем нажмите OK.",
+ "sketch_panel.use_plane": "Использовать плоскость {plane}",
"sketch_text.align_center": "По центру",
"sketch_text.align_left": "По левому краю",
"sketch_text.align_right": "По правому краю",
@@ -856,6 +866,7 @@
"ui.combine": "Объединение",
"ui.coming_later": "появится позже",
"ui.command_done": "{command} — готово",
+ "ui.command_palette_hint": "Введите команду, напр. {example} — или нажмите S для поиска",
"ui.concentric": "Концентричность",
"ui.configurations": "Конфигурации",
"ui.conic_curve": "Коническая кривая",
@@ -1110,8 +1121,11 @@
"ui.orbit_around": "Вращать вокруг",
"ui.orientation": "Ориентация",
"ui.origin": "Начало координат",
+ "ui.palette_construction_mode": "Вспомогательный режим (X)",
+ "ui.palette_more": "Ещё",
"ui.palette_points": "Точки",
"ui.palette_profile": "Профиль",
+ "ui.palette_sketch_options": "Параметры эскиза",
"ui.pan": "Панорамирование",
"ui.pan_zoom_orbit": "Панорама, масштаб, орбита",
"ui.parallel": "Параллельность",
diff --git a/assets/locales/tr.json b/assets/locales/tr.json
index 2747eef9ed..84aba852cd 100644
--- a/assets/locales/tr.json
+++ b/assets/locales/tr.json
@@ -755,8 +755,18 @@
"settings.reset_title": "Ayarlar değiştirildi",
"settings.supersampling_note": "Görünümü daha yüksek çözünürlükte çizer ve küçültür: 4K altındaki ekranlarda kenarlar, çizgiler ve ızgaralar daha pürüzsüz görünür. GPU süresi gerektirir: 1,5× ayarında yaklaşık 2,25 kat, 2× ayarında 4 kat daha fazla piksel işlenir.",
"sketch.degrees_of_freedom": "{count} serbestlik derecesi",
+ "sketch.dof_left": "Kalan serbestlik derecesi: {count}",
+ "sketch.dof_left_one": "Kalan serbestlik derecesi: {count}",
"sketch.draw_curves": "{linetype} olarak çiz",
"sketch.make_selection": "Seçimi {linetype} olarak işaretle",
+ "sketch_panel.attached": "Bağlı olduğu: {body} / {path}",
+ "sketch_panel.author": "Yazar yerleşimi: {path}",
+ "sketch_panel.dimension_hint": "Bir değer veya ifade girip Tamam’a basın.",
+ "sketch_panel.move_hint": "Uzaklıkları ve bir açı girip Tamam’a basın.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Sac gövdenin düz bir yüzüne bağlıdır; sac değiştiğinde bu paneli izler.",
+ "sketch_panel.text_hint": "Metni ve yerleşimini düzenleyip Tamam’a basın.",
+ "sketch_panel.use_plane": "{plane} düzlemini kullan",
"sketch_text.align_center": "Orta",
"sketch_text.align_left": "Sol",
"sketch_text.align_right": "Sağ",
@@ -994,6 +1004,7 @@
"ui.combine": "Birleştir",
"ui.coming_later": "yakında",
"ui.command_done": "{command} tamamlandı",
+ "ui.command_palette_hint": "Bir komut yazın (ör. {example}) — veya aramak için S tuşuna basın",
"ui.concentric": "Eş merkezli",
"ui.configurations": "Konfigürasyonlar",
"ui.conic_curve": "Konik eğri",
@@ -1247,8 +1258,11 @@
"ui.orbit_around": "Etrafında döndür",
"ui.orientation": "Yönlendirme",
"ui.origin": "Orijin",
+ "ui.palette_construction_mode": "Yardımcı çizim modu (X)",
+ "ui.palette_more": "Diğer",
"ui.palette_points": "Noktalar",
"ui.palette_profile": "Profil",
+ "ui.palette_sketch_options": "Eskiz seçenekleri",
"ui.pan": "Kaydır",
"ui.pan_zoom_orbit": "Kaydır, yakınlaştır, döndür",
"ui.parallel": "Paralel",
diff --git a/assets/locales/uk.json b/assets/locales/uk.json
index 6d7571acdd..4b76a43024 100644
--- a/assets/locales/uk.json
+++ b/assets/locales/uk.json
@@ -845,10 +845,20 @@
"settings.reset_title": "Налаштування було змінено",
"settings.supersampling_note": "Малює вид у вищій роздільності й потім зменшує його: плавніші ребра, лінії та сітка на екранах до 4K. Це коштує часу GPU: приблизно 2,25× пікселів за 1,5× і 4× за 2×.",
"sketch.degrees_of_freedom": "{count} ступенів вільності",
+ "sketch.dof_left": "Залишилося ступенів свободи: {count}",
+ "sketch.dof_left_one": "Залишився {count} ступінь свободи",
"sketch.draw_curves": "Малювати як {linetype}",
"sketch.make_selection": "Перетворити виділене на {linetype}",
"sketch.open_ends": "Відкритих: {count}",
"sketch.untied_ends": "Незв'язаних: {count}",
+ "sketch_panel.attached": "Прив’язано до {body} / {path}",
+ "sketch_panel.author": "Початкове розміщення: {path}",
+ "sketch_panel.dimension_hint": "Введіть значення або вираз, потім натисніть OK.",
+ "sketch_panel.move_hint": "Введіть відстані та кут, потім натисніть OK.",
+ "sketch_panel.redefine_title": "{command}: {name}",
+ "sketch_panel.sheet_attachment": "Прив’язано до плоскої грані листового тіла; слідує за цією панеллю під час зміни листа.",
+ "sketch_panel.text_hint": "Змініть текст і його розміщення, потім натисніть OK.",
+ "sketch_panel.use_plane": "Використати площину {plane}",
"sketch_text.align_center": "По центру",
"sketch_text.align_left": "Ліворуч",
"sketch_text.align_right": "Праворуч",
@@ -1143,6 +1153,7 @@
"ui.combine": "Об'єднати",
"ui.coming_later": "з'явиться пізніше",
"ui.command_done": "{command} виконано",
+ "ui.command_palette_hint": "Введіть команду, напр. {example} — або натисніть S для пошуку",
"ui.concentric": "Концентричність",
"ui.configurations": "Конфігурації",
"ui.conic_curve": "Конічна крива",
@@ -1410,8 +1421,11 @@
"ui.orbit_around": "Обертати навколо",
"ui.orientation": "Орієнтація",
"ui.origin": "Початок координат",
+ "ui.palette_construction_mode": "Допоміжний режим (X)",
+ "ui.palette_more": "Більше",
"ui.palette_points": "Точки",
"ui.palette_profile": "Профіль",
+ "ui.palette_sketch_options": "Параметри ескізу",
"ui.pan": "Панорамувати",
"ui.pan_zoom_orbit": "Панорамування, масштаб, обертання",
"ui.parallel": "Паралельність",
diff --git a/assets/locales/zh.json b/assets/locales/zh.json
index 7033e195ae..c6d893c26e 100644
--- a/assets/locales/zh.json
+++ b/assets/locales/zh.json
@@ -905,10 +905,20 @@
"settings.reset_title": "设置已更改",
"settings.supersampling_note": "以更高分辨率绘制视图再缩小:在低于 4K 的屏幕上边、线和网格更平滑。会消耗 GPU 时间:1.5× 时约 2.25 倍像素,2× 时 4 倍。",
"sketch.degrees_of_freedom": "{count} 个自由度",
+ "sketch.dof_left": "剩余 {count} 个自由度",
+ "sketch.dof_left_one": "剩余 {count} 个自由度",
"sketch.draw_curves": "绘制为 {linetype}",
"sketch.make_selection": "将选择转换为 {linetype}",
"sketch.open_ends": "开放 {count}",
"sketch.untied_ends": "未约束 {count}",
+ "sketch_panel.attached": "附着到 {body} / {path}",
+ "sketch_panel.author": "创建时的放置:{path}",
+ "sketch_panel.dimension_hint": "输入数值或表达式,然后按“确定”。",
+ "sketch_panel.move_hint": "输入距离和角度,然后按“确定”。",
+ "sketch_panel.redefine_title": "{command}:{name}",
+ "sketch_panel.sheet_attachment": "附着到钣金实体的平面上;钣金变化时会跟随该面板。",
+ "sketch_panel.text_hint": "编辑文字及其位置,然后按“确定”。",
+ "sketch_panel.use_plane": "使用 {plane} 平面",
"sketch_text.align_center": "居中",
"sketch_text.align_left": "左对齐",
"sketch_text.align_right": "右对齐",
@@ -1205,6 +1215,7 @@
"ui.combine": "组合",
"ui.coming_later": "即将推出",
"ui.command_done": "{command} 完成",
+ "ui.command_palette_hint": "输入命令,例如 {example} — 或按 S 搜索",
"ui.concentric": "同心",
"ui.configurations": "配置",
"ui.conic_curve": "圆锥曲线",
@@ -1475,8 +1486,11 @@
"ui.orbit_around": "环绕",
"ui.orientation": "定向",
"ui.origin": "原点",
+ "ui.palette_construction_mode": "构造模式 (X)",
+ "ui.palette_more": "更多",
"ui.palette_points": "点",
"ui.palette_profile": "轮廓",
+ "ui.palette_sketch_options": "草图选项",
"ui.pan": "平移",
"ui.pan_zoom_orbit": "平移、缩放、环绕",
"ui.parallel": "平行",
diff --git a/assets/styles/ui/palettes.rs b/assets/styles/ui/palettes.rs
index c2052dec1d..edcdf12726 100644
--- a/assets/styles/ui/palettes.rs
+++ b/assets/styles/ui/palettes.rs
@@ -31,6 +31,35 @@ impl Tokens {
font_label: 12.5,
font_button: 13.0,
font_heading: 14.0,
+ font_triad: 8.0,
+ font_compass: 13.5,
+ font_subtitle: 15.0,
+ font_intro: 16.0,
+ font_article_heading: 17.0,
+ font_title: 22.0,
+ font_display: 26.0,
+ control_height: 24.0,
+ control_radius: 5,
+ form_label_width: 70.0,
+ form_gap_y: 5.0,
+ form_footer_height: 38.0,
+ form_header_height: 30.0,
+ form_card_width: 264.0,
+ form_icon_size: 18.0,
+ form_close_size: 22.0,
+ form_inset: 7.0,
+ form_icon_inset: 4.5,
+ form_section_icon_size: 11.0,
+ form_checkbox_height: 22.0,
+ form_button_height: 26.0,
+ sketch_palette_width: 232.0,
+ sketch_mode_size: 36.0,
+ sketch_mode_radius: 7,
+ sketch_mode_border: 1.5,
+ sketch_palette_alpha: 0.96,
+ sketch_mode_tint: 0.12,
+ sketch_footer_icon_size: 15.0,
+ font_section_tracking: 0.04,
app_bar: Color32::from_rgb(52, 56, 64),
app_bar_separator: Color32::from_rgb(136, 145, 160),
toolbar: Color32::from_rgb(246, 247, 249),
@@ -117,6 +146,14 @@ impl Tokens {
app_bar_hover_button: Color32::from_rgba_unmultiplied_const(255, 255, 255, 30),
app_bar_hover_strong: Color32::from_rgba_unmultiplied_const(255, 255, 255, 40),
app_bar_tab_active: Color32::from_rgb(53, 59, 71),
+ dialog_body: Color32::from_rgb(255, 255, 255),
+ dialog_footer: Color32::from_rgb(246, 248, 250),
+ dialog_rule: Color32::from_rgb(230, 234, 240),
+ control_fill: Color32::from_rgb(255, 255, 255),
+ control_border: Color32::from_rgb(195, 203, 214),
+ dialog_label: Color32::from_rgb(58, 70, 86),
+ selected_ink: Color32::from_rgb(26, 80, 127),
+ selected_bg: Color32::from_rgb(227, 240, 251),
timeline_item: Color32::WHITE,
timeline_item_error: Color32::from_rgb(250, 220, 220),
timeline_marker: Color32::from_rgb(70, 76, 88),
@@ -170,6 +207,36 @@ impl Tokens {
}
pub const fn dark() -> Tokens {
let mut t = Tokens::light();
+ // Shared typography and dense form dimensions stay identical in both palettes.
+ t.font_triad = 8.0;
+ t.font_compass = 13.5;
+ t.font_subtitle = 15.0;
+ t.font_intro = 16.0;
+ t.font_article_heading = 17.0;
+ t.font_title = 22.0;
+ t.font_display = 26.0;
+ t.control_height = 24.0;
+ t.control_radius = 5;
+ t.form_label_width = 70.0;
+ t.form_gap_y = 5.0;
+ t.form_footer_height = 38.0;
+ t.form_header_height = 30.0;
+ t.form_card_width = 264.0;
+ t.form_icon_size = 18.0;
+ t.form_close_size = 22.0;
+ t.form_inset = 7.0;
+ t.form_icon_inset = 4.5;
+ t.form_section_icon_size = 11.0;
+ t.form_checkbox_height = 22.0;
+ t.form_button_height = 26.0;
+ t.sketch_palette_width = 232.0;
+ t.sketch_mode_size = 36.0;
+ t.sketch_mode_radius = 7;
+ t.sketch_mode_border = 1.5;
+ t.sketch_palette_alpha = 0.96;
+ t.sketch_mode_tint = 0.12;
+ t.sketch_footer_icon_size = 15.0;
+ t.font_section_tracking = 0.04;
t.app_bar = Color32::from_rgb(28, 31, 38);
t.toolbar = Color32::from_rgb(39, 43, 52);
t.panel = Color32::from_rgb(39, 43, 52);
@@ -184,6 +251,14 @@ impl Tokens {
t.mesh_accent = Color32::from_rgb(133, 113, 0);
t.form_accent = Color32::from_rgb(123, 99, 166);
t.render_accent = Color32::from_rgb(224, 116, 174);
+ t.dialog_body = Color32::from_rgb(59, 68, 83);
+ t.dialog_footer = Color32::from_rgb(47, 52, 62);
+ t.dialog_rule = Color32::from_rgb(53, 59, 71);
+ t.control_fill = Color32::from_rgb(39, 43, 52);
+ t.control_border = Color32::from_rgb(74, 82, 98);
+ t.dialog_label = Color32::from_rgb(180, 187, 200);
+ t.selected_ink = Color32::from_rgb(156, 199, 245);
+ t.selected_bg = Color32::from_rgb(42, 70, 110);
t.construction_geom = icon_primary(crate::icon_svg::CONSTRUCTION_PRIMARY[1]);
t.error = Color32::from_rgb(240, 100, 96);
t.warning = Color32::from_rgb(236, 170, 70);
@@ -249,6 +324,7 @@ impl Tokens {
t.icons.axes[1] = t.triad[1];
t.icons.access = [good, Color32::from_rgb(217, 102, 13)];
t.construction_geom = icon_primary(crate::icon_svg::CONSTRUCTION_RED_GREEN[dark as usize]);
+ t.glyph_text = icon_primary(crate::icon_svg::CONSTRAINT_RED_GREEN[dark as usize]);
t.icons.draft = [good, Color32::from_rgb(242, 230, 153)];
t.surface_accent = if dark { Color32::from_rgb(200, 135, 55) } else { Color32::from_rgb(164, 80, 0) };
t.mesh_accent = if dark { Color32::from_rgb(190, 175, 70) } else { Color32::from_rgb(130, 103, 0) };
diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml
index d1bf0fc4b5..0f25e308ec 100644
--- a/crates/ui-egui/Cargo.toml
+++ b/crates/ui-egui/Cargo.toml
@@ -36,6 +36,10 @@ tiny-skia = { workspace = true }
# updated by its installer (MIT; already in the tree as a build dependency).
winreg = "0.56"
+[dev-dependencies]
+# Parse the source guard structurally, including code after inline test modules.
+syn = { workspace = true, features = ["visit"] }
+
# Pictures pasted into the agent chat; already in the tree, with the same features, through
# egui-winit's clipboard.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
diff --git a/crates/ui-egui/build.rs b/crates/ui-egui/build.rs
index 797da0514e..79c9c0b0f9 100644
--- a/crates/ui-egui/build.rs
+++ b/crates/ui-egui/build.rs
@@ -132,6 +132,7 @@ fn icon_data() -> Result<(), String> {
("CONSTRUCTION_PRIMARY", palette.get("accents").and_then(|v| v.get("construction"))),
("SKETCH_RED_GREEN", palette.get("variants").and_then(|v| v.get("red-green")).and_then(|v| v.get("sketch"))),
("CONSTRUCTION_RED_GREEN", palette.get("variants").and_then(|v| v.get("red-green")).and_then(|v| v.get("construction"))),
+ ("CONSTRAINT_RED_GREEN", palette.get("variants").and_then(|v| v.get("red-green")).and_then(|v| v.get("constraint"))),
("CONSTRUCTION_BLUE_YELLOW", palette.get("variants").and_then(|v| v.get("blue-yellow")).and_then(|v| v.get("construction"))),
("CONSTRAINT_BLUE_YELLOW", palette.get("variants").and_then(|v| v.get("blue-yellow")).and_then(|v| v.get("constraint"))),
] {
diff --git a/crates/ui-egui/src/agent_chat/markdown_view.rs b/crates/ui-egui/src/agent_chat/markdown_view.rs
index 2d8d6ebfb8..ba8647329b 100644
--- a/crates/ui-egui/src/agent_chat/markdown_view.rs
+++ b/crates/ui-egui/src/agent_chat/markdown_view.rs
@@ -5,6 +5,7 @@
//! so the parsed blocks are kept per conversation item and parsed again only when its text
//! changes.
+use crate::fonts::RichTextExt as _;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
@@ -41,9 +42,11 @@ fn job(ui: &egui::Ui, spans: &[Span], size: f32, color: Color32) -> LayoutJob {
let plain = TextFormat { font_id: base.clone(), color, ..Default::default() };
match s {
Span::Text(x) => j.append(x, 0.0, plain),
- Span::Bold(x) => j.append(x, 0.0, TextFormat { color: t.text, ..plain }),
+ Span::Bold(x) => j.append(x, 0.0, TextFormat { font_id: crate::fonts::semibold(size), color: t.text, ..plain }),
Span::Italic(x) => j.append(x, 0.0, TextFormat { italics: true, ..plain }),
- Span::Code(x) => j.append(x, 0.0, TextFormat { font_id: FontId::monospace(size - 1.0), background: t.field, ..plain }),
+ Span::Code(x) => {
+ j.append(x, 0.0, TextFormat { font_id: FontId::monospace(size - (t.font_button - t.font_body)), background: t.field, ..plain })
+ }
Span::Link { label, .. } => j.append(label, 0.0, TextFormat { color: t.accent, underline: Stroke::new(1.0, t.accent), ..plain }),
}
}
@@ -58,6 +61,7 @@ fn host(url: &str) -> &str {
/// A paragraph's text, then its links as buttons (a laid-out text cannot be clicked in parts).
fn spans(ui: &mut egui::Ui, spans: &[Span], size: f32, color: Color32) {
+ let t = Tokens::get();
ui.add(egui::Label::new(job(ui, spans, size, color)).selectable(true).wrap());
let links: Vec<(&str, &str)> =
spans.iter().filter_map(|s| if let Span::Link { label, url } = s { Some((label.as_str(), url.as_str())) } else { None }).collect();
@@ -66,7 +70,7 @@ fn spans(ui: &mut egui::Ui, spans: &[Span], size: f32, color: Color32) {
for (label, url) in links {
// The text above already shows the label; the button says where it goes.
let to = format!("↗ {}", host(url));
- ui.hyperlink_to(RichText::new(to).size(size - 1.0), url).on_hover_text(format!("{label}: {url}"));
+ ui.hyperlink_to(RichText::new(to).size(size - (t.font_button - t.font_body)), url).on_hover_text(format!("{label}: {url}"));
}
});
}
@@ -75,24 +79,28 @@ fn spans(ui: &mut egui::Ui, spans: &[Span], size: f32, color: Color32) {
/// Draw `src` as Markdown. `slot`: the conversation item it belongs to.
pub fn show(ui: &mut egui::Ui, slot: usize, src: &str) {
let t = Tokens::get();
- let size = 13.0;
+ let size = t.font_button;
let parsed = blocks(ui.ctx(), slot, src);
for block in parsed.iter() {
match block {
Block::Paragraph(s) => spans(ui, s, size, t.text),
Block::Heading { level, spans: s } => {
let size = match level {
- 1 => 17.0,
- 2 => 15.0,
- _ => 14.0,
+ 1 => t.font_article_heading,
+ 2 => t.font_subtitle,
+ _ => t.font_heading,
};
ui.add_space(4.0);
- ui.add(egui::Label::new(RichText::new(markdown::plain(s)).size(size).strong().color(t.text)).selectable(true).wrap());
+ ui.add(egui::Label::new(RichText::new(markdown::plain(s)).size(size).semibold().color(t.text)).selectable(true).wrap());
}
Block::Code { text, .. } => {
egui::Frame::NONE.fill(t.field).corner_radius(4.0).inner_margin(Margin::same(6)).show(ui, |ui| {
ui.set_width(ui.available_width());
- ui.add(egui::Label::new(RichText::new(text).monospace().size(size - 1.0).color(t.text)).selectable(true).wrap());
+ ui.add(
+ egui::Label::new(RichText::new(text).monospace().size(size - (t.font_button - t.font_body)).color(t.text))
+ .selectable(true)
+ .wrap(),
+ );
if ui.small_button(tr("ui.agent_chat_copy")).clicked() {
ui.ctx().copy_text(text.clone());
}
@@ -116,7 +124,7 @@ pub fn show(ui: &mut egui::Ui, slot: usize, src: &str) {
}
Block::Pre(text) => {
egui::ScrollArea::horizontal().id_salt(("agent_chat_pre", slot, text.len())).show(ui, |ui| {
- ui.add(egui::Label::new(RichText::new(text).monospace().size(size - 2.0).color(t.text)).selectable(true));
+ ui.add(egui::Label::new(RichText::new(text).monospace().size(t.font_small).color(t.text)).selectable(true));
});
}
Block::Rule => {
diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rs
index 8f6c792c2d..f4aa88c762 100644
--- a/crates/ui-egui/src/agent_chat/panel.rs
+++ b/crates/ui-egui/src/agent_chat/panel.rs
@@ -2,6 +2,7 @@
//! or in Preferences), resizable, folded to a thin strip with Minimise, closed with ×. Its side,
//! width and fold are preferences, so they come back next time.
+use crate::fonts::RichTextExt as _;
use egui::{Align, Align2, Color32, Id, Layout, Rect, RichText, Sense, Stroke, pos2, vec2};
use super::*;
@@ -134,13 +135,13 @@ fn picture_strip(ui: &mut egui::Ui, n: usize, pictures: &[Picture]) -> Option<us
Shown::Ready(texture) => texture,
// Being decoded: a spinner the size of a thumbnail's corner, until it is in.
Shown::Loading => {
- ui.add(egui::Spinner::new().size(THUMB_MAX.1 / 2.0));
+ ui.add(egui::Spinner::new().size(t.space_24));
continue;
}
// Not a readable picture: its name, or the plain caption.
Shown::Failed => {
let caption = if picture.note.is_empty() { tr("ui.agent_chat_view_attached").to_string() } else { picture.note.clone() };
- ui.label(RichText::new(caption).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(caption).color(t.text_dim).size(t.font_small));
continue;
}
};
@@ -203,7 +204,7 @@ fn gallery_window(app: &mut SolveApp, ctx: &egui::Context) {
crate::scenario::publish_rect("agent_chat:gallery_picture", resp.rect);
}
Shown::Loading => {
- ui.add(egui::Spinner::new().size(32.0));
+ ui.add(egui::Spinner::new().size(t.space_24));
}
Shown::Failed => {
ui.label(RichText::new(tr("ui.agent_chat_view_attached")).color(t.text_dim));
@@ -242,7 +243,7 @@ fn drop_hint(ctx: &egui::Context, area: Rect) {
let painter = ctx.layer_painter(egui::LayerId::new(egui::Order::Foreground, Id::new("sc_agent_chat_drop_hint")));
let zone = area.shrink(6.0);
painter.rect(zone, 10.0, t.accent.gamma_multiply(0.16), Stroke::new(2.0, t.accent), egui::StrokeKind::Inside);
- let font = egui::FontId::proportional(14.0);
+ let font = egui::FontId::proportional(Tokens::get().font_heading);
let text = painter.layout(tr("ui.agent_chat_drop_hint").to_string(), font, t.text, (zone.width() - 24.0).max(40.0));
let at = zone.center() - text.size() / 2.0;
painter.galley(at, text, t.text);
@@ -422,7 +423,13 @@ fn strip(app: &mut SolveApp, ui: &mut egui::Ui) {
if waiting > 0 {
let at = button.right_top() + vec2(-3.0, 3.0);
ui.painter().circle_filled(at, 6.5, t.warning);
- ui.painter().text(at, Align2::CENTER_CENTER, waiting.min(9).to_string(), egui::FontId::proportional(9.5), t.panel);
+ ui.painter().text(
+ at,
+ Align2::CENTER_CENTER,
+ waiting.min(9).to_string(),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_badge),
+ t.panel,
+ );
}
ui.painter().line_segment(
if app.preferences.agent_chat_side == "left" { [r.right_top(), r.right_bottom()] } else { [r.left_top(), r.left_bottom()] },
@@ -451,7 +458,9 @@ fn header(app: &mut SolveApp, ui: &mut egui::Ui, left: bool) {
}
}
}
- let l = ui.label(RichText::new(tr("ui.agent_chat")).strong().size(14.0));
+ let l = ui.label(
+ RichText::new(tr("ui.agent_chat")).semibold().color(crate::theme::Tokens::get().text).size(crate::theme::Tokens::get().font_heading),
+ );
grip.union(l.rect)
};
let mut s = state.label().to_string();
@@ -539,7 +548,7 @@ fn dock_drag(app: &mut SolveApp, ui: &egui::Ui, drag: &egui::Response, left: boo
zone.center(),
Align2::CENTER_CENTER,
tr(if to_left { "ui.agent_chat_dock_left" } else { "ui.agent_chat_dock_right" }),
- egui::FontId::proportional(14.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_heading),
t.text,
);
}
@@ -693,7 +702,7 @@ pub(super) fn login_chip(ui: &mut egui::Ui, login: &str) {
_ => return,
};
egui::Frame::NONE.stroke(Stroke::new(1.0, color)).corner_radius(8.0).inner_margin(egui::Margin::symmetric(6, 1)).show(ui, |ui| {
- ui.label(RichText::new(text).color(color).size(11.0));
+ ui.label(RichText::new(text).color(color).size(crate::theme::Tokens::get().font_small));
});
}
@@ -736,29 +745,32 @@ fn switcher(app: &mut SolveApp, ui: &mut egui::Ui) {
(ui.available_width() - if app.agent_chat.modes.is_empty() { 4.0 } else { 116.0 } - if models { 146.0 } else { 0.0 }).clamp(90.0, 260.0);
let mut picked: Option<String> = None;
let mut add = false;
- let combo = egui::ComboBox::from_id_salt("sc_agent_switch").width(w).selected_text(RichText::new(label).strong()).show_ui(ui, |ui| {
- for e in &all {
- let sel = current.as_ref().is_some_and(|c| c.id == e.id);
- let r = ui.horizontal(|ui| {
- kind_icon(ui, e.kind);
- let r = ui.selectable_label(sel, &e.name);
- ui.label(RichText::new(e.detail()).color(t.text_dim).size(11.0));
- login_chip(ui, e.login);
- r
- });
- crate::scenario::publish_handle(&format!("agent_chat:agent:{}", e.id), r.inner.rect.center());
- if r.inner.clicked() {
- picked = Some(e.id.clone());
+ let combo = egui::ComboBox::from_id_salt("sc_agent_switch")
+ .width(w)
+ .selected_text(RichText::new(label).semibold().color(crate::theme::Tokens::get().text))
+ .show_ui(ui, |ui| {
+ for e in &all {
+ let sel = current.as_ref().is_some_and(|c| c.id == e.id);
+ let r = ui.horizontal(|ui| {
+ kind_icon(ui, e.kind);
+ let r = ui.selectable_label(sel, &e.name);
+ ui.label(RichText::new(e.detail()).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
+ login_chip(ui, e.login);
+ r
+ });
+ crate::scenario::publish_handle(&format!("agent_chat:agent:{}", e.id), r.inner.rect.center());
+ if r.inner.clicked() {
+ picked = Some(e.id.clone());
+ }
}
- }
- ui.separator();
- if ui.selectable_label(false, tr("ui.ai_add_agent")).clicked() {
- add = true;
- }
- if ui.selectable_label(false, tr("ui.ai_settings")).clicked() {
- crate::prefs::open_at(app, crate::prefs::PAGE_AI);
- }
- });
+ ui.separator();
+ if ui.selectable_label(false, tr("ui.ai_add_agent")).clicked() {
+ add = true;
+ }
+ if ui.selectable_label(false, tr("ui.ai_settings")).clicked() {
+ crate::prefs::open_at(app, crate::prefs::PAGE_AI);
+ }
+ });
crate::scenario::publish_handle("agent_chat:switcher", combo.response.rect.center());
combo.response.on_hover_text(tr("ui.ai_switch_tip"));
if add {
@@ -811,7 +823,7 @@ fn switcher(app: &mut SolveApp, ui: &mut egui::Ui) {
}
});
if let Some(a) = &app.agent_chat.auth_status {
- ui.label(RichText::new(a).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(a).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
}
}
@@ -826,7 +838,7 @@ fn picker(app: &mut SolveApp, ui: &mut egui::Ui) {
let all = agents::entries(app);
let current = agents::current(app);
ui.horizontal(|ui| {
- ui.label(RichText::new(tr("ui.agent_chat_pick")).strong());
+ ui.label(RichText::new(tr("ui.agent_chat_pick")).semibold().color(crate::theme::Tokens::get().text));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
let refreshing = app.agent_chat.detecting.is_some();
if ui.add_enabled(!refreshing, egui::Button::new(tr("ui.agent_chat_refresh")).small()).clicked() {
@@ -847,8 +859,8 @@ fn picker(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
kind_icon(ui, e.kind);
- ui.label(RichText::new(&e.name).strong().color(t.text));
- ui.label(RichText::new(e.detail()).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(&e.name).semibold().color(t.text));
+ ui.label(RichText::new(e.detail()).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| login_chip(ui, e.login));
});
});
@@ -866,12 +878,16 @@ fn picker(app: &mut SolveApp, ui: &mut egui::Ui) {
|ui| {
for m in missing {
ui.horizontal(|ui| {
- ui.label(RichText::new(m.name).strong());
+ ui.label(RichText::new(m.name).semibold().color(crate::theme::Tokens::get().text));
if ui.small_button(tr("ui.agent_chat_copy")).on_hover_text(m.install).clicked() {
ui.ctx().copy_text(m.install.to_string());
}
});
- ui.add(egui::Label::new(RichText::new(m.install).monospace().size(11.0).color(t.text_dim)).selectable(true).wrap());
+ ui.add(
+ egui::Label::new(RichText::new(m.install).monospace().size(crate::theme::Tokens::get().font_small).color(t.text_dim))
+ .selectable(true)
+ .wrap(),
+ );
}
},
);
@@ -883,7 +899,7 @@ fn auth_box(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
egui::Frame::group(ui.style()).stroke(Stroke::new(1.0, t.warning)).show(ui, |ui| {
ui.set_width(ui.available_width());
- ui.label(RichText::new(tr("ui.agent_chat_auth_title")).strong());
+ ui.label(RichText::new(tr("ui.agent_chat_auth_title")).semibold().color(crate::theme::Tokens::get().text));
ui.label(RichText::new(tr("ui.agent_chat_auth_needed")).color(t.text_dim));
let methods = app.agent_chat.auth.clone();
let base = app.agent_chat.argv.iter().map(|a| quote(a)).collect::<Vec<_>>().join(" ");
@@ -893,14 +909,22 @@ fn auth_box(app: &mut SolveApp, ui: &mut egui::Ui) {
for m in methods {
ui.add_space(4.0);
let desc = m.description.trim();
- ui.label(RichText::new(if desc.is_empty() || desc == m.name { m.name.clone() } else { format!("{} — {desc}", m.name) }).strong());
+ ui.label(
+ RichText::new(if desc.is_empty() || desc == m.name { m.name.clone() } else { format!("{} — {desc}", m.name) })
+ .semibold()
+ .color(crate::theme::Tokens::get().text),
+ );
match &m.kind {
acp::AuthKind::Terminal { args, .. } => {
ui.label(tr("ui.agent_chat_auth_terminal"));
let cmd = format!("{base} {}", args.iter().map(|a| quote(a)).collect::<Vec<_>>().join(" "));
ui.horizontal_wrapped(|ui| {
egui::Frame::NONE.fill(t.toolbar).corner_radius(4.0).inner_margin(egui::Margin::symmetric(6, 3)).show(ui, |ui| {
- ui.add(egui::Label::new(RichText::new(&cmd).monospace().size(11.0)).selectable(true).wrap());
+ ui.add(
+ egui::Label::new(RichText::new(&cmd).monospace().size(crate::theme::Tokens::get().font_small))
+ .selectable(true)
+ .wrap(),
+ );
});
if ui.small_button(tr("ui.agent_chat_copy")).clicked() {
ui.ctx().copy_text(cmd.clone());
@@ -950,7 +974,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
}
} else if *image {
// Taken when the agent starts on the message: nothing to show yet.
- ui.label(RichText::new(tr("ui.agent_chat_view_attached")).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tr("ui.agent_chat_view_attached")).color(t.text_dim).size(t.font_small));
}
files_line(ui, files.iter().map(String::as_str));
});
@@ -981,7 +1005,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
Item::Permission { title, options, answer: given, .. } => {
egui::Frame::group(ui.style()).stroke(Stroke::new(1.0, t.accent)).show(ui, |ui| {
ui.set_width(ui.available_width());
- ui.label(RichText::new(trf("ui.agent_chat_permission", &[("title", title)])).strong());
+ ui.label(RichText::new(trf("ui.agent_chat_permission", &[("title", title)])).semibold().color(crate::theme::Tokens::get().text));
match given {
Some(a) => {
ui.label(RichText::new(trf("ui.agent_chat_answered", &[("option", a)])).color(t.text_dim));
@@ -1005,8 +1029,8 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
Item::Approval { id, title, tool, answer: given } => {
egui::Frame::group(ui.style()).stroke(Stroke::new(1.5, t.warning)).show(ui, |ui| {
ui.set_width(ui.available_width());
- ui.label(RichText::new(tr("ui.agent_chat_approval")).strong());
- ui.add(egui::Label::new(RichText::new(title).monospace().size(11.5)).selectable(true).wrap());
+ ui.label(RichText::new(tr("ui.agent_chat_approval")).semibold().color(crate::theme::Tokens::get().text));
+ ui.add(egui::Label::new(RichText::new(title).monospace().size(crate::theme::Tokens::get().font_caption)).selectable(true).wrap());
match given {
Some(true) => {
ui.label(RichText::new(tr("ui.agent_chat_allowed")).color(t.text_dim));
@@ -1039,9 +1063,9 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
Item::Changes { steps, doc, undone } => {
ui.horizontal(|ui| {
let text = trf("ui.agent_chat_changes", &[("n", &steps.to_string())]);
- ui.label(RichText::new(text).color(t.text_dim).size(11.5));
+ ui.label(RichText::new(text).color(t.text_dim).size(crate::theme::Tokens::get().font_caption));
if *undone {
- ui.label(RichText::new(tr("ui.agent_chat_undone")).color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tr("ui.agent_chat_undone")).color(t.text_dim).size(crate::theme::Tokens::get().font_caption));
} else if Arc::ptr_eq(doc, &current_doc) {
let b = ui.button(tr("ui.agent_chat_undo_changes")).on_hover_text(tr("ui.ai_undo_tip"));
crate::scenario::publish_handle("agent_chat:undo", b.rect.center());
@@ -1071,15 +1095,19 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
let tag = if stopped && !busy { "ui.agent_chat_queued_stopped" } else { "ui.agent_chat_queued" };
- ui.label(RichText::new(tr(tag)).color(t.accent).strong().size(11.0));
+ ui.label(RichText::new(tr(tag)).color(t.accent).semibold().size(crate::theme::Tokens::get().font_small));
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- let x = ui.add(egui::Button::new(RichText::new("×").size(14.0)).frame(false)).on_hover_text(tr("ui.agent_chat_remove"));
+ let x = ui
+ .add(egui::Button::new(RichText::new("×").size(crate::theme::Tokens::get().font_heading)).frame(false))
+ .on_hover_text(tr("ui.agent_chat_remove"));
crate::scenario::publish_handle(&format!("agent_chat:pending_remove:{n}"), x.rect.center());
if x.clicked() {
remove = Some(n);
}
if editing.as_ref().is_none_or(|(i, _)| *i != n) {
- let e = ui.add(egui::Button::new(RichText::new(tr("ui.agent_chat_edit")).size(11.5)).frame(false));
+ let e = ui.add(
+ egui::Button::new(RichText::new(tr("ui.agent_chat_edit")).size(crate::theme::Tokens::get().font_caption)).frame(false),
+ );
crate::scenario::publish_handle(&format!("agent_chat:pending_edit:{n}"), e.rect.center());
if e.clicked() {
start_edit = Some((n, p.text.clone()));
@@ -1105,7 +1133,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.add(egui::Label::new(RichText::new(&p.text).color(t.text)).selectable(true).wrap());
}
if p.image {
- ui.label(RichText::new(tr("ui.agent_chat_view_attached")).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tr("ui.agent_chat_view_attached")).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
}
files_line(ui, p.files.iter().map(|f| f.name.as_str()));
}
@@ -1134,7 +1162,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.add_space(12.0);
ui.label(RichText::new(tr("ui.agent_chat_intro")).color(t.text_dim));
ui.add_space(6.0);
- ui.label(RichText::new(tr("ui.agent_chat_privacy")).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tr("ui.agent_chat_privacy")).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
}
if let Some((n, text)) = edit_done {
if let (Some(text), Some(p)) = (text.filter(|t| !t.trim().is_empty()), app.agent_chat.pending.get_mut(n)) {
@@ -1173,7 +1201,7 @@ fn files_line<'a>(ui: &mut egui::Ui, names: impl Iterator<Item = &'a str>) {
let list = names.collect::<Vec<_>>().join(", ");
if !list.is_empty() {
let t = Tokens::get();
- ui.add(egui::Label::new(RichText::new(trf("ui.agent_chat_files", &[("files", &list)])).color(t.text_dim).size(11.0)).wrap());
+ ui.add(egui::Label::new(RichText::new(trf("ui.agent_chat_files", &[("files", &list)])).color(t.text_dim).size(t.font_small)).wrap());
}
}
@@ -1248,11 +1276,11 @@ fn loading_chip(ui: &mut egui::Ui, name: &str, importing: bool, i: usize, w: f32
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 4.0;
let doing = tr(if importing { "ui.agent_chat_file_importing" } else { "ui.agent_chat_file_loading" });
- let mark = ui.add(egui::Spinner::new().size(16.0)).on_hover_text(doing).rect.width();
+ let mark = ui.add(egui::Spinner::new().size(t.form_icon_size)).on_hover_text(doing).rect.width();
let name_w = (inner - mark - 18.0 - 8.0).max(8.0);
ui.allocate_ui(vec2(name_w, 20.0), |ui| {
ui.set_width(name_w);
- ui.add(egui::Label::new(RichText::new(name).size(11.5).color(t.text_dim)).truncate())
+ ui.add(egui::Label::new(RichText::new(name).size(t.font_small).color(t.text_dim)).truncate())
})
.inner
.on_hover_text(name);
@@ -1295,14 +1323,20 @@ fn chip(ui: &mut egui::Ui, thumbs: &mut std::collections::HashMap<u64, egui::Tex
let (r, _) = ui.allocate_exact_size(vec2(28.0, 20.0), Sense::hover());
let color = if matches!(f.content, attach::Content::Pdf { .. }) { t.error } else { t.text_dim };
ui.painter().rect_stroke(r.shrink2(vec2(1.0, 1.0)), 2.0, Stroke::new(1.2, color), egui::StrokeKind::Inside);
- ui.painter().text(r.center(), Align2::CENTER_CENTER, f.mark(), egui::FontId::proportional(8.5), color);
+ ui.painter().text(
+ r.center(),
+ Align2::CENTER_CENTER,
+ f.mark(),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_micro),
+ color,
+ );
r.width()
}
};
let name_w = (inner - mark - 18.0 - 8.0).max(8.0);
ui.allocate_ui(vec2(name_w, 20.0), |ui| {
ui.set_width(name_w);
- ui.add(egui::Label::new(RichText::new(&f.name).size(11.5)).truncate())
+ ui.add(egui::Label::new(RichText::new(&f.name).size(t.font_small)).truncate())
})
.inner
.on_hover_text(&f.name);
@@ -1325,8 +1359,9 @@ fn chip(ui: &mut egui::Ui, thumbs: &mut std::collections::HashMap<u64, egui::Tex
/// the clipboard's picture.
#[cfg(not(target_arch = "wasm32"))]
fn add_menu(app: &mut SolveApp, ui: &mut egui::Ui) {
+ let t = Tokens::get();
let (mut choose, mut paste) = (false, false);
- let r = ui.menu_button(RichText::new("+").strong().size(15.0), |ui| {
+ let r = ui.menu_button(RichText::new("+").semibold().size(t.font_heading), |ui| {
let a = ui.button(tr("ui.agent_chat_add_file"));
crate::scenario::publish_handle("agent_chat:add_file", a.rect.center());
let b = ui.button(tr("ui.agent_chat_paste_picture"));
@@ -1376,12 +1411,16 @@ fn tool_card(ui: &mut egui::Ui, n: usize, title: &str, kind: &str, status: Optio
status_dot(ui, color, filled);
// The state and kind keep their room at the right; the title is cut short before them.
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
- ui.label(RichText::new(tr(state)).size(10.5).color(color));
+ ui.label(RichText::new(tr(state)).size(crate::theme::Tokens::get().font_panel).color(color));
if !kind.is_empty() && kind != "other" {
- ui.label(RichText::new(kind).size(10.5).color(t.text_dim));
+ ui.label(RichText::new(kind).size(crate::theme::Tokens::get().font_panel).color(t.text_dim));
}
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
- ui.add(egui::Label::new(RichText::new(title).monospace().size(11.5).color(t.text)).truncate()).on_hover_text(title);
+ ui.add(
+ egui::Label::new(RichText::new(title).monospace().size(crate::theme::Tokens::get().font_caption).color(t.text))
+ .truncate(),
+ )
+ .on_hover_text(title);
});
});
});
@@ -1397,7 +1436,7 @@ fn tool_card(ui: &mut egui::Ui, n: usize, title: &str, kind: &str, status: Optio
if let Some(o) = output {
ui.separator();
egui::ScrollArea::vertical().id_salt(("sc_agent_tool_out", n)).max_height(180.0).show(ui, |ui| {
- ui.add(egui::Label::new(RichText::new(o).monospace().size(11.0)).selectable(true).wrap());
+ ui.add(egui::Label::new(RichText::new(o).monospace().size(crate::theme::Tokens::get().font_small)).selectable(true).wrap());
});
}
});
diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rs
index cd4412a39a..b9d3463361 100644
--- a/crates/ui-egui/src/agent_chat/settings.rs
+++ b/crates/ui-egui/src/agent_chat/settings.rs
@@ -3,6 +3,7 @@
//! and the panel. Plus the Add agent dialog: an installed ACP agent, a custom command, or an
//! OpenAI-compatible endpoint (whose key goes to the system keychain).
+use crate::fonts::RichTextExt as _;
use egui::{RichText, Stroke};
use super::agents::{self, AgentConfig, Kind, Mode};
@@ -92,13 +93,13 @@ fn test_line(ui: &mut egui::Ui, t: &Option<&Test>) {
let tk = Tokens::get();
match t {
Some(Test::Running(_)) => {
- ui.label(RichText::new(tr("ui.ai_testing")).color(tk.text_dim).size(11.0));
+ ui.label(RichText::new(tr("ui.ai_testing")).color(tk.text_dim).size(crate::theme::Tokens::get().font_small));
}
Some(Test::Done(Ok(m))) => {
- ui.label(RichText::new(m.clone()).color(tk.accent).size(11.0));
+ ui.label(RichText::new(m.clone()).color(tk.accent).size(crate::theme::Tokens::get().font_small));
}
Some(Test::Done(Err(e))) => {
- ui.add(egui::Label::new(RichText::new(e).color(tk.error).size(11.0)).wrap());
+ ui.add(egui::Label::new(RichText::new(e).color(tk.error).size(crate::theme::Tokens::get().font_small)).wrap());
}
None => {}
}
@@ -106,19 +107,20 @@ fn test_line(ui: &mut egui::Ui, t: &Option<&Test>) {
fn section(ui: &mut egui::Ui, title: &str) {
ui.add_space(10.0);
- ui.label(RichText::new(title).strong().size(13.0));
+ ui.label(RichText::new(title).semibold().color(crate::theme::Tokens::get().text).size(crate::theme::Tokens::get().font_button));
ui.separator();
}
fn note(ui: &mut egui::Ui, text: &str) {
let t = Tokens::get();
- ui.add(egui::Label::new(RichText::new(text).size(11.0).color(t.text_dim)).wrap());
+ ui.add(egui::Label::new(RichText::new(text).size(crate::theme::Tokens::get().font_small).color(t.text_dim)).wrap());
}
/// The AI page of Settings.
pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
- let r = ui.checkbox(&mut app.preferences.ai_features, RichText::new(tr("ui.ai_show_features")).strong());
+ let r =
+ ui.checkbox(&mut app.preferences.ai_features, RichText::new(tr("ui.ai_show_features")).semibold().color(crate::theme::Tokens::get().text));
crate::scenario::publish_handle("prefs:ai_features", r.rect.center());
note(ui, tr("ui.ai_show_features_note"));
if cfg!(target_arch = "wasm32") {
@@ -163,7 +165,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
let remembered: Vec<(String, Vec<String>)> =
app.preferences.agent_always_allow.iter().filter(|(_, v)| !v.is_empty()).map(|(k, v)| (k.clone(), v.clone())).collect();
ui.add_space(4.0);
- ui.label(RichText::new(tr("ui.ai_always_allowed")).strong());
+ ui.label(RichText::new(tr("ui.ai_always_allowed")).semibold().color(crate::theme::Tokens::get().text));
if remembered.is_empty() {
note(ui, tr("ui.ai_always_allowed_none"));
}
@@ -172,7 +174,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.horizontal_wrapped(|ui| {
ui.label(names.get(&agent).cloned().unwrap_or_else(|| agent.clone()));
for tool in &tools {
- ui.label(RichText::new(tool).monospace().size(11.0).color(t.text_dim));
+ ui.label(RichText::new(tool).monospace().size(crate::theme::Tokens::get().font_small).color(t.text_dim));
}
if ui.small_button(tr("ui.ai_reset")).clicked() {
app.preferences.agent_always_allow.remove(&agent);
@@ -230,11 +232,11 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.set_width(ui.available_width());
ui.horizontal(|ui| {
super::panel::kind_icon(ui, e.kind);
- ui.label(RichText::new(&e.name).strong());
- ui.label(RichText::new(e.detail()).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(&e.name).semibold().color(crate::theme::Tokens::get().text));
+ ui.label(RichText::new(e.detail()).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
super::panel::login_chip(ui, e.login);
if !e.found {
- ui.label(RichText::new(tr("ui.ai_added")).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tr("ui.ai_added")).color(t.text_dim).size(crate::theme::Tokens::get().font_small));
}
});
ui.horizontal(|ui| {
@@ -388,7 +390,12 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
ui.add(egui::TextEdit::singleline(&mut s.command).desired_width(300.0));
ui.end_row();
ui.label("");
- ui.add(egui::Label::new(RichText::new(tr("ui.ai_add_installed_note")).size(11.0).color(t.text_dim)).wrap());
+ ui.add(
+ egui::Label::new(
+ RichText::new(tr("ui.ai_add_installed_note")).size(crate::theme::Tokens::get().font_small).color(t.text_dim),
+ )
+ .wrap(),
+ );
ui.end_row();
}
AddKind::Custom => {
@@ -399,7 +406,12 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
ui.add(egui::TextEdit::singleline(&mut s.command).hint_text("my-agent --acp").desired_width(300.0));
ui.end_row();
ui.label("");
- ui.add(egui::Label::new(RichText::new(tr("ui.agent_chat_custom_hint")).size(11.0).color(t.text_dim)).wrap());
+ ui.add(
+ egui::Label::new(
+ RichText::new(tr("ui.agent_chat_custom_hint")).size(crate::theme::Tokens::get().font_small).color(t.text_dim),
+ )
+ .wrap(),
+ );
ui.end_row();
}
AddKind::Api => {
@@ -437,7 +449,7 @@ pub fn dialog(app: &mut SolveApp, ctx: &egui::Context) {
ui.end_row();
ui.label("");
let note = if has_keychain { tr("ui.ai_key_note") } else { tr("ui.ai_no_keychain") };
- ui.add(egui::Label::new(RichText::new(note).size(11.0).color(t.text_dim)).wrap());
+ ui.add(egui::Label::new(RichText::new(note).size(crate::theme::Tokens::get().font_small).color(t.text_dim)).wrap());
ui.end_row();
ui.label("");
ui.horizontal(|ui| {
diff --git a/crates/ui-egui/src/agent_chat/tests.rs b/crates/ui-egui/src/agent_chat/tests.rs
index 26246fd727..193abff08d 100644
--- a/crates/ui-egui/src/agent_chat/tests.rs
+++ b/crates/ui-egui/src/agent_chat/tests.rs
@@ -79,7 +79,7 @@ fn ask(tx: &Sender<ControlRequest>, method: &str, params: Value) -> Receiver<Val
}
fn frame(app: &mut SolveApp) {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
poll(app, &ctx);
app.drain_control(&ctx);
}
@@ -463,7 +463,7 @@ fn app_with_script() -> (SolveApp, Script, egui::Context) {
let script = Script::default();
app.agent_chat.backend = Some(Box::new(script.clone()));
app.agent_chat.state = Some(State::Ready);
- (app, script, egui::Context::default())
+ (app, script, crate::fonts::test_context())
}
fn ended(script: &Script, reason: &str) {
@@ -631,7 +631,7 @@ done
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
app.agent_chat.backend = Some(Box::new(acp_client::AcpBackend::start(&argv, start).unwrap()));
app.agent_chat.state = Some(State::Starting);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let until = |app: &mut SolveApp, what: &str, done: &dyn Fn(&SolveApp) -> bool| {
let t = std::time::Instant::now();
while !done(app) {
@@ -724,7 +724,7 @@ done
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
app.agent_chat.backend = Some(Box::new(acp_client::AcpBackend::start(&argv, start).unwrap()));
app.agent_chat.state = Some(State::Starting);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let until = |app: &mut SolveApp, done: &dyn Fn(&SolveApp) -> bool| {
let t = std::time::Instant::now();
while !done(app) {
@@ -842,7 +842,7 @@ done
app.agent_chat.state = Some(State::Starting);
app.agent_chat.running_id = "fake".into();
app.preferences.agent_models.insert("fake".into(), "smart".into());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let t = std::time::Instant::now();
loop {
poll(&mut app, &ctx);
diff --git a/crates/ui-egui/src/bom_panel.rs b/crates/ui-egui/src/bom_panel.rs
index 5bab059de9..6694eef3aa 100644
--- a/crates/ui-egui/src/bom_panel.rs
+++ b/crates/ui-egui/src/bom_panel.rs
@@ -89,7 +89,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let bom = d.rows(app);
let rows: Vec<Value> = bom["rows"].as_array().cloned().unwrap_or_default();
let (mut export, mut apply_row) = (None, None);
- let title = RichText::new(crate::i18n::tr_label("Bill of Materials")).strong().size(13.0);
+ let title = RichText::new(crate::i18n::tr_label("Bill of Materials")).strong().size(t.font_button);
crate::frame::window(ctx, title, crate::frame::Width::Wide).id(egui::Id::new("sc_bom")).open(&mut open).resizable(true).show(ctx, |ui| {
ui.horizontal(|ui| {
let was = (d.top, d.by_definition, d.group_children);
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index d895670271..f083115b9a 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -6,6 +6,7 @@
//! viewport, a double-click on a sketch edits it, and a right-click opens the item's menu
//! ([`crate::context_menu`]).
+use crate::fonts::RichTextExt as _;
#[cfg(test)]
#[path = "occurrence_ui_tests.rs"]
mod occurrence_ui_tests;
@@ -176,14 +177,14 @@ pub fn group_name(app: &SolveApp, id: u64) -> Option<String> {
pub fn group_items(app: &SolveApp, id: u64, scope: &str) -> Vec<Item> {
let Some(g) = find_group(app, id) else { return Vec::new() };
let mut v = vec![
- Item::action("ui.rename", "Rename", "").with(json!({ "group": id })),
+ Item::action("ui.rename", "Rename", "rename").with(json!({ "group": id })),
Item::action("ui.ungroup", "Ungroup", "folder").with(json!({ "group": id })),
Item::sep(),
// The group itself: its items keep their own state.
Item::action("ui.folderVisible", "Show/Hide", "eye").key("V").with(json!({ "key": format!("{scope}/g{id}") })),
];
if g.folder == "bodies" {
- v.push(Item::action("ui.isolate", "Isolate", "").with(json!({ "bodies": group_bodies(app, id) })));
+ v.push(Item::action("ui.isolate", "Isolate", "body").with(json!({ "bodies": group_bodies(app, id) })));
}
v
}
@@ -426,10 +427,14 @@ pub(crate) fn draw_row(ui: &mut egui::Ui, id: egui::Id, row: &Row) -> RowResp {
icons::paint_icon(ui.painter(), ir, row.icon, if row.dim { DIM_ICON_OPACITY } else { 1.0 });
x += 21.0;
}
- let col =
- if row.selected { crate::theme::TabAccent::current(ui.ctx()).color } else { row.color.unwrap_or(if row.dim { t.text_dim } else { t.text }) };
+ let col = if row.selected {
+ crate::theme::selected_ink(&t, crate::theme::TabAccent::current(ui.ctx()).color)
+ } else {
+ row.color.unwrap_or(if row.dim { t.text_dim } else { t.text })
+ };
let label_display = if row.name { crate::i18n::tr_name(row.label) } else { crate::i18n::tr_dyn(row.label) };
- let galley = ui.painter().layout_no_wrap(label_display, FontId::proportional(t.font_label), col);
+ let font = if row.selected { crate::fonts::semibold(t.font_label) } else { FontId::proportional(t.font_label) };
+ let galley = ui.painter().layout_no_wrap(label_display, font, col);
let lw = galley.size().x;
ui.painter().galley(pos2(x, cy - galley.size().y / 2.0), galley, col);
let mut bx = (x + lw + 6.0).min(r.right() - 16.0);
@@ -673,7 +678,7 @@ fn browser_panel(app: &mut SolveApp, ui: &mut egui::Ui, timeline_above: bool) {
DRAWN.with(|d| d.borrow_mut().clear());
OCCURRENCES.with(|d| d.borrow_mut().clear());
let mut acts = Actions::default();
- let width = browser_width(app);
+ let width = browser_width(app.preferences.browser_width);
let panel = egui::Panel::left("sc_browser")
.exact_size(width)
.resizable(false)
@@ -704,8 +709,8 @@ fn browser_panel(app: &mut SolveApp, ui: &mut egui::Ui, timeline_above: bool) {
crate::scenario::publish_handle("left-history-divider", rect.center());
}
let arrow = if browser_collapsed { "▶" } else { "▼" };
- let response =
- ui.add(egui::Button::new(RichText::new(format!("{arrow} BROWSER")).size(t.font_small).strong().color(t.text_dim)).frame(false));
+ let response = ui
+ .add(egui::Button::new(RichText::new(format!("{arrow} BROWSER")).size(t.font_small).semibold().color(t.text_dim)).frame(false));
crate::scenario::publish_handle("left-browser-toggle", response.rect.center());
if response.clicked() {
app.preferences.timeline_left_browser_collapsed = !browser_collapsed;
@@ -722,8 +727,7 @@ fn browser_panel(app: &mut SolveApp, ui: &mut egui::Ui, timeline_above: bool) {
finish_browser(app, ui, acts);
}
-fn browser_width(app: &SolveApp) -> f32 {
- let remembered = app.preferences.browser_width;
+fn browser_width(remembered: f32) -> f32 {
if remembered.is_finite() { remembered.clamp(MIN_BROWSER_WIDTH, MAX_BROWSER_WIDTH) } else { crate::prefs::DEFAULT_BROWSER_WIDTH }
}
@@ -749,11 +753,8 @@ pub fn floating(app: &mut SolveApp, ui: &mut egui::Ui, available: Rect) {
let mut acts = Actions::default();
let gap = crate::shell::SHELL_GAP;
let top_gap = if app.ui.layout == crate::shell::LayoutMode::Docked { gap } else { 0.0 };
- let min = available.min + vec2(gap, top_gap);
- let right = (available.right() - gap).max(min.x);
- let bottom = app.shell.history.map_or(available.bottom() - gap, |r| r.top() - gap).max(min.y);
- let width = browser_width(app);
- let bounds = Rect::from_min_max(min, pos2((min.x + width).min(right), bottom));
+ let width = browser_width(app.preferences.browser_width);
+ let bounds = floating_bounds(available, app.shell.history, width, top_gap);
app.shell.browser = None;
let min_height = HEADER_H + 2.0 * (CARD_INSET + 1.0);
if bounds.is_positive() && bounds.height() >= min_height {
@@ -780,6 +781,14 @@ pub fn floating(app: &mut SolveApp, ui: &mut egui::Ui, available: Rect) {
finish_browser(app, ui, acts);
}
+fn floating_bounds(available: Rect, history: Option<Rect>, width: f32, top_gap: f32) -> Rect {
+ let gap = crate::shell::SHELL_GAP;
+ let min = available.min + vec2(gap, top_gap);
+ let right = (available.right() - gap).max(min.x);
+ let bottom = history.map_or(available.bottom() - gap, |r| r.top() - gap).max(min.y);
+ Rect::from_min_max(min, pos2((min.x + width).min(right), bottom))
+}
+
fn browser_contents(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, collapsible: bool) {
let t = Tokens::get();
// Only the floating card folds; the docked column keeps its full height.
@@ -811,7 +820,7 @@ fn browser_header(app: &mut SolveApp, ui: &mut egui::Ui, collapsible: bool) {
let title = crate::i18n::tr("ui.browser_title").to_string();
let kind = if collapsible { egui::WidgetType::Button } else { egui::WidgetType::Label };
response.widget_info(|| egui::WidgetInfo::labeled(kind, true, &title));
- let galley = ui.painter().layout_no_wrap(title, FontId::proportional(t.font_heading), t.text);
+ let galley = ui.painter().layout_no_wrap(title, crate::fonts::semibold(t.font_heading), t.text);
ui.painter().galley(pos2(rect.left() + t.space_6, rect.center().y - galley.size().y / 2.0), galley, t.text);
let mut right = rect.right() - t.space_6;
if collapsible {
@@ -921,8 +930,7 @@ fn finish_browser(app: &mut SolveApp, ui: &mut egui::Ui, acts: Actions) {
occurrence_panel(app, ui);
capture_prompt(app, ui.ctx());
canvas_panel(app, ui.ctx());
- let repair_anchor = app.viewport.rect.map(|rect| rect.right_top() + vec2(-16.0, 16.0)).unwrap_or_else(|| ui.ctx().content_rect().right_top());
- crate::sketch_attachment_ui::panel(app, ui.ctx(), repair_anchor);
+ crate::sketch_attachment_ui::panel(app, ui.ctx());
}
fn component_name(app: &SolveApp, id: u64) -> String {
@@ -1327,7 +1335,7 @@ pub fn view_items(app: &SolveApp, name: &str) -> Vec<Item> {
Item::action("ui.restoreView", "Restore", "home").with(json!({ "view": name })),
Item::action("ui.updateView", "Update to Current View", "perspective").with(json!({ "view": name })).on_if(saved),
Item::sep(),
- Item::action("ui.rename", "Rename", "").with(json!({ "view": name })).on_if(saved),
+ Item::action("ui.rename", "Rename", "rename").with(json!({ "view": name })).on_if(saved),
Item::action("view.delete", "Delete", "delete").with(json!({ "view": name })).on_if(saved),
]
}
@@ -1508,7 +1516,7 @@ pub fn canvas_items(app: &SolveApp, id: u64) -> Vec<Item> {
Item::action("ui.calibrateCanvas", "Calibrate", "measure").with(json!({ "canvas": id })),
Item::sep(),
Item::action("ui.delete", "Delete", "delete").with(json!({ "canvases": [id] })),
- Item::action("ui.rename", "Rename", "").with(json!({ "canvas": id })),
+ Item::action("ui.rename", "Rename", "rename").with(json!({ "canvas": id })),
Item::sep(),
Item::action("ui.canvasVisible", "Show/Hide", "eye").key("V").with(json!({ "canvas": id, "visible": !visible })),
]
@@ -2340,9 +2348,12 @@ pub fn dims_overlay(app: &SolveApp, ctx: &egui::Context) {
}
}
-/// Where the browser's panels open: the viewport's top left corner.
+/// Keep browser panels beside the browser and below the ribbon, including the floating shell.
fn panel_pos(app: &SolveApp) -> Pos2 {
- app.viewport.rect.map(|r| crate::shell::content_rect(app, r).left_top() + vec2(16.0, 16.0)).unwrap_or(pos2(270.0, 140.0))
+ app.viewport
+ .rect
+ .map(|r| crate::shell::content_rect(app, r).left_top() + vec2(Tokens::get().space_16, Tokens::get().space_16))
+ .unwrap_or(pos2(270.0, 140.0))
}
/// The Capture Position question stands for saving.
diff --git a/crates/ui-egui/src/browser_card_tests.rs b/crates/ui-egui/src/browser_card_tests.rs
index 6f3308687a..2ca4bd7b94 100644
--- a/crates/ui-egui/src/browser_card_tests.rs
+++ b/crates/ui-egui/src/browser_card_tests.rs
@@ -47,7 +47,7 @@ fn browser_card_shrinks_and_scrolls_without_covering_history() {
fn selected_row_paints_tab_soft_fill_and_accent_text_in_both_layouts() {
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
for tab in ["MODEL", "SURFACE", "SKETCH"] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(Default::default(), Default::default());
app.ui.layout = mode;
app.ui.tab = tab.into();
@@ -64,7 +64,7 @@ fn selected_row_paints_tab_soft_fill_and_accent_text_in_both_layouts() {
assert!(
out.shapes
.iter()
- .any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Selected body" && t.fallback_color == accent.color))
+ .any(|s| matches!(&s.shape, egui::Shape::Text(t) if t.galley.text() == "Selected body" && t.fallback_color == crate::theme::selected_ink(&Tokens::get(), accent.color)))
);
}
}
@@ -167,3 +167,72 @@ fn one_browser_keeps_its_resized_width_across_layouts_and_overlay_preferences()
}
}
}
+#[test]
+fn browser_title_uses_a_single_semibold_run() {
+ let ctx = crate::fonts::test_context();
+ let mut app = SolveApp::new(Default::default(), Default::default());
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ ui.set_width(250.0);
+ browser_header(&mut app, ui, true);
+ });
+ output.textures_delta.clear();
+ let title = crate::i18n::tr("ui.browser_title");
+ let titles: Vec<_> = output
+ .shapes
+ .iter()
+ .filter_map(|s| match &s.shape {
+ egui::Shape::Text(text) if text.galley.text() == title => Some(text),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(titles.len(), 1);
+ assert_eq!(titles[0].galley.job.sections[0].format.font_id, crate::fonts::semibold(Tokens::get().font_heading));
+}
+
+#[test]
+fn resizing_browser_card_and_column_persists_width_including_floating_preference() {
+ for (mode, float, left_history) in [
+ (LayoutMode::Floating, false, false),
+ (LayoutMode::Docked, false, false),
+ (LayoutMode::Docked, true, false),
+ (LayoutMode::Floating, true, true),
+ (LayoutMode::Docked, true, true),
+ ] {
+ let mut h = Harness::new();
+ h.app.ui.layout = mode;
+ h.app.preferences.browser_float = float;
+ h.app.preferences.timeline_left = left_history;
+ h.call("ui.resize", json!({"width":1400,"height":900}));
+ h.settle();
+ let before = h.app.viewport.rect.unwrap();
+ let at = handle_at("left-browser-rail").unwrap();
+ h.call("ui.drag", json!({"x0":at.x,"y0":at.y,"x1":at.x+80.0,"y1":at.y,"steps":8}));
+ h.settle();
+ let width = h.app.preferences.browser_width;
+ assert!(width > crate::prefs::DEFAULT_BROWSER_WIDTH + 40.0, "{mode:?}, float={float}, width={width}");
+ if mode == LayoutMode::Floating || float {
+ assert!((rect_of("browser:card").unwrap().width() - width).abs() < 1.0);
+ assert_eq!(h.app.viewport.rect.unwrap(), before, "the card leaves the projection intact");
+ } else {
+ assert!((h.app.viewport.rect.unwrap().left() - width).abs() < 1.0);
+ }
+ let mut restored = SolveApp::new(Default::default(), Default::default());
+ restored.load_prefs(&h.app.prefs());
+ assert_eq!(restored.preferences.browser_width, width);
+ assert_eq!(restored.preferences.browser_float, float);
+ }
+}
+
+#[test]
+fn browser_width_rejects_hostile_preferences_and_tiny_windows_still_fit() {
+ for width in [f32::NAN, f32::INFINITY, f32::NEG_INFINITY] {
+ assert_eq!(browser_width(width), crate::prefs::DEFAULT_BROWSER_WIDTH);
+ }
+ assert_eq!(browser_width(-100.0), MIN_BROWSER_WIDTH);
+ assert_eq!(browser_width(f32::MAX), MAX_BROWSER_WIDTH);
+ let available = Rect::from_min_size(Pos2::ZERO, vec2(100.0, 300.0));
+ for top_gap in [0.0, crate::shell::SHELL_GAP] {
+ let bounds = floating_bounds(available, None, MAX_BROWSER_WIDTH, top_gap);
+ assert!(available.contains_rect(bounds));
+ }
+}
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 6a96c74aed..960c6c491c 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -571,7 +571,7 @@ fn value_box(ui: &mut egui::Ui, label: &str, value: &mut String, at: Pos2, selec
crate::frame::area(egui::Id::new("sc_canvas_area")).fixed_pos(at).order(egui::Order::Foreground).show(ui.ctx(), |ui| {
egui::Frame::popup(ui.style()).inner_margin(egui::Margin::symmetric(6, 3)).show(ui, |ui| {
ui.horizontal(|ui| {
- ui.label(egui::RichText::new(crate::i18n::tr_label(label)).color(t.text_dim).size(11.5));
+ ui.label(egui::RichText::new(crate::i18n::tr_label(label)).color(t.text_dim).size(crate::theme::Tokens::get().font_caption));
let r = ui.add(egui::TextEdit::singleline(value).id(id).desired_width(72.0));
crate::params_dialog::complete(ui, &r, value);
if select_all {
@@ -889,7 +889,7 @@ fn measure_line(app: &SolveApp, painter: &egui::Painter, proj: &Proj, r: &serde_
painter.circle(s, 3.5, t.manipulator, Stroke::new(1.0, Color32::WHITE));
}
let mid = sa + (sb - sa) * 0.5 + vec2(10.0, -14.0);
- let galley = painter.layout_no_wrap(crate::prefs::show_mm(app, d, 1), egui::FontId::proportional(12.5), t.text);
+ let galley = painter.layout_no_wrap(crate::prefs::show_mm(app, d, 1), egui::FontId::proportional(crate::theme::Tokens::get().font_label), t.text);
let rect = egui::Rect::from_min_size(mid, galley.size() + vec2(10.0, 6.0));
crate::scenario::publish_handle("measure:label", rect.center());
crate::scenario::publish_rect("measure:label", rect);
@@ -931,7 +931,7 @@ fn measure_components(app: &SolveApp, painter: &egui::Painter, proj: &Proj, a: V
(total.center(), vec2(20.0, 20.0))
};
let text = format!("{}: {}", axis.to_uppercase(), crate::prefs::show_mm(app, distance, 1));
- let galley = painter.layout_no_wrap(text, egui::FontId::proportional(12.5), t.text);
+ let galley = painter.layout_no_wrap(text, egui::FontId::proportional(crate::theme::Tokens::get().font_label), t.text);
let size = galley.size() + vec2(10.0, 6.0);
let bounds = proj.rect.shrink(4.0);
let clamp = |rect: egui::Rect| {
diff --git a/crates/ui-egui/src/colour_tokens_tests.rs b/crates/ui-egui/src/colour_tokens_tests.rs
index 82a1b7d741..8239e23308 100644
--- a/crates/ui-egui/src/colour_tokens_tests.rs
+++ b/crates/ui-egui/src/colour_tokens_tests.rs
@@ -121,23 +121,30 @@ fn colours_outside_the_theme_are_only_the_listed_neutral_ones() {
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let dirs = [root.join("src"), root.join("../../assets/icons/ui/source")];
let mut found = Vec::new();
- for dir in &dirs {
- let entries = std::fs::read_dir(dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display()));
- for entry in entries.flatten() {
- let path = entry.path();
- let name = path.file_name().and_then(|n| n.to_str()).unwrap_or_default().to_string();
- if !name.ends_with(".rs") || name.ends_with("_tests.rs") || name == "theme.rs" {
+ fn scan(dir: &std::path::Path, prefix: &str, found: &mut Vec<String>) {
+ for entry in std::fs::read_dir(dir).unwrap() {
+ let path = entry.unwrap().path();
+ let name = path.file_name().unwrap().to_str().unwrap();
+ let relative = format!("{prefix}{name}");
+ if path.is_dir() {
+ scan(&path, &format!("{relative}/"), found);
+ continue;
+ }
+ if !name.ends_with(".rs") || name.ends_with("_tests.rs") || matches!(name, "theme.rs" | "gallery.rs" | "test_support.rs") {
continue;
}
- let src = std::fs::read_to_string(&path).unwrap_or_default();
+ let src = std::fs::read_to_string(&path).unwrap();
let code = src.split("#[cfg(test)]").next().unwrap_or(&src);
let n: usize = COLOUR_LITERALS.iter().map(|p| code.matches(p).count()).sum();
- let allowed = ALLOWED_LITERALS.iter().find(|(f, _, _)| *f == name).map_or(0, |(_, n, _)| *n);
+ let allowed = ALLOWED_LITERALS.iter().find(|(f, _, _)| *f == relative).map_or(0, |(_, n, _)| *n);
if n > allowed {
- found.push(format!("{name}: {n} colour literal(s), at most {allowed} allowed"));
+ found.push(format!("{relative}: {n} colour literal(s), at most {allowed} allowed"));
}
}
}
+ for dir in &dirs {
+ scan(dir, "", &mut found);
+ }
assert!(found.is_empty(), "colour literals outside theme::Tokens: {found:?}");
}
diff --git a/crates/ui-egui/src/colour_vision_tests.rs b/crates/ui-egui/src/colour_vision_tests.rs
index 4e028c73bb..0a01ec3e22 100644
--- a/crates/ui-egui/src/colour_vision_tests.rs
+++ b/crates/ui-egui/src/colour_vision_tests.rs
@@ -399,11 +399,48 @@ const NO_MEANING: &[(&str, &str)] = &[
("font_label", "layout dimension"),
("font_button", "layout dimension"),
("font_heading", "layout dimension"),
+ ("font_triad", "layout dimension"),
+ ("font_compass", "layout dimension"),
+ ("font_subtitle", "layout dimension"),
+ ("font_intro", "layout dimension"),
+ ("font_article_heading", "layout dimension"),
+ ("font_title", "layout dimension"),
+ ("font_display", "layout dimension"),
+ ("control_height", "layout dimension"),
+ ("control_radius", "layout dimension"),
+ ("form_label_width", "layout dimension"),
+ ("form_gap_y", "layout dimension"),
+ ("form_footer_height", "layout dimension"),
+ ("form_header_height", "layout dimension"),
+ ("form_card_width", "layout dimension"),
+ ("form_icon_size", "layout dimension"),
+ ("form_close_size", "layout dimension"),
+ ("form_inset", "layout dimension"),
+ ("form_icon_inset", "layout dimension"),
+ ("form_section_icon_size", "layout dimension"),
+ ("form_checkbox_height", "layout dimension"),
+ ("form_button_height", "layout dimension"),
+ ("sketch_palette_width", "layout dimension"),
+ ("sketch_mode_size", "layout dimension"),
+ ("sketch_mode_radius", "layout dimension"),
+ ("sketch_mode_border", "layout dimension"),
+ ("sketch_palette_alpha", "neutral panel opacity"),
+ ("sketch_mode_tint", "selected background tint of the measured sketch accent"),
+ ("sketch_footer_icon_size", "layout dimension"),
+ ("font_section_tracking", "layout dimension"),
("on_accent", "ink on an accent fill"),
("app_bar_hover_subtle", "translucent hover chrome"),
("app_bar_hover_button", "translucent hover chrome"),
("app_bar_hover_strong", "translucent hover chrome"),
("app_bar_tab_active", "the active document tab's surface"),
+ ("dialog_body", "dense dialog surface"),
+ ("dialog_footer", "dense dialog footer band"),
+ ("dialog_rule", "dense dialog divider"),
+ ("control_fill", "input control fill"),
+ ("control_border", "input control border"),
+ ("dialog_label", "dense dialog field label"),
+ ("selected_ink", "foreground of selected elements"),
+ ("selected_bg", "background of selected elements"),
("render_accent", "the Render workspace's identity colour"),
// The window's chrome: grounds, text and borders (measured as grounds where meaning sits on them).
("panel_header", "chrome"),
@@ -678,7 +715,7 @@ fn each_mode_changes_only_its_table() {
];
let mut red_green_light =
red_green_both.into_iter().filter(|name| !["surface_accent", "mesh_accent", "form_accent"].contains(name)).collect::<Vec<_>>();
- red_green_light.extend(["sketch_projected", "sketch_locked", "timeline_item_error", "construction_geom"]);
+ red_green_light.extend(["sketch_projected", "sketch_locked", "timeline_item_error", "construction_geom", "glyph_text"]);
for (dark, mode, want) in [
(false, ColorVision::Protan, set(&red_green_light)),
(true, ColorVision::Protan, set(&red_green_both)),
@@ -695,6 +732,7 @@ fn each_mode_changes_only_its_table() {
"sketch_locked",
"box_crossing",
"construction_geom",
+ "glyph_text",
"preview_sketch",
"analysis.hatch",
]),
diff --git a/crates/ui-egui/src/configuration_rules_ui.rs b/crates/ui-egui/src/configuration_rules_ui.rs
index e88ec83790..f3c1361221 100644
--- a/crates/ui-egui/src/configuration_rules_ui.rs
+++ b/crates/ui-egui/src/configuration_rules_ui.rs
@@ -1,5 +1,6 @@
//! Structured configuration rule editing and non-mutating row preview.
use crate::SolveApp;
+use crate::fonts::RichTextExt as _;
use egui::{RichText, Ui};
use serde_json::{Value, json};
use solidcraft_engine::doc::config::{Column, ConfigRule, RuleCondition, RuleEffect, RuleOperator};
@@ -58,7 +59,7 @@ pub(super) fn show(ui: &mut Ui, app: &mut SolveApp, error: &mut Option<String>,
let suppression_features: Vec<(u64, String)> =
features.iter().filter(|(id, _)| app.session.doc.configs.columns.contains(&Column::Suppress(*id))).cloned().collect();
ui.separator();
- ui.label(RichText::new(crate::i18n::tr_label("Configuration rules")).strong());
+ ui.label(RichText::new(crate::i18n::tr_label("Configuration rules")).semibold().color(crate::theme::Tokens::get().text));
ui.add(egui::Label::new("Rules run from top to bottom. Matched drives change effective values.").wrap());
ui.add(egui::Label::new("Matched restrictions check the final values.").wrap());
for (index, rule) in rules.iter().enumerate() {
diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs
index cd6bcc6fad..702889563b 100644
--- a/crates/ui-egui/src/context_menu.rs
+++ b/crates/ui-egui/src/context_menu.rs
@@ -11,6 +11,7 @@
//! state; [`items`] lists them and [`run_item`] runs one, so the control channel (`ui.menu`,
//! `ui.menuPick`) and tests reach everything a click does.
+use crate::fonts::RichTextExt as _;
use egui::{Align2, Color32, FontId, Pos2, Rect, Sense, Stroke, Vec2, pos2, vec2};
use serde::Serialize;
use serde_json::{Value, json};
@@ -425,7 +426,7 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
}
// Everything under the cursor, for what lies beneath something else.
if app.menu.over_geometry {
- v.push(act("ui.selectOther", "Select Other…", "").key("Hold click"));
+ v.push(act("ui.selectOther", "Select Other…", "select").key("Hold click"));
v.push(Item::sep());
}
if app.session.active_sketch.is_some() {
@@ -457,7 +458,7 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
v.push(cmd(app, "solid.extrude", "Extrude"));
v.push(cmd(app, "construct.plane.offset", "Offset Plane"));
v.push(cmd(app, "solid.shell", "Shell"));
- v.push(act("ui.editFeature", "Edit Feature", "").with(json!({ "feature": feature })).on(feature.is_some()));
+ v.push(act("ui.editFeature", "Edit Feature", "edit").with(json!({ "feature": feature })).on(feature.is_some()));
v.push(act("ui.editSketch", "Edit Profile Sketch", "sketch").with(json!({ "sketch": sketch })).on(sketch.is_some()));
v.push(Item::sep());
v.push(act("ui.appearance", "Appearance", "appearance").key("A"));
@@ -467,8 +468,8 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
v.push(act("ui.delete", "Delete", "delete").key("Del"));
v.push(act(if hidden { "ui.show" } else { "ui.hide" }, "Show/Hide", "eye").key("V").with(json!({ "bodies": [face] })));
v.push(Item::sep());
- v.push(act("ui.findBrowser", "Find in Browser", "").with(json!({ "body": face, "feature": feature })).on(feature.is_some()));
- v.push(act("ui.findTimeline", "Find in Timeline", "").with(json!({ "feature": feature })).on(feature.is_some()));
+ v.push(act("ui.findBrowser", "Find in Browser", "list").with(json!({ "body": face, "feature": feature })).on(feature.is_some()));
+ v.push(act("ui.findTimeline", "Find in Timeline", "rollback").with(json!({ "feature": feature })).on(feature.is_some()));
v.push(Item::sep());
v.push(cmd(app, "solid.press_pull", "Press Pull"));
v.push(cmd(app, "inspect.measure", "Measure"));
@@ -481,10 +482,10 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
v.push(act("ui.delete", "Delete", "delete").key("Del"));
v.push(act(if hidden { "ui.show" } else { "ui.hide" }, "Show/Hide", "eye").key("V").with(json!({ "bodies": [body] })));
v.push(Item::sep());
- v.push(act("ui.findBrowser", "Find in Browser", "").with(json!({ "body": body })));
+ v.push(act("ui.findBrowser", "Find in Browser", "list").with(json!({ "body": body })));
v.push(act("ui.saveMesh", "Save As Mesh", "export").with(json!({ "bodies": [body] })));
v.push(Item::sep());
- v.push(act("ui.tangentChain", "Select Tangent Chain", ""));
+ v.push(act("ui.tangentChain", "Select Tangent Chain", "chain"));
v.push(cmd(app, "inspect.measure", "Measure"));
} else if has(|s| matches!(s, Sel::Body { .. })) {
v.extend(body_items(app, &sel_bodies(app), false));
@@ -507,7 +508,7 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
|| !app.session.visibility.hidden_sketches.is_empty()
|| !app.session.visibility.hidden_folders.is_empty();
v.push(act("ui.showAll", "Show All", "eye").on(anything_hidden));
- v.push(act("ui.showAll", "Unisolate", "").on(!app.session.visibility.hidden_bodies.is_empty()));
+ v.push(act("ui.showAll", "Unisolate", "eye").on(!app.session.visibility.hidden_bodies.is_empty()));
v.push(Item::sep());
v.push(cmd(app, "solid.extrude", "Extrude"));
v.push(cmd(app, "solid.fillet", "Fillet"));
@@ -528,7 +529,7 @@ fn viewport_items(app: &SolveApp) -> Vec<Item> {
v.push(cmd(app, "parts.resize", "Change Part Size").with(json!({"component":component})));
}
v.push(Item::sep());
- v.push(act("ui.clear", "Clear Selection", "").key("Esc"));
+ v.push(act("ui.clear", "Clear Selection", "close").key("Esc"));
}
v
}
@@ -543,7 +544,7 @@ fn body_items(app: &SolveApp, bodies: &[String], browser: bool) -> Vec<Item> {
act("ui.moveBodies", "Move/Copy", "move").key("M").with(json!({ "bodies": names })).on(!locked),
cmd(app, "component.from_bodies", "Create Components from Bodies").with(json!({ "bodies": names })),
Item::sep(),
- act("ui.material", "Physical Material", "").with(json!({ "bodies": names })),
+ act("ui.material", "Physical Material", "material").with(json!({ "bodies": names })),
act("ui.appearance", "Appearance", "appearance").key("A").with(json!({ "bodies": names })),
act("ui.properties", "Properties", "measure").with(json!({ "bodies": names })),
Item::sep(),
@@ -552,11 +553,11 @@ fn body_items(app: &SolveApp, bodies: &[String], browser: bool) -> Vec<Item> {
Item::sep(),
act("ui.delete", "Delete", "delete").key("Del").with(json!({ "items": items })).on(!locked),
cmd(app, "solid.remove", "Remove").with(json!({ "bodies": names })).on(!locked),
- act("ui.rename", "Rename", "").with(json!({ "body": bodies.first() })).on(one),
+ act("ui.rename", "Rename", "rename").with(json!({ "body": bodies.first() })).on(one),
Item::sep(),
act(if all_hidden { "ui.show" } else { "ui.hide" }, "Show/Hide", "eye").key("V").with(json!({ "bodies": names })),
- act("ui.lock", if locked { "Unlock" } else { "Lock" }, "").with(json!({ "bodies": names })),
- act("ui.isolate", "Isolate", "").with(json!({ "bodies": names })),
+ act("ui.lock", if locked { "Unlock" } else { "Lock" }, "ground").with(json!({ "bodies": names })),
+ act("ui.isolate", "Isolate", "body").with(json!({ "bodies": names })),
];
if one {
let b = bodies.first().cloned().unwrap_or_default();
@@ -565,9 +566,9 @@ fn body_items(app: &SolveApp, bodies: &[String], browser: bool) -> Vec<Item> {
}
v.push(Item::sep());
if !browser {
- v.push(act("ui.findBrowser", "Find in Browser", "").with(json!({ "body": b })));
+ v.push(act("ui.findBrowser", "Find in Browser", "list").with(json!({ "body": b })));
}
- v.push(act("ui.findTimeline", "Find in Timeline", "").with(json!({ "body": b })));
+ v.push(act("ui.findTimeline", "Find in Timeline", "rollback").with(json!({ "body": b })));
}
v
}
@@ -586,14 +587,14 @@ fn sketch_items(app: &SolveApp, id: u64) -> Vec<Item> {
act("ui.exportDxf", "Export DXF…", "export").with(json!({ "sketch": id })),
Item::sep(),
act("ui.delete", "Delete", "delete").key("Del").with(json!({ "items": [{"type": "feature", "id": id}] })),
- act("ui.rename", "Rename", "").with(json!({ "feature": id })),
+ act("ui.rename", "Rename", "rename").with(json!({ "feature": id })),
Item::sep(),
- act("ui.lookAt", "Look At", "").with(json!({ "sketch": id })),
- act("ui.sketchProfile", if profiles { "Hide Profile" } else { "Show Profile" }, "").with(json!({ "sketch": id })),
+ act("ui.lookAt", "Look At", "lookat").with(json!({ "sketch": id })),
+ act("ui.sketchProfile", if profiles { "Hide Profile" } else { "Show Profile" }, "sketch").with(json!({ "sketch": id })),
act("ui.sketchDims", if dims { "Hide Dimension" } else { "Show Dimension" }, "dimension").with(json!({ "sketch": id })),
act(if visible { "ui.hideSketch" } else { "ui.showSketch" }, "Show/Hide", "eye").key("V").with(json!({ "sketch": id })),
Item::sep(),
- act("ui.findTimeline", "Find in Timeline", "").with(json!({ "feature": id })),
+ act("ui.findTimeline", "Find in Timeline", "rollback").with(json!({ "feature": id })),
]
}
@@ -607,11 +608,11 @@ fn plane_items(app: &SolveApp, id: u64) -> Vec<Item> {
act("ui.editFeature", "Edit Feature", "plane").with(json!({ "feature": id })),
Item::sep(),
act("ui.delete", "Delete", "delete").key("Del").with(json!({ "items": [{"type": "feature", "id": id}] })),
- act("ui.rename", "Rename", "").with(json!({ "feature": id })),
+ act("ui.rename", "Rename", "rename").with(json!({ "feature": id })),
Item::sep(),
act("ui.originPart", "Show/Hide", "eye").key("V").with(json!({ "keys": [f.name], "show": !visible })),
Item::sep(),
- act("ui.findTimeline", "Find in Timeline", "").with(json!({ "feature": id })),
+ act("ui.findTimeline", "Find in Timeline", "rollback").with(json!({ "feature": id })),
]
}
@@ -637,14 +638,14 @@ fn joint_items(app: &SolveApp, id: u64) -> Vec<Item> {
let hidden = !joints.iter().any(|j| app.session.joint_visible(*j));
vec![
act("ui.editJoint", "Edit Joint", "joint").with(json!({ "joint": id })),
- act("ui.editJoint", "Edit Joint Limits", "").with(json!({ "joint": id })).on(!rigid),
- act("ui.driveJoint", "Drive Joint", "").with(json!({ "joint": id })).on(!rigid),
- act("ui.animateJoint", "Animate Joint", "").with(json!({ "joint": id })).on(!rigid && !j.suppressed),
- act("ui.findJoint", "Find in Window", "").with(json!({ "joint": id })),
+ act("ui.editJoint", "Edit Joint Limits", "joint").with(json!({ "joint": id })).on(!rigid),
+ act("ui.driveJoint", "Drive Joint", "drive").with(json!({ "joint": id })).on(!rigid),
+ act("ui.animateJoint", "Animate Joint", "play").with(json!({ "joint": id })).on(!rigid && !j.suppressed),
+ act("ui.findJoint", "Find in Window", "fit").with(json!({ "joint": id })),
cmd(app, "joint.edit", if j.suppressed { "Unsuppress" } else { "Suppress" }).with(json!({ "joint": id, "suppressed": !j.suppressed })),
Item::sep(),
act("ui.delete", "Delete", "delete").key("Del").with(json!({ "joints": [id] })),
- act("ui.rename", "Rename", "").with(json!({ "joint": id })),
+ act("ui.rename", "Rename", "rename").with(json!({ "joint": id })),
Item::sep(),
// Hiding a joint hides only its glyph: it still constrains and moves the parts.
act("browser.visibility", "Show/Hide", "eye").key("V").with(json!({ "joints": joints, "visible": hidden })),
@@ -733,12 +734,12 @@ fn component_items(app: &SolveApp, id: u64) -> Vec<Item> {
}
v.push(cmd(app, "component.create", "New Component").with(json!({ "parent": id })));
if id == 0 {
- v.push(act("ui.copyDesign", "Copy", "").key("Ctrl+C"));
- v.push(act("ui.paste", "Paste", "").key("Ctrl+V").on(crate::edit_clipboard::can_paste(app)));
+ v.push(act("ui.copyDesign", "Copy", "copy").key("Ctrl+C"));
+ v.push(act("ui.paste", "Paste", "paste").key("Ctrl+V").on(crate::edit_clipboard::can_paste(app)));
v.push(cmd(app, "component.from_bodies", "Create Components from Bodies").with(json!({ "bodies": names })).on(!bodies.is_empty()));
}
v.push(Item::sep());
- v.push(act("ui.material", "Physical Material", "").with(json!({ "bodies": names })).on(!bodies.is_empty()));
+ v.push(act("ui.material", "Physical Material", "material").with(json!({ "bodies": names })).on(!bodies.is_empty()));
v.push(
act("ui.appearance", "Appearance", "appearance")
.key("A")
@@ -761,11 +762,11 @@ fn component_items(app: &SolveApp, id: u64) -> Vec<Item> {
v.push(cmd(app, "component.paste_new", "Paste New").with(json!({ "component": id, "translate": [10, 10, 0] })));
v.push(act("ui.delete", "Delete", "delete").key("Del").with(json!({ "occurrences": [occ.map(|o| o.id)] })).on(occ.is_some()));
}
- v.push(act("ui.rename", "Rename", "").with(json!({ "component": id })));
+ v.push(act("ui.rename", "Rename", "rename").with(json!({ "component": id })));
v.push(Item::sep());
v.push(act(if hidden { "ui.show" } else { "ui.hide" }, "Show/Hide", "eye").key("V").with(json!({ "bodies": names })).on(!bodies.is_empty()));
v.push(act("ui.showAll", "Show All Bodies", "eye"));
- v.push(act("ui.isolate", "Isolate", "").with(json!({ "bodies": names })).on(!bodies.is_empty() && id != 0));
+ v.push(act("ui.isolate", "Isolate", "body").with(json!({ "bodies": names })).on(!bodies.is_empty() && id != 0));
v.push(act("ui.newGroup", "New Group", "folder").with(json!({ "component": id })));
v
}
@@ -819,7 +820,7 @@ fn sketch_entity_items(app: &SolveApp) -> Vec<Item> {
v.push(cmd(app, "sketch.circle.center", "Circle"));
v.push(cmd(app, "sketch.dimension", "Sketch Dimension"));
v.push(Item::sep());
- v.push(act("ui.paste", "Paste", "").key("Ctrl+V").on(app.session.sketch_clipboard.is_some()));
+ v.push(act("ui.paste", "Paste", "paste").key("Ctrl+V").on(app.session.sketch_clipboard.is_some()));
return v;
}
let ents: Vec<String> = curves.iter().chain(points.iter()).cloned().collect();
@@ -835,9 +836,9 @@ fn sketch_entity_items(app: &SolveApp) -> Vec<Item> {
v.extend(explode_text(app));
}
v.push(cmd(app, "sketch.move", "Move/Copy").key("M"));
- v.push(act("ui.cut", "Cut", "").key("Ctrl+X"));
- v.push(act("ui.copy", "Copy", "").key("Ctrl+C"));
- v.push(act("ui.paste", "Paste", "").key("Ctrl+V").on(app.session.sketch_clipboard.is_some()));
+ v.push(act("ui.cut", "Cut", "cut").key("Ctrl+X"));
+ v.push(act("ui.copy", "Copy", "copy").key("Ctrl+C"));
+ v.push(act("ui.paste", "Paste", "paste").key("Ctrl+V").on(app.session.sketch_clipboard.is_some()));
if !curves.is_empty() {
v.push(cmd(app, "sketch.construction", "Normal / Construction").with(json!({ "curves": curves })));
}
@@ -1482,12 +1483,23 @@ pub fn describe(app: &SolveApp) -> Value {
return json!({ "open": false, "pending": app.menu.pending.is_some() });
};
let radial = if app.menu.radial { radial_items(app) } else { Vec::new() };
+ let describe_items = |items: Vec<Item>| {
+ items
+ .into_iter()
+ .map(|item| {
+ let placeholder = !item.icon.is_empty() && crate::icon_svg::resolve(&item.icon).placeholder;
+ let mut value = json!(item);
+ value["placeholder"] = json!(placeholder);
+ value
+ })
+ .collect::<Vec<_>>()
+ };
json!({
"open": true,
"at": [at.x, at.y],
"target": app.menu.target,
- "radial": radial,
- "items": items(app, &app.menu.target),
+ "radial": describe_items(radial),
+ "items": describe_items(items(app, &app.menu.target)),
"rename": app.menu.rename.as_ref().map(|r| r.text.clone()),
})
}
@@ -1683,7 +1695,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let resp = crate::frame::area(egui::Id::new("sc_marking_menu")).fixed_pos(area.min).order(egui::Order::Foreground).show(ctx, |ui| {
let (r, _) = ui.allocate_exact_size(area.size(), Sense::hover());
let painter = ui.painter_at(r.expand(4.0));
- let font = FontId::proportional(13.0);
+ let font = FontId::proportional(crate::theme::Tokens::get().font_button);
// Centre: a ring with a pointer toward the hot direction.
let direction = hot.zip(pointer).map(|(k, p)| ((p - c).normalized(), radial.get(k).is_some_and(|i| i.enabled)));
crate::icons::glyphs::radial_centre(&painter, c, direction, t);
@@ -1782,7 +1794,12 @@ fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<usize>, hei
ui.set_width(450.0);
ui.spacing_mut().item_spacing.y = 0.0;
ui.add_space(4.0);
- ui.label(egui::RichText::new(crate::i18n::tr("ui.ribbon_workspace").to_uppercase()).size(11.0).strong().color(t.text_dim));
+ ui.label(
+ egui::RichText::new(crate::i18n::tr("ui.ribbon_workspace").to_uppercase())
+ .size(crate::theme::Tokens::get().font_small)
+ .semibold()
+ .color(t.text_dim),
+ );
ui.add_space(8.0);
egui::ScrollArea::vertical().id_salt("workspace_menu_rows").max_height((height - 116.0).max(60.0)).show(ui, |ui| {
for (k, item) in items.iter().enumerate() {
@@ -1824,16 +1841,13 @@ fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<usize>, hei
let name = crate::i18n::tr_label(&item.label);
let x = r.left() + 74.0;
let y = r.top() + 17.0;
- let galley = egui::WidgetText::from(egui::RichText::new(name).strong().size(14.0).color(text)).into_galley(
- ui,
- Some(egui::TextWrapMode::Extend),
- f32::INFINITY,
- egui::TextStyle::Button,
- );
+ let galley = egui::WidgetText::from(egui::RichText::new(name).semibold().size(crate::theme::Tokens::get().font_heading).color(text))
+ .into_galley(ui, Some(egui::TextWrapMode::Extend), f32::INFINITY, egui::TextStyle::Button);
let badge_x = x + galley.size().x + 9.0;
let origin = pos2(x, y - galley.size().y / 2.0);
- ui.painter().galley(origin - vec2(0.2, 0.0), galley.clone(), text);
- ui.painter().galley(origin + vec2(0.2, 0.0), galley, text);
+ let ppp = ui.ctx().pixels_per_point().max(0.5);
+ let origin = pos2((origin.x * ppp).round() / ppp, (origin.y * ppp).round() / ppp);
+ ui.painter().galley(origin, galley, text);
let badge = crate::i18n::tr(if planned {
"ui.workspace_planned"
} else if current {
@@ -1841,24 +1855,28 @@ fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<usize>, hei
} else {
"ui.workspace_available"
});
- let badge = ui.painter().layout_no_wrap(badge.to_string(), FontId::proportional(11.0), if current { t.on_accent } else { accent });
+ let badge = ui.painter().layout_no_wrap(
+ badge.to_string(),
+ FontId::proportional(crate::theme::Tokens::get().font_small),
+ if current { t.on_accent } else { accent },
+ );
let badge_rect = Rect::from_min_size(pos2(badge_x, y - 8.0), badge.size() + vec2(12.0, 3.0));
ui.painter().rect_filled(badge_rect, 8.0, if current { accent } else { soft });
ui.painter().galley(badge_rect.min + vec2(6.0, 1.5), badge, accent);
- let line = |label: &str, y: f32| {
- let mut job = egui::text::LayoutJob::simple_singleline(label.to_string(), FontId::proportional(12.0), text);
+ let line = |content: String, y: f32| {
+ let mut job =
+ egui::text::LayoutJob::simple_singleline(content, FontId::proportional(crate::theme::Tokens::get().font_body), text);
job.wrap.max_width = r.right() - x - 6.0;
job.wrap.max_rows = 1;
job.wrap.break_anywhere = false;
let galley = ui.painter().layout_job(job);
ui.painter().galley(pos2(x, y), galley, text);
};
- line(crate::i18n::tr(description), r.top() + 29.0);
+ line(crate::i18n::tr(description).to_string(), r.top() + 29.0);
if let Some(tabs) = tabs {
- // Reuse existing tab-name translations when a partial catalog falls back
- // to the English summary; complete catalogs keep their translated summary.
+ // Translate each tab even when this composed message falls back to English.
let labels = crate::i18n::tr(tabs).split('·').map(|label| crate::i18n::tr_label(label.trim())).collect::<Vec<_>>().join(" · ");
- line(&labels, r.top() + 47.0);
+ line(labels, r.top() + 47.0);
}
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, item.enabled, name));
if resp.clicked() && item.enabled {
@@ -1869,7 +1887,12 @@ fn workspace_menu(ui: &mut egui::Ui, items: &[Item], key_row: Option<usize>, hei
ui.add_space(6.0);
ui.separator();
ui.add_space(6.0);
- ui.add(egui::Label::new(egui::RichText::new(crate::i18n::tr("ui.workspace_footer")).size(11.0).color(t.text_dim)).wrap());
+ ui.add(
+ egui::Label::new(
+ egui::RichText::new(crate::i18n::tr("ui.workspace_footer")).size(crate::theme::Tokens::get().font_small).color(t.text_dim),
+ )
+ .wrap(),
+ );
ui.add_space(4.0);
});
picked
@@ -1897,6 +1920,27 @@ pub fn menu_frame<R>(ui: &mut egui::Ui, add: impl FnOnce(&mut egui::Ui) -> R) ->
.inner
}
+/// A compact menu button with an explicit semantic icon, for native egui popup menus.
+pub fn button(ui: &mut egui::Ui, label: &str, icon: &str) -> egui::Response {
+ button_enabled(ui, label, icon, true)
+}
+
+/// The disabled form keeps its icon visible and dims it with the menu row.
+pub fn button_enabled(ui: &mut egui::Ui, label: &str, icon: &str, enabled: bool) -> egui::Response {
+ let response = ui
+ .add_enabled_ui(enabled, |ui| {
+ let icon_id = ui.id().with(("menu_icon", label));
+ let row = egui::Button::new((egui::Atom::custom(icon_id, vec2(16.0, 16.0)), label)).min_size(vec2(180.0, 22.0)).atom_ui(ui);
+ if let Some(rect) = row.rect(icon_id) {
+ icons::paint_icon(ui.painter(), rect, icon, if enabled { 1.0 } else { 0.35 });
+ }
+ row.response
+ })
+ .inner;
+ crate::scenario::publish_handle(&format!("menu:{label}"), response.rect.center());
+ response
+}
+
/// One list row; the item when it was clicked.
pub fn list_row(ui: &mut egui::Ui, item: &Item) -> Option<Item> {
list_row_lit(ui, item, false)
@@ -1912,7 +1956,12 @@ pub fn list_row_lit(ui: &mut egui::Ui, item: &Item, lit: bool) -> Option<Item> {
return None;
}
if item.is_heading() {
- let text = ui.painter().layout(crate::i18n::tr_label(&item.label).to_uppercase(), FontId::proportional(10.5), t.text_dim, w - 16.0);
+ let text = ui.painter().layout(
+ crate::i18n::tr_label(&item.label).to_uppercase(),
+ FontId::proportional(crate::theme::Tokens::get().font_panel),
+ t.text_dim,
+ w - 16.0,
+ );
let (r, _) = ui.allocate_exact_size(vec2(w, (text.size().y + 8.0).max(20.0)), Sense::hover());
ui.painter().galley(pos2(r.left() + 8.0, r.top() + 4.0), text, t.text_dim);
return None;
@@ -1935,10 +1984,23 @@ pub fn list_row_lit(ui: &mut egui::Ui, item: &Item, lit: bool) -> Option<Item> {
}
let text = if item.enabled { t.text } else { t.text_dim.gamma_multiply(0.75) };
let display_label = crate::i18n::tr_label(&item.label);
- ui.painter().text(pos2(r.left() + 32.0, r.center().y), Align2::LEFT_CENTER, display_label, FontId::proportional(13.0), text);
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, item.enabled, display_label));
+ ui.painter().text(
+ pos2(r.left() + 32.0, r.center().y),
+ Align2::LEFT_CENTER,
+ display_label,
+ FontId::proportional(crate::theme::Tokens::get().font_button),
+ text,
+ );
if !item.shortcut.is_empty() {
let display_shortcut = crate::i18n::tr_label(&item.shortcut);
- ui.painter().text(pos2(r.right() - 10.0, r.center().y), Align2::RIGHT_CENTER, display_shortcut, FontId::proportional(11.5), t.text_dim);
+ ui.painter().text(
+ pos2(r.right() - 10.0, r.center().y),
+ Align2::RIGHT_CENTER,
+ display_shortcut,
+ FontId::proportional(crate::theme::Tokens::get().font_caption),
+ t.text_dim,
+ );
}
(item.enabled && resp.clicked()).then(|| item.clone())
}
@@ -1955,7 +2017,7 @@ fn show_rename(app: &mut SolveApp, ctx: &egui::Context) {
let resp = crate::frame::area(egui::Id::new("sc_rename")).fixed_pos(r.at).constrain(true).order(egui::Order::Foreground).show(ctx, |ui| {
menu_frame(ui, |ui| {
ui.add_space(2.0);
- ui.label(egui::RichText::new(crate::i18n::tr_label("Rename")).size(11.0).color(t.text_dim));
+ ui.label(egui::RichText::new(crate::i18n::tr_label("Rename")).size(crate::theme::Tokens::get().font_small).color(t.text_dim));
let te = ui.add(egui::TextEdit::singleline(&mut r.text).desired_width(200.0).id(egui::Id::new("sc_rename_text")));
if !r.focused {
// Start with the whole name selected, ready to type over.
@@ -2085,7 +2147,7 @@ mod tests {
#[test]
fn disabled_radial_menu_does_not_capture_right_button_hold() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let point = pos2(600.0, 400.0);
app.viewport.mouse = Some(point);
for (time, events) in [
@@ -2165,6 +2227,27 @@ mod workspace_menu_tests {
use super::*;
use crate::scenario::{Harness, rect_of};
+ #[test]
+ fn workspace_titles_use_one_semibold_text_run() {
+ let ctx = crate::fonts::test_context();
+ let app = SolveApp::new(Default::default(), Default::default());
+ let list = items(&app, &Target::Workspace);
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ workspace_menu(ui, &list, None, 1000.0);
+ });
+ output.textures_delta.clear();
+ let titles: Vec<_> = output
+ .shapes
+ .iter()
+ .filter_map(|s| match &s.shape {
+ egui::Shape::Text(text) if text.galley.text() == "Design" => Some(text),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(titles.len(), 1, "workspace titles must never be drawn twice");
+ assert_eq!(titles[0].galley.job.sections[0].format.font_id, crate::fonts::semibold(14.0));
+ }
+
#[test]
fn workspace_rows_keep_switching_handles_and_disabled_render_behavior() {
let mut h = Harness::new();
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index f33db5648f..fca297c442 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -24,6 +24,7 @@
//! headless CPU render of the model with the current camera, in the window's theme, with the
//! section the viewport shows (no window needed); the ground grid and the origin's axes as the
//! window shows them, unless `grid` or `axes` says
+//! - `ui.icon_audit {reset?, stop?}`: collect/drain requested icon names, resolved masters and placeholder flags;
//! - `ui.menu {x?, y?, target?, close?}`: open a context menu at a point (the viewport's marking
//! menu, or a browser menu with `target: {type: body|sketch|component, …}`); without a point,
//! the open menu and its items. `ui.menuPick {item}` runs an item by id or label;
@@ -668,6 +669,16 @@ fn dispatch(app: &mut SolveApp, ctx: &egui::Context, method: &str, p: &Value) ->
app.synthetic.push(egui::Event::Text(s("text").unwrap_or("").to_string()));
ok(Value::Null)
}
+ "ui.icon_audit" => {
+ if b("reset") {
+ crate::icon_svg::audit::start();
+ }
+ let requested = crate::icon_svg::audit::take();
+ if b("stop") {
+ crate::icon_svg::audit::stop();
+ }
+ ok(json!({"requested": requested}))
+ }
"ui.menu" => {
if b("close") {
crate::context_menu::close(app);
@@ -957,7 +968,7 @@ mod tests {
#[test]
fn touchpad_text_prefix_does_not_collapse_queued_pointer_frames() {
let mut app = SolveApp::new(Session::default(), Services::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let (req, _) = ControlRequest::new("ui.text", json!({"text":"prefix"}));
assert!(matches!(handle(&mut app, &ctx, &req), Outcome::Done(_)));
for params in [json!({"x":10,"y":10,"shift":true}), json!({"x":20,"y":20,"alt":true}), json!({"x":30,"y":30})] {
@@ -981,7 +992,7 @@ mod tests {
#[test]
fn touchpad_automation_preserves_each_queued_moves_modifiers() {
let mut app = SolveApp::new(Session::default(), Services::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
for params in [json!({"x":10,"y":10,"shift":true}), json!({"x":20,"y":20,"alt":true}), json!({"x":30,"y":30})] {
let (req, _) = ControlRequest::new("ui.move", params);
assert!(matches!(handle(&mut app, &ctx, &req), Outcome::Done(_)));
@@ -1003,7 +1014,7 @@ mod tests {
fn render(app: &mut SolveApp, path: &std::path::Path) -> Vec<u8> {
let (req, _rx) = ControlRequest::new("ui.render", json!({"path": path.to_string_lossy(), "width": 200, "height": 140}));
- match handle(app, &egui::Context::default(), &req) {
+ match handle(app, &crate::fonts::test_context(), &req) {
Outcome::Done(v) => assert_eq!(v["ok"], true, "{v}"),
Outcome::Screenshot { .. } => panic!("ui.render took a screenshot"),
}
@@ -1073,7 +1084,7 @@ mod tests {
params[k.as_str()] = v.clone();
}
let (req, _rx) = ControlRequest::new("ui.render", params);
- match handle(app, &egui::Context::default(), &req) {
+ match handle(app, &crate::fonts::test_context(), &req) {
Outcome::Done(v) => assert_eq!(v["ok"], true, "{v}"),
Outcome::Screenshot { .. } => panic!("ui.render took a screenshot"),
}
@@ -1348,7 +1359,7 @@ mod tests {
params["allow_paths"] = json!([root.to_string_lossy()]);
}
let (req, _rx) = ControlRequest::new(method, params);
- match handle(&mut app, &egui::Context::default(), &req) {
+ match handle(&mut app, &crate::fonts::test_context(), &req) {
Outcome::Done(v) => v,
Outcome::Screenshot { path } => json!({"ok": true, "screenshot": path}),
}
diff --git a/crates/ui-egui/src/crash_ui.rs b/crates/ui-egui/src/crash_ui.rs
index b1194c35bb..75412fefde 100644
--- a/crates/ui-egui/src/crash_ui.rs
+++ b/crates/ui-egui/src/crash_ui.rs
@@ -1,6 +1,7 @@
//! The Crash Reports window (Help > Crash Reports…): the reports `solidcraft_engine::crash`
//! keeps on this computer, each with a reviewed issue draft. It opens by itself after a crash.
+use crate::fonts::RichTextExt as _;
use egui::{RichText, vec2};
use solidcraft_engine::crash::{self, Summary};
@@ -88,7 +89,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
if ui.small_button("Copy folder path").clicked() {
ctx.copy_text(d.clone());
}
- ui.add(egui::Label::new(RichText::new(&d).monospace().size(11.0)).truncate()).on_hover_text(&d);
+ ui.add(egui::Label::new(RichText::new(&d).monospace().size(crate::theme::Tokens::get().font_small)).truncate()).on_hover_text(&d);
});
}
ui.separator();
@@ -98,14 +99,14 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {
for r in &app.crashes.reports {
ui.horizontal(|ui| {
- ui.label(RichText::new(report_heading(r)).strong());
+ ui.label(RichText::new(report_heading(r)).semibold().color(crate::theme::Tokens::get().text));
if let Some(c) = &r.command {
- ui.label(RichText::new(c).monospace().size(11.0).color(t.text_dim));
+ ui.label(RichText::new(c).monospace().size(crate::theme::Tokens::get().font_small).color(t.text_dim));
}
});
- ui.label(RichText::new(&r.message).size(12.0));
+ ui.label(RichText::new(&r.message).size(t.font_body));
if r.kind == "unclean_exit" {
- ui.label(RichText::new(crate::i18n::tr("crash.unclean_explanation")).size(12.0).color(t.text_dim));
+ ui.label(RichText::new(crate::i18n::tr("crash.unclean_explanation")).size(t.font_body).color(t.text_dim));
}
ui.horizontal(|ui| {
if ui.small_button("Report…").clicked() {
@@ -118,7 +119,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
delete = Some(Some(r.id.clone()));
}
if r.replayable {
- ui.label(RichText::new("replayable").size(11.0).color(t.text_dim));
+ ui.label(RichText::new("replayable").size(crate::theme::Tokens::get().font_small).color(t.text_dim));
}
});
ui.add_space(6.0);
diff --git a/crates/ui-egui/src/design_properties.rs b/crates/ui-egui/src/design_properties.rs
index 7a5503205e..1a20dacf6c 100644
--- a/crates/ui-egui/src/design_properties.rs
+++ b/crates/ui-egui/src/design_properties.rs
@@ -5,6 +5,7 @@
//! Document Settings, the root component's menu and `ui.start` of `document.metadata` or
//! `document.metadata.set` open it.
+use crate::fonts::RichTextExt as _;
use egui::RichText;
use serde_json::{Map, Value};
use solidcraft_engine::doc::metadata::{DESCRIPTION, WELL_KNOWN};
@@ -89,7 +90,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let mut open = true;
let (mut ok, mut cancel) = (false, false);
let metadata = app.session.doc.metadata.clone();
- let title = RichText::new(crate::i18n::tr_label("Design Properties")).strong().size(13.0);
+ let title = RichText::new(crate::i18n::tr_label("Design Properties"))
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_button);
crate::frame::window(ctx, title, crate::frame::Width::Normal)
.id(egui::Id::new("sc_design_properties"))
.open(&mut open)
@@ -123,7 +127,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
ui.label(RichText::new(crate::i18n::tr("ui.design_properties.others_note")).small().color(t.text_dim));
egui::ScrollArea::vertical().max_height(160.0).show(ui, |ui| {
for (k, v) in others {
- ui.label(RichText::new(k).monospace().size(12.0).color(t.text));
+ ui.label(RichText::new(k).monospace().size(crate::theme::Tokens::get().font_body).color(t.text));
ui.label(RichText::new(preview(v)).monospace().small().color(t.text_dim));
}
});
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 5a06ffd634..2b5ce075bf 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -2,6 +2,7 @@
//! inputs (geometry picked in the viewport, never typed), then runs its command; it never
//! changes the design itself. Things selected before the command starts become its input.
+use crate::fonts::RichTextExt as _;
use std::hash::{Hash, Hasher};
use egui::{Color32, RichText, Stroke, vec2};
@@ -18,6 +19,9 @@ use crate::theme::Tokens;
use crate::tool_modifiers::{Audit, Scope, ToolModifiers};
use crate::viewport::Hit;
+#[path = "dialogs_dense.rs"]
+mod dense;
+
const SELECT_ONLY: &[Scope] = &[Scope::Selection, Scope::FeaturePreview];
const SELECT_MANIP: &[Scope] = &[Scope::Selection, Scope::Manipulator, Scope::FeaturePreview];
@@ -402,6 +406,10 @@ pub struct Dialog {
pub focus: bool,
/// Folded to its header (the "−" glyph).
pub collapsed: bool,
+ /// Transient display preference; never part of a command or a saved feature.
+ pub preview_enabled: bool,
+ /// Preserve Apply intent across asynchronous evaluation; never a command parameter.
+ repeat_after_apply: bool,
/// Parameters the dialog doesn't show but the command needs (kept when editing).
pub extra: serde_json::Map<String, Value>,
/// What the inputs were when OK was refused: `error` stays only while they still are.
@@ -527,6 +535,8 @@ impl Dialog {
profile_selection_changed: false,
focus: true,
collapsed: false,
+ preview_enabled: true,
+ repeat_after_apply: false,
extra: serde_json::Map::new(),
refused: None,
then_start: None,
@@ -962,7 +972,7 @@ impl Dialog {
/// Dialogs holding a table get the wide limit.
pub fn is_wide(&self) -> bool {
- matches!(self.kind, Kind::Params { .. } | Kind::SketchModify(crate::sketch_modify_ui::Mod::PatternRect { .. }))
+ matches!(self.kind, Kind::Params { .. })
|| (matches!(self.kind, Kind::PatternRect { .. }) && self.inputs.first().is_some_and(|i| i.accept == selection::FEATURES))
|| matches!(&self.kind, Kind::Motion(k) if k.wide())
}
@@ -1542,6 +1552,9 @@ fn plane_value(s: &Session, sel: Option<&Sel>) -> Option<Value> {
/// A value field; true when Enter was pressed in it.
pub(crate) fn field(ui: &mut egui::Ui, s: &mut String) -> bool {
+ if crate::ui_kit::contains(ui) {
+ return crate::ui_kit::field(ui, s);
+ }
let r = ui.text_edit_singleline(s);
crate::theme::TabAccent::number_focus(ui, &r);
publish_row(&r);
@@ -1552,11 +1565,15 @@ pub(crate) fn field(ui: &mut egui::Ui, s: &mut String) -> bool {
/// A checkbox row. Its row handle (`dialog:<row label>`) lets a scenario click it by the label
/// beside it, the way `field` already publishes one for a value field.
pub(crate) fn check(ui: &mut egui::Ui, on: &mut bool) {
- let r = ui.checkbox(on, "");
- publish_row(&r);
+ let r = if crate::ui_kit::contains(ui) { crate::ui_kit::checkbox(ui, "", on) } else { ui.checkbox(on, "") };
+ publish_check(ui, &r, *on);
}
pub(crate) fn combo(ui: &mut egui::Ui, id: &str, labels: &[&str], sel: &mut usize) {
+ if crate::ui_kit::contains(ui) {
+ crate::ui_kit::dropdown(ui, id, sel, labels);
+ return;
+ }
let row = ROW.with(|r| r.borrow().clone());
let selected = labels.get(*sel).copied().map(tr).unwrap_or("");
let r = egui::ComboBox::from_id_salt(id).selected_text(selected).width(FIELD_W).show_ui(ui, |ui| {
@@ -1568,39 +1585,6 @@ pub(crate) fn combo(ui: &mut egui::Ui, id: &str, labels: &[&str], sel: &mut usiz
publish_row(&r.response);
}
-/// A mode choice as a row of icon buttons rather than a drop-down: every mode is on screen at
-/// once, each drawn as the shape it makes, with its name as the tooltip. `labels` and `icons`
-/// run in step; a mode with no icon gets the fallback square. Publishes the handles a combo
-/// does, `dialog:<row label>:<label>` per mode and `dialog:<row label>` for the row.
-pub(crate) fn icon_choice(ui: &mut egui::Ui, labels: &[&str], icons: &[&str], sel: &mut usize) {
- let t = Tokens::get();
- let row = ROW.with(|r| r.borrow().clone());
- let mut at = None;
- ui.horizontal(|ui| {
- for (i, label) in labels.iter().enumerate() {
- let on = *sel == i;
- let (r, resp) = ui.allocate_exact_size(vec2(28.0, 24.0), egui::Sense::click());
- if on {
- ui.painter().rect_filled(r, 4.0, t.accent);
- } else if resp.hovered() {
- ui.painter().rect_filled(r, 4.0, t.hover);
- }
- let ink = if on { t.on_accent } else { t.icon };
- crate::icons::paint(ui.painter(), r.shrink(3.0), icons.get(i).copied().unwrap_or(""), ink, t.icon_fill, ink);
- crate::scenario::publish_handle(&format!("dialog:{row}:{label}"), r.center());
- if on {
- at = Some(r.center());
- }
- if resp.on_hover_text(tr(label)).clicked() {
- *sel = i;
- }
- }
- });
- if let Some(p) = at {
- crate::scenario::publish_handle(&format!("dialog:{row}"), p);
- }
-}
-
thread_local! {
/// The label of the dialog row being laid out (its widgets publish `dialog:<label>` handles).
static ROW: std::cell::RefCell<String> = const { std::cell::RefCell::new(String::new()) };
@@ -1610,6 +1594,13 @@ fn tr(text: &str) -> &str {
crate::i18n::tr_label(text)
}
+fn publish_check(ui: &egui::Ui, response: &egui::Response, selected: bool) {
+ if crate::ui_kit::contains(ui) {
+ ROW.with(|row| response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), selected, tr(&row.borrow()))));
+ }
+ publish_row(response);
+}
+
/// A dialog row's widget, for scenarios and demos: the handle `dialog:<row label>`.
pub(crate) fn publish_row(r: &egui::Response) {
ROW.with(|row| crate::scenario::publish_handle(&format!("dialog:{}", row.borrow()), r.rect.center()));
@@ -1709,6 +1700,18 @@ const LABEL_W: f32 = 92.0;
/// The label column grows to fit its labels up to this, then long labels wrap.
const LABEL_MAX_W: f32 = 150.0;
+pub(crate) fn form_row<R>(ui: &mut egui::Ui, label: &str, add: impl FnOnce(&mut egui::Ui) -> R) -> R {
+ ROW.with(|row| *row.borrow_mut() = label.to_string());
+ if crate::ui_kit::contains(ui) {
+ crate::ui_kit::row(ui, label, add)
+ } else {
+ row_label(ui, label);
+ let result = add(ui);
+ ui.end_row();
+ result
+ }
+}
+
/// A row label in the dialog's label column (the grid sizes the column to its widest label).
pub(crate) fn row_label(ui: &mut egui::Ui, text: &str) {
ROW.with(|r| *r.borrow_mut() = text.to_string());
@@ -1795,11 +1798,11 @@ fn is_pattern(k: &Kind) -> bool {
/// timeline, e.g. a hole).
fn object_type_row(d: &mut Dialog, ui: &mut egui::Ui) {
let Some(inp) = d.inputs.first_mut() else { return };
- row_label(ui, "Object Type");
let cur = usize::from(inp.accept == selection::FEATURES);
let mut ty = cur;
- combo(ui, "pat_obj", &["Bodies", "Features"], &mut ty);
- ui.end_row();
+ form_row(ui, "Object Type", |ui| {
+ combo(ui, "pat_obj", &["Bodies", "Features"], &mut ty);
+ });
if ty != cur {
inp.accept = if ty == 1 { selection::FEATURES } else { BODIES };
inp.label = objects_label(inp.accept);
@@ -1826,10 +1829,10 @@ fn placement_row(d: &mut Dialog, ui: &mut egui::Ui) {
_ => None,
};
if let Some(cur) = current {
- row_label(ui, "Type");
let mut ty = cur;
- combo(ui, "pat_type", &["Rectangular", "Circular", "Path"], &mut ty);
- ui.end_row();
+ form_row(ui, "Type", |ui| {
+ combo(ui, "pat_type", &["Rectangular", "Circular", "Path"], &mut ty);
+ });
if ty != cur {
// Same objects, the new pattern's other inputs.
let objects = d.inputs.first().map(|i| i.items.clone()).unwrap_or_default();
@@ -1866,10 +1869,10 @@ fn placement_row(d: &mut Dialog, ui: &mut egui::Ui) {
return;
}
let Kind::Hole { opts, .. } = &mut d.kind else { return };
- row_label(ui, "Placement");
let mut m = usize::from(opts.multiple);
- combo(ui, "hole_place", &["Single", "Multiple"], &mut m);
- ui.end_row();
+ form_row(ui, "Placement", |ui| {
+ combo(ui, "hole_place", &["Single", "Multiple"], &mut m);
+ });
if (m == 1) != opts.multiple {
opts.multiple = m == 1;
d.inputs = vec![if opts.multiple { SelInput::new("Points", selection::POINTS, true) } else { SelInput::new("Face", HOLE_FACES, true) }];
@@ -1914,6 +1917,13 @@ fn feature_pattern_reference_key(d: &Dialog, index: usize) -> Option<&'static st
}
}
+fn stored_revolve_axis(kind: &Kind) -> Option<&Value> {
+ match kind {
+ Kind::Revolve { axis, .. } | Kind::Surface(crate::dialogs_surface::Surf::Revolve { axis, .. }) => axis.as_ref(),
+ _ => None,
+ }
+}
+
fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, range: std::ops::Range<usize>) {
// Edit Text shows its Path input among its own rows.
if matches!(d.kind, Kind::Text(_)) {
@@ -1922,63 +1932,93 @@ fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, range: std::
let t = Tokens::get();
let mut clear: Option<usize> = None;
let mut activate: Option<usize> = None;
+ let mut remove = None;
for (i, inp) in d.inputs.iter().enumerate().skip(range.start).take(range.end.saturating_sub(range.start)) {
let stored_reference = feature_pattern_reference_key(d, i).and_then(|key| d.extra.get(key)).filter(|_| inp.items.is_empty());
- row_label(ui, inp.label);
- ui.horizontal(|ui| {
- let active = i == d.active;
- // A chip: "↖ Select" (outlined) while empty, "N selected" (filled) once picked.
- let custom_axis = i == 1 && inp.items.is_empty() && matches!(d.kind, Kind::Revolve { axis: Some(_), .. });
- let filled = !inp.items.is_empty() || custom_axis || stored_reference.is_some();
- let text = if filled {
- RichText::new(if custom_axis || stored_reference.is_some() {
- crate::i18n::tr("dialog.custom_axis").into()
- } else if !inp.multi {
- inp.items.first().map(|item| selection_label(s, item)).unwrap_or_default()
+ form_row(ui, inp.label, |ui| {
+ ui.horizontal(|ui| {
+ let active = i == d.active;
+ // A chip: "↖ Select" (outlined) while empty, "N selected" (filled) once picked.
+ let custom_axis = i == 1 && inp.items.is_empty() && stored_revolve_axis(&d.kind).is_some();
+ let filled = !inp.items.is_empty() || custom_axis || stored_reference.is_some();
+ let text = if filled {
+ RichText::new(if custom_axis || stored_reference.is_some() {
+ crate::i18n::tr("dialog.custom_axis").into()
+ } else if !inp.multi {
+ inp.items.first().map(|item| selection_label(s, item)).unwrap_or_default()
+ } else {
+ crate::i18n::format("dialog.selected_count", &[("count", &inp.items.len().to_string())])
+ })
+ .color(t.on_accent)
} else {
- crate::i18n::format("dialog.selected_count", &[("count", &inp.items.len().to_string())])
- })
- .color(t.on_accent)
- } else {
- RichText::new(crate::i18n::tr("dialog.select")).color(t.text)
- };
- let stroke = if active { Stroke::new(1.5, t.accent) } else { Stroke::new(1.0, t.dialog_border.gamma_multiply(1.6)) };
- // Not in the Tab order: Tab moves between values.
- let b = egui::Button::new(text)
- .wrap_mode(egui::TextWrapMode::Wrap)
- .fill(if filled { t.chip } else { Color32::TRANSPARENT })
- .stroke(stroke)
- .min_size(vec2(0.0, 22.0))
- .sense(egui::Sense::CLICK);
- let chip = crate::frame::add_outlined(ui, b, stroke.width);
- publish_row(&chip);
- let tooltip = if let Some(reference) = stored_reference {
- reference.to_string()
- } else if custom_axis {
- if let Kind::Revolve { axis: Some(axis), .. } = &d.kind {
- format!(
- "Custom axis\nOrigin: {}\nDirection: {}\nClick to select a replacement axis",
- axis.get("origin").map(ToString::to_string).unwrap_or_default(),
- axis.get("dir").map(ToString::to_string).unwrap_or_default()
- )
+ RichText::new(crate::i18n::tr("dialog.select")).color(t.text)
+ };
+ let stroke = if active { Stroke::new(1.5, t.accent) } else { Stroke::new(1.0, t.dialog_border.gamma_multiply(1.6)) };
+ // Not in the Tab order: Tab moves between values.
+ let b = egui::Button::new(text.clone())
+ .wrap_mode(egui::TextWrapMode::Wrap)
+ .fill(if filled { t.chip } else { Color32::TRANSPARENT })
+ .stroke(stroke)
+ .min_size(vec2(0.0, 22.0))
+ .sense(egui::Sense::CLICK);
+ let chip = if crate::ui_kit::contains(ui) {
+ // The dense field replaces the legacy arrow chip with a filled surface.
+ let selected_text = text.text().strip_prefix("↖ ").unwrap_or_else(|| text.text());
+ let prompt = if !filled && inp.label == "Edges" { tr("Select edges") } else { selected_text };
+ crate::ui_kit::selection_field_state(ui, prompt, active, filled)
+ } else {
+ crate::frame::add_outlined(ui, b, stroke.width)
+ };
+ let chip_rect = chip.rect;
+ publish_row(&chip);
+ let tooltip = if let Some(reference) = stored_reference {
+ reference.to_string()
+ } else if custom_axis {
+ if let Some(axis) = stored_revolve_axis(&d.kind) {
+ format!(
+ "Custom axis\nOrigin: {}\nDirection: {}\nClick to select a replacement axis",
+ axis.get("origin").map(ToString::to_string).unwrap_or_default(),
+ axis.get("dir").map(ToString::to_string).unwrap_or_default()
+ )
+ } else {
+ hint(inp).to_string()
+ }
} else {
- hint(inp).to_string()
+ format!("{} (click to pick into this input)", hint(inp))
+ };
+ if chip.on_hover_text(tooltip).clicked() {
+ activate = Some(i);
}
- } else {
- format!("{} (click to pick into this input)", hint(inp))
- };
- if chip.on_hover_text(tooltip).clicked() {
- activate = Some(i);
- }
- if !inp.items.is_empty() || stored_reference.is_some() {
- let button = ui.small_button("×").on_hover_text(tr("Clear the selection"));
- crate::scenario::publish_handle(&format!("dialog:clear:{}", inp.label), button.rect.center());
- if button.clicked() {
- clear = Some(i);
+ if !inp.items.is_empty() || stored_reference.is_some() {
+ let button = if crate::ui_kit::contains(ui) {
+ let rect = egui::Rect::from_center_size(
+ egui::pos2(chip_rect.right() - t.space_24 / 2.0, chip_rect.center().y),
+ vec2(t.space_24, t.space_24),
+ );
+ crate::ui_kit::icon_button_at(ui, rect, "close", "Clear the selection")
+ } else {
+ ui.small_button("×").on_hover_text(tr("Clear the selection"))
+ };
+ crate::scenario::publish_handle(&format!("dialog:clear:{}", inp.label), button.rect.center());
+ if button.clicked() {
+ clear = Some(i);
+ }
}
- }
+ });
});
- ui.end_row();
+ if crate::ui_kit::contains(ui) && matches!(d.kind, Kind::SketchModify(_)) && inp.multi {
+ for (index, item) in inp.items.iter().enumerate() {
+ if crate::ui_kit::list_row(ui, &format!("{}:{index}", inp.label), &selection_label(s, item)).clicked() {
+ remove = Some((i, index));
+ }
+ }
+ }
+ }
+ if let Some((input, index)) = remove
+ && let Some(input) = d.inputs.get_mut(input)
+ && index < input.items.len()
+ {
+ input.items.remove(index);
}
if let Some(i) = activate {
d.active = i;
@@ -1998,70 +2038,6 @@ fn input_rows_range(d: &mut Dialog, ui: &mut egui::Ui, s: &Session, range: std::
d.sync_thread(s);
}
-/// Each live reference sits with the independent values it drives.
-fn rectangular_pattern_rows(d: &mut Dialog, ui: &mut egui::Ui, session: &Session) -> bool {
- use crate::sketch_modify_ui::Mod;
- use solidcraft_engine::sketch::PatternAlignment;
- let mut enter = false;
- ui.vertical(|ui| {
- ui.label(tr("dialog.selection_guidance"));
- egui::Grid::new("pattern_source").spacing(vec2(10.0, 8.0)).show(ui, |ui| {
- if matches!(d.kind, Kind::PatternRect { .. }) {
- placement_row(d, ui);
- }
- input_rows_range(d, ui, session, 0..1);
- });
- ui.separator();
- ui.columns(2, |columns| {
- for (index, ui) in columns.iter_mut().enumerate() {
- ui.strong(tr(if index == 0 { "Direction 1" } else { "Direction 2" }));
- egui::Grid::new(("pattern_direction", index)).spacing(vec2(8.0, 8.0)).show(ui, |ui| {
- input_rows_range(d, ui, session, index + 1..index + 2);
- if let Kind::PatternRect { count, spacing, count2, spacing2 } = &mut d.kind {
- let (count, spacing, count_label, spacing_label) =
- if index == 0 { (count, spacing, "Quantity", "Spacing") } else { (count2, spacing2, "Quantity 2", "Spacing 2") };
- row_label(ui, count_label);
- enter |= field(ui, count);
- ui.end_row();
- row_label(ui, spacing_label);
- enter |= field(ui, spacing);
- ui.end_row();
- feature_pattern_alignment_row(ui, &mut d.extra, index);
- return;
- }
- let Kind::SketchModify(Mod::PatternRect { count, spacing, count2, spacing2, alignment, alignment2, reversed, reversed2 }) =
- &mut d.kind
- else {
- return;
- };
- let (count, spacing, alignment, reversed, count_label, spacing_label, alignment_label) = if index == 0 {
- (count, spacing, alignment, reversed, "Quantity", "Spacing", "Alignment")
- } else {
- (count2, spacing2, alignment2, reversed2, "Quantity 2", "Spacing 2", "Alignment 2")
- };
- row_label(ui, count_label);
- enter |= field(ui, count);
- ui.end_row();
- row_label(ui, spacing_label);
- enter |= field(ui, spacing);
- ui.end_row();
- row_label(ui, alignment_label);
- ui.horizontal(|ui| {
- pattern_toggle(ui, alignment_label, "Flip direction", "pattern_flip", reversed);
- let mut centered = *alignment == PatternAlignment::Center;
- pattern_toggle(ui, alignment_label, "Center", "pattern_center", &mut centered);
- *alignment = if centered { PatternAlignment::Center } else { PatternAlignment::Right };
- });
- ui.end_row();
- });
- }
- });
- ui.small(tr("Counts include the original. Center balances copies; Flip chooses the extra side for even totals."));
- });
- ui.end_row();
- enter
-}
-
/// Feature patterns use the same source-fixed slot ordering and controls as sketch patterns.
fn feature_pattern_alignment_row(ui: &mut egui::Ui, extra: &mut serde_json::Map<String, Value>, index: usize) {
use solidcraft_engine::sketch::PatternAlignment;
@@ -2072,28 +2048,26 @@ fn feature_pattern_alignment_row(ui: &mut egui::Ui, extra: &mut serde_json::Map<
// Retain programmatic Left placement until the user changes its alignment.
let mut centered = alignment == PatternAlignment::Center;
let was_centered = centered;
- row_label(ui, label);
- ui.horizontal(|ui| {
- pattern_toggle(ui, label, "Flip direction", "pattern_flip", &mut reversed);
- pattern_toggle(ui, label, "Center", "pattern_center", &mut centered);
+ form_row(ui, label, |ui| {
+ ui.horizontal(|ui| {
+ pattern_toggle(ui, label, "Flip direction", "pattern_flip", &mut reversed);
+ pattern_toggle(ui, label, "Center", "pattern_center", &mut centered);
+ });
+ extra.insert(reversed_key.into(), json!(reversed));
+ if centered != was_centered {
+ extra.insert(alignment_key.into(), json!(if centered { PatternAlignment::Center } else { PatternAlignment::Right }));
+ }
});
- extra.insert(reversed_key.into(), json!(reversed));
- if centered != was_centered {
- extra.insert(alignment_key.into(), json!(if centered { PatternAlignment::Center } else { PatternAlignment::Right }));
- }
- ui.end_row();
}
pub(crate) fn pattern_toggle(ui: &mut egui::Ui, row: &str, label: &str, icon: &str, selected: &mut bool) {
- // Tab moves between value fields; Enter after a value edit applies the dialog.
- let response = ui.add(egui::Button::new("").selected(*selected).min_size(vec2(28.0, 24.0)).sense(egui::Sense::CLICK));
- let t = Tokens::get();
- crate::icons::paint(ui.painter(), response.rect.shrink(3.0), icon, t.icon, t.icon_fill, t.accent);
- response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, *selected, tr(label)));
- crate::scenario::publish_handle(&format!("dialog:{row}:{label}"), response.rect.center());
- if response.on_hover_text(tr(label)).clicked() {
- *selected = !*selected;
- }
+ crate::ui_kit::toggle_icon(ui, row, label, selected, icon);
+}
+
+/// A refusal that only says nothing is picked yet ("Select the curves to offset first", "select the
+/// corner to cut first"): guidance, not a failure. The sources word it with or without a capital.
+fn awaiting_selection(error: &str) -> bool {
+ error.get(..7).is_some_and(|start| start.eq_ignore_ascii_case("select "))
}
fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut egui::Ui, full_width: bool) {
@@ -2109,12 +2083,17 @@ fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut
d.error = app.preview.error.clone();
}
if let Some(error) = d.error.as_ref().or(app.preview.error.as_ref()).cloned() {
+ // "Select the curves to offset first" is not a failure: nothing is picked yet. The header hint
+ // and the disabled OK already say so, so it is not drawn as a red error with an issue button.
+ if matches!(d.kind, Kind::SketchModify(_)) && awaiting_selection(&error) {
+ return;
+ }
if !full_width {
row_label(ui, "");
}
ui.vertical(|ui| {
ui.add(egui::Label::new(RichText::new(error.as_str()).color(Tokens::get().error)).wrap());
- let response = ui.button("Create Issue…");
+ let response = crate::ui_kit::secondary_button(ui, "Create Issue…");
crate::scenario::publish_handle("dialog:create_issue", response.rect.center());
if response.clicked() {
crate::issue_report::begin(app, ctx, Some(d), Some(&error));
@@ -2300,12 +2279,12 @@ fn measure_rows(app: &SolveApp, ui: &mut egui::Ui, r: Option<&Value>, show: &mut
*show = Some(which);
}
let text = RichText::new(mm(v));
- ui.label(if now == which { text.strong() } else { text });
+ ui.label(if now == which { text.semibold().color(crate::theme::Tokens::get().text) } else { text });
ui.end_row();
}
} else {
- ui.label(RichText::new(crate::i18n::tr_label("Distance")).strong());
- ui.label(RichText::new(crate::prefs::show_mm(app, d, 1)).strong());
+ ui.label(RichText::new(crate::i18n::tr_label("Distance")).semibold().color(crate::theme::Tokens::get().text));
+ ui.label(RichText::new(crate::prefs::show_mm(app, d, 1)).semibold().color(crate::theme::Tokens::get().text));
ui.end_row();
}
let delta = b - a;
@@ -2318,8 +2297,8 @@ fn measure_rows(app: &SolveApp, ui: &mut egui::Ui, r: Option<&Value>, show: &mut
if let Some(a) = r["angle_deg"].as_f64()
&& r["items"].as_array().is_some_and(|v| v.len() == 2)
{
- ui.label(RichText::new(crate::i18n::tr_label("Angle")).strong());
- ui.label(RichText::new(format!("{a:.3}°")).strong());
+ ui.label(RichText::new(crate::i18n::tr_label("Angle")).semibold().color(crate::theme::Tokens::get().text));
+ ui.label(RichText::new(format!("{a:.3}°")).semibold().color(crate::theme::Tokens::get().text));
ui.end_row();
}
}
@@ -2380,9 +2359,13 @@ fn picked_side(app: &SolveApp, d: &Dialog, first: &Sel) -> Option<usize> {
/// view, sized to its content. The right edge is its place, except while a sketch is open: the
/// Sketch Palette keeps the right there, and the dialog takes the left so both stay on screen.
pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
- app.viewport.dialog_rect = None;
+ if app.tree.redefine.is_none() {
+ app.viewport.dialog_rect = None;
+ }
let Some(mut d) = app.dialog.take() else {
- crate::frame::reset_dock_offset(ctx);
+ if app.tree.redefine.is_none() {
+ crate::frame::reset_dock_offset(ctx);
+ }
return;
};
// Edit Text lasts as long as its text: other design changes leave it open.
@@ -2428,7 +2411,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
} else {
crate::frame::Side::Right
};
+ let dense_form = dense::command(&d.kind).is_some();
let top = crate::shell::panel_top(app, vp, vp.bottom(), side);
+ // Empty/hostile viewport geometry cannot provide a safe window rectangle.
+ if dense_form && (!vp.is_finite() || !vp.is_positive()) {
+ app.dialog = Some(d);
+ return;
+ }
// Dragged by its title band, the dialog keeps that offset from its docked place while it
// is open (#1335), kept inside the viewport.
let moved = crate::frame::dock_offset(ctx, title(&d.kind));
@@ -2437,20 +2426,21 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let mut keep = true;
let mut ok = false;
let mut applied = false;
+ let mut apply_again = app.applying.is_some() && d.repeat_after_apply;
let mut cancel = false;
let mut enter = false;
let wide = d.is_wide();
- let pattern_columns = matches!(d.kind, Kind::SketchModify(crate::sketch_modify_ui::Mod::PatternRect { .. }))
- || (matches!(d.kind, Kind::PatternRect { .. }) && d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES));
+
let raw_title = title(&d.kind);
let heading = if d.editing.is_some() { crate::i18n::format("dialog.edit_title", &[("title", tr(raw_title))]) } else { tr(raw_title).to_string() };
- let frame = crate::frame::dock_frame(ctx, side);
+ let frame = if dense_form { crate::ui_kit::Panel::feature_frame(ctx, app.ui.layout, side) } else { crate::frame::dock_frame(ctx, side) };
// The area includes the border as well as the inner margins; reserve all of it so a
// horizontally scrolling table cannot push a wide dialog two pixels past its limit.
let horizontal_frame = frame.inner_margin.leftf() + frame.inner_margin.rightf() + 2.0 * frame.stroke.width;
// OK is offered once the inputs make a feature.
let has_ok = !matches!(d.kind, Kind::Sketch | Kind::Params { .. } | Kind::Measure { .. });
let valid = match &d.kind {
+ Kind::Sketch => false,
Kind::SaveMesh(_) => crate::dialogs_save_mesh::ready(&d.inputs),
Kind::SketchModify(crate::sketch_modify_ui::Mod::Corner { .. }) => {
// Corner dialogs: preview errors are visual only; validation errors from
@@ -2461,28 +2451,74 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
};
let width = if wide { crate::frame::Width::Wide } else { crate::frame::Width::Normal };
let wkey = egui::Id::new(("sc_dialog_w", wide));
- let response = crate::frame::docked_on(
- RichText::new(heading.clone()).strong().size(13.0),
- egui::Id::new(("sc_dialog", title(&d.kind))),
- anchor,
- vp.bottom() - anchor.y - 8.0,
- width,
- side,
- )
- .frame(frame)
- .open(&mut keep)
- .show(ctx, |ui| {
+ let panel = crate::ui_kit::Panel::new(&heading, egui::Id::new(("sc_dialog", title(&d.kind))), anchor, vp, side, frame);
+ let window = if dense_form {
+ panel.window()
+ } else {
+ crate::frame::docked_on(
+ RichText::new(heading.clone()).semibold().color(crate::theme::Tokens::get().text).size(crate::theme::Tokens::get().font_button),
+ egui::Id::new(("sc_dialog", title(&d.kind))),
+ anchor,
+ vp.bottom() - anchor.y - 8.0,
+ width,
+ side,
+ )
+ };
+ let repeatable =
+ matches!(&d.kind, Kind::SketchModify(k) if crate::sketch_modify_ui::repeatable(k)) && d.editing.is_none() && !d.extra.contains_key("pattern");
+ let response = window.frame(frame).open(&mut keep).show(ctx, |ui| {
+ if dense_form {
+ let spec = dense::command(&d.kind).and_then(solidcraft_engine::find_command);
+ let icon = spec.as_ref().map_or("", |s| s.icon);
+ let label = spec.as_ref().map_or(heading.as_str(), |s| tr(s.label));
+ let label = if d.editing.is_some() { heading.as_str() } else { label };
+ let (closed, action) = panel.feature(
+ ui,
+ crate::ui_kit::FeatureOptions {
+ icon,
+ title: label,
+ drag_key: title(&d.kind),
+ moved,
+ docked,
+ apply_label: repeatable.then_some("Apply"),
+ },
+ app.applying.is_some(),
+ valid,
+ |ui| {
+ enter |= dense::rows(app, ctx, &mut d, ui);
+ let text = app.applying.as_ref().map(|job| {
+ let seconds = ((crate::now_ms() - job.started) / 1000.0).floor().max(0.0);
+ crate::i18n::format("dialog.computing", &[("seconds", &format!("{seconds:.0}"))])
+ });
+ crate::ui_kit::ComputeStatus { text, busy: app.applying.is_some() || app.preview.busy, applying: app.applying.is_some() }
+ },
+ );
+ cancel |= closed;
+ if app.issue_report.draft.is_none() {
+ match action {
+ crate::ui_kit::Action::Ok => {
+ ok = true;
+ apply_again = false;
+ }
+ crate::ui_kit::Action::Cancel => {
+ if !app.esc_handled || !ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
+ cancel = true;
+ }
+ }
+ crate::ui_kit::Action::Apply => {
+ ok = true;
+ apply_again = true;
+ }
+ crate::ui_kit::Action::None => {}
+ }
+ }
+ return;
+ }
ui.spacing_mut().text_edit_width = FIELD_W;
// Long texts (errors, notes) wrap instead of widening the dialog.
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
let margin = horizontal_frame;
- let min_w = if pattern_columns {
- 540.0
- } else if wide {
- 480.0
- } else {
- DIALOG_MIN_W
- } - margin;
+ let min_w = if wide { 480.0 } else { DIALOG_MIN_W } - margin;
ui.set_min_width(min_w);
ui.set_max_width(if wide { DIALOG_WIDE_MAX_W } else { DIALOG_MAX_W } - margin);
// Rows that end at the right edge line up with last frame's content width.
@@ -2496,14 +2532,19 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let total = total - 2.0 * crate::frame::HEADING_MARGIN;
let fold = if d.collapsed { "+" } else { "−" };
if ui
- .add(egui::Button::new(RichText::new(fold).size(14.0)).frame(false))
+ .add(egui::Button::new(RichText::new(fold).size(crate::theme::Tokens::get().font_heading)).frame(false))
.on_hover_text(if d.collapsed { "Expand" } else { "Collapse" })
.clicked()
{
d.collapsed = !d.collapsed;
}
// Not selectable: a drag on the title moves the dialog.
- ui.add(egui::Label::new(RichText::new(heading.as_str()).strong().size(12.5)).selectable(false));
+ ui.add(
+ egui::Label::new(
+ RichText::new(heading.as_str()).semibold().color(crate::theme::Tokens::get().text).size(crate::theme::Tokens::get().font_label),
+ )
+ .selectable(false),
+ );
let chevron_width = ui.spacing().interact_size.x;
crate::frame::right_aligned(ui, total, chevron_width, |ui| {
let chevron = if d.collapsed { "«" } else { "»" };
@@ -2536,12 +2577,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
if let Kind::Motion(k @ crate::dialogs_motion::Mo::Configurations { .. }) = &mut d.kind {
enter |= crate::dialogs_motion::rows(app, ui, k, &mut d.inputs);
}
- egui::Grid::new("sc_dialog_grid").num_columns(if pattern_columns { 1 } else { 2 }).spacing(vec2(10.0, 8.0)).show(ui, |ui| {
- if pattern_columns {
- enter |= rectangular_pattern_rows(&mut d, ui, &app.session);
- error_rows(app, ctx, &mut d, ui, true);
- return;
- }
+ egui::Grid::new("sc_dialog_grid").num_columns(2).spacing(vec2(10.0, 8.0)).show(ui, |ui| {
if matches!(&d.kind, Kind::Motion(crate::dialogs_motion::Mo::Configurations { .. })) {
return;
}
@@ -2563,545 +2599,41 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
d.sync_fillet_chain(&app.session);
input_rows(&mut d, ui, &app.session);
match &mut d.kind {
- Kind::Sketch => {
- if d.error.is_some()
- && let Some(selection @ Sel::Face { .. }) = d.inputs.first().and_then(|i| i.items.first())
- {
- row_label(ui, "Attachment");
- ui.label(tr("This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane."));
- ui.end_row();
- row_label(ui, "");
- if ui.button(tr("Use fixed plane")).clicked()
- && let Some(mut plane) = crate::sketch_attachment_ui::face_plane(app, selection)
- {
- plane["fixed"] = json!(true);
- match app.run("sketch.create", json!({"plane":plane})) {
- Ok(_) => {
- app.pre_sketch_cam = Some(app.cam);
- look_at_sketch(app);
- cancel = true;
- }
- Err(error) => d.refuse(app, error),
- }
- }
- ui.end_row();
- }
- }
- Kind::Extrude {
- distance,
- direction,
- operation,
- auto_op,
- smart,
- distance2,
- taper,
- taper_present,
- to_offset,
- start,
- all,
- thin,
- wall,
- wall_side,
- wall2,
- } => {
- row_label(ui, "Thin");
- if ui.checkbox(thin, tr("Thin Extrude")).changed() {
- set_thin(&mut d.inputs, *thin);
- }
- ui.end_row();
- if *thin {
- row_label(ui, "Wall Location");
- combo(ui, "ex_wall", &WALL_LABELS, wall_side);
- ui.end_row();
- row_label(ui, "Wall Thickness");
- enter |= field(ui, wall);
- ui.end_row();
- if *wall_side == 3 {
- row_label(ui, "Thickness Outside");
- enter |= field(ui, wall2);
- ui.end_row();
- }
- }
- row_label(ui, "Start");
- let old = if object_on(&d.inputs, FROM_OBJECT) { 2 } else { usize::from(!start.is_empty()) };
- let mut st = old;
- combo(ui, "ex_start", &["Profile Plane", "Offset", "From Object"], &mut st);
- if st != old {
- set_object(&mut d.inputs, &mut d.active, FROM_OBJECT, st == 2);
- if st == 1 && start.is_empty() {
- *start = "5 mm".into();
- }
- if st == 0 {
- start.clear();
- }
- }
- ui.end_row();
- if st != 0 {
- row_label(ui, "Offset");
- enter |= field(ui, start);
- ui.end_row();
- }
- row_label(ui, "Direction");
- // One Side, Two Sides, Symmetric (a flip is a negative distance).
- let order = [0usize, TWO_SIDES, 2];
- let reversed = *direction == 1 || *direction == TWO_SIDES_REVERSED;
- let shown = match *direction {
- 1 => 0,
- TWO_SIDES_REVERSED => TWO_SIDES,
- d => d,
- };
- let mut pos = order.iter().position(|o| *o == shown).unwrap_or(0);
- combo(ui, "ex_dir", &["One Side", "Two Sides", "Symmetric"], &mut pos);
- if pos != order.iter().position(|o| *o == shown).unwrap_or(0) {
- // One Side and Two Sides keep Reverse.
- *direction = match (order.get(pos).copied().unwrap_or(0), reversed) {
- (0, true) => 1,
- (TWO_SIDES, true) => TWO_SIDES_REVERSED,
- (d, _) => d,
- };
- // Selecting Symmetric applies the current total-distance semantics.
- d.extra.insert("convention".into(), json!(solidcraft_engine::doc::ExtrudeConvention::TotalDistance));
- // An explicit direction ends the automatic choices (#1257).
- smart.manual_dir = true;
- *auto_op = false;
- }
- ui.end_row();
- if *direction < 2 || two_sided(*direction) {
- row_label(ui, "Reverse");
- let mut reverse = *direction == 1 || *direction == TWO_SIDES_REVERSED;
- if ui.checkbox(&mut reverse, tr("Reverse Direction")).changed() {
- *direction = match (two_sided(*direction), reverse) {
- (true, true) => TWO_SIDES_REVERSED,
- (true, false) => TWO_SIDES,
- (false, r) => usize::from(r),
- };
- // An explicit direction ends the automatic choices (#1257).
- smart.manual_dir = true;
- *auto_op = false;
- }
- ui.end_row();
- }
- row_label(ui, "Extent Type");
- let cur = if to_object_on(&d.inputs) { 1 } else { usize::from(*all) * 2 };
- let mut ext = cur;
- combo(ui, "ex_ext", &["Distance", "To Object", "All"], &mut ext);
- *all = ext == 2;
- set_to_object(&mut d.inputs, &mut d.active, ext == 1);
- ui.end_row();
- if ext == 0 {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- }
- if ext == 1 {
- row_label(ui, "To Offset");
- enter |= field(ui, to_offset);
- ui.end_row();
- }
- // The second side is a distance whatever the first side's extent: All one
- // way and a distance the other is a common two-sided cut (#2700).
- if two_sided(*direction) {
- row_label(ui, "Distance 2");
- enter |= field(ui, distance2);
- ui.end_row();
- }
- if *direction < 2 {
- row_label(ui, "Taper Angle");
- let before = taper.clone();
- enter |= field(ui, taper);
- if *taper != before {
- *taper_present = !taper.trim().is_empty();
- }
- ui.end_row();
- }
- row_label(ui, "Operation");
- let before = *operation;
- combo(ui, "ex_op", &OP_LABELS, operation);
- // A choice made by hand sticks.
- if *operation != before {
- *auto_op = false;
- }
- ui.end_row();
- }
- Kind::Revolve { angle, operation, .. } => {
- row_label(ui, "Type");
- let cur = usize::from(to_object_on(&d.inputs));
- let mut ty = cur;
- combo(ui, "rv_type", &["Angle", "To Object"], &mut ty);
- set_to_object(&mut d.inputs, &mut d.active, ty == 1);
- ui.end_row();
- if ty == 0 {
- // One Side, Two Sides (a second angle), Symmetric (the angle split).
- row_label(ui, "Direction");
- let cur = if d.extra.contains_key("angle2") {
- 1
- } else if d.extra.get("direction").is_some() {
- 2
- } else {
- 0
- };
- let mut dir = cur;
- combo(ui, "rv_dir", &["One Side", "Two Sides", "Symmetric"], &mut dir);
- if dir != cur {
- d.extra.remove("angle2");
- d.extra.remove("direction");
- match dir {
- 1 => {
- d.extra.insert("angle2".into(), json!("90 deg"));
- }
- 2 => {
- d.extra.insert("direction".into(), json!("symmetric"));
- }
- _ => {}
- }
- }
- ui.end_row();
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- if dir == 1 {
- row_label(ui, "Angle 2");
- enter |= extra_field(ui, &mut d.extra, "angle2", "90 deg");
- ui.end_row();
- }
- }
- row_label(ui, "Operation");
- combo(ui, "rv_op", &OP_LABELS, operation);
- ui.end_row();
- }
- Kind::Fillet { radius, chamfer, chain, ctype, distance2, angle, flip } => {
- if *chamfer {
- row_label(ui, "Chamfer Type");
- combo(ui, "ch_type", &CHAMFER_TYPES, ctype);
- ui.end_row();
- }
- let mut rtype = 0;
- if !*chamfer {
- row_label(ui, "Radius Type");
- rtype = extra_choice(
- ui,
- &mut d.extra,
- "fi_type",
- "type",
- &[
- ("Constant", "constant"),
- ("Chord Length", "chord"),
- ("Variable", "variable"),
- ("Spline", "spline"),
- ("Curvature (G2)", "curvature"),
- ],
- );
- ui.end_row();
- }
- row_label(
- ui,
- if !*chamfer {
- match rtype {
- 1 => "Chord Length",
- 2 | 3 => "Start Radius",
- 4 => "Equivalent Radius",
- _ => "Radius",
- }
- } else if *ctype == 0 {
- "Distance"
- } else {
- "Distance 1"
- },
- );
- enter |= field(ui, radius);
- ui.end_row();
- // A constant radius too large for the edges: refused, reduced to the
- // largest that fits (the preview shows what was used), or tapered along
- // the edges to the room there.
- if !*chamfer && rtype == 0 {
- row_label(ui, "Radius Fit");
- let fit = extra_choice(
- ui,
- &mut d.extra,
- "fi_fit",
- "fit",
- &[("Exact", "exact"), ("Reduce to Fit", "reduce"), ("Taper to Fit", "taper")],
- );
- ui.end_row();
- if fit == 1
- && let Some((lo, hi)) = app.preview.applied
- {
- // A range where edges apart from each other fit different radii.
- row_label(ui, "Applied Radius");
- let shown = if hi > lo {
- format!("{} – {}", crate::prefs::show_mm_bare(app, lo), crate::prefs::show_mm(app, hi, 1))
- } else {
- crate::prefs::show_mm(app, lo, 1)
- };
- ui.label(RichText::new(shown).color(t.warning));
- ui.end_row();
- }
- } else if !*chamfer {
- d.extra.remove("fit");
- }
- if *chamfer && *ctype == 1 {
- row_label(ui, "Distance 2");
- enter |= field(ui, distance2);
- ui.end_row();
- }
- if *chamfer && *ctype == 2 {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- }
- if *chamfer && *ctype > 0 {
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
- }
- if !*chamfer && rtype == 2 {
- row_label(ui, "End Radius");
- enter |= extra_field(ui, &mut d.extra, "radius2", "1 mm");
- ui.end_row();
- // Which end of the first edge takes the start radius.
- row_label(ui, "Swap Ends");
- extra_check(ui, &mut d.extra, "swap_ends");
- ui.end_row();
- // Radii between the ends: position along the edge (from the start end)
- // and radius.
- let mut mids = mid_points(&d.extra);
- let mut remove = None;
- for (k, (t, r)) in mids.iter_mut().enumerate() {
- row_label(ui, "Mid Radius");
- ui.horizontal(|ui| {
- ui.add(
- egui::DragValue::new(t)
- .speed(0.01)
- .range(0.01..=0.99)
- .fixed_decimals(2)
- .custom_parser(crate::prefs::parse_number),
- )
- .on_hover_text(tr("Position along the edge, 0 at the start end, 1 at the other"));
- enter |= field(ui, r);
- if ui.small_button("×").on_hover_text(tr("Remove this point")).clicked() {
- remove = Some(k);
- }
- });
- ui.end_row();
- }
- if let Some(k) = remove {
- mids.remove(k);
- }
- row_label(ui, "");
- if ui.button(tr("Add Mid Radius")).clicked() && mids.len() < 20 {
- let t = if mids.is_empty() { 0.5 } else { (mids.iter().map(|m| m.0).fold(0.0, f64::max) + 1.0) * 0.5 };
- mids.push((t.min(0.99), radius.clone()));
- }
- ui.end_row();
- d.extra.insert("mid".into(), json!(mids.iter().map(|(t, r)| json!([t, r])).collect::<Vec<_>>()));
- if !mids.is_empty() {
- row_label(ui, "Smooth");
- extra_check(ui, &mut d.extra, "smooth");
- ui.end_row();
- }
- }
- if !*chamfer && rtype == 3 {
- // The radius along the edge as a B-spline: its control radii from the
- // start end, also dragged by their handles on the edge.
- row_label(ui, "Swap Ends");
- extra_check(ui, &mut d.extra, "swap_ends");
- ui.end_row();
- let mut radii = spline_radii(&mut d.extra, radius);
- let n = radii.len();
- for (k, r) in radii.iter_mut().enumerate() {
- row_label(ui, if k + 1 == n { "End Radius" } else { "Control Radius" });
- enter |= field(ui, r);
- ui.end_row();
- }
- d.extra.insert("radii".into(), json!(radii));
- }
- row_label(ui, "Tangent Chain");
- let r = ui.checkbox(chain, "");
- publish_row(&r);
- ui.end_row();
- }
- Kind::Shell { thickness } => {
- row_label(ui, "Tangent Chain");
- extra_check(ui, &mut d.extra, "tangent_chain");
- ui.end_row();
- let dir = d.extra.get("direction").and_then(Value::as_str).unwrap_or("inside").to_string();
- row_label(
- ui,
- match dir.as_str() {
- "outside" => "Outside Thickness",
- "both" => "Thickness",
- _ => "Inside Thickness",
- },
- );
- enter |= field(ui, thickness);
- ui.end_row();
- row_label(ui, "Direction");
- extra_choice(ui, &mut d.extra, "sh_dir", "direction", &[("Inside", "inside"), ("Outside", "outside"), ("Both", "both")]);
- ui.end_row();
- }
- Kind::Draft { angle } => {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- }
- Kind::Mirror => {
- // Feature replay retains the source operation; Join is for body copies.
- if !d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES) {
- row_label(ui, "Operation");
- let mut op = usize::from(d.extra.get("combine").and_then(Value::as_bool).unwrap_or(false));
- combo(ui, "mi_op", &["New Body", "Join"], &mut op);
- d.extra.insert("combine".into(), json!(op == 1));
- ui.end_row();
- }
- }
+ // These forms are drawn by dense::rows before entering this legacy grid.
+ Kind::Extrude { .. } | Kind::Fillet { .. } | Kind::PatternRect { .. } | Kind::PatternCirc { .. } | Kind::Hole { .. } => {}
+
+ Kind::Sketch | Kind::SketchModify(_) | Kind::Text(_) | Kind::TextMove(_) | Kind::EditParam { .. } => {}
+
+ Kind::Revolve { .. }
+ | Kind::Shell { .. }
+ | Kind::Draft { .. }
+ | Kind::Mirror
+ | Kind::OffsetPlane { .. }
+ | Kind::AnglePlane { .. }
+ | Kind::PathPlane { .. }
+ | Kind::Split
+ | Kind::DeleteFaces
+ | Kind::ReplaceFace
+ | Kind::Remove
+ | Kind::Midplane
+ | Kind::MeshConvert { .. }
+ | Kind::Construct { .. }
+ | Kind::Rib { .. }
+ | Kind::Emboss { .. }
+ | Kind::Align { .. }
+ | Kind::BoundaryFill { .. }
+ | Kind::PathPattern { .. }
+ | Kind::Pipe { .. }
+ | Kind::Stock { .. }
+ | Kind::Scale { .. }
+ | Kind::OffsetFaces { .. }
+ | Kind::Thread { .. }
+ | Kind::Loft { .. }
+ | Kind::Sweep { .. }
+ | Kind::Move { .. }
+ | Kind::Primitive { .. }
+ | Kind::Combine { .. } => {}
Kind::Measure { result, show, .. } => measure_rows(app, ui, result.as_ref(), show),
- Kind::OffsetPlane { offset } => {
- row_label(ui, "Distance");
- enter |= field(ui, offset);
- ui.end_row();
- }
- Kind::AnglePlane { angle } => {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- }
- Kind::PathPlane { t, .. } => {
- row_label(ui, "Position (0 to 1)");
- enter |= field(ui, t);
- ui.end_row();
- }
- Kind::Split | Kind::ReplaceFace | Kind::DeleteFaces | Kind::Remove | Kind::Midplane | Kind::Construct { t: None, .. } => {}
- Kind::MeshConvert { tolerance } => {
- row_label(ui, "Tolerance");
- enter |= field(ui, tolerance);
- ui.end_row();
- }
- Kind::Construct { t: Some(t), .. } => {
- row_label(ui, "Position (0 to 1)");
- enter |= field(ui, t);
- ui.end_row();
- }
- Kind::Rib { thickness, depth, flip, normal, .. } => {
- row_label(ui, "Direction");
- let mut i = usize::from(*normal);
- combo(ui, "rib_direction", &["In plane", "Normal to sketch"], &mut i);
- *normal = i == 1;
- ui.end_row();
- row_label(ui, "Thickness");
- enter |= field(ui, thickness);
- ui.end_row();
- row_label(ui, "Depth");
- let r = ui.add(egui::TextEdit::singleline(depth).hint_text(tr("to the next face")));
- crate::params_dialog::complete(ui, &r, depth);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
- }
- Kind::Emboss { depth, deboss } => {
- row_label(ui, "Depth");
- enter |= field(ui, depth);
- ui.end_row();
- row_label(ui, "Type");
- let mut i = usize::from(*deboss);
- combo(ui, "emb_mode", &["Emboss", "Deboss"], &mut i);
- *deboss = i == 1;
- ui.end_row();
- ui.label("");
- ui.add(
- egui::Label::new(
- "Orthogonal line profiles tangent to one supported cylinder wrap automatically. Pick a wall to choose a target.",
- )
- .wrap(),
- );
- ui.end_row();
- }
- Kind::Align { flip } => {
- // Where on the picked face or edge to snap: as picked (a face turns to meet
- // the other, an edge at its middle), its centre, or a round one's centre.
- for (label, key) in [("From Snap", "from_snap"), ("To Snap", "to_snap")] {
- row_label(ui, label);
- extra_choice(ui, &mut d.extra, key, key, &[("As Picked", "picked"), ("Centre", "center"), ("Circle Centre", "circle")]);
- ui.end_row();
- }
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
- }
- Kind::BoundaryFill { operation, cells, .. } => {
- row_label(ui, "Cells");
- if cells.is_empty() {
- ui.label(RichText::new(tr("Pick the tool bodies")).color(Tokens::get().text_dim));
- }
- ui.end_row();
- for (i, (_, label, on)) in cells.iter_mut().enumerate() {
- row_label(ui, &format!("Cell {}", i + 1));
- ui.checkbox(on, label.as_str());
- ui.end_row();
- }
- row_label(ui, "Operation");
- combo(ui, "bf_op", &OP_LABELS, operation);
- ui.end_row();
- row_label(ui, "Remove Tools");
- extra_check(ui, &mut d.extra, "remove_tools");
- ui.end_row();
- }
- Kind::PathPattern { count, spacing } => {
- for (l, v) in [("Quantity", count), ("Spacing", spacing)] {
- row_label(ui, l);
- enter |= field(ui, v);
- ui.end_row();
- }
- }
- Kind::Pipe { diameter, wall } => {
- row_label(ui, "Diameter");
- enter |= field(ui, diameter);
- ui.end_row();
- row_label(ui, "Wall");
- let r = ui.add(egui::TextEdit::singleline(wall).hint_text("solid"));
- crate::params_dialog::complete(ui, &r, wall);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- }
- Kind::Stock { margin } => {
- row_label(ui, "Margin");
- enter |= field(ui, margin);
- ui.end_row();
- }
- Kind::Scale { factor } => {
- row_label(ui, "Scale factor");
- enter |= field(ui, factor);
- ui.end_row();
- }
- Kind::OffsetFaces { distance } => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- }
- Kind::Thread { designation, length, suggested, of } => {
- row_label(ui, "Modeled");
- extra_check(ui, &mut d.extra, "modeled");
- ui.end_row();
- row_label(ui, "Full Length");
- let mut full = length.trim().is_empty();
- let response = ui.checkbox(&mut full, "");
- publish_row(&response);
- if response.changed() {
- *length = if full { String::new() } else { "10 mm".into() };
- }
- ui.end_row();
- let (submitted, reset) = crate::dialogs_thread::rows(ui, designation, suggested);
- enter |= submitted;
- if reset {
- of.clear();
- }
- if !full {
- row_label(ui, "Length");
- enter |= field(ui, length);
- ui.end_row();
- }
- }
Kind::Material { index } => {
let names: Vec<&str> = material_names.iter().map(String::as_str).collect();
row_label(ui, "Material");
@@ -3116,156 +2648,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
ui.checkbox(flip, "");
ui.end_row();
}
- Kind::PatternRect { count, spacing, count2, spacing2 } => {
- for (l, v) in [("Quantity", count), ("Spacing", spacing), ("Quantity 2", count2), ("Spacing 2", spacing2)] {
- row_label(ui, l);
- enter |= field(ui, v);
- ui.end_row();
- }
- }
- Kind::PatternCirc { count, angle } => {
- for (l, v) in [("Quantity", count), ("Total angle", angle)] {
- row_label(ui, l);
- enter |= field(ui, v);
- ui.end_row();
- }
- if d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES) {
- feature_pattern_alignment_row(ui, &mut d.extra, 0);
- }
- }
- Kind::Loft { operation, rail_fit } => {
- crate::dialogs_sweep::rail_fit_row(ui, "lf", rail_fit);
- row_label(ui, "Operation");
- combo(ui, "lf_op", &OP_LABELS, operation);
- ui.end_row();
- }
- Kind::Sweep { operation, opts } => {
- enter |= crate::dialogs_sweep::rows(ui, opts, "sw");
- row_label(ui, "Operation");
- combo(ui, "sw_op", &OP_LABELS, operation);
- ui.end_row();
- }
- k @ Kind::Move { .. } => {
- enter |= crate::dialogs_move::rows(ui, k);
- row_label(ui, "Create Copy");
- extra_check(ui, &mut d.extra, "copy");
- ui.end_row();
- }
- Kind::Hole { diameter, depth, kind, cb_diameter, cb_depth, cs_diameter, cs_angle, opts } => {
- row_label(ui, "Extents");
- let cur = if to_object_on(&d.inputs) { 1 } else { usize::from(opts.all) * 2 };
- let mut ext = cur;
- combo(ui, "hole_ext", &["Distance", "To Object", "All"], &mut ext);
- opts.all = ext == 2;
- set_to_object(&mut d.inputs, &mut d.active, ext == 1);
- ui.end_row();
- if opts.multiple {
- // Every point of the picked points' sketches (standalone points and
- // circle centres), not just the picked ones.
- row_label(ui, "All Sketch Points");
- extra_check(ui, &mut d.extra, "all_points");
- ui.end_row();
- // The holes go into the part the sketch touches; Flip drills the
- // other way.
- row_label(ui, "Flip");
- extra_check(ui, &mut d.extra, "flip");
- ui.end_row();
- }
- row_label(ui, "Hole Type");
- combo(ui, "hole_kind", &HOLE_LABELS, kind);
- ui.end_row();
- row_label(ui, "Hole Tap Type");
- let mut tap = usize::from(opts.tapped);
- combo(ui, "hole_tap", &["Simple", "Tapped"], &mut tap);
- opts.tapped = tap == 1;
- ui.end_row();
- if opts.tapped {
- row_label(ui, "Size");
- let r = ui.add(egui::TextEdit::singleline(&mut opts.thread).hint_text("M5"));
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- }
- if *kind == 0 {
- row_label(ui, "Drill Point");
- let mut tip = usize::from(opts.angled);
- combo(ui, "hole_tip", &["Flat", "Angle"], &mut tip);
- opts.angled = tip == 1;
- ui.end_row();
- }
- if !opts.all {
- row_label(ui, "Depth");
- enter |= field(ui, depth);
- ui.end_row();
- }
- if *kind == 0 && opts.angled {
- row_label(ui, "Tip Angle");
- enter |= field(ui, &mut opts.tip_angle);
- ui.end_row();
- }
- row_label(ui, "Diameter");
- enter |= field(ui, diameter);
- ui.end_row();
- if *kind == 1 {
- row_label(ui, "Counterbore Ø");
- enter |= field(ui, cb_diameter);
- ui.end_row();
- row_label(ui, "Counterbore depth");
- enter |= field(ui, cb_depth);
- ui.end_row();
- }
- if *kind == 2 {
- row_label(ui, "Countersink Ø");
- enter |= field(ui, cs_diameter);
- ui.end_row();
- row_label(ui, "Countersink angle");
- enter |= field(ui, cs_angle);
- ui.end_row();
- }
- }
- Kind::Primitive { fields, operation, at, .. } => {
- for (k, v) in fields.iter_mut() {
- row_label(ui, k);
- enter |= field(ui, v);
- ui.end_row();
- }
- if let Some((p, _)) = *at {
- row_label(ui, "Position");
- ui.horizontal(|ui| {
- ui.label(format!("{:.2}, {:.2}, {:.2}", p.x, p.y, p.z));
- if ui.small_button("×").on_hover_text(tr("Place at the origin instead")).clicked() {
- *at = None;
- }
- });
- ui.end_row();
- }
- row_label(ui, "Operation");
- combo(ui, "pr_op", &OP_LABELS, operation);
- ui.end_row();
- }
- Kind::Combine { operation, keep_tools } => {
- row_label(ui, "Operation");
- let mut op = operation.saturating_sub(1);
- combo(ui, "cb_op", &OP_LABELS[1..], &mut op);
- *operation = op + 1;
- ui.end_row();
- row_label(ui, "New Component");
- extra_check(ui, &mut d.extra, "new_component");
- ui.end_row();
- row_label(ui, "Keep Tools");
- ui.checkbox(keep_tools, "");
- ui.end_row();
- }
+
Kind::Params { new_name, new_expr } => params_table(app, ui, new_name, new_expr),
- Kind::EditParam { name, expr } => {
- ui.label(name.as_str());
- let r = ui.text_edit_singleline(expr);
- crate::params_dialog::complete(ui, &r, expr);
- if r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
- ok = true;
- }
- r.request_focus();
- ui.end_row();
- }
Kind::Rename { name, .. } => {
row_label(ui, "Name");
let r = ui.text_edit_singleline(name);
@@ -3278,7 +2662,6 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
Kind::Assembly(k) => enter |= crate::dialogs_assembly::rows(app, ui, k, &mut d.inputs, &mut d.active),
Kind::Sheet(k) => enter |= crate::dialogs_sheet::rows(app, ui, k, &mut d.inputs),
Kind::Surface(k) => enter |= crate::dialogs_surface::rows(ui, k),
- Kind::SketchModify(k) => enter |= crate::sketch_modify_ui::rows(ui, k),
Kind::SaveMesh(k) => enter |= crate::dialogs_save_mesh::rows(app, ui, k),
Kind::ViewDxf { dashed, tolerance } => crate::dialogs_view_dxf::rows(app, ui, dashed, tolerance),
Kind::Plastic(k) => enter |= crate::dialogs_plastic::rows(app, ui, k, &d.inputs),
@@ -3286,8 +2669,6 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
Kind::Motion(k) => enter |= crate::dialogs_motion::rows(app, ui, k, &mut d.inputs),
Kind::Part(k) => enter |= crate::dialogs_parts::rows(app, ui, k, &d.inputs),
Kind::PartSize(k) => enter |= crate::dialogs_part_size::rows(app, ui, k),
- Kind::Text(k) => enter |= crate::sketch_text::rows(ui, k, &mut d.inputs, &mut d.active),
- Kind::TextMove(k) => enter |= crate::sketch_text_move::rows(ui, k),
Kind::ConfirmDelete { with, fail, .. } => {
if !with.is_empty() {
row_label(ui, "Also deletes");
@@ -3310,7 +2691,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
ui.horizontal(|ui| {
let (r, resp) = ui.allocate_exact_size(vec2(16.0, 16.0), egui::Sense::hover());
ui.painter().circle_stroke(r.center(), 7.0, Stroke::new(1.2, t.text_dim));
- ui.painter().text(r.center(), egui::Align2::CENTER_CENTER, "i", egui::FontId::proportional(11.0), t.text_dim);
+ ui.painter().text(
+ r.center(),
+ egui::Align2::CENTER_CENTER,
+ "i",
+ egui::FontId::proportional(crate::theme::Tokens::get().font_small),
+ t.text_dim,
+ );
resp.on_hover_text(heading.as_str());
// The spinner's place is always taken: a widget that comes and goes would shift
// the automatic ids of OK and Cancel, and a click pressed in one frame and
@@ -3362,6 +2749,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
app.viewport.dialog_rect = response.map(|r| r.response.rect);
if let Some(r) = app.viewport.dialog_rect {
crate::scenario::publish_rect("dialog:outer", r);
+ crate::scenario::publish_rect("dialog:card", r);
+ crate::scenario::publish_handle("dialog:card", r.center());
}
// Keyboard: Enter applies (from a value field, or with nothing focused), Esc cancels.
let (enter_free, esc) = ctx.input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape)));
@@ -3381,6 +2770,23 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
// A plane picked for a new sketch starts it right away.
let mut then_start = None;
if matches!(d.kind, Kind::Sketch)
+ && d.extra.remove("fixed_plane").and_then(|v| v.as_bool()).unwrap_or(false)
+ && let Some(sel) = d.inputs.first().and_then(|i| i.items.first())
+ && let Some(mut plane) = crate::sketch_attachment_ui::face_plane(app, sel)
+ {
+ plane["fixed"] = json!(true);
+ match app.run("sketch.create", json!({"plane":plane})) {
+ Ok(_) => {
+ app.pre_sketch_cam = Some(app.cam);
+ look_at_sketch(app);
+ cancel = true;
+ then_start = d.then_start;
+ }
+ Err(error) => d.refuse(app, error),
+ }
+ }
+ if matches!(d.kind, Kind::Sketch)
+ && !cancel
&& d.error.is_none()
&& let Some(sel) = d.inputs.first().and_then(|i| i.items.first()).cloned()
{
@@ -3393,6 +2799,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
}
if ok && app.applying.is_none() {
+ d.repeat_after_apply = apply_again;
// Edit Text applies its own way: its live changes and OK are one undo step.
let run = match &mut d.kind {
Kind::Text(k) => Some(crate::sketch_text::apply(app, k)),
@@ -3407,8 +2814,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
};
match run {
Some(Ok(())) => {
- cancel = true;
applied = true;
+ cancel = !apply_again;
}
Some(Err(e)) => d.refuse(app, e),
None => {}
@@ -3425,13 +2832,23 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
Some(job) => app.applying = Some(job),
None => match run_dialog(app, &d) {
Ok(()) => {
- cancel = true;
+ cancel = !apply_again;
applied = true;
}
Err(e) => d.refuse(app, e),
},
}
}
+ if applied && apply_again {
+ for input in &mut d.inputs {
+ input.items.clear();
+ }
+ d.active = 0;
+ d.error = None;
+ d.refused = None;
+ d.repeat_after_apply = false;
+ let _ = app.session.execute("select.clear", &json!({}));
+ }
// Cancel while computing: the result goes (its worker runs on to its end).
if cancel && !applied {
app.applying = None;
@@ -3568,12 +2985,12 @@ fn extra_choice(ui: &mut egui::Ui, extra: &mut serde_json::Map<String, Value>, i
/// A checkbox stored in the dialog's extra parameters.
fn extra_check(ui: &mut egui::Ui, extra: &mut serde_json::Map<String, Value>, key: &str) {
let mut on = extra.get(key).and_then(Value::as_bool).unwrap_or(false);
- let r = ui.checkbox(&mut on, "");
+ let r = if crate::ui_kit::contains(ui) { crate::ui_kit::checkbox(ui, "", &mut on) } else { ui.checkbox(&mut on, "") };
if r.changed() {
extra.insert(key.into(), json!(on));
}
- // The box carries no text of its own, so a scenario reaches it by its row handle.
- publish_row(&r);
+ // Keep both the checkbox's accessibility label and its existing scenario handle.
+ publish_check(ui, &r, on);
}
/// A value field stored in the dialog's extra parameters (`default` until edited).
@@ -3679,8 +3096,8 @@ fn hole_defaults() -> Kind {
fn params_table(app: &mut SolveApp, ui: &mut egui::Ui, new_name: &mut String, new_expr: &mut String) {
let t = Tokens::get();
- ui.label(RichText::new(tr("Name")).strong());
- ui.label(RichText::new(tr("Expression · value")).strong());
+ ui.label(RichText::new(tr("Name")).semibold().color(crate::theme::Tokens::get().text));
+ ui.label(RichText::new(tr("Expression · value")).semibold().color(crate::theme::Tokens::get().text));
ui.end_row();
let (vals, errs) = app.session.doc.param_values();
let params = app.session.doc.params.clone();
@@ -5183,6 +4600,11 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
*flip = *f;
}
}
+ if let FeatureKind::Fillet { corner, .. } = &f.kind
+ && !corner.is_rolling()
+ {
+ d.extra.insert("corner".into(), json!("g2"));
+ }
// A fillet that reduces or tapers a radius too large for its edges.
if let FeatureKind::Fillet { fit, .. } = &f.kind {
use solidcraft_engine::doc::FilletFit;
@@ -5966,3 +5388,24 @@ fn same_face(a: &Sel, b: &Sel) -> bool {
fn face_point(x: &Sel) -> Option<Value> {
if let Sel::Face { point, .. } = x { Some(pt(*point)) } else { None }
}
+
+#[cfg(test)]
+mod awaiting_selection_tests {
+ use super::awaiting_selection;
+
+ #[test]
+ fn missing_selection_messages_are_guidance_and_real_failures_are_not() {
+ for guidance in [
+ "Select the curves to offset first",
+ "Select the mirror line",
+ "select the corner to cut first",
+ "select the corners to round first",
+ "select corner points, or the two lines of one corner",
+ ] {
+ assert!(awaiting_selection(guidance), "{guidance}");
+ }
+ for failure in ["Offset distance must be positive", "the sketch has no curves", "Selection is not on this sketch", "", "sel"] {
+ assert!(!awaiting_selection(failure), "{failure}");
+ }
+ }
+}
diff --git a/crates/ui-egui/src/dialogs_all_tests.rs b/crates/ui-egui/src/dialogs_all_tests.rs
new file mode 100644
index 0000000000..fc72f68f8f
--- /dev/null
+++ b/crates/ui-egui/src/dialogs_all_tests.rs
@@ -0,0 +1,322 @@
+//! Each ribbon feature form keeps its parameter builder while sharing the dense layout.
+use super::*;
+use crate::scenario::{self, Harness};
+
+fn fixture() -> Harness {
+ let mut h = Harness::new();
+ for (name, x) in [("A", 0), ("B", 30), ("C", 60), ("D", 90)] {
+ h.app.run("component.activate", json!({"component":"root"})).unwrap();
+ h.app.run("component.create", json!({"name":name})).unwrap();
+ h.app.run("solid.cylinder", json!({"base":[x,0,0],"radius":10,"height":5})).unwrap();
+ }
+ h.app.run("component.activate", json!({"component":"root"})).unwrap();
+ h.app.run("occurrence.ground", json!({"occurrence":"A:1","grounded":true})).unwrap();
+ for (name, kind) in [("B", "revolute"), ("C", "cylindrical"), ("D", "slider")] {
+ h.app.run("joint.as_built", json!({"name":name,"type":kind,"a":"A","b":name})).unwrap();
+ }
+ for (name, offset) in [("Base", 0), ("Top", 10)] {
+ h.app.run("sketch.create", json!({"plane":"XY","offset":offset,"name":name})).unwrap();
+ h.app.run("sketch.rectangle.two_point", json!({"p0":[12,0],"p1":[16,4]})).unwrap();
+ h.app.run("sketch.finish", json!({})).unwrap();
+ }
+ h.app.run("sketch.create", json!({"plane":"XZ","name":"Path"})).unwrap();
+ h.app.run("sketch.line", json!({"points":[[0,0],[0,20]]})).unwrap();
+ h.app.run("sketch.finish", json!({})).unwrap();
+ h
+}
+
+fn representative(h: &Harness, command: &str) -> Dialog {
+ let mut d = Dialog::for_command(&h.app, command).unwrap();
+ let s = &h.app.session;
+ let profiles: Vec<_> = s.world_state().sketches.iter().take(2).map(|sk| Sel::Profile { sketch: sk.feature, index: 0 }).collect();
+ let path = s.world_state().sketches.last().unwrap().sketch.curves.first().unwrap().id.clone();
+ for (index, input) in d.inputs.iter_mut().enumerate() {
+ if command == "joint.gear" {
+ continue;
+ }
+ if matches!(input.label, "Rail" | "Second Rail" | "Pass through" | "Direction" | "Roller (optional)" | "Tip (optional)") {
+ continue;
+ }
+ let name = if index == 1 && command != "surface.ruled" { "Body2" } else { "Body1" };
+ let point = if index == 1 && command != "surface.ruled" { Vec3::new(30.0, 0.0, 5.0) } else { Vec3::new(0.0, 0.0, 5.0) };
+ input.items = if command == "construct.point.along_path" {
+ vec![edge_sel(s, Vec3::new(10.0, 0.0, 5.0)).unwrap()]
+ } else if input.accept & PROFILES != 0 {
+ if matches!(d.kind, Kind::Loft { .. } | Kind::Surface(crate::dialogs_surface::Surf::Loft { .. })) {
+ profiles.clone()
+ } else {
+ vec![profiles[0].clone()]
+ }
+ } else if input.accept & BODIES != 0 {
+ if matches!(command, "joint.as_built" | "joint.rigid_group") {
+ vec![Sel::Body { name: "Body1".into() }, Sel::Body { name: "Body2".into() }]
+ } else {
+ vec![Sel::Body { name: name.into() }]
+ }
+ } else if input.accept & PLANES != 0 {
+ vec![Sel::Plane { name: if index == 1 { "XZ" } else { "XY" }.into() }]
+ } else if input.accept & CURVES != 0 || command == "sheet.fold" && index == 0 {
+ vec![Sel::SketchCurve { id: path.clone() }]
+ } else if input.accept & AXES != 0 {
+ vec![Sel::Axis { name: "Z".into() }]
+ } else if input.accept & (FACES | PLANAR_FACES) != 0 {
+ vec![face_sel(s, point).unwrap()]
+ } else if input.accept & EDGES != 0 {
+ vec![edge_sel(s, Vec3::new(10.0, 0.0, 5.0)).unwrap()]
+ } else {
+ Vec::new()
+ };
+ }
+ if let Kind::PathPlane { sketch, .. } = &mut d.kind {
+ *sketch = Some(s.world_state().sketches.last().unwrap().feature);
+ }
+ if let Kind::Mirror = &d.kind {
+ d.extra.insert("combine".into(), json!(false));
+ }
+ if let Kind::BoundaryFill { cells, .. } = &mut d.kind {
+ cells.push((Vec3::new(0.0, 0.0, 2.0), "Cell".into(), true));
+ }
+ if let Kind::Thread { designation, .. } = &mut d.kind {
+ *designation = "M20x2.5".into();
+ }
+ if let Kind::Assembly(crate::dialogs_assembly::Asm::Cam(f)) = &mut d.kind {
+ f.b = s.doc.assembly.joints[2].id;
+ }
+ d
+}
+
+fn check_form(command: &str, labels: &[&str]) {
+ let mut h = fixture();
+ let mut d = representative(&h, command);
+ assert_eq!(super::command(&d.kind), Some(command));
+ let spec = solidcraft_engine::find_command(command).unwrap();
+ assert!(!spec.icon.is_empty());
+ let expected = apply_commands(&h.app, &d).unwrap_or_else(|e| panic!("{command}: representative parameters: {e}"));
+ // Rendering must never discard an optional/default value or add a new parameter.
+ for _ in 0..3 {
+ scenario::clear_handles();
+ let mut out = h.ctx.run_ui(
+ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 1600.0))), ..Default::default() },
+ |ui| {
+ ui.set_width(264.0);
+ ui_kit::scope(ui, |ui| {
+ ui_kit::header(ui, spec.icon, tr(spec.label), || {});
+ rows(&mut h.app, &h.ctx, &mut d, ui);
+ ui_kit::footer(ui, "OK", "Cancel", true, None);
+ });
+ },
+ );
+ out.textures_delta.clear();
+ h.output = out.platform_output;
+ }
+ let nodes = &h.output.accesskit_update.as_ref().unwrap().nodes;
+ for input in &d.inputs {
+ assert!(scenario::rect_of(&format!("dialog:field:{}", input.label)).is_some(), "{command}: selection field {}", input.label);
+ assert!(
+ nodes.iter().any(|(_, n)| n.role() == egui::accesskit::Role::Button && n.label() == Some(input.label)),
+ "{command}: picker {} is a button",
+ input.label
+ );
+ }
+ for label in labels {
+ if let Some(role) = control_role(command, label) {
+ if *label == "Animate" || *label == "Radius" && command == "joint.rack_pinion" {
+ let control = scenario::rect_of(&format!("dialog:control:{label}")).unwrap();
+ assert!(
+ nodes.iter().any(|(_, n)| n.role() == role
+ && n.bounds().is_some_and(|b| control.contains(egui::pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32)))),
+ "{command}: {label} uses {role:?}"
+ );
+ continue;
+ }
+ assert!(nodes.iter().any(|(_, n)| n.role() == role && n.label() == Some(tr(label))), "{command}: {label} uses {role:?}");
+ }
+ }
+ let checks: &[&str] = match command {
+ "solid.shell" => &["Tangent Chain"],
+ "solid.rib" | "solid.web" | "solid.align" | "sheet.flange" | "sheet.hem" | "sheet.fold" | "joint.create" => &["Flip"],
+ "solid.move" => &["Create Copy"],
+ "solid.combine" => &["Keep Tools", "New Component"],
+ "solid.thread" => &["Modeled", "Full Length", "Automatic size"],
+ "solid.boundary_fill" => &["Remove Tools"],
+ "surface.offset" => &["Tangent chain"],
+ "surface.trim" => &["Extend to meet", "Stitch the kept pieces"],
+ "surface.ruled" => &["Flip"],
+ "surface.untrim" => &["Restore outer boundary", "In place (surfaces)"],
+ "component.create" => &["Activate"],
+ "joint.gear" => &["Reverse", "Internal gear"],
+ "joint.rack_pinion" | "joint.screw" => &["Reverse"],
+ "joint.cam" => &["Other side"],
+ _ => &[],
+ };
+ for label in checks {
+ assert!(nodes.iter().any(|(_, n)| n.role() == egui::accesskit::Role::CheckBox && n.label() == Some(*label)), "{command}: option {label}");
+ }
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(1.0), "{command}");
+ assert_eq!(apply_commands(&h.app, &d).unwrap(), expected, "{command}: drawing is lossless");
+ let mut label_width: Option<f32> = None;
+ for label in d.inputs.iter().map(|i| i.label).chain(labels.iter().copied()) {
+ let row = scenario::rect_of(&format!("dialog:row:{label}")).unwrap_or_else(|| panic!("{command}: missing dense row {label}"));
+ let label_rect = scenario::rect_of(&format!("dialog:label:{label}")).unwrap();
+ let control = scenario::rect_of(&format!("dialog:control:{label}")).unwrap();
+ assert_eq!(row.height(), Tokens::get().control_height, "{command}: {label}");
+ // The label column is the design's width, widened to the longest label, equally for every row.
+ let t = Tokens::get();
+ assert!(label_rect.width() >= t.form_label_width && label_rect.width() <= t.form_label_width * 1.6, "{command}: {label}");
+ if let Some(first) = label_width {
+ assert_eq!(label_rect.width(), first, "{command}: {label} lines up with the other rows");
+ }
+ label_width = Some(label_rect.width());
+ assert!(row.contains_rect(control), "{command}: {label}");
+ assert!(scenario::handle_at(&format!("dialog:{label}")).is_some() || scenario::rect_of(&format!("dialog:control:{label}")).is_some());
+ }
+ assert!(scenario::rect_of("dialog:footer").is_some());
+ assert!(scenario::handle_at("dialog:ok").is_some());
+ assert!(scenario::handle_at("dialog:cancel").is_some());
+ let mut out = h.ctx.run_ui(egui::RawInput::default(), |ui| {
+ ui_kit::scope(ui, |ui| {
+ assert_eq!(ui_kit::footer(ui, "OK", "Cancel", false, None), ui_kit::Action::None);
+ });
+ });
+ out.textures_delta.clear();
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0), "{command}");
+}
+
+fn control_role(command: &str, label: &str) -> Option<egui::accesskit::Role> {
+ use egui::accesskit::Role;
+ Some(match label {
+ "Type" if matches!(command, "sheet.flange" | "sheet.hem" | "solid.revolve" | "solid.emboss") => return None,
+ "Direction" => return None, // segmented buttons, labelled by each choice
+ "Continuity" | "Corners" | "Cells" | "Profile" => return None,
+ "Operation" if command == "solid.mirror" => return None,
+ "Operation" | "Type" | "Orientation" | "Move Type" | "Object Type" | "Rule" | "Rim Edge" | "Catch Direction" | "Shape" | "Holes" | "Size"
+ | "Bend Line Position" | "From Snap" | "To Snap" | "Joint" | "Joint 1" | "Joint 2" | "Gear 1" | "Gear 2" | "Pinion" | "Rack" | "Screw"
+ | "Nut" | "Cam" | "Follower" => Role::ComboBox,
+ "Radius" if command == "joint.rack_pinion" => Role::Label,
+ "Pitch" if command == "solid.thread" => Role::ComboBox,
+ "Automatic size" | "Reverse" | "Other side" => Role::CheckBox,
+ "Animate" => Role::Button,
+ "Ratio" if command.starts_with("joint.") && command != "joint.motion_link" => return None,
+ _ => Role::TextInput,
+ })
+}
+
+macro_rules! form_case {
+ ($name:ident, $command:literal, [$($label:literal),*]) => {
+ #[test] fn $name() { check_form($command, &[$($label),*]); }
+ };
+}
+form_case!(revolve, "solid.revolve", ["Angle", "Direction", "Type"]);
+form_case!(shell, "solid.shell", ["Thickness", "Direction"]);
+form_case!(draft, "solid.draft", ["Angle"]);
+form_case!(mirror, "solid.mirror", ["Operation"]);
+form_case!(loft, "solid.loft", ["Operation"]);
+form_case!(sweep, "solid.sweep", ["Orientation"]);
+form_case!(offset_plane, "construct.plane.offset", ["Distance"]);
+form_case!(midplane, "construct.plane.midplane", []);
+form_case!(mesh_convert, "mesh.convert", ["Tolerance"]);
+form_case!(axis_two_planes, "construct.axis.two_planes", []);
+form_case!(point_along_path, "construct.point.along_path", ["Position (0 to 1)"]);
+form_case!(angle_plane, "construct.plane.at_angle", ["Angle"]);
+form_case!(path_plane, "construct.plane.along_path", ["Position (0 to 1)"]);
+form_case!(split, "solid.split_body", []);
+form_case!(scale, "solid.scale", ["Scale factor"]);
+form_case!(offset_faces, "solid.offset_face", ["Distance"]);
+form_case!(move_copy, "solid.move", ["Move Type", "X Distance", "Y Distance", "Z Distance", "X Angle", "Y Angle", "Z Angle"]);
+form_case!(rib, "solid.rib", ["Direction", "Thickness", "Depth"]);
+form_case!(web, "solid.web", ["Direction", "Thickness", "Depth"]);
+form_case!(emboss, "solid.emboss", ["Depth", "Type"]);
+form_case!(replace_face, "solid.replace_face", []);
+form_case!(boundary_fill, "solid.boundary_fill", ["Cells", "Operation"]);
+form_case!(align, "solid.align", ["From Snap", "To Snap"]);
+form_case!(remove, "solid.remove", []);
+form_case!(path_pattern, "solid.pattern.path", ["Type", "Object Type", "Quantity", "Spacing"]);
+form_case!(pipe, "solid.pipe", ["Diameter", "Wall"]);
+form_case!(stock, "solid.bounding_solid", ["Margin"]);
+form_case!(thread, "solid.thread", ["Profile", "Size", "Pitch", "Designation"]);
+form_case!(primitive_box, "solid.box", ["length", "width", "height", "Operation"]);
+form_case!(cylinder, "solid.cylinder", ["diameter", "height", "Operation"]);
+form_case!(sphere, "solid.sphere", ["diameter", "Operation"]);
+form_case!(torus, "solid.torus", ["major", "minor", "Operation"]);
+form_case!(coil, "solid.coil", ["diameter", "revolutions", "pitch", "section_size", "Operation"]);
+form_case!(combine, "solid.combine", ["Operation"]);
+form_case!(surface_extrude, "surface.extrude", ["Distance", "Direction"]);
+form_case!(surface_revolve, "surface.revolve", ["Angle", "Direction"]);
+form_case!(surface_sweep, "surface.sweep", ["Orientation"]);
+form_case!(surface_loft, "surface.loft", []);
+form_case!(surface_patch, "surface.patch", ["Continuity"]);
+form_case!(surface_unstitch, "surface.unstitch", []);
+form_case!(surface_reverse, "surface.reverse_normal", []);
+form_case!(surface_offset, "surface.offset", ["Distance"]);
+form_case!(surface_ruled, "surface.ruled", ["Distance", "Type", "Corners"]);
+form_case!(surface_stitch, "surface.stitch", ["Tolerance"]);
+form_case!(thicken, "surface.thicken", ["Thickness", "Direction", "Operation"]);
+form_case!(surface_extend, "surface.extend", ["Distance"]);
+form_case!(surface_trim, "surface.trim", []);
+form_case!(surface_untrim, "surface.untrim", ["Holes"]);
+form_case!(split_face, "solid.split_face", []);
+form_case!(flange, "sheet.flange", ["Type", "Rule"]);
+form_case!(hem, "sheet.hem", ["Type", "Length", "ui.sheet_gap"]);
+form_case!(fold, "sheet.fold", ["Bend Line Position", "Angle", "Bend Radius"]);
+form_case!(unfold, "sheet.unfold", []);
+form_case!(refold, "sheet.refold", []);
+form_case!(sheet_convert, "sheet.convert", ["Rule"]);
+form_case!(boss, "plastic.boss", ["Diameter", "Height", "Hole Diameter", "Hole Depth"]);
+form_case!(lip, "plastic.lip", ["Type", "Rim Edge", "Width", "Height"]);
+form_case!(snap_fit, "plastic.snap_fit", ["Catch Direction", "Length", "Thickness", "Width", "Catch Depth", "Catch Length"]);
+form_case!(rest, "plastic.rest", ["Shape", "Diameter", "Height"]);
+form_case!(plastic_assign, "plastic.assign_rule", ["Rule"]);
+form_case!(component, "component.create", ["Name"]);
+form_case!(joint, "joint.create", ["Type", "Angle"]);
+form_case!(as_built, "joint.as_built", ["Type"]);
+form_case!(joint_origin, "joint.origin", ["Name"]);
+form_case!(rigid_group, "joint.rigid_group", []);
+form_case!(motion_link, "joint.motion_link", ["Joint 1", "Joint 2", "Ratio", "Offset"]);
+form_case!(gear, "joint.gear", ["Gear 1", "Radius 1", "Gear 2", "Radius 2", "Ratio", "Animate"]);
+form_case!(rack, "joint.rack_pinion", ["Pinion", "Radius", "Rack", "Ratio", "Animate"]);
+form_case!(screw, "joint.screw", ["Screw", "Nut", "Pitch", "Ratio", "Animate"]);
+form_case!(cam, "joint.cam", ["Cam", "Follower", "Type", "Animate"]);
+form_case!(trace, "motion.trace", ["Joint", "From", "To", "Samples"]);
+
+#[test]
+fn registry_dialog_inventory_has_no_unclassified_feature_forms() {
+ let h = fixture();
+ for spec in solidcraft_engine::command_specs() {
+ let Some(d) = Dialog::for_command(&h.app, spec.id) else { continue };
+ let excluded = matches!(
+ d.kind,
+ Kind::Params { .. }
+ | Kind::Rename { .. }
+ | Kind::ConfirmDelete { .. }
+ | Kind::Measure { .. }
+ | Kind::Material { .. }
+ | Kind::Section { .. }
+ | Kind::SaveMesh(_)
+ | Kind::ViewDxf { .. }
+ | Kind::Appearance(_)
+ | Kind::Motion(_)
+ | Kind::Part(_)
+ | Kind::Sheet(crate::dialogs_sheet::Sm::Rules { .. } | crate::dialogs_sheet::Sm::FlatPattern { .. })
+ | Kind::Plastic(crate::dialogs_plastic::Pl::Rules { .. })
+ | Kind::Assembly(crate::dialogs_assembly::Asm::Drive { .. } | crate::dialogs_assembly::Asm::Interference { .. })
+ );
+ assert_eq!(super::command(&d.kind).is_some(), !excluded, "{}: {:?}", spec.id, d.kind);
+ }
+}
+
+#[test]
+fn new_cards_settle_before_the_first_click_in_both_layouts() {
+ for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
+ for command in ["solid.box", "solid.revolve", "solid.shell", "joint.create"] {
+ let mut h = fixture();
+ h.call("ui.set", json!({"layout":mode}));
+ h.call("ui.resize", json!({"width":1400,"height":950}));
+ h.app.dialog = Some(representative(&h, command));
+ h.frames(2);
+ let first = scenario::rect_of("dialog:footer").unwrap();
+ h.frames(1);
+ let settled = scenario::rect_of("dialog:footer").unwrap();
+ assert_eq!(first, settled, "{command} {mode:?}: footer moved under the first click");
+ }
+ }
+}
diff --git a/crates/ui-egui/src/dialogs_assembly.rs b/crates/ui-egui/src/dialogs_assembly.rs
index 16270ba85b..7255ec5978 100644
--- a/crates/ui-egui/src/dialogs_assembly.rs
+++ b/crates/ui-egui/src/dialogs_assembly.rs
@@ -5,6 +5,7 @@
//! before the click. Joints and drives preview on the placed (world) model: the moving
//! component shows where it goes, and with Animate the joint plays its motion.
+use crate::fonts::RichTextExt as _;
use egui::{Color32, Pos2, RichText, Stroke, vec2};
use serde_json::{Value, json};
use solidcraft_engine::Sel;
@@ -14,7 +15,7 @@ use solidcraft_engine::doc::joints::JointKind;
use solidcraft_engine::geom::{Aabb3, Mesh, Vec3};
use crate::SolveApp;
-use crate::dialogs::{Dialog, Kind, combo, field, row_label};
+use crate::dialogs::{Dialog, Kind, combo, field, form_row, row_label};
use crate::preview::{Built, Colors};
use crate::selection::{BODIES, EDGES, FACES, SelInput, VERTICES};
use crate::theme::Tokens;
@@ -518,13 +519,10 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
let problem = joint_problem(app, k, inputs);
match k {
Asm::NewComponent { name, activate } => {
- row_label(ui, "Name");
- let r = ui.add(egui::TextEdit::singleline(name).hint_text(crate::i18n::tr_label("Component1")));
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- row_label(ui, "Activate");
- ui.checkbox(activate, "");
- ui.end_row();
+ form_row(ui, "Name", |ui| {
+ enter |= crate::ui_kit::text_field(ui, name, crate::i18n::tr_label("Component1")).0;
+ });
+ crate::ui_kit::options(ui, "component_options", &mut [("Activate", activate)]);
}
Asm::Joint(f) => {
// As-built: two components picked, the position comes next.
@@ -533,63 +531,65 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
}
// Picks that make no joint say why, under them, and offer the way out (#1239).
if let Some((why, bodies)) = problem {
- row_label(ui, "");
ui.vertical(|ui| {
ui.add(egui::Label::new(RichText::new(why).color(t.warning)).wrap());
if !bodies.is_empty()
- && ui.button(crate::i18n::tr("cmd.component_from_bodies")).on_hover_text(crate::i18n::tr("joint.from_bodies_hint")).clicked()
+ && crate::ui_kit::secondary_button(ui, crate::i18n::tr("cmd.component_from_bodies"))
+ .on_hover_text(crate::i18n::tr("joint.from_bodies_hint"))
+ .clicked()
{
// A refusal shows on the status line; the picks stay either way.
let _ = app.run("component.from_bodies", json!({ "bodies": bodies }));
}
});
- ui.end_row();
}
- row_label(ui, "Motion");
- ui.label("");
- ui.end_row();
- row_label(ui, "Type");
- combo(ui, "jt_type", &TYPE_LABELS, &mut f.kind);
- ui.end_row();
+ form_row(ui, "Motion", |ui| {
+ ui.label("");
+ });
+ form_row(ui, "Type", |ui| {
+ combo(ui, "jt_type", &TYPE_LABELS, &mut f.kind);
+ });
f.fit_limits();
if !f.as_built {
- row_label(ui, "Angle");
- enter |= field(ui, &mut f.angle);
- ui.end_row();
- for (l, v) in ["Offset X", "Offset Y", "Offset Z"].iter().zip(f.offset.iter_mut()) {
- if f.editing.is_some() && *l != "Offset Z" {
- continue;
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, &mut f.angle);
+ });
+ crate::ui_kit::section(ui, "joint_position", "Position", false, |ui| {
+ for (l, v) in ["Offset X", "Offset Y", "Offset Z"].iter().zip(f.offset.iter_mut()) {
+ if f.editing.is_some() && *l != "Offset Z" {
+ continue;
+ }
+ form_row(ui, l, |ui| {
+ enter |= field(ui, v);
+ });
}
- row_label(ui, l);
- enter |= field(ui, v);
- ui.end_row();
- }
- row_label(ui, "Flip");
- ui.checkbox(&mut f.flip, "");
- ui.end_row();
+ });
+ crate::ui_kit::options(ui, "joint_options", &mut [("Flip", &mut f.flip)]);
}
let kind = f.joint_kind();
if kind != JointKind::Rigid {
- row_label(ui, "Animate");
- let label = if f.animate { "■ Stop" } else { "▶ Play" };
- if ui.button(label).on_hover_text("Play the joint's motion in the view").clicked() {
- f.animate = !f.animate;
- }
- ui.end_row();
- for (i, (on, lo, hi)) in f.limits.iter_mut().enumerate() {
- let name = kind.dofs().get(i).copied().unwrap_or("value");
- row_label(ui, &format!("{} limits", capital(name)));
- ui.checkbox(on, "");
- ui.end_row();
- if *on {
- row_label(ui, " Minimum");
- enter |= field(ui, lo);
- ui.end_row();
- row_label(ui, " Maximum");
- enter |= field(ui, hi);
- ui.end_row();
+ form_row(ui, "Animate", |ui| {
+ let label = if f.animate { "■ Stop" } else { "▶ Play" };
+ if crate::ui_kit::secondary_button(ui, label).on_hover_text("Play the joint's motion in the view").clicked() {
+ f.animate = !f.animate;
}
- }
+ });
+ crate::ui_kit::section(ui, "joint_limits", "Limits", false, |ui| {
+ for (i, (on, lo, hi)) in f.limits.iter_mut().enumerate() {
+ let name = kind.dofs().get(i).copied().unwrap_or("value");
+ form_row(ui, &format!("{} limits", capital(name)), |ui| {
+ crate::ui_kit::checkbox(ui, "", on);
+ });
+ if *on {
+ form_row(ui, " Minimum", |ui| {
+ enter |= field(ui, lo);
+ });
+ form_row(ui, " Maximum", |ui| {
+ enter |= field(ui, hi);
+ });
+ }
+ }
+ });
} else {
f.animate = false;
}
@@ -601,10 +601,9 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
}
}
Asm::JointOrigin { name, .. } => {
- row_label(ui, "Name");
- let r = ui.add(egui::TextEdit::singleline(name).hint_text(crate::i18n::tr_label("Joint Origin1")));
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
+ form_row(ui, "Name", |ui| {
+ enter |= crate::ui_kit::text_field(ui, name, crate::i18n::tr_label("Joint Origin1")).0;
+ });
}
Asm::RigidGroup => {}
Asm::Drive { joint, values, focus } => {
@@ -677,7 +676,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
row_label(ui, "");
ui.label(
RichText::new(format!("{} … {}{}", fmt(lo), fmt(hi), if limited { " (limits)" } else { " (no limits)" }))
- .size(11.0)
+ .size(crate::theme::Tokens::get().font_small)
.color(if limited { t.text } else { t.text_dim }),
);
ui.end_row();
@@ -694,50 +693,50 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
let s = &app.session;
let joints = &s.doc.assembly.joints;
if joints.len() < 2 {
- row_label(ui, "");
- ui.label(RichText::new(crate::i18n::tr_label("needs two joints")).color(t.text_dim));
- ui.end_row();
+ form_row(ui, "", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("needs two joints")).color(t.text_dim));
+ });
return false;
}
let labels: Vec<&str> = joints.iter().map(|j| j.name.as_str()).collect();
for (l, sel, idx, id) in [("Joint 1", &mut *a, &mut *ia, "ml_a"), ("Joint 2", &mut *b, &mut *ib, "ml_b")] {
- row_label(ui, l);
- combo(ui, id, &labels, sel);
- ui.end_row();
+ form_row(ui, l, |ui| {
+ combo(ui, id, &labels, sel);
+ });
let dofs = joints.get(*sel).map(|j| j.kind.dofs()).unwrap_or(&[]);
if dofs.len() > 1 {
- row_label(ui, " Value");
- let caps: Vec<String> = dofs.iter().map(|d| capital(d)).collect();
- let refs: Vec<&str> = caps.iter().map(String::as_str).collect();
- combo(ui, &format!("{id}_i"), &refs, idx);
- ui.end_row();
+ form_row(ui, " Value", |ui| {
+ let caps: Vec<String> = dofs.iter().map(|d| capital(d)).collect();
+ let refs: Vec<&str> = caps.iter().map(String::as_str).collect();
+ combo(ui, &format!("{id}_i"), &refs, idx);
+ });
} else {
*idx = 0;
}
}
- row_label(ui, "Ratio");
- enter |= field(ui, ratio);
- ui.end_row();
- row_label(ui, "Offset");
- enter |= field(ui, offset);
- ui.end_row();
+ form_row(ui, "Ratio", |ui| {
+ enter |= field(ui, ratio);
+ });
+ form_row(ui, "Offset", |ui| {
+ enter |= field(ui, offset);
+ });
}
Asm::Coupling(f) => enter |= crate::dialogs_coupling::rows(app, ui, f, inputs),
Asm::Cam(f) => enter |= crate::dialogs_coupling::cam::rows(app, ui, f, inputs),
Asm::Interference { result, overlaps, of, clearance } => {
let picked: Vec<Sel> = inputs.first().map(|i| i.items.clone()).unwrap_or_default();
- row_label(ui, "Clearance");
- field(ui, clearance);
- ui.end_row();
- row_label(ui, "");
- let stale = result.is_some() && *of != picked;
- if ui.button(crate::i18n::tr(if stale { "dialog.compute_again" } else { "dialog.compute" })).clicked() {
- let (r, o) = interference(app, &picked, clearance);
- *result = Some(r);
- *overlaps = o;
- *of = picked;
- }
- ui.end_row();
+ form_row(ui, "Clearance", |ui| {
+ enter |= field(ui, clearance);
+ });
+ form_row(ui, "", |ui| {
+ let stale = result.is_some() && *of != picked;
+ if crate::ui_kit::secondary_button(ui, crate::i18n::tr(if stale { "dialog.compute_again" } else { "dialog.compute" })).clicked() {
+ let (r, o) = interference(app, &picked, clearance);
+ *result = Some(r);
+ *overlaps = o;
+ *of = picked;
+ }
+ });
if let Some(r) = result.as_ref() {
interference_rows(app, ui, r);
}
@@ -785,65 +784,66 @@ fn interference(app: &mut SolveApp, picked: &[Sel], clearance: &str) -> (Value,
fn interference_rows(app: &SolveApp, ui: &mut egui::Ui, r: &Value) {
let t = Tokens::get();
if let Some(e) = r.get("error").and_then(Value::as_str) {
- row_label(ui, "");
- ui.label(RichText::new(e).color(t.error));
- ui.end_row();
+ form_row(ui, "", |ui| {
+ ui.label(RichText::new(e).color(t.error));
+ });
return;
}
let hits = r["overlaps"].as_array().cloned().unwrap_or_default();
- row_label(ui, "Checked");
- ui.label(crate::i18n::format("dialog.bodies_count", &[("count", &r["bodies"].as_u64().unwrap_or(0).to_string())]));
- ui.end_row();
+ form_row(ui, "Checked", |ui| {
+ ui.label(crate::i18n::format("dialog.bodies_count", &[("count", &r["bodies"].as_u64().unwrap_or(0).to_string())]));
+ });
let unchecked = r["unchecked"].as_array().cloned().unwrap_or_default();
let near = r["near"].as_array().cloned().unwrap_or_default();
let pair = |h: &Value| format!("{} · {}", h["a"].as_str().unwrap_or(""), h["b"].as_str().unwrap_or(""));
if hits.is_empty() && unchecked.is_empty() {
- row_label(ui, "Result");
- ui.label(RichText::new(crate::i18n::tr_label("no interference")).color(t.text_dim));
- ui.end_row();
+ form_row(ui, "Result", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("no interference")).color(t.text_dim));
+ });
}
// Pairs closer than the clearance, nearest first.
if !near.is_empty() {
- row_label(ui, "Too close");
- ui.label(RichText::new(crate::i18n::tr("ui.distance")).strong());
- ui.end_row();
+ form_row(ui, "Too close", |ui| {
+ ui.label(RichText::new(crate::i18n::tr("ui.distance")).semibold().color(crate::theme::Tokens::get().text));
+ });
}
for h in &near {
- row_label(ui, &pair(h));
- ui.label(RichText::new(crate::prefs::show_mm(app, h["distance_mm"].as_f64().unwrap_or(0.0), 1)).color(t.warning));
- ui.end_row();
+ form_row(ui, &pair(h), |ui| {
+ ui.label(RichText::new(crate::prefs::show_mm(app, h["distance_mm"].as_f64().unwrap_or(0.0), 1)).color(t.warning));
+ });
}
// Each body's nearest neighbour.
let nearest = r["nearest"].as_object().cloned().unwrap_or_default();
if !nearest.is_empty() {
- row_label(ui, "Nearest");
- ui.label(RichText::new(crate::i18n::tr("ui.distance")).strong());
- ui.end_row();
+ form_row(ui, "Nearest", |ui| {
+ ui.label(RichText::new(crate::i18n::tr("ui.distance")).semibold().color(crate::theme::Tokens::get().text));
+ });
}
for (body, list) in &nearest {
let Some(n) = list.get(0) else { continue };
- row_label(ui, &format!("{body} → {}", n["body"].as_str().unwrap_or("")));
- ui.label(crate::prefs::show_mm(app, n["distance_mm"].as_f64().unwrap_or(0.0), 1));
- ui.end_row();
+ form_row(ui, &format!("{body} → {}", n["body"].as_str().unwrap_or("")), |ui| {
+ ui.label(crate::prefs::show_mm(app, n["distance_mm"].as_f64().unwrap_or(0.0), 1));
+ });
}
if hits.is_empty() && unchecked.is_empty() {
return;
}
if !hits.is_empty() {
- row_label(ui, "Interferes");
- ui.label(RichText::new(crate::i18n::tr_label("Volume")).strong());
- ui.end_row();
+ form_row(ui, "Interferes", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("Volume")).semibold().color(crate::theme::Tokens::get().text));
+ });
}
for h in hits {
- row_label(ui, &format!("{} · {}", h["a"].as_str().unwrap_or(""), h["b"].as_str().unwrap_or("")));
- ui.label(RichText::new(crate::prefs::show_mm(app, h["volume_mm3"].as_f64().unwrap_or(0.0), 3)).color(t.error));
- ui.end_row();
+ form_row(ui, &format!("{} · {}", h["a"].as_str().unwrap_or(""), h["b"].as_str().unwrap_or("")), |ui| {
+ ui.label(RichText::new(crate::prefs::show_mm(app, h["volume_mm3"].as_f64().unwrap_or(0.0), 3)).color(t.error));
+ });
}
// Pairs the check could not work out: not clear, not known to interfere.
for u in unchecked {
- row_label(ui, &format!("{} · {}", u["a"].as_str().unwrap_or(""), u["b"].as_str().unwrap_or("")));
- ui.label(RichText::new(crate::i18n::tr("dialog.could_not_be_checked")).color(t.warning)).on_hover_text(u["reason"].as_str().unwrap_or(""));
- ui.end_row();
+ form_row(ui, &format!("{} · {}", u["a"].as_str().unwrap_or(""), u["b"].as_str().unwrap_or("")), |ui| {
+ ui.label(RichText::new(crate::i18n::tr("dialog.could_not_be_checked")).color(t.warning))
+ .on_hover_text(u["reason"].as_str().unwrap_or(""));
+ });
}
}
@@ -1297,7 +1297,7 @@ pub fn timeline_joints_vertical(app: &mut SolveApp, ui: &mut egui::Ui) {
return;
}
ui.add_space(4.0);
- ui.label(egui::RichText::new("JOINTS").size(10.0).strong().color(t.text_dim));
+ ui.label(egui::RichText::new("JOINTS").size(crate::theme::Tokens::get().font_micro).semibold().color(t.text_dim));
let mut open = None;
let mut run = None;
for (id, name, kind, suppressed) in joints {
@@ -1317,7 +1317,7 @@ pub fn timeline_joints_vertical(app: &mut SolveApp, ui: &mut egui::Ui) {
egui::pos2(icon.right() + 7.0, rect.center().y),
egui::Align2::LEFT_CENTER,
&name,
- egui::FontId::proportional(12.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_body),
if suppressed { t.text_dim } else { t.text },
);
let response = response.on_hover_text(format!("{name} ({kind:?} joint)\nDouble-click to edit · right-click for more"));
diff --git a/crates/ui-egui/src/dialogs_assembly_tests.rs b/crates/ui-egui/src/dialogs_assembly_tests.rs
index d163db67e8..8dbcfe3e51 100644
--- a/crates/ui-egui/src/dialogs_assembly_tests.rs
+++ b/crates/ui-egui/src/dialogs_assembly_tests.rs
@@ -215,7 +215,7 @@ fn ok_click_survives_a_busy_preview() {
f.animate = true;
}
app.dialog = Some(d);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0));
let frame = |app: &mut SolveApp, busy: bool, events: Vec<egui::Event>| {
app.preview.busy = busy;
@@ -267,7 +267,7 @@ fn picks_on_one_component_say_why_and_offer_components() {
d.pick(&app.session, face_sel(&app.session, Vec3::new(40.0, 10.0, 0.0)).unwrap());
assert!(apply_commands(&app, &d).is_err(), "one component: no joint");
app.dialog = Some(d);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0));
let frame = |app: &mut SolveApp, events: Vec<egui::Event>| {
let input = egui::RawInput { screen_rect: Some(screen), events, ..Default::default() };
@@ -335,7 +335,7 @@ fn drive_value_takes_the_keyboard() {
app.run("joint.create", json!({"type": "revolute", "a": {"occurrence": a, "face": [10, 10, 10]}, "b": {"occurrence": b, "face": [40, 10, 0]}}))
.unwrap();
app.start("joint.drive");
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0));
let frame = |app: &mut SolveApp, events: Vec<egui::Event>| {
let input = egui::RawInput { screen_rect: Some(screen), events, ..Default::default() };
diff --git a/crates/ui-egui/src/dialogs_cam.rs b/crates/ui-egui/src/dialogs_cam.rs
index 983e87795b..25885d30fa 100644
--- a/crates/ui-egui/src/dialogs_cam.rs
+++ b/crates/ui-egui/src/dialogs_cam.rs
@@ -12,7 +12,7 @@ use solidcraft_engine::doc::joints::JointKind;
use super::{ROUND, joint_row, occurrence, pick, picked_radius, trim, turn};
use crate::SolveApp;
-use crate::dialogs::{check, combo, field, row_label};
+use crate::dialogs::{combo, field, form_row};
use crate::dialogs_assembly::Asm;
use crate::selection::{EDGES, FACES, PROFILES, SelInput, VERTICES};
use crate::theme::Tokens;
@@ -85,9 +85,9 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CamForm, inputs: &[Se
let s = &app.session;
let (cams, followers) = (joints_of(s, &[JointKind::Revolute]), joints_of(s, &[JointKind::Slider, JointKind::Revolute]));
if cams.is_empty() || followers.len() < 2 && followers.iter().all(|j| cams.iter().any(|c| c.0 == j.0)) {
- row_label(ui, "");
- ui.label(RichText::new(crate::i18n::tr_label("needs a joint that turns and one that slides or swings")).color(t.text_dim));
- ui.end_row();
+ form_row(ui, "", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("needs a joint that turns and one that slides or swings")).color(t.text_dim));
+ });
return false;
}
// A profile picked on a part chooses the joint that part turns on, once.
@@ -107,13 +107,12 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CamForm, inputs: &[Se
let mut enter = false;
joint_row(ui, "Cam", "cam_a", &cams, &mut f.a);
joint_row(ui, "Follower", "cam_b", &followers, &mut f.b);
- row_label(ui, "Type");
- let labels: Vec<&str> = FOLLOWER_LABELS.iter().map(|l| crate::i18n::tr_label(l)).collect();
- combo(ui, "cam_follower", &labels, &mut f.follower);
- ui.end_row();
+ form_row(ui, "Type", |ui| {
+ let labels: Vec<&str> = FOLLOWER_LABELS.iter().map(|l| crate::i18n::tr_label(l)).collect();
+ combo(ui, "cam_follower", &labels, &mut f.follower);
+ });
if FOLLOWERS.get(f.follower) == Some(&"roller") {
- row_label(ui, "Radius");
- match (pick(inputs, ROLLER), picked_radius(s, inputs, ROLLER)) {
+ form_row(ui, "Radius", |ui| match (pick(inputs, ROLLER), picked_radius(s, inputs, ROLLER)) {
(_, Some(r)) => {
ui.label(format!("{} mm ({})", trim(r), crate::i18n::tr_label("picked")));
}
@@ -121,20 +120,17 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CamForm, inputs: &[Se
ui.label(RichText::new(crate::i18n::tr_label("not a round face")).color(t.warning));
}
(None, None) => enter |= field(ui, &mut f.radius),
- }
- ui.end_row();
- }
- row_label(ui, "Other side");
- check(ui, &mut f.flip);
- ui.end_row();
- row_label(ui, "Animate");
- let label = if f.animate { "■ Stop" } else { "▶ Play" };
- let r = ui.button(label).on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
- crate::scenario::publish_handle("dialog:Animate", r.rect.center());
- if r.clicked() {
- f.animate = !f.animate;
+ });
}
- ui.end_row();
+ crate::ui_kit::options(ui, "cam_options", &mut [("Other side", &mut f.flip)]);
+ form_row(ui, "Animate", |ui| {
+ let label = if f.animate { "■ Stop" } else { "▶ Play" };
+ let r = crate::ui_kit::secondary_button(ui, label).on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
+ crate::scenario::publish_handle("dialog:Animate", r.rect.center());
+ if r.clicked() {
+ f.animate = !f.animate;
+ }
+ });
if f.animate {
let now = ui.input(|i| i.time);
// 72 steps over 6 s: each one a preview.
diff --git a/crates/ui-egui/src/dialogs_cam_tests.rs b/crates/ui-egui/src/dialogs_cam_tests.rs
index dd8808e729..47df9f9347 100644
--- a/crates/ui-egui/src/dialogs_cam_tests.rs
+++ b/crates/ui-egui/src/dialogs_cam_tests.rs
@@ -67,7 +67,7 @@ fn a_picked_cam_edge_makes_the_cam() {
let pick = edge(&app, Vec3::new(-20.0, 0.0, 5.0));
d.pick(&app.session, pick);
app.dialog = Some(d);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
for _ in 0..3 {
let input =
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() };
diff --git a/crates/ui-egui/src/dialogs_coupling.rs b/crates/ui-egui/src/dialogs_coupling.rs
index bcb03d6bf6..eb299666f2 100644
--- a/crates/ui-egui/src/dialogs_coupling.rs
+++ b/crates/ui-egui/src/dialogs_coupling.rs
@@ -11,7 +11,7 @@ use solidcraft_engine::Session;
use solidcraft_engine::doc::expr::Kind as ValueKind;
use crate::SolveApp;
-use crate::dialogs::{check, combo, field, row_label};
+use crate::dialogs::{combo, field, form_row};
use crate::dialogs_assembly::Asm;
use crate::selection::{EDGES, FACES, SelInput};
use crate::theme::Tokens;
@@ -119,9 +119,9 @@ fn size(s: &Session, f: &CouplingForm, inputs: &[SelInput], i: usize) -> Option<
fn joint_row(ui: &mut egui::Ui, label: &str, salt: &str, list: &[(u64, String)], sel: &mut u64) {
let labels: Vec<&str> = list.iter().map(|j| j.1.as_str()).collect();
let mut pos = list.iter().position(|j| j.0 == *sel).unwrap_or(0);
- row_label(ui, label);
- combo(ui, salt, &labels, &mut pos);
- ui.end_row();
+ form_row(ui, label, |ui| {
+ combo(ui, salt, &labels, &mut pos);
+ });
*sel = list.get(pos).map(|j| j.0).unwrap_or(0);
}
@@ -132,10 +132,10 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
let ([role_a, role_b], turn_b) = roles(f.command);
let (la, lb) = (joints_that(s, true), joints_that(s, turn_b));
if la.is_empty() || lb.is_empty() {
- row_label(ui, "");
- let need = if turn_b { "needs two joints that turn" } else { "needs a joint that turns and one that slides" };
- ui.label(RichText::new(crate::i18n::tr_label(need)).color(t.text_dim));
- ui.end_row();
+ form_row(ui, "", |ui| {
+ let need = if turn_b { "needs two joints that turn" } else { "needs a joint that turns and one that slides" };
+ ui.label(RichText::new(crate::i18n::tr_label(need)).color(t.text_dim));
+ });
return false;
}
// A face picked on a part chooses the joint that part turns on, once.
@@ -157,18 +157,18 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
}
let mut enter = false;
let size_row = |ui: &mut egui::Ui, label: &str, i: usize, text: &mut String, enter: &mut bool| {
- row_label(ui, label);
- match (pick(inputs, i), picked_radius(s, inputs, i)) {
- (_, Some(r)) => {
- ui.label(format!("{} mm ({})", trim(r), crate::i18n::tr_label("picked")));
- }
- // A pick on a flat face or a straight edge has no radius: say so rather than fail on OK.
- (Some(_), None) => {
- ui.label(RichText::new(crate::i18n::tr_label("not a round face")).color(t.warning));
+ form_row(ui, label, |ui| {
+ match (pick(inputs, i), picked_radius(s, inputs, i)) {
+ (_, Some(r)) => {
+ ui.label(format!("{} mm ({})", trim(r), crate::i18n::tr_label("picked")));
+ }
+ // A pick on a flat face or a straight edge has no radius: say so rather than fail on OK.
+ (Some(_), None) => {
+ ui.label(RichText::new(crate::i18n::tr_label("not a round face")).color(t.warning));
+ }
+ (None, None) => *enter |= field(ui, text),
}
- (None, None) => *enter |= field(ui, text),
- }
- ui.end_row();
+ });
};
joint_row(ui, role_a, "cp_a", &la, &mut f.a);
let [s0, s1] = &mut f.sizes;
@@ -177,9 +177,6 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
size_row(ui, "Radius 1", 0, s0, &mut enter);
joint_row(ui, role_b, "cp_b", &lb, &mut f.b);
size_row(ui, "Radius 2", 1, s1, &mut enter);
- row_label(ui, "Internal gear");
- check(ui, &mut f.internal);
- ui.end_row();
}
"joint.rack_pinion" => {
size_row(ui, "Radius", 0, s0, &mut enter);
@@ -187,14 +184,16 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
}
_ => {
joint_row(ui, role_b, "cp_b", &lb, &mut f.b);
- row_label(ui, "Pitch");
- enter |= field(ui, s0);
- ui.end_row();
+ form_row(ui, "Pitch", |ui| {
+ enter |= field(ui, s0);
+ });
}
}
- row_label(ui, "Reverse");
- check(ui, &mut f.reverse);
- ui.end_row();
+ if f.command == "joint.gear" {
+ crate::ui_kit::options(ui, "coupling_options", &mut [("Internal gear", &mut f.internal), ("Reverse", &mut f.reverse)]);
+ } else {
+ crate::ui_kit::options(ui, "coupling_options", &mut [("Reverse", &mut f.reverse)]);
+ }
// What the coupling does, as joint.list gives a link's ratio.
let sign = |neg: bool| if neg { -1.0 } else { 1.0 };
let shown = match f.command {
@@ -204,17 +203,17 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
"joint.rack_pinion" => size(s, f, inputs, 0).map(|r| format!("{} mm / deg", trim(r.to_radians() * sign(f.reverse)))),
_ => size(s, f, inputs, 0).map(|p| format!("{} mm / deg", trim(p / 360.0 * sign(f.reverse)))),
};
- row_label(ui, "Ratio");
- ui.label(RichText::new(shown.unwrap_or_else(|| "-".into())).color(t.text_dim));
- ui.end_row();
- row_label(ui, "Animate");
- let label = if f.animate { "■ Stop" } else { "▶ Play" };
- let r = ui.button(label).on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
- crate::scenario::publish_handle("dialog:Animate", r.rect.center());
- if r.clicked() {
- f.animate = !f.animate;
- }
- ui.end_row();
+ form_row(ui, "Ratio", |ui| {
+ ui.label(RichText::new(shown.unwrap_or_else(|| "-".into())).color(t.text_dim));
+ });
+ form_row(ui, "Animate", |ui| {
+ let label = if f.animate { "■ Stop" } else { "▶ Play" };
+ let r = crate::ui_kit::secondary_button(ui, label).on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
+ crate::scenario::publish_handle("dialog:Animate", r.rect.center());
+ if r.clicked() {
+ f.animate = !f.animate;
+ }
+ });
if f.animate {
let now = ui.input(|i| i.time);
// 48 steps over 4 s: each one a preview.
diff --git a/crates/ui-egui/src/dialogs_coupling_tests.rs b/crates/ui-egui/src/dialogs_coupling_tests.rs
index 206d3467ae..0d24b5faaf 100644
--- a/crates/ui-egui/src/dialogs_coupling_tests.rs
+++ b/crates/ui-egui/src/dialogs_coupling_tests.rs
@@ -72,7 +72,7 @@ fn picked_gear_faces_choose_their_joints_and_radii() {
d.pick(&app.session, pick);
}
app.dialog = Some(d);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0));
let frame = |app: &mut SolveApp| {
let input = egui::RawInput { screen_rect: Some(screen), ..Default::default() };
@@ -134,7 +134,7 @@ fn instances_of_one_gear_are_coupled_as_two() {
d.pick(&app.session, pick);
}
app.dialog = Some(d);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
for _ in 0..2 {
let input =
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() };
diff --git a/crates/ui-egui/src/dialogs_dense.rs b/crates/ui-egui/src/dialogs_dense.rs
new file mode 100644
index 0000000000..54d5dec070
--- /dev/null
+++ b/crates/ui-egui/src/dialogs_dense.rs
@@ -0,0 +1,1110 @@
+//! Dense ports of the common feature forms. Commands and parameter construction stay in dialogs.
+use super::*;
+use crate::ui_kit;
+
+pub(super) fn command(kind: &Kind) -> Option<&'static str> {
+ match kind {
+ Kind::Sketch => Some("sketch.create"),
+ Kind::SketchModify(k) => Some(crate::sketch_modify_ui::command(k)),
+ Kind::Text(_) => Some("sketch.edit_text"),
+ Kind::TextMove(_) => Some("sketch.move"),
+ Kind::EditParam { .. } => Some("parameters.change"),
+ Kind::Extrude { .. } => Some("solid.extrude"),
+ Kind::Fillet { chamfer, .. } => Some(if *chamfer { "solid.chamfer" } else { "solid.fillet" }),
+ Kind::Hole { .. } => Some("solid.hole"),
+ Kind::PatternRect { .. } => Some("solid.pattern.rectangular"),
+ Kind::PatternCirc { .. } => Some("solid.pattern.circular"),
+ Kind::Revolve { .. } => Some("solid.revolve"),
+ Kind::Shell { .. } => Some("solid.shell"),
+ Kind::Draft { .. } => Some("solid.draft"),
+ Kind::Mirror => Some("solid.mirror"),
+ Kind::Loft { .. } => Some("solid.loft"),
+ Kind::Sweep { .. } => Some("solid.sweep"),
+ Kind::OffsetPlane { .. } => Some("construct.plane.offset"),
+ Kind::Midplane => Some("construct.plane.midplane"),
+ Kind::MeshConvert { .. } => Some("mesh.convert"),
+ Kind::Construct { command, .. } => Some(command),
+ Kind::AnglePlane { .. } => Some("construct.plane.at_angle"),
+ Kind::PathPlane { .. } => Some("construct.plane.along_path"),
+ Kind::Split => Some("solid.split_body"),
+ Kind::Scale { .. } => Some("solid.scale"),
+ Kind::OffsetFaces { .. } => Some("solid.offset_face"),
+ Kind::Move { .. } => Some("solid.move"),
+ Kind::Thread { .. } => Some("solid.thread"),
+ Kind::Emboss { .. } => Some("solid.emboss"),
+ Kind::ReplaceFace => Some("solid.replace_face"),
+ Kind::BoundaryFill { .. } => Some("solid.boundary_fill"),
+ Kind::Align { .. } => Some("solid.align"),
+ Kind::Remove => Some("solid.remove"),
+ Kind::PathPattern { .. } => Some("solid.pattern.path"),
+ Kind::Pipe { .. } => Some("solid.pipe"),
+ Kind::Stock { .. } => Some("solid.bounding_solid"),
+ Kind::Combine { .. } => Some("solid.combine"),
+ Kind::Rib { web, .. } => Some(if *web { "solid.web" } else { "solid.rib" }),
+ Kind::Primitive { cmd, .. } => Some(cmd),
+ Kind::Surface(k) => Some(match k {
+ crate::dialogs_surface::Surf::Extrude { .. } => "surface.extrude",
+ crate::dialogs_surface::Surf::Revolve { .. } => "surface.revolve",
+ crate::dialogs_surface::Surf::Sweep(_) => "surface.sweep",
+ crate::dialogs_surface::Surf::Loft { .. } => "surface.loft",
+ crate::dialogs_surface::Surf::Blend { .. } => "surface.blend",
+ crate::dialogs_surface::Surf::Boundary { .. } => "surface.boundary",
+ crate::dialogs_surface::Surf::Patch { .. } => "surface.patch",
+ crate::dialogs_surface::Surf::Unstitch => "surface.unstitch",
+ crate::dialogs_surface::Surf::ReverseNormal => "surface.reverse_normal",
+ crate::dialogs_surface::Surf::Offset { .. } => "surface.offset",
+ crate::dialogs_surface::Surf::Ruled { .. } => "surface.ruled",
+ crate::dialogs_surface::Surf::Stitch { .. } => "surface.stitch",
+ crate::dialogs_surface::Surf::Thicken { .. } => "surface.thicken",
+ crate::dialogs_surface::Surf::Extend { .. } => "surface.extend",
+ crate::dialogs_surface::Surf::Trim { .. } => "surface.trim",
+ crate::dialogs_surface::Surf::Untrim { .. } => "surface.untrim",
+ crate::dialogs_surface::Surf::SplitFace => "solid.split_face",
+ }),
+ Kind::Sheet(k) => match k {
+ crate::dialogs_sheet::Sm::Flange { .. } => Some("sheet.flange"),
+ crate::dialogs_sheet::Sm::Hem { .. } => Some("sheet.hem"),
+ crate::dialogs_sheet::Sm::Fold { .. } => Some("sheet.fold"),
+ crate::dialogs_sheet::Sm::Unfold { refold } => Some(if *refold { "sheet.refold" } else { "sheet.unfold" }),
+ crate::dialogs_sheet::Sm::Convert { .. } => Some("sheet.convert"),
+ _ => None,
+ },
+ Kind::Plastic(k) => match k {
+ crate::dialogs_plastic::Pl::Boss { .. } => Some("plastic.boss"),
+ crate::dialogs_plastic::Pl::Lip { .. } => Some("plastic.lip"),
+ crate::dialogs_plastic::Pl::SnapFit { .. } => Some("plastic.snap_fit"),
+ crate::dialogs_plastic::Pl::Rest { .. } => Some("plastic.rest"),
+ crate::dialogs_plastic::Pl::Assign { .. } => Some("plastic.assign_rule"),
+ _ => None,
+ },
+ Kind::Assembly(k) => match k {
+ crate::dialogs_assembly::Asm::NewComponent { .. } => Some("component.create"),
+ crate::dialogs_assembly::Asm::Joint(f) => Some(if f.as_built { "joint.as_built" } else { "joint.create" }),
+ crate::dialogs_assembly::Asm::JointOrigin { .. } => Some("joint.origin"),
+ crate::dialogs_assembly::Asm::RigidGroup => Some("joint.rigid_group"),
+ crate::dialogs_assembly::Asm::MotionLink { .. } => Some("joint.motion_link"),
+ crate::dialogs_assembly::Asm::Coupling(f) => Some(f.command),
+ crate::dialogs_assembly::Asm::Cam(_) => Some("joint.cam"),
+ crate::dialogs_assembly::Asm::Trace(_) => Some("motion.trace"),
+ _ => None,
+ },
+ _ => None,
+ }
+}
+
+const FILLET_TYPES: [(&str, &str); 5] = [
+ ("Constant radius", "constant"),
+ ("Chord length", "chord"),
+ ("Variable radius", "variable"),
+ ("Curvature continuous (G2)", "curvature"),
+ ("Spline", "spline"),
+];
+
+fn fillet_type(extra: &serde_json::Map<String, Value>) -> usize {
+ let value = extra.get("type").and_then(Value::as_str).unwrap_or("constant");
+ if value == "g2" { 3 } else { FILLET_TYPES.iter().position(|(_, key)| *key == value).unwrap_or(0) }
+}
+
+/// Defaults are introduced only for an explicit new type choice, never for a no-op edit.
+fn choose_fillet_type(extra: &mut serde_json::Map<String, Value>, index: usize, radius: &str) {
+ let Some((_, key)) = FILLET_TYPES.get(index) else { return };
+ if index == 0 {
+ extra.remove("type");
+ } else {
+ extra.insert("type".into(), json!(key));
+ }
+ if index != 0 {
+ extra.remove("fit");
+ extra.remove("corner");
+ }
+ if index == 2 {
+ extra.entry("radius2").or_insert_with(|| json!("1 mm"));
+ extra.entry("mid").or_insert_with(|| json!([]));
+ }
+ if index == 4 {
+ let radii = spline_radii(extra, radius);
+ extra.insert("radii".into(), json!(radii));
+ }
+}
+
+pub(super) fn rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut egui::Ui) -> bool {
+ let t = Tokens::get();
+ let mut enter = false;
+ if matches!(d.kind, Kind::Sketch | Kind::SketchModify(_) | Kind::Text(_) | Kind::TextMove(_) | Kind::EditParam { .. }) {
+ let prompt = if let Some(input) = d.active_input() {
+ tr(hint(input)).to_owned()
+ } else {
+ let key = match d.kind {
+ Kind::Text(_) => "sketch_panel.text_hint",
+ Kind::TextMove(_) => "sketch_panel.move_hint",
+ Kind::EditParam { .. } => "sketch_panel.dimension_hint",
+ _ => "dialog.selection_guidance",
+ };
+ tr(key).to_owned()
+ };
+ ui_kit::hint(ui, "tool", &prompt).on_hover_text(&prompt);
+ if matches!(&d.kind, Kind::SketchModify(k) if k.previews()) {
+ let label = d.active_input().map(|input| tr(input.label)).unwrap_or_else(|| tr("Objects"));
+ let step = crate::i18n::format(
+ "dialog.selection_step",
+ &[("step", &(d.active + 1).to_string()), ("total", &d.inputs.len().to_string()), ("input", label)],
+ );
+ ui_kit::hint(ui, "step", &step).on_hover_text(tr("dialog.selection_guidance"));
+ }
+ }
+ placement_row(d, ui);
+ input_rows(d, ui, &app.session);
+ match &mut d.kind {
+ Kind::Sketch => {
+ if d.error.is_some() && matches!(d.inputs.first().and_then(|i| i.items.first()), Some(Sel::Face { .. })) {
+ ui_kit::hint(
+ ui,
+ "attachment",
+ tr("This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane."),
+ );
+ if ui_kit::secondary_button(ui, tr("Use fixed plane")).clicked() {
+ d.extra.insert("fixed_plane".into(), json!(true));
+ }
+ }
+ }
+ Kind::SketchModify(k) => enter |= crate::sketch_modify_ui::rows(ui, k),
+ Kind::Text(k) => enter |= crate::sketch_text::rows(ui, k, &mut d.inputs, &mut d.active),
+ Kind::TextMove(k) => enter |= crate::sketch_text_move::rows(ui, k),
+ Kind::EditParam { name, expr } => {
+ enter |= ui_kit::row(ui, name, |ui| ui_kit::focused_field(ui, expr));
+ }
+ Kind::Extrude {
+ distance,
+ direction,
+ operation,
+ auto_op,
+ smart,
+ distance2,
+ taper,
+ taper_present,
+ to_offset,
+ start,
+ all,
+ thin,
+ wall,
+ wall_side,
+ wall2,
+ } => {
+ form_row(ui, "Direction", |ui| {
+ // One Side, Two Sides, Symmetric (a flip is a negative distance).
+ let order = [0usize, TWO_SIDES, 2];
+ let reversed = *direction == 1 || *direction == TWO_SIDES_REVERSED;
+ let shown = match *direction {
+ 1 => 0,
+ TWO_SIDES_REVERSED => TWO_SIDES,
+ d => d,
+ };
+ let mut pos = order.iter().position(|o| *o == shown).unwrap_or(0);
+ combo(ui, "ex_dir", &["One Side", "Two Sides", "Symmetric"], &mut pos);
+ if pos != order.iter().position(|o| *o == shown).unwrap_or(0) {
+ *direction = match (order.get(pos).copied().unwrap_or(0), reversed) {
+ (0, true) => 1,
+ (TWO_SIDES, true) => TWO_SIDES_REVERSED,
+ (d, _) => d,
+ };
+ // Selecting Symmetric applies the current total-distance semantics.
+ d.extra.insert("convention".into(), json!(solidcraft_engine::doc::ExtrudeConvention::TotalDistance));
+ // An explicit direction ends the automatic choices (#1257).
+ smart.manual_dir = true;
+ *auto_op = false;
+ }
+ });
+ let cur = if to_object_on(&d.inputs) { 1 } else { usize::from(*all) * 2 };
+ let mut ext = cur;
+ form_row(ui, "Extent Type", |ui| {
+ combo(ui, "ex_ext", &["Distance", "To Object", "All"], &mut ext);
+ *all = ext == 2;
+ set_to_object(&mut d.inputs, &mut d.active, ext == 1);
+ });
+ if ext == 0 {
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+ }
+ if ext == 1 {
+ form_row(ui, "To Offset", |ui| {
+ enter |= field(ui, to_offset);
+ });
+ }
+ if two_sided(*direction) {
+ form_row(ui, "Distance 2", |ui| {
+ enter |= field(ui, distance2);
+ });
+ }
+ form_row(ui, "Operation", |ui| {
+ let before = *operation;
+ combo(ui, "ex_op", &OP_LABELS, operation);
+ // A choice made by hand sticks.
+ if *operation != before {
+ *auto_op = false;
+ }
+ });
+ ui_kit::section(ui, "extrude_options", "Options", true, |ui| {
+ let was_thin = *thin;
+ let was_direction = *direction;
+ let mut reverse = *direction == 1 || *direction == TWO_SIDES_REVERSED;
+ if *direction < 2 || two_sided(*direction) {
+ ui_kit::checkbox_grid(ui, &mut [("Thin Extrude", thin), ("Reverse Direction", &mut reverse)], 2);
+ *direction = match (two_sided(*direction), reverse) {
+ (true, true) => TWO_SIDES_REVERSED,
+ (true, false) => TWO_SIDES,
+ (false, r) => usize::from(r),
+ };
+ if *direction != was_direction {
+ smart.manual_dir = true;
+ *auto_op = false;
+ }
+ } else {
+ ui_kit::checkbox_grid(ui, &mut [("Thin Extrude", thin)], 2);
+ }
+ if *thin != was_thin {
+ set_thin(&mut d.inputs, *thin);
+ }
+ if *thin {
+ form_row(ui, "Wall Location", |ui| {
+ combo(ui, "ex_wall", &WALL_LABELS, wall_side);
+ });
+ form_row(ui, "Wall Thickness", |ui| {
+ enter |= field(ui, wall);
+ });
+ if *wall_side == 3 {
+ form_row(ui, "Thickness Outside", |ui| {
+ enter |= field(ui, wall2);
+ });
+ }
+ }
+ });
+ let advanced = !start.is_empty() || object_on(&d.inputs, FROM_OBJECT) || *taper_present;
+ ui_kit::section(ui, "extrude_advanced", "Advanced", advanced, |ui| {
+ let old = if object_on(&d.inputs, FROM_OBJECT) { 2 } else { usize::from(!start.is_empty()) };
+ let mut st = old;
+ form_row(ui, "Start", |ui| {
+ combo(ui, "ex_start", &["Profile Plane", "Offset", "From Object"], &mut st);
+ if st != old {
+ set_object(&mut d.inputs, &mut d.active, FROM_OBJECT, st == 2);
+ if st == 1 && start.is_empty() {
+ *start = "5 mm".into();
+ }
+ if st == 0 {
+ start.clear();
+ }
+ }
+ });
+ if st != 0 {
+ form_row(ui, "Offset", |ui| {
+ enter |= field(ui, start);
+ });
+ }
+ if *direction < 2 {
+ form_row(ui, "Taper Angle", |ui| {
+ let before = taper.clone();
+ enter |= field(ui, taper);
+ if *taper != before {
+ *taper_present = !taper.trim().is_empty();
+ }
+ });
+ }
+ });
+ }
+ Kind::Fillet { radius, chamfer, chain, ctype, distance2, angle, flip } => {
+ if *chamfer {
+ form_row(ui, "Chamfer Type", |ui| combo(ui, "ch_type", &CHAMFER_TYPES, ctype));
+ }
+ form_row(ui, if *chamfer { if *ctype == 0 { "Distance" } else { "Distance 1" } } else { "Radius" }, |ui| {
+ enter |= field(ui, radius);
+ });
+ let mut rtype = fillet_type(&d.extra);
+ if !*chamfer {
+ form_row(ui, "Type", |ui| {
+ let previous = rtype;
+ combo(ui, "fi_type", &FILLET_TYPES.map(|(label, _)| label), &mut rtype);
+ if previous != rtype {
+ choose_fillet_type(&mut d.extra, rtype, radius);
+ }
+ });
+ form_row(ui, "Continuity", |ui| {
+ let mut continuity = usize::from(rtype == 3);
+ if ui_kit::segmented(ui, &mut continuity, &["G1", "G2"]) {
+ rtype = if continuity == 1 { 3 } else { 0 };
+ choose_fillet_type(&mut d.extra, rtype, radius);
+ // G1 explicitly returns to rolling corners. G2 describes the edge blend,
+ // whereas the separate advanced Corner control describes a vertex patch.
+ d.extra.remove("corner");
+ }
+ });
+ }
+ if *chamfer && *ctype == 1 {
+ form_row(ui, "Distance 2", |ui| {
+ enter |= field(ui, distance2);
+ });
+ }
+ if *chamfer && *ctype == 2 {
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ }
+ if *chamfer && *ctype > 0 {
+ form_row(ui, "Flip", |ui| check(ui, flip));
+ }
+ ui_kit::section(ui, "fillet_options", "Options", true, |ui| {
+ ui_kit::checkbox_grid(ui, &mut [("Tangent Chain", chain), ("Preview", &mut d.preview_enabled)], 2);
+ });
+ if !*chamfer {
+ ui.add_enabled_ui(matches!(rtype, 2 | 4), |ui| {
+ ui_kit::section(ui, "variable_radius", "Variable Radius", false, |ui| {
+ if !matches!(rtype, 2 | 4) {
+ ui.add_enabled(false, egui::Label::new(tr("Choose Variable radius or Spline in Type.")).wrap());
+ }
+ if rtype == 2 {
+ form_row(ui, "End Radius", |ui| {
+ enter |= extra_field(ui, &mut d.extra, "radius2", "1 mm");
+ });
+ // Which end of the first edge takes the start radius.
+ form_row(ui, "Swap Ends", |ui| {
+ extra_check(ui, &mut d.extra, "swap_ends");
+ });
+ // Radii between the ends: position along the edge (from the start end)
+ // and radius.
+ let mut mids = mid_points(&d.extra);
+ let mut remove = None;
+ for (k, (position, r)) in mids.iter_mut().enumerate() {
+ form_row(ui, "Mid Radius", |ui| {
+ ui.horizontal(|ui| {
+ ui_kit::fraction_field(ui, position)
+ .on_hover_text(tr("Position along the edge, 0 at the start end, 1 at the other"));
+ let width = (ui.available_width() - t.space_24 - t.space_4).max(0.0);
+ ui.allocate_ui_with_layout(vec2(width, t.space_24), egui::Layout::left_to_right(egui::Align::Center), |ui| {
+ enter |= field(ui, r);
+ });
+ if ui_kit::small_button(ui, "×").on_hover_text(tr("Remove this point")).clicked() {
+ remove = Some(k);
+ }
+ });
+ });
+ }
+ if let Some(k) = remove {
+ mids.remove(k);
+ }
+ form_row(ui, "", |ui| {
+ if ui_kit::secondary_button(ui, tr("Add Mid Radius")).clicked() && mids.len() < 20 {
+ let t = if mids.is_empty() { 0.5 } else { (mids.iter().map(|m| m.0).fold(0.0, f64::max) + 1.0) * 0.5 };
+ mids.push((t.min(0.99), radius.clone()));
+ }
+ });
+ d.extra.insert("mid".into(), json!(mids.iter().map(|(t, r)| json!([t, r])).collect::<Vec<_>>()));
+ form_row(ui, "Smooth", |ui| {
+ extra_check(ui, &mut d.extra, "smooth");
+ });
+ }
+ if rtype == 4 {
+ // The radius along the edge as a B-spline: its control radii from the
+ // start end, also dragged by their handles on the edge.
+ form_row(ui, "Swap Ends", |ui| {
+ extra_check(ui, &mut d.extra, "swap_ends");
+ });
+ let mut radii = spline_radii(&mut d.extra, radius);
+ let n = radii.len();
+ for (k, r) in radii.iter_mut().enumerate() {
+ form_row(ui, if k + 1 == n { "End Radius" } else { "Control Radius" }, |ui| {
+ enter |= field(ui, r);
+ });
+ }
+ d.extra.insert("radii".into(), json!(radii));
+ }
+ });
+ })
+ .response
+ .on_disabled_hover_text(tr("Choose Variable radius or Spline in Type."));
+ ui_kit::section(ui, "fillet_advanced", "Advanced", false, |ui| {
+ let constant = rtype == 0;
+ ui.add_enabled_ui(constant, |ui| {
+ let fit = form_row(ui, "Radius Fit", |ui| {
+ extra_choice(
+ ui,
+ &mut d.extra,
+ "fi_fit",
+ "fit",
+ &[("Exact", "exact"), ("Reduce to Fit", "reduce"), ("Taper to Fit", "taper")],
+ )
+ });
+ if fit == 1
+ && let Some((lo, hi)) = app.preview.applied
+ {
+ form_row(ui, "Applied Radius", |ui| {
+ let shown = if hi > lo {
+ format!("{} – {}", crate::prefs::show_mm_bare(app, lo), crate::prefs::show_mm(app, hi, 1))
+ } else {
+ crate::prefs::show_mm(app, lo, 1)
+ };
+ ui.label(RichText::new(shown).color(t.warning));
+ });
+ }
+ });
+ let exact = d.extra.get("fit").and_then(Value::as_str).is_none_or(|fit| fit == "exact");
+ ui.add_enabled_ui(constant && exact, |ui| {
+ form_row(ui, "Corner", |ui| {
+ extra_choice(ui, &mut d.extra, "fi_corner", "corner", &[("Rolling", "rolling"), ("G2", "g2")]);
+ });
+ })
+ .response
+ .on_hover_text(tr("G2 corners require a constant radius and Exact fit. G2 corner construction is not supported yet."));
+ if !constant {
+ ui.label(RichText::new(tr("Fit and G2 corners require Constant radius.")).color(t.text_dim).size(t.font_small));
+ }
+ });
+ }
+ }
+ Kind::PatternRect { count, spacing, count2, spacing2 } => {
+ for (l, v) in [("Quantity", count), ("Spacing", spacing), ("Quantity 2", count2), ("Spacing 2", spacing2)] {
+ form_row(ui, l, |ui| {
+ enter |= field(ui, v);
+ });
+ }
+ if d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES) {
+ feature_pattern_alignment_row(ui, &mut d.extra, 0);
+ feature_pattern_alignment_row(ui, &mut d.extra, 1);
+ }
+ }
+ Kind::PatternCirc { count, angle } => {
+ for (l, v) in [("Quantity", count), ("Total angle", angle)] {
+ form_row(ui, l, |ui| {
+ enter |= field(ui, v);
+ });
+ }
+ if d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES) {
+ feature_pattern_alignment_row(ui, &mut d.extra, 0);
+ }
+ }
+ Kind::Hole { diameter, depth, kind, cb_diameter, cb_depth, cs_diameter, cs_angle, opts } => {
+ form_row(ui, "Extents", |ui| {
+ let cur = if to_object_on(&d.inputs) { 1 } else { usize::from(opts.all) * 2 };
+ let mut ext = cur;
+ combo(ui, "hole_ext", &["Distance", "To Object", "All"], &mut ext);
+ opts.all = ext == 2;
+ set_to_object(&mut d.inputs, &mut d.active, ext == 1);
+ });
+ if opts.multiple {
+ // Every point of the picked points' sketches (standalone points and
+ // circle centres), not just the picked ones.
+ form_row(ui, "All Sketch Points", |ui| {
+ extra_check(ui, &mut d.extra, "all_points");
+ });
+ // The holes go into the part the sketch touches; Flip drills the
+ // other way.
+ form_row(ui, "Flip", |ui| {
+ extra_check(ui, &mut d.extra, "flip");
+ });
+ }
+ form_row(ui, "Hole Type", |ui| {
+ combo(ui, "hole_kind", &HOLE_LABELS, kind);
+ });
+ form_row(ui, "Hole Tap Type", |ui| {
+ let mut tap = usize::from(opts.tapped);
+ combo(ui, "hole_tap", &["Simple", "Tapped"], &mut tap);
+ opts.tapped = tap == 1;
+ });
+ if opts.tapped {
+ form_row(ui, "Size", |ui| {
+ enter |= field(ui, &mut opts.thread);
+ });
+ }
+ if *kind == 0 {
+ form_row(ui, "Drill Point", |ui| {
+ let mut tip = usize::from(opts.angled);
+ combo(ui, "hole_tip", &["Flat", "Angle"], &mut tip);
+ opts.angled = tip == 1;
+ });
+ }
+ if !opts.all {
+ form_row(ui, "Depth", |ui| {
+ enter |= field(ui, depth);
+ });
+ }
+ if *kind == 0 && opts.angled {
+ form_row(ui, "Tip Angle", |ui| {
+ enter |= field(ui, &mut opts.tip_angle);
+ });
+ }
+ form_row(ui, "Diameter", |ui| {
+ enter |= field(ui, diameter);
+ });
+ if *kind == 1 {
+ form_row(ui, "Counterbore Ø", |ui| {
+ enter |= field(ui, cb_diameter);
+ });
+ form_row(ui, "Counterbore depth", |ui| {
+ enter |= field(ui, cb_depth);
+ });
+ }
+ if *kind == 2 {
+ form_row(ui, "Countersink Ø", |ui| {
+ enter |= field(ui, cs_diameter);
+ });
+ form_row(ui, "Countersink angle", |ui| {
+ enter |= field(ui, cs_angle);
+ });
+ }
+ }
+ _ => enter |= additional_rows(app, d, ui),
+ }
+ error_rows(app, ctx, d, ui, true);
+ enter
+}
+
+fn extra_segments(ui: &mut egui::Ui, extra: &mut serde_json::Map<String, Value>, key: &str, choices: &[(&str, &str)]) {
+ let current = extra.get(key).and_then(Value::as_str).and_then(|value| choices.iter().position(|(_, key)| *key == value)).unwrap_or(0);
+ let mut selected = current;
+ let labels: Vec<_> = choices.iter().map(|(label, _)| *label).collect();
+ if ui_kit::segmented(ui, &mut selected, &labels) && selected != current {
+ if selected == 0 {
+ extra.remove(key);
+ } else if let Some((_, value)) = choices.get(selected) {
+ extra.insert(key.into(), json!(value));
+ }
+ }
+}
+
+/// Only user changes add optional JSON keys, preserving no-op feature edits.
+fn extra_options(ui: &mut egui::Ui, id: &str, extra: &mut serde_json::Map<String, Value>, choices: &[(&str, &str)]) {
+ let mut values: Vec<bool> = choices.iter().map(|(_, key)| extra.get(*key).and_then(Value::as_bool).unwrap_or(false)).collect();
+ let before = values.clone();
+ let mut items: Vec<_> = choices.iter().zip(values.iter_mut()).map(|((label, _), value)| (*label, value)).collect();
+ ui_kit::options(ui, id, &mut items);
+ for (((_, key), value), before) in choices.iter().zip(values).zip(before) {
+ if value != before {
+ extra.insert((*key).into(), json!(value));
+ }
+ }
+}
+
+fn additional_rows(app: &mut SolveApp, d: &mut Dialog, ui: &mut egui::Ui) -> bool {
+ let mut enter = false;
+ match &mut d.kind {
+ Kind::Revolve { angle, operation, .. } => {
+ let cur = usize::from(to_object_on(&d.inputs));
+ let mut ty = cur;
+ form_row(ui, "Type", |ui| {
+ ui_kit::segmented(ui, &mut ty, &["Angle", "To Object"]);
+ set_to_object(&mut d.inputs, &mut d.active, ty == 1);
+ });
+ if ty == 0 {
+ // One Side, Two Sides (a second angle), Symmetric (the angle split).
+ let cur = if d.extra.contains_key("angle2") {
+ 1
+ } else if d.extra.get("direction").is_some() {
+ 2
+ } else {
+ 0
+ };
+ let mut dir = cur;
+ form_row(ui, "Direction", |ui| {
+ ui_kit::segmented(ui, &mut dir, &["One Side", "Two Sides", "Symmetric"]);
+ if dir != cur {
+ d.extra.remove("angle2");
+ d.extra.remove("direction");
+ match dir {
+ 1 => {
+ d.extra.insert("angle2".into(), json!("90 deg"));
+ }
+ 2 => {
+ d.extra.insert("direction".into(), json!("symmetric"));
+ }
+ _ => {}
+ }
+ }
+ });
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ if dir == 1 {
+ form_row(ui, "Angle 2", |ui| {
+ enter |= extra_field(ui, &mut d.extra, "angle2", "90 deg");
+ });
+ }
+ }
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "rv_op", &OP_LABELS, operation);
+ });
+ }
+
+ Kind::Shell { thickness } => {
+ // The direction below says which side the wall grows to; the label stays short enough
+ // for the label column.
+ form_row(ui, "Thickness", |ui| {
+ enter |= field(ui, thickness);
+ });
+ form_row(ui, "Direction", |ui| {
+ extra_segments(ui, &mut d.extra, "direction", &[("Inside", "inside"), ("Outside", "outside"), ("Both", "both")]);
+ });
+ extra_options(ui, "shell_options", &mut d.extra, &[("Tangent Chain", "tangent_chain")]);
+ }
+ Kind::Draft { angle } => {
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ }
+ Kind::Mirror => {
+ // Feature replay retains the source operation; Join is for body copies.
+ if !d.inputs.first().is_some_and(|i| i.accept == selection::FEATURES) {
+ form_row(ui, "Operation", |ui| {
+ let mut op = usize::from(d.extra.get("combine").and_then(Value::as_bool).unwrap_or(false));
+ ui_kit::segmented(ui, &mut op, &["New Body", "Join"]);
+ d.extra.insert("combine".into(), json!(op == 1));
+ });
+ }
+ }
+ Kind::OffsetPlane { offset } => {
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, offset);
+ });
+ }
+ Kind::AnglePlane { angle } => {
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ }
+ Kind::PathPlane { t, .. } => {
+ form_row(ui, "Position (0 to 1)", |ui| {
+ enter |= field(ui, t);
+ });
+ }
+ Kind::MeshConvert { tolerance } => {
+ form_row(ui, "Tolerance", |ui| enter |= field(ui, tolerance));
+ }
+ Kind::Construct { t: Some(t), .. } => {
+ form_row(ui, "Position (0 to 1)", |ui| enter |= field(ui, t));
+ }
+ Kind::Split | Kind::ReplaceFace | Kind::Remove | Kind::Midplane | Kind::Construct { t: None, .. } => {}
+ Kind::Rib { thickness, depth, flip, normal, .. } => {
+ form_row(ui, "Direction", |ui| {
+ let mut i = usize::from(*normal);
+ ui_kit::segmented(ui, &mut i, &["In plane", "Normal"]);
+ *normal = i == 1;
+ });
+ form_row(ui, "Thickness", |ui| {
+ enter |= field(ui, thickness);
+ });
+ form_row(ui, "Depth", |ui| {
+ enter |= ui_kit::hint_field(ui, depth, tr("to the next face"));
+ });
+ ui_kit::options(ui, "feature_options", &mut [("Flip", flip)]);
+ }
+ Kind::Emboss { depth, deboss } => {
+ form_row(ui, "Depth", |ui| {
+ enter |= field(ui, depth);
+ });
+ form_row(ui, "Type", |ui| {
+ let mut i = usize::from(*deboss);
+ ui_kit::segmented(ui, &mut i, &["Emboss", "Deboss"]);
+ *deboss = i == 1;
+ });
+ ui.add(
+ egui::Label::new("Orthogonal line profiles tangent to one supported cylinder wrap automatically. Pick a wall to choose a target.")
+ .wrap(),
+ );
+ }
+ Kind::Align { flip } => {
+ // Where on the picked face or edge to snap: as picked (a face turns to meet
+ // the other, an edge at its middle), its centre, or a round one's centre.
+ for (label, key) in [("From Snap", "from_snap"), ("To Snap", "to_snap")] {
+ form_row(ui, label, |ui| {
+ extra_choice(ui, &mut d.extra, key, key, &[("As Picked", "picked"), ("Centre", "center"), ("Circle Centre", "circle")]);
+ });
+ }
+ ui_kit::options(ui, "feature_options", &mut [("Flip", flip)]);
+ }
+ Kind::BoundaryFill { operation, cells, .. } => {
+ form_row(ui, "Cells", |ui| {
+ if cells.is_empty() {
+ ui.label(RichText::new(tr("Pick the tool bodies")).color(Tokens::get().text_dim));
+ }
+ });
+ for (i, (_, label, on)) in cells.iter_mut().enumerate() {
+ form_row(ui, &format!("Cell {}", i + 1), |ui| {
+ ui_kit::checkbox(ui, label.as_str(), on);
+ });
+ }
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "bf_op", &OP_LABELS, operation);
+ });
+ extra_options(ui, "boundary_options", &mut d.extra, &[("Remove Tools", "remove_tools")]);
+ }
+ Kind::PathPattern { count, spacing } => {
+ for (l, v) in [("Quantity", count), ("Spacing", spacing)] {
+ form_row(ui, l, |ui| {
+ enter |= field(ui, v);
+ });
+ }
+ }
+ Kind::Pipe { diameter, wall } => {
+ form_row(ui, "Diameter", |ui| {
+ enter |= field(ui, diameter);
+ });
+ form_row(ui, "Wall", |ui| {
+ enter |= ui_kit::hint_field(ui, wall, tr("solid"));
+ });
+ }
+ Kind::Stock { margin } => {
+ form_row(ui, "Margin", |ui| {
+ enter |= field(ui, margin);
+ });
+ }
+ Kind::Scale { factor } => {
+ form_row(ui, "Scale factor", |ui| {
+ enter |= field(ui, factor);
+ });
+ }
+ Kind::OffsetFaces { distance } => {
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+ }
+ Kind::Thread { designation, length, suggested, of } => {
+ let mut full = length.trim().is_empty();
+ let was_full = full;
+ let mut modeled = d.extra.get("modeled").and_then(Value::as_bool).unwrap_or(false);
+ let before = modeled;
+ let (submitted, reset) = crate::dialogs_thread::rows(ui, designation, suggested, &mut modeled, &mut full);
+ if modeled != before {
+ d.extra.insert("modeled".into(), json!(modeled));
+ }
+ if full != was_full {
+ *length = if full { String::new() } else { "10 mm".into() };
+ }
+ enter |= submitted;
+ if reset {
+ of.clear();
+ }
+ if !full {
+ form_row(ui, "Length", |ui| {
+ enter |= field(ui, length);
+ });
+ }
+ }
+
+ Kind::Loft { operation, rail_fit } => {
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "lf_op", &OP_LABELS, operation);
+ });
+ crate::dialogs_sweep::rail_fit_row(ui, "lf", rail_fit);
+ }
+ Kind::Sweep { operation, opts } => {
+ enter |= crate::dialogs_sweep::rows_with(ui, opts, "sw", |ui| {
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "sw_op", &OP_LABELS, operation);
+ });
+ });
+ }
+ k @ Kind::Move { .. } => {
+ enter |= crate::dialogs_move::rows(ui, k);
+ extra_options(ui, "move_options", &mut d.extra, &[("Create Copy", "copy")]);
+ }
+
+ Kind::Primitive { fields, operation, at, .. } => {
+ for (k, v) in fields.iter_mut() {
+ form_row(ui, k, |ui| {
+ enter |= field(ui, v);
+ });
+ }
+ if let Some((p, _)) = *at {
+ form_row(ui, "Position", |ui| {
+ ui.horizontal(|ui| {
+ ui.label(format!("{:.2}, {:.2}, {:.2}", p.x, p.y, p.z));
+ if ui_kit::small_button(ui, "×").on_hover_text(tr("Place at the origin instead")).clicked() {
+ *at = None;
+ }
+ });
+ });
+ }
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "pr_op", &OP_LABELS, operation);
+ });
+ }
+ Kind::Combine { operation, keep_tools } => {
+ form_row(ui, "Operation", |ui| {
+ let mut op = operation.saturating_sub(1);
+ combo(ui, "cb_op", &OP_LABELS[1..], &mut op);
+ *operation = op + 1;
+ });
+ ui_kit::section(ui, "combine_options", "Options", true, |ui| {
+ let mut new_component = d.extra.get("new_component").and_then(Value::as_bool).unwrap_or(false);
+ let before = new_component;
+ ui_kit::checkbox_grid(ui, &mut [("New Component", &mut new_component), ("Keep Tools", keep_tools)], 2);
+ if new_component != before {
+ d.extra.insert("new_component".into(), json!(new_component));
+ }
+ });
+ }
+ Kind::Surface(k) => enter |= crate::dialogs_surface::rows(ui, k),
+ Kind::Sheet(k) => enter |= crate::dialogs_sheet::rows(app, ui, k, &mut d.inputs),
+ Kind::Plastic(k) => enter |= crate::dialogs_plastic::rows(app, ui, k, &d.inputs),
+ Kind::Assembly(k) => enter |= crate::dialogs_assembly::rows(app, ui, k, &mut d.inputs, &mut d.active),
+ _ => {}
+ }
+ enter
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use crate::scenario::{self, Harness};
+
+ const COMMANDS: [&str; 6] =
+ ["solid.extrude", "solid.fillet", "solid.chamfer", "solid.hole", "solid.pattern.rectangular", "solid.pattern.circular"];
+
+ fn sample(h: &mut Harness) {
+ h.app.run("sketch.create", json!({"plane":"XY","name":"Base"})).unwrap();
+ h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,10]})).unwrap();
+ h.app.run("sketch.finish", json!({})).unwrap();
+ h.app.run("solid.extrude", json!({"distance":"5 mm"})).unwrap();
+ }
+
+ #[test]
+ fn common_forms_fit_both_layouts_and_scales_and_pin_footer_at_small_heights() {
+ for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
+ for scale in [1.0, 2.0] {
+ for height in [950.0, 720.0] {
+ let mut h = Harness::new();
+ h.call("ui.set", json!({"layout": mode}));
+ h.app.preferences.ui_scale = scale;
+ h.call("ui.resize", json!({"width": 1400.0 / scale, "height": height / scale}));
+ sample(&mut h);
+ for command in COMMANDS {
+ h.step(&json!({"start":command})).unwrap();
+ // Force the long Hole variant too: counterbore, tapping and multiple picks.
+ if let Some(Dialog { kind: Kind::Hole { kind, opts, .. }, .. }) = h.app.dialog.as_mut() {
+ *kind = 1;
+ opts.tapped = true;
+ opts.multiple = true;
+ }
+ h.frames(8);
+ let card = scenario::rect_of("dialog:card").unwrap();
+ let viewport = h.app.viewport.rect.unwrap();
+ assert!(
+ viewport.expand(1.0).contains_rect(card),
+ "{command} {mode:?} scale={scale} height={height}: {card:?} outside {viewport:?}"
+ );
+ for action in ["dialog:ok", "dialog:cancel"] {
+ let rect = scenario::rect_of(action).unwrap();
+ assert!(
+ card.contains_rect(rect),
+ "{command} {mode:?} scale={scale} height={height}: clipped {action} {rect:?} card={card:?}"
+ );
+ }
+ assert!(crate::shell::covered_rects(&h.app).contains(&card));
+ assert!(card.width() <= 301.0, "{card:?}");
+ h.step(&json!({"widget":"Cancel"})).unwrap();
+ assert!(h.app.dialog.is_none(), "{command}");
+ }
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn tiny_windows_do_not_panic_or_publish_non_finite_cards() {
+ for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
+ for size in [(1.0, 1.0), (40.0, 80.0), (180.0, 240.0)] {
+ let mut h = Harness::new();
+ h.call("ui.set", json!({"layout": mode}));
+ sample(&mut h);
+ h.call("ui.resize", json!({"width":size.0,"height":size.1}));
+ for command in COMMANDS {
+ h.app.start(command);
+ assert!(h.app.dialog.is_some(), "{command} must actually open");
+ h.frames(3);
+ if let Some(rect) = h.app.viewport.dialog_rect {
+ assert!(rect.is_finite() && rect.width() >= 0.0 && rect.height() >= 0.0, "{command}: {rect:?}");
+ }
+ cancel(&mut h.app);
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn fillet_options_and_continuity_keep_the_existing_command_parameters() {
+ let mut h = Harness::new();
+ h.call("ui.resize", json!({"width":1400,"height":1000}));
+ sample(&mut h);
+ h.step(&json!({"start":"solid.fillet"})).unwrap();
+ h.frames(4);
+ h.step(&json!({"click":{"handle":"dialog:Continuity:G2"}})).unwrap();
+ assert_eq!(h.app.dialog.as_ref().unwrap().extra.get("type"), Some(&json!("curvature")));
+ h.step(&json!({"click":{"handle":"dialog:Tangent Chain"}})).unwrap();
+ assert!(matches!(h.app.dialog.as_ref().unwrap().kind, Kind::Fillet { chain: false, .. }));
+ h.step(&json!({"click":{"handle":"dialog:section:Options"}})).unwrap();
+ h.frames(2);
+ assert!(scenario::handle_at("dialog:Tangent Chain").is_none());
+ h.step(&json!({"click":{"handle":"dialog:section:Options"}})).unwrap();
+ h.frames(2);
+ assert!(scenario::handle_at("dialog:Tangent Chain").is_some());
+ }
+ fn fillet_harness() -> Harness {
+ let mut h = Harness::new();
+ h.call("ui.resize", json!({"width":1400,"height":1000}));
+ sample(&mut h);
+ let edge = edge_sel(&h.app.session, Vec3::new(5.0, 0.0, 5.0)).unwrap();
+ h.app.session.selection = vec![edge];
+ h.step(&json!({"start":"solid.fillet"})).unwrap();
+ h.frames(4);
+ h
+ }
+
+ fn parameters(h: &Harness) -> Value {
+ let commands = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
+ assert_eq!(commands.first().unwrap().0, "solid.fillet");
+ commands.first().unwrap().1.clone()
+ }
+
+ fn choose(h: &mut Harness, row: &str, option: &str) {
+ h.step(&json!({"click":{"handle":format!("dialog:{row}")}})).unwrap();
+ h.step(&json!({"click":{"handle":format!("dialog:{row}:{option}")}})).unwrap();
+ h.frames(2);
+ }
+
+ #[test]
+ fn every_type_choice_produces_its_supported_command_without_changing_defaults() {
+ for (label, key) in FILLET_TYPES {
+ let mut h = fillet_harness();
+ let original = parameters(&h);
+ h.frames(3);
+ assert_eq!(parameters(&h), original, "merely drawing the default form is lossless");
+ choose(&mut h, "Type", label);
+ let p = parameters(&h);
+ assert_eq!(p.get("type").and_then(Value::as_str).unwrap_or("constant"), key, "{p}");
+ assert_eq!(p["radius"], original["radius"]);
+ assert_eq!(p["edges"], original["edges"]);
+ assert!(p.get("preview").is_none() && p.get("preview_enabled").is_none());
+ if key == "variable" {
+ assert_eq!(p["radius2"], json!("1 mm"));
+ assert!(p["start"].is_array());
+ }
+ if key == "spline" {
+ assert_eq!(p["radii"].as_array().unwrap().len(), 4);
+ assert_eq!(p["knots"].as_array().unwrap().len(), 9);
+ assert!(p["start"].is_array());
+ }
+ assert!(scenario::handle_at("dialog:Continuity:G3").is_none());
+ }
+ }
+
+ #[test]
+ fn continuity_and_advanced_controls_map_to_edge_type_fit_and_corner() {
+ let mut h = fillet_harness();
+ assert!(scenario::handle_at("dialog:Radius Fit").is_none(), "Advanced starts collapsed");
+ h.step(&json!({"click":{"handle":"dialog:section:Advanced"}})).unwrap();
+ choose(&mut h, "Corner", "G2");
+ assert_eq!(parameters(&h)["corner"], json!("g2"));
+ choose(&mut h, "Corner", "Rolling");
+ assert!(parameters(&h).get("corner").is_none());
+ choose(&mut h, "Radius Fit", "Reduce to Fit");
+ assert_eq!(parameters(&h)["fit"], json!("reduce"));
+ choose(&mut h, "Radius Fit", "Taper to Fit");
+ assert_eq!(parameters(&h)["fit"], json!("taper"));
+ choose(&mut h, "Radius Fit", "Exact");
+ assert!(parameters(&h).get("fit").is_none());
+ h.step(&json!({"click":{"handle":"dialog:Continuity:G2"}})).unwrap();
+ assert_eq!(parameters(&h)["type"], json!("curvature"));
+ h.step(&json!({"click":{"handle":"dialog:Continuity:G1"}})).unwrap();
+ let p = parameters(&h);
+ assert!(p.get("type").is_none() && p.get("corner").is_none());
+ choose(&mut h, "Type", "Chord length");
+ h.step(&json!({"click":{"handle":"dialog:Continuity:G1"}})).unwrap();
+ assert!(parameters(&h).get("type").is_none(), "even an already highlighted G1 explicitly selects Constant radius");
+ }
+
+ #[test]
+ fn variable_controls_toggle_keep_mid_radii_and_preview_is_ui_only() {
+ let mut h = fillet_harness();
+ let original = parameters(&h);
+ h.step(&json!({"click":{"handle":"dialog:Preview"}})).unwrap();
+ h.frames(3);
+ assert!(!h.app.dialog.as_ref().unwrap().preview_enabled);
+ assert!(!h.app.preview.active && !h.app.preview.busy);
+ assert_eq!(parameters(&h), original);
+ h.step(&json!({"click":{"handle":"dialog:Preview"}})).unwrap();
+ assert!(h.app.dialog.as_ref().unwrap().preview_enabled);
+ assert_eq!(parameters(&h), original);
+ assert!(scenario::handle_at("dialog:End Radius").is_none());
+ choose(&mut h, "Type", "Variable radius");
+ assert!(scenario::handle_at("dialog:End Radius").is_none(), "the section stays collapsed after a type choice");
+ h.step(&json!({"click":{"handle":"dialog:section:Variable Radius"}})).unwrap();
+ assert!(scenario::handle_at("dialog:End Radius").is_some());
+ assert!(scenario::handle_at("dialog:Smooth").is_some(), "Smooth is a supported variable-radius option even before adding a middle radius");
+ h.step(&json!({"widget":"Add Mid Radius"})).unwrap();
+ h.step(&json!({"click":{"handle":"dialog:Smooth"}})).unwrap();
+ let saved = parameters(&h);
+ assert_eq!(saved["mid"].as_array().unwrap().len(), 1);
+ assert_eq!(saved["smooth"], json!(true));
+ h.step(&json!({"click":{"handle":"dialog:section:Variable Radius"}})).unwrap();
+ h.frames(2);
+ assert!(scenario::handle_at("dialog:Mid Radius").is_none());
+ assert_eq!(parameters(&h), saved, "folding keeps all values and commands");
+ assert!(scenario::handle_at("dialog:section:Setbacks").is_none());
+ assert!(scenario::handle_at("dialog:Result").is_none());
+ }
+
+ #[test]
+ fn edges_field_paints_zero_one_and_many_and_footer_follows_validity() {
+ fn contains_text(shape: &egui::Shape, expected: &str) -> bool {
+ match shape {
+ egui::Shape::Text(text) => text.galley.job.text == expected,
+ egui::Shape::Vec(shapes) => shapes.iter().any(|shape| contains_text(shape, expected)),
+ _ => false,
+ }
+ }
+ let mut h = fillet_harness();
+ let picks: Vec<_> = [Vec3::new(5.0, 0.0, 5.0), Vec3::new(0.0, 5.0, 5.0), Vec3::new(10.0, 5.0, 5.0)]
+ .into_iter()
+ .map(|p| edge_sel(&h.app.session, p).unwrap())
+ .collect();
+ for (count, text) in [(0, "Select edges"), (1, "1 selected"), (3, "3 selected")] {
+ h.app.dialog.as_mut().unwrap().inputs.first_mut().unwrap().items = picks.iter().take(count).cloned().collect();
+ h.frames(3);
+ if count <= 1 {
+ let tree = h.output.accesskit_update.as_ref().unwrap();
+ let disabled = tree
+ .nodes
+ .iter()
+ .find_map(|(_, node)| (node.role() == egui::accesskit::Role::Button && node.label() == Some("OK")).then(|| node.is_disabled()))
+ .unwrap();
+ assert_eq!(disabled, count == 0, "OK follows the actual required edge selection");
+ }
+ let mut output = h.ctx.run_ui(
+ egui::RawInput {
+ time: Some(h.ctx.input(|input| input.time)),
+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1400.0, 1000.0))),
+ ..Default::default()
+ },
+ |ui| h.app.ui(ui),
+ );
+ let painted = output.shapes.iter().any(|shape| contains_text(&shape.shape, text));
+ output.textures_delta.clear();
+ assert!(painted, "the actual field must paint {text}");
+ let field = scenario::rect_of("dialog:field:Edges").unwrap();
+ assert!(
+ (field.width() - scenario::rect_of("dialog:control:Edges").unwrap().width()).abs() < 0.02,
+ "clear is inside the full field (allow egui subpixel rounding)"
+ );
+ assert!(h.widget("OK").is_some());
+ if count == 0 {
+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();
+ assert!(h.app.dialog.is_some(), "invalid OK stays disabled");
+ }
+ }
+ }
+}
+
+#[cfg(test)]
+#[path = "dialogs_all_tests.rs"]
+mod all_tests;
+
+#[cfg(test)]
+#[path = "dialogs_sketch_tests.rs"]
+mod sketch_tests;
diff --git a/crates/ui-egui/src/dialogs_library.rs b/crates/ui-egui/src/dialogs_library.rs
index bdbb154ee7..5a9e01a672 100644
--- a/crates/ui-egui/src/dialogs_library.rs
+++ b/crates/ui-egui/src/dialogs_library.rs
@@ -1,6 +1,8 @@
//! The first local appearance-library consumer, inside the existing Appearance panel.
#[cfg(not(target_arch = "wasm32"))]
use crate::dialogs_appearance::selected_params;
+#[cfg(not(target_arch = "wasm32"))]
+use crate::fonts::RichTextExt as _;
use crate::{SolveApp, dialogs::row_label, dialogs_appearance::Ap, selection::SelInput, theme::Tokens};
use egui::RichText;
use serde_json::json;
@@ -153,7 +155,7 @@ fn import_rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Ap, inputs: &[SelI
}
});
if let Some(catalog) = &k.local.catalog {
- ui.label(RichText::new(&catalog.name).strong());
+ ui.label(RichText::new(&catalog.name).semibold().color(crate::theme::Tokens::get().text));
let search = ui.add(egui::TextEdit::singleline(&mut k.local.search).hint_text("Search this library").desired_width(200.0));
crate::scenario::publish_handle("library:search", search.rect.center());
if search.changed() {
diff --git a/crates/ui-egui/src/dialogs_library_tests.rs b/crates/ui-egui/src/dialogs_library_tests.rs
index ea82b6b203..3a5debe816 100644
--- a/crates/ui-egui/src/dialogs_library_tests.rs
+++ b/crates/ui-egui/src/dialogs_library_tests.rs
@@ -70,7 +70,7 @@ fn async_library_export_holds_its_document_until_the_answer() {
let (mut h, token) = appearance_fixture().unwrap();
let original = h.app.session.doc.clone();
let path = h.dir.join("delayed-library.json");
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
save_library(&mut h.app, token, false);
@@ -97,7 +97,7 @@ fn async_library_export_captures_overwrite_consent_and_cancel_writes_nothing() {
let path = h.dir.join("existing-library.json");
std::fs::write(&path, b"keep this file").unwrap();
let original = h.app.session.doc.clone();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
save_library(&mut h.app, token.clone(), false);
@@ -123,7 +123,7 @@ fn async_library_open_does_not_replace_a_new_appearance_editor() {
let path = h.dir.join("source-library.json");
h.app.run("library.export", json!({"path":path})).unwrap();
let original = h.app.session.doc.clone();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
// Prepare a different editor before the picker holds user commands, then model
@@ -158,7 +158,7 @@ fn delayed_library_export_refuses_an_internally_changed_design_without_overwriti
let changed = h.app.session.doc.clone();
let history = (h.app.session.undo.len(), h.app.session.revision);
*slot.borrow_mut() = Some(Some(path.to_string_lossy().into_owned()));
- crate::file_picker::tick(&mut h.app, &egui::Context::default());
+ crate::file_picker::tick(&mut h.app, &crate::fonts::test_context());
assert_eq!(std::fs::read(path).unwrap(), b"keep library");
assert!(Arc::ptr_eq(&changed, &h.app.session.doc));
assert_eq!((h.app.session.undo.len(), h.app.session.revision), history);
diff --git a/crates/ui-egui/src/dialogs_motion.rs b/crates/ui-egui/src/dialogs_motion.rs
index 2ddc86d309..28943fa426 100644
--- a/crates/ui-egui/src/dialogs_motion.rs
+++ b/crates/ui-egui/src/dialogs_motion.rs
@@ -3,6 +3,7 @@
//! show while open (a study's pose, an explosion) is display only: pending occurrence moves,
//! computed on a scratch copy of the design and put back when the dialog closes.
+use crate::fonts::RichTextExt as _;
use std::collections::BTreeMap;
use egui::{Color32, Pos2, RichText, Sense, Stroke, pos2, vec2};
@@ -765,7 +766,7 @@ fn configurations_rows(
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
egui::Grid::new("configuration_table").num_columns(2).min_col_width(210.0).spacing(vec2(10.0, 8.0)).show(ui, |ui| {
// Header.
- ui.label(RichText::new(crate::i18n::tr_label("Configuration")).strong());
+ ui.label(RichText::new(crate::i18n::tr_label("Configuration")).semibold().color(crate::theme::Tokens::get().text));
ui.horizontal(|ui| {
for c in &tb.columns {
ui.allocate_ui_with_layout(vec2(190.0, 22.0), egui::Layout::left_to_right(egui::Align::Center), |ui| {
@@ -783,7 +784,11 @@ fn configurations_rows(
.filter(|_| matches!(kind, "component_appearance" | "face_appearance"))
.map(str::to_string)
.unwrap_or(label);
- ui.add_sized(vec2(156.0, 22.0), egui::Label::new(RichText::new(label).strong()).truncate()).on_hover_text(c);
+ ui.add_sized(
+ vec2(156.0, 22.0),
+ egui::Label::new(RichText::new(label).semibold().color(crate::theme::Tokens::get().text)).truncate(),
+ )
+ .on_hover_text(c);
if ui.small_button("×").on_hover_text(crate::i18n::tr_label("Remove the column")).clicked() {
let key = if kind == "suppress" { "feature" } else { kind };
run(app, error, "config.column", json!({ key: if kind == "face_appearance" {c.as_str()} else {n}, "delete": true }));
@@ -797,7 +802,12 @@ fn configurations_rows(
ui.horizontal(|ui| {
ui.add_sized(
vec2(100.0, 22.0),
- egui::Label::new(if active { RichText::new(name).strong() } else { RichText::new(name) }).truncate(),
+ egui::Label::new(if active {
+ RichText::new(name).semibold().color(crate::theme::Tokens::get().text)
+ } else {
+ RichText::new(name)
+ })
+ .truncate(),
)
.on_hover_text(name);
if active {
diff --git a/crates/ui-egui/src/dialogs_motion_plot.rs b/crates/ui-egui/src/dialogs_motion_plot.rs
index 28929992a8..1d301f55ef 100644
--- a/crates/ui-egui/src/dialogs_motion_plot.rs
+++ b/crates/ui-egui/src/dialogs_motion_plot.rs
@@ -159,7 +159,7 @@ fn chart(ui: &mut egui::Ui, xs: &[f64], ys: &[f64], unit: &str, total: u32, now:
}
let pts: Vec<egui::Pos2> = xs.iter().zip(ys).filter(|(_, v)| v.is_finite()).map(|(s, v)| pos2(x(*s), y(*v))).collect();
p.add(egui::Shape::line(pts, Stroke::new(1.5, t.accent)));
- let font = FontId::proportional(10.0);
+ let font = FontId::proportional(crate::theme::Tokens::get().font_micro);
p.text(r.left_top() + vec2(4.0, 2.0), Align2::LEFT_TOP, format!("{} {unit}", short(hi)), font.clone(), t.text_dim);
p.text(r.left_bottom() + vec2(4.0, -2.0), Align2::LEFT_BOTTOM, format!("{} {unit}", short(lo)), font.clone(), t.text_dim);
if let Some(v) = value_at(xs, ys, now) {
diff --git a/crates/ui-egui/src/dialogs_move.rs b/crates/ui-egui/src/dialogs_move.rs
index b555f4c311..8781e2fadb 100644
--- a/crates/ui-egui/src/dialogs_move.rs
+++ b/crates/ui-egui/src/dialogs_move.rs
@@ -8,7 +8,7 @@ use solidcraft_engine::doc::expr::Kind as ValueKind;
use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
-use crate::dialogs::{Dialog, Kind, combo, field, row_label};
+use crate::dialogs::{Dialog, Kind, combo, field, form_row};
use crate::gizmo::{self, Change, Drag};
use crate::selection::{AXES, BODIES, EDGES, FACES, SelInput, VERTICES};
@@ -46,10 +46,10 @@ pub fn inputs(mode: usize) -> Vec<SelInput> {
/// The Move Type row (above the inputs); switching keeps the bodies and resets the values.
pub fn type_row(d: &mut Dialog, ui: &mut egui::Ui) {
let Kind::Move { mode, .. } = d.kind else { return };
- row_label(ui, "Move Type");
let mut m = mode;
- combo(ui, "move_type", &TYPES, &mut m);
- ui.end_row();
+ form_row(ui, "Move Type", |ui| {
+ combo(ui, "move_type", &TYPES, &mut m);
+ });
if m != mode {
let bodies = d.inputs.first().map(|i| i.items.clone()).unwrap_or_default();
d.kind = kind(m);
@@ -71,9 +71,9 @@ pub fn rows(ui: &mut egui::Ui, k: &mut Kind) -> bool {
let Kind::Move { mode, x, y, z, rx, ry, rz, angle } = k else { return false };
let mut enter = false;
let mut row = |ui: &mut egui::Ui, l: &str, v: &mut String| {
- row_label(ui, l);
- enter |= field(ui, v);
- ui.end_row();
+ form_row(ui, l, |ui| {
+ enter |= field(ui, v);
+ });
};
match *mode {
FREE | TRANSLATE => {
diff --git a/crates/ui-egui/src/dialogs_plastic.rs b/crates/ui-egui/src/dialogs_plastic.rs
index 48dae642ea..8539145d40 100644
--- a/crates/ui-egui/src/dialogs_plastic.rs
+++ b/crates/ui-egui/src/dialogs_plastic.rs
@@ -9,7 +9,7 @@ use solidcraft_engine::doc::plastic::PlasticRule;
use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
-use crate::dialogs::{Kind, combo, face_sel, field, row_label, shown_expr};
+use crate::dialogs::{Kind, combo, face_sel, field, form_row, row_label, shown_expr};
use crate::selection::{BODIES, FACES, PLANAR_FACES, SelInput};
#[derive(Clone, Debug)]
@@ -140,23 +140,22 @@ pub fn start(app: &SolveApp, id: &str) -> Option<(Kind, Vec<SelInput>)> {
Some((Kind::Plastic(pl), inputs))
}
-/// A value row whose empty value means "from the rule" (or another default). `unit` leads the
-/// hint ("mm, from the rule") so the empty field names the unit a typed number takes.
+/// A value row whose empty value means "from the rule" (or another default).
fn opt_field(ui: &mut egui::Ui, label: &str, v: &mut String, unit: &str, hint: &str) -> bool {
- row_label(ui, label);
let hint = format!("{unit}, {}", crate::i18n::tr_label(hint));
- let r = ui.add(egui::TextEdit::singleline(v).hint_text(hint));
- crate::dialogs::publish_row(&r);
- crate::params_dialog::complete(ui, &r, v);
- ui.end_row();
- r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter))
+ form_row(ui, label, |ui| {
+ if crate::ui_kit::contains(ui) {
+ return crate::ui_kit::hint_field(ui, v, &hint);
+ }
+ let r = ui.add(egui::TextEdit::singleline(v).hint_text(hint));
+ crate::dialogs::publish_row(&r);
+ crate::params_dialog::complete(ui, &r, v);
+ r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter))
+ })
}
fn value_row(ui: &mut egui::Ui, label: &str, v: &mut String) -> bool {
- row_label(ui, label);
- let e = field(ui, v);
- ui.end_row();
- e
+ form_row(ui, label, |ui| field(ui, v))
}
/// Directions across a face (with normal `n`) a snap fit's catch can point: two axes and their
@@ -185,28 +184,32 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Pl, inputs: &[SelInpu
Pl::Boss { diameter, height, hole_diameter, hole_depth, draft, fillet, ribs, rib_thickness, rib_length, rib_offset } => {
enter |= value_row(ui, "Diameter", diameter);
enter |= value_row(ui, "Height", height);
- enter |= opt_field(ui, "Hole Diameter", hole_diameter, "mm", "no hole");
- enter |= opt_field(ui, "Hole Depth", hole_depth, "mm", "to the face");
- enter |= opt_field(ui, "Draft Angle", draft, "deg", "from the rule");
- enter |= opt_field(ui, "Root Fillet", fillet, "mm", "none");
- enter |= value_row(ui, "Ribs", ribs);
- if app.session.doc.eval(ribs, ValueKind::Unitless).is_ok_and(|n| n >= 1.0) {
- enter |= value_row(ui, " Rib Thickness", rib_thickness);
- enter |= value_row(ui, " Rib Length", rib_length);
- enter |= value_row(ui, " Rib Offset", rib_offset);
- }
+ crate::ui_kit::section(ui, "boss_options", "Options", true, |ui| {
+ enter |= opt_field(ui, "Hole Diameter", hole_diameter, "mm", "no hole");
+ enter |= opt_field(ui, "Hole Depth", hole_depth, "mm", "to the face");
+ });
+ crate::ui_kit::section(ui, "boss_advanced", "Advanced", false, |ui| {
+ enter |= opt_field(ui, "Draft Angle", draft, "deg", "from the rule");
+ enter |= opt_field(ui, "Root Fillet", fillet, "mm", "none");
+ enter |= value_row(ui, "Ribs", ribs);
+ if app.session.doc.eval(ribs, ValueKind::Unitless).is_ok_and(|n| n >= 1.0) {
+ enter |= value_row(ui, " Rib Thickness", rib_thickness);
+ enter |= value_row(ui, " Rib Length", rib_length);
+ enter |= value_row(ui, " Rib Offset", rib_offset);
+ }
+ });
}
Pl::Lip { groove, width, height, gap, outside } => {
- row_label(ui, "Type");
- let mut ty = usize::from(*groove);
- combo(ui, "pl_lip", &["Lip", "Groove"], &mut ty);
- *groove = ty == 1;
- ui.end_row();
- row_label(ui, "Rim Edge");
- let mut side = usize::from(*outside);
- combo(ui, "pl_side", &["Inside", "Outside"], &mut side);
- *outside = side == 1;
- ui.end_row();
+ form_row(ui, "Type", |ui| {
+ let mut ty = usize::from(*groove);
+ combo(ui, "pl_lip", &["Lip", "Groove"], &mut ty);
+ *groove = ty == 1;
+ });
+ form_row(ui, "Rim Edge", |ui| {
+ let mut side = usize::from(*outside);
+ combo(ui, "pl_side", &["Inside", "Outside"], &mut side);
+ *outside = side == 1;
+ });
enter |= value_row(ui, "Width", width);
enter |= value_row(ui, "Height", height);
if *groove {
@@ -217,9 +220,9 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Pl, inputs: &[SelInpu
let dirs = face_normal(app, inputs).map(hook_dirs).unwrap_or_default();
if !dirs.is_empty() {
let names: Vec<&str> = dirs.iter().map(|(n, _)| n.as_str()).collect();
- row_label(ui, "Catch Direction");
- combo(ui, "pl_hook", &names, hook);
- ui.end_row();
+ form_row(ui, "Catch Direction", |ui| {
+ combo(ui, "pl_hook", &names, hook);
+ });
}
enter |= value_row(ui, "Length", length);
enter |= value_row(ui, "Thickness", thickness);
@@ -228,18 +231,20 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Pl, inputs: &[SelInpu
enter |= value_row(ui, "Catch Length", catch_length);
}
Pl::Rest { round, width, length, height, draft, thickness } => {
- row_label(ui, "Shape");
- let mut sh = usize::from(!*round);
- combo(ui, "pl_rest", &["Round", "Rectangular"], &mut sh);
- *round = sh == 0;
- ui.end_row();
+ form_row(ui, "Shape", |ui| {
+ let mut sh = usize::from(!*round);
+ combo(ui, "pl_rest", &["Round", "Rectangular"], &mut sh);
+ *round = sh == 0;
+ });
enter |= value_row(ui, if *round { "Diameter" } else { "Width" }, width);
if !*round {
enter |= value_row(ui, "Length", length);
}
enter |= value_row(ui, "Height", height);
- enter |= opt_field(ui, "Draft Angle", draft, "deg", "from the rule");
- enter |= opt_field(ui, "Wall Thickness", thickness, "mm", "solid");
+ crate::ui_kit::section(ui, "rest_advanced", "Advanced", false, |ui| {
+ enter |= opt_field(ui, "Draft Angle", draft, "deg", "from the rule");
+ enter |= opt_field(ui, "Wall Thickness", thickness, "mm", "solid");
+ });
}
Pl::Rules { pick, name, values, active, loaded } => {
let rules = app.session.doc.plastic_rules();
@@ -280,9 +285,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Pl, inputs: &[SelInpu
let mut names: Vec<String> = vec!["(no rule)".into()];
names.extend(app.session.doc.plastic_rules().into_iter().map(|r| r.name));
let refs: Vec<&str> = names.iter().map(String::as_str).collect();
- row_label(ui, "Rule");
- combo(ui, "pl_assign", &refs, rule);
- ui.end_row();
+ form_row(ui, "Rule", |ui| combo(ui, "pl_assign", &refs, rule));
}
}
enter
diff --git a/crates/ui-egui/src/dialogs_save_mesh.rs b/crates/ui-egui/src/dialogs_save_mesh.rs
index ccaf2c3972..fd5025a222 100644
--- a/crates/ui-egui/src/dialogs_save_mesh.rs
+++ b/crates/ui-egui/src/dialogs_save_mesh.rs
@@ -126,7 +126,13 @@ fn paint_icon(ui: &egui::Ui, rect: egui::Rect, tex: Option<egui::TextureId>, nam
let t = Tokens::get();
ui.painter().rect_filled(rect, 3.0, t.chip);
let letter = name.chars().next().map(|c| c.to_uppercase().to_string()).unwrap_or_default();
- ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, letter, egui::FontId::proportional(11.0), t.text);
+ ui.painter().text(
+ rect.center(),
+ egui::Align2::CENTER_CENTER,
+ letter,
+ egui::FontId::proportional(crate::theme::Tokens::get().font_small),
+ t.text,
+ );
}
}
}
@@ -196,7 +202,7 @@ fn slicer_combo(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh) {
rect.left_center() + vec2(ICON + 9.0, 0.0),
egui::Align2::LEFT_CENTER,
&e.slicer.name,
- egui::FontId::proportional(13.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_button),
ui.visuals().text_color(),
);
crate::scenario::publish_handle(&format!("dialog:Slicer:{}", e.slicer.name), rect.center());
@@ -223,7 +229,7 @@ fn slicer_combo(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh) {
rect.left_center() + vec2(ICON + 9.0, 0.0),
egui::Align2::LEFT_CENTER,
crate::i18n::tr_label("Custom…"),
- egui::FontId::proportional(13.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_button),
Tokens::get().text,
);
crate::scenario::publish_handle("dialog:Slicer:Custom", rect.center());
diff --git a/crates/ui-egui/src/dialogs_sheet.rs b/crates/ui-egui/src/dialogs_sheet.rs
index d3eb6cedcd..48982b8cc7 100644
--- a/crates/ui-egui/src/dialogs_sheet.rs
+++ b/crates/ui-egui/src/dialogs_sheet.rs
@@ -12,7 +12,7 @@ use solidcraft_engine::doc::{FeatureKind, ProfileSel};
use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
-use crate::dialogs::{Dialog, Kind, combo, edge_sel, face_sel, field, profile_indices, row_label};
+use crate::dialogs::{Dialog, Kind, combo, edge_sel, face_sel, field, form_row, profile_indices, row_label};
use crate::selection::{AXES, BODIES, CURVES, EDGES, PLANAR_FACES, PROFILES, SelInput};
use crate::theme::Tokens;
@@ -186,9 +186,9 @@ fn rule_names(app: &SolveApp) -> Vec<String> {
fn rule_combo(app: &SolveApp, ui: &mut egui::Ui, id: &str, rule: &mut usize) {
let names = rule_names(app);
let refs: Vec<&str> = names.iter().map(String::as_str).collect();
- row_label(ui, "Rule");
- combo(ui, id, &refs, rule);
- ui.end_row();
+ form_row(ui, "Rule", |ui| {
+ combo(ui, id, &refs, rule);
+ });
}
/// The flange type the picks make: edges an edge flange, sketch lines a contour, else base.
@@ -210,110 +210,104 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Sm, inputs: &mut [Sel
match k {
Sm::Flange { ty, height, angle, radius, position, flip, distance, reverse, rule, own, relief, relief_size } => {
*ty = flange_type(inputs);
- row_label(ui, "Type");
- ui.label(FLANGE_TYPES.get(*ty).copied().unwrap_or(""));
- ui.end_row();
+ form_row(ui, "Type", |ui| {
+ ui.label(FLANGE_TYPES.get(*ty).copied().unwrap_or(""));
+ });
match *ty {
1 => {
- row_label(ui, "Height");
- enter |= field(ui, height);
- ui.end_row();
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- row_label(ui, "Bend Position");
- combo(ui, "sm_pos", &POSITION_LABELS, position);
- ui.end_row();
- row_label(ui, "Bend Radius");
- let r = ui.add(egui::TextEdit::singleline(radius).hint_text(crate::i18n::tr_label("from the rule")));
- crate::params_dialog::complete(ui, &r, radius);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- // The relief at the corners these flanges make: the rule's unless set here.
- row_label(ui, "Corner Relief Shape");
- combo(ui, "sm_flange_relief", &FLANGE_RELIEF_LABELS, relief);
- ui.end_row();
- row_label(ui, "Corner Relief");
- let r = ui.add(egui::TextEdit::singleline(relief_size).hint_text(crate::i18n::tr_label("from the rule")));
- crate::params_dialog::complete(ui, &r, relief_size);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- // With several edges, a row for each: an angle and a height of its own, left
- // empty for the values above (shown as the hints).
- let points = edge_point_list(inputs);
- if points.len() > 1 || own.iter().any(|o| !(o.1.trim().is_empty() && o.2.trim().is_empty())) {
- row_label(ui, "Per Edge");
- ui.label(RichText::new(crate::i18n::tr_label("angle, height")).weak())
- .on_hover_text("An edge's own angle and height. Empty: the values above.");
- ui.end_row();
- let w = ((ui.spacing().text_edit_width - ui.spacing().item_spacing.x) / 2.0).max(40.0);
- for (n, p) in points.iter().enumerate() {
- let slot = own_slot(own, *p);
- let Some((_, a, h)) = own.get_mut(slot) else { continue };
- row_label(ui, &format!("Edge {}", n + 1));
- ui.horizontal(|ui| {
- for (text, hint, what, id) in
- [(a, angle.as_str(), "angle", "sm_edge_angle"), (h, height.as_str(), "height", "sm_edge_height")]
- {
- let r = ui
- .add(egui::TextEdit::singleline(text).hint_text(hint).desired_width(w).id_salt((id, n)))
- .on_hover_text(format!("The {what} of the edge picked at ({:.1}, {:.1}, {:.1})", p.x, p.y, p.z));
- // For scenarios and the control channel: `dialog:Edge 2 angle`.
- crate::scenario::publish_handle(&format!("dialog:Edge {} {what}", n + 1), r.rect.center());
- crate::params_dialog::complete(ui, &r, text);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- }
+ form_row(ui, "Height", |ui| {
+ enter |= field(ui, height);
+ });
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ form_row(ui, "Bend Position", |ui| {
+ combo(ui, "sm_pos", &POSITION_LABELS, position);
+ });
+ crate::ui_kit::section(ui, "flange_advanced", "Advanced", false, |ui| {
+ form_row(ui, "Bend Radius", |ui| {
+ enter |= crate::ui_kit::hint_field(ui, radius, crate::i18n::tr_label("from the rule"));
+ });
+ // The relief at the corners these flanges make: the rule's unless set here.
+ form_row(ui, "Corner Relief Shape", |ui| {
+ combo(ui, "sm_flange_relief", &FLANGE_RELIEF_LABELS, relief);
+ });
+ form_row(ui, "Corner Relief", |ui| {
+ enter |= crate::ui_kit::hint_field(ui, relief_size, crate::i18n::tr_label("from the rule"));
+ });
+ // With several edges, a row for each: an angle and a height of its own, left
+ // empty for the values above (shown as the hints).
+ let points = edge_point_list(inputs);
+ if points.len() > 1 || own.iter().any(|o| !(o.1.trim().is_empty() && o.2.trim().is_empty())) {
+ form_row(ui, "Per Edge", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("angle, height")).weak())
+ .on_hover_text("An edge's own angle and height. Empty: the values above.");
});
- ui.end_row();
+ for (n, p) in points.iter().enumerate() {
+ let slot = own_slot(own, *p);
+ let Some((_, a, h)) = own.get_mut(slot) else { continue };
+ form_row(ui, &format!("Edge {}", n + 1), |ui| {
+ ui.horizontal(|ui| {
+ let w = ((ui.available_width() - ui.spacing().item_spacing.x) / 2.0).max(0.0);
+ for (text, hint, what, id) in
+ [(a, angle.as_str(), "angle", "sm_edge_angle"), (h, height.as_str(), "height", "sm_edge_height")]
+ {
+ ui.push_id((id, n), |ui| {
+ ui.allocate_ui_with_layout(
+ vec2(w, Tokens::get().control_height),
+ egui::Layout::left_to_right(egui::Align::Center),
+ |ui| {
+ enter |= crate::ui_kit::hint_field(ui, text, hint);
+ },
+ );
+ let at = ui.min_rect().center();
+ crate::scenario::publish_handle(&format!("dialog:Edge {} {what}", n + 1), at);
+ });
+ }
+ });
+ });
+ }
}
- }
+ });
}
2 => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- row_label(ui, "Other side");
- ui.checkbox(reverse, "");
- ui.end_row();
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+
rule_combo(app, ui, "sm_rule", rule);
}
_ => rule_combo(app, ui, "sm_rule", rule),
}
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
+ if *ty == 2 {
+ crate::ui_kit::options(ui, "sheet_options", &mut [("Flip", flip), ("Other side", reverse)]);
+ } else {
+ crate::ui_kit::options(ui, "sheet_options", &mut [("Flip", flip)]);
+ }
}
Sm::Hem { length, gap, flip } => {
- row_label(ui, "Type");
- ui.label(crate::i18n::tr_label("Flat"));
- ui.end_row();
- row_label(ui, "Length");
- enter |= field(ui, length);
- ui.end_row();
- row_label(ui, "ui.sheet_gap");
- let r = ui.add(egui::TextEdit::singleline(gap).hint_text(crate::i18n::tr_label("from the rule")));
- crate::params_dialog::complete(ui, &r, gap);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
+ form_row(ui, "Type", |ui| {
+ ui.label(crate::i18n::tr_label("Flat"));
+ });
+ form_row(ui, "Length", |ui| {
+ enter |= field(ui, length);
+ });
+ form_row(ui, "ui.sheet_gap", |ui| {
+ enter |= crate::ui_kit::hint_field(ui, gap, crate::i18n::tr_label("from the rule"));
+ });
+ crate::ui_kit::options(ui, "sheet_options", &mut [("Flip", flip)]);
}
Sm::Fold { angle, radius, position, flip } => {
- row_label(ui, "Bend Line Position");
- combo(ui, "sm_fold_pos", &FOLD_POSITION_LABELS, position);
- ui.end_row();
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- row_label(ui, "Bend Radius");
- let r = ui.add(egui::TextEdit::singleline(radius).hint_text(crate::i18n::tr_label("from the rule")));
- crate::params_dialog::complete(ui, &r, radius);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
+ form_row(ui, "Bend Line Position", |ui| {
+ combo(ui, "sm_fold_pos", &FOLD_POSITION_LABELS, position);
+ });
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ form_row(ui, "Bend Radius", |ui| {
+ enter |= crate::ui_kit::hint_field(ui, radius, crate::i18n::tr_label("from the rule"));
+ });
+ crate::ui_kit::options(ui, "sheet_options", &mut [("Flip", flip)]);
}
Sm::Unfold { .. } => {}
Sm::Convert { rule } => rule_combo(app, ui, "sm_conv_rule", rule),
@@ -849,7 +843,13 @@ pub fn overlay(app: &mut SolveApp, painter: &egui::Painter, rect: Rect, d: &Dial
let (up_col, down_col) = bend_colors();
painter.rect_filled(rect, 0.0, t.panel);
let Some(Ok(v)) = data else {
- painter.text(rect.center(), Align2::CENTER_CENTER, "no sheet metal body", FontId::proportional(14.0), t.text_dim);
+ painter.text(
+ rect.center(),
+ Align2::CENTER_CENTER,
+ "no sheet metal body",
+ FontId::proportional(crate::theme::Tokens::get().font_heading),
+ t.text_dim,
+ );
return true;
};
let read = |p: &Value| -> Option<(f64, f64)> { Some((p.get(0)?.as_f64()?, p.get(1)?.as_f64()?)) };
@@ -926,7 +926,7 @@ pub fn overlay(app: &mut SolveApp, painter: &egui::Painter, rect: Rect, d: &Dial
}
}
for (anchor, labels) in pocket_annotations {
- painter.text(anchor, Align2::CENTER_BOTTOM, labels.join("\n"), FontId::proportional(12.0), t.accent);
+ painter.text(anchor, Align2::CENTER_BOTTOM, labels.join("\n"), FontId::proportional(crate::theme::Tokens::get().font_body), t.accent);
}
for b in v["bends"].as_array().into_iter().flatten() {
let (Some(a), Some(e)) = (read(&b["start"]), read(&b["end"])) else { continue };
@@ -935,11 +935,17 @@ pub fn overlay(app: &mut SolveApp, painter: &egui::Painter, rect: Rect, d: &Dial
}
// Legend.
let mut y = rect.top() + 14.0;
- painter.text(pos2(rect.left() + 14.0, y), Align2::LEFT_TOP, "FLAT PATTERN", FontId::proportional(13.0), t.text);
+ painter.text(
+ pos2(rect.left() + 14.0, y),
+ Align2::LEFT_TOP,
+ "FLAT PATTERN",
+ FontId::proportional(crate::theme::Tokens::get().font_button),
+ t.text,
+ );
for (label, col) in [("Bend up", up_col), ("Bend down", down_col)] {
y += 20.0;
painter.line_segment([pos2(rect.left() + 14.0, y + 7.0), pos2(rect.left() + 38.0, y + 7.0)], Stroke::new(2.0, col));
- painter.text(pos2(rect.left() + 44.0, y), Align2::LEFT_TOP, label, FontId::proportional(12.0), t.text_dim);
+ painter.text(pos2(rect.left() + 44.0, y), Align2::LEFT_TOP, label, FontId::proportional(crate::theme::Tokens::get().font_body), t.text_dim);
}
if !pockets.is_empty() {
y += 20.0;
@@ -949,7 +955,13 @@ pub fn overlay(app: &mut SolveApp, painter: &egui::Painter, rect: Rect, d: &Dial
3.0,
3.0,
));
- painter.text(pos2(rect.left() + 44.0, y), Align2::LEFT_TOP, "Pocket boundary (material remains)", FontId::proportional(12.0), t.text_dim);
+ painter.text(
+ pos2(rect.left() + 44.0, y),
+ Align2::LEFT_TOP,
+ "Pocket boundary (material remains)",
+ FontId::proportional(crate::theme::Tokens::get().font_body),
+ t.text_dim,
+ );
}
true
}
diff --git a/crates/ui-egui/src/dialogs_sheet_tests.rs b/crates/ui-egui/src/dialogs_sheet_tests.rs
index 20fd1d8b1a..6f0ddd909b 100644
--- a/crates/ui-egui/src/dialogs_sheet_tests.rs
+++ b/crates/ui-egui/src/dialogs_sheet_tests.rs
@@ -126,9 +126,9 @@ fn flat_exports_use_the_save_picker() {
Box::pin(std::future::ready(None))
}));
assert_eq!(export_flat(&mut app, "Base", "csv"), "Choose an export file…");
- crate::file_picker::tick(&mut app, &egui::Context::default());
+ crate::file_picker::tick(&mut app, &crate::fonts::test_context());
assert_eq!(export_flat(&mut app, "Base", "dxf"), "Choose an export file…");
- crate::file_picker::tick(&mut app, &egui::Context::default());
+ crate::file_picker::tick(&mut app, &crate::fonts::test_context());
let picks = picks.lock().unwrap();
assert!(picks[0].0.ends_with("-Base.csv"));
assert_eq!(picks[0].1, vec!["csv"]);
@@ -153,7 +153,7 @@ fn shallow_pocket_overlay_labels_depth_without_drawing_a_through_void() {
let mut dialog = app.dialog.clone().unwrap();
let Kind::Sheet(Sm::FlatPattern { data, .. }) = &mut dialog.kind else { panic!("flat dialog") };
*data = Some(Ok(flat));
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("flat-pocket-test")));
assert!(overlay(&mut app, &painter, Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0)), &dialog));
@@ -211,7 +211,7 @@ fn flat_pattern_islands_fit_before_the_actual_command_panel() {
if mode == crate::shell::LayoutMode::Floating {
app.shell.content = Some(Rect::from_min_max(pos2(browser.right(), viewport.top()), pos2(viewport.right(), history.top())));
}
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let id = egui::Id::new(("sc_dialog", "FLAT PATTERN"));
let mut output = egui::FullOutput::default();
for _ in 0..3 {
@@ -273,7 +273,7 @@ fn coincident_top_and_bottom_pocket_depths_share_a_readable_annotation() {
let mut dialog = app.dialog.clone().unwrap();
let Kind::Sheet(Sm::FlatPattern { data, .. }) = &mut dialog.kind else { panic!("flat dialog") };
*data = Some(Ok(flat));
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Middle, egui::Id::new("coincident-pocket-test")));
assert!(overlay(&mut app, &painter, Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0)), &dialog));
@@ -348,7 +348,7 @@ fn bend_table_picker_writes_the_current_body() {
}));
let undo = app.session.undo.len();
assert_eq!(export_flat(&mut app, &body, "csv"), "Choose an export file…");
- crate::file_picker::tick(&mut app, &egui::Context::default());
+ crate::file_picker::tick(&mut app, &crate::fonts::test_context());
assert_eq!(app.status.as_ref().map(|s| &s.0), Some(&format!("Exported {output}")));
let contents = std::fs::read_to_string(&path).unwrap();
std::fs::remove_file(&path).unwrap();
@@ -506,6 +506,8 @@ fn flange_dialog_picks_a_corner_relief_of_its_own() {
let d = h.app.dialog.clone().unwrap();
let c = apply_commands(&h.app, &d).unwrap();
assert!(c[0].1.get("corner_relief_shape").is_none() && c[0].1.get("corner_relief").is_none(), "{}", c[0].1);
+ // The optional overrides live in the collapsed Advanced group.
+ h.step(&json!({"click": {"handle": "dialog:section:Advanced"}})).unwrap();
// Round from the selector, 6 mm in the size row.
h.step(&json!({"click": {"handle": "dialog:Corner Relief Shape"}})).unwrap();
h.step(&json!({"click": {"handle": "dialog:Corner Relief Shape:Round"}})).unwrap();
@@ -707,7 +709,7 @@ fn flat_pattern_pans_and_zooms_like_the_design_viewport() {
let chords = [none, Modifiers::SHIFT, Modifiers::CTRL, Modifiers::ALT, Modifiers::SHIFT | Modifiers::ALT];
for preset in crate::prefs::NAV_PRESETS.iter().map(|p| p.id) {
for (reverse, to_cursor) in [(false, true), (true, true), (false, false)] {
- let (flat_ctx, design_ctx) = (egui::Context::default(), egui::Context::default());
+ let (flat_ctx, design_ctx) = (crate::fonts::test_context(), crate::fonts::test_context());
let mut flat = flat_app(preset, mode);
let mut design = flat_app(preset, mode);
design.dialog = None;
@@ -805,7 +807,7 @@ fn design_camera_is_unchanged_while_the_flat_pattern_has_focus() {
use egui::{Event, Modifiers, PointerButton};
let none = Modifiers::NONE;
for preset in crate::prefs::NAV_PRESETS.iter().map(|p| p.id) {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = flat_app(preset, mode);
let mut t = 0.0;
frame(&mut app, &ctx, &mut t, none, vec![]);
@@ -838,7 +840,7 @@ fn design_camera_is_unchanged_while_the_flat_pattern_has_focus() {
#[test]
fn fit_and_home_frame_the_flat_pattern() {
for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = flat_app("fusion", mode);
let mut t = 0.0;
let none = egui::Modifiers::NONE;
diff --git a/crates/ui-egui/src/dialogs_sketch_tests.rs b/crates/ui-egui/src/dialogs_sketch_tests.rs
new file mode 100644
index 0000000000..01918d4141
--- /dev/null
+++ b/crates/ui-egui/src/dialogs_sketch_tests.rs
@@ -0,0 +1,209 @@
+//! Every legacy sketch popup uses the same card as the feature dialogs.
+use super::*;
+use crate::scenario::{self, Harness};
+use crate::sketch_modify_ui::Mod;
+
+fn fixture() -> Harness {
+ let mut h = Harness::new();
+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
+ h.app.run("sketch.rectangle.two_point", json!({"p0":[10,10],"p1":[40,30]})).unwrap();
+ h.frames(3);
+ h
+}
+
+fn picked(h: &Harness, command: &str) -> Dialog {
+ let mut d = Dialog::for_command(&h.app, command).unwrap();
+ let sk = h.app.session.doc.sketch(h.app.session.active_sketch.unwrap()).unwrap();
+ if let Kind::SketchModify(k) = &d.kind {
+ d.inputs[0].items = vec![if matches!(k, Mod::Corner { .. }) {
+ Sel::SketchPoint { id: sk.points.iter().find(|p| p.id != "origin").unwrap().id.clone() }
+ } else {
+ Sel::SketchCurve { id: sk.curves[0].id.clone() }
+ }];
+ if matches!(k, Mod::Mirror) {
+ d.inputs[1].items = vec![Sel::SketchCurve { id: sk.curves[3].id.clone() }];
+ }
+ if matches!(k, Mod::PatternCirc { .. }) {
+ d.inputs[1].items = vec![Sel::SketchPoint { id: "origin".into() }];
+ }
+ }
+ if let Kind::SketchModify(Mod::Move { x, .. }) = &mut d.kind {
+ *x = "2 mm".into();
+ }
+ d
+}
+
+fn card(h: &Harness) {
+ let outer = scenario::rect_of("dialog:card").unwrap();
+ for key in ["dialog:header", "dialog:hint:tool", "dialog:footer"] {
+ assert!(outer.expand(1.0).contains_rect(scenario::rect_of(key).unwrap()), "{key}");
+ }
+ for key in ["dialog:close", "dialog:ok", "dialog:cancel"] {
+ assert!(outer.contains(scenario::handle_at(key).unwrap()), "{key}");
+ }
+ if let Some(palette) = h.app.viewport.palette_rect {
+ assert!(!palette.intersects(outer), "{outer:?} / {palette:?}");
+ }
+}
+
+fn form(command: &str, labels: &[&str]) {
+ let mut h = fixture();
+ let d = picked(&h, command);
+ let expected = apply_commands(&h.app, &d).unwrap();
+ assert_eq!(expected[0].0, command);
+ assert_eq!(super::command(&d.kind), Some(command));
+ let before = h.app.session.doc.to_json();
+ h.app.dialog = Some(d);
+ h.frames(6);
+ card(&h);
+ let d = h.app.dialog.as_ref().unwrap();
+ assert_eq!(apply_commands(&h.app, d).unwrap(), expected, "rendering retains all command parameters");
+ assert_eq!(h.app.session.doc.to_json(), before, "preview never commits");
+ for label in d.inputs.iter().map(|i| i.label).chain(labels.iter().copied()) {
+ let rect = scenario::rect_of(&format!("dialog:row:{label}")).unwrap_or_else(|| panic!("{command}: missing {label}"));
+ assert_eq!(rect.height(), Tokens::get().control_height);
+ }
+ let spec = solidcraft_engine::find_command(command).unwrap();
+ assert!(h.widget(spec.label).is_some(), "header uses command label");
+ assert!(!spec.icon.is_empty());
+ h.step(&json!({"click":{"handle":"dialog:cancel"}})).unwrap();
+ assert!(h.app.dialog.is_none());
+ assert_eq!(h.app.session.doc.to_json(), before);
+}
+
+macro_rules! form_case {
+ ($name:ident, $id:literal, [$($label:literal),*]) => {
+ #[test] fn $name() { form($id, &[$($label),*]); }
+ };
+}
+
+form_case!(scale, "sketch.scale", ["Factor"]);
+form_case!(offset, "sketch.offset", ["Direction", "Distance"]);
+form_case!(mirror, "sketch.mirror", []);
+form_case!(move_copy, "sketch.move", ["Position", "Angle"]);
+form_case!(rectangular_pattern, "sketch.pattern.rectangular", ["Quantity", "Spacing", "Alignment", "Quantity 2", "Spacing 2", "Alignment 2"]);
+form_case!(circular_pattern, "sketch.pattern.circular", ["Quantity", "Total angle", "Alignment"]);
+form_case!(fillet, "sketch.fillet", ["Radius"]);
+form_case!(chamfer_equal, "sketch.chamfer.equal_distance", ["Chamfer Type", "Distance"]);
+form_case!(chamfer_two, "sketch.chamfer.two_distance", ["Chamfer Type", "Distance 1", "Distance 2"]);
+form_case!(chamfer_angle, "sketch.chamfer.distance_angle", ["Chamfer Type", "Distance 1", "Angle"]);
+
+#[test]
+fn create_sketch_uses_card_and_still_starts_immediately_on_plane_pick() {
+ let mut h = Harness::new();
+ h.app.start("sketch.create");
+ h.frames(4);
+ card(&h);
+ assert!(scenario::rect_of("dialog:field:Plane").is_some());
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0));
+ h.step(&json!({"click":{"plane":"XY"}})).unwrap();
+ assert!(h.app.dialog.is_none());
+ assert!(h.app.session.active_sketch.is_some());
+}
+
+#[test]
+fn apply_commits_once_keeps_values_and_waits_for_new_selection_ok_closes() {
+ for command in ["sketch.offset", "sketch.mirror", "sketch.pattern.rectangular", "sketch.pattern.circular"] {
+ let mut h = fixture();
+ h.app.dialog = Some(picked(&h, command));
+ h.settle();
+ let before = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(1.0), "{command}");
+ let undo = h.app.session.undo.len();
+ h.step(&json!({"click":{"handle":"dialog:apply"}})).unwrap();
+ h.settle();
+ assert_eq!(h.app.session.undo.len(), undo + 1, "{command}: one Apply, one undo");
+ let d = h.app.dialog.as_ref().unwrap();
+ assert!(d.inputs.iter().all(|i| i.items.is_empty()));
+ assert_eq!(d.active, 0);
+ // Repick the original input; the numeric values are unchanged.
+ let next = picked(&h, command);
+ h.app.dialog.as_mut().unwrap().inputs = next.inputs;
+ let after = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
+ assert_eq!(before, after);
+ h.settle();
+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();
+ h.settle();
+ assert!(h.app.dialog.is_none(), "{command}: OK closes");
+ }
+}
+
+#[test]
+fn picked_list_removes_one_item_and_field_still_activates_input() {
+ let mut h = fixture();
+ let mut d = picked(&h, "sketch.scale");
+ let second = h.app.session.doc.sketch(1).unwrap().curves[1].id.clone();
+ d.inputs[0].items.push(Sel::SketchCurve { id: second.clone() });
+ h.app.dialog = Some(d);
+ h.frames(4);
+ h.step(&json!({"click":{"handle":"dialog:list:Entities:0:remove"}})).unwrap();
+ assert_eq!(h.app.dialog.as_ref().unwrap().inputs[0].items, vec![Sel::SketchCurve { id: second }]);
+ h.step(&json!({"click":{"handle":"dialog:Base point"}})).unwrap();
+ assert_eq!(h.app.dialog.as_ref().unwrap().active, 1);
+}
+
+#[test]
+fn panel_dimension_preserves_expression_and_command_and_ok_closes() {
+ let mut h = fixture();
+ h.app.run("parameters.add", json!({"name":"span","expression":"3 mm"})).unwrap();
+ h.app.dialog = Some(Dialog::edit_param(&h.app.session, "span"));
+ h.frames(4);
+ card(&h);
+ assert!(h.ctx.memory(|m| m.focused().is_some()), "single-value popup takes keyboard focus on open");
+ h.step(&json!({"click":{"handle":"dialog:span"}})).unwrap();
+ h.step(&json!({"key":"A","cmd":true})).unwrap();
+ h.step(&json!({"text":"2 * 5 mm"})).unwrap();
+ let commands = apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
+ assert_eq!(commands, vec![("parameters.change".into(), json!({"name":"span","expression":"2 * 5 mm"}))]);
+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();
+ assert!(h.app.dialog.is_none());
+ assert_eq!(h.app.session.doc.param("span").unwrap().expr, "2 * 5 mm");
+}
+
+#[test]
+fn text_and_text_move_cards_preserve_parameters_and_cancel_live_edits() {
+ let mut h = fixture();
+ let out = h.app.run("sketch.text", json!({"text":"II","at":[50,20],"height":8})).unwrap();
+ h.app.session.selection = vec![Sel::SketchCurve { id: out["curves"][0].as_str().unwrap().into() }];
+ h.app.start("sketch.edit_text");
+ h.frames(4);
+ card(&h);
+ for label in ["Text", "Font", "Style", "Alignment", "Position", "Height", "Angle", "Letter Spacing", "Line Spacing", "Path"] {
+ assert!(scenario::rect_of(&format!("dialog:row:{label}")).is_some(), "{label}");
+ }
+ let before = h.app.session.doc.to_json();
+ h.step(&json!({"text":"Changed"})).unwrap();
+ h.step(&json!({"click":{"handle":"dialog:cancel"}})).unwrap();
+ assert_eq!(h.app.session.doc.to_json(), before);
+ h.app.session.selection = vec![Sel::SketchCurve { id: out["curves"][0].as_str().unwrap().into() }];
+ h.app.start("sketch.move");
+ h.frames(4);
+ card(&h);
+ assert!(matches!(h.app.dialog.as_ref().unwrap().kind, Kind::TextMove(_)));
+ assert!(scenario::handle_at("dialog:Distance X").is_some());
+ assert!(scenario::handle_at("dialog:Distance Y").is_some());
+ assert!(scenario::handle_at("dialog:Create Copy").is_some());
+ h.step(&json!({"click":{"handle":"dialog:ok"}})).unwrap();
+ assert!(h.app.dialog.is_none());
+}
+
+#[test]
+fn apply_keeps_the_panel_open_after_asynchronous_evaluation() {
+ let mut h = fixture();
+ let mut d = picked(&h, "sketch.pattern.rectangular");
+ let cmds = apply_commands(&h.app, &d).unwrap();
+ d.repeat_after_apply = true;
+ h.app.dialog = Some(d);
+ let (finish, done) = std::sync::mpsc::channel();
+ h.app.applying = Some(Applying { done, started: crate::now_ms(), cmds });
+ let undo = h.app.session.undo.len();
+ h.frames(2);
+ assert_eq!(h.app.session.undo.len(), undo);
+ finish.send(()).unwrap();
+ h.frames(3);
+ assert!(h.app.applying.is_none());
+ let d = h.app.dialog.as_ref().unwrap();
+ assert_eq!(h.app.session.undo.len(), undo + 1);
+ assert!(d.inputs.iter().all(|i| i.items.is_empty()));
+ assert!(!d.repeat_after_apply);
+}
diff --git a/crates/ui-egui/src/dialogs_surface.rs b/crates/ui-egui/src/dialogs_surface.rs
index 0a88aa69a7..78014c4585 100644
--- a/crates/ui-egui/src/dialogs_surface.rs
+++ b/crates/ui-egui/src/dialogs_surface.rs
@@ -9,8 +9,9 @@ use solidcraft_engine::doc::{AxisRef, Direction, FaceAt, FeatureKind, Mat, Plane
use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
-use crate::dialogs::{Kind, OP_LABELS, OPS, combo, field, op_index, row_label};
+use crate::dialogs::{Kind, OP_LABELS, OPS, combo, field, form_row, op_index};
use crate::selection::{AXES, BODIES, CURVES, EDGES, FACES, PLANES, PROFILES, SelInput, VERTICES};
+use crate::ui_kit;
/// A surface tool dialog's values.
#[derive(Clone, Debug, PartialEq)]
@@ -220,131 +221,111 @@ pub fn rows(ui: &mut egui::Ui, k: &mut Surf) -> bool {
let mut enter = false;
match k {
Surf::Stitch { tolerance } => {
- row_label(ui, "Tolerance");
- let r = ui.add(egui::TextEdit::singleline(tolerance).hint_text("tight"));
- crate::theme::TabAccent::number_focus(ui, &r);
- crate::params_dialog::complete(ui, &r, tolerance);
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
+ form_row(ui, "Tolerance", |ui| {
+ enter |= crate::ui_kit::hint_field(ui, tolerance, "tight");
+ });
}
Surf::Thicken { thickness, symmetric, operation } => {
- row_label(ui, "Thickness");
- enter |= field(ui, thickness);
- ui.end_row();
- row_label(ui, "Direction");
- let mut dir = usize::from(*symmetric);
- combo(ui, "th_dir", &["One Side", "Symmetric"], &mut dir);
- *symmetric = dir == 1;
- ui.end_row();
- row_label(ui, "Operation");
- combo(ui, "th_op", &OP_LABELS, operation);
- ui.end_row();
+ form_row(ui, "Thickness", |ui| {
+ enter |= field(ui, thickness);
+ });
+ form_row(ui, "Direction", |ui| {
+ let mut dir = usize::from(*symmetric);
+ ui_kit::segmented(ui, &mut dir, &["One Side", "Symmetric"]);
+ *symmetric = dir == 1;
+ });
+ form_row(ui, "Operation", |ui| {
+ combo(ui, "th_op", &OP_LABELS, operation);
+ });
}
Surf::Extend { distance } => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
}
Surf::Revolve { angle, symmetric, .. } => {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- row_label(ui, "Direction");
- let mut dir = usize::from(*symmetric);
- combo(ui, "sr_dir", &["One Side", "Symmetric"], &mut dir);
- *symmetric = dir == 1;
- ui.end_row();
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
+ form_row(ui, "Direction", |ui| {
+ let mut dir = usize::from(*symmetric);
+ ui_kit::segmented(ui, &mut dir, &["One Side", "Symmetric"]);
+ *symmetric = dir == 1;
+ });
}
Surf::Offset { distance, chain } => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- row_label(ui, "Tangent chain");
- ui.checkbox(chain, "");
- ui.end_row();
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+ ui_kit::options(ui, "offset_options", &mut [("Tangent chain", chain)]);
}
Surf::Ruled { distance, mode, angle, flip, round } => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- row_label(ui, "Type");
- combo(ui, "ru_mode", &RULED_MODES.map(|(label, _)| label), mode);
- ui.end_row();
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+ form_row(ui, "Type", |ui| {
+ combo(ui, "ru_mode", &RULED_MODES.map(|(label, _)| label), mode);
+ });
if RULED_MODES.get(*mode).is_some_and(|(_, m)| *m == "angle") {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
+ form_row(ui, "Angle", |ui| {
+ enter |= field(ui, angle);
+ });
}
- row_label(ui, "Corners");
- let mut corner = usize::from(*round);
- combo(ui, "ru_corners", &["Mitre", "Round"], &mut corner);
- *round = corner == 1;
- ui.end_row();
- row_label(ui, "Flip");
- ui.checkbox(flip, "");
- ui.end_row();
+ form_row(ui, "Corners", |ui| {
+ let mut corner = usize::from(*round);
+ ui_kit::segmented(ui, &mut corner, &["Mitre", "Round"]);
+ *round = corner == 1;
+ });
+ ui_kit::options(ui, "ruled_options", &mut [("Flip", flip)]);
}
Surf::Extrude { distance, direction } => {
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
- row_label(ui, "Direction");
- combo(ui, "sx_dir", &EXTRUDE_SIDES.map(|(label, _)| label), direction);
- ui.end_row();
+ form_row(ui, "Distance", |ui| {
+ enter |= field(ui, distance);
+ });
+ form_row(ui, "Direction", |ui| {
+ ui_kit::segmented(ui, direction, &EXTRUDE_SIDES.map(|(label, _)| label));
+ });
}
Surf::Untrim { holes, outer, in_place } => {
- row_label(ui, "Holes");
- combo(ui, "ut_holes", &UNTRIM_HOLES, holes);
- ui.end_row();
- row_label(ui, "Restore outer boundary");
- ui.checkbox(outer, "");
- ui.end_row();
- row_label(ui, "In place (surfaces)");
- ui.checkbox(in_place, "");
- ui.end_row();
+ form_row(ui, "Holes", |ui| {
+ combo(ui, "ut_holes", &UNTRIM_HOLES, holes);
+ });
+ ui_kit::options(ui, "untrim_options", &mut [("Restore outer boundary", outer), ("In place (surfaces)", in_place)]);
}
Surf::Patch { continuity } => {
- row_label(ui, "Continuity");
- combo(ui, "pa_cont", &PATCH_CONTINUITY.map(|(label, _)| label), continuity);
- ui.end_row();
+ form_row(ui, "Continuity", |ui| {
+ ui_kit::segmented(ui, continuity, &PATCH_CONTINUITY.map(|(label, _)| label));
+ });
}
Surf::Blend { continuity, bulge, stitch } => {
- // One row per end, so the dialog keeps its docked width.
let [from, to] = continuity;
let [from_bulge, to_bulge] = bulge;
- row_label(ui, "Start continuity");
- combo(ui, "bl_cont0", &BLEND_CONTINUITY.map(|(label, _)| label), from);
- ui.end_row();
- row_label(ui, "Start bulge");
- ui.add(egui::DragValue::new(from_bulge).range(-0.9..=3.0).speed(0.01).max_decimals(2));
- ui.end_row();
- row_label(ui, "End continuity");
- combo(ui, "bl_cont1", &BLEND_CONTINUITY.map(|(label, _)| label), to);
- ui.end_row();
- row_label(ui, "End bulge");
- ui.add(egui::DragValue::new(to_bulge).range(-0.9..=3.0).speed(0.01).max_decimals(2));
- ui.end_row();
- row_label(ui, "Stitch to both bodies");
- ui.checkbox(stitch, "");
- ui.end_row();
+ form_row(ui, "Start continuity", |ui| {
+ combo(ui, "bl_cont0", &BLEND_CONTINUITY.map(|(label, _)| label), from);
+ });
+ form_row(ui, "Start bulge", |ui| {
+ ui_kit::bulge_field(ui, from_bulge);
+ });
+ form_row(ui, "End continuity", |ui| {
+ combo(ui, "bl_cont1", &BLEND_CONTINUITY.map(|(label, _)| label), to);
+ });
+ form_row(ui, "End bulge", |ui| {
+ ui_kit::bulge_field(ui, to_bulge);
+ });
+ ui_kit::options(ui, "blend_options", &mut [("Stitch to both bodies", stitch)]);
}
Surf::Boundary { continuity, join } => {
- row_label(ui, "Continuity");
- combo(ui, "bo_cont", &PATCH_CONTINUITY.map(|(label, _)| label), continuity);
- ui.end_row();
- row_label(ui, "Operation");
- let mut op = usize::from(*join);
- combo(ui, "bo_op", &BOUNDARY_OPS, &mut op);
- *join = op == 1;
- ui.end_row();
+ form_row(ui, "Continuity", |ui| {
+ ui_kit::segmented(ui, continuity, &PATCH_CONTINUITY.map(|(label, _)| label));
+ });
+ form_row(ui, "Operation", |ui| {
+ let mut op = usize::from(*join);
+ combo(ui, "bo_op", &BOUNDARY_OPS, &mut op);
+ *join = op == 1;
+ });
}
Surf::Trim { extend, stitch, .. } => {
- row_label(ui, "Extend to meet");
- ui.checkbox(extend, "");
- ui.end_row();
- row_label(ui, "Stitch the kept pieces");
- ui.checkbox(stitch, "");
- ui.end_row();
+ ui_kit::options(ui, "trim_options", &mut [("Extend to meet", extend), ("Stitch the kept pieces", stitch)]);
}
Surf::Sweep(opts) => enter |= crate::dialogs_sweep::rows(ui, opts, "ss"),
Surf::Loft { rail_fit } => crate::dialogs_sweep::rail_fit_row(ui, "sl", rail_fit),
diff --git a/crates/ui-egui/src/dialogs_sweep.rs b/crates/ui-egui/src/dialogs_sweep.rs
index 7528e05887..c05e4a9523 100644
--- a/crates/ui-egui/src/dialogs_sweep.rs
+++ b/crates/ui-egui/src/dialogs_sweep.rs
@@ -8,7 +8,7 @@ use solidcraft_engine::doc::{Expr, Mat, RailFit, SweepOrientation, SweepRail};
use solidcraft_engine::geom::Vec3;
use crate::SolveApp;
-use crate::dialogs::{combo, field, row_label};
+use crate::dialogs::{combo, field, form_row};
use crate::selection::{AXES, CURVES, EDGES, SelInput};
/// The orientation choices, in combo order: perpendicular, parallel, a direction.
@@ -100,25 +100,34 @@ pub fn rail_sels(rails: &[SweepRail]) -> [Vec<Sel>; 2] {
/// The option rows; true when Enter was pressed in a field.
pub fn rows(ui: &mut egui::Ui, o: &mut SweepOpts, id: &str) -> bool {
+ rows_with(ui, o, id, |_| {})
+}
+
+/// [`rows`] with extra rows between the orientation and the collapsed Advanced section, so the
+/// feature's own rows (such as its operation) stay above the section.
+pub fn rows_with(ui: &mut egui::Ui, o: &mut SweepOpts, id: &str, between: impl FnOnce(&mut egui::Ui)) -> bool {
let mut enter = false;
- row_label(ui, "Orientation");
- combo(ui, &format!("{id}_orient"), &ORIENTATIONS, &mut o.orientation);
- ui.end_row();
- row_label(ui, "Twist");
- enter |= field(ui, &mut o.twist);
- ui.end_row();
- row_label(ui, "End Scale");
- enter |= field(ui, &mut o.scale);
- ui.end_row();
- rail_fit_row(ui, id, &mut o.rail_fit);
+ form_row(ui, "Orientation", |ui| {
+ combo(ui, &format!("{id}_orient"), &ORIENTATIONS, &mut o.orientation);
+ });
+ between(ui);
+ crate::ui_kit::section(ui, id, "Advanced", false, |ui| {
+ form_row(ui, "Twist", |ui| {
+ enter |= field(ui, &mut o.twist);
+ });
+ form_row(ui, "End Scale", |ui| {
+ enter |= field(ui, &mut o.scale);
+ });
+ rail_fit_row(ui, id, &mut o.rail_fit);
+ });
enter
}
/// The Rail Fit row: `fit` an index into [`RAIL_FITS`].
pub fn rail_fit_row(ui: &mut egui::Ui, id: &str, fit: &mut usize) {
- row_label(ui, "Rail Fit");
- combo(ui, &format!("{id}_rail_fit"), &RAIL_FITS, fit);
- ui.end_row();
+ form_row(ui, "Rail Fit", |ui| {
+ combo(ui, &format!("{id}_rail_fit"), &RAIL_FITS, fit);
+ });
}
/// A stored rail fit as an index into [`RAIL_FITS`].
diff --git a/crates/ui-egui/src/dialogs_thread.rs b/crates/ui-egui/src/dialogs_thread.rs
index b9d0cdf1dc..8aa166602d 100644
--- a/crates/ui-egui/src/dialogs_thread.rs
+++ b/crates/ui-egui/src/dialogs_thread.rs
@@ -3,7 +3,7 @@
use solidcraft_engine::doc::{metric_thread_sizes, parse_metric_thread};
-use crate::dialogs::{check, combo, row_label};
+use crate::dialogs::{combo, form_row};
use crate::i18n::tr;
/// Common pitch presets, not an exhaustive catalogue of standard diameter/pitch pairs.
@@ -11,15 +11,17 @@ use crate::i18n::tr;
const PITCHES: &[f64] = &[0.2, 0.25, 0.35, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0];
/// Returns (Enter pressed, automatic sizing requested).
-pub(crate) fn rows(ui: &mut egui::Ui, designation: &mut String, suggested: &mut Option<String>) -> (bool, bool) {
- row_label(ui, "Profile");
- ui.label(tr("ISO metric"));
- ui.end_row();
+pub(crate) fn rows(ui: &mut egui::Ui, designation: &mut String, suggested: &mut Option<String>, modeled: &mut bool, full: &mut bool) -> (bool, bool) {
+ form_row(ui, "Profile", |ui| {
+ ui.label(tr("ISO metric"));
+ });
- row_label(ui, "Automatic size");
let before = designation.trim().is_empty() || suggested.as_deref() == Some(designation.as_str());
let mut automatic = before;
- ui.add_enabled_ui(!designation.trim().is_empty(), |ui| check(ui, &mut automatic));
+ crate::ui_kit::section(ui, "thread_options", "Options", true, |ui| {
+ crate::ui_kit::checkbox_grid(ui, &mut [("Modeled", modeled), ("Full Length", full)], 2);
+ ui.add_enabled_ui(!designation.trim().is_empty(), |ui| crate::ui_kit::checkbox_grid(ui, &mut [("Automatic size", &mut automatic)], 2));
+ });
let reset = automatic && !before;
if automatic != before {
*suggested = None;
@@ -27,7 +29,6 @@ pub(crate) fn rows(ui: &mut egui::Ui, designation: &mut String, suggested: &mut
designation.clear();
}
}
- ui.end_row();
let current = parse_metric_thread(designation);
let mut diameters: Vec<f64> = metric_thread_sizes().iter().map(|(d, _)| *d).collect();
@@ -37,59 +38,58 @@ pub(crate) fn rows(ui: &mut egui::Ui, designation: &mut String, suggested: &mut
diameters.push(d);
diameters.sort_by(f64::total_cmp);
}
- row_label(ui, "Size");
- let labels: Vec<String> = diameters.iter().map(|d| format!("{d} mm")).collect();
- let mut selected = current.and_then(|(d, _)| diameters.iter().position(|n| *n == d)).unwrap_or(diameters.len());
- let before = selected;
- let mut labels: Vec<&str> = labels.iter().map(String::as_str).collect();
- if current.is_none() {
- labels.push("Select size");
- }
- combo(ui, "thread_diameter", &labels, &mut selected);
- // A new diameter starts with its coarse pitch. The current custom diameter, if any,
- // is already selected and retains its explicit pitch.
- if selected != before
- && let Some(d) = diameters.get(selected)
- && let Some((_, coarse)) = metric_thread_sizes().iter().find(|(n, _)| n == d)
- {
- *designation = format!("M{d}x{coarse}");
- *suggested = None;
- }
- ui.end_row();
-
- let current = parse_metric_thread(designation);
- row_label(ui, "Pitch");
- ui.add_enabled_ui(current.is_some(), |ui| {
- let mut pitches = Vec::new();
- if let Some((d, p)) = current {
- let coarse = metric_thread_sizes().iter().find(|(n, _)| *n == d).map(|(_, p)| *p);
- pitches.extend(PITCHES.iter().copied().filter(|p| *p < d && *p <= coarse.unwrap_or(d)));
- pitches.extend(coarse);
- pitches.push(p);
- }
- pitches.sort_by(|a, b| b.total_cmp(a));
- pitches.dedup();
- let labels: Vec<String> = pitches.iter().map(|p| format!("{p} mm")).collect();
- let labels: Vec<&str> = labels.iter().map(String::as_str).collect();
- let mut selected = current.and_then(|(_, p)| pitches.iter().position(|n| *n == p)).unwrap_or(0);
+ form_row(ui, "Size", |ui| {
+ let labels: Vec<String> = diameters.iter().map(|d| format!("{d} mm")).collect();
+ let mut selected = current.and_then(|(d, _)| diameters.iter().position(|n| *n == d)).unwrap_or(diameters.len());
let before = selected;
- combo(ui, "thread_pitch", &labels, &mut selected);
+ let mut labels: Vec<&str> = labels.iter().map(String::as_str).collect();
+ if current.is_none() {
+ labels.push("Select size");
+ }
+ combo(ui, "thread_diameter", &labels, &mut selected);
+ // A new diameter starts with its coarse pitch. The current custom diameter, if any,
+ // is already selected and retains its explicit pitch.
if selected != before
- && let (Some((d, _)), Some(p)) = (current, pitches.get(selected))
+ && let Some(d) = diameters.get(selected)
+ && let Some((_, coarse)) = metric_thread_sizes().iter().find(|(n, _)| n == d)
{
- *designation = format!("M{d}x{p}");
+ *designation = format!("M{d}x{coarse}");
*suggested = None;
}
});
- ui.end_row();
- row_label(ui, "Designation");
- let response = ui.add(egui::TextEdit::singleline(designation).hint_text(tr("fits the face, e.g. M8")));
- crate::scenario::publish_handle("dialog:thread_size", response.rect.center());
- if response.changed() {
+ let current = parse_metric_thread(designation);
+ form_row(ui, "Pitch", |ui| {
+ ui.add_enabled_ui(current.is_some(), |ui| {
+ let mut pitches = Vec::new();
+ if let Some((d, p)) = current {
+ let coarse = metric_thread_sizes().iter().find(|(n, _)| *n == d).map(|(_, p)| *p);
+ pitches.extend(PITCHES.iter().copied().filter(|p| *p < d && *p <= coarse.unwrap_or(d)));
+ pitches.extend(coarse);
+ pitches.push(p);
+ }
+ pitches.sort_by(|a, b| b.total_cmp(a));
+ pitches.dedup();
+ let labels: Vec<String> = pitches.iter().map(|p| format!("{p} mm")).collect();
+ let labels: Vec<&str> = labels.iter().map(String::as_str).collect();
+ let mut selected = current.and_then(|(_, p)| pitches.iter().position(|n| *n == p)).unwrap_or(0);
+ let before = selected;
+ combo(ui, "thread_pitch", &labels, &mut selected);
+ if selected != before
+ && let (Some((d, _)), Some(p)) = (current, pitches.get(selected))
+ {
+ *designation = format!("M{d}x{p}");
+ *suggested = None;
+ }
+ });
+ });
+
+ let (enter, changed) = form_row(ui, "Designation", |ui| crate::ui_kit::text_field(ui, designation, tr("fits the face, e.g. M8")));
+ if let Some(at) = crate::scenario::handle_at("dialog:Designation") {
+ crate::scenario::publish_handle("dialog:thread_size", at);
+ }
+ if changed {
*suggested = None;
}
- let enter = response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
(enter, reset)
}
diff --git a/crates/ui-egui/src/dialogs_trace.rs b/crates/ui-egui/src/dialogs_trace.rs
index 0433434a9e..ef96cb3e29 100644
--- a/crates/ui-egui/src/dialogs_trace.rs
+++ b/crates/ui-egui/src/dialogs_trace.rs
@@ -9,7 +9,7 @@ use solidcraft_engine::geom::Vec3;
use solidcraft_engine::{Sel, Session};
use super::{Hover, body_of, capital, movable, num, pt, sel_items, snap_of};
-use crate::dialogs::{combo, field, row_label};
+use crate::dialogs::{combo, field, form_row};
use crate::selection::SelInput;
use crate::theme::Tokens;
use crate::viewport::Proj;
@@ -115,58 +115,57 @@ pub fn rows(app: &mut crate::SolveApp, ui: &mut egui::Ui, f: &mut TraceForm, inp
let studies: Vec<&str> = s.doc.assembly.studies.iter().map(|m| m.name.as_str()).collect();
f.by_study &= !studies.is_empty();
if !studies.is_empty() {
- row_label(ui, "Motion");
- let mut by = usize::from(f.by_study);
- combo(ui, "tr_by", &["Joint", "Motion Study"], &mut by);
- f.by_study = by == 1;
- ui.end_row();
+ form_row(ui, "Motion", |ui| {
+ let mut by = usize::from(f.by_study);
+ combo(ui, "tr_by", &["Joint", "Motion Study"], &mut by);
+ f.by_study = by == 1;
+ });
}
if f.by_study {
- row_label(ui, "Study");
- combo(ui, "tr_study", &studies, &mut f.study);
- ui.end_row();
+ form_row(ui, "Study", |ui| {
+ combo(ui, "tr_study", &studies, &mut f.study);
+ });
} else {
let list = movable(s);
if list.is_empty() {
- row_label(ui, "");
- ui.label(RichText::new(crate::i18n::tr_label("no joint that moves yet")).color(t.text_dim));
- ui.end_row();
+ form_row(ui, "", |ui| {
+ ui.label(RichText::new(crate::i18n::tr_label("no joint that moves yet")).color(t.text_dim));
+ });
return false;
}
let labels: Vec<&str> = list.iter().filter_map(|i| s.doc.assembly.joints.get(*i)).map(|j| j.name.as_str()).collect();
let mut pos = list.iter().position(|i| *i == f.joint).unwrap_or(0);
- row_label(ui, "Joint");
- combo(ui, "tr_joint", &labels, &mut pos);
- ui.end_row();
+ form_row(ui, "Joint", |ui| {
+ combo(ui, "tr_joint", &labels, &mut pos);
+ });
let joint = list.get(pos).copied().unwrap_or(0);
let dofs = s.doc.assembly.joints.get(joint).map(|j| j.kind.dofs()).unwrap_or(&[]);
let mut index = if joint == f.joint { f.index.min(dofs.len().saturating_sub(1)) } else { 0 };
if dofs.len() > 1 {
- row_label(ui, " Of");
- let caps: Vec<String> = dofs.iter().map(|d| capital(d)).collect();
- let refs: Vec<&str> = caps.iter().map(String::as_str).collect();
- combo(ui, "tr_index", &refs, &mut index);
- ui.end_row();
+ form_row(ui, " Of", |ui| {
+ let caps: Vec<String> = dofs.iter().map(|d| capital(d)).collect();
+ let refs: Vec<&str> = caps.iter().map(String::as_str).collect();
+ combo(ui, "tr_index", &refs, &mut index);
+ });
}
if joint != f.joint || index != f.index {
(f.joint, f.index) = (joint, index);
(f.from, f.to) = range(s, joint, index);
}
- row_label(ui, "From");
- enter |= field(ui, &mut f.from);
- ui.end_row();
- row_label(ui, "To");
- enter |= field(ui, &mut f.to);
- ui.end_row();
+ form_row(ui, "From", |ui| {
+ enter |= field(ui, &mut f.from);
+ });
+ form_row(ui, "To", |ui| {
+ enter |= field(ui, &mut f.to);
+ });
}
let default = match s.doc.assembly.studies.get(f.study).filter(|_| f.by_study) {
Some(m) => (u64::from(m.steps) + 1).clamp(2, 500),
None => 100,
};
- row_label(ui, "Samples");
- let r = ui.add(egui::TextEdit::singleline(&mut f.samples).hint_text(default.to_string()));
- enter |= r.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter));
- ui.end_row();
+ form_row(ui, "Samples", |ui| {
+ enter |= crate::ui_kit::text_field(ui, &mut f.samples, &default.to_string()).0;
+ });
// The preview, traced again when what it traces (or the design) changes.
let p = params(s, f, inputs);
let key = format!("{}:{p:?}", s.revision);
@@ -183,9 +182,9 @@ pub fn rows(app: &mut crate::SolveApp, ui: &mut egui::Ui, f: &mut TraceForm, inp
},
Err(e) => (e.clone(), t.text_dim),
};
- row_label(ui, "");
- ui.add(egui::Label::new(RichText::new(text).color(colour)).wrap());
- ui.end_row();
+ form_row(ui, "", |ui| {
+ ui.add(egui::Label::new(RichText::new(text).color(colour)).wrap());
+ });
}
enter
}
diff --git a/crates/ui-egui/src/dim_view.rs b/crates/ui-egui/src/dim_view.rs
index 119d735346..39f9306975 100644
--- a/crates/ui-egui/src/dim_view.rs
+++ b/crates/ui-egui/src/dim_view.rs
@@ -9,6 +9,7 @@
//! Everything acts through commands: `sketch.dimension_text`, `sketch.delete`,
//! `parameters.change`.
+use crate::fonts::RichTextExt as _;
use std::cell::RefCell;
use std::sync::Arc;
@@ -481,7 +482,7 @@ pub fn show(app: &mut SolveApp, ui: &egui::Ui, painter: &egui::Painter, proj: &P
let tk = Tokens::get();
let is_sel = |id: &str| app.session.selection.iter().any(|s| matches!(s, Sel::SketchConstraint { id: x } if x == id));
let hover = ui.input(|i| i.pointer.hover_pos()).filter(|_| ui.rect_contains_pointer(proj.rect)).and_then(hit);
- let font = FontId::proportional(12.0);
+ let font = FontId::monospace(crate::theme::Tokens::get().font_body);
let centres = chain_centres(sk);
let draft_sketch = draft.as_ref().and_then(|(_, d)| d.preview.sketch(d.sketch));
let draft_centres = draft_sketch.map(|solved| chain_centres(&solved.sketch));
@@ -698,7 +699,7 @@ fn edit_box(app: &mut SolveApp, ctx: &egui::Context) {
crate::frame::area(egui::Id::new("sc_dim_edit_area")).fixed_pos(anchor).order(egui::Order::Foreground).show(ctx, |ui| {
egui::Frame::popup(ui.style()).inner_margin(egui::Margin::symmetric(3, 1)).show(ui, |ui| {
ui.set_max_width(popup_width);
- ui.label(egui::RichText::new(format!("Dimension: {}", e.param)).strong())
+ ui.label(egui::RichText::new(format!("Dimension: {}", e.param)).semibold().color(crate::theme::Tokens::get().text))
.on_hover_text("Click another driving dimension to insert its name");
let r = ui.add(egui::TextEdit::singleline(&mut e.expr).id(id).desired_width(popup_width));
crate::theme::TabAccent::number_focus(ui, &r);
diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rs
index 4a41672e1f..e89b17243a 100644
--- a/crates/ui-egui/src/documents.rs
+++ b/crates/ui-egui/src/documents.rs
@@ -382,7 +382,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
.map(|(name, dirty)| {
let shown_name = crate::i18n::Locale::for_language(&app.preferences.language).given_name(name);
let label = format!("{shown_name}{}", if *dirty { " •" } else { "" });
- let text = ui.painter().layout_no_wrap(label, FontId::proportional(13.0), t.app_bar_text).size().x;
+ let text = ui.painter().layout_no_wrap(label, crate::fonts::semibold(crate::theme::Tokens::get().font_button), t.app_bar_text).size().x;
(text + 40.0).clamp(72.0, MAX_FIT)
})
.collect();
@@ -405,8 +405,14 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
}
tab_shape(ui.painter(), &t, tr, active, resp.hovered() || resp.has_focus());
let ink = if active || resp.hovered() { t.app_bar_text } else { t.app_bar_text.gamma_multiply(0.7) };
- let label = format!("{}{}", crate::i18n::Locale::for_language(&app.preferences.language).given_name(name), if *dirty { " •" } else { "" });
- let g = ui.painter().layout_no_wrap(label, FontId::proportional(13.0), ink);
+ let name_display = crate::i18n::Locale::for_language(&app.preferences.language).given_name(name);
+ let label = format!("{name_display}{}", if *dirty { " •" } else { "" });
+ let font = if active {
+ crate::fonts::semibold(crate::theme::Tokens::get().font_button)
+ } else {
+ FontId::proportional(crate::theme::Tokens::get().font_button)
+ };
+ let g = ui.painter().layout_no_wrap(label, font, ink);
let text_w = (tr.width() - 30.0).max(10.0);
let clip = Rect::from_min_size(tr.min, vec2(text_w + 10.0, tr.height()));
ui.painter().with_clip_rect(clip).galley(pos2(tr.left() + 10.0, tr.center().y - g.size().y / 2.0), g, ink);
@@ -438,10 +444,17 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
if shown < n {
let mr = Rect::from_center_size(pos2(x + 12.0, r.center().y), vec2(20.0, 22.0));
let mresp = ui.interact(mr, ui.id().with("doc_more"), Sense::click());
+ crate::scenario::publish_handle("tab:overflow", mr.center());
if mresp.hovered() {
ui.painter().rect_filled(mr, 4.0, t.app_bar_hover_button);
}
- ui.painter().text(mr.center(), egui::Align2::CENTER_CENTER, format!("»{}", n - shown), FontId::proportional(12.0), t.app_bar_text);
+ ui.painter().text(
+ mr.center(),
+ egui::Align2::CENTER_CENTER,
+ format!("»{}", n - shown),
+ FontId::proportional(crate::theme::Tokens::get().font_body),
+ t.app_bar_text,
+ );
let id = egui::Id::new("sc_doc_more");
if mresp.clone().on_hover_text(crate::i18n::tr_label("All open designs")).clicked() {
ui.ctx().data_mut(|d| d.insert_temp(id, !d.get_temp::<bool>(id).unwrap_or(false)));
@@ -677,7 +690,7 @@ mod tests {
for t in [Tokens::light(), Tokens::dark()] {
let r = Rect::from_min_size(pos2(10.0, 5.0), vec2(80.0, 30.0));
for (active, hovered) in [(false, false), (false, true), (true, false)] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| tab_shape(ui.painter(), &t, r, active, hovered));
out.textures_delta.clear();
let rects: Vec<_> = out
@@ -807,7 +820,7 @@ mod tests {
request_quit(&mut a);
answer_prompt(&mut a, Answer::Save);
assert!(!a.quit_requested && a.file_picker_busy());
- crate::file_picker::tick(&mut a, &egui::Context::default());
+ crate::file_picker::tick(&mut a, &crate::fonts::test_context());
crate::save_job::tick(&mut a, true);
assert!(a.quit_requested && file.exists());
let _ = std::fs::remove_file(&file);
diff --git a/crates/ui-egui/src/drag_snap.rs b/crates/ui-egui/src/drag_snap.rs
index 5646239a70..1c2aa10e9c 100644
--- a/crates/ui-egui/src/drag_snap.rs
+++ b/crates/ui-egui/src/drag_snap.rs
@@ -232,7 +232,7 @@ pub fn show(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
if !label.is_empty() {
let r = egui::Rect::from_min_size(sp + egui::vec2(12.0, -24.0), egui::vec2(24.0, 14.0));
painter.rect_filled(r, 3.0, tk.accent_soft);
- painter.text(r.center(), Align2::CENTER_CENTER, label, FontId::proportional(10.0), tk.text);
+ painter.text(r.center(), Align2::CENTER_CENTER, label, FontId::proportional(crate::theme::Tokens::get().font_micro), tk.text);
}
crate::scenario::publish_count("drag_guides", s.guides.len() as f64);
}
diff --git a/crates/ui-egui/src/expression_complete.rs b/crates/ui-egui/src/expression_complete.rs
index 6738831212..42b139b27b 100644
--- a/crates/ui-egui/src/expression_complete.rs
+++ b/crates/ui-egui/src/expression_complete.rs
@@ -181,7 +181,7 @@ mod tests {
impl Editor {
fn new(text: &str) -> Self {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
for (name, value) in [("width", 40), ("width_extra", 50), ("wing", 20), ("wire", 10)] {
app.run("parameters.add", json!({"name":name,"expression":format!("{value} mm")})).unwrap();
diff --git a/crates/ui-egui/src/file_load.rs b/crates/ui-egui/src/file_load.rs
index bff9b92c60..b72deb4234 100644
--- a/crates/ui-egui/src/file_load.rs
+++ b/crates/ui-egui/src/file_load.rs
@@ -7,6 +7,7 @@
//! control-channel commands that change the design are held until the file is in. A control
//! (MCP) `doc.open` or import is answered when its file finishes loading.
+use crate::fonts::RichTextExt as _;
use std::collections::VecDeque;
use std::sync::{
Arc,
@@ -933,8 +934,9 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
Kind::ExportDxf => crate::i18n::tr_label("dxf.exporting"),
}
})
- .strong()
- .size(14.0),
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_heading),
);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let b = ui.button(crate::i18n::tr("ui.cancel"));
@@ -1099,10 +1101,10 @@ mod tests {
app.session.revision += 1;
}
let newer = app.session.doc.clone();
- tick(&mut app, &egui::Context::default());
+ tick(&mut app, &crate::fonts::test_context());
assert!(app.file_load.running.as_ref().unwrap().preview.is_none());
tx.send(Ok(Made { session: Session::default(), result: Value::Null, thumbnail: false })).unwrap();
- tick(&mut app, &egui::Context::default());
+ tick(&mut app, &crate::fonts::test_context());
assert!(Arc::ptr_eq(&newer, &app.session.doc));
assert!(app.status.as_ref().unwrap().0.contains("discarded"));
}
@@ -1160,7 +1162,7 @@ mod tests {
built: None,
staged: None,
});
- tick(&mut app, &egui::Context::default());
+ tick(&mut app, &crate::fonts::test_context());
assert!(Arc::ptr_eq(&app.session.doc, &old));
assert!(!app.file_load.busy());
assert!(app.status.as_ref().unwrap().0.contains("bad STEP"));
@@ -1191,7 +1193,7 @@ mod tests {
let mut computed = Session::default();
computed.execute("solid.box", &serde_json::json!({"length":10,"width":10,"height":10})).unwrap();
tx.send(Ok(Made { session: computed, result: Value::Null, thumbnail: false })).unwrap();
- tick(&mut app, &egui::Context::default());
+ tick(&mut app, &crate::fonts::test_context());
assert!(app.file_load.running.is_none());
assert!(Arc::ptr_eq(&old, &app.session.doc));
}
@@ -1209,7 +1211,7 @@ mod tests {
part.execute("solid.box", &serde_json::json!({"length": 10, "width": 10, "height": 10, "corner": [i * 20, 0, 0]})).unwrap();
}
part.execute("file.export", &serde_json::json!({"path": path})).unwrap();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(Session::default(), Default::default());
let bodies = |app: &SolveApp| app.session.world_state().bodies.len();
assert!(staged_kind(&Request::new(&path, Kind::Insert)) && staged_kind(&Request::new(&path, Kind::Open)));
diff --git a/crates/ui-egui/src/file_load_ui_tests.rs b/crates/ui-egui/src/file_load_ui_tests.rs
index d6aa945f0c..cfcbf354fd 100644
--- a/crates/ui-egui/src/file_load_ui_tests.rs
+++ b/crates/ui-egui/src/file_load_ui_tests.rs
@@ -18,7 +18,7 @@ impl Win {
fn new() -> Self {
let mut app = SolveApp::new(Session::default(), Default::default());
app.custom_titlebar = true;
- let mut w = Win { ctx: egui::Context::default(), app, time: 0.0 };
+ let mut w = Win { ctx: crate::fonts::test_context(), app, time: 0.0 };
for _ in 0..3 {
w.frame(vec![]);
}
diff --git a/crates/ui-egui/src/file_picker.rs b/crates/ui-egui/src/file_picker.rs
index 56d0dcf59a..2c081346b5 100644
--- a/crates/ui-egui/src/file_picker.rs
+++ b/crates/ui-egui/src/file_picker.rs
@@ -175,7 +175,7 @@ mod tests {
if let Some(waker) = answer.waker.borrow_mut().take() {
waker.wake();
}
- tick(app, &egui::Context::default());
+ tick(app, &crate::fonts::test_context());
// A save the answer started is written on a worker: wait for it.
crate::save_job::tick(app, true);
assert!(!app.file_picker_busy());
diff --git a/crates/ui-egui/src/font_literals_tests.rs b/crates/ui-egui/src/font_literals_tests.rs
new file mode 100644
index 0000000000..ca6b3ea096
--- /dev/null
+++ b/crates/ui-egui/src/font_literals_tests.rs
@@ -0,0 +1,188 @@
+//! Typography belongs to Tokens, and named font families belong to fonts.rs.
+//! Like the colour guard, exceptions have a per-file count and an explicit reason.
+
+use std::path::Path;
+use syn::visit::{self, Visit};
+use syn::{Expr, Item, Lit};
+
+/// These `.size()` calls size spinner geometry, not text. No text sizes are exempt.
+const ALLOWED_LITERALS: &[(&str, usize, &str)] = &[
+ ("dialogs.rs", 2, "preview spinners: graphic diameter, not typography"),
+ ("home.rs", 1, "thumbnail loading spinner: graphic diameter, not typography"),
+ ("viewport.rs", 1, "viewport status spinner: graphic diameter, not typography"),
+];
+
+fn test_only(attrs: &[syn::Attribute]) -> bool {
+ attrs.iter().any(|a| a.path().is_ident("test") || (a.path().is_ident("cfg") && a.parse_args::<syn::Path>().is_ok_and(|p| p.is_ident("test"))))
+}
+
+fn number(expr: &Expr) -> Option<f64> {
+ match expr {
+ Expr::Lit(e) => match &e.lit {
+ Lit::Int(n) => n.base10_parse().ok(),
+ Lit::Float(n) => n.base10_parse().ok(),
+ _ => None,
+ },
+ Expr::Paren(e) => number(&e.expr),
+ Expr::Group(e) => number(&e.expr),
+ Expr::Unary(e) => number(&e.expr),
+ _ => None,
+ }
+}
+
+/// Includes literals hidden in arithmetic such as `FontId::proportional(12.0 * zoom)`.
+fn has_number(expr: &Expr) -> bool {
+ struct Numbers(bool);
+ impl<'ast> Visit<'ast> for Numbers {
+ fn visit_lit(&mut self, lit: &'ast Lit) {
+ self.0 |= matches!(lit, Lit::Int(_) | Lit::Float(_));
+ }
+ }
+ let mut numbers = Numbers(false);
+ numbers.visit_expr(expr);
+ numbers.0
+}
+
+fn spacing(expr: &Expr) -> bool {
+ match expr {
+ Expr::Field(e) => spacing(&e.base),
+ Expr::MethodCall(e) => e.method == "spacing_mut" || spacing(&e.receiver),
+ _ => false,
+ }
+}
+
+struct Guard<'a> {
+ file: &'a str,
+ found: Vec<String>,
+}
+
+impl<'ast> Visit<'ast> for Guard<'_> {
+ fn visit_item(&mut self, item: &'ast Item) {
+ let attrs = match item {
+ Item::Mod(i) => &i.attrs,
+ Item::Fn(i) => &i.attrs,
+ Item::Impl(i) => &i.attrs,
+ Item::Const(i) => &i.attrs,
+ Item::Static(i) => &i.attrs,
+ _ => return visit::visit_item(self, item),
+ };
+ if !test_only(attrs) {
+ visit::visit_item(self, item);
+ }
+ }
+
+ fn visit_expr_call(&mut self, call: &'ast syn::ExprCall) {
+ if let Expr::Path(p) = call.func.as_ref() {
+ let names: Vec<_> = p.path.segments.iter().map(|s| s.ident.to_string()).collect();
+ let last = names.last().map(String::as_str).unwrap_or_default();
+ let font_id = names.iter().any(|s| s == "FontId") && matches!(last, "proportional" | "monospace" | "new");
+ let weight = matches!(last, "medium" | "semibold" | "bold");
+ if (font_id || weight) && call.args.first().is_some_and(has_number) {
+ self.found.push(format!("{last}(numeric size)"));
+ }
+ // Helpers that take the text size as their fourth argument.
+ if matches!(last, "ribbon_text" | "face_text") && call.args.iter().nth(3).is_some_and(has_number) {
+ self.found.push(format!("{last}(numeric size)"));
+ }
+ if self.file != "fonts.rs" && names.iter().any(|s| s == "FontFamily") && last == "Name" {
+ self.found.push("FontFamily::Name outside fonts.rs".into());
+ }
+ if self.file.starts_with("ui_kit/")
+ && (matches!(last, "vec2" | "pos2") || (names.iter().any(|s| s == "Margin") && matches!(last, "same" | "symmetric")))
+ && call.args.iter().any(|e| number(e).is_some_and(|n| n > 1.0))
+ {
+ self.found.push(format!("{last}(numeric form metric)"));
+ }
+ }
+ visit::visit_expr_call(self, call);
+ }
+
+ fn visit_expr_method_call(&mut self, call: &'ast syn::ExprMethodCall) {
+ if call.method == "size" && call.args.first().is_some_and(has_number) {
+ self.found.push(".size(numeric size)".into());
+ }
+ if self.file.starts_with("ui_kit/")
+ && matches!(call.method.to_string().as_str(), "margin" | "inner_margin" | "outer_margin" | "add_space" | "shrink" | "corner_radius")
+ && call.args.iter().any(|e| number(e).is_some_and(|n| n > 1.0))
+ {
+ self.found.push(format!(".{}(numeric form metric)", call.method));
+ }
+ visit::visit_expr_method_call(self, call);
+ }
+
+ fn visit_expr_assign(&mut self, assign: &'ast syn::ExprAssign) {
+ if self.file.starts_with("ui_kit/") && spacing(&assign.left) && has_number(&assign.right) {
+ // Zero disables spacing along an axis; it is not a design dimension.
+ if number(&assign.right) != Some(0.0) && !matches!(assign.right.as_ref(), Expr::Call(_)) {
+ self.found.push("numeric ui.spacing_mut assignment".into());
+ }
+ }
+ if let Expr::Field(field) = assign.left.as_ref()
+ && matches!(&field.member, syn::Member::Named(name) if name == "extra_letter_spacing")
+ && has_number(&assign.right)
+ {
+ self.found.push("numeric extra_letter_spacing".into());
+ }
+ visit::visit_expr_assign(self, assign);
+ }
+}
+
+fn scan(dir: &Path, prefix: &str, failures: &mut Vec<String>) {
+ let entries = std::fs::read_dir(dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display()));
+ for entry in entries {
+ let path = entry.unwrap().path();
+ let name = path.file_name().unwrap().to_str().unwrap();
+ let relative = format!("{prefix}{name}");
+ if path.is_dir() {
+ scan(&path, &format!("{relative}/"), failures);
+ } else if name.ends_with(".rs") && !name.ends_with("_tests.rs") && name != "tests.rs" {
+ let src = std::fs::read_to_string(&path).unwrap();
+ let ast = syn::parse_file(&src).unwrap_or_else(|e| panic!("{relative}: {e}"));
+ let mut guard = Guard { file: &relative, found: Vec::new() };
+ guard.visit_file(&ast);
+ let allowed = ALLOWED_LITERALS.iter().find(|(f, _, _)| *f == relative).map_or(0, |(_, n, _)| *n);
+ if guard.found.len() > allowed {
+ failures.push(format!("{relative}: {} literal(s), at most {allowed} allowed: {:?}", guard.found.len(), guard.found));
+ }
+ }
+ }
+}
+
+#[test]
+fn font_sizes_and_dense_form_metrics_come_from_tokens() {
+ let root = Path::new(env!("CARGO_MANIFEST_DIR"));
+ let mut failures = Vec::new();
+ scan(&root.join("src"), "", &mut failures);
+ scan(&root.join("../../assets/icons/ui/source"), "icons/", &mut failures);
+ failures.sort();
+ assert!(
+ failures.is_empty(),
+ "literals outside theme::Tokens (add a token, or a small per-file allowance with a reason):\n{}",
+ failures.join("\n")
+ );
+}
+
+#[test]
+fn guard_catches_multiline_sizes_and_continues_after_test_modules() {
+ let src = r#"
+ #[cfg(test)] mod tests { fn example() { label.size(42.0); } }
+ fn render() {
+ label.size(
+ 12.0
+ );
+ FontId::proportional(14.0 * zoom);
+ crate::fonts::semibold(13.0);
+ FontFamily::Name("private-family".into());
+ ui.spacing_mut().item_spacing.x = 5.0;
+ ui.add_space(7.0);
+ vec2(24.0, t.space_8);
+ format.extra_letter_spacing = size * 0.04;
+ label.size(t.font_body);
+ FontId::monospace(t.font_body * zoom);
+ }
+ "#;
+ let ast = syn::parse_file(src).unwrap();
+ let mut guard = Guard { file: "ui_kit/layout.rs", found: Vec::new() };
+ guard.visit_file(&ast);
+ assert_eq!(guard.found.len(), 8, "{:?}", guard.found);
+}
diff --git a/crates/ui-egui/src/fonts.rs b/crates/ui-egui/src/fonts.rs
index bc54ccc14d..476c40dde0 100644
--- a/crates/ui-egui/src/fonts.rs
+++ b/crates/ui-egui/src/fonts.rs
@@ -1,14 +1,106 @@
-//! System font loading and fallback setup for multi-language (CJK: Japanese, Chinese, Korean;
-//! Thai) support.
-//!
-//! The UI's Latin font always comes first; a CJK font (then a Hangul font, then a Thai font) is only
-//! ever appended as a fallback, so English text renders exactly as before and only glyphs the Latin
-//! font lacks use the CJK face. The Hangul fallback covers Korean where the CJK font found (Meiryo,
-//! Hiragino) lacks Hangul; the Thai fallback covers Thai typed in a name or the agent chat (#1902). The order of the CJK and Chinese faces follows the UI language
-//! (see [`fallback_order`]): one face drawing a whole word keeps its glyphs on one baseline.
+//! Bundled IBM Plex interface faces, user overrides, and language-specific system fallbacks.
+//! The same definitions are used on desktop and web; the web shell adds Japanese on demand.
use std::sync::Arc;
+use egui::{FontDefinitions, FontFamily, FontId, RichText};
+
+const PLEX_SANS: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf"));
+const PLEX_MONO: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf"));
+const WEIGHTS: [(&str, f32); 4] = [("plex-sans", 400.0), ("ui-medium", 500.0), ("ui-semibold", 600.0), ("ui-bold", 700.0)];
+
+fn sans_families() -> [FontFamily; 4] {
+ [FontFamily::Proportional, medium_family(), semibold_family(), bold_family()]
+}
+
+fn all_families() -> impl Iterator<Item = FontFamily> {
+ sans_families().into_iter().chain([FontFamily::Monospace])
+}
+
+/// IBM Plex Sans at 400/500/600/700 and Plex Mono Regular, followed by egui's symbol/emoji
+/// fallbacks. Each variable instance shares the embedded bytes and selects a real weight.
+pub fn base_font_definitions() -> FontDefinitions {
+ let mut fonts = FontDefinitions::default();
+ let fallbacks = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default();
+ for ((name, weight), family) in WEIGHTS.into_iter().zip(sans_families()) {
+ let mut data = egui::FontData::from_static(PLEX_SANS);
+ data.tweak.coords = egui::epaint::text::VariationCoords::new([(b"wght", weight)]);
+ fonts.font_data.insert(name.to_owned(), Arc::new(data));
+ fonts.families.insert(family, std::iter::once(name.to_owned()).chain(fallbacks.iter().cloned()).collect());
+ }
+ fonts.font_data.insert("plex-mono".to_owned(), Arc::new(egui::FontData::from_static(PLEX_MONO)));
+ fonts.families.entry(FontFamily::Monospace).or_default().insert(0, "plex-mono".to_owned());
+ with_symbol_fallback(fonts)
+}
+
+fn medium_family() -> FontFamily {
+ FontFamily::Name("ui-medium".into())
+}
+
+fn semibold_family() -> FontFamily {
+ FontFamily::Name("ui-semibold".into())
+}
+
+fn bold_family() -> FontFamily {
+ FontFamily::Name("ui-bold".into())
+}
+
+/// Medium (500) interface text, retaining the language fallbacks and user override.
+pub fn medium(size: f32) -> FontId {
+ FontId::new(size, medium_family())
+}
+
+/// Semibold (600) interface text, retaining the language fallbacks and user override.
+pub fn semibold(size: f32) -> FontId {
+ FontId::new(size, semibold_family())
+}
+
+/// Bold (700) interface text, retaining the language fallbacks and user override.
+pub fn bold(size: f32) -> FontId {
+ FontId::new(size, bold_family())
+}
+
+/// Select a real interface weight without changing the text's size or colour.
+pub trait RichTextExt {
+ fn medium(self) -> Self;
+ fn semibold(self) -> Self;
+ fn bold_face(self) -> Self;
+}
+
+impl RichTextExt for RichText {
+ fn medium(self) -> Self {
+ self.family(medium_family())
+ }
+ fn semibold(self) -> Self {
+ self.family(semibold_family())
+ }
+ fn bold_face(self) -> Self {
+ self.family(bold_family())
+ }
+}
+
+// Keep pending definitions too: set_fonts takes effect on the next frame, while the web
+// fetch and preference update can both finish before that frame starts.
+fn installed_fonts_id() -> egui::Id {
+ egui::Id::new("solidcraft_interface_fonts")
+}
+
+fn install(ctx: &egui::Context, fonts: FontDefinitions) {
+ let fonts = with_symbol_fallback(fonts);
+ ctx.data_mut(|d| d.insert_temp(installed_fonts_id(), fonts.clone()));
+ ctx.set_fonts(fonts);
+ ctx.global_style_mut(|style| {
+ if let Some(heading) = style.text_styles.get_mut(&egui::TextStyle::Heading) {
+ heading.family = semibold(heading.size).family;
+ }
+ });
+}
+
+/// Install only the bundled definitions (also used by the offscreen scenario shell).
+pub(crate) fn setup_bundled_fonts(ctx: &egui::Context) {
+ install(ctx, base_font_definitions());
+}
+
/// Name of the CJK fallback entry in [`egui::FontDefinitions`].
pub const CJK_FALLBACK: &str = "cjk_fallback";
@@ -17,7 +109,7 @@ pub const CJK_FALLBACK: &str = "cjk_fallback";
/// Chinese falls through to this one per glyph.
pub const CHINESE_FALLBACK: &str = "chinese_fallback";
-/// Name of the chosen interface font in [`egui::FontDefinitions`], first in the Proportional
+/// Name of the chosen interface font in [`egui::FontDefinitions`], first in every sans
/// family when one is set (#1290).
pub const UI_FONT: &str = "ui_font";
@@ -35,13 +127,15 @@ pub fn ui_font(name: &str) -> Option<egui::FontData> {
Some(font)
}
-/// `fonts` with `font` first in the Proportional family (menus, dialogs, labels); the default
-/// face and the fallbacks stay after it for the glyphs it lacks.
-pub fn with_ui_font(mut fonts: egui::FontDefinitions, font: egui::FontData) -> egui::FontDefinitions {
+/// Put a chosen interface face first in every sans family; keep Plex and language fallbacks.
+/// A user-selected static face keeps its own weight (we never synthesize a bold face).
+pub fn with_ui_font(mut fonts: FontDefinitions, font: egui::FontData) -> FontDefinitions {
fonts.font_data.insert(UI_FONT.to_owned(), Arc::new(font));
- let list = fonts.families.entry(egui::FontFamily::Proportional).or_default();
- list.retain(|entry| entry != UI_FONT);
- list.insert(0, UI_FONT.to_owned());
+ for family in sans_families() {
+ let list = fonts.families.entry(family).or_default();
+ list.retain(|entry| entry != UI_FONT);
+ list.insert(0, UI_FONT.to_owned());
+ }
fonts
}
@@ -51,17 +145,19 @@ pub const HANGUL_FALLBACK: &str = "hangul_fallback";
/// Name of the Thai fallback entry in [`egui::FontDefinitions`], last (#1902).
pub const THAI_FALLBACK: &str = "thai_fallback";
-/// egui's built-in monospace face, also the last fallback of the Proportional family (#2955).
+/// egui's built-in monospace face, also the last fallback of every sans family (#2955).
pub const SYMBOL_FALLBACK: &str = "Hack";
-/// `fonts` with egui's built-in Hack last in the Proportional family. Ubuntu-Light, NotoEmoji and
+/// `fonts` with egui's built-in Hack last in every sans family. Ubuntu-Light, NotoEmoji and
/// emoji-icon-font lack common symbols such as ▲ ▼ ↑ ↓ → ⁻, which Hack has, so they no longer
/// show as empty boxes where no system font fills in (#2955). Text the other faces draw keeps them.
pub fn with_symbol_fallback(mut fonts: egui::FontDefinitions) -> egui::FontDefinitions {
if fonts.font_data.contains_key(SYMBOL_FALLBACK) {
- let list = fonts.families.entry(egui::FontFamily::Proportional).or_default();
- list.retain(|name| name != SYMBOL_FALLBACK);
- list.push(SYMBOL_FALLBACK.to_owned());
+ for family in sans_families() {
+ let list = fonts.families.entry(family).or_default();
+ list.retain(|name| name != SYMBOL_FALLBACK);
+ list.push(SYMBOL_FALLBACK.to_owned());
+ }
}
fonts
}
@@ -107,18 +203,18 @@ fn shape_has_cjk(shape: &egui::Shape) -> bool {
}
}
-/// `fonts` with `bytes` appended as the last fallback of the Proportional and Monospace
-/// families, after the Latin UI font. `None` when the bytes are not a font.
+/// `fonts` with `bytes` appended as the last fallback of every interface
+/// family, after the Latin UI font. `None` when the bytes are not a font.
pub fn with_cjk_fallback(fonts: egui::FontDefinitions, bytes: Vec<u8>) -> Option<egui::FontDefinitions> {
with_fallback(fonts, CJK_FALLBACK, bytes)
}
-/// `fonts` with `bytes` appended under `name` as the last fallback of the Proportional and
-/// Monospace families. `None` when the bytes are not a font.
+/// `fonts` with `bytes` appended under `name` as the last fallback of every interface
+/// family. `None` when the bytes are not a font.
fn with_fallback(mut fonts: egui::FontDefinitions, name: &str, bytes: Vec<u8>) -> Option<egui::FontDefinitions> {
ttf_parser::Face::parse(&bytes, 0).ok()?;
fonts.font_data.insert(name.to_owned(), Arc::new(egui::FontData::from_owned(bytes)));
- for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {
+ for family in all_families() {
let list = fonts.families.entry(family).or_default();
list.retain(|entry| entry != name);
list.push(name.to_owned());
@@ -126,29 +222,35 @@ fn with_fallback(mut fonts: egui::FontDefinitions, name: &str, bytes: Vec<u8>) -
Some(fonts)
}
-/// Move `name` to the head of [`egui::FontFamily::Proportional`] so that ASCII characters
-/// (digits, units, labels) and CJK glyphs use the same face, keeping them on one baseline.
-fn promote_font_to_front(fonts: &mut egui::FontDefinitions, name: &str) {
- if let Some(list) = fonts.families.get_mut(&egui::FontFamily::Proportional)
- && let Some(pos) = list.iter().position(|e| e == name)
- {
- let item = list.remove(pos);
- list.insert(0, item);
+/// Use one primary CJK face for mixed-script labels in every sans weight family.
+/// An explicit interface font stays first; Plex and the other fallbacks remain available.
+fn promote_font_to_front(fonts: &mut FontDefinitions, name: &str) {
+ for family in sans_families() {
+ if let Some(list) = fonts.families.get_mut(&family)
+ && let Some(pos) = list.iter().position(|entry| entry == name)
+ {
+ let item = list.remove(pos);
+ let first = usize::from(list.first().is_some_and(|entry| entry == UI_FONT));
+ list.insert(first, item);
+ }
}
}
-/// Install font bytes as a fallback for the Proportional and Monospace families for `language`.
-/// For a CJK language the font is promoted to the front of Proportional so digits and labels share
-/// one baseline with the CJK glyphs; for any other language it stays a fallback (its Cyrillic can
-/// be full-width, so it must not draw the Latin or Cyrillic UI text).
+/// Install font bytes as fallback for every interface family, retaining its bundled weights.
/// Returns true if the font was parsed and installed successfully.
+pub fn install_cjk_font(ctx: &egui::Context, bytes: Vec<u8>) -> bool {
+ install_cjk_font_for(ctx, bytes, "ja")
+}
+
+/// Install the downloaded font with the CJK UI's shared mixed-script baseline.
pub fn install_cjk_font_for(ctx: &egui::Context, bytes: Vec<u8>, language: &str) -> bool {
- match with_cjk_fallback(egui::FontDefinitions::default(), bytes) {
+ let fonts = ctx.data(|d| d.get_temp::<FontDefinitions>(installed_fonts_id())).unwrap_or_else(base_font_definitions);
+ match with_cjk_fallback(fonts, bytes) {
Some(mut fonts) => {
if needs_cjk_font(language) {
promote_font_to_front(&mut fonts, CJK_FALLBACK);
}
- ctx.set_fonts(with_symbol_fallback(fonts));
+ install(ctx, fonts);
true
}
None => false,
@@ -561,13 +663,11 @@ pub fn setup_fonts_for(ctx: &egui::Context, language: &str, ui_font: &str) {
let chinese = find_system_chinese_font().filter(|bytes| cjk.as_ref() != Some(bytes));
let hangul = HANGUL_FONT_CANDIDATES.iter().find_map(|path| try_read_font(std::path::Path::new(path)));
let thai = THAI_FONT_CANDIDATES.iter().find_map(|path| try_read_font(std::path::Path::new(path)));
- let mut fonts = egui::FontDefinitions::default();
+ let mut fonts = base_font_definitions();
if let Some(font) = self::ui_font(ui_font) {
fonts = with_ui_font(fonts, font);
}
let order = fallback_order(language);
- // Whether a system fallback was found.
- let mut found = false;
for name in order {
let bytes = match name {
CJK_FALLBACK => cjk.clone(),
@@ -579,21 +679,16 @@ pub fn setup_fonts_for(ctx: &egui::Context, language: &str, ui_font: &str) {
&& let Some(with_fallback) = with_fallback(fonts.clone(), name, bytes)
{
fonts = with_fallback;
- found = true;
}
}
- if found && needs_cjk_font(language) && ui_font.trim().is_empty() {
- // For a CJK UI (Japanese, Chinese, Korean) without a custom interface font,
- // promote the primary CJK font to the front of FontFamily::Proportional.
- // This ensures that ASCII characters (digits, units, English words) within mixed
- // labels (e.g. "4 個選択中", "2 mm") are drawn with the same font face as the
- // CJK glyphs, sharing identical line height, ascender, and baseline (#1070 follow-up).
- let primary = order[0];
- promote_font_to_front(&mut fonts, primary);
- }
- // Set the fonts every time: the symbol fallback goes in even when no system fallback is
- // found (#2955), and going back to the default interface font takes the chosen one away.
- ctx.set_fonts(with_symbol_fallback(fonts));
+ if needs_cjk_font(language) {
+ // Select the first installed face in language order (a duplicate Chinese face may
+ // already be installed as CJK_FALLBACK). Keep explicit interface choices ahead of it.
+ if let Some(primary) = order.into_iter().find(|name| *name != THAI_FALLBACK && fonts.font_data.contains_key(*name)) {
+ promote_font_to_front(&mut fonts, primary);
+ }
+ }
+ install(ctx, fonts);
}
/// Configure font definitions with system fallbacks for an English UI (all fallbacks are
@@ -672,16 +767,45 @@ fn find_chinese_font_in(dirs: &[std::path::PathBuf]) -> Option<Vec<u8>> {
dirs.iter().find_map(|dir| scan_dir_for_font_where(dir, 3, is_chinese_font_name, draws_simplified_chinese))
}
-/// On web, setup_fonts does not perform synchronous disk reads.
-/// Use asynchronous loading through [`solidcraft_web`] or host scripts.
+/// Web installs the bundled faces synchronously; Japanese is fetched by the shell on demand.
+/// Preserve that downloaded face when preferences change later in the session.
#[cfg(target_arch = "wasm32")]
-pub fn setup_fonts_for(_ctx: &egui::Context, _language: &str, _ui_font: &str) {}
+pub fn setup_fonts_for(ctx: &egui::Context, language: &str, ui_font: &str) {
+ let previous = ctx.data(|d| d.get_temp::<FontDefinitions>(installed_fonts_id()));
+ let mut fonts = web_font_definitions(ui_font, previous);
+ if needs_cjk_font(language) {
+ promote_font_to_front(&mut fonts, CJK_FALLBACK);
+ }
+ install(ctx, fonts);
+}
+
+#[cfg(any(test, target_arch = "wasm32"))]
+fn web_font_definitions(ui_font: &str, previous: Option<FontDefinitions>) -> FontDefinitions {
+ let mut fonts = base_font_definitions();
+ if let Some(font) = self::ui_font(ui_font) {
+ fonts = with_ui_font(fonts, font);
+ }
+ if let Some(data) = previous.and_then(|f| f.font_data.get(CJK_FALLBACK).cloned()) {
+ fonts.font_data.insert(CJK_FALLBACK.to_owned(), data);
+ for family in all_families() {
+ fonts.families.entry(family).or_default().push(CJK_FALLBACK.to_owned());
+ }
+ }
+ with_symbol_fallback(fonts)
+}
-/// On web only the symbol fallback goes in at start (#2955); the CJK font loads later through
-/// [`install_cjk_font_for`], which keeps it as a fallback unless the UI is a CJK language.
+/// Web starts with the bundled faces and symbol fallback; Japanese loads on demand.
#[cfg(target_arch = "wasm32")]
pub fn setup_fonts(ctx: &egui::Context) {
- ctx.set_fonts(with_symbol_fallback(egui::FontDefinitions::default()));
+ setup_fonts_for(ctx, "en", "");
+}
+
+/// A context with the production bundled faces, for isolated widget tests.
+#[cfg(test)]
+pub(crate) fn test_context() -> egui::Context {
+ let ctx = egui::Context::default();
+ setup_bundled_fonts(&ctx);
+ ctx
}
#[cfg(test)]
@@ -701,7 +825,12 @@ mod tests {
/// comes last and once, after the system fallbacks, and goes in with the desktop's fonts.
#[test]
fn symbols_fall_back_to_the_built_in_hack() {
- let fonts = with_symbol_fallback(egui::FontDefinitions::default());
+ let fonts = with_symbol_fallback(base_font_definitions());
+ for family in sans_families() {
+ let list = &fonts.families[&family];
+ assert_eq!(list.last().map(String::as_str), Some(SYMBOL_FALLBACK));
+ assert_eq!(list.iter().filter(|name| *name == SYMBOL_FALLBACK).count(), 1);
+ }
for c in "▲▼↑↓→⁻".chars() {
assert!(proportional_draws(&fonts, c), "{c:?} (U+{:04X}) has a face", c as u32);
}
@@ -725,20 +854,118 @@ mod tests {
assert!(ui_font("").is_none());
assert!(ui_font("No Such Font 1290").is_none());
let font = ui_font(solidcraft_engine::sketch::DEFAULT_FONT_FAMILY).expect("the built-in sketch font reads");
- let defaults = egui::FontDefinitions::default();
- let first_default = defaults.families[&egui::FontFamily::Proportional][0].clone();
- let fonts = with_ui_font(defaults, font.clone());
- let list = &fonts.families[&egui::FontFamily::Proportional];
- assert_eq!(list[0], UI_FONT);
- assert!(list.contains(&first_default), "{list:?}");
- assert!(!fonts.families[&egui::FontFamily::Monospace].contains(&UI_FONT.to_string()));
- // Choosing again replaces it rather than adding a second entry.
+ let defaults = base_font_definitions();
+ let fonts = with_ui_font(defaults.clone(), font.clone());
let again = with_ui_font(fonts, font);
- assert_eq!(again.families[&egui::FontFamily::Proportional].iter().filter(|n| *n == UI_FONT).count(), 1);
+ for family in sans_families() {
+ let list = &again.families[&family];
+ assert_eq!(list[0], UI_FONT);
+ assert_eq!(&list[1..], defaults.families[&family]);
+ assert_eq!(list.iter().filter(|n| *n == UI_FONT).count(), 1);
+ }
+ assert_eq!(again.families[&FontFamily::Monospace], defaults.families[&FontFamily::Monospace]);
+ }
+
+ #[test]
+ fn bundled_faces_lead_every_family_and_keep_egui_fallbacks() {
+ let defaults = with_symbol_fallback(FontDefinitions::default());
+ let fonts = base_font_definitions();
+ for ((name, weight), family) in WEIGHTS.into_iter().zip(sans_families()) {
+ let list = &fonts.families[&family];
+ assert_eq!(list[0], name);
+ assert_eq!(&list[1..], defaults.families[&FontFamily::Proportional]);
+ let data = &fonts.font_data[name];
+ assert_eq!(data.font.as_ref(), PLEX_SANS);
+ assert_eq!(data.tweak.coords.as_ref()[0].1, weight);
+ assert!(data.variation_axes().iter().any(|a| a.tag == *b"wght"));
+ }
+ let mono = &fonts.families[&FontFamily::Monospace];
+ assert_eq!(mono[0], "plex-mono");
+ assert_eq!(&mono[1..], defaults.families[&FontFamily::Monospace]);
+ assert_eq!(fonts.font_data["plex-mono"].font.as_ref(), PLEX_MONO);
+ }
+
+ #[test]
+ fn semibold_has_distinct_metrics_and_rich_text_preserves_size_and_colour() {
+ let h = crate::scenario::Harness::new();
+ let ink = crate::theme::Tokens::get().accent;
+ let (regular, heavier) = h.ctx.fonts_mut(|f| {
+ let regular = f.layout_no_wrap("Chamfer Revolve New Sketch".into(), FontId::proportional(16.0), ink);
+ let heavier = f.layout_no_wrap("Chamfer Revolve New Sketch".into(), semibold(16.0), ink);
+ (regular.size().x, heavier.size().x)
+ });
+ assert!(heavier > regular + 0.1, "real semibold metrics differ: {regular} -> {heavier}");
+ let mut output = h.ctx.run_ui(egui::RawInput::default(), |ui| {
+ for (text, expected) in [
+ (RichText::new("Medium").color(ink).size(16.0).medium(), medium(16.0)),
+ (RichText::new("Semibold").color(ink).size(16.0).semibold(), semibold(16.0)),
+ (RichText::new("Bold").color(ink).size(16.0).bold_face(), bold(16.0)),
+ ] {
+ let galley = egui::WidgetText::from(text).into_galley(ui, None, f32::INFINITY, egui::TextStyle::Body);
+ assert_eq!(galley.job.sections[0].format.font_id, expected);
+ assert_eq!(galley.job.sections[0].format.color, ink);
+ }
+ });
+ output.textures_delta.clear();
+ }
+
+ #[test]
+ fn web_download_and_preference_changes_compose_without_losing_plex_or_japanese() {
+ let ctx = test_context();
+ let chosen = solidcraft_engine::sketch::DEFAULT_FONT_FAMILY;
+ install(&ctx, web_font_definitions(chosen, None));
+ // Both installations happen before the first frame, like a fast cached web fetch.
+ assert!(install_cjk_font(
+ &ctx,
+ include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf")).to_vec()
+ ));
+ let installed = ctx.data(|d| d.get_temp::<FontDefinitions>(installed_fonts_id())).unwrap();
+ for family in sans_families() {
+ assert_eq!(installed.families[&family][0], UI_FONT);
+ assert_eq!(installed.families[&family].get(1).map(String::as_str), Some(CJK_FALLBACK));
+ }
+ let reset = web_font_definitions("", Some(installed));
+ for ((name, _), family) in WEIGHTS.into_iter().zip(sans_families()) {
+ assert_eq!(reset.families[&family][0], name);
+ let list = &reset.families[&family];
+ assert_eq!(list.get(list.len() - 2).map(String::as_str), Some(CJK_FALLBACK));
+ assert_eq!(list.last().map(String::as_str), Some(SYMBOL_FALLBACK));
+ }
+ install(&ctx, reset);
+ let mut output = ctx.run_ui(egui::RawInput::default(), |_| {});
+ output.textures_delta.clear();
+ assert!(ctx.fonts_mut(|f| f.has_glyphs(&semibold(14.0), "日本語テスト")));
+ }
+
+ #[test]
+ fn japanese_and_chinese_fallbacks_cover_semibold_text() {
+ let japanese = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../../assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf"));
+ let chinese = find_system_chinese_font();
+ for language in ["ja", "zh"] {
+ let mut fonts = base_font_definitions();
+ for name in fallback_order(language) {
+ let bytes = match name {
+ CJK_FALLBACK => Some(japanese.to_vec()),
+ CHINESE_FALLBACK => chinese.clone(),
+ _ => None,
+ };
+ if let Some(bytes) = bytes {
+ fonts = with_fallback(fonts, name, bytes).unwrap();
+ }
+ }
+ let ctx = test_context();
+ install(&ctx, fonts);
+ let mut output = ctx.run_ui(egui::RawInput::default(), |_| {});
+ output.textures_delta.clear();
+ assert!(ctx.fonts_mut(|f| f.has_glyphs(&semibold(14.0), "日本語テスト")));
+ if chinese.is_some() {
+ assert!(ctx.fonts_mut(|f| f.has_glyphs(&semibold(14.0), "简体中文")));
+ }
+ }
}
fn latin_font_bytes() -> Vec<u8> {
- let defaults = egui::FontDefinitions::default();
+ let defaults = base_font_definitions();
let name = &defaults.families[&egui::FontFamily::Proportional][0];
defaults.font_data[name].font.to_vec()
}
@@ -751,9 +978,9 @@ mod tests {
#[test]
fn cjk_font_is_a_fallback_after_the_latin_ui_font() {
- let defaults = egui::FontDefinitions::default();
+ let defaults = base_font_definitions();
let fonts = with_cjk_fallback(defaults.clone(), latin_font_bytes()).unwrap();
- for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {
+ for family in all_families() {
let list = &fonts.families[&family];
assert_eq!(list.first(), defaults.families[&family].first(), "the Latin UI font stays first");
assert_eq!(list.last().map(String::as_str), Some(CJK_FALLBACK), "CJK is the last fallback");
@@ -772,12 +999,12 @@ mod tests {
"{lang} keeps the Japanese font first"
);
}
- let defaults = egui::FontDefinitions::default();
+ let defaults = base_font_definitions();
let mut fonts = defaults.clone();
for name in fallback_order("zh") {
fonts = with_fallback(fonts, name, latin_font_bytes()).unwrap();
}
- for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {
+ for family in all_families() {
let list = &fonts.families[&family];
assert_eq!(list.first(), defaults.families[&family].first(), "the Latin UI font stays first");
assert_eq!(&list[list.len() - 4..], [CHINESE_FALLBACK, CJK_FALLBACK, HANGUL_FALLBACK, THAI_FALLBACK]);
@@ -808,12 +1035,22 @@ mod tests {
#[test]
fn cjk_ui_promotes_primary_cjk_font_to_front_for_consistent_baseline() {
- let defaults = egui::FontDefinitions::default();
+ let defaults = base_font_definitions();
let mut fonts = with_cjk_fallback(defaults.clone(), latin_font_bytes()).unwrap();
promote_font_to_front(&mut fonts, CJK_FALLBACK);
- let prop = &fonts.families[&egui::FontFamily::Proportional];
- assert_eq!(prop.first().map(String::as_str), Some(CJK_FALLBACK), "CJK font is promoted to first so digits and CJK share one baseline");
- assert!(prop.contains(&defaults.families[&egui::FontFamily::Proportional][0]), "Latin font remains in the fallback chain");
+ for family in sans_families() {
+ let list = &fonts.families[&family];
+ assert_eq!(list.first().map(String::as_str), Some(CJK_FALLBACK));
+ assert!(list.contains(&defaults.families[&family][0]), "the bundled weight remains available");
+ }
+ assert_eq!(fonts.families[&FontFamily::Monospace][0], "plex-mono");
+ let chosen = egui::FontData::from_static(PLEX_SANS);
+ let mut fonts = with_ui_font(fonts, chosen);
+ promote_font_to_front(&mut fonts, CJK_FALLBACK);
+ for family in sans_families() {
+ assert_eq!(fonts.families[&family][0], UI_FONT);
+ assert_eq!(fonts.families[&family][1], CJK_FALLBACK);
+ }
}
/// A Ukrainian UI drew Cyrillic wide and loose: the bundled CJK face (BIZ UDPGothic) sets every
@@ -842,10 +1079,10 @@ mod tests {
#[test]
fn hangul_font_falls_back_after_the_cjk_font() {
- let defaults = egui::FontDefinitions::default();
+ let defaults = base_font_definitions();
let cjk = with_cjk_fallback(defaults.clone(), latin_font_bytes()).unwrap();
let fonts = with_fallback(cjk, HANGUL_FALLBACK, latin_font_bytes()).unwrap();
- for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {
+ for family in all_families() {
let list = &fonts.families[&family];
assert_eq!(list.first(), defaults.families[&family].first(), "the Latin UI font stays first");
assert_eq!(&list[list.len() - 2..], [CJK_FALLBACK, HANGUL_FALLBACK], "Hangul follows the CJK fallback");
diff --git a/crates/ui-egui/src/frame_rate.rs b/crates/ui-egui/src/frame_rate.rs
index 523cdc08f9..f7b2ab33fe 100644
--- a/crates/ui-egui/src/frame_rate.rs
+++ b/crates/ui-egui/src/frame_rate.rs
@@ -48,7 +48,7 @@ pub(crate) fn paint(app: &mut SolveApp, ctx: &egui::Context, painter: &egui::Pai
ctx.request_repaint();
let Some(text) = app.frame_rate.label() else { return };
let t = Tokens::get();
- let font = FontId::monospace(12.0);
+ let font = FontId::monospace(crate::theme::Tokens::get().font_body);
let galley = painter.layout_no_wrap(text, font, t.text);
let size = galley.size() + vec2(16.0, 8.0);
let r = Rect::from_min_size(pos2(rect.right() - 12.0 - size.x, rect.bottom() - 12.0 - size.y), size);
diff --git a/crates/ui-egui/src/help.rs b/crates/ui-egui/src/help.rs
index 9f9cfb4dd3..fe38a3f3b8 100644
--- a/crates/ui-egui/src/help.rs
+++ b/crates/ui-egui/src/help.rs
@@ -3,6 +3,7 @@
//! (read only), Messages (every status message of the run, #2763), and Report an Issue, which
//! opens a local editable report draft.
+use crate::fonts::RichTextExt as _;
use egui::{RichText, vec2};
use crate::SolveApp;
@@ -72,15 +73,15 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context, anchor: egui::Pos2) {
let resp =
crate::frame::area(egui::Id::new("sc_help_menu")).fixed_pos(anchor).constrain(true).order(egui::Order::Foreground).show(ctx, |ui| {
crate::context_menu::menu_frame(ui, |ui| {
- for (id, label) in [
- ("docs", "Documentation"),
- ("about", "About SolidCraft"),
- ("shortcuts", "Keyboard Shortcuts"),
- ("messages", "Messages…"),
- ("report", "Report an Issue…"),
- ("crashes", "Crash Reports…"),
+ for (id, label, icon) in [
+ ("docs", "Documentation", "library"),
+ ("about", "About SolidCraft", "help"),
+ ("shortcuts", "Keyboard Shortcuts", "list"),
+ ("messages", "Messages…", "list"),
+ ("report", "Report an Issue…", "bug_report"),
+ ("crashes", "Crash Reports…", "status_error"),
] {
- if crate::context_menu::list_row(ui, &crate::context_menu::Item::action(id, label, "")).is_some() {
+ if crate::context_menu::list_row(ui, &crate::context_menu::Item::action(id, label, icon)).is_some() {
pick = Some(id);
}
}
@@ -112,7 +113,7 @@ fn about(app: &mut SolveApp, ctx: &egui::Context) {
.open(&mut open)
.default_size(vec2(440.0, 560.0))
.show(ctx, |ui| {
- ui.label(RichText::new("SolidCraft").size(22.0).strong());
+ ui.label(RichText::new("SolidCraft").size(crate::theme::Tokens::get().font_title).semibold().color(crate::theme::Tokens::get().text));
ui.label(format!("Version {VERSION} · commit {COMMIT} · built {BUILD_DATE}"));
ui.label(RichText::new(crate::i18n::tr_label("Open-source parametric 3D CAD in Rust. Licensed MIT OR Apache-2.0.")).color(t.text_dim));
ui.add_space(6.0);
@@ -124,20 +125,20 @@ fn about(app: &mut SolveApp, ctx: &egui::Context) {
ui.separator();
egui::ScrollArea::vertical().show(ui, |ui| {
egui::CollapsingHeader::new("Attributions (ATTRIBUTION.md)").show(ui, |ui| {
- ui.label(RichText::new(ATTRIBUTION).monospace().size(11.0));
+ ui.label(RichText::new(ATTRIBUTION).monospace().size(crate::theme::Tokens::get().font_small));
});
egui::CollapsingHeader::new("Fonts").show(ui, |ui| {
ui.label(FONTS);
});
egui::CollapsingHeader::new("Licences").show(ui, |ui| {
egui::CollapsingHeader::new("NOTICE").show(ui, |ui| {
- ui.label(RichText::new(NOTICE).monospace().size(11.0));
+ ui.label(RichText::new(NOTICE).monospace().size(crate::theme::Tokens::get().font_small));
});
egui::CollapsingHeader::new("MIT licence").show(ui, |ui| {
- ui.label(RichText::new(LICENSE_MIT).monospace().size(11.0));
+ ui.label(RichText::new(LICENSE_MIT).monospace().size(crate::theme::Tokens::get().font_small));
});
egui::CollapsingHeader::new("Apache licence 2.0").show(ui, |ui| {
- ui.label(RichText::new(LICENSE_APACHE).monospace().size(11.0));
+ ui.label(RichText::new(LICENSE_APACHE).monospace().size(crate::theme::Tokens::get().font_small));
});
egui::CollapsingHeader::new("Third-party licences").show(ui, |ui| {
if ui.button(crate::i18n::tr_label("Copy all licences")).clicked() {
@@ -156,7 +157,7 @@ fn about(app: &mut SolveApp, ctx: &egui::Context) {
/// THIRD-PARTY-LICENSES.txt (over 10 000 lines): only the lines in view are laid out.
fn third_party(ui: &mut egui::Ui) {
let lines: Vec<&str> = THIRD_PARTY.lines().collect();
- let font = egui::FontId::monospace(11.0);
+ let font = egui::FontId::monospace(crate::theme::Tokens::get().font_small);
let row_h = ui.fonts_mut(|f| f.row_height(&font));
egui::ScrollArea::both().id_salt("sc_third_party").max_height(360.0).show_rows(ui, row_h, lines.len(), |ui, rows| {
for line in lines.get(rows).unwrap_or_default() {
diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rs
index 5ca150a4d0..3fd5d3a09f 100644
--- a/crates/ui-egui/src/home.rs
+++ b/crates/ui-egui/src/home.rs
@@ -2,6 +2,7 @@
//! picture of the design rendered from it. Shown on launch without a file and from the house
//! button or the first document tab; selecting a design returns to its view.
+use crate::fonts::RichTextExt as _;
use std::collections::HashMap;
use egui::{Color32, CornerRadius, RichText, Sense, Stroke, vec2};
@@ -454,9 +455,9 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
egui::CentralPanel::default().frame(egui::Frame::NONE.fill(t.panel).inner_margin(egui::Margin::symmetric(36, 24))).show(ui, |ui| {
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
ui.horizontal(|ui| {
- ui.label(RichText::new("SolidCraft").size(26.0).strong().color(t.text));
+ ui.label(RichText::new("SolidCraft").size(crate::theme::Tokens::get().font_display).semibold().color(t.text));
ui.add_space(t.space_12);
- ui.label(RichText::new(crate::i18n::tr_label("Start")).size(16.0).color(t.text_dim));
+ ui.label(RichText::new(crate::i18n::tr_label("Start")).size(crate::theme::Tokens::get().font_intro).color(t.text_dim));
});
ui.add_space(t.space_16);
ui.horizontal(|ui| {
@@ -464,7 +465,11 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
// The label sets the width: a translation longer than the English one widens
// the button instead of running past its edge.
let ink_text = if primary { t.on_accent } else { t.text };
- let galley = ui.painter().layout_no_wrap(label.to_owned(), egui::FontId::proportional(15.0), ink_text);
+ let galley = ui.painter().layout_no_wrap(
+ label.to_owned(),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_subtitle),
+ ink_text,
+ );
let width = (56.0 + galley.size().x + 20.0).max(170.0);
let (r, resp) = ui.allocate_exact_size(vec2(width, 64.0), Sense::click());
let fill = if primary {
@@ -552,12 +557,14 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
.on_hover_text(p.as_str());
crate::scenario::publish_handle(&format!("home:recent:{i}"), response.rect.center());
response.context_menu(|ui| {
- if ui.button(crate::i18n::tr_label("Remove from list")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Remove from list"), "delete").clicked() {
app.home.recent.retain(|x| x != p);
app.home.opened_at.remove(p);
ui.close();
}
- if !cfg!(target_arch = "wasm32") && ui.button(crate::i18n::tr_label("Show in folder")).clicked() {
+ if !cfg!(target_arch = "wasm32")
+ && crate::context_menu::button(ui, crate::i18n::tr_label("Show in folder"), "folder").clicked()
+ {
if let Some(show) = &app.services.show_in_folder {
show(p);
}
@@ -596,7 +603,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
fn section(ui: &mut egui::Ui, title: &str) {
let t = Tokens::get();
- ui.label(RichText::new(title).size(15.0).strong().color(t.text));
+ ui.label(RichText::new(title).size(crate::theme::Tokens::get().font_subtitle).semibold().color(t.text));
ui.add_space(t.space_8);
}
diff --git a/crates/ui-egui/src/i18n_ui_tests.rs b/crates/ui-egui/src/i18n_ui_tests.rs
index 3d1ac2ab05..08e58f3c4a 100644
--- a/crates/ui-egui/src/i18n_ui_tests.rs
+++ b/crates/ui-egui/src/i18n_ui_tests.rs
@@ -53,6 +53,8 @@ fn sketch_palette_profile_and_points_rows_show_their_own_translation() {
h.app.home.open = false;
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.frames(3);
+ let at = scenario::handle_at("sketch_palette:options_fold").unwrap();
+ h.call("ui.click", json!({"x":at.x,"y":at.y}));
assert!(h.widget(profile).is_some(), "{lang}: the Profile row must show {profile:?}");
assert!(h.widget(points).is_some(), "{lang}: the Points row must show {points:?}");
assert!(h.widget("Profile").is_none(), "{lang}: must not silently fall back to English");
@@ -227,10 +229,14 @@ fn translated_dialog_buttons_do_not_wrap() {
h.app.preferences.language = "ja".into();
h.app.home.open = false;
h.call("ui.start", json!({"command":"solid.extrude"}));
- let mut out = h.ctx.run_ui(
- egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() },
- |ui| h.app.ui(ui),
- );
+ // A few frames: the card sizes itself from its content over the first passes.
+ let mut out = egui::FullOutput::default();
+ for _ in 0..5 {
+ out = h.ctx.run_ui(
+ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() },
+ |ui| h.app.ui(ui),
+ );
+ }
assert_eq!(out.shapes.iter().find_map(|shape| cancel_rows(&shape.shape)), Some(1));
out.textures_delta.clear();
}
diff --git a/crates/ui-egui/src/icon_svg.rs b/crates/ui-egui/src/icon_svg.rs
index b4708be660..e80d0382e5 100644
--- a/crates/ui-egui/src/icon_svg.rs
+++ b/crates/ui-egui/src/icon_svg.rs
@@ -23,6 +23,54 @@ include!(concat!(env!("OUT_DIR"), "/icon_data.rs"));
/// The id drawn for every icon that has no master yet.
pub const PLACEHOLDER: &str = "placeholder";
+/// Opt-in icon discovery on the UI thread. Disabled rendering only checks a thread-local flag.
+pub mod audit {
+ use std::cell::{Cell, RefCell};
+ use std::collections::BTreeMap;
+
+ /// One requested semantic id and the artwork actually selected by the renderer.
+ #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize)]
+ pub struct Requested {
+ pub name: String,
+ pub master: String,
+ pub placeholder: bool,
+ }
+
+ thread_local! {
+ static ACTIVE: Cell<bool> = const { Cell::new(false) };
+ static REQUESTS: RefCell<BTreeMap<String, Requested>> = const { RefCell::new(BTreeMap::new()) };
+ }
+
+ /// Enable collection and reset the accumulated names.
+ pub fn start() {
+ REQUESTS.with(|requests| requests.borrow_mut().clear());
+ ACTIVE.set(true);
+ }
+
+ /// Drain sorted, unique requests; collection stays enabled until `stop`.
+ pub fn take() -> Vec<Requested> {
+ REQUESTS.with(|requests| std::mem::take(&mut *requests.borrow_mut()).into_values().collect())
+ }
+
+ /// Disable collection, releasing any requests that were not taken.
+ pub fn stop() {
+ ACTIVE.set(false);
+ REQUESTS.with(|requests| requests.borrow_mut().clear());
+ }
+
+ pub(super) fn record(name: &str, resolved: super::Resolved) {
+ if ACTIVE.get() {
+ REQUESTS.with(|requests| {
+ requests.borrow_mut().entry(name.to_owned()).or_insert_with(|| Requested {
+ name: name.to_owned(),
+ master: resolved.master.to_owned(),
+ placeholder: resolved.placeholder,
+ });
+ });
+ }
+ }
+}
+
/// How a shape is painted.
#[derive(Clone, Copy, Debug, PartialEq)]
enum Paint {
@@ -561,6 +609,12 @@ pub(crate) fn role_colour(name: &str, look: Look) -> egui::Color32 {
/// The master and accent for an app icon id: an alias (with its accent), a master of that name,
/// or the placeholder.
pub fn resolve(name: &str) -> Resolved {
+ let resolved = resolve_master(name);
+ audit::record(name, resolved);
+ resolved
+}
+
+fn resolve_master(name: &str) -> Resolved {
let (big, _) = table();
let placeholder = Resolved { master: PLACEHOLDER, accent: None, placeholder: true };
if let Some((_, master, accent)) = ALIASES.iter().find(|(a, _, _)| *a == name) {
diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs
index 5d9cb6ba60..7aa7ebc44d 100644
--- a/crates/ui-egui/src/icons.rs
+++ b/crates/ui-egui/src/icons.rs
@@ -96,7 +96,7 @@ mod tests {
fn assistant_pixels_use_the_application_bar_text_token() {
let previous = theme::is_dark();
for dark in [false, true] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
theme::set_dark(dark);
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
paint_app_bar(ui.painter(), Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(32.0, 32.0)), "assistant", 1.0);
@@ -112,17 +112,17 @@ mod tests {
#[test]
fn actual_uploaded_icon_pixels_follow_semantics_and_vision_cache_changes() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let previous = theme::vision();
for dark in [false, true] {
for vision in [ColorVision::Off, ColorVision::Protan, ColorVision::Tritan] {
theme::set_vision(vision);
- for icon in ["line", "c_parallel", "construction", "centerline", "surface_extrude", "mesh_export", "contact_new"] {
- let expected = if icon == "construction" {
- icon_svg::role_colour("guide", Look { dark, accent: None, vision })
- } else {
- icon_svg::primary(icon, dark, vision)
- };
+ // The line types: Normal in the base blue, and Construction, Centerline and Infinite
+ // in the construction accent, as the sketch canvas draws them.
+ for icon in
+ ["line", "c_parallel", "normal", "construction", "centerline", "infinite", "surface_extrude", "mesh_export", "contact_new"]
+ {
+ let expected = icon_svg::primary(icon, dark, vision);
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let r = Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(64.0, 64.0));
paint_on(ui.painter(), r, icon, Some(dark), 1.0);
diff --git a/crates/ui-egui/src/issue_report.rs b/crates/ui-egui/src/issue_report.rs
index e0fc8c4a10..1b095dbf6e 100644
--- a/crates/ui-egui/src/issue_report.rs
+++ b/crates/ui-egui/src/issue_report.rs
@@ -1,5 +1,6 @@
//! Reviewed issue drafts with local evidence; never publishes or uploads a report.
+use crate::fonts::RichTextExt as _;
use std::fmt::Write as _;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
@@ -590,7 +591,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
});
ui.separator();
- ui.label(RichText::new(crate::i18n::tr_label("Send your report on GitHub")).strong());
+ ui.label(RichText::new(crate::i18n::tr_label("Send your report on GitHub")).semibold().color(crate::theme::Tokens::get().text));
let (url, copy_needed) = draft_url(&draft.title, &draft.body);
ui.add(
egui::Label::new(crate::i18n::tr_label(if copy_needed {
@@ -606,7 +607,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let t = crate::theme::Tokens::get();
if crate::frame::add_outlined(
ui,
- egui::Button::new(RichText::new(crate::i18n::tr_label("Open GitHub draft")).strong().color(t.text))
+ egui::Button::new(RichText::new(crate::i18n::tr_label("Open GitHub draft")).semibold().color(t.text))
.fill(t.accent_soft)
.stroke(egui::Stroke::new(1.0, t.accent)),
1.0,
@@ -754,7 +755,7 @@ mod tests {
app.run("solid.combine", json!({"target":"Stock","tools":["Cutter"],"operation":"cut","keep_tools":true})).unwrap();
assert!(app.session.model.results.iter().all(|r| r.error.is_none()));
let before = (app.session.doc.to_json(), app.session.undo.len(), app.session.redo.len(), app.cam);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
help::run(&mut app, &ctx, "report");
let draft = app.issue_report.draft.as_ref().unwrap();
assert!(draft.body.contains("Describe the unexpected result"));
@@ -938,7 +939,7 @@ mod tests {
#[test]
fn issue_report_boundary_preserves_opacity_widget_state_and_real_focus() {
let mut app = app();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let focus = egui::Id::new("report-review-focus");
let state = egui::Id::new("cad-layout-state");
begin(&mut app, &ctx, None, None);
@@ -1133,7 +1134,7 @@ mod tests {
#[test]
fn issue_report_capture_accepts_only_its_matching_unchanged_frame() {
let mut app = app();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
begin(&mut app, &ctx, None, None);
let token = app.issue_report.pending.as_ref().unwrap().token;
let (reply, _receiver) = std::sync::mpsc::channel();
@@ -1158,7 +1159,7 @@ mod tests {
fn issue_report_capture_rejects_changed_inputs_timeout_and_malformed_images() {
let mut app = app();
combine(&mut app);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let dialog = app.dialog.clone();
begin(&mut app, &ctx, dialog.as_ref(), Some("bad Boolean"));
app.dialog.as_mut().unwrap().extra.insert("direction".into(), json!("negative"));
diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs
index abb3810345..fe004b4a55 100644
--- a/crates/ui-egui/src/keymap.rs
+++ b/crates/ui-egui/src/keymap.rs
@@ -3,6 +3,7 @@
//! already uses is reported and only taken over on request; keys the app itself handles (Esc, S,
//! V, Delete, Ctrl+Z…) can't be bound. Changes are kept between runs.
+use crate::fonts::RichTextExt as _;
use std::collections::BTreeMap;
use egui::RichText;
@@ -229,7 +230,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
RichText::new(
app.tr_label("Select Other: hold the left button still on the model (or right-click › Select Other…) to list everything under the cursor; click again on the same spot to select the next thing there. Double-click the middle button to go Home (Preferences › Navigation)."),
)
- .size(11.0)
+ .size(crate::theme::Tokens::get().font_small)
.color(t.text_dim),
);
ui.separator();
@@ -243,7 +244,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
continue;
}
ui.label(translated_label);
- ui.label(RichText::new(c.id).size(10.5).color(t.text_dim));
+ ui.label(RichText::new(c.id).size(crate::theme::Tokens::get().font_panel).color(t.text_dim));
let capturing = app.keymap.capturing.as_deref() == Some(c.id);
let changed = app.keymap.custom.contains_key(c.id);
let text = if capturing {
@@ -254,7 +255,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
key.clone()
};
if app.keymap.read_only {
- ui.label(RichText::new(text).strong());
+ ui.label(RichText::new(text).semibold().color(crate::theme::Tokens::get().text));
ui.end_row();
continue;
}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index fd995697e0..bfa139363c 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -46,6 +46,8 @@ mod dimension_create_ui_tests;
pub mod documents;
pub mod drag_snap;
pub mod edit_clipboard;
+#[cfg(test)]
+mod font_literals_tests;
pub mod fonts;
pub mod frame;
pub mod frame_rate;
@@ -210,6 +212,9 @@ pub mod tool_modifiers;
pub mod toolbar;
pub mod toolbar_custom;
pub mod tools;
+pub mod ui_kit;
+#[cfg(test)]
+mod ui_kit_guard_tests;
pub mod update;
pub mod viewport;
mod viewport_layout;
diff --git a/crates/ui-egui/src/material_card_review.rs b/crates/ui-egui/src/material_card_review.rs
index c23f69f19a..4205d1257c 100644
--- a/crates/ui-egui/src/material_card_review.rs
+++ b/crates/ui-egui/src/material_card_review.rs
@@ -1,4 +1,5 @@
//! Candidate review through the existing validator, independent of assigned-card persistence.
+use crate::fonts::RichTextExt as _;
use egui::RichText;
use serde_json::{Value, json};
use solidcraft_engine::doc::physical_material::{Family, MaterialCard, PropertyData, admit_card};
@@ -106,7 +107,7 @@ fn show_card(ui: &mut egui::Ui, card: &MaterialCard, report: &Value) {
// Schema identifiers are inert metadata, not translated source claims or assigned body axes.
let family = serde_json::to_value(card.family).unwrap_or(Value::Null);
value(ui, "family", family.as_str().map(str::to_string), "");
- ui.strong(tr("ui.material_review.properties"));
+ ui.label(egui::RichText::new(tr("ui.material_review.properties")).semibold().color(crate::theme::Tokens::get().text));
for kind in KINDS {
let label = format!("ui.material_review.{kind}");
let Some(property) = card.properties.iter().find(|p| p.data.kind() == kind) else {
@@ -123,7 +124,7 @@ fn show_card(ui: &mut egui::Ui, card: &MaterialCard, report: &Value) {
value(ui, "axes", Some(axes), "");
ui.label(tr("ui.material_review.axes"));
}
- ui.strong(tr("ui.material_review.conditions"));
+ ui.label(egui::RichText::new(tr("ui.material_review.conditions")).semibold().color(crate::theme::Tokens::get().text));
let c = &property.conditions;
value(ui, "temperature_k", c.temperature_k.map(|v| v.to_string()), "K");
value(ui, "state", c.state.clone(), "");
@@ -133,7 +134,7 @@ fn show_card(ui: &mut egui::Ui, card: &MaterialCard, report: &Value) {
if card.family == Family::Polymer || c.strain_rate_per_s.is_some() {
value(ui, "strain_rate_per_s", c.strain_rate_per_s.map(|v| v.to_string()), "s⁻¹");
}
- ui.strong(tr("ui.material_review.source"));
+ ui.label(egui::RichText::new(tr("ui.material_review.source")).semibold().color(crate::theme::Tokens::get().text));
if let Some(source) = card.sources.iter().find(|s| s.id == property.source_id) {
ui.label(&source.title);
value(ui, "source_id", Some(source.id.clone()), "");
@@ -144,7 +145,7 @@ fn show_card(ui: &mut egui::Ui, card: &MaterialCard, report: &Value) {
});
}
if let Some(moduli) = report.get("validation").and_then(|v| v.get("isotropic_moduli")).filter(|v| v.is_object()) {
- ui.strong(tr("ui.material_review.derived"));
+ ui.label(egui::RichText::new(tr("ui.material_review.derived")).semibold().color(crate::theme::Tokens::get().text));
for field in ["shear_pa", "bulk_pa"] {
value(ui, field, moduli.get(field).and_then(Value::as_f64).map(|v| format!("{v:e}")), "Pa");
}
diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rs
index 982bf9fdbf..b85c497fb2 100644
--- a/crates/ui-egui/src/navigation.rs
+++ b/crates/ui-egui/src/navigation.rs
@@ -409,7 +409,10 @@ pub(crate) fn handle(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, resp: &e
} else {
None
};
- let dragging = resp.dragged() || (inside && button.is_some());
+ // An orbit started on the viewport owns its button until release, including over a
+ // floating shell card that disables the underlying egui response.
+ let captured_orbit = app.viewport.orbit_from.is_some() && button.is_some();
+ let dragging = resp.dragged() || (inside && button.is_some()) || captured_orbit;
// Without orbit (a flat page), bindings that orbit do nothing.
let allowed = |m: NavMode| caps.orbit || m != NavMode::Orbit;
let motion = modifier_motion(app, ui, inside, hover, mods, picking).filter(|(m, _)| allowed(*m));
@@ -783,7 +786,7 @@ mod tests {
let mut app = crate::SolveApp::new(s, crate::Services::default());
app.preferences.nav = preset.into();
app.viewport.spin = true;
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut time = 0.0;
let mut frame = |app: &mut crate::SolveApp, mods: Modifiers, events: Vec<Event>| {
time += 1.0 / 60.0;
@@ -848,7 +851,7 @@ mod tests {
let mut s = solidcraft_engine::Session::default();
s.execute("solid.box", &serde_json::json!({"length":40,"width":30,"height":20})).unwrap();
let mut app = crate::SolveApp::new(s, crate::Services::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let before = app.cam;
app.viewport.device_motion = Some(every_axis);
let raw = egui::RawInput {
diff --git a/crates/ui-egui/src/navigation_cube.rs b/crates/ui-egui/src/navigation_cube.rs
index f3525f9e86..3c03df8985 100644
--- a/crates/ui-egui/src/navigation_cube.rs
+++ b/crates/ui-egui/src/navigation_cube.rs
@@ -231,7 +231,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {
let (r, u, _) = app.cam.basis();
let tip = origin + vec2((d.dot(r) * 17.0) as f32, -(d.dot(u) * 17.0) as f32) * scale;
painter.line_segment([origin, tip], Stroke::new(1.5, color));
- painter.text(tip, Align2::CENTER_CENTER, label, FontId::proportional(8.0), color);
+ painter.text(tip, Align2::CENTER_CENTER, label, FontId::proportional(crate::theme::Tokens::get().font_triad), color);
}
}
@@ -272,7 +272,7 @@ mod tests {
fn former_edge_strips_click_the_face_and_hover_without_internal_seams() {
let mut h = crate::scenario::Harness::new();
h.call("ui.prefs", json!({"navigator_style":"cube"}));
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
h.app.preferences.look_at_anim = false;
for up in ["z", "y"] {
h.call("ui.prefs", json!({"up_axis":up}));
@@ -337,7 +337,7 @@ mod tests {
#[test]
fn hovered_face_and_corner_have_a_pale_blue_opaque_fill_in_both_themes() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let faces = facets(&Camera::default(), pos2(100.0, 100.0), HALF);
for t in [Tokens::light(), Tokens::dark()] {
assert_ne!(t.navigation_cube(false).cube_face, t.cube_face);
@@ -363,7 +363,7 @@ mod tests {
#[test]
fn idle_principal_views_have_square_faces_without_visible_picking_seams() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
for up in [UpAxis::Z, UpAxis::Y] {
for view in [StandardView::Front, StandardView::Back, StandardView::Top, StandardView::Bottom, StandardView::Left, StandardView::Right] {
let mut cam = Camera { up, ..Default::default() };
@@ -427,11 +427,11 @@ mod tests {
#[test]
fn face_labels_use_normalized_font_atlas_coordinates() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let output = paint_frame(&ctx, |ui| {
let faces = facets(&Camera::default(), pos2(100.0, 100.0), HALF);
for face in &faces {
- face_text(ui.painter(), face, Tokens::light().cube_text, 14.0);
+ face_text(ui.painter(), face, Tokens::light().cube_text, Tokens::get().font_heading);
}
});
let meshes: Vec<_> = output.shapes.iter().filter_map(|shape| if let Shape::Mesh(mesh) = &shape.shape { Some(mesh) } else { None }).collect();
@@ -444,7 +444,7 @@ mod tests {
#[test]
fn label_uvs_follow_font_atlas_growth_later_in_the_same_frame() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut pixel_uv = Pos2::ZERO;
let mut glyph_vertex = 0;
let mut early_size = [0; 2];
@@ -457,7 +457,7 @@ mod tests {
let (index, vertex) = galley.rows.first().unwrap().visuals.mesh.vertices.iter().enumerate().find(|(_, v)| v.uv.y > 1.0).unwrap();
glyph_vertex = index;
pixel_uv = vertex.uv;
- face_text(ui.painter(), face, Tokens::light().cube_text, 14.0);
+ face_text(ui.painter(), face, Tokens::light().cube_text, Tokens::get().font_heading);
early_size = ctx.fonts(|f| f.font_image_size());
// Other widgets can allocate new glyphs after the cube has been drawn.
let text: String = (32_u8..127).map(char::from).collect();
@@ -473,7 +473,7 @@ mod tests {
#[test]
fn rotating_cube_facets_stay_opaque_and_inside_the_projected_geometry() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
for up in [UpAxis::Z, UpAxis::Y] {
for view in [StandardView::Top, StandardView::Bottom, StandardView::Front, StandardView::Back, StandardView::Left, StandardView::Right] {
let from = Camera { up, ..Default::default() };
diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs
index e26e33947f..dfbc92b088 100644
--- a/crates/ui-egui/src/palette.rs
+++ b/crates/ui-egui/src/palette.rs
@@ -87,7 +87,7 @@ pub fn palette_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
submit(app, &line);
}
if let Some(last) = app.session.log.last() {
- ui.label(RichText::new(last).size(11.5).color(t.text_dim));
+ ui.label(RichText::new(last).size(t.font_caption).color(t.text_dim));
}
});
},
@@ -128,7 +128,7 @@ pub fn popup(app: &mut SolveApp, ctx: &egui::Context) {
if ui.add_enabled(enabled, egui::Button::new(*label).frame(false)).clicked() {
picked = Some(id);
}
- ui.label(RichText::new(*id).size(10.5).color(t.text_dim));
+ ui.label(RichText::new(*id).size(t.font_panel).color(t.text_dim));
});
}
});
diff --git a/crates/ui-egui/src/params_dialog.rs b/crates/ui-egui/src/params_dialog.rs
index 475a08e42b..0a73a70a5f 100644
--- a/crates/ui-egui/src/params_dialog.rs
+++ b/crates/ui-egui/src/params_dialog.rs
@@ -9,6 +9,7 @@
//! [`complete`] adds suggestions (parameters, functions, units) under any expression box: the
//! names come from `parameters.complete`, cached per document revision by [`publish`].
+use crate::fonts::RichTextExt as _;
use std::sync::Arc;
use egui::RichText;
@@ -148,64 +149,74 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
d.lists += 1;
r
};
- crate::frame::window(ctx, RichText::new(crate::i18n::tr_label("PARAMETERS")).strong().size(13.0), crate::frame::Width::Wide)
- .id(egui::Id::new("sc_params_dialog"))
- .open(&mut open)
- .default_width(740.0)
- .default_height(520.0)
- .resizable(true)
- .collapsible(false)
- .show(ctx, |ui| {
- ui.horizontal(|ui| {
- ui.add(egui::TextEdit::singleline(&mut d.filter).hint_text(crate::i18n::tr_label("Filter")).desired_width(180.0));
- ui.separator();
- if ui.button("Import…").on_hover_text(crate::i18n::tr_label("CSV or JSON: updates existing parameters, adds new ones")).clicked() {
- app.pick_open_command("parameters.import", json!({}), &[]);
- }
- for (label, ext) in [("Export CSV…", "csv"), ("Export JSON…", "json")] {
- if ui.button(label).clicked() {
- app.pick_save_command(&format!("parameters.{ext}"), &[ext], "parameters.export", json!({"format": ext}));
- }
- }
- });
- if let Some(e) = &d.error {
- ui.label(RichText::new(e).color(t.error));
- }
+ crate::frame::window(
+ ctx,
+ RichText::new(crate::i18n::tr_label("PARAMETERS"))
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_button),
+ crate::frame::Width::Wide,
+ )
+ .id(egui::Id::new("sc_params_dialog"))
+ .open(&mut open)
+ .default_width(740.0)
+ .default_height(520.0)
+ .resizable(true)
+ .collapsible(false)
+ .show(ctx, |ui| {
+ ui.horizontal(|ui| {
+ ui.add(egui::TextEdit::singleline(&mut d.filter).hint_text(crate::i18n::tr_label("Filter")).desired_width(180.0));
ui.separator();
- let f = d.filter.to_ascii_lowercase();
- let visible: Vec<&Row> = all
- .iter()
- .filter(|r| {
- f.is_empty()
- || r.name.to_ascii_lowercase().contains(&f)
- || r.comment.to_ascii_lowercase().contains(&f)
- || r.group.to_ascii_lowercase().contains(&f)
- })
- .collect();
- egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
- let favs: Vec<&Row> = visible.iter().copied().filter(|r| r.favorite).collect();
- if !favs.is_empty() {
- section(ui, &t, "Favorites");
- table(app, ui, &mut d, &favs, "fav");
+ if ui.button("Import…").on_hover_text(crate::i18n::tr_label("CSV or JSON: updates existing parameters, adds new ones")).clicked() {
+ app.pick_open_command("parameters.import", json!({}), &[]);
+ }
+ for (label, ext) in [("Export CSV…", "csv"), ("Export JSON…", "json")] {
+ if ui.button(label).clicked() {
+ app.pick_save_command(&format!("parameters.{ext}"), &[ext], "parameters.export", json!({"format": ext}));
}
- section(ui, &t, "User Parameters");
- let users: Vec<&Row> = visible.iter().copied().filter(|r| r.source == "user").collect();
- table(app, ui, &mut d, &users, "user");
- section(ui, &t, "Model Parameters");
- let mut groups: Vec<String> = Vec::new();
- for r in visible.iter().filter(|r| r.source != "user") {
- if !groups.contains(&r.group) {
- groups.push(r.group.clone());
- }
+ }
+ });
+ if let Some(e) = &d.error {
+ ui.label(RichText::new(e).color(t.error));
+ }
+ ui.separator();
+ let f = d.filter.to_ascii_lowercase();
+ let visible: Vec<&Row> = all
+ .iter()
+ .filter(|r| {
+ f.is_empty()
+ || r.name.to_ascii_lowercase().contains(&f)
+ || r.comment.to_ascii_lowercase().contains(&f)
+ || r.group.to_ascii_lowercase().contains(&f)
+ })
+ .collect();
+ egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
+ let favs: Vec<&Row> = visible.iter().copied().filter(|r| r.favorite).collect();
+ if !favs.is_empty() {
+ section(ui, &t, "Favorites");
+ table(app, ui, &mut d, &favs, "fav");
+ }
+ section(ui, &t, "User Parameters");
+ let users: Vec<&Row> = visible.iter().copied().filter(|r| r.source == "user").collect();
+ table(app, ui, &mut d, &users, "user");
+ section(ui, &t, "Model Parameters");
+ let mut groups: Vec<String> = Vec::new();
+ for r in visible.iter().filter(|r| r.source != "user") {
+ if !groups.contains(&r.group) {
+ groups.push(r.group.clone());
}
- for g in groups {
- let members: Vec<&Row> = visible.iter().copied().filter(|r| r.source != "user" && r.group == g).collect();
- egui::CollapsingHeader::new(RichText::new(&g).strong()).id_salt(("pgroup", &g)).default_open(true).show(ui, |ui| {
+ }
+ for g in groups {
+ let members: Vec<&Row> = visible.iter().copied().filter(|r| r.source != "user" && r.group == g).collect();
+ egui::CollapsingHeader::new(RichText::new(&g).semibold().color(crate::theme::Tokens::get().text))
+ .id_salt(("pgroup", &g))
+ .default_open(true)
+ .show(ui, |ui| {
table(app, ui, &mut d, &members, &g);
});
- }
- });
+ }
});
+ });
// The title bar's close button, for scenarios and demos.
if let Some(r) = ctx.memory(|m| m.area_rect(egui::Id::new("sc_params_dialog"))) {
crate::scenario::publish_handle("params:close", egui::pos2(r.right() - 16.0, r.top() + 15.0));
@@ -220,7 +231,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
fn section(ui: &mut egui::Ui, t: &Tokens, title: &str) {
ui.add_space(6.0);
- ui.label(RichText::new(title).strong().color(t.text));
+ ui.label(RichText::new(title).semibold().color(t.text));
}
/// Live check of an expression typed for a parameter of this unit: Ok(shown value) or the message.
@@ -602,7 +613,7 @@ mod tests {
assert_eq!(word_before("width + 1", 5), (0, "width".to_string()));
assert_eq!(word_before("1 + ", 4), (4, String::new()));
assert_eq!(word_before("ü", 9), (0, "ü".to_string()));
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
let _ = app.run("parameters.add", json!({"name": "width", "expression": "40 mm"}));
publish(&mut app, &ctx);
diff --git a/crates/ui-egui/src/plugins.rs b/crates/ui-egui/src/plugins.rs
index 7a42066f57..4d9bf4440a 100644
--- a/crates/ui-egui/src/plugins.rs
+++ b/crates/ui-egui/src/plugins.rs
@@ -141,7 +141,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
return;
};
let path = dir.display().to_string();
- ui.add(egui::Label::new(RichText::new(crate::i18n::format("ui.plugins_note", &[("path", &path)])).size(11.0).color(t.text_dim)).wrap());
+ ui.add(egui::Label::new(RichText::new(crate::i18n::format("ui.plugins_note", &[("path", &path)])).size(t.font_small).color(t.text_dim)).wrap());
ui.add_space(8.0);
if ui.button(crate::i18n::tr_label("Show in folder")).clicked() {
// `show_in_folder` opens the parent of the path it is given, so the argument is a name
@@ -171,9 +171,11 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
}
ui.vertical(|ui| {
ui.label(RichText::new(&plugin.name).strong());
- ui.label(RichText::new(crate::i18n::format("ui.plugins_version", &[("version", &plugin.version)])).size(11.0).color(t.text_dim));
+ ui.label(
+ RichText::new(crate::i18n::format("ui.plugins_version", &[("version", &plugin.version)])).size(t.font_small).color(t.text_dim),
+ );
if !plugin.description.is_empty() {
- ui.label(RichText::new(&plugin.description).size(11.0).color(t.text_dim));
+ ui.label(RichText::new(&plugin.description).size(t.font_small).color(t.text_dim));
}
});
});
@@ -181,10 +183,12 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {
}
if !skipped.is_empty() {
ui.add_space(6.0);
- ui.label(RichText::new(crate::i18n::format("ui.plugins_skipped", &[("count", &skipped.len().to_string())])).size(11.0).color(t.text_dim));
+ ui.label(
+ RichText::new(crate::i18n::format("ui.plugins_skipped", &[("count", &skipped.len().to_string())])).size(t.font_small).color(t.text_dim),
+ );
for skip in skipped.iter().take(8) {
let who = if skip.folder.is_empty() { "folder" } else { skip.folder.as_str() };
- ui.label(RichText::new(format!("{who}: {}", skip.reason)).size(11.0).color(t.text_dim));
+ ui.label(RichText::new(format!("{who}: {}", skip.reason)).size(t.font_small).color(t.text_dim));
}
}
}
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index bf13c61406..c54a302fab 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -8,6 +8,7 @@
//! Apply keeps them and stays open, and Restore Defaults resets the page shown. Everything is
//! kept between runs, except anti-aliasing, which needs a restart.
+use crate::fonts::RichTextExt as _;
use egui::{Modifiers, Pos2, RichText};
use serde::{Deserialize, Serialize};
use serde_json::json;
@@ -1136,7 +1137,12 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
ui_body.separator();
ui_body.vertical(|ui| {
ui.set_width(ui.available_width());
- ui.label(RichText::new(app.tr_label(PAGES.get(app.prefs_window.section).copied().unwrap_or_default())).strong().size(14.0));
+ ui.label(
+ RichText::new(app.tr_label(PAGES.get(app.prefs_window.section).copied().unwrap_or_default()))
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_heading),
+ );
ui.add_space(6.0);
if app.prefs_window.section == PAGE_SHORTCUTS {
// The shortcuts table scrolls by itself.
@@ -1223,7 +1229,7 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
let note = |ui: &mut egui::Ui, s: &str| {
ui.label("");
// Descriptions wrap within the page instead of widening it.
- ui.add(egui::Label::new(RichText::new(s).size(11.0).color(t.text_dim)).wrap());
+ ui.add(egui::Label::new(RichText::new(s).size(crate::theme::Tokens::get().font_small).color(t.text_dim)).wrap());
ui.end_row();
};
if app.prefs_window.section == PAGE_SHORTCUTS {
@@ -1505,7 +1511,7 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
// Keep accessibility controls visible before the longer rendering-quality controls.
ui.label("");
ui.end_row();
- ui.label(RichText::new(app.tr("ui.colour_vision")).strong());
+ ui.label(RichText::new(app.tr("ui.colour_vision")).semibold().color(crate::theme::Tokens::get().text));
ui.label("");
ui.end_row();
ui.label(app.tr("ui.colour_vision_mode"));
@@ -1704,7 +1710,7 @@ fn colour_vision_sample(ui: &mut egui::Ui, t: &Tokens) {
cell.center_bottom() + egui::vec2(0.0, 3.0),
egui::Align2::CENTER_TOP,
crate::i18n::tr(name),
- egui::FontId::proportional(11.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_small),
t.text_dim,
);
}
@@ -2506,7 +2512,7 @@ mod tests {
// File and Help › Keyboard Shortcuts open the same dialog at its page.
app.keymap.open = true;
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut out = ctx.run_ui(Default::default(), |ui| show(&mut app, ui.ctx()));
out.textures_delta.clear();
assert!(app.prefs_window.open && app.prefs_window.section == PAGE_SHORTCUTS && !app.keymap.open);
@@ -2657,7 +2663,7 @@ mod tests {
fn up_axis_preference_turns_the_view() {
use solidcraft_engine::render::UpAxis;
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
apply(&mut app, &ctx);
assert_eq!(app.cam.up, UpAxis::Z);
app.preferences.up_axis = "y".into();
diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs
index 1ae3c38120..1feb8008e5 100644
--- a/crates/ui-egui/src/preselect_tests.rs
+++ b/crates/ui-egui/src/preselect_tests.rs
@@ -1322,9 +1322,13 @@ fn thread_choices_can_start_without_a_face_and_recover_from_invalid_text() {
h.step(&json!({"text":"Munknown"})).unwrap();
h.frames(2);
assert!(matches!(&h.app.dialog.as_ref().unwrap().kind, Kind::Thread { designation, .. } if designation == "Munknown"));
- for handle in ["dialog:Size", "dialog:Size:8 mm"] {
- h.step(&json!({"click":{"handle":handle}})).unwrap();
- }
+ h.step(&json!({"click":{"handle":"dialog:Size"}})).unwrap();
+ // Plex's taller rows put 8 mm below the first page of this long popup. Scroll the
+ // visible list before clicking its choice, as a person would, rather than a clipped handle.
+ let first = crate::scenario::handle_at("dialog:Size:1.6 mm").unwrap();
+ h.call("ui.scroll", json!({"x":first.x,"y":first.y,"delta":-60}));
+ h.frames(12);
+ h.step(&json!({"click":{"handle":"dialog:Size:8 mm"}})).unwrap();
assert!(matches!(&h.app.dialog.as_ref().unwrap().kind, Kind::Thread { designation, .. } if designation == "M8x1.25"));
assert!(apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).is_err(), "a face is still required");
}
@@ -1421,7 +1425,7 @@ fn boundary_fill_finds_the_cells_and_fills_the_ticked_ones() {
d.inputs[0].items = vec![Sel::Body { name: "Body1".into() }, Sel::Body { name: "Body2".into() }];
app.dialog = Some(d);
// The dialog finds the cells on its next frame.
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
ctx.run_ui(Default::default(), |ui| crate::dialogs::show(&mut app, ui.ctx())).textures_delta.clear();
let mut d = app.dialog.take().unwrap();
let Kind::BoundaryFill { cells, .. } = &mut d.kind else { panic!() };
diff --git a/crates/ui-egui/src/preview.rs b/crates/ui-egui/src/preview.rs
index eb50792536..4ff42d0f42 100644
--- a/crates/ui-egui/src/preview.rs
+++ b/crates/ui-egui/src/preview.rs
@@ -306,7 +306,7 @@ fn stream_key(cmds: &[(String, Value)], revision: u64, colors: Colors) -> Option
/// Keep the preview in step with the open dialog: start a computation when its inputs changed,
/// take finished results. Called once per frame.
pub fn update(app: &mut SolveApp, ctx: &egui::Context) {
- let cmds = match app.dialog.as_ref().filter(|d| d.previews()).map(|d| crate::dialogs::preview_commands(app, d)) {
+ let cmds = match app.dialog.as_ref().filter(|d| d.previews() && d.preview_enabled).map(|d| crate::dialogs::preview_commands(app, d)) {
Some(Ok(c)) if !c.is_empty() => c,
_ if crate::sketch_attachment_ui::commands(app).is_some() => crate::sketch_attachment_ui::commands(app).unwrap_or_default(),
// A parameter being edited in Change Parameters.
diff --git a/crates/ui-egui/src/primitive_units_tests.rs b/crates/ui-egui/src/primitive_units_tests.rs
index 7de003a38c..c3a190d267 100644
--- a/crates/ui-egui/src/primitive_units_tests.rs
+++ b/crates/ui-egui/src/primitive_units_tests.rs
@@ -39,7 +39,11 @@ fn fields(h: &Harness) -> Vec<(&'static str, String)> {
/// Every field shows its text in its row, as a person sees it.
fn assert_shown(h: &Harness, fields: &[(&str, String)]) {
for (label, text) in fields {
- assert!(h.widget_near(text, label).is_some(), "the {label} row shows {text:?}");
+ let nodes = &h.output.accesskit_update.as_ref().unwrap().nodes;
+ assert!(
+ nodes.iter().any(|(_, n)| n.role() == egui::accesskit::Role::TextInput && n.label() == Some(*label) && n.value() == Some(text)),
+ "the {label} editor shows {text:?}"
+ );
}
}
diff --git a/crates/ui-egui/src/recovery_ui.rs b/crates/ui-egui/src/recovery_ui.rs
index dfd3e813a7..9780d1fcbd 100644
--- a/crates/ui-egui/src/recovery_ui.rs
+++ b/crates/ui-egui/src/recovery_ui.rs
@@ -1,5 +1,6 @@
//! Autosave ticks and the "Recover unsaved design?" window shown at launch.
+use crate::fonts::RichTextExt as _;
use egui::RichText;
use serde_json::json;
use solidcraft_engine::recovery::{self, Autosaver, Entry};
@@ -57,34 +58,41 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let dir = app.autosave.as_ref().map(|a| a.dir.clone()).or_else(recovery::default_dir);
let mut act: Option<(Entry, bool)> = None;
let mut later = false;
- crate::frame::window(ctx, RichText::new(crate::i18n::tr_label("Recover unsaved design?")).strong().size(13.0), crate::frame::Width::Normal)
- .collapsible(false)
- .resizable(false)
- .min_width(420.0)
- .anchor(egui::Align2::CENTER_CENTER, egui::vec2(0.0, 0.0))
- .show(ctx, |ui| {
- ui.label(crate::i18n::tr_label("SolidCraft closed before these designs were saved. Their last autosave can be opened."));
- ui.add_space(6.0);
- for e in app.recoverable.iter().take(20) {
- ui.label(RichText::new(&e.name).strong());
- let file = e.path.clone().unwrap_or_else(|| "never saved".into());
- ui.label(RichText::new(format!("{file} · {} features · autosaved {}", e.features, ago(e.saved_at))).small().weak());
- ui.horizontal(|ui| {
- if ui.button(crate::i18n::tr_label("Recover")).clicked() {
- act = Some((e.clone(), true));
- }
- if ui.button(crate::i18n::tr_label("Discard")).clicked() {
- act = Some((e.clone(), false));
- }
- });
- ui.separator();
- }
+ crate::frame::window(
+ ctx,
+ RichText::new(crate::i18n::tr_label("Recover unsaved design?"))
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_button),
+ crate::frame::Width::Normal,
+ )
+ .collapsible(false)
+ .resizable(false)
+ .min_width(420.0)
+ .anchor(egui::Align2::CENTER_CENTER, egui::vec2(0.0, 0.0))
+ .show(ctx, |ui| {
+ ui.label(crate::i18n::tr_label("SolidCraft closed before these designs were saved. Their last autosave can be opened."));
+ ui.add_space(6.0);
+ for e in app.recoverable.iter().take(20) {
+ ui.label(RichText::new(&e.name).semibold().color(crate::theme::Tokens::get().text));
+ let file = e.path.clone().unwrap_or_else(|| "never saved".into());
+ ui.label(RichText::new(format!("{file} · {} features · autosaved {}", e.features, ago(e.saved_at))).small().weak());
ui.horizontal(|ui| {
- if ui.button(crate::i18n::tr_label("Later")).on_hover_text("Keep them; ask again next launch").clicked() {
- later = true;
+ if ui.button(crate::i18n::tr_label("Recover")).clicked() {
+ act = Some((e.clone(), true));
+ }
+ if ui.button(crate::i18n::tr_label("Discard")).clicked() {
+ act = Some((e.clone(), false));
}
});
+ ui.separator();
+ }
+ ui.horizontal(|ui| {
+ if ui.button(crate::i18n::tr_label("Later")).on_hover_text("Keep them; ask again next launch").clicked() {
+ later = true;
+ }
});
+ });
let dir_s = dir.map(|d| d.to_string_lossy().to_string());
if let Some((e, recover)) = act {
app.recoverable.retain(|x| x.id != e.id);
diff --git a/crates/ui-egui/src/render_workspace.rs b/crates/ui-egui/src/render_workspace.rs
index df32b0816d..481081c4ff 100644
--- a/crates/ui-egui/src/render_workspace.rs
+++ b/crates/ui-egui/src/render_workspace.rs
@@ -549,7 +549,13 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
Ok(())
})();
if let Err(error) = result {
- ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, error, egui::FontId::proportional(14.0), Tokens::get().text);
+ ui.painter().text(
+ rect.center(),
+ egui::Align2::CENTER_CENTER,
+ error,
+ egui::FontId::proportional(crate::theme::Tokens::get().font_heading),
+ Tokens::get().text,
+ );
}
crate::viewport::axis_view(app, ui, rect);
}
diff --git a/crates/ui-egui/src/render_workspace_tests.rs b/crates/ui-egui/src/render_workspace_tests.rs
index 4c53f21602..9d635854ad 100644
--- a/crates/ui-egui/src/render_workspace_tests.rs
+++ b/crates/ui-egui/src/render_workspace_tests.rs
@@ -356,7 +356,7 @@ fn delayed_image_export_holds_its_document_without_changing_history() {
let path = h.dir.join("delayed.png");
let doc = h.app.session.doc.clone();
let undo = h.app.session.undo.len();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
export_image(&mut h.app, job, false);
@@ -384,7 +384,7 @@ fn delayed_image_export_cancel_and_overwrite_choice_preserve_existing_files() {
let path = h.dir.join("existing.png");
std::fs::write(&path, b"existing contents").unwrap();
let doc = h.app.session.doc.clone();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
export_image(&mut h.app, job, false);
@@ -409,7 +409,7 @@ fn delayed_image_export_never_substitutes_a_newer_retained_image() {
use crate::picker_test_support::{Slot, save};
let (mut h, job) = async_export_fixture();
let path = h.dir.join("old-image.png");
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
export_image(&mut h.app, job, false);
@@ -431,7 +431,7 @@ fn delayed_image_export_holds_close_and_new_document_until_cancel() {
use crate::picker_test_support::{Slot, save};
let (mut h, job) = async_export_fixture();
let path = h.dir.join("closed.png");
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let slot: Slot = Default::default();
save(&mut h.app, &slot);
export_image(&mut h.app, job, false);
@@ -463,7 +463,7 @@ fn delayed_image_export_refuses_an_internally_replaced_document_even_with_overwr
let changed = h.app.session.doc.clone();
let history = (h.app.session.undo.len(), h.app.session.revision);
*slot.borrow_mut() = Some(Some(path.to_string_lossy().into_owned()));
- crate::file_picker::tick(&mut h.app, &egui::Context::default());
+ crate::file_picker::tick(&mut h.app, &crate::fonts::test_context());
assert_eq!(std::fs::read(path).unwrap(), b"keep this file");
assert!(Arc::ptr_eq(&changed, &h.app.session.doc));
assert_eq!((h.app.session.undo.len(), h.app.session.revision), history);
@@ -521,7 +521,7 @@ fn render_preview_navigates_like_the_modelling_viewport_in_every_preset() {
let arounds = [crate::prefs::OrbitAround::ViewCentre, crate::prefs::OrbitAround::Cursor, crate::prefs::OrbitAround::Origin];
for preset in crate::prefs::NAV_PRESETS.iter().map(|p| p.id) {
for around in arounds {
- let (design_ctx, render_ctx) = (egui::Context::default(), egui::Context::default());
+ let (design_ctx, render_ctx) = (crate::fonts::test_context(), crate::fonts::test_context());
let mut design = nav_app(false, preset, around);
let mut render = nav_app(true, preset, around);
let (mut design_time, mut render_time) = (0.0, 0.0);
diff --git a/crates/ui-egui/src/revolve_edit_tests.rs b/crates/ui-egui/src/revolve_edit_tests.rs
index 7a82ba9969..1f939fcd0a 100644
--- a/crates/ui-egui/src/revolve_edit_tests.rs
+++ b/crates/ui-egui/src/revolve_edit_tests.rs
@@ -127,7 +127,7 @@ fn second_active_occurrence_noop_preserves_definition_axis_target_and_instances(
let placed = preview.after.bodies.iter().find(|body| body.mesh().bounds().center().x > 50.0).unwrap();
assert!(placed.mesh().triangles.len() > 10);
assert_eq!(placed.mesh().bounds(), before.iter().find(|(_, bounds)| bounds.center().x > 50.0).unwrap().1);
- assert!(h.widget("↖ Custom Axis").is_some());
+ assert_eq!(crate::scenario::count_of("dialog:selection:Axis:filled"), Some(1.0), "the stored custom axis stays selected");
// In the floating shell the read-only Sweep badge overlaps OK at this placement.
// It must not intercept the dialog's click or leave the timeline rolled back.
h.step(&json!({"widget":"OK"})).unwrap();
diff --git a/crates/ui-egui/src/revolve_manipulator_tests.rs b/crates/ui-egui/src/revolve_manipulator_tests.rs
index 1b8c85ad8d..a9d493af2e 100644
--- a/crates/ui-egui/src/revolve_manipulator_tests.rs
+++ b/crates/ui-egui/src/revolve_manipulator_tests.rs
@@ -162,7 +162,7 @@ fn selected_second_placement_custom_axis_handle_and_preview_stay_in_its_frame()
_ => panic!("revolve"),
};
open(&mut h);
- assert!(h.widget("↖ Custom Axis").is_some());
+ assert_eq!(crate::scenario::count_of("dialog:selection:Axis:filled"), Some(1.0), "the stored custom axis stays selected");
handle_at(&mut h, "revolve", world(90.0));
h.step(&json!({"drag":[{"handle":"revolve"},{"world":world(60.0)}]})).unwrap();
let commands = crate::dialogs::apply_commands(&h.app, h.app.dialog.as_ref().unwrap()).unwrap();
diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs
index 6a002fa820..238ea47574 100644
--- a/crates/ui-egui/src/scenario.rs
+++ b/crates/ui-egui/src/scenario.rs
@@ -160,7 +160,11 @@ impl Harness {
pub fn new() -> Harness {
let mut h = Harness {
app: SolveApp::new(Session::default(), Services::default()),
- ctx: egui::Context::default(),
+ ctx: {
+ let ctx = egui::Context::default();
+ crate::fonts::setup_bundled_fonts(&ctx);
+ ctx
+ },
output: Default::default(),
dir: scratch_dir(),
next_file: Rc::new(RefCell::new(None)),
@@ -517,6 +521,7 @@ impl Harness {
}
drop(old);
self.ctx = egui::Context::default();
+ crate::fonts::setup_bundled_fonts(&self.ctx);
self.ctx.enable_accesskit();
self.install();
self.start_autosave();
@@ -780,7 +785,8 @@ pub fn check(h: &mut Harness, e: &Value) -> Result<(), String> {
if r.width() < lo - 0.5 || r.width() > hi + 0.5 {
return Err(format!("dialog width {:.0}, want {lo}..{hi}", r.width()));
}
- if (r.right() - vp.right()).abs() > 2.0 || r.top() < vp.top() || r.bottom() > vp.bottom() + 1.0 {
+ let clearance = if rect_of("dialog:header").is_some() { crate::theme::Tokens::get().space_8 } else { 0.0 };
+ if (r.right() - (vp.right() - clearance)).abs() > 0.5 || r.top() < vp.top() || r.bottom() > vp.bottom() + 1.0 {
return Err(format!("dialog {r:?} is not docked right inside the viewport {vp:?}"));
}
}
diff --git a/crates/ui-egui/src/select_other.rs b/crates/ui-egui/src/select_other.rs
index 210ec85918..bc34d93768 100644
--- a/crates/ui-egui/src/select_other.rs
+++ b/crates/ui-egui/src/select_other.rs
@@ -524,7 +524,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let (r, _) = ui.allocate_exact_size(vec2(w, 20.0), Sense::hover());
let title = crate::i18n::tr_label("Select Other").to_uppercase();
let title = if p.total > p.rows.len() { format!("{title} · {} / {}", p.rows.len(), p.total) } else { title };
- ui.painter().text(pos2(r.left() + 8.0, r.center().y), Align2::LEFT_CENTER, title, FontId::proportional(10.5), t.text_dim);
+ ui.painter().text(
+ pos2(r.left() + 8.0, r.center().y),
+ Align2::LEFT_CENTER,
+ title,
+ FontId::proportional(crate::theme::Tokens::get().font_panel),
+ t.text_dim,
+ );
egui::ScrollArea::vertical().max_height(360.0).show(ui, |ui| {
for (i, row) in p.rows.iter().enumerate() {
let (r, resp) = ui.allocate_exact_size(vec2(w, 24.0), Sense::click());
@@ -541,7 +547,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
t.icon_fill,
t.accent,
);
- ui.painter().text(pos2(r.left() + 32.0, r.center().y), Align2::LEFT_CENTER, &row.label, FontId::proportional(13.0), t.text);
+ ui.painter().text(
+ pos2(r.left() + 32.0, r.center().y),
+ Align2::LEFT_CENTER,
+ &row.label,
+ FontId::proportional(crate::theme::Tokens::get().font_button),
+ t.text,
+ );
if resp.clicked() {
picked = Some(i);
}
diff --git a/crates/ui-egui/src/shell.rs b/crates/ui-egui/src/shell.rs
index 56753ceb31..42a8771ec7 100644
--- a/crates/ui-egui/src/shell.rs
+++ b/crates/ui-egui/src/shell.rs
@@ -93,7 +93,7 @@ pub(crate) fn covered_rects(app: &SolveApp) -> Vec<Rect> {
}
rects.extend(app.shell.browser.filter(|_| app.ui.show_browser));
rects.extend(app.viewport.palette_rect.filter(|_| app.session.active_sketch.is_some()));
- rects.extend(app.viewport.dialog_rect.filter(|_| app.dialog.is_some()));
+ rects.extend(app.viewport.dialog_rect.filter(|_| app.dialog.is_some() || app.tree.redefine.is_some()));
rects.retain(|r| r.is_finite() && r.is_positive());
rects
}
diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rs
index 0705d22299..aa9d52349c 100644
--- a/crates/ui-egui/src/shell_tests.rs
+++ b/crates/ui-egui/src/shell_tests.rs
@@ -106,7 +106,7 @@ fn floating_sketch_palette_and_compass_share_measured_clearance() {
let palette = h.app.viewport.palette_rect.unwrap();
assert!(palette.top() >= layout.axis_view.bottom(), "{style:?} {palette:?} {layout:?}");
assert!(layout.viewport.expand(1.0).contains_rect(palette), "{palette:?} {layout:?}");
- assert!(palette.contains(crate::scenario::handle_at("sketch_palette:finish").unwrap()));
+ assert!(palette.contains(crate::scenario::handle_at("sketch_palette:look_at").unwrap()));
let proj = crate::viewport::projection(&h.app, layout.viewport);
for point in [solidcraft_engine::geom::Vec3::ZERO, solidcraft_engine::geom::Vec3::new(20.0, 0.0, 0.0)] {
assert!(layout.drawable.contains(proj.to_screen(point).unwrap()), "{layout:?}");
@@ -154,14 +154,15 @@ fn short_floating_palette_stays_in_viewport() {
if compass.is_positive() {
assert!(palette.top() < compass.bottom(), "short panels reclaim compass space");
}
- let finish = crate::scenario::handle_at("sketch_palette:finish").unwrap();
- if !palette.contains(finish) {
- // Once reclaiming is insufficient, the whole palette must scroll to Finish.
+ let action = crate::scenario::handle_at("sketch_palette:look_at").unwrap();
+ if !palette.contains(action) {
+ // Once reclaiming is insufficient, the whole palette scrolls to its footer.
h.call("ui.scroll", json!({"x":palette.center().x,"y":palette.center().y,"delta":-1200}));
h.frames(20);
}
+ let action = crate::scenario::handle_at("sketch_palette:look_at").unwrap();
+ assert!(palette.contains(action), "footer must be reachable: {style:?}, height={height}, {action:?} in {palette:?}");
let finish = crate::scenario::handle_at("sketch_palette:finish").unwrap();
- assert!(palette.contains(finish), "Finish Sketch must be reachable: {style:?}, height={height}, {finish:?} in {palette:?}");
h.call("ui.click", json!({"x":finish.x,"y":finish.y}));
assert!(h.app.session.active_sketch.is_none(), "Finish Sketch must work after scrolling");
}
diff --git a/crates/ui-egui/src/shortcut_box.rs b/crates/ui-egui/src/shortcut_box.rs
index 8a5763032e..ff2b35ed90 100644
--- a/crates/ui-egui/src/shortcut_box.rs
+++ b/crates/ui-egui/src/shortcut_box.rs
@@ -134,7 +134,7 @@ pub fn search(app: &SolveApp, q: &str) -> Vec<Row> {
/// ("Sketch › Create"). The separator is drawn, centred on the ink of the panel's name: a
/// font's "›", or one centred on the row, sits low beside Japanese or Chinese words.
fn paint_key_and_place(painter: &egui::Painter, at: Pos2, key: &str, place: Option<(&str, &str)>, color: egui::Color32) {
- let font = FontId::proportional(10.5);
+ let font = FontId::proportional(crate::theme::Tokens::get().font_panel);
// One piece of text ending at `x`, centred on the row: its left edge and the middle of its ink.
let piece = |x: f32, text: &str| -> (f32, f32) {
let galley = painter.layout_no_wrap(text.to_string(), font.clone(), color);
@@ -263,7 +263,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
ui.add_space(4.0);
if app.sbox.text.trim().is_empty() && !app.sbox.recent.is_empty() {
- ui.label(egui::RichText::new(crate::i18n::tr_label("RECENT")).size(10.0).color(t.text_dim));
+ ui.label(egui::RichText::new(crate::i18n::tr_label("RECENT")).size(crate::theme::Tokens::get().font_micro).color(t.text_dim));
}
egui::ScrollArea::vertical().max_height(h - 90.0).show(ui, |ui| {
ui.spacing_mut().item_spacing.y = 0.0;
@@ -287,7 +287,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
t.accent,
);
let col = if enabled { t.text } else { t.text_dim };
- ui.painter().text(pos2(r.left() + 30.0, r.center().y), Align2::LEFT_CENTER, label, FontId::proportional(13.0), col);
+ ui.painter().text(
+ pos2(r.left() + 30.0, r.center().y),
+ Align2::LEFT_CENTER,
+ label,
+ FontId::proportional(crate::theme::Tokens::get().font_button),
+ col,
+ );
let key = crate::keymap::effective(app, id).unwrap_or_default();
paint_key_and_place(ui.painter(), pos2(r.right() - 26.0, r.center().y), &key, *place, t.text_dim);
// The pin.
@@ -373,7 +379,7 @@ mod tests {
#[test]
fn the_search_field_asks_for_focus_once_per_opening() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let field = egui::Id::new("sc_sbox_text");
open(&mut app, None);
frame(&mut app, &ctx);
diff --git a/crates/ui-egui/src/sketch3d.rs b/crates/ui-egui/src/sketch3d.rs
index b4ab561d7a..64584420ed 100644
--- a/crates/ui-egui/src/sketch3d.rs
+++ b/crates/ui-egui/src/sketch3d.rs
@@ -209,13 +209,19 @@ pub fn preview(app: &SolveApp, t: &Tool, painter: &egui::Painter, proj: &Proj) -
}
painter.circle_stroke(s, if label == "Plane" { 3.0 } else { 6.0 }, stroke);
if label != "Plane" {
- painter.text(s + vec2(10.0, -14.0), egui::Align2::LEFT_BOTTOM, label, egui::FontId::proportional(10.0), tk.text);
+ painter.text(
+ s + vec2(10.0, -14.0),
+ egui::Align2::LEFT_BOTTOM,
+ label,
+ egui::FontId::proportional(crate::theme::Tokens::get().font_micro),
+ tk.text,
+ );
}
painter.text(
s + vec2(10.0, 10.0),
egui::Align2::LEFT_TOP,
format!("{}, {}, {}", crate::prefs::show_mm(app, h.x, 1), crate::prefs::show_mm(app, h.y, 1), crate::prefs::show_mm(app, h.z, 1)),
- egui::FontId::proportional(11.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_small),
tk.text_dim,
);
}
diff --git a/crates/ui-egui/src/sketch3d_frame_ui_tests.rs b/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
index a89e9aba00..44647131f4 100644
--- a/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
+++ b/crates/ui-egui/src/sketch3d_frame_ui_tests.rs
@@ -138,6 +138,7 @@ fn second_occurrence_drawn_wire_fit_picks_and_world_triad_drag_stay_aligned() {
let sketch = h.app.run("sketch.create", json!({"plane":"XY","name":"Wire"})).unwrap()["sketch"].as_u64().unwrap();
h.app.ui.show_origin = false;
h.settle();
+ h.step(&json!({"click":{"handle":"sketch_palette:options_fold"}})).unwrap();
h.step(&json!({"widget":"3D Sketch"})).unwrap();
assert!(
crate::sketch3d::active(&h.app),
@@ -158,7 +159,9 @@ fn second_occurrence_drawn_wire_fit_picks_and_world_triad_drag_stay_aligned() {
for world in [Vec3::new(17.0, 32.0, 45.0), Vec3::new(17.0, 32.0, 55.0)] {
let [x, y] = h.at(&json!({"world":[world.x,world.y,world.z]})).unwrap();
let proj = crate::viewport::projection(&h.app, h.app.viewport.rect.unwrap());
- let picked = crate::sketch3d::point_at(&h.app, &proj, egui::pos2(x as f32, y as f32));
+ let screen = egui::pos2(x as f32, y as f32);
+ assert!(!crate::scenario::rect_of("toast").is_some_and(|r| r.contains(screen)), "the drawing click must clear the message action");
+ let picked = crate::sketch3d::point_at(&h.app, &proj, screen);
assert!(picked.is_some_and(|(p, _)| p.dist(world) < 1e-5), "world={world:?}, picked={picked:?}, status={:?}", h.app.status);
}
h.step(&json!({"click":{"world":[17,32,45]}})).unwrap();
diff --git a/crates/ui-egui/src/sketch_attachment_ui.rs b/crates/ui-egui/src/sketch_attachment_ui.rs
index 2531790e2f..2a7a7fe2cd 100644
--- a/crates/ui-egui/src/sketch_attachment_ui.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui.rs
@@ -1,6 +1,6 @@
//! Reviewable sketch-plane rebinding. Saved lost planes are repair guides, never model geometry.
-use egui::{Pos2, RichText};
+use egui::RichText;
use serde_json::{Value, json};
use solidcraft_engine::Sel;
use solidcraft_engine::doc::face_anchor::plane_face_anchor;
@@ -9,6 +9,7 @@ use solidcraft_engine::geom::{Plane, Vec3};
use crate::SolveApp;
use crate::theme::Tokens;
+use crate::ui_kit;
#[derive(Clone, Debug)]
pub struct Draft {
@@ -70,6 +71,7 @@ impl Draft {
}
pub fn clear(app: &mut SolveApp) {
+ app.viewport.dialog_rect = None;
app.tree.redefine = None;
app.tree.redefine_draft = None;
}
@@ -120,123 +122,182 @@ fn path_label(app: &SolveApp, path: &[u64]) -> String {
.join(" / ")
}
-pub fn panel(app: &mut SolveApp, ctx: &egui::Context, at: Pos2) {
+pub fn panel(app: &mut SolveApp, ctx: &egui::Context) {
let Some(sketch) = app.tree.redefine else { return };
if app.session.doc.feature(sketch).is_none() {
clear(app);
return;
}
let mut draft = app.tree.redefine_draft.take().filter(|draft| draft.sketch == sketch).unwrap_or_else(|| Draft::new(app, sketch));
+ let _language = crate::i18n::scope(&app.preferences.language);
let status = attachment(app, sketch);
let name = app.session.doc.feature(sketch).map(|feature| feature.name.as_str()).unwrap_or("Sketch");
let selected = app.session.selection.iter().find(|selection| matches!(selection, Sel::Face { .. })).cloned();
- let mut open = true;
let mut apply = false;
let mut cancel = false;
let t = Tokens::get();
- crate::frame::docked(
- format!("Redefine Sketch Plane: {name}"),
- egui::Id::new("sc_redefine"),
- at,
- app.viewport.rect.map(|rect| rect.bottom()).unwrap_or_else(|| ctx.content_rect().bottom()) - at.y - 8.0,
- crate::frame::Width::Normal,
- )
- .open(&mut open)
- .scroll([false, true])
- .show(ctx, |ui| {
- ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
- // The wrapped notes below fill the width anyway, so the band may too.
- let width = ui.available_width();
- crate::frame::heading(ui, crate::frame::Level::Title, width, |ui| ui.strong(format!("Redefine Sketch Plane: {name}")));
- let saved_plane = match &status {
- FaceAttachmentStatus::Healthy { plane, target, path } => {
- ui.label(format!("Attached to {} / {}", target.body, path_label(app, path)));
- Some(*plane)
- }
- FaceAttachmentStatus::Lost { message, repair_plane } => {
- ui.label(RichText::new(crate::i18n::tr_label("Face attachment lost")).color(t.error));
- ui.label(message);
- if repair_plane.is_some() {
- ui.label(crate::i18n::tr_label("The dashed sketch is a saved plane guide. Select a new face to repair the attachment."));
- } else {
- ui.label(crate::i18n::tr_label("The saved author occurrence is missing. Select a valid author placement before rebinding."));
+ let viewport = crate::shell::content_rect(app, app.viewport.rect.unwrap_or_else(|| ctx.content_rect()));
+ if !viewport.is_finite() || !viewport.is_positive() {
+ app.tree.redefine_draft = Some(draft);
+ return;
+ }
+ let side = if crate::sketch_palette::editing(app) && crate::sketch_palette::fits_beside_a_dialog(app, ctx) {
+ crate::frame::Side::Left
+ } else {
+ crate::frame::Side::Right
+ };
+ let top = crate::shell::panel_top(app, viewport, viewport.bottom(), side);
+ let docked = egui::pos2(side.anchor_x(viewport), top);
+ let moved = crate::frame::dock_offset(ctx, "sc_redefine");
+ let anchor = crate::frame::offset_anchor(docked, moved, viewport, side);
+ let frame = ui_kit::Panel::feature_frame(ctx, app.ui.layout, side);
+ let spec = solidcraft_engine::find_command("sketch.redefine");
+ let command = spec.as_ref().map_or("", |s| crate::i18n::tr_label(s.label));
+ let title = crate::i18n::format("sketch_panel.redefine_title", &[("command", command), ("name", name)]);
+ let panel = ui_kit::Panel::new(&title, egui::Id::new("sc_redefine"), anchor, viewport, side, frame);
+ let response = panel.window().show(ctx, |ui| {
+ let (closed, action) = panel.feature(
+ ui,
+ ui_kit::FeatureOptions {
+ icon: spec.as_ref().map_or("", |s| s.icon),
+ title: &title,
+ drag_key: "sc_redefine",
+ moved,
+ docked,
+ apply_label: None,
+ },
+ false,
+ draft.candidate.is_some() && app.preview.error.is_none(),
+ |ui| {
+ ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
+ ui_kit::hint(
+ ui,
+ "tool",
+ crate::i18n::tr_label("Choose a new plane. Sketch geometry and dimensions stay unchanged in its two-dimensional coordinates."),
+ );
+ let saved_plane = match &status {
+ FaceAttachmentStatus::Healthy { plane, target, path } => {
+ ui_kit::row(ui, "Attachment", |ui| {
+ ui.label(crate::i18n::format("sketch_panel.attached", &[("body", &target.body), ("path", &path_label(app, path))]));
+ });
+ Some(*plane)
+ }
+ FaceAttachmentStatus::Lost { message, repair_plane } => {
+ ui.label(RichText::new(crate::i18n::tr_label("Face attachment lost")).color(t.error));
+ ui.label(message);
+ if repair_plane.is_some() {
+ ui.label(crate::i18n::tr_label("The dashed sketch is a saved plane guide. Select a new face to repair the attachment."));
+ } else {
+ ui.label(crate::i18n::tr_label(
+ "The saved author occurrence is missing. Select a valid author placement before rebinding.",
+ ));
+ }
+ *repair_plane
+ }
+ FaceAttachmentStatus::Legacy { plane } => {
+ ui.label(crate::i18n::tr_label("Legacy face attachment. Rebinding to a certified face creates an exact attachment."));
+ *plane
+ }
+ FaceAttachmentStatus::Sheet { plane } => {
+ ui.label(crate::i18n::tr("sketch_panel.sheet_attachment"));
+ *plane
+ }
+ FaceAttachmentStatus::Fixed { plane } => {
+ ui.label(crate::i18n::tr_label("Sketch plane has no body-face attachment."));
+ *plane
+ }
+ };
+ ui_kit::divider(ui, "attachment");
+ if matches!(&status, FaceAttachmentStatus::Lost { repair_plane: None, .. }) {
+ let author = app.session.doc.feature(sketch).map(|feature| feature.component);
+ let available = author == Some(app.session.active_component);
+ if ui
+ .add_enabled_ui(available, |ui| ui_kit::secondary_button(ui, crate::i18n::tr_label("Use active author placement")))
+ .inner
+ .clicked()
+ {
+ draft.author_path = Some(app.session.active_occurrence_path.clone().unwrap_or_default());
+ draft.error = None;
+ }
+ if available && let Some(path) = &draft.author_path {
+ ui.label(crate::i18n::format("sketch_panel.author", &[("path", &path_label(app, path))]));
+ }
}
- *repair_plane
- }
- FaceAttachmentStatus::Legacy { plane } => {
- ui.label(crate::i18n::tr_label("Legacy face attachment. Rebinding to a certified face creates an exact attachment."));
- *plane
- }
- FaceAttachmentStatus::Sheet { plane } => {
- ui.label("Attached to a flat face of a sheet metal body; it follows that panel when the sheet changes.");
- *plane
- }
- FaceAttachmentStatus::Fixed { plane } => {
- ui.label(crate::i18n::tr_label("Sketch plane has no body-face attachment."));
- *plane
- }
- };
- ui.separator();
- if matches!(&status, FaceAttachmentStatus::Lost { repair_plane: None, .. }) {
- let author = app.session.doc.feature(sketch).map(|feature| feature.component);
- let available = author == Some(app.session.active_component);
- if ui.add_enabled(available, egui::Button::new(crate::i18n::tr_label("Use active author placement"))).clicked() {
- draft.author_path = Some(app.session.active_occurrence_path.clone().unwrap_or_default());
- draft.error = None;
- }
- if available && let Some(path) = &draft.author_path {
- ui.label(format!("Author placement: {}", path_label(app, path)));
- }
- }
- ui.label(crate::i18n::tr_label("Choose a new plane. Sketch geometry and dimensions stay unchanged in its two-dimensional coordinates."));
- ui.horizontal_wrapped(|ui| {
- for plane in ["XY", "XZ", "YZ"] {
- if ui.button(format!("Use {plane} plane")).clicked() {
- draft.choose(json!(plane), plane.into());
+ ui_kit::row(ui, "Plane", |ui| {
+ let text = if draft.candidate.is_some() { draft.label.as_str() } else { crate::i18n::tr("dialog.select") };
+ let response = ui_kit::selection_field_state(ui, text, true, draft.candidate.is_some());
+ if response
+ .on_hover_text(crate::i18n::tr_label(
+ "Choose a new plane. Sketch geometry and dimensions stay unchanged in its two-dimensional coordinates.",
+ ))
+ .clicked()
+ && let Some(selection) = &selected
+ && let Some(plane) = face_plane(app, selection)
+ {
+ draft.choose(plane, face_label(app, selection));
+ }
+ });
+ ui.horizontal_wrapped(|ui| {
+ for plane in ["XY", "XZ", "YZ"] {
+ if ui_kit::secondary_button(ui, crate::i18n::format("sketch_panel.use_plane", &[("plane", plane)])).clicked() {
+ draft.choose(json!(plane), plane.into());
+ }
+ }
+ });
+ for feature in &app.session.doc.features {
+ if matches!(feature.kind, FeatureKind::ConstructionPlane { .. }) && ui_kit::secondary_button(ui, &feature.name).clicked() {
+ draft.choose(json!(feature.name), feature.name.clone());
+ }
}
- }
- });
- for feature in &app.session.doc.features {
- if matches!(feature.kind, FeatureKind::ConstructionPlane { .. }) && ui.button(&feature.name).clicked() {
- draft.choose(json!(feature.name), feature.name.clone());
- }
- }
- if ui.add_enabled(selected.is_some(), egui::Button::new(crate::i18n::tr_label("Reattach selected face"))).clicked()
- && let Some(selection @ Sel::Face { .. }) = &selected
- && let Some(plane) = face_plane(app, selection)
- {
- let label = face_label(app, selection);
- draft.choose(plane, label);
- }
- if ui.add_enabled(saved_plane.is_some(), egui::Button::new(crate::i18n::tr_label("Use saved fixed plane"))).clicked()
- && let Some(plane) = saved_plane
- && let Err(error) = draft.choose_saved_fixed(app, plane)
- {
- draft.error = Some(error);
- }
- if ui.add_enabled(selected.is_some(), egui::Button::new(crate::i18n::tr_label("Use selected face as fixed plane"))).clicked()
- && let Some(selection) = &selected
- && let Some(mut plane) = face_plane(app, selection)
- {
- plane["fixed"] = json!(true);
- draft.choose(plane, "Fixed plane: independent of the selected body".into());
- }
- if draft.candidate.is_some() {
- ui.separator();
- ui.label(format!("Preview: {}", draft.label));
- }
- if let Some(error) = draft.error.as_ref().or(app.preview.error.as_ref()) {
- ui.label(RichText::new(error).color(t.error));
- }
- ui.horizontal(|ui| {
- if ui.add_enabled(draft.candidate.is_some() && app.preview.error.is_none(), egui::Button::new("Apply")).clicked() {
- apply = true;
- }
- if ui.button("Cancel").clicked() {
- cancel = true;
- }
- });
+ if ui
+ .add_enabled_ui(selected.is_some(), |ui| ui_kit::secondary_button(ui, crate::i18n::tr_label("Reattach selected face")))
+ .inner
+ .clicked()
+ && let Some(selection @ Sel::Face { .. }) = &selected
+ && let Some(plane) = face_plane(app, selection)
+ {
+ let label = face_label(app, selection);
+ draft.choose(plane, label);
+ }
+ if ui
+ .add_enabled_ui(saved_plane.is_some(), |ui| ui_kit::secondary_button(ui, crate::i18n::tr_label("Use saved fixed plane")))
+ .inner
+ .clicked()
+ && let Some(plane) = saved_plane
+ && let Err(error) = draft.choose_saved_fixed(app, plane)
+ {
+ draft.error = Some(error);
+ }
+ if ui
+ .add_enabled_ui(selected.is_some(), |ui| ui_kit::secondary_button(ui, crate::i18n::tr_label("Use selected face as fixed plane")))
+ .inner
+ .clicked()
+ && let Some(selection) = &selected
+ && let Some(mut plane) = face_plane(app, selection)
+ {
+ plane["fixed"] = json!(true);
+ draft.choose(plane, "Fixed plane: independent of the selected body".into());
+ }
+ if draft.candidate.is_some() {
+ ui_kit::divider(ui, "attachment");
+ ui_kit::row(ui, "Preview", |ui| {
+ ui.label(crate::i18n::tr_label(&draft.label));
+ });
+ }
+ if let Some(error) = draft.error.as_ref().or(app.preview.error.as_ref()) {
+ ui.label(RichText::new(error).color(t.error));
+ }
+ ui_kit::ComputeStatus { text: None, busy: app.preview.busy, applying: false }
+ },
+ );
+ cancel |= closed || action == ui_kit::Action::Cancel;
+ apply |= action == ui_kit::Action::Ok;
});
+ app.viewport.dialog_rect = response.map(|r| r.response.rect);
+ if let Some(rect) = app.viewport.dialog_rect {
+ crate::scenario::publish_rect("dialog:outer", rect);
+ crate::scenario::publish_rect("dialog:card", rect);
+ }
if ctx.input(|input| input.key_pressed(egui::Key::Escape)) {
cancel = true;
app.esc_handled = true;
@@ -249,7 +310,7 @@ pub fn panel(app: &mut SolveApp, ctx: &egui::Context, at: Pos2) {
}
}
}
- if cancel || !open {
+ if cancel {
clear(app);
} else {
app.tree.redefine_draft = Some(draft);
diff --git a/crates/ui-egui/src/sketch_attachment_ui_tests.rs b/crates/ui-egui/src/sketch_attachment_ui_tests.rs
index e63862fcbe..c41a08f5aa 100644
--- a/crates/ui-egui/src/sketch_attachment_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_attachment_ui_tests.rs
@@ -105,7 +105,7 @@ fn lost_attachment_ghost_rebind_preview_cancel_apply_and_undo_preserve_sketch()
h.frames(4);
h.step(&json!({"widget":"Reattach selected face"})).unwrap();
h.frames(8);
- h.step(&json!({"widget":"Apply"})).unwrap();
+ h.step(&json!({"widget":"OK"})).unwrap();
assert!(h.app.tree.redefine.is_none(), "{:?}", h.app.tree.redefine_draft);
assert_eq!(raw_sketch(&h, sketch), raw, "curves, dimensions and expressions remain exact");
assert_eq!(h.app.session.undo.len(), undo + 1);
@@ -320,7 +320,7 @@ fn nested_anchor_saved_fixed_conversion_preserves_rotated_second_author_plane()
assert!(shown.x.dist(expected.x) < 1e-7 && shown.y.dist(expected.y) < 1e-7);
assert_eq!(h.app.session.doc.to_json(), before);
h.frames(6);
- h.step(&json!({"widget":"Apply"})).unwrap();
+ h.step(&json!({"widget":"OK"})).unwrap();
assert!(h.app.tree.redefine.is_none());
assert_eq!(h.app.session.doc.sketch(id).unwrap(), &raw);
assert_eq!(h.app.session.undo.len(), undo + 1);
@@ -370,3 +370,32 @@ fn picked_top_face_of_a_stacked_join_extrude_takes_a_sketch() {
};
assert!((plane.origin.z - 20.).abs() < 1e-9);
}
+
+#[test]
+fn plane_redefinition_uses_dense_card_and_keeps_command_preview_cancel_and_ok() {
+ use crate::scenario;
+ let mut h = Harness::new();
+ let sketch = h.app.run("sketch.create", json!({"plane":"XY"})).unwrap()["sketch"].as_u64().unwrap();
+ h.app.run("sketch.rectangle.two_point", json!({"p0":[10,10],"p1":[30,20]})).unwrap();
+ h.app.finish_sketch();
+ let before = h.app.session.doc.to_json();
+ for apply in [false, true] {
+ crate::browser::redefine_sketch(&mut h.app, sketch);
+ h.frames(5);
+ for rect in ["dialog:header", "dialog:hint:tool", "dialog:field:Plane", "dialog:footer"] {
+ assert!(scenario::rect_of(rect).is_some(), "{rect}");
+ }
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0));
+ h.step(&json!({"widget":"Use XZ plane"})).unwrap();
+ h.frames(3);
+ assert_eq!(crate::sketch_attachment_ui::commands(&h.app).unwrap(), vec![("sketch.redefine".into(), json!({"sketch":sketch,"plane":"XZ"}))]);
+ assert_eq!(h.app.session.doc.to_json(), before, "candidate is scratch preview only");
+ h.step(&json!({"click":{"handle":if apply { "dialog:ok" } else { "dialog:cancel" }}})).unwrap();
+ assert!(h.app.tree.redefine.is_none());
+ if apply {
+ assert_ne!(h.app.session.doc.to_json(), before);
+ h.app.run("edit.undo", json!({})).unwrap();
+ }
+ assert_eq!(h.app.session.doc.to_json(), before);
+ }
+}
diff --git a/crates/ui-egui/src/sketch_drag_ui_tests.rs b/crates/ui-egui/src/sketch_drag_ui_tests.rs
index 517174714c..4a126d3967 100644
--- a/crates/ui-egui/src/sketch_drag_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_drag_ui_tests.rs
@@ -205,9 +205,15 @@ fn a_dragged_line_that_stops_short_stays_under_the_cursor_when_it_can_follow_aga
run(&mut h, "sketch.dimension", json!({"entities": [l], "value": 10}));
}
run(&mut h, "sketch.constraint.horizontal_vertical", json!({"line": "l3"}));
- let grab = screen(&mut h, x + 5.0, y);
- let far = screen(&mut h, x + 11.0, y);
- let back = screen(&mut h, x + 7.0, y);
+ // Dimension text uses the bundled font's actual bounds. Grab an exposed interior point
+ // of the curve so this tests a curve drag rather than dragging an overlapping value label.
+ let grab_offset = [5.0, 6.0, 4.0, 7.0, 3.0]
+ .into_iter()
+ .find(|offset| crate::dim_view::hit_text(screen(&mut h, x + offset, y)).is_none())
+ .expect("an exposed interior point of the line");
+ let grab = screen(&mut h, x + grab_offset, y);
+ let far = screen(&mut h, x + grab_offset + 6.0, y);
+ let back = screen(&mut h, x + grab_offset + 2.0, y);
let mut path = vec![grab];
path.extend(steps(grab, far, 8));
path.extend(steps(far, back, 4));
diff --git a/crates/ui-egui/src/sketch_modify_ui.rs b/crates/ui-egui/src/sketch_modify_ui.rs
index be9644d231..fbd739a86b 100644
--- a/crates/ui-egui/src/sketch_modify_ui.rs
+++ b/crates/ui-egui/src/sketch_modify_ui.rs
@@ -31,9 +31,10 @@ use solidcraft_engine::geom::{Vec2, Vec3};
use solidcraft_engine::sketch::PatternAlignment;
use crate::SolveApp;
-use crate::dialogs::{CHAMFER_TYPES, Dialog, Kind, check, field, icon_choice, pattern_toggle, row_label};
+use crate::dialogs::{CHAMFER_TYPES, Dialog, Kind};
use crate::selection::{AXES, CURVES, SKETCH_POINTS, SelInput};
use crate::tool_modifiers::{Audit, Scope, ToolModifiers};
+use crate::ui_kit;
use crate::viewport::{Hit, Proj};
const SELECT_MANIP: &[Scope] = &[Scope::Selection, Scope::Manipulator, Scope::FeaturePreview];
@@ -303,105 +304,114 @@ pub fn pick_position(d: &mut Dialog, session: &solidcraft_engine::Session, point
true
}
-/// The rows after the inputs; true when Enter was pressed in a field.
+/// Command metadata for the active variant, including an explicitly chosen chamfer type.
+pub(crate) fn command(k: &Mod) -> &'static str {
+ match k {
+ Mod::Scale { .. } => "sketch.scale",
+ Mod::Offset { .. } => "sketch.offset",
+ Mod::Mirror => "sketch.mirror",
+ Mod::Move { .. } => "sketch.move",
+ Mod::PatternRect { .. } => "sketch.pattern.rectangular",
+ Mod::PatternCirc { .. } => "sketch.pattern.circular",
+ Mod::Corner { chamfer: false, .. } => "sketch.fillet",
+ Mod::Corner { ctype: 1, .. } => "sketch.chamfer.two_distance",
+ Mod::Corner { ctype: 2, .. } => "sketch.chamfer.distance_angle",
+ Mod::Corner { .. } => "sketch.chamfer.equal_distance",
+ }
+}
+
+/// Repeatable operations offer Apply for another selection, with the same typed values.
+pub(crate) fn repeatable(k: &Mod) -> bool {
+ matches!(k, Mod::Offset { .. } | Mod::Mirror | Mod::PatternRect { .. } | Mod::PatternCirc { .. })
+}
+
+/// A labelled value row. The value carries its own unit text ("2 mm", "45 deg").
+fn number(ui: &mut egui::Ui, label: &str, value: &mut String) -> bool {
+ ui_kit::row(ui, label, |ui| ui_kit::field(ui, value))
+}
+
+fn icons(ui: &mut egui::Ui, label: &str, labels: &[&'static str], icons: &[&'static str], selected: &mut usize) {
+ ui_kit::row(ui, label, |ui| {
+ let choices: Vec<_> =
+ labels.iter().zip(icons).map(|(key, icon)| ui_kit::IconSegment { key, icon, tip: crate::i18n::tr_label(key).to_string() }).collect();
+ ui_kit::segmented_icons(ui, selected, &choices, &[]);
+ });
+}
+
+fn alignment(ui: &mut egui::Ui, label: &str, alignment: &mut PatternAlignment, reversed: &mut bool) {
+ ui_kit::row(ui, label, |ui| {
+ ui_kit::toggle_icon(ui, label, "Flip direction", reversed, "pattern_flip");
+ let mut centered = *alignment == PatternAlignment::Center;
+ ui_kit::toggle_icon(ui, label, "Center", &mut centered, "pattern_center");
+ *alignment = if centered { PatternAlignment::Center } else { PatternAlignment::Right };
+ });
+}
+
+fn pattern_hint(ui: &mut egui::Ui) {
+ ui_kit::note(
+ ui,
+ "pattern",
+ crate::i18n::tr_label("Counts include the original. Center balances copies; Flip chooses the extra side for even totals."),
+ );
+}
+
+/// Dense rows after the selection inputs; true when an expression field accepts Enter.
pub fn rows(ui: &mut egui::Ui, k: &mut Mod) -> bool {
let mut enter = false;
match k {
- Mod::Scale { factor } => {
- row_label(ui, "Factor");
- enter |= field(ui, factor);
- ui.end_row();
- }
+ Mod::Scale { factor } => enter |= number(ui, "Factor", factor),
Mod::Offset { distance, distance2, mode, chain, flip } => {
- row_label(ui, "Direction");
- icon_choice(ui, &OFFSET_MODES, &OFFSET_MODE_ICONS, mode);
- ui.end_row();
- row_label(ui, "Distance");
- enter |= field(ui, distance);
- ui.end_row();
+ icons(ui, "Direction", &OFFSET_MODES, &OFFSET_MODE_ICONS, mode);
+ enter |= number(ui, "Distance", distance);
if *mode == TWO_SIDES {
- row_label(ui, "Distance 2");
- enter |= field(ui, distance2);
- ui.end_row();
- }
- // Symmetric offsets both sides, so there is no side left for Flip to swap.
- if *mode != SYMMETRIC {
- row_label(ui, "Flip");
- check(ui, flip);
- ui.end_row();
+ enter |= number(ui, "Distance 2", distance2);
}
- row_label(ui, "Chain");
- check(ui, chain);
- ui.end_row();
+ ui_kit::section(ui, "offset_options", "Options", true, |ui| {
+ if *mode != SYMMETRIC {
+ ui_kit::checkbox_grid(ui, &mut [("Flip", flip), ("Chain", chain)], 2);
+ } else {
+ ui_kit::checkbox_grid(ui, &mut [("Chain", chain)], 2);
+ }
+ });
}
- // Mirror has no value of its own: its inputs are the whole window.
Mod::Mirror => {}
Mod::Move { x, y, angle, copy } => {
- row_label(ui, "X Distance");
- enter |= field(ui, x);
- ui.end_row();
- row_label(ui, "Y Distance");
- enter |= field(ui, y);
- ui.end_row();
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
- row_label(ui, "Create Copy");
- check(ui, copy);
- ui.end_row();
+ enter |= ui_kit::value_pair_named(ui, "Position", [x, y], ["X", "Y"], ["X Distance", "Y Distance"]);
+ enter |= number(ui, "Angle", angle);
+ ui_kit::options(ui, "move_options", &mut [("Create Copy", copy)]);
}
- // Its two direction columns include both the reference picks and values.
- Mod::PatternRect { .. } => {}
- Mod::PatternCirc { count, angle, alignment, reversed } => {
- for (label, value) in [("Quantity", count), ("Total angle", angle)] {
- row_label(ui, label);
- enter |= field(ui, value);
- ui.end_row();
+ Mod::PatternRect { count, spacing, count2, spacing2, alignment: a, alignment2, reversed, reversed2 } => {
+ for (key, title, count, spacing, align, reverse, quantity, distance, align_label) in [
+ ("direction1", "Direction 1", count, spacing, a, reversed, "Quantity", "Spacing", "Alignment"),
+ ("direction2", "Direction 2", count2, spacing2, alignment2, reversed2, "Quantity 2", "Spacing 2", "Alignment 2"),
+ ] {
+ ui_kit::section(ui, key, title, true, |ui| {
+ enter |= number(ui, quantity, count);
+ enter |= number(ui, distance, spacing);
+ alignment(ui, align_label, align, reverse);
+ });
}
- row_label(ui, "Alignment");
- ui.horizontal(|ui| {
- pattern_toggle(ui, "Alignment", "Flip direction", "pattern_flip", reversed);
- let mut centered = *alignment == PatternAlignment::Center;
- pattern_toggle(ui, "Alignment", "Center", "pattern_center", &mut centered);
- *alignment = if centered { PatternAlignment::Center } else { PatternAlignment::Right };
- });
- ui.end_row();
- row_label(ui, "");
- ui.add(
- egui::Label::new(
- egui::RichText::new(crate::i18n::tr_label(
- "Counts include the original. Center balances copies; Flip chooses the extra side for even totals.",
- ))
- .small(),
- )
- .wrap(),
- );
- ui.end_row();
+ pattern_hint(ui);
+ }
+ Mod::PatternCirc { count, angle, alignment: a, reversed } => {
+ enter |= number(ui, "Quantity", count);
+ enter |= number(ui, "Total angle", angle);
+ alignment(ui, "Alignment", a, reversed);
+ pattern_hint(ui);
}
Mod::Corner { chamfer, ctype, size, distance2, angle, flip } => {
if *chamfer {
- row_label(ui, "Chamfer Type");
- icon_choice(ui, &CHAMFER_TYPES, &CHAMFER_TYPE_ICONS, ctype);
- ui.end_row();
+ icons(ui, "Chamfer Type", &CHAMFER_TYPES, &CHAMFER_TYPE_ICONS, ctype);
}
- row_label(ui, size_label(*chamfer, *ctype));
- enter |= field(ui, size);
- ui.end_row();
+ enter |= number(ui, size_label(*chamfer, *ctype), size);
if *chamfer && *ctype == 1 {
- row_label(ui, "Distance 2");
- enter |= field(ui, distance2);
- ui.end_row();
+ enter |= number(ui, "Distance 2", distance2);
}
if *chamfer && *ctype == 2 {
- row_label(ui, "Angle");
- enter |= field(ui, angle);
- ui.end_row();
+ enter |= number(ui, "Angle", angle);
}
- // With two equal distances there is nothing to swap.
if *chamfer && *ctype > 0 {
- row_label(ui, "Flip");
- check(ui, flip);
- ui.end_row();
+ ui_kit::options(ui, "corner_options", &mut [("Flip", flip)]);
}
}
}
diff --git a/crates/ui-egui/src/sketch_modify_ui_tests.rs b/crates/ui-egui/src/sketch_modify_ui_tests.rs
index e1bec723cd..8e7276776e 100644
--- a/crates/ui-egui/src/sketch_modify_ui_tests.rs
+++ b/crates/ui-egui/src/sketch_modify_ui_tests.rs
@@ -480,7 +480,7 @@ fn rectangular_pattern_window_opens_instead_of_a_click_tool() {
}
#[test]
-fn rectangular_columns_flip_and_center_independently_and_restore_even_counts_when_editing() {
+fn rectangular_sections_flip_and_center_independently_and_restore_even_counts_when_editing() {
use solidcraft_engine::sketch::PatternAlignment;
let (mut h, id) = open("sketch.pattern.rectangular");
h.app.dialog.as_mut().unwrap().inputs[0].items = vec![Sel::SketchCurve { id }];
@@ -488,8 +488,8 @@ fn rectangular_columns_flip_and_center_independently_and_restore_even_counts_whe
h.settle();
let first = crate::scenario::handle_at("dialog:Spacing").unwrap();
let second = crate::scenario::handle_at("dialog:Spacing 2").unwrap();
- assert!(second.x - first.x > 180.0, "the directions should occupy separate columns: {first:?}, {second:?}");
- assert!((second.y - first.y).abs() < 2.0, "the independent spacing fields should share a row");
+ assert!((second.x - first.x).abs() < 2.0, "the dense direction sections share the same control column: {first:?}, {second:?}");
+ assert!(second.y > first.y, "the independent spacing fields belong to successive direction sections");
for label in ["Alignment", "Alignment 2"] {
let left = crate::scenario::handle_at(&format!("dialog:{label}:Flip direction")).unwrap();
let right = crate::scenario::handle_at(&format!("dialog:{label}:Center")).unwrap();
diff --git a/crates/ui-egui/src/sketch_palette.rs b/crates/ui-egui/src/sketch_palette.rs
index 355ecd7e7b..adb10e82e6 100644
--- a/crates/ui-egui/src/sketch_palette.rs
+++ b/crates/ui-egui/src/sketch_palette.rs
@@ -3,7 +3,7 @@
//! buttons. Options: the line type of the selected curves (normal, construction, centerline),
//! Look At, and the display toggles kept with the sketch (grid, snap, slice, profiles, points,
//! dimensions, constraints, projected geometry, construction geometry, 3D sketch); the sketch's
-//! degrees of freedom; Finish Sketch. Toggles run `sketch.options`, line types
+//! degrees of freedom. Finish Sketch lives in the ribbon Exit group. Toggles run `sketch.options`, line types
//! `sketch.construction` / `sketch.centerline`.
//!
//! The line type is also a drawing mode: with nothing selected, Construction (or X) makes what
@@ -11,51 +11,20 @@
use std::cell::Cell;
-use egui::{Color32, RichText, Stroke, vec2};
use serde_json::{Value, json};
use solidcraft_engine::Sel;
use crate::SolveApp;
-use crate::frame::Level;
use crate::theme::Tokens;
thread_local! {
/// The drawing line type (0 normal, 1 construction, 2 centerline) and the sketch it is for.
static MODE: Cell<(u8, Option<u64>)> = const { Cell::new((0, None)) };
- static FOLDED: Cell<bool> = const { Cell::new(false) };
- static OPTIONS_FOLDED: Cell<bool> = const { Cell::new(false) };
- static FEATURE_FOLDED: Cell<bool> = const { Cell::new(false) };
}
-/// Palette width (logical px).
-const WIDTH: f32 = 236.0;
-
-/// The display toggles: option key and label. Plain nouns throughout, no "Show " prefix: the
-/// checkbox itself already says whether each one is on.
-///
-/// Eight of these pass their English source text directly, like the rest of this file's
-/// `app.tr_label(...)` calls: `Locale::label` looks up a literal English string against every
-/// other English catalog entry to find its id. "Profile" and "Points" cannot do that safely:
-/// both already name something else under that same lookup (`SelInput::new("Profile", ...)` /
-/// `SelInput::new("Points", ...)` in `dialogs.rs`, the Extrude/Sweep/Shell/Loft and
-/// point-selection dialogs' own row labels, and "Profile" is also `context_menu.rs`'s "Show
-/// Profile" / "Hide Profile" action by way of the existing `ui.show_profile` key). Giving the
-/// palette row the same bare text would silently repoint one of those unrelated lookups to
-/// whichever translation this file happens to carry. `ui.palette_profile` and
-/// `ui.palette_points` are dedicated keys instead, carrying exactly "Profile" and "Points" in
-/// English; passing the id itself (`Locale::label` falls back to a direct id lookup when the
-/// text it was given does not match any other entry) reaches them without going through the
-/// shared text lookup at all. See `i18n::tests::id_labels_resolve_to_their_own_translation_not_an_english_fallback`
-/// and `i18n_ui_tests::sketch_palette_profile_and_points_rows_show_their_own_translation` for
-/// proof they resolve to the real translation in German, Japanese and Korean rather than
-/// silently falling back to English.
-///
-/// The id-fallback check still runs the text lookup first: a future English catalog entry
-/// whose value happened to be the literal string "ui.palette_profile" or "ui.palette_points"
-/// would silently steal this lookup (`Locale::label`'s `ids.get(label)` would then match
-/// before the id fallback ever runs). Nobody writes UI copy that looks like a dotted id, so
-/// this is a remote hazard, not a likely one, but it is why these two ids are spelled out here
-/// rather than reused anywhere else.
+/// Option keys and existing localized labels. The five primary design rows are selected below;
+/// the remaining display options live in More. Dedicated point/profile ids avoid collisions
+/// with selection-field translations elsewhere in the UI.
pub const TOGGLES: [(&str, &str); 10] = [
("grid", "Sketch Grid"),
("snap", "Snap"),
@@ -242,8 +211,17 @@ pub fn set_linetype(app: &mut SolveApp, kind: u8) {
}
/// The palette's content width in `vp`; it gives way to the viewport on narrow views.
+/// The line types, in the order of the mode and of the selection flags: key, icon master and name.
+const LINE_TYPES: [(&str, &str, &str); 4] = [
+ ("normal", "normal", "Normal"),
+ ("construction", "construction", "Construction"),
+ ("centerline", "centerline", "Centerline"),
+ ("infinite", "infinite", "Infinite"),
+];
+
fn width(vp: egui::Rect) -> f32 {
- WIDTH.min((vp.width() * 0.46 - 16.0).max(120.0))
+ let t = Tokens::get();
+ t.sketch_palette_width.min((vp.width() * 0.46 - t.space_16).max(t.space_24 * 5.0))
}
/// The viewport the palette docks into.
@@ -266,18 +244,7 @@ pub fn fits_beside_a_dialog(app: &SolveApp, ctx: &egui::Context) -> bool {
/// Is the palette on screen? It stays for as long as a sketch is being edited, a command dialog
/// open or not: the dialog takes the left edge of the viewport and the palette keeps the right.
pub fn visible(app: &SolveApp, ctx: &egui::Context) -> bool {
- editing(app) && (app.dialog.is_none() || fits_beside_a_dialog(app, ctx))
-}
-
-/// A small disclosure triangle for the Options section: pointing right when collapsed, down
-/// when open. Kept separate from the palette's own "−"/"+" fold, which stays a plain glyph.
-fn disclosure_triangle(p: &egui::Painter, c: egui::Pos2, open: bool, col: Color32) {
- let pts = if open {
- vec![egui::pos2(c.x - 4.0, c.y - 2.0), egui::pos2(c.x + 4.0, c.y - 2.0), egui::pos2(c.x, c.y + 3.0)]
- } else {
- vec![egui::pos2(c.x - 2.5, c.y - 4.0), egui::pos2(c.x - 2.5, c.y + 4.0), egui::pos2(c.x + 3.0, c.y)]
- };
- p.add(egui::Shape::convex_polygon(pts, col, Stroke::NONE));
+ editing(app) && ((app.dialog.is_none() && app.tree.redefine.is_none()) || fits_beside_a_dialog(app, ctx))
}
/// The creation family of the tool that is running, and the exact variant it is running, when
@@ -298,77 +265,69 @@ fn active_feature(app: &SolveApp) -> Option<(&'static crate::sketch_families::Fa
(family.commands.len() > 1).then_some((family, id))
}
-/// One row of the Feature Options section: the family's name, then its modes as icon buttons
-/// right-aligned in the same column every other palette row ends at. Five buttons do not fit one
-/// palette-wide row, so the group wraps onto as many rows as it needs.
-fn feature_row(app: &SolveApp, ui: &mut egui::Ui, width: f32, family: &crate::sketch_families::Family, current: &str) -> Option<&'static str> {
- let t = Tokens::get();
- let mut start = None;
- ui.horizontal(|ui| {
- ui.label(app.tr_label(family.label));
- let btn_w = 28.0;
- let btn_h = 22.0;
- let sp = ui.spacing().item_spacing.x;
- let room = (width - ui.min_rect().width() - sp).max(btn_w);
- let fits = ((room + sp) / (btn_w + sp)).floor().clamp(1.0, family.commands.len() as f32) as usize;
- let per_row = fits.max(1);
- let group_w = per_row as f32 * btn_w + per_row.saturating_sub(1) as f32 * sp;
- crate::frame::right_aligned(ui, width, group_w, |ui| {
- ui.vertical(|ui| {
- for chunk in family.commands.chunks(per_row) {
- ui.horizontal(|ui| {
- for spec in chunk.iter().filter_map(|id| solidcraft_engine::find_command(id)) {
- let on = spec.id == current;
- let enabled = spec.info(&app.session).enabled;
- let resp = ui.add_enabled(enabled, egui::Button::new("").selected(on).min_size(vec2(btn_w, btn_h)));
- let side = (resp.rect.width().min(resp.rect.height()) - 4.0).max(12.0);
- let icon_rect = egui::Rect::from_center_size(resp.rect.center(), vec2(side, side));
- let (ink, fill, acc) = if enabled { (t.icon, t.icon_fill, t.accent) } else { (t.border, t.panel_header, t.border) };
- crate::icons::paint(ui.painter(), icon_rect, spec.icon, ink, fill, acc);
- crate::scenario::publish_handle(&format!("sketch_palette:feature:{}", spec.id), resp.rect.center());
- // The button draws an icon and no text of its own, so give a screen
- // reader the command's own name and whether it is the mode in use.
- let label = app.tr_label(spec.label).to_string();
- resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, enabled, on, &label));
- if resp.on_hover_text(app.tr_label(spec.label)).clicked() && enabled {
- start = Some(spec.id);
- }
- }
- });
- }
- });
- });
- });
- start
+fn section_alias(name: &str, title: &str) {
+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:section:{title}")) {
+ crate::scenario::publish_handle(name, at);
+ }
+}
+
+/// Count the sketch's independent input coordinates and radii before constraints. The solver
+/// stores remaining DOF but no total: fixed/projected inputs are constants, not free variables.
+/// Arc endpoints already supply their radii through coordinates, as in the solver's layout.
+fn unconstrained_total(sketch: &solidcraft_engine::sketch::Sketch) -> usize {
+ let coordinates = sketch.points.iter().filter(|p| !p.fixed && p.link.is_none()).count().saturating_mul(2);
+ let radii = sketch
+ .curves
+ .iter()
+ .filter(|c| {
+ !c.fixed
+ && c.link.is_none()
+ && matches!(c.kind, solidcraft_engine::sketch::CurveKind::Circle { .. } | solidcraft_engine::sketch::CurveKind::Ellipse { .. })
+ })
+ .count();
+ coordinates.saturating_add(radii)
+}
+
+fn constrained_fraction(remaining: usize, total: usize, solved: bool) -> f32 {
+ if !solved {
+ 0.0
+ } else if total == 0 {
+ if remaining == 0 { 1.0 } else { 0.0 }
+ } else {
+ 1.0 - remaining.min(total) as f32 / total as f32
+ }
}
-/// Draw the palette (while a sketch is being edited).
+/// Draw the sketch options card, retaining the command paths used by the original palette.
pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
app.viewport.palette_rect = None;
let _language = crate::i18n::scope(&app.preferences.language);
if !visible(app, ctx) {
return;
}
- let (opts, dof_line, ok, open_ends, untied_ends) = {
+ let (opts, name, remaining, solved, total, geometry, open_ends, untied_ends) = {
let st = app.session.world_state();
let Some(ss) = app.session.active_sketch.and_then(|s| st.sketch(s)) else { return };
(
ss.sketch.view.clone(),
- dof_text(ss.report.dof, ss.report.ok(), has_geometry(&ss.sketch)),
- ss.report.ok() && ss.report.dof == 0 && has_geometry(&ss.sketch),
+ ss.name.clone(),
+ ss.report.dof,
+ ss.report.ok(),
+ unconstrained_total(&ss.sketch),
+ has_geometry(&ss.sketch),
ss.ends.open.len(),
ss.ends.untied.len(),
)
};
- let t = Tokens::get();
let vp = viewport(app, ctx);
- let bottom = vp.bottom().min(ctx.content_rect().bottom()) - 8.0;
- // Prefer the space below Axis View, but reclaim it on short/HiDPI views.
+ if !vp.is_finite() || !vp.is_positive() {
+ return;
+ }
+ let bottom = vp.bottom().min(ctx.content_rect().bottom()) - crate::shell::SHELL_GAP;
let top = crate::shell::panel_top(app, vp, bottom, crate::frame::Side::Right);
- // Area rounds its left edge to a physical pixel; leave room for that rounding.
- let anchor = egui::pos2(vp.right() - 0.5 / ctx.pixels_per_point(), top);
- let frame = crate::frame::dock_frame(ctx, crate::frame::Side::Right);
- let shown = |k: &str| match k {
+ let frame = crate::ui_kit::Panel::palette_frame(ctx, app.ui.layout);
+ let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP - frame.stroke.width, top + frame.stroke.width);
+ let shown = |key: &str| match key {
"grid" => !opts.hide_grid,
"snap" => !opts.no_snap,
"slice" => opts.slice,
@@ -382,266 +341,256 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
_ => false,
};
let mut set: Option<(String, bool)> = None;
- let mut linetype: Option<u8> = None;
+ let mut linetype = None;
+ let mut construction = false;
let mut look = false;
- let mut finish = false;
let mut tie = false;
- let mut start: Option<&'static str> = None;
+ let mut start = None;
let feature = active_feature(app);
let has_curves = !selected_curves(app).is_empty();
- let selected_types = selected_linetypes(app);
- let margin_bottom = f32::from(frame.inner_margin.bottom);
- let response = crate::frame::docked(
- app.tr("ui.heading_sketch_palette"),
+ let selected_types = if has_curves { selected_linetypes(app) } else { std::array::from_fn(|i| mode(app) == i as u8) };
+ let panel = crate::ui_kit::Panel::new(
+ app.tr_label("ui.palette_sketch_options"),
egui::Id::new("sc_sketch_palette"),
anchor,
- bottom - anchor.y,
- crate::frame::Width::Normal,
+ vp,
+ crate::frame::Side::Right,
+ frame,
)
- .frame(frame)
- .show(ctx, |ui| {
- let width = width(vp);
- ui.set_width(width);
- ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);
- // The options list normally scrolls on its own to keep Finish Sketch visible.
- // When even the headings and footer cannot fit, scroll the whole palette.
- let available_height = (bottom - anchor.y - frame.inner_margin.sum().y - 2.0 * frame.stroke.width).max(0.0);
- let scroll_palette = bottom - anchor.y < 360.0;
- let mut contents = |ui: &mut egui::Ui| {
- let content_top = ui.cursor().top();
- let line = ui.text_style_height(&egui::TextStyle::Body);
- let gap = ui.spacing().item_spacing.y;
- crate::frame::heading(ui, Level::Title, width, |ui| {
- let folded = FOLDED.with(Cell::get);
- if ui.add(egui::Button::new(RichText::new(if folded { "+" } else { "−" }).size(14.0)).frame(false)).clicked() {
- FOLDED.with(|f| f.set(!folded));
- }
- ui.label(RichText::new(app.tr("ui.heading_sketch_palette")).strong().size(12.5));
- });
- if FOLDED.with(Cell::get) {
- return;
+ .width(width(vp));
+ let response = panel.window().show(ctx, |ui| {
+ panel.palette(ui, bottom, top, |ui, part| match part {
+ crate::ui_kit::Part::Header => {
+ let status = if !solved || !geometry || remaining == 0 {
+ crate::i18n::tr_dyn(&dof_text(remaining, solved, geometry))
+ } else {
+ crate::i18n::format(if remaining == 1 { "sketch.dof_left_one" } else { "sketch.dof_left" }, &[("count", &remaining.to_string())])
+ };
+ crate::ui_kit::status_header(
+ ui,
+ "sketch_palette",
+ &name,
+ crate::ui_kit::StatusHeader {
+ icon: "sketch",
+ text: &status,
+ complete: solved && remaining == 0 && geometry,
+ fraction: constrained_fraction(remaining, total, solved && geometry),
+ },
+ );
}
- // Feature Options sits above Options: the modes of the creation tool that is running.
- if let Some((family, current)) = feature {
- let ffold = FEATURE_FOLDED.with(Cell::get);
- crate::frame::heading(ui, Level::Section, width, |ui| {
- let (tri_rect, tri_resp) = ui.allocate_exact_size(vec2(14.0, 14.0), egui::Sense::click());
- disclosure_triangle(ui.painter(), tri_rect.center(), !ffold, t.text);
- crate::scenario::publish_handle("sketch_palette:feature_fold", tri_rect.center());
- let label_resp = ui.add(egui::Label::new(RichText::new(app.tr("ui.feature_options")).size(12.0)).sense(egui::Sense::click()));
- if tri_resp.clicked() || label_resp.clicked() {
- FEATURE_FOLDED.with(|f| f.set(!ffold));
+ crate::ui_kit::Part::Body => {
+ let t = crate::theme::Tokens::get();
+ if open_ends > 0 {
+ let text = crate::i18n::format("sketch.open_ends", &[("count", &open_ends.to_string())]);
+ ui.label(egui::RichText::new(text).size(t.font_small).color(t.warning)).on_hover_text(app.tr("ui.open_ends_tip"));
+ }
+ if untied_ends > 0 {
+ ui.horizontal(|ui| {
+ let text = crate::i18n::format("sketch.untied_ends", &[("count", &untied_ends.to_string())]);
+ ui.label(egui::RichText::new(text).size(t.font_small).color(t.warning)).on_hover_text(app.tr("ui.untied_ends_tip"));
+ let button = crate::ui_kit::secondary_button(ui, "ui.tie_ends").on_hover_text(app.tr("ui.tie_ends_tip"));
+ crate::scenario::publish_handle("sketch_palette:tie_ends", button.rect.center());
+ tie = button.clicked();
+ });
+ }
+
+ if let Some((family, current)) = feature {
+ let section = crate::ui_kit::section(ui, "feature", "Feature Options", true, |ui| {
+ let choices: Vec<_> = family
+ .commands
+ .iter()
+ .filter_map(|id| solidcraft_engine::find_command(id))
+ .map(|spec| crate::ui_kit::ToolChoice {
+ key: spec.id,
+ icon: spec.icon,
+ label: app.tr_label(spec.label),
+ enabled: spec.info(&app.session).enabled,
+ })
+ .collect();
+ let section = ui.vertical(|ui| crate::ui_kit::tool_choices(ui, app.tr_label(family.label), current, &choices));
+ crate::scenario::publish_rect("sketch_palette:feature_options", section.response.rect);
+ section.inner
+ });
+ start = section.flatten();
+ section_alias("sketch_palette:feature_fold", "Feature Options");
+ }
+ crate::ui_kit::row(ui, "Line Type", |ui| {
+ // Normal, Construction, Centerline and the Infinite line, as icons. With a
+ // selection a click converts it; without, it picks the mode new curves use.
+ let segments = LINE_TYPES.map(|(key, icon, name)| {
+ let name = app.tr_label(name);
+ let tip = if has_curves {
+ crate::i18n::format("sketch.make_selection", &[("linetype", name)])
+ } else {
+ crate::i18n::format("sketch.draw_curves", &[("linetype", name)])
+ };
+ crate::ui_kit::IconSegment { key, icon, tip }
+ });
+ let mut selected = selected_types.iter().position(|on| *on).unwrap_or(usize::MAX);
+ if crate::ui_kit::segmented_icons(ui, &mut selected, &segments, &selected_types) {
+ linetype = u8::try_from(selected).ok();
}
});
- if !ffold {
- let section = ui.vertical(|ui| feature_row(app, ui, width, family, current));
- start = section.inner;
- crate::scenario::publish_rect("sketch_palette:feature_options", section.response.rect);
- }
- ui.add_space(2.0);
- }
- let ofold = OPTIONS_FOLDED.with(Cell::get);
- crate::frame::heading(ui, Level::Section, width, |ui| {
- let (tri_rect, tri_resp) = ui.allocate_exact_size(vec2(14.0, 14.0), egui::Sense::click());
- disclosure_triangle(ui.painter(), tri_rect.center(), !ofold, t.text);
- crate::scenario::publish_handle("sketch_palette:options_fold", tri_rect.center());
- let label_resp = ui.add(egui::Label::new(RichText::new(app.tr("ui.options")).size(12.0)).sense(egui::Sense::click()));
- if tri_resp.clicked() || label_resp.clicked() {
- OPTIONS_FOLDED.with(|f| f.set(!ofold));
+ // In words: the selection's line types (several for a mixed selection), or the
+ // mode new curves are drawn in.
+ let names: Vec<&str> =
+ LINE_TYPES.iter().zip(selected_types).filter(|(_, on)| *on).map(|((_, _, name), _)| app.tr_label(name)).collect();
+ crate::ui_kit::caption(ui, "Line Type", &names.join(", "));
+ for key in ["show_constraints", "show_dimensions", "show_points", "snap"] {
+ if let Some((_, label)) = TOGGLES.iter().find(|(k, _)| *k == key)
+ && crate::ui_kit::checkbox_row(ui, key, label, shown(key))
+ {
+ set = Some((key.to_string(), !shown(key)));
+ }
}
- });
- if !ofold {
- // Keep room for the footer: status heading and line, a line, Finish Sketch, a line.
- let ends_rows = if open_ends > 0 { line + gap } else { 0.0 } + if untied_ends > 0 { ui.spacing().interact_size.y + gap } else { 0.0 };
- let footer = 5.0 * line + ui.spacing().interact_size.y + 6.0 * gap + 8.0 + ends_rows;
- let options_height =
- if scroll_palette { available_height - (ui.cursor().top() - content_top) - footer } else { bottom - ui.cursor().top() - footer }
- .max(24.0);
- let options =
- egui::ScrollArea::vertical().id_salt("sc_palette_options").max_height(options_height).auto_shrink([false, true]).show(ui, |ui| {
- // Every row below: its label at the left, its control right-aligned at the
- // same column (`frame::right_aligned`), so every row lines up instead of
- // each control sitting wherever its label happened to end.
- ui.vertical(|ui| {
- ui.horizontal(|ui| {
- ui.label(app.tr("ui.linetype"));
- // Taller and wider than the old text-only buttons. Construction and
- // Centerline need a round dot and a clear gap to read apart. 30 by
- // 20 px left too little square room for either.
- let btn_w = 36.0;
- let group_w = 4.0 * btn_w + 3.0 * ui.spacing().item_spacing.x;
- crate::frame::right_aligned(ui, width, group_w, |ui| {
- ui.horizontal(|ui| {
- // With a selection: its line type, and a click converts it;
- // without: the mode new curves are drawn in. Each button
- // still carries its old glyph as hidden (transparent) text.
- // That keeps its hit target, size and accessible name
- // exactly as before. A drawn icon (icons.rs) paints over it.
- // Construction and Centerline always draw in the theme's
- // construction orange. Normal's icon never changes with the
- // accent colour. It stays neutral in every case.
- let current = mode(app);
- for (i, (label, icon, tip)) in [
- ("—", "normal", "Normal"),
- ("- -", "construction", "Construction"),
- ("-·-", "centerline", "Centerline"),
- ("↔", "infinite", "Infinite"),
- ]
- .iter()
- .enumerate()
- {
- let on = if has_curves { selected_types.get(i).copied().unwrap_or(false) } else { current == i as u8 };
- let tr_tip = app.tr_label(tip);
- let hover = if has_curves {
- crate::i18n::format("sketch.make_selection", &[("linetype", tr_tip)])
- } else {
- crate::i18n::format("sketch.draw_curves", &[("linetype", tr_tip)])
- };
- let btn = egui::Button::new(RichText::new(*label).color(Color32::TRANSPARENT))
- .selected(on)
- .min_size(vec2(btn_w, 28.0));
- let resp = ui.add(btn).on_hover_text(hover);
- let accent = if *icon == "normal" { t.icon } else { t.construction_geom };
- // A square icon area. The button's own rect is
- // text-shaped, wider than tall. A flattened diagonal
- // leaves less room for a dash pattern's gaps to read.
- let side = (resp.rect.width().min(resp.rect.height()) - 3.0).max(12.0);
- let icon_rect = egui::Rect::from_center_size(resp.rect.center(), vec2(side, side));
- crate::icons::paint(ui.painter(), icon_rect, icon, t.icon, t.icon_fill, accent);
- if resp.clicked() {
- linetype = Some(i as u8);
- }
- }
- });
- });
- });
- ui.horizontal(|ui| {
- // One label, one icon button (the "lookat" glyph already used on the
- // viewport's own navigation overlay): not the word "Look At" twice.
- // The button carries no visible text of its own; `labelled_by` gives
- // it the row's own label as its accessible name, so a screen reader
- // still hears "Look At" the way the old text button said it.
- let label_resp = ui.label(app.tr("ui.look_at"));
- let icon_w = 28.0;
- let resp = crate::frame::right_aligned(ui, width, icon_w, |ui| {
- let r = ui.add(egui::Button::new("").min_size(vec2(icon_w, 20.0)));
- let side = (r.rect.width().min(r.rect.height()) - 4.0).max(12.0);
- let icon_rect = egui::Rect::from_center_size(r.rect.center(), vec2(side, side));
- crate::icons::paint(ui.painter(), icon_rect, "lookat", t.icon, t.icon_fill, t.accent);
- crate::scenario::publish_handle("sketch_palette:look_at", r.rect.center());
- r.labelled_by(label_resp.id)
- });
- let resp = resp.on_hover_text(app.tr("ui.look_at"));
- if resp.clicked() {
- look = true;
- }
- });
- });
- for (k, label) in TOGGLES {
- ui.horizontal(|ui| {
- // The label is still part of the toggle: clicking it flips the
- // checkbox too, same as before the checkbox moved to its own column.
- let label_resp = ui.add(egui::Label::new(app.tr_label(label)).sense(egui::Sense::click()));
- let mut on = shown(k);
- let box_w = ui.spacing().interact_size.y;
- let cb = crate::frame::right_aligned(ui, width, box_w, |ui| {
- ui.add(egui::Checkbox::without_text(&mut on)).labelled_by(label_resp.id)
- });
- if cb.changed() {
- set = Some((k.to_string(), on));
- } else if label_resp.clicked() {
- set = Some((k.to_string(), !on));
- }
- });
+ construction = crate::ui_kit::checkbox_row(
+ ui,
+ "construction_mode",
+ "ui.palette_construction_mode",
+ selected_types.get(1).copied().unwrap_or(false),
+ );
+ crate::ui_kit::section(ui, "more", "ui.palette_more", false, |ui| {
+ for (key, label) in TOGGLES {
+ if !["show_constraints", "show_dimensions", "show_points", "snap"].contains(&key)
+ && crate::ui_kit::checkbox_row(ui, key, label, shown(key))
+ {
+ set = Some((key.to_string(), !shown(key)));
}
- });
- crate::scenario::publish_rect("sketch_palette:options", options.inner_rect);
- }
- ui.add_space(4.0);
- // The status changes when the sketch needs attention, so it gets its own heading.
- crate::frame::heading(ui, Level::Section, width, |ui| {
- ui.label(RichText::new(app.tr("ui.sketch_status")).size(12.0));
- });
- ui.label(RichText::new(crate::i18n::tr_dyn(&dof_line)).color(if ok { t.sketch_accent } else { t.text_dim }));
- // Where a profile can fail (the viewport rings and diamonds them).
- if open_ends > 0 {
- let text = crate::i18n::format("sketch.open_ends", &[("count", &open_ends.to_string())]);
- ui.label(RichText::new(text).color(t.warning)).on_hover_text(app.tr("ui.open_ends_tip"));
- }
- if untied_ends > 0 {
- ui.horizontal(|ui| {
- let text = crate::i18n::format("sketch.untied_ends", &[("count", &untied_ends.to_string())]);
- ui.label(RichText::new(text).color(t.warning)).on_hover_text(app.tr("ui.untied_ends_tip"));
- let button = ui.button(app.tr("ui.tie_ends")).on_hover_text(app.tr("ui.tie_ends_tip"));
- crate::scenario::publish_handle("sketch_palette:tie_ends", button.rect.center());
- if button.clicked() {
- tie = true;
}
});
+ section_alias("sketch_palette:options_fold", "ui.palette_more");
}
- // One line between the status and Finish Sketch, and below it to the edge.
- ui.add_space((line - gap).max(0.0));
- // A row as tall as the button, so the gap below it is just the line.
- ui.allocate_ui_with_layout(vec2(ui.available_width(), 0.0), egui::Layout::right_to_left(egui::Align::Min), |ui| {
- let button = ui.add(egui::Button::new(RichText::new(app.tr("ui.finish_sketch")).color(t.on_accent)).fill(t.accent));
- crate::scenario::publish_rect("sketch_palette:finish", button.rect);
- crate::scenario::publish_handle("sketch_palette:finish", button.rect.center());
- if button.clicked() {
- finish = true;
+ crate::ui_kit::Part::Footer => {
+ let (at, slice) = crate::ui_kit::button_pair(
+ ui,
+ "sketch_palette",
+ [false, opts.slice],
+ [
+ crate::ui_kit::PairButton { key: "look_at", label: "ui.look_at", icon: Some("lookat") },
+ crate::ui_kit::PairButton { key: "slice", label: "Slice", icon: None },
+ ],
+ );
+ look = at;
+ if slice {
+ set = Some(("slice".into(), !opts.slice));
}
- });
- ui.add_space((line - margin_bottom).max(0.0));
- };
- if scroll_palette {
- egui::ScrollArea::vertical()
- .id_salt("sc_palette_content")
- .max_height(available_height)
- .min_scrolled_height(0.0)
- .auto_shrink([false, true])
- .show(ui, contents);
- } else {
- contents(ui);
- }
+ }
+ });
});
- app.viewport.palette_rect = response.map(|r| r.response.rect);
- if let Some(r) = app.viewport.palette_rect {
- crate::scenario::publish_rect("sketch_palette:outer", r);
- }
- if let Some((k, on)) = set {
- let mut p = serde_json::Map::new();
- p.insert(k, Value::Bool(on));
- if let Err(e) = app.run("sketch.options", Value::Object(p)) {
- app.set_status(e, true);
+ app.viewport.palette_rect = response.map(|r| r.response.rect.expand(frame.stroke.width));
+ if let Some(rect) = app.viewport.palette_rect {
+ crate::scenario::publish_rect("sketch_palette:outer", rect);
+ }
+ // Compatibility automation hook now points at the single Finish action in the ribbon.
+ if let Some(at) = crate::scenario::handle_at("button:sketch.finish") {
+ crate::scenario::publish_handle("sketch_palette:finish", at);
+ if let Some(rect) = crate::scenario::rect_of("button:sketch.finish") {
+ crate::scenario::publish_rect("sketch_palette:finish", rect);
+ }
+ }
+ if let Some((key, on)) = set {
+ let mut params = serde_json::Map::new();
+ params.insert(key, Value::Bool(on));
+ if let Err(error) = app.run("sketch.options", Value::Object(params)) {
+ app.set_status(error, true);
}
}
- if let Some(k) = linetype {
+ if let Some(kind) = linetype {
if has_curves {
- set_linetype(app, k);
+ set_linetype(app, kind);
} else {
- set_mode(app, k);
+ set_mode(app, kind);
}
}
+ if construction {
+ toggle_construction(app);
+ }
if let Some(id) = start {
- // The same path a toolbar click takes. It drops the half-drawn shape and starts the
- // chosen mode from its first point, so a partly placed 3-point rectangle does not
- // carry its stale points into a 2-point one.
app.start(id);
}
+ if tie && let Err(error) = app.run("sketch.loose_ends.tie", json!({})) {
+ app.set_status(error, true);
+ }
if look {
crate::dialogs::look_at_sketch_again(app);
}
- if tie && let Err(e) = app.run("sketch.loose_ends.tie", json!({})) {
- app.set_status(e, true);
- }
- if finish {
- app.finish_sketch();
- }
}
#[cfg(test)]
mod tests {
use super::*;
+ #[test]
+ fn card_uses_design_dimensions_and_all_options_still_run_commands() {
+ let mut h = crate::scenario::Harness::new();
+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
+ h.settle();
+ let palette = h.app.viewport.palette_rect.unwrap();
+ assert!(
+ (palette.width() - Tokens::get().sketch_palette_width).abs() < 1.0,
+ "palette {palette:?}, width {}",
+ Tokens::get().sketch_palette_width
+ );
+ let look = crate::scenario::rect_of("sketch_palette:look_at").unwrap();
+ let slice = crate::scenario::rect_of("sketch_palette:slice").unwrap();
+ assert_eq!(look.size(), slice.size());
+ assert_eq!(look.height(), Tokens::get().form_button_height);
+ assert_eq!(crate::scenario::rect_of("sketch_palette:meter").unwrap().height(), Tokens::get().space_6);
+ assert!(crate::scenario::handle_at("sketch_palette:toggle:grid").is_none());
+ let more = crate::scenario::handle_at("sketch_palette:options_fold").unwrap();
+ h.call("ui.click", json!({"x":more.x,"y":more.y}));
+ let active = h.app.session.active_sketch.unwrap();
+ for (key, _) in TOGGLES {
+ let before = h.app.session.doc.to_json();
+ let undo = h.app.session.undo.len();
+ let at = crate::scenario::handle_at(&format!("sketch_palette:toggle:{key}")).unwrap();
+ h.call("ui.click", json!({"x":at.x,"y":at.y}));
+ assert_ne!(h.app.session.doc.to_json(), before, "{key}");
+ assert_eq!(h.app.session.undo.len(), undo + 1, "{key}");
+ assert_eq!(h.app.session.active_sketch, Some(active));
+ h.app.run("edit.undo", json!({})).unwrap();
+ h.settle();
+ assert_eq!(h.app.session.doc.to_json(), before, "{key}");
+ }
+ let construction = crate::scenario::handle_at("sketch_palette:toggle:construction_mode").unwrap();
+ h.call("ui.click", json!({"x":construction.x,"y":construction.y}));
+ assert_eq!(mode(&h.app), 1);
+ h.call("ui.click", json!({"x":construction.x,"y":construction.y}));
+ assert_eq!(mode(&h.app), 0);
+ let infinite = crate::scenario::handle_at("dialog:Line Type:infinite").expect("the Infinite segment is drawn");
+ h.call("ui.click", json!({"x":infinite.x,"y":infinite.y}));
+ assert_eq!(mode(&h.app), 3);
+ set_mode(&mut h.app, 0);
+ }
+
+ #[test]
+ fn meter_uses_input_variables_and_solver_remaining_dof() {
+ let mut h = crate::scenario::Harness::new();
+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
+ h.app.run("sketch.circle.center", json!({"center":[10,10],"radius":5})).unwrap();
+ h.settle();
+ let state = h.app.session.world_state();
+ let sketch = state.sketch(h.app.session.active_sketch.unwrap()).unwrap();
+ assert_eq!(unconstrained_total(&sketch.sketch), 3);
+ assert_eq!(sketch.report.dof, 3);
+ assert_eq!(crate::scenario::count_of("sketch_palette:constrained_fraction"), Some(0.0));
+ assert_eq!(constrained_fraction(2, 14, true), 1.0 - 2.0 / 14.0);
+ assert_eq!(constrained_fraction(0, 0, true), 1.0);
+ assert_eq!(constrained_fraction(0, 14, false), 0.0);
+ assert_eq!(constrained_fraction(20, 14, true), 0.0);
+ }
+
+ #[test]
+ fn ribbon_exit_finishes_the_active_sketch() {
+ let mut h = crate::scenario::Harness::new();
+ h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
+ h.settle();
+ assert!(crate::scenario::rect_of("ribbon:section:SKETCH:FINISH SKETCH").is_some());
+ let at = crate::scenario::handle_at("button:sketch.finish").unwrap();
+ h.call("ui.click", json!({"x":at.x,"y":at.y}));
+ assert!(h.app.session.active_sketch.is_none());
+ }
+
#[test]
fn construction_shortcut_keeps_the_drawing_tool_and_commits_its_line_type() {
for command in ["sketch.line", "sketch.rectangle.two_point", "sketch.circle.center"] {
@@ -679,18 +628,18 @@ mod tests {
#[test]
fn palette_footer_and_scrolled_lower_option_remain_reachable_at_scale_and_resize() {
for (scale, height) in [(1.0, 900.0), (2.0, 900.0), (2.0, 720.0)] {
- FOLDED.with(|v| v.set(false));
- OPTIONS_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.circle.center", json!({"center":[0,0],"radius":1})).unwrap();
h.call("ui.resize", json!({"width":1400,"height":height}));
h.call("ui.prefs", json!({"ui_scale":scale}));
h.settle();
+ let at = crate::scenario::handle_at("sketch_palette:options_fold").unwrap();
+ h.call("ui.click", json!({"x":at.x,"y":at.y}));
let baseline = h.app.session.doc.to_json();
let undo = h.app.session.undo.len();
let vp = h.app.viewport.rect.unwrap();
- let footer = crate::scenario::rect_of("sketch_palette:finish").unwrap();
+ let footer = crate::scenario::rect_of("sketch_palette:look_at").unwrap();
assert!(vp.contains_rect(footer), "scale{scale} height{height}: {footer:?} outside {vp:?}");
let options = crate::scenario::rect_of("sketch_palette:options").unwrap();
assert!(vp.contains_rect(options));
@@ -707,8 +656,8 @@ mod tests {
h.app.run("edit.undo", json!({})).unwrap();
assert_eq!(h.app.session.doc.to_json(), baseline);
h.settle();
- let footer = crate::scenario::rect_of("sketch_palette:finish").unwrap();
- h.call("ui.click", json!({"x":footer.center().x,"y":footer.center().y}));
+ let at = crate::scenario::handle_at("sketch_palette:finish").unwrap();
+ h.call("ui.click", json!({"x":at.x,"y":at.y}));
h.settle();
assert!(h.app.session.active_sketch.is_none(), "Finish Sketch must work at scale{scale} height{height}");
assert_eq!(h.app.session.doc.to_json(), baseline);
@@ -720,8 +669,6 @@ mod tests {
/// too narrow for both keeps the dialog alone.
#[test]
fn a_dialog_opened_while_sketching_keeps_the_palette_beside_it() {
- FOLDED.with(|v| v.set(false));
- OPTIONS_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[40,30]})).unwrap();
@@ -735,7 +682,7 @@ mod tests {
let dialog = h.app.viewport.dialog_rect.unwrap();
assert!(!palette.intersect(dialog).is_positive(), "palette {palette:?} overlaps dialog {dialog:?}");
assert!(dialog.left() < palette.left(), "the dialog takes the left edge: {dialog:?}, {palette:?}");
- let finish = crate::scenario::rect_of("sketch_palette:finish").expect("Finish Sketch stays reachable");
+ let finish = crate::scenario::rect_of("sketch_palette:look_at").expect("Look At stays reachable");
assert!(palette.contains_rect(finish));
// Neither panel ever covers the other, however narrow the view gets.
for width in [1200.0, 1000.0, 860.0, 720.0, 600.0] {
@@ -758,26 +705,31 @@ mod tests {
let center = curve(h.app.run("sketch.line", json!({"points":[[0,20],[20,20]],"infer":false,"connect":false})).unwrap());
h.app.run("sketch.construction", json!({"curves":[cons],"value":true})).unwrap();
h.app.run("sketch.centerline", json!({"curves":[center],"value":true})).unwrap();
- // Which of Normal, Construction and Centerline the palette shows pressed.
+ // Which of Normal, Construction, Centerline and Infinite the palette shows pressed.
let pressed = |h: &mut crate::scenario::Harness, ids: &[&String]| {
h.app.session.selection = ids.iter().map(|id| Sel::SketchCurve { id: (*id).clone() }).collect();
h.settle();
let tree = h.output.accesskit_update.as_ref().unwrap();
- ["—", "- -", "-·-"]
+ ["normal", "construction", "centerline", "infinite"]
.map(|label| tree.nodes.iter().any(|(_, n)| n.label() == Some(label) && n.toggled() == Some(egui::accesskit::Toggled::True)))
};
- assert_eq!(pressed(&mut h, &[&normal]), [true, false, false]);
- assert_eq!(pressed(&mut h, &[&cons]), [false, true, false]);
- assert_eq!(pressed(&mut h, &[&center]), [false, false, true]);
+ assert_eq!(pressed(&mut h, &[&normal]), [true, false, false, false]);
+ assert_eq!(pressed(&mut h, &[&cons]), [false, true, false, false]);
+ assert_eq!(pressed(&mut h, &[&center]), [false, false, true, false]);
// A mixed selection shows each of its line types.
- assert_eq!(pressed(&mut h, &[&normal, &center]), [true, false, true]);
+ assert_eq!(pressed(&mut h, &[&normal, &center]), [true, false, true, false]);
// Nothing selected: the drawing mode.
- assert_eq!(pressed(&mut h, &[]), [true, false, false]);
+ assert_eq!(pressed(&mut h, &[]), [true, false, false, false]);
+ set_mode(&mut h.app, 1);
+ assert_eq!(pressed(&mut h, &[]), [false, true, false, false]);
+ set_mode(&mut h.app, 3);
+ assert_eq!(pressed(&mut h, &[]), [false, false, false, true]);
set_mode(&mut h.app, 1);
- assert_eq!(pressed(&mut h, &[]), [false, true, false]);
// A selection overrides the mode until it is cleared.
- assert_eq!(pressed(&mut h, &[&normal]), [true, false, false]);
- assert_eq!(pressed(&mut h, &[]), [false, true, false]);
+ assert_eq!(pressed(&mut h, &[&normal]), [true, false, false, false]);
+ assert_eq!(pressed(&mut h, &[]), [false, true, false, false]);
+ // The line types are also named in words under the icons.
+ assert!(crate::scenario::rect_of("dialog:caption:Line Type").is_some_and(|r| r.height() > 0.0));
}
#[test]
@@ -828,19 +780,17 @@ mod tests {
#[test]
fn options_disclosure_triangle_folds_and_unfolds_the_section() {
- OPTIONS_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.settle();
- assert!(h.widget("Sketch Grid").is_some(), "options are open by default");
+ assert!(h.widget("Sketch Grid").is_none(), "More is collapsed by default");
let at = crate::scenario::handle_at("sketch_palette:options_fold").unwrap();
h.call("ui.click", json!({"x": at.x, "y": at.y}));
h.settle();
- assert!(h.widget("Sketch Grid").is_none(), "the triangle must fold the options section");
+ assert!(h.widget("Sketch Grid").is_some(), "the triangle must unfold More");
h.call("ui.click", json!({"x": at.x, "y": at.y}));
h.settle();
- assert!(h.widget("Sketch Grid").is_some(), "the triangle must unfold it again");
- OPTIONS_FOLDED.with(|v| v.set(false));
+ assert!(h.widget("Sketch Grid").is_none(), "the triangle must collapse More again");
}
#[test]
@@ -875,8 +825,6 @@ mod tests {
#[test]
fn feature_options_show_every_mode_of_the_running_tool_and_switch_between_them() {
- FOLDED.with(|v| v.set(false));
- FEATURE_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.start("sketch.circle.center");
@@ -904,8 +852,6 @@ mod tests {
#[test]
fn switching_mode_mid_draw_restarts_the_tool_and_leaves_the_design_alone() {
- FOLDED.with(|v| v.set(false));
- FEATURE_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.start("sketch.rectangle.three_point");
@@ -926,8 +872,6 @@ mod tests {
#[test]
fn feature_options_stay_hidden_without_a_tool_that_has_other_modes() {
- FOLDED.with(|v| v.set(false));
- FEATURE_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.settle();
@@ -949,8 +893,6 @@ mod tests {
#[test]
fn feature_options_disclosure_triangle_folds_and_unfolds_the_section() {
- FOLDED.with(|v| v.set(false));
- FEATURE_FOLDED.with(|v| v.set(false));
let mut h = crate::scenario::Harness::new();
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.start("sketch.slot.center_to_center");
@@ -961,12 +903,11 @@ mod tests {
h.call("ui.click", json!({"x": at.x, "y": at.y}));
h.settle();
assert!(crate::scenario::handle_at(button).is_none(), "the triangle must fold the section");
- assert!(h.widget("Sketch Grid").is_some(), "folding Feature Options leaves Options open");
+ assert!(h.widget("Constraints").is_some(), "folding Feature Options leaves primary options visible");
let at = crate::scenario::handle_at("sketch_palette:feature_fold").unwrap();
h.call("ui.click", json!({"x": at.x, "y": at.y}));
h.settle();
assert!(crate::scenario::handle_at(button).is_some(), "the triangle must unfold it again");
- FEATURE_FOLDED.with(|v| v.set(false));
}
#[test]
@@ -991,6 +932,9 @@ mod tests {
dof_text(ss.report.dof, ss.report.ok(), has_geometry(&ss.sketch))
};
assert_eq!(line(&h), "No geometry yet");
+ assert!(h.widget("No geometry yet").is_some(), "the kit header shows the empty-sketch status");
+ assert!(h.widget("Fully constrained").is_none());
+ assert_eq!(crate::scenario::count_of("sketch_palette:constrained_fraction"), Some(0.0));
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,5]})).unwrap();
h.settle();
assert_ne!(line(&h), "No geometry yet", "a drawn rectangle is geometry");
diff --git a/crates/ui-egui/src/sketch_text.rs b/crates/ui-egui/src/sketch_text.rs
index 57ed9b6dad..2c5aff1b1f 100644
--- a/crates/ui-egui/src/sketch_text.rs
+++ b/crates/ui-egui/src/sketch_text.rs
@@ -14,6 +14,7 @@ use solidcraft_engine::{
use crate::SolveApp;
use crate::dialogs::{Dialog, Kind};
use crate::selection::SelInput;
+use crate::ui_kit;
/// Field rows after the text: position, height (lengths), angle, letter spacing (a length) and
/// line spacing (a factor).
@@ -448,13 +449,11 @@ pub(crate) fn refresh(app: &SolveApp, k: &mut Tx) -> bool {
/// starts a new line there). `inputs` and `active`: the dialog's Path input.
pub(crate) fn rows(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], active: &mut usize) -> bool {
let mut enter = false;
- crate::dialogs::row_label(ui, "Text");
- let width = ui.spacing().text_edit_width;
let id = egui::Id::new("sketch_text_content");
if ui.memory(|m| m.has_focus(id)) {
enter |= ui.input_mut(|i| !i.modifiers.shift && i.consume_key(egui::Modifiers::NONE, egui::Key::Enter));
}
- let response = ui.add(egui::TextEdit::multiline(&mut k.text).id(id).desired_rows(3).desired_width(width));
+ let response = ui_kit::multiline_text_field(ui, "Text", id, &mut k.text);
crate::scenario::publish_handle("dialog:Text", response.rect.center());
if k.focus {
response.request_focus();
@@ -464,42 +463,44 @@ pub(crate) fn rows(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], activ
state.store(ui.ctx(), id);
k.focus = false;
}
- ui.end_row();
- crate::dialogs::row_label(ui, "Font");
- font_row(ui, k, width);
- ui.end_row();
- crate::dialogs::row_label(ui, "Style");
- ui.horizontal(|ui| {
- let bold = ui.toggle_value(&mut k.style.bold, egui::RichText::new("B").strong()).on_hover_text(crate::i18n::tr("sketch_text.bold"));
- crate::scenario::publish_handle("dialog:Bold", bold.rect.center());
- let italic = ui.toggle_value(&mut k.style.italic, egui::RichText::new("I").italics()).on_hover_text(crate::i18n::tr("sketch_text.italic"));
- crate::scenario::publish_handle("dialog:Italic", italic.rect.center());
- });
- ui.end_row();
- crate::dialogs::row_label(ui, "Alignment");
- ui.horizontal(|ui| {
- for (align, id, handle) in [
- (TextAlign::Left, "sketch_text.align_left", "dialog:Align left"),
- (TextAlign::Center, "sketch_text.align_center", "dialog:Align center"),
- (TextAlign::Right, "sketch_text.align_right", "dialog:Align right"),
- ] {
- let response = ui.selectable_value(&mut k.style.align, align, crate::i18n::tr(id));
- crate::scenario::publish_handle(handle, response.rect.center());
+ ui_kit::row(ui, "Font", |ui| font_row(ui, k));
+ ui_kit::row(ui, "Style", |ui| ui_kit::text_emphasis(ui, &mut k.style.bold, &mut k.style.italic));
+ ui_kit::row(ui, "Alignment", |ui| {
+ let mut selected = match k.style.align {
+ TextAlign::Left => 0,
+ TextAlign::Center => 1,
+ TextAlign::Right => 2,
+ };
+ let labels = ["sketch_text.align_left", "sketch_text.align_center", "sketch_text.align_right"].map(crate::i18n::tr);
+ ui_kit::segmented_compact(ui, &mut selected, &labels);
+ k.style.align = match selected {
+ 1 => TextAlign::Center,
+ 2 => TextAlign::Right,
+ _ => TextAlign::Left,
+ };
+ for (label, handle) in labels.iter().zip(["dialog:Align left", "dialog:Align center", "dialog:Align right"]) {
+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:Alignment:{label}")) {
+ crate::scenario::publish_handle(handle, at);
+ }
}
});
- ui.end_row();
// On a path the curve places the text: X, Y and the angle do not.
let on_path = k.style.path.is_some();
- for (i, (label, value)) in LABELS.iter().zip(k.values.iter_mut()).enumerate() {
- crate::dialogs::row_label(ui, label);
- let placed = on_path && matches!(i, 0 | 1 | ANGLE);
- if placed {
- let response = ui.add_enabled_ui(false, |ui| crate::dialogs::field(ui, value));
+ let (xy, rest) = k.values.split_at_mut(2);
+ if let [x, y] = xy {
+ let response = ui.add_enabled_ui(!on_path, |ui| ui_kit::value_pair(ui, "Position", [x, y], ["X", "Y"]));
+ enter |= response.inner;
+ if on_path {
+ response.response.on_disabled_hover_text(crate::i18n::tr("sketch_text.on_path"));
+ }
+ }
+ for (i, (label, value)) in LABELS.iter().skip(2).zip(rest).enumerate() {
+ let index = i + 2;
+ let response = ui.add_enabled_ui(!(on_path && index == ANGLE), |ui| ui_kit::row(ui, label, |ui| ui_kit::field(ui, value)));
+ enter |= response.inner;
+ if on_path && index == ANGLE {
response.response.on_disabled_hover_text(crate::i18n::tr("sketch_text.on_path"));
- } else {
- enter |= crate::dialogs::field(ui, value);
}
- ui.end_row();
}
path_row(ui, k, inputs, active);
enter
@@ -508,25 +509,20 @@ pub(crate) fn rows(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], activ
/// The curve the text follows: a chip that, clicked, takes the next curve clicked on the canvas;
/// × takes the text off it; Reverse runs it the other way along.
fn path_row(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], active: &mut usize) {
- let t = crate::theme::Tokens::get();
- crate::dialogs::row_label(ui, "Path");
- ui.horizontal(|ui| {
+ ui_kit::row(ui, "Path", |ui| {
let on = k.style.path.is_some();
- let text = if on {
- egui::RichText::new(crate::i18n::format("dialog.selected_count", &[("count", "1")])).color(t.on_accent)
- } else {
- egui::RichText::new(crate::i18n::tr("dialog.select")).color(t.text)
- };
- let stroke = if k.picking { egui::Stroke::new(1.5, t.accent) } else { egui::Stroke::new(1.0, t.dialog_border.gamma_multiply(1.6)) };
- let chip = egui::Button::new(text).fill(if on { t.chip } else { egui::Color32::TRANSPARENT }).stroke(stroke).min_size(egui::vec2(0.0, 22.0));
- let chip = crate::frame::add_outlined(ui, chip, stroke.width).on_hover_text(crate::i18n::tr("sketch_text.path_hint"));
+ let text = if on { crate::i18n::format("dialog.selected_count", &[("count", "1")]) } else { crate::i18n::tr("dialog.select").into() };
+ let chip = ui_kit::selection_field_state(ui, &text, k.picking, on).on_hover_text(crate::i18n::tr("sketch_text.path_hint"));
+ let chip_rect = chip.rect;
crate::scenario::publish_handle("dialog:Path", chip.rect.center());
if chip.clicked() {
k.picking = true;
*active = 0;
}
if on {
- let clear = ui.small_button("\u{d7}").on_hover_text(crate::i18n::tr("sketch_text.path_clear"));
+ let size = crate::theme::Tokens::get().space_24;
+ let rect = egui::Rect::from_center_size(egui::pos2(chip_rect.right() - size / 2.0, chip_rect.center().y), egui::vec2(size, size));
+ let clear = ui_kit::icon_button_at(ui, rect, "close", "sketch_text.path_clear");
crate::scenario::publish_handle("dialog:Path clear", clear.rect.center());
if clear.clicked() {
for input in inputs.iter_mut() {
@@ -537,12 +533,11 @@ fn path_row(ui: &mut egui::Ui, k: &mut Tx, inputs: &mut [SelInput], active: &mut
}
}
});
- ui.end_row();
if k.style.path.is_some() {
- crate::dialogs::row_label(ui, "Reverse");
- let reverse = ui.checkbox(&mut k.style.reverse, "");
- crate::scenario::publish_handle("dialog:Reverse", reverse.rect.center());
- ui.end_row();
+ ui_kit::section(ui, "path_options", "Options", true, |ui| {
+ let reverse = ui_kit::checkbox(ui, crate::i18n::tr_label("Reverse"), &mut k.style.reverse);
+ crate::scenario::publish_handle("dialog:Reverse", reverse.rect.center());
+ });
}
}
@@ -578,70 +573,25 @@ fn is_font_file(s: &str) -> bool {
lower.contains(['/', '\\']) || [".ttf", ".otf", ".ttc", ".otc"].iter().any(|e| lower.ends_with(e))
}
-/// Height of the font list (points).
-const FONT_LIST_PX: f32 = 260.0;
-
-/// The font: a list of the installed families (the built-in font first) with a search box; a
-/// font file's path typed there can be used too.
-fn font_row(ui: &mut egui::Ui, k: &mut Tx, width: f32) {
+/// The application supplies families/file recognition; the kit owns search and list widgets.
+fn font_row(ui: &mut egui::Ui, k: &mut Tx) {
let builtin = crate::i18n::format("sketch_text.builtin_font", &[("family", solidcraft_engine::sketch::DEFAULT_FONT_FAMILY)]);
let current = if k.font.trim().is_empty() { builtin.clone() } else { k.font.clone() };
- let mut chosen = None;
- let response = egui::ComboBox::from_id_salt("sketch_text_font")
- .width(width)
- .height(FONT_LIST_PX + 80.0)
- .selected_text(current)
- .close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
- .show_ui(ui, |ui| {
- let search = egui::TextEdit::singleline(&mut k.font_filter)
- .id_salt("sketch_text_font_search")
- .hint_text(crate::i18n::tr("sketch_text.font_search"));
- let search = ui.add(search.desired_width(f32::INFINITY));
- crate::scenario::publish_handle("dialog:Font search", search.rect.center());
- let typed = k.font_filter.trim();
- if is_font_file(typed) {
- let file = ui.selectable_label(false, crate::i18n::format("sketch_text.use_font_file", &[("path", typed)]));
- crate::scenario::publish_handle("dialog:Font file", file.rect.center());
- if file.clicked() {
- chosen = Some(typed.to_string());
- ui.close();
- }
- return;
- }
- let filter = typed.to_lowercase();
- // The list scrolls below the search box, at one height whatever it holds.
- let list = egui::ScrollArea::vertical()
- .id_salt("sketch_text_font_list")
- .max_height(FONT_LIST_PX)
- .min_scrolled_height(FONT_LIST_PX)
- .auto_shrink([false, false]);
- list.show(ui, |ui| {
- if builtin.to_lowercase().contains(&filter) {
- let item = ui.selectable_label(k.font.trim().is_empty(), &builtin);
- crate::scenario::publish_handle("dialog:Font built-in", item.rect.center());
- if item.clicked() {
- chosen = Some(String::new());
- ui.close();
- }
- }
- match families(ui.ctx()) {
- None => {
- ui.label(crate::i18n::tr("sketch_text.loading_fonts"));
- }
- Some(list) => {
- for family in list.iter().filter(|f| f.to_lowercase().contains(&filter)) {
- if ui.selectable_label(k.font.trim() == family, family).clicked() {
- chosen = Some(family.clone());
- ui.close();
- }
- }
- }
- }
- });
- })
- .response;
- crate::scenario::publish_handle("dialog:Font", response.rect.center());
- if let Some(font) = chosen {
+ let families = families(ui.ctx());
+ let mut options = vec![ui_kit::SearchOption { value: "", label: &builtin, handle: Some("dialog:Font built-in") }];
+ if let Some(list) = &families {
+ options.extend(list.iter().map(|family| ui_kit::SearchOption { value: family, label: family, handle: None }));
+ }
+ let custom = is_font_file(&k.font_filter).then(|| crate::i18n::format("sketch_text.use_font_file", &[("path", k.font_filter.trim())]));
+ if let Some(font) = ui_kit::searchable_dropdown(
+ ui,
+ "sketch_text_font",
+ &current,
+ &mut k.font_filter,
+ &options,
+ custom.as_deref(),
+ families.is_none().then(|| crate::i18n::tr("sketch_text.loading_fonts")),
+ ) {
k.font = font;
k.font_filter.clear();
}
diff --git a/crates/ui-egui/src/sketch_text_handles.rs b/crates/ui-egui/src/sketch_text_handles.rs
index 8c1ac01a42..2aadf1820d 100644
--- a/crates/ui-egui/src/sketch_text_handles.rs
+++ b/crates/ui-egui/src/sketch_text_handles.rs
@@ -308,7 +308,7 @@ pub(crate) fn show(app: &SolveApp, ui: &egui::Ui, painter: &Painter, proj: &Proj
}
Grab::Rotate => format!("{:.1}°", f.angle.to_degrees()),
};
- painter.text(p + vec2(14.0, -14.0), Align2::LEFT_BOTTOM, label, FontId::proportional(12.0), tk.accent);
+ painter.text(p + vec2(14.0, -14.0), Align2::LEFT_BOTTOM, label, FontId::proportional(crate::theme::Tokens::get().font_body), tk.accent);
}
}
diff --git a/crates/ui-egui/src/sketch_text_move.rs b/crates/ui-egui/src/sketch_text_move.rs
index 33c12cdc84..97c7c87831 100644
--- a/crates/ui-egui/src/sketch_text_move.rs
+++ b/crates/ui-egui/src/sketch_text_move.rs
@@ -29,16 +29,10 @@ pub(crate) fn valid(app: &SolveApp, k: &TextMove) -> bool {
}
pub(crate) fn rows(ui: &mut egui::Ui, k: &mut TextMove) -> bool {
- let mut enter = false;
- for (label, value) in ["Distance X", "Distance Y", "Angle"].iter().zip(&mut k.values) {
- crate::dialogs::row_label(ui, label);
- enter |= crate::dialogs::field(ui, value);
- ui.end_row();
- }
- crate::dialogs::row_label(ui, "Create Copy");
- let response = ui.checkbox(&mut k.copy, "");
- crate::scenario::publish_handle("dialog:Create Copy", response.rect.center());
- ui.end_row();
+ let [x, y, angle] = &mut k.values;
+ let mut enter = crate::ui_kit::value_pair_named(ui, "Position", [x, y], ["X", "Y"], ["Distance X", "Distance Y"]);
+ enter |= crate::ui_kit::row(ui, "Angle", |ui| crate::ui_kit::field(ui, angle));
+ crate::ui_kit::options(ui, "text_move_options", &mut [("Create Copy", &mut k.copy)]);
enter
}
diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs
index 47555ee4de..b8a758a358 100644
--- a/crates/ui-egui/src/sketch_tools.rs
+++ b/crates/ui-egui/src/sketch_tools.rs
@@ -199,7 +199,7 @@ fn continuity_legend(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
// Stable ids: this Gap is a hole between faces, not the sheet-metal gap (`ui.sheet_gap`).
let tr = crate::i18n::tr;
let rows = [(tr("ui.continuity_g2"), smooth), (tr("ui.continuity_g1"), jump), (tr("ui.continuity_g0"), sharp), (tr("ui.continuity_gap"), gap)];
- let font = egui::FontId::proportional(12.0);
+ let font = egui::FontId::proportional(tk.font_body);
let (row, pad, swatch) = (18.0, 8.0, 22.0);
let text_width = rows.iter().map(|(label, _)| painter.layout_no_wrap(label.to_string(), font.clone(), tk.text).size().x).fold(0.0, f32::max);
let size = egui::vec2(pad + swatch + 8.0 + text_width + pad, rows.len() as f32 * row + 2.0 * pad);
@@ -244,9 +244,21 @@ fn marks(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
painter.circle(q, 6.0, tk.panel.gamma_multiply(0.8), Stroke::new(1.6, tk.accent));
painter.line_segment([q - egui::vec2(10.0, 0.0), q + egui::vec2(10.0, 0.0)], Stroke::new(1.2, tk.accent));
painter.line_segment([q - egui::vec2(0.0, 10.0), q + egui::vec2(0.0, 10.0)], Stroke::new(1.2, tk.accent));
- let r = painter.text(q + egui::vec2(12.0, -12.0), egui::Align2::LEFT_BOTTOM, label, egui::FontId::proportional(12.0), tk.text);
+ let r = painter.text(
+ q + egui::vec2(12.0, -12.0),
+ egui::Align2::LEFT_BOTTOM,
+ label,
+ egui::FontId::proportional(crate::theme::Tokens::get().font_body),
+ tk.text,
+ );
painter.rect_filled(r.expand(3.0), 3.0, tk.panel.gamma_multiply(0.85));
- painter.text(q + egui::vec2(12.0, -12.0), egui::Align2::LEFT_BOTTOM, label, egui::FontId::proportional(12.0), tk.text);
+ painter.text(
+ q + egui::vec2(12.0, -12.0),
+ egui::Align2::LEFT_BOTTOM,
+ label,
+ egui::FontId::proportional(crate::theme::Tokens::get().font_body),
+ tk.text,
+ );
}
});
}
@@ -1248,7 +1260,13 @@ fn glyphs(app: &SolveApp, painter: &egui::Painter, proj: &Proj, hover: Option<Po
match pattern_icon.or_else(|| glyph_icon(c.kind.name())) {
Some(icon) => crate::icons::paint(painter, r.shrink(2.0), icon, col, tk.glyph_bg, col),
None => {
- painter.text(*sp, egui::Align2::CENTER_CENTER, glyph_letter(c.kind.name()), egui::FontId::proportional(10.5), col);
+ painter.text(
+ *sp,
+ egui::Align2::CENTER_CENTER,
+ glyph_letter(c.kind.name()),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_panel),
+ col,
+ );
}
}
drawn.push((id.clone(), *sp));
@@ -1262,7 +1280,7 @@ fn glyphs(app: &SolveApp, painter: &egui::Painter, proj: &Proj, hover: Option<Po
format!("{} ({id})", c.kind.name())
};
let at = h + egui::vec2(12.0, 12.0);
- let g = painter.layout_no_wrap(label, egui::FontId::proportional(11.0), tk.text);
+ let g = painter.layout_no_wrap(label, egui::FontId::proportional(crate::theme::Tokens::get().font_small), tk.text);
painter.rect_filled(egui::Rect::from_min_size(at, g.size()).expand(3.0), 3.0, tk.panel);
painter.galley(at, g, tk.text);
}
@@ -1344,7 +1362,7 @@ fn snap_hint(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
let tk = crate::theme::Tokens::get();
let r = egui::Rect::from_min_size(sp + egui::vec2(12.0, -24.0), egui::vec2(24.0, 14.0));
painter.rect_filled(r, 3.0, tk.accent_soft);
- painter.text(r.center(), egui::Align2::CENTER_CENTER, label, egui::FontId::proportional(10.0), tk.text);
+ painter.text(r.center(), egui::Align2::CENTER_CENTER, label, egui::FontId::proportional(crate::theme::Tokens::get().font_micro), tk.text);
}
/// Per frame, after the viewport is drawn: constraint glyphs, snap hints and analysis marks.
diff --git a/crates/ui-egui/src/space_mouse.rs b/crates/ui-egui/src/space_mouse.rs
index fbd61fc48f..c2295ce67e 100644
--- a/crates/ui-egui/src/space_mouse.rs
+++ b/crates/ui-egui/src/space_mouse.rs
@@ -234,7 +234,7 @@ mod tests {
/// A window that has run a frame, with or without focus. A context that has never run one
/// reads as unfocused, so the tests run one first, as the app always has.
fn window(focused: bool) -> egui::Context {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut output = ctx.run_ui(egui::RawInput { focused, ..Default::default() }, |_| {});
output.textures_delta.clear();
ctx
diff --git a/crates/ui-egui/src/sweep_dialog_tests.rs b/crates/ui-egui/src/sweep_dialog_tests.rs
index 60c54b00ba..75f2eb7d68 100644
--- a/crates/ui-egui/src/sweep_dialog_tests.rs
+++ b/crates/ui-egui/src/sweep_dialog_tests.rs
@@ -25,6 +25,7 @@ fn a_new_sweep_takes_its_options_from_the_dialog() {
let sketch = setup(&mut h);
h.step(&json!({"call":"ui.start","params":{"command":"solid.sweep"}})).unwrap();
h.frames(3);
+ h.step(&json!({"click":{"handle":"dialog:section:Advanced"}})).unwrap();
assert!(h.widget("Twist").is_some() && h.widget("End Scale").is_some() && h.widget("Orientation").is_some());
let d = h.app.dialog.as_mut().unwrap();
d.inputs[0].items = vec![Sel::Profile { sketch, index: 0 }];
@@ -112,6 +113,7 @@ fn a_rail_picked_in_the_dialog_is_kept_through_an_edit() {
let rail_sketch = h.app.session.doc.find_feature("R").unwrap().id;
h.step(&json!({"call":"ui.start","params":{"command":"solid.sweep"}})).unwrap();
h.frames(3);
+ h.step(&json!({"click":{"handle":"dialog:section:Advanced"}})).unwrap();
assert!(h.widget("Rail Fit").is_some());
let d = h.app.dialog.as_mut().unwrap();
d.inputs[0].items = vec![Sel::Profile { sketch, index: 0 }];
diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs
index 54e3a70ced..d4b02b8f63 100644
--- a/crates/ui-egui/src/theme.rs
+++ b/crates/ui-egui/src/theme.rs
@@ -48,6 +48,18 @@ pub(crate) struct TabAccent {
pub soft: Color32,
}
+/// The foreground of a selected element on its tinted background: light blue in the dark theme,
+/// a darker blue in the light theme. Other accents (Sketch green…) get the same treatment.
+pub(crate) fn selected_ink(t: &Tokens, accent: Color32) -> Color32 {
+ if accent == t.accent {
+ t.selected_ink
+ } else if is_dark() {
+ accent.lerp_to_gamma(t.on_accent, 0.5)
+ } else {
+ accent.lerp_to_gamma(Color32::BLACK, 0.3)
+ }
+}
+
impl TabAccent {
pub fn for_tab(t: &Tokens, tab: &str) -> Self {
let color = match tab {
@@ -242,6 +254,61 @@ pub struct Tokens {
pub font_label: f32,
pub font_button: f32,
pub font_heading: f32,
+ /// Tiny world-axis triad letters.
+ pub font_triad: f32,
+ /// Bold letters on the navigation compass discs.
+ pub font_compass: f32,
+ /// Home section titles, home actions and update titles.
+ pub font_subtitle: f32,
+ /// Introductory text on the home page.
+ pub font_intro: f32,
+ /// Top-level headings in assistant Markdown.
+ pub font_article_heading: f32,
+ /// Application title in the About dialog.
+ pub font_title: f32,
+ /// Application name on the home page.
+ pub font_display: f32,
+ /// Height of dense form controls and rows.
+ pub control_height: f32,
+ /// Corner radius of dense form controls and actions.
+ pub control_radius: u8,
+ /// Width of the dense form label column.
+ pub form_label_width: f32,
+ /// Vertical gap between dense form rows.
+ pub form_gap_y: f32,
+ /// Height of the full-width dense form footer.
+ pub form_footer_height: f32,
+ /// Height of the dense form header.
+ pub form_header_height: f32,
+ /// Outer width of a dense feature card.
+ pub form_card_width: f32,
+ /// Size of the icon in a dense form header.
+ pub form_icon_size: f32,
+ /// Size of the dense form close button.
+ pub form_close_size: f32,
+ /// Text inset in controls and gap after the header icon.
+ pub form_inset: f32,
+ /// Inset of artwork inside a dense form icon button.
+ pub form_icon_inset: f32,
+ /// Size of the section disclosure chevron.
+ pub form_section_icon_size: f32,
+ /// Height of a dense form checkbox row.
+ pub form_checkbox_height: f32,
+ /// Minimum height of a dense form footer action.
+ pub form_button_height: f32,
+ /// Outer width of the sketch options card.
+ pub sketch_palette_width: f32,
+ /// Square creation-mode button size and radius.
+ pub sketch_mode_size: f32,
+ pub sketch_mode_radius: u8,
+ pub sketch_mode_border: f32,
+ /// Opacity of the sketch card and its selected accent tint.
+ pub sketch_palette_alpha: f32,
+ pub sketch_mode_tint: f32,
+ /// Footer navigation icon size.
+ pub sketch_footer_icon_size: f32,
+ /// Extra section heading letter spacing as a fraction of font size.
+ pub font_section_tracking: f32,
pub app_bar: Color32,
/// Dividers between the application bar groups.
pub app_bar_separator: Color32,
@@ -367,6 +434,16 @@ pub struct Tokens {
pub app_bar_hover_strong: Color32,
/// The active document tab: a solid surface lifted from the bar.
pub app_bar_tab_active: Color32,
+ /// Dense feature dialogs: the body surface, the footer band, the dividers, input controls
+ /// (fill and border), field labels, and the selected-element foreground and background.
+ pub dialog_body: Color32,
+ pub dialog_footer: Color32,
+ pub dialog_rule: Color32,
+ pub control_fill: Color32,
+ pub control_border: Color32,
+ pub dialog_label: Color32,
+ pub selected_ink: Color32,
+ pub selected_bg: Color32,
/// Timeline items: normal and failed.
pub timeline_item: Color32,
pub timeline_item_error: Color32,
@@ -519,8 +596,8 @@ mod tests {
fn tab_accent_context_is_per_app_and_does_not_change_widget_visuals() {
let mut harness = crate::scenario::Harness::new();
let app = &mut harness.app;
- let first = egui::Context::default();
- let second = egui::Context::default();
+ let first = crate::fonts::test_context();
+ let second = crate::fonts::test_context();
let before = first.style_of(egui::Theme::Dark).visuals.clone();
app.ui.tab = "SURFACE".into();
super::TabAccent::publish(app, &first);
@@ -563,7 +640,7 @@ mod tests {
#[test]
fn active_movable_window_header_uses_theme_panel_header() {
for dark in [false, true] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
ctx.set_theme(if dark { egui::Theme::Dark } else { egui::Theme::Light });
ctx.set_visuals(super::visuals(dark));
let mut output = egui::FullOutput::default();
diff --git a/crates/ui-egui/src/theme_files.rs b/crates/ui-egui/src/theme_files.rs
index c5566856d3..cecd28ff63 100644
--- a/crates/ui-egui/src/theme_files.rs
+++ b/crates/ui-egui/src/theme_files.rs
@@ -81,10 +81,15 @@ macro_rules! theme_keys {
let Tokens {
$($one: _,)* $($many: _,)*
hover_face_lift: _, analysis: _, icons: _,
- space_2: _, space_3: _, space_4: _, space_6: _, space_8: _, space_10: _, space_12: _, space_14: _, space_16: _, space_24: _,
- radius_sm: _, radius_md: _, radius_lg: _, radius_xl: _,
- font_badge: _, font_micro: _, font_panel: _, font_small: _, font_caption: _, font_body: _, font_label: _, font_button: _,
- font_heading: _,
+ space_2: _, space_3: _, space_4: _, space_6: _, space_8: _, space_10: _,
+ space_12: _, space_14: _, space_16: _, space_24: _, radius_sm: _, radius_md: _,
+ radius_lg: _, radius_xl: _, font_badge: _, font_micro: _, font_panel: _, font_small: _,
+ font_caption: _, font_body: _, font_label: _, font_button: _, font_heading: _, font_triad: _,
+ font_compass: _, font_subtitle: _, font_intro: _, font_article_heading: _, font_title: _, font_display: _,
+ control_height: _, control_radius: _, form_label_width: _, form_gap_y: _, form_footer_height: _, form_header_height: _,
+ form_card_width: _, form_icon_size: _, form_close_size: _, form_inset: _, form_icon_inset: _, form_section_icon_size: _,
+ form_checkbox_height: _, form_button_height: _, sketch_palette_width: _, sketch_mode_size: _, sketch_mode_radius: _, sketch_mode_border: _,
+ sketch_palette_alpha: _, sketch_mode_tint: _, sketch_footer_icon_size: _, font_section_tracking: _,
} = t;
let IconColors { $($ione: _,)* $($imany: _,)* } = &t.icons;
}
@@ -105,6 +110,7 @@ theme_keys! {
sketch_construction, sketch_centerline, bend_up, bend_down, interference,
app_bar_separator, surface_accent, mesh_accent, form_accent, render_accent, on_accent, agent_ok, agent_busy, app_bar_hover_subtle,
app_bar_hover_button, app_bar_hover_strong, app_bar_tab_active,
+ dialog_body, dialog_footer, dialog_rule, control_fill, control_border, dialog_label, selected_ink, selected_bg,
],
many: [triad, gizmo, continuity, app_bar_icon, logo],
icons_one: [
diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rs
index 389951a277..95fa228ddc 100644
--- a/crates/ui-egui/src/timeline.rs
+++ b/crates/ui-egui/src/timeline.rs
@@ -196,12 +196,12 @@ pub(crate) fn copy_targets(app: &SolveApp, id: u64) -> Vec<u64> {
/// Copy and Paste in a feature's timeline menu. Paste puts the copies at the history marker.
pub(crate) fn clipboard_buttons(app: &mut SolveApp, ui: &mut egui::Ui, id: u64) {
- if ui.button(crate::i18n::tr_label("Copy")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Copy"), "copy").clicked() {
let features = copy_targets(app, id);
let _ = app.run("timeline.copy", json!({ "features": features }));
ui.close();
}
- if ui.add_enabled(!app.session.clipboard.is_empty(), egui::Button::new(crate::i18n::tr_label("Paste"))).clicked() {
+ if crate::context_menu::button_enabled(ui, crate::i18n::tr_label("Paste"), "paste", !app.session.clipboard.is_empty()).clicked() {
let _ = app.run("timeline.paste", json!({}));
ui.close();
}
@@ -230,7 +230,7 @@ pub(crate) fn message_button(app: &SolveApp, ui: &mut egui::Ui, id: u64) {
let Some(text) = feature_message(app, id) else { return };
let failed = app.session.model.result(id).is_some_and(|r| r.error.is_some());
let label = if failed { "Copy Error Message" } else { "Copy Warning Message" };
- if ui.button(crate::i18n::tr_label(label)).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label(label), "copy").clicked() {
ui.ctx().copy_text(text);
ui.close();
}
@@ -450,29 +450,29 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
}
let sketch_of = kind.profile_sketch();
resp.context_menu(|ui| {
- if ui.button(crate::i18n::tr_label("Edit Feature")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Edit Feature"), "edit").clicked() {
edit = Some(*id);
ui.close();
}
if let Some(sk) = sketch_of
- && ui.button(crate::i18n::tr_label("Edit Profile Sketch")).clicked()
+ && crate::context_menu::button(ui, crate::i18n::tr_label("Edit Profile Sketch"), "sketch").clicked()
{
app.edit_sketch(sk.0);
ui.close();
}
- if ui.button(crate::i18n::tr_label("Rename")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Rename"), "rename").clicked() {
app.dialog = Some(crate::dialogs::Dialog::rename(*id, name));
ui.close();
}
- if ui.button(if *suppressed { "Unsuppress Features" } else { "Suppress Features" }).clicked() {
+ if crate::context_menu::button(ui, if *suppressed { "Unsuppress Features" } else { "Suppress Features" }, "suppress").clicked() {
let _ = app.run_heavy("timeline.suppress", json!({"feature": id}));
ui.close();
}
- if ui.button(crate::i18n::tr_label("Roll History Marker Here")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Roll History Marker Here"), "rollback").clicked() {
let _ = app.run_heavy("timeline.roll_to", json!({ "feature": id }));
ui.close();
}
- if ui.button(crate::i18n::tr_label("Find in Browser")).clicked() {
+ if crate::context_menu::button(ui, crate::i18n::tr_label("Find in Browser"), "list").clicked() {
find_in_browser(app, *id);
ui.close();
}
@@ -480,7 +480,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
clipboard_buttons(app, ui, *id);
message_button(app, ui, *id);
ui.separator();
- if ui.button("Delete").clicked() {
+ if crate::context_menu::button(ui, "Delete", "delete").clicked() {
delete_feature(app, *id);
ui.close();
}
@@ -829,7 +829,7 @@ mod tests {
h.app.ui.tab = "SURFACE".into();
let t = crate::theme::Tokens::get();
let accent = crate::theme::TabAccent::for_tab(&t, "SURFACE");
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| super::timeline(&mut h.app, ui));
out.textures_delta.clear();
let texts: Vec<_> = out
diff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rs
index c4428dab69..7301711aae 100644
--- a/crates/ui-egui/src/timeline_left.rs
+++ b/crates/ui-egui/src/timeline_left.rs
@@ -1,5 +1,6 @@
//! The left feature-history panel: named rows, folders, rollback and drag-and-drop.
+use crate::fonts::RichTextExt as _;
use egui::{Color32, Rect, RichText, Sense, Stroke, pos2, vec2};
use serde_json::json;
@@ -73,8 +74,11 @@ pub fn left_timeline(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let groups = app.session.doc.timeline_groups.clone();
ui.horizontal(|ui| {
- ui.set_min_height(22.0);
- ui.label(RichText::new("FEATURE HISTORY").size(11.0).strong().color(t.text_dim));
+ // Reserve the selection menu's measured height even when no features are selected.
+ let font = egui::TextStyle::Button.resolve(ui.style());
+ let menu_height = ui.fonts_mut(|fonts| fonts.row_height(&font)) + 2.0 * ui.spacing().button_padding.y;
+ ui.set_min_height(menu_height.ceil().max(22.0));
+ ui.label(RichText::new("FEATURE HISTORY").size(crate::theme::Tokens::get().font_small).semibold().color(t.text_dim));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let count = selected_feature_ids(app).len() + app.tree.picked_timeline_groups.len();
if count > 0 {
@@ -314,7 +318,7 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
let selected_groups = app.tree.picked_timeline_groups.clone();
let has_selection = !features.is_empty() || !selected_groups.is_empty();
if has_selection {
- if ui.button("Add to New Folder").clicked() {
+ if crate::context_menu::button(ui, "Add to New Folder", "folder").clicked() {
let result = app.run("timeline.group", json!({"features": features, "groups": selected_groups}));
if let Ok(result) = result
&& let Some(group) = result.get("group").and_then(serde_json::Value::as_u64)
@@ -325,7 +329,7 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
ui.close();
}
let grouped = features.iter().any(|feature| group_for(groups, *feature).is_some()) || !selected_groups.is_empty();
- if grouped && ui.button("Remove from Folder").clicked() {
+ if grouped && crate::context_menu::button(ui, "Remove from Folder", "folder").clicked() {
let mut params = json!({"group": null});
if !features.is_empty() {
params["features"] = json!(features);
@@ -341,7 +345,10 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
if !features.is_empty() || !selected_groups.is_empty() {
ui.separator();
}
- if ui.button("Delete Selected Folders").on_hover_text("Keep their features and nested folders in the history").clicked() {
+ if crate::context_menu::button(ui, "Delete Selected Folders", "delete")
+ .on_hover_text("Keep their features and nested folders in the history")
+ .clicked()
+ {
let ids = app.tree.picked_timeline_groups.clone();
let _ = app.run("timeline.ungroup", json!({"groups": ids}));
app.tree.picked_timeline_groups.clear();
@@ -350,7 +357,7 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
}
if !features.is_empty() {
ui.separator();
- if ui.button("Delete Selected Features…").clicked() {
+ if crate::context_menu::button(ui, "Delete Selected Features…", "delete").clicked() {
delete_features(app, features);
ui.close();
}
@@ -498,7 +505,7 @@ fn timeline_group_name(
pos2(rect.left() + 40.0 + offset, rect.center().y),
egui::Align2::LEFT_CENTER,
&group.name,
- egui::FontId::proportional(12.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_body),
t.text,
);
return false;
@@ -602,7 +609,7 @@ fn vertical_group_row(
select_only(app, TimelineItem::Group(group.id));
}
response.context_menu(|ui| {
- if ui.button("Rename Folder").clicked() {
+ if crate::context_menu::button(ui, "Rename Folder", "rename").clicked() {
crate::context_menu::start_rename(app, crate::context_menu::RenameWhat::TimelineGroup(group.id), rect.center());
ui.close();
}
@@ -733,7 +740,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui) {
pos2(icon_rect.right() + 7.0, rect.center().y),
egui::Align2::LEFT_CENTER,
name,
- egui::FontId::proportional(12.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_body),
text_colour,
);
// A failed feature has a mark of its own, not only its colour (#972).
@@ -783,25 +790,25 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui) {
select_only(app, TimelineItem::Feature(*id));
}
response.context_menu(|ui| {
- if ui.button("Edit Feature").clicked() {
+ if crate::context_menu::button(ui, "Edit Feature", "edit").clicked() {
edit = Some(*id);
ui.close();
}
if let Some(sketch) = sketch
- && ui.button("Edit Profile Sketch").clicked()
+ && crate::context_menu::button(ui, "Edit Profile Sketch", "sketch").clicked()
{
app.edit_sketch(sketch.0);
ui.close();
}
- if ui.button("Rename Feature").clicked() {
+ if crate::context_menu::button(ui, "Rename Feature", "rename").clicked() {
crate::context_menu::start_rename(app, crate::context_menu::RenameWhat::Feature(*id), rect.center());
ui.close();
}
- if ui.button(if *suppressed { "Unsuppress Feature" } else { "Suppress Feature" }).clicked() {
+ if crate::context_menu::button(ui, if *suppressed { "Unsuppress Feature" } else { "Suppress Feature" }, "suppress").clicked() {
let _ = app.run_heavy("timeline.suppress", json!({"feature": id}));
ui.close();
}
- if ui.button("Roll Back Here").clicked() {
+ if crate::context_menu::button(ui, "Roll Back Here", "rollback").clicked() {
let _ = app.run_heavy("timeline.roll_to", json!({"feature": id}));
ui.close();
}
@@ -811,7 +818,7 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui) {
ui.separator();
selection_actions(app, ui, &groups);
ui.separator();
- if ui.button("Delete").clicked() {
+ if crate::context_menu::button(ui, "Delete", "delete").clicked() {
delete_feature(app, *id);
ui.close();
}
diff --git a/crates/ui-egui/src/timeline_marks_tests.rs b/crates/ui-egui/src/timeline_marks_tests.rs
index 7406d782d8..1cce7c8b11 100644
--- a/crates/ui-egui/src/timeline_marks_tests.rs
+++ b/crates/ui-egui/src/timeline_marks_tests.rs
@@ -32,7 +32,7 @@ fn features(app: &SolveApp) -> Vec<(String, bool)> {
/// (the sample has no warnings, so every such image is an error mark).
fn error_discs(app: &mut SolveApp, draw: fn(&mut SolveApp, &mut egui::Ui)) -> Vec<Pos2> {
crate::scenario::clear_handles();
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let screen = Rect::from_min_size(Pos2::ZERO, vec2(1400.0, 900.0));
let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| draw(app, ui));
// Icons upload textures; dropping their deltas unapplied would panic.
diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rs
index 6109e48471..cdbf11214f 100644
--- a/crates/ui-egui/src/titlebar.rs
+++ b/crates/ui-egui/src/titlebar.rs
@@ -220,7 +220,7 @@ mod tests {
impl Win {
fn new(width: f32) -> Self {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(Session::default(), Default::default());
app.custom_titlebar = true;
Self { ctx, app, width, time: 0.0, maximized: false, full: false }
diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs
index 3379cb4fe5..e2fb8ffc6f 100644
--- a/crates/ui-egui/src/toolbar.rs
+++ b/crates/ui-egui/src/toolbar.rs
@@ -1,5 +1,6 @@
//! Application bar, the workspace toolbar (tabs and panels) and keyboard shortcuts.
+use crate::fonts::RichTextExt as _;
use crate::icons::glyphs::pin_icon;
use egui::{Align2, Color32, FontId, Rect, Sense, Stroke, pos2, vec2};
use serde_json::json;
@@ -291,7 +292,7 @@ pub fn app_bar(app: &mut SolveApp, ui: &mut egui::Ui) {
pos2(left + 36.0, r.center().y),
Align2::LEFT_CENTER,
"SolidCraft",
- FontId::proportional(t.font_heading),
+ crate::fonts::semibold(t.font_heading),
t.app_bar_text,
);
}
@@ -488,17 +489,17 @@ fn file_menu(app: &mut SolveApp, ctx: &egui::Context) {
ui.visuals_mut().widgets.inactive.weak_bg_fill = Color32::TRANSPARENT;
ui.visuals_mut().widgets.inactive.bg_stroke = Stroke::NONE;
ui.visuals_mut().widgets.hovered.weak_bg_fill = Tokens::get().hover;
- let item_if = |ui: &mut egui::Ui, label: &str, key: &str, enabled: bool| {
- ui.add_enabled(enabled, egui::Button::new(label).shortcut_text(key).min_size(vec2(180.0, 22.0))).clicked()
+ let item_if = |ui: &mut egui::Ui, label: &str, key: &str, icon: &str, enabled: bool| {
+ crate::context_menu::list_row(ui, &crate::context_menu::Item::action(label, label, icon).key(key).on_if(enabled)).is_some()
};
- let item = |ui: &mut egui::Ui, label: &str, key: &str| item_if(ui, label, key, true);
+ let item = |ui: &mut egui::Ui, label: &str, key: &str, icon: &str| item_if(ui, label, key, icon, true);
// Insert, Save and Export act on the design, which Home hides.
let shown = design_shown(app);
- if item(ui, app.tr("ui.new_design"), "Ctrl+N") {
+ if item(ui, app.tr("ui.new_design"), "Ctrl+N", "new") {
crate::documents::new_design(app);
close = true;
}
- if item(ui, &format!("{}…", app.tr("ui.open")), "Ctrl+O") {
+ if item(ui, &format!("{}…", app.tr("ui.open")), "Ctrl+O", "open") {
app.pick_open(|app, path| {
if let Some(path) = path {
app.open_path_async(&path);
@@ -510,41 +511,41 @@ fn file_menu(app: &mut SolveApp, ctx: &egui::Context) {
for path in app.home.recent.clone() {
let missing = !solidcraft_engine::io::vfs::exists(&path);
let label = format!("{path}{}", if missing { " (missing)" } else { "" });
- if ui.button(label).clicked() {
+ if crate::context_menu::button(ui, &label, "open").clicked() {
crate::home::open_recent(app, &path);
close = true;
ui.close();
}
}
ui.separator();
- if ui.button(app.tr("ui.clear_recent")).clicked() {
+ if crate::context_menu::button(ui, app.tr("ui.clear_recent"), "delete").clicked() {
app.home.recent.clear();
app.home.opened_at.clear();
close = true;
ui.close();
}
});
- if item_if(ui, "Insert STEP…", "", shown) {
+ if item_if(ui, "Insert STEP…", "", "import", shown) {
app.start("file.insert_step");
close = true;
}
- if item_if(ui, "Insert Mesh…", "", shown) {
+ if item_if(ui, "Insert Mesh…", "", "import", shown) {
app.start("file.insert_mesh");
close = true;
}
- if item_if(ui, &format!("{}…", app.tr_label("Insert Design")), "", shown) {
+ if item_if(ui, &format!("{}…", app.tr_label("Insert Design")), "", "component", shown) {
app.start("component.insert_design");
close = true;
}
- if item_if(ui, app.tr("ui.save"), "Ctrl+S", shown) {
+ if item_if(ui, app.tr("ui.save"), "Ctrl+S", "save", shown) {
save(app);
close = true;
}
- if item_if(ui, &format!("{}…", app.tr("ui.save_as")), "", shown) {
+ if item_if(ui, &format!("{}…", app.tr("ui.save_as")), "", "save", shown) {
save_as(app);
close = true;
}
- if item(ui, "Save As JSON…", "") {
+ if item(ui, "Save As JSON…", "", "save") {
save_as_with_extension(app, "json");
close = true;
}
@@ -560,56 +561,55 @@ fn file_menu(app: &mut SolveApp, ctx: &egui::Context) {
close = true;
}
ui.separator();
- if item_if(ui, "Save as mesh…", "", shown) {
+ if item_if(ui, "Save as mesh…", "", "mesh_export", shown) {
app.start("file.save_mesh");
close = true;
}
- if item_if(ui, "Export STEP…", "", shown) {
+ if item_if(ui, "Export STEP…", "", "export", shown) {
export(app, "step");
close = true;
}
- if item_if(ui, app.tr_label("Export Current View as DXF…"), "", shown) {
+ if item_if(ui, app.tr_label("Export Current View as DXF…"), "", "export", shown) {
app.start("file.export_view_dxf");
close = true;
}
- if item_if(ui, "Export OBJ…", "", shown) {
+ if item_if(ui, "Export OBJ…", "", "export", shown) {
export(app, "obj");
close = true;
}
- if item_if(ui, "Export URDF…", "", shown) {
+ if item_if(ui, "Export URDF…", "", "export", shown) {
export(app, "urdf");
close = true;
}
- if item(ui, "Export Design as JSON…", "") {
+ if item(ui, "Export Design as JSON…", "", "export") {
export(app, "json");
close = true;
}
ui.separator();
- if item_if(ui, &format!("{}…", app.tr_label("Design Properties")), "", shown) {
+ if item_if(ui, &format!("{}…", app.tr_label("Design Properties")), "", "settings", shown) {
app.start("document.metadata");
close = true;
}
ui.separator();
// The browser can install SolidCraft as an app (`install`): only while it offers to.
if let Some(offer) = crate::install::offered(app)
- && ui
- .add(egui::Button::new(crate::i18n::tr("install.menu")).min_size(vec2(180.0, 22.0)))
+ && crate::context_menu::button(ui, crate::i18n::tr("install.menu"), "new")
.on_hover_text(crate::i18n::tr("install.button_tip"))
.clicked()
{
crate::install::start(app, offer);
close = true;
}
- if item(ui, &format!("{}…", app.tr("ui.preferences")), "") {
+ if item(ui, &format!("{}…", app.tr("ui.preferences")), "", "settings") {
app.prefs_window.open = true;
close = true;
}
- if item(ui, &format!("{}…", app.tr("ui.keyboard_shortcuts")), "") {
+ if item(ui, &format!("{}…", app.tr("ui.keyboard_shortcuts")), "", "list") {
app.keymap.open = true;
app.keymap.read_only = false;
close = true;
}
- if item(ui, app.tr("ui.quit"), "") {
+ if item(ui, app.tr("ui.quit"), "", "close") {
crate::documents::request_quit(app);
close = true;
}
@@ -709,7 +709,8 @@ fn ribbon_button_lines(painter: &egui::Painter, label: &str, width: f32) -> Vec<
}
fn ribbon_label_width(painter: &egui::Painter, text: &str) -> f32 {
- let mut job = egui::text::LayoutJob::simple(text.to_owned(), FontId::proportional(12.0), Color32::WHITE, f32::INFINITY);
+ let mut job =
+ egui::text::LayoutJob::simple(text.to_owned(), FontId::proportional(crate::theme::Tokens::get().font_body), Color32::WHITE, f32::INFINITY);
job.halign = egui::Align::Center;
painter.layout_job(job).size().x
}
@@ -745,7 +746,7 @@ fn ribbon_label_lines(painter: &egui::Painter, label: &str, width: f32) -> Vec<S
fn ribbon_button_galley(painter: &egui::Painter, label: &str, width: f32, color: Color32) -> std::sync::Arc<egui::Galley> {
let lines = ribbon_button_lines(painter, label, width);
// Explicit newlines only: egui must never split an oversized word.
- let mut job = egui::text::LayoutJob::simple(lines.join("\n"), FontId::proportional(12.0), color, f32::INFINITY);
+ let mut job = egui::text::LayoutJob::simple(lines.join("\n"), FontId::proportional(crate::theme::Tokens::get().font_body), color, f32::INFINITY);
job.halign = egui::Align::Center;
painter.layout_job(job)
}
@@ -768,15 +769,12 @@ fn ribbon_label(app: &SolveApp, label: &str) -> String {
fn ribbon_text(ui: &egui::Ui, at: egui::Pos2, text: &str, size: f32, color: Color32, bold: bool) {
let text = egui::RichText::new(text).size(size).color(color);
- let text = if bold { text.strong() } else { text };
+ let text = if bold { text.semibold() } else { text };
let galley = egui::WidgetText::from(text).into_galley(ui, Some(egui::TextWrapMode::Extend), f32::INFINITY, egui::TextStyle::Button);
let origin = at - galley.size() / 2.0;
- // egui's `strong` only changes colour. A small overstrike adds weight while retaining
- // the user's interface font and its language fallbacks, without another font asset.
- if bold {
- ui.painter().galley(origin - vec2(0.2, 0.0), galley.clone(), color);
- }
- ui.painter().galley(origin + vec2(if bold { 0.2 } else { 0.0 }, 0.0), galley, color);
+ let ppp = ui.ctx().pixels_per_point().max(0.5);
+ let origin = pos2((origin.x * ppp).round() / ppp, (origin.y * ppp).round() / ppp);
+ ui.painter().galley(origin, galley, color);
}
/// The ribbon and S shortcut share one popup anchor, including after resizing.
@@ -787,8 +785,13 @@ fn search_anchor(ctx: &egui::Context) -> Option<egui::Pos2> {
fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) {
let t = Tokens::get();
let tabs = crate::workspace::visible_tabs(app);
- let widths: Vec<_> =
- tabs.iter().map(|tab| ui.painter().layout_no_wrap(ribbon_label(app, tab), FontId::proportional(13.0), t.text).size().x + 24.0).collect();
+ let widths: Vec<_> = tabs
+ .iter()
+ .map(|tab| {
+ ui.painter().layout_no_wrap(ribbon_label(app, tab), crate::fonts::semibold(crate::theme::Tokens::get().font_button), t.text).size().x
+ + 24.0
+ })
+ .collect();
let tabs_width: f32 = widths.iter().sum::<f32>()
+ tabs.len().saturating_sub(1) as f32 * 2.0
+ tabs.iter().filter(|tab| matches!(**tab, "SKETCH" | "SHEET METAL")).count() as f32 * 6.0;
@@ -811,10 +814,16 @@ fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) {
icons::paint_icon(ui.painter(), Rect::from_center_size(search.left_center() + vec2(12.0, 0.0), vec2(16.0, 16.0)), "zoom", 1.0);
let label = app.tr_label("Search commands");
if search_width > 24.0 {
- ui.painter().text(search.left_center() + vec2(29.0, 0.0), Align2::LEFT_CENTER, label, FontId::proportional(12.5), t.text_dim);
+ ui.painter().text(
+ search.left_center() + vec2(29.0, 0.0),
+ Align2::LEFT_CENTER,
+ label,
+ FontId::proportional(crate::theme::Tokens::get().font_label),
+ t.text_dim,
+ );
let cap = Rect::from_center_size(search.right_center() - vec2(14.0, 0.0), vec2(16.0, 16.0));
ui.painter().rect(cap, 3.0, t.toolbar, Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
- ribbon_text(ui, cap.center(), "S", 11.0, t.text_dim, false);
+ ribbon_text(ui, cap.center(), "S", t.font_small, t.text_dim, false);
}
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, label));
if resp.on_hover_text(label).clicked() {
@@ -865,7 +874,7 @@ fn ribbon_tabs(app: &mut SolveApp, ui: &mut egui::Ui, row: Rect) {
ui,
tr.center(),
&ribbon_label(app, tab),
- 13.0,
+ t.font_button,
if contextual {
t.on_accent
} else if active {
@@ -914,9 +923,9 @@ fn chevron(painter: &egui::Painter, at: egui::Pos2, ink: Color32) {
crate::icons::paint_ink(painter, Rect::from_center_size(at, vec2(10.0, 10.0)), "chevron", ink);
}
-/// The label colour on a selected tab or open section: on the dark ribbon a lighter tint of the accent.
+/// The label colour on a selected tab or open section.
fn selected_ink(accent: &crate::theme::TabAccent) -> Color32 {
- if crate::theme::is_dark() { accent.color.lerp_to_gamma(Tokens::get().on_accent, 0.5) } else { accent.color }
+ crate::theme::selected_ink(&Tokens::get(), accent.color)
}
pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
@@ -962,10 +971,11 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
let render = crate::render_workspace::active(app);
let workspace_icon = if render { "ws_render" } else { "ws_design" };
icons::paint_icon(&painter, Rect::from_center_size(pos2(ws.center().x, ws.top() + 39.0), vec2(30.0, 30.0)), workspace_icon, 1.0);
- ribbon_text(ui, pos2(ws.center().x, ws.top() + 69.0), app.tr(if render { "ui.render" } else { "ui.design" }), 13.0, t.text, true);
+ ribbon_text(ui, pos2(ws.center().x, ws.top() + 69.0), app.tr(if render { "ui.render" } else { "ui.design" }), t.font_button, t.text, true);
let label = app.tr("ui.ribbon_workspace");
- let label_width = painter.layout_no_wrap(label.to_string(), FontId::proportional(11.0), t.text_dim).size().x;
- ribbon_text(ui, pos2(ws.center().x - 6.0, ws.top() + 89.0), label, 11.0, t.text_dim, false);
+ let label_width =
+ painter.layout_no_wrap(label.to_string(), FontId::proportional(crate::theme::Tokens::get().font_small), t.text_dim).size().x;
+ ribbon_text(ui, pos2(ws.center().x - 6.0, ws.top() + 89.0), label, t.font_small, t.text_dim, false);
chevron(&painter, pos2(ws.center().x - 6.0 + label_width / 2.0 + 7.0, ws.top() + 89.5), t.text_dim);
if wresp.on_hover_text(app.tr("ui.change_workspace")).clicked() {
crate::context_menu::toggle_for(app, ws, ws.left_bottom(), crate::context_menu::Target::Workspace);
@@ -1249,9 +1259,14 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
painter.rect_filled(lr, 4.0, if panel_open { accent.soft } else { t.hover });
}
let label = if finish { app.tr("ui.ribbon_exit").to_string() } else { ribbon_label(app, panel) };
- let label_width = painter.layout_no_wrap(label.clone(), FontId::proportional(11.5), t.text_dim).size().x;
+ let font = if panel_open || hot {
+ crate::fonts::semibold(crate::theme::Tokens::get().font_caption)
+ } else {
+ FontId::proportional(crate::theme::Tokens::get().font_caption)
+ };
+ let label_width = painter.layout_no_wrap(label.clone(), font, t.text_dim).size().x;
let ink = if panel_open { selected_ink(&accent) } else { t.text_dim };
- ribbon_text(ui, lr.center() - vec2(if finish { 0.0 } else { 6.0 }, 0.0), &label, 11.5, ink, panel_open || hot);
+ ribbon_text(ui, lr.center() - vec2(if finish { 0.0 } else { 6.0 }, 0.0), &label, t.font_caption, ink, panel_open || hot);
if !finish {
chevron(&painter, pos2(lr.center().x + label_width / 2.0 + 1.0, lr.center().y + 0.5), ink);
}
@@ -1378,7 +1393,18 @@ pub fn toolbar(app: &mut SolveApp, ui: &mut egui::Ui) {
}
for c in cmds {
let info = c.info(&app.session);
- let response = ui.add_enabled(info.enabled, egui::Button::new(c.label).shortcut_text(c.shortcut.unwrap_or("")));
+ let response = ui
+ .add_enabled_ui(info.enabled, |ui| {
+ let icon = ui.id().with(("overflow_icon", c.id));
+ let row = egui::Button::new((egui::Atom::custom(icon, vec2(16.0, 16.0)), c.label))
+ .shortcut_text(c.shortcut.unwrap_or(""))
+ .atom_ui(ui);
+ if let Some(rect) = row.rect(icon) {
+ icons::paint_icon(ui.painter(), rect, c.icon, if info.enabled { 1.0 } else { 0.35 });
+ }
+ row.response
+ })
+ .inner;
crate::scenario::publish_handle(&format!("toolbar:{}", c.id), response.rect.center());
if response.clicked() {
app.start(c.id);
@@ -1513,15 +1539,18 @@ fn ribbon_tooltip(app: &SolveApp, response: egui::Response, command: &solidcraft
response.on_hover_ui(|ui| {
let t = Tokens::get();
let name = app.tr_label(command.label);
- let name_width = ui.painter().layout_no_wrap(name.to_string(), FontId::proportional(14.0), t.text).size().x;
+ let name_width =
+ ui.painter().layout_no_wrap(name.to_string(), crate::fonts::semibold(crate::theme::Tokens::get().font_heading), t.text).size().x;
let key_width = command
.shortcut
- .map(|key| ui.painter().layout_no_wrap(key.to_string(), FontId::monospace(12.0), t.text_dim).size().x + 24.0)
+ .map(|key| {
+ ui.painter().layout_no_wrap(key.to_string(), FontId::monospace(crate::theme::Tokens::get().font_body), t.text_dim).size().x + 24.0
+ })
.unwrap_or(0.0);
ui.set_width(280.0_f32.max(name_width + key_width + 12.0));
ui.horizontal(|ui| {
let (rect, _) = ui.allocate_exact_size(vec2(name_width, 20.0), Sense::hover());
- ribbon_text(ui, rect.center(), name, 14.0, t.text, true);
+ ribbon_text(ui, rect.center(), name, t.font_heading, t.text, true);
if let Some(key) = command.shortcut {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
egui::Frame::new()
@@ -1561,7 +1590,7 @@ fn section_heading(ui: &mut egui::Ui, label: &str, width: f32) {
rect.left_center() + vec2(6.0, 0.0),
Align2::LEFT_CENTER,
crate::i18n::tr_label(label).to_uppercase(),
- FontId::proportional(11.0),
+ crate::fonts::semibold(crate::theme::Tokens::get().font_small),
t.text_dim,
);
}
@@ -1569,7 +1598,12 @@ fn section_heading(ui: &mut egui::Ui, label: &str, width: f32) {
fn section_footer(ui: &mut egui::Ui) {
ui.separator();
ui.add_space(4.0);
- ui.add(egui::Label::new(egui::RichText::new(crate::i18n::tr("ui.ribbon_pin_footer")).size(11.0).color(Tokens::get().text_dim)).wrap());
+ ui.add(
+ egui::Label::new(
+ egui::RichText::new(crate::i18n::tr("ui.ribbon_pin_footer")).size(crate::theme::Tokens::get().font_small).color(Tokens::get().text_dim),
+ )
+ .wrap(),
+ );
ui.add_space(4.0);
}
@@ -2185,8 +2219,8 @@ mod header_report_tests {
2.0 * (1400.0 - crate::titlebar::WIDTH - RIGHT_GROUP - center.x)
};
let (en, ru) = (width_in("en"), width_in("ru"));
- assert!((en - 115.2).abs() < 0.5, "{en}");
- // "Сообщить об ошибке" needs more than the English button's 115 px.
+ assert!((en - 114.34375).abs() < 0.05, "Plex Sans report button width: {en}");
+ // "Сообщить об ошибке" needs more than the English button's 114 px.
assert!(ru > en + 10.0, "{ru}");
}
@@ -2570,9 +2604,36 @@ mod app_bar_tests {
mod ribbon_label_tests {
use super::*;
+ #[test]
+ fn ribbon_weight_is_painted_once_at_a_pixel_aligned_origin() {
+ for scale in [1.0, 1.5, 2.0] {
+ let ctx = crate::fonts::test_context();
+ ctx.set_pixels_per_point(scale);
+ let ink = Tokens::get().text_dim;
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ ribbon_text(ui, pos2(100.3, 40.7), "Selected tab", 13.0, ink, true);
+ });
+ output.textures_delta.clear();
+ let text: Vec<_> = output
+ .shapes
+ .iter()
+ .filter_map(|s| match &s.shape {
+ egui::Shape::Text(text) if text.galley.text() == "Selected tab" => Some(text),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(text.len(), 1, "ribbon labels must never be drawn twice");
+ let text = text[0];
+ assert_eq!(text.galley.job.sections[0].format.font_id, crate::fonts::semibold(13.0));
+ assert_eq!(text.galley.job.sections[0].format.color, ink);
+ assert!((text.pos.x * scale - (text.pos.x * scale).round()).abs() < 0.001);
+ assert!((text.pos.y * scale - (text.pos.y * scale).round()).abs() < 0.001);
+ }
+ }
+
#[test]
fn every_promoted_label_wraps_only_at_word_boundaries() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.painter().clone();
let specs = solidcraft_engine::command_specs();
@@ -2608,7 +2669,7 @@ mod ribbon_label_tests {
}
}
}
- for label in ["Rectangular", "Dimension", "Coincident"] {
+ for label in ["Rectangular", "Dimension", "Coincident", "Chamfer", "Revolve"] {
let width = ribbon_button_width(&painter, label);
assert_eq!(ribbon_button_lines(&painter, label, width - BUTTON_LABEL_PADDING), vec![label]);
assert!((BUTTON_MIN_WIDTH..=BUTTON_MAX_WIDTH).contains(&width));
diff --git a/crates/ui-egui/src/toolbar_custom.rs b/crates/ui-egui/src/toolbar_custom.rs
index 26258cb2d7..24be3f9f09 100644
--- a/crates/ui-egui/src/toolbar_custom.rs
+++ b/crates/ui-egui/src/toolbar_custom.rs
@@ -8,6 +8,7 @@
//! and Reset Toolbar; Reset Toolbar restores the tab. Kept with the
//! preferences and exported or imported with the keyboard shortcuts.
+use crate::fonts::RichTextExt as _;
use std::collections::BTreeMap;
use serde_json::{Value, json};
@@ -213,22 +214,22 @@ pub fn command_items(app: &SolveApp, id: &str) -> Vec<Item> {
let fav = app.sbox.pinned.iter().any(|p| p == id);
let mut v = Vec::new();
v.push(if on {
- Item::action("ui.toolbarRemove", "Remove from Toolbar", "").with(json!({ "command": id }))
+ Item::action("ui.toolbarRemove", "Remove from Toolbar", "close").with(json!({ "command": id }))
} else {
- Item::action("ui.toolbarPin", "Pin to Toolbar", "").with(json!({ "command": id }))
+ Item::action("ui.toolbarPin", "Pin to Toolbar", "plus").with(json!({ "command": id }))
});
- v.push(Item::action("ui.shortcutPin", if fav { "Unpin from Shortcuts" } else { "Pin to Shortcuts" }, "").with(json!({ "command": id })));
+ v.push(Item::action("ui.shortcutPin", if fav { "Unpin from Shortcuts" } else { "Pin to Shortcuts" }, "star").with(json!({ "command": id })));
v.push(Item::sep());
- v.push(Item::action("ui.toolbarCustomize", "Customize Toolbar…", ""));
- v.push(Item::action("ui.toolbarReset", "Reset Toolbar", "").with(json!({ "tab": tab })));
+ v.push(Item::action("ui.toolbarCustomize", "Customize Toolbar…", "settings"));
+ v.push(Item::action("ui.toolbarReset", "Reset Toolbar", "restore").with(json!({ "tab": tab })));
v
}
/// The toolbar's own menu (right-click on its empty space).
pub fn toolbar_items(app: &SolveApp) -> Vec<Item> {
vec![
- Item::action("ui.toolbarCustomize", "Customize Toolbar…", ""),
- Item::action("ui.toolbarReset", "Reset Toolbar", "").with(json!({ "tab": app.ui.tab })),
+ Item::action("ui.toolbarCustomize", "Customize Toolbar…", "settings"),
+ Item::action("ui.toolbarReset", "Reset Toolbar", "restore").with(json!({ "tab": app.ui.tab })),
]
}
@@ -301,7 +302,7 @@ pub fn window(app: &mut SolveApp, ctx: &egui::Context) {
if cmds.is_empty() {
continue;
}
- ui.label(egui::RichText::new(app.tr_label(panel)).strong().size(11.0));
+ ui.label(egui::RichText::new(app.tr_label(panel)).semibold().color(crate::theme::Tokens::get().text).size(crate::theme::Tokens::get().font_small));
let shown = buttons(app, &tab, panel, &cmds, n);
for c in &cmds {
let mut on = shown.iter().any(|b| b.id == c.id) || pinned_on(app, &tab, c.id).is_some();
diff --git a/crates/ui-egui/src/tools.rs b/crates/ui-egui/src/tools.rs
index 70c1a73871..e205dced0e 100644
--- a/crates/ui-egui/src/tools.rs
+++ b/crates/ui-egui/src/tools.rs
@@ -862,7 +862,7 @@ pub fn preview(app: &SolveApp, t: &Tool, painter: &egui::Painter, proj: &Proj) {
sp + egui::vec2(10.0, 10.0),
egui::Align2::LEFT_TOP,
format!("{}, {}", crate::prefs::show_mm(app, hp.x, 1), crate::prefs::show_mm(app, hp.y, 1)),
- egui::FontId::proportional(11.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_small),
tk.text_dim,
);
}
@@ -918,7 +918,7 @@ pub fn preview(app: &SolveApp, t: &Tool, painter: &egui::Painter, proj: &Proj) {
m + g,
egui::Align2::CENTER_CENTER,
if horizontal { "H" } else { "V" },
- egui::FontId::proportional(10.0),
+ egui::FontId::proportional(crate::theme::Tokens::get().font_micro),
tk.sketch_accent,
);
}
diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rs
new file mode 100644
index 0000000000..30cac39b10
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/actions.rs
@@ -0,0 +1,250 @@
+//! Actions elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::metrics::*;
+use crate::{fonts::RichTextExt as _, scenario, theme::Tokens};
+use egui::{Response, RichText, Ui, vec2};
+
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub enum Action {
+ #[default]
+ None,
+ Ok,
+ Cancel,
+ Apply,
+}
+
+/// Every enabled button shows the pointing hand on hover, as the application's other clickable
+/// chrome does. A disabled button stays inert and keeps the arrow.
+pub(crate) fn pointer_on_hover(ui: &Ui, response: &Response) {
+ if response.enabled() && response.hovered() {
+ ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
+ }
+}
+
+/// Icon action inside an existing rectangle. Tokens: `form_icon_inset, text, text_dim; icon palette`.
+pub fn icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str) -> Response {
+ let t = Tokens::get();
+ let response = ui.interact(rect, ui.make_persistent_id(("icon_button", icon, label)), egui::Sense::click());
+ crate::icons::paint_ink(
+ ui.painter(),
+ rect.shrink(t.form_icon_inset),
+ icon,
+ if response.hovered() || response.has_focus() { t.text } else { t.text_dim },
+ );
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::tr_label(label)));
+ pointer_on_hover(ui, &response);
+ response.on_hover_text(crate::i18n::tr_label(label))
+}
+
+/// Enter applies only when no editor owns it. Editors report their own accepted Enter.
+/// Esc cancels; unowned Enter submits only when valid. Tokens: `none`.
+pub fn keyboard(ctx: &egui::Context, ok_enabled: bool) -> Action {
+ if ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
+ Action::Cancel
+ } else if ok_enabled && ctx.memory(|m| m.focused().is_none()) && ctx.input(|i| i.key_pressed(egui::Key::Enter)) {
+ Action::Ok
+ } else {
+ Action::None
+ }
+}
+
+/// Pinned actions; `apply_label` adds Apply without closing. Tokens: form_footer_height,
+/// form_button_height, dialog_footer/rule, control_*, accent, on_accent, font_label, spacing.
+/// Pinned OK / optional Apply / Cancel; returns Action. Tokens: `form_footer_height, form_button_height, dialog_footer/rule, radius_lg, control_*, accent, on_accent, font_label, space_6/10/12/16`.
+pub fn footer(ui: &mut Ui, ok_label: &str, cancel_label: &str, ok_enabled: bool, apply_label: Option<&str>) -> Action {
+ footer_impl(ui, ok_label, cancel_label, ok_enabled, apply_label, None)
+}
+
+/// Footer with stable button IDs and compute text. Tokens: `footer tokens, text_dim, space_4/8`.
+pub fn footer_with_status(
+ ui: &mut Ui,
+ ok_label: &str,
+ cancel_label: &str,
+ ok_enabled: bool,
+ apply_label: Option<&str>,
+ status: Option<&str>,
+) -> Action {
+ footer_impl(ui, ok_label, cancel_label, ok_enabled, apply_label, status)
+}
+
+/// Shared footer implementation. Tokens: `footer tokens`.
+fn footer_impl(ui: &mut Ui, ok_label: &str, cancel_label: &str, ok_enabled: bool, apply_label: Option<&str>, status: Option<&str>) -> Action {
+ let t = Tokens::get();
+ // The footer is a full-width band (the card has no margin of its own): its own fill, a rule
+ // on top, and the buttons right-aligned with 6 pt above/below and 10 pt at the sides.
+ let (band, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.form_footer_height), egui::Sense::hover());
+ let corner = t.radius_lg.saturating_sub(1);
+ ui.painter().rect_filled(band, egui::CornerRadius { nw: 0, ne: 0, sw: corner, se: corner }, t.dialog_footer);
+ ui.painter().hline(band.x_range(), band.top(), egui::Stroke::new(1.0, t.dialog_rule));
+ scenario::publish_rect("dialog:footer", band);
+ scenario::publish_count("dialog:ok:enabled", f64::from(ok_enabled && ui.is_enabled()));
+ let inner = band.shrink2(vec2(t.space_10, t.space_6));
+ let mut action = if ui.is_enabled() { keyboard(ui.ctx(), ok_enabled) } else { Action::None };
+ let mut actions_left = inner.right();
+ let row = ui.scope_builder(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
+ ui.spacing_mut().item_spacing.x = t.space_6;
+ for (label, kind) in [(ok_label, Action::Ok), (apply_label.unwrap_or(""), Action::Apply), (cancel_label, Action::Cancel)] {
+ if kind == Action::Apply && apply_label.is_none() {
+ continue;
+ }
+ let primary = kind == Action::Ok;
+ let live = kind == Action::Cancel || ok_enabled;
+ ui.spacing_mut().button_padding = vec2(if primary { t.space_16 } else { t.space_12 }, 0.0);
+ let text = RichText::new(crate::i18n::tr_label(label)).size(t.font_label).color(if primary && ok_enabled {
+ t.on_accent
+ } else if primary {
+ t.text_dim
+ } else {
+ t.text
+ });
+ let response = ui.add_enabled(
+ live,
+ egui::Button::new(if primary && ok_enabled { text.bold_face() } else { text })
+ .fill(if primary && ok_enabled { t.accent } else { t.control_fill })
+ .stroke(egui::Stroke::new(if primary && ok_enabled { 0.0 } else { 1.0 }, t.control_border))
+ .wrap_mode(egui::TextWrapMode::Extend)
+ .corner_radius(t.control_radius)
+ .min_size(vec2(0.0, t.form_button_height)),
+ );
+ pointer_on_hover(ui, &response);
+ actions_left = actions_left.min(response.rect.left());
+ let key = match kind {
+ Action::Ok => "dialog:ok",
+ Action::Apply => "dialog:apply",
+ _ => "dialog:cancel",
+ };
+ scenario::publish_handle(key, response.rect.center());
+ scenario::publish_rect(key, response.rect);
+ scenario::publish_handle(&format!("dialog:{label}"), response.rect.center());
+ if response.clicked() {
+ action = kind;
+ }
+ }
+ });
+ });
+ if let Some(status) = status {
+ let left = (row.response.rect.left() + t.space_16 + t.space_4).min(actions_left);
+ let right = (actions_left - t.space_8).max(left);
+ let rect = egui::Rect::from_min_max(egui::pos2(left, inner.top()), egui::pos2(right, inner.bottom()));
+ // Added after the actions, so status changes cannot change the button IDs.
+ ui.put(rect, egui::Label::new(RichText::new(status).medium().color(t.text_dim)).truncate());
+ }
+ action
+}
+
+/// One equal-width secondary action, with optional existing icon master.
+pub struct PairButton<'a> {
+ pub key: &'a str,
+ pub label: &'a str,
+ pub icon: Option<&'a str>,
+}
+
+/// Equal secondary footer actions; Tokens: form_button_height, control_*, selected_bg, hover, font_label, spacing.
+/// Equal-width secondary actions with optional icons and selected state. Tokens: `form_button_height, control_*, selected_bg, hover, font_label, text, icon/fill, accent, sketch_footer_icon_size, space_4/6/10`.
+pub fn button_pair(ui: &mut egui::Ui, key: &str, states: [bool; 2], buttons: [PairButton<'_>; 2]) -> (bool, bool) {
+ let t = Tokens::get();
+ ui.painter().hline(ui.max_rect().x_range(), ui.cursor().top(), egui::Stroke::new(1.0, t.dialog_rule));
+ let mut clicked = [false; 2];
+ egui::Frame::NONE.inner_margin(egui::Margin::symmetric(t.space_10 as i8, t.space_6 as i8)).show(ui, |ui| {
+ ui.horizontal(|ui| {
+ ui.spacing_mut().item_spacing.x = t.space_6;
+ let width = (ui.available_width() - t.space_6) / 2.0;
+ for (index, button) in buttons.iter().enumerate() {
+ let (rect, response) = ui.allocate_exact_size(vec2(width, t.form_button_height), egui::Sense::click());
+ let on = states.get(index).copied().unwrap_or(false);
+ ui.painter().rect(
+ rect,
+ t.control_radius,
+ if on {
+ t.selected_bg
+ } else if response.hovered() || response.has_focus() {
+ t.hover
+ } else {
+ t.control_fill
+ },
+ egui::Stroke::new(1.0, t.control_border),
+ egui::StrokeKind::Inside,
+ );
+ let label = crate::i18n::tr_label(button.label);
+ let galley = ui.painter().layout_no_wrap(label.to_string(), egui::FontId::proportional(t.font_label), t.text);
+ let icon_width = if button.icon.is_some() { t.sketch_footer_icon_size + t.space_4 } else { 0.0 };
+ let left = rect.center().x - (galley.size().x + icon_width) / 2.0;
+ let painter = ui.painter().with_clip_rect(ui.clip_rect().intersect(rect));
+ if let Some(icon) = button.icon {
+ crate::icons::paint(
+ &painter,
+ egui::Rect::from_center_size(
+ egui::pos2(left + t.sketch_footer_icon_size / 2.0, rect.center().y),
+ vec2(t.sketch_footer_icon_size, t.sketch_footer_icon_size),
+ ),
+ icon,
+ t.icon,
+ t.icon_fill,
+ t.accent,
+ );
+ }
+ painter.galley(egui::pos2(left + icon_width, rect.center().y - galley.size().y / 2.0), galley, t.text);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, label));
+ pointer_on_hover(ui, &response);
+ crate::scenario::publish_handle(&format!("{key}:{}", button.key), rect.center());
+ crate::scenario::publish_rect(&format!("{key}:{}", button.key), rect);
+ if let Some(value) = clicked.get_mut(index) {
+ *value = response.on_hover_text(label).clicked();
+ }
+ }
+ });
+ });
+ (clicked.first().copied().unwrap_or(false), clicked.get(1).copied().unwrap_or(false))
+}
+
+/// Ordinary secondary action inheriting `scope`'s control and font tokens; preserves egui sizing.
+/// Ordinary secondary action preserving native sizing. Tokens: `scope font/control/spacing tokens`.
+pub fn secondary_button(ui: &mut Ui, label: impl Into<egui::WidgetText>) -> Response {
+ let label = label.into();
+ let key = label.text().to_owned();
+ let response = ui.button(label);
+ pointer_on_hover(ui, &response);
+ publish_button(ui, &response, &key);
+ response
+}
+
+/// Accent action. Tokens: accent, on_accent and the scope's control/font/spacing tokens.
+/// Accent action outside the footer. Tokens: `accent, on_accent; scope tokens`.
+pub fn primary_button(ui: &mut Ui, label: &str) -> Response {
+ let t = Tokens::get();
+ let response = ui.add(egui::Button::new(RichText::new(crate::i18n::tr_label(label)).color(t.on_accent)).fill(t.accent));
+ pointer_on_hover(ui, &response);
+ scenario::publish_rect(&format!("dialog:button:{label}"), response.rect);
+ scenario::publish_handle(&format!("dialog:button:{label}"), response.rect.center());
+ response
+}
+
+/// Compact inline removal action; Tokens: scope's font and control tokens, egui small padding.
+/// Compact inline action preserving native sizing. Tokens: `scope font/control tokens`.
+pub fn small_button(ui: &mut Ui, label: &str) -> Response {
+ let response = ui.small_button(label);
+ pointer_on_hover(ui, &response);
+ publish_button(ui, &response, label);
+ response
+}
+
+/// Allocate a control-height icon action. Tokens: control_height, form_icon_inset, text/dim.
+/// Allocated control-height icon action. Tokens: `control_height; icon_button_at tokens`.
+pub fn icon_button(ui: &mut Ui, label: &str, icon: &str) -> Response {
+ let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());
+ let response = icon_button_at(ui, rect, icon, label);
+ scenario::publish_rect(&format!("dialog:button:{label}"), rect);
+ scenario::publish_handle(&format!("dialog:button:{label}"), rect.center());
+ response
+}
+
+#[cfg(test)]
+#[path = "actions_tests.rs"]
+mod tests;
+
+// Additional identities must never replace an existing field handle in compound rows.
+fn publish_button(ui: &Ui, response: &Response, label: &str) {
+ let key = format!("dialog:button:{}:{label}", super::layout::label(ui));
+ scenario::publish_handle(&key, response.rect.center());
+ scenario::publish_rect(&key, response.rect);
+}
diff --git a/crates/ui-egui/src/ui_kit/actions_tests.rs b/crates/ui-egui/src/ui_kit/actions_tests.rs
new file mode 100644
index 0000000000..6924c3a1c5
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/actions_tests.rs
@@ -0,0 +1,74 @@
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::scenario;
+use egui::Ui;
+
+#[test]
+fn footer_clicks_and_keyboard_respect_validation_and_editor_focus() {
+ for enabled in [false, true] {
+ let ctx = crate::fonts::test_context();
+ let mut action = Action::None;
+ let mut draw = |ui: &mut Ui| {
+ action = footer(ui, "OK", "Cancel", enabled, None);
+ };
+ frame(&ctx, vec![], &mut draw);
+ let pos = scenario::handle_at("dialog:ok").unwrap();
+ frame(&ctx, pointer(pos, true), &mut draw);
+ frame(&ctx, pointer(pos, false), &mut draw);
+ assert_eq!(action, if enabled { Action::Ok } else { Action::None });
+ // Button clicks may own focus; keyboard submission is for an unfocused form.
+ ctx.memory_mut(|m| {
+ if let Some(id) = m.focused() {
+ m.surrender_focus(id);
+ }
+ });
+ frame(&ctx, key(egui::Key::Enter), |ui| action = footer(ui, "OK", "Cancel", enabled, None));
+ assert_eq!(action, if enabled { Action::Ok } else { Action::None });
+ frame(&ctx, key(egui::Key::Escape), |ui| action = footer(ui, "OK", "Cancel", enabled, None));
+ assert_eq!(action, Action::Cancel);
+ frame(&ctx, vec![], |ui| {
+ footer(ui, "OK", "Cancel", enabled, None);
+ });
+ let cancel = scenario::handle_at("dialog:cancel").unwrap();
+ frame(&ctx, pointer(cancel, true), |ui| action = footer(ui, "OK", "Cancel", enabled, None));
+ frame(&ctx, pointer(cancel, false), |ui| action = footer(ui, "OK", "Cancel", enabled, None));
+ assert_eq!(action, Action::Cancel);
+ }
+ let ctx = crate::fonts::test_context();
+ let mut action = Action::None;
+ let mut text = "radius".to_string();
+ frame(&ctx, vec![], |ui| {
+ let response = ui.text_edit_singleline(&mut text);
+ response.request_focus();
+ footer(ui, "OK", "Cancel", true, None);
+ });
+ frame(&ctx, key(egui::Key::Enter), |ui| {
+ ui.text_edit_singleline(&mut text).request_focus();
+ action = footer(ui, "OK", "Cancel", true, None);
+ });
+ // A text editor handles Enter itself; the footer cannot apply merely because it was pressed.
+ assert_eq!(action, Action::None);
+}
+
+#[test]
+fn enabled_buttons_show_the_pointing_hand_and_disabled_ones_do_not() {
+ for (enabled, expected) in [(true, egui::CursorIcon::PointingHand), (false, egui::CursorIcon::Default)] {
+ let ctx = crate::fonts::test_context();
+ let mut draw = |ui: &mut Ui| {
+ footer(ui, "OK", "Cancel", enabled, Some("Apply"));
+ };
+ frame(&ctx, vec![], &mut draw);
+ let ok = scenario::handle_at("dialog:ok").unwrap();
+ // Settled over two frames: the hover is known from the first frame's layout.
+ frame_cursor(&ctx, ok, &mut draw);
+ assert_eq!(frame_cursor(&ctx, ok, &mut draw), expected, "OK, enabled {enabled}");
+ // Apply is a button too, and Cancel is always enabled.
+ let apply = scenario::handle_at("dialog:apply").unwrap();
+ frame_cursor(&ctx, apply, &mut draw);
+ assert_eq!(frame_cursor(&ctx, apply, &mut draw), expected, "Apply, enabled {enabled}");
+ let cancel = scenario::handle_at("dialog:cancel").unwrap();
+ frame_cursor(&ctx, cancel, &mut draw);
+ assert_eq!(frame_cursor(&ctx, cancel, &mut draw), egui::CursorIcon::PointingHand, "Cancel is always enabled");
+ }
+}
diff --git a/crates/ui-egui/src/ui_kit/choice.rs b/crates/ui-egui/src/ui_kit/choice.rs
new file mode 100644
index 0000000000..1ef8bf5b43
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/choice.rs
@@ -0,0 +1,297 @@
+//! Choice elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::{
+ fields::dropdown,
+ layout::{label, section},
+ metrics::*,
+ text::paint_text,
+};
+use crate::{scenario, theme::Tokens};
+use egui::{Ui, vec2};
+
+/// Segments share the row equally. When the longest label would not fit its segment (several long
+/// choices in a narrow card), the choice is a dropdown instead of overlapping or clipped text.
+/// Equal text choices, falling back to dropdown when labels cannot fit. Tokens: `control_height, control_fill/border/radius, font_label, selected_bg/ink, hover, text, space_8`.
+pub fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str]) -> bool {
+ segmented_states(ui, selected, options, &[])
+}
+
+/// Optional per-segment states preserve mixed selections in command-backed controls.
+/// Segmented choices with mixed per-choice state. Tokens: `same as segmented`.
+pub fn segmented_states(ui: &mut Ui, selected: &mut usize, options: &[&str], states: &[bool]) -> bool {
+ segments(ui, selected, options, states, false)
+}
+
+/// Always-visible compact choices for short modes with established per-choice handles.
+/// Long translated labels clip within their segment and remain available as tooltips.
+/// Tokens: segmented tokens, space_4. Prefer segmented when dropdown fallback is appropriate.
+pub fn segmented_compact(ui: &mut Ui, selected: &mut usize, options: &[&str]) -> bool {
+ segments(ui, selected, options, &[], true)
+}
+
+fn segments(ui: &mut Ui, selected: &mut usize, options: &[&str], states: &[bool], compact: bool) -> bool {
+ let t = Tokens::get();
+ let segment_width = dimension(ui.available_width()) / options.len().max(1) as f32;
+ let widest = options
+ .iter()
+ .map(|option| ui.painter().layout_no_wrap(crate::i18n::tr_label(option).to_string(), crate::fonts::semibold(t.font_label), t.text).size().x)
+ .fold(0.0, f32::max);
+ if !compact && widest + 2.0 * t.space_8 > segment_width {
+ let before = *selected;
+ let id = format!("segments_fallback_{}", label(ui));
+ dropdown(ui, &id, selected, options);
+ return *selected != before;
+ }
+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());
+ ui.painter().rect_filled(rect, t.control_radius, t.control_fill);
+ let width = rect.width() / options.len().max(1) as f32;
+ let mut clicked = false;
+ for (index, option) in options.iter().enumerate() {
+ let segment = egui::Rect::from_min_size(rect.min + vec2(index as f32 * width, 0.0), vec2(width, rect.height()));
+ let response = ui.interact(segment, ui.make_persistent_id(("segment", index)), egui::Sense::click());
+ let on = states.get(index).copied().unwrap_or(*selected == index);
+ let rounding = egui::CornerRadius {
+ nw: if index == 0 { t.control_radius } else { 0 },
+ sw: if index == 0 { t.control_radius } else { 0 },
+ ne: if index + 1 == options.len() { t.control_radius } else { 0 },
+ se: if index + 1 == options.len() { t.control_radius } else { 0 },
+ };
+ if on || response.hovered() {
+ ui.painter().rect_filled(segment, rounding, if on { t.selected_bg } else { t.hover });
+ }
+ if index > 0 {
+ ui.painter().vline(segment.left(), segment.y_range(), egui::Stroke::new(1.0, t.control_border));
+ }
+ let font = if on { crate::fonts::semibold(t.font_label) } else { egui::FontId::proportional(t.font_label) };
+ let galley = ui.painter().layout_no_wrap((*option).to_string(), font.clone(), t.text);
+ let text_rect =
+ egui::Rect::from_min_size(egui::pos2(segment.center().x - galley.size().x / 2.0, segment.top()), vec2(galley.size().x, segment.height()));
+ let text_rect = if compact { text_rect.intersect(segment.shrink2(vec2(t.space_4, 0.0))) } else { text_rect };
+ paint_text(ui, text_rect, option, font, if on { t.selected_ink } else { t.text }, false);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, *option));
+ scenario::publish_handle(&format!("dialog:{}:{option}", label(ui)), segment.center());
+ if response.on_hover_text(*option).clicked() {
+ *selected = index;
+ clicked = true;
+ }
+ }
+ ui.painter().rect_stroke(rect, t.control_radius, egui::Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);
+ scenario::publish_rect(&format!("dialog:segments:{}", label(ui)), rect);
+ scenario::publish_handle(&format!("dialog:{}", label(ui)), rect.center());
+ clicked
+}
+
+/// One segment of [`segmented_icons`]: a stable key (also the accessible fallback text), the icon
+/// master to draw and the hover text. The icon's colours come from the palette (its roles and the
+/// accent assigned to its id in `palette.toml`), not from the caller.
+pub struct IconSegment {
+ pub key: &'static str,
+ pub icon: &'static str,
+ pub tip: String,
+}
+
+/// A row of equal icon segments in the segmented control's frame. `states` says which segments are on
+/// (several may be, for a mixed selection); without it `selected` is. True when a segment was clicked.
+/// Equal icon choices with mixed state. Tokens: `segmented tokens, space_4/12, icon/fill, accent; icon palette`.
+pub fn segmented_icons(ui: &mut Ui, selected: &mut usize, options: &[IconSegment], states: &[bool]) -> bool {
+ let t = Tokens::get();
+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());
+ ui.painter().rect_filled(rect, t.control_radius, t.control_fill);
+ let width = rect.width() / options.len().max(1) as f32;
+ let mut clicked = false;
+ for (index, option) in options.iter().enumerate() {
+ let segment = egui::Rect::from_min_size(rect.min + vec2(index as f32 * width, 0.0), vec2(width, rect.height()));
+ let response = ui.interact(segment, ui.make_persistent_id(("icon_segment", index)), egui::Sense::click());
+ let on = states.get(index).copied().unwrap_or(*selected == index);
+ let rounding = egui::CornerRadius {
+ nw: if index == 0 { t.control_radius } else { 0 },
+ sw: if index == 0 { t.control_radius } else { 0 },
+ ne: if index + 1 == options.len() { t.control_radius } else { 0 },
+ se: if index + 1 == options.len() { t.control_radius } else { 0 },
+ };
+ if on || response.hovered() {
+ ui.painter().rect_filled(segment, rounding, if on { t.selected_bg } else { t.hover });
+ }
+ if index > 0 {
+ ui.painter().vline(segment.left(), segment.y_range(), egui::Stroke::new(1.0, t.control_border));
+ }
+ // A square icon area inside the segment: dash gaps and dots need the room to read apart.
+ let side = (segment.width().min(segment.height()) - t.space_4).max(t.space_12);
+ let icon_rect = egui::Rect::from_center_size(segment.center(), vec2(side, side));
+ crate::icons::paint(ui.painter(), icon_rect, option.icon, t.icon, t.icon_fill, t.accent);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), on, option.key));
+ scenario::publish_handle(&format!("dialog:{}:{}", label(ui), option.key), segment.center());
+ let response = response.on_hover_text(&option.tip);
+ if response.clicked() {
+ *selected = index;
+ clicked = true;
+ }
+ }
+ ui.painter().rect_stroke(rect, t.control_radius, egui::Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);
+ scenario::publish_rect(&format!("dialog:segments:{}", label(ui)), rect);
+ scenario::publish_handle(&format!("dialog:{}", label(ui)), rect.center());
+ clicked
+}
+
+/// Compact checkbox options in bounded columns. Tokens: `form_checkbox_height, control_fill/border, radius_sm, accent, on_accent, font_body, text, space_2/3/6/8/14`.
+pub fn checkbox_grid(ui: &mut Ui, items: &mut [(&str, &mut bool)], columns: usize) {
+ let t = Tokens::get();
+ let columns = columns.clamp(1, items.len().max(1));
+ let width = ((dimension(ui.available_width()) - t.space_8 * columns.saturating_sub(1) as f32) / columns as f32).max(0.0);
+ for chunk in items.chunks_mut(columns) {
+ ui.horizontal(|ui| {
+ ui.spacing_mut().item_spacing = vec2(t.space_8, 0.0);
+ for (label, value) in chunk {
+ let (rect, mut response) = ui.allocate_exact_size(vec2(width, t.form_checkbox_height), egui::Sense::click());
+ if response.clicked() {
+ **value = !**value;
+ response.mark_changed();
+ }
+ let square = egui::Rect::from_center_size(egui::pos2(rect.left() + t.space_14 / 2.0, rect.center().y), vec2(t.space_14, t.space_14));
+ ui.painter().rect(
+ square,
+ t.radius_sm,
+ if **value { t.accent } else { t.control_fill },
+ egui::Stroke::new(1.0, if **value { t.accent } else { t.control_border }),
+ egui::StrokeKind::Inside,
+ );
+ if **value {
+ let mark = square.shrink(t.space_3);
+ ui.painter().add(egui::Shape::line(
+ vec![mark.left_center(), mark.center_bottom(), mark.right_top()],
+ egui::Stroke::new(t.space_2, t.on_accent),
+ ));
+ }
+ let translated = crate::i18n::tr_label(label);
+ let text = if translated == "Tangent Chain" { "Tangent chain" } else { translated };
+ let text_rect = egui::Rect::from_min_max(egui::pos2((square.right() + t.space_6).min(rect.right()), rect.top()), rect.max);
+ paint_text(ui, text_rect, text, egui::FontId::proportional(t.font_body), t.text, false);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), **value, translated));
+ scenario::publish_handle(&format!("dialog:{label}"), rect.center());
+ scenario::publish_rect(&format!("dialog:checkbox:{label}"), rect);
+ }
+ });
+ }
+}
+
+/// Shared expanded options band for feature dialogs.
+/// Expanded two-column Options disclosure. Tokens: `section and checkbox_grid tokens`.
+pub fn options(ui: &mut Ui, id: &str, items: &mut [(&str, &mut bool)]) {
+ section(ui, id, "Options", true, |ui| checkbox_grid(ui, items, 2));
+}
+
+/// Entire row is the checkbox hit target, including its label on the left.
+/// Full-row target with label left and box right; returns clicked. Tokens: `control_height, control_radius, hover, radius_sm, accent, control_fill/border, on_accent, font_label, text, space_2/3/6/14`.
+pub fn checkbox_row(ui: &mut egui::Ui, key: &str, label: &str, on: bool) -> bool {
+ let t = Tokens::get();
+ let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width(), t.control_height), egui::Sense::click());
+ let square = egui::Rect::from_center_size(egui::pos2(rect.right() - t.space_14 / 2.0, rect.center().y), vec2(t.space_14, t.space_14));
+ if response.hovered() || response.has_focus() {
+ ui.painter().rect_filled(rect, t.control_radius, t.hover);
+ }
+ ui.painter().rect(
+ square,
+ t.radius_sm,
+ if on { t.accent } else { t.control_fill },
+ egui::Stroke::new(1.0, if on { t.accent } else { t.control_border }),
+ egui::StrokeKind::Inside,
+ );
+ if on {
+ let mark = square.shrink(t.space_3);
+ ui.painter()
+ .add(egui::Shape::line(vec![mark.left_center(), mark.center_bottom(), mark.right_top()], egui::Stroke::new(t.space_2, t.on_accent)));
+ }
+ let label = crate::i18n::tr_label(label);
+ let painter = ui
+ .painter()
+ .with_clip_rect(ui.clip_rect().intersect(egui::Rect::from_min_max(rect.min, egui::pos2(square.left() - t.space_6, rect.bottom()))));
+ painter.text(rect.left_center(), egui::Align2::LEFT_CENTER, label, egui::FontId::proportional(t.font_label), t.text);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, ui.is_enabled(), on, label));
+ crate::scenario::publish_handle(&format!("sketch_palette:toggle:{key}"), rect.center());
+ crate::scenario::publish_rect(&format!("sketch_palette:toggle:{key}"), rect);
+ response.on_hover_text(label).clicked()
+}
+
+/// Standard inline checkbox; inherits scope's font_label, accent, control and text tokens.
+/// Use checkbox_row for a full-width label-left/box-right palette option.
+/// Inline native checkbox retaining existing accessibility and sizing. Tokens: `scope control/font/accent tokens`.
+pub fn checkbox(ui: &mut Ui, label: &str, value: &mut bool) -> egui::Response {
+ let response = ui.checkbox(value, label);
+ super::layout::publish_geometry(ui, &response);
+ response
+}
+
+/// Compact bold/italic toggles for text. Tokens: scope font/control tokens.
+/// The glyphs keep the familiar B/I treatment; accessible names use translated style names.
+pub fn text_emphasis(ui: &mut Ui, bold: &mut bool, italic: &mut bool) {
+ use crate::fonts::RichTextExt as _;
+ for (key, text, value, id) in [
+ ("Bold", egui::RichText::new("B").semibold(), bold, "sketch_text.bold"),
+ ("Italic", egui::RichText::new("I").italics(), italic, "sketch_text.italic"),
+ ] {
+ let response = ui.toggle_value(value, text).on_hover_text(crate::i18n::tr(id));
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, ui.is_enabled(), *value, crate::i18n::tr(id)));
+ scenario::publish_handle(&format!("dialog:{key}"), response.rect.center());
+ scenario::publish_rect(&format!("dialog:emphasis:{key}"), response.rect);
+ }
+}
+
+/// A command variant supplied by the panel; the kit only draws and returns its key.
+pub struct ToolChoice<'a> {
+ pub key: &'a str,
+ pub icon: &'a str,
+ pub label: &'a str,
+ pub enabled: bool,
+}
+
+/// Wrapped creation-mode icon choices. Tokens: sketch_mode_*, sketch_accent, control_*, icon, spacing.
+/// Wrapped command-variant icons, supplied with enabled state. Tokens: `sketch_mode_size/radius/border/tint, sketch_accent, control_fill/border, icon/fill, space_4/6`.
+pub fn tool_choices<'a>(ui: &mut Ui, label: &str, current: &str, choices: &[ToolChoice<'a>]) -> Option<&'a str> {
+ let t = Tokens::get();
+ let mut start = None;
+ ui.label(label);
+ ui.horizontal_wrapped(|ui| {
+ ui.spacing_mut().item_spacing = vec2(t.space_4, t.space_4);
+ for choice in choices {
+ let on = choice.key == current;
+ let enabled = choice.enabled;
+ let fill = if on { t.control_fill.lerp_to_gamma(t.sketch_accent, t.sketch_mode_tint) } else { t.control_fill };
+ let response = ui.add_enabled(
+ enabled,
+ egui::Button::new("")
+ .fill(fill)
+ .stroke(egui::Stroke::new(if on { t.sketch_mode_border } else { 1.0 }, if on { t.sketch_accent } else { t.control_border }))
+ .corner_radius(t.sketch_mode_radius)
+ .min_size(vec2(t.sketch_mode_size, t.sketch_mode_size)),
+ );
+ crate::icons::paint(ui.painter(), response.rect.shrink(t.space_6), choice.icon, t.icon, t.icon_fill, t.sketch_accent);
+ scenario::publish_handle(&format!("sketch_palette:feature:{}", choice.key), response.rect.center());
+ scenario::publish_rect(&format!("sketch_palette:feature:{}", choice.key), response.rect);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, enabled, on, choice.label));
+ if response.on_hover_text(choice.label).clicked() && enabled {
+ start = Some(choice.key);
+ }
+ }
+ });
+ start
+}
+
+/// Independent selected icon action, used for pattern direction/centering.
+/// Tokens: control_height, space_3/4/24, icon/fill, accent; inherited control surface tokens.
+pub fn toggle_icon(ui: &mut Ui, row: &str, label: &str, selected: &mut bool, icon: &str) -> egui::Response {
+ // Tab moves between value fields; Enter after a value edit applies the dialog.
+ let t = Tokens::get();
+ let response =
+ ui.add(egui::Button::new("").selected(*selected).min_size(vec2(t.space_24 + t.space_4, t.control_height)).sense(egui::Sense::CLICK));
+ crate::icons::paint(ui.painter(), response.rect.shrink(t.space_3), icon, t.icon, t.icon_fill, t.accent);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, *selected, crate::i18n::tr_label(label)));
+ crate::scenario::publish_handle(&format!("dialog:{row}:{label}"), response.rect.center());
+ if response.clone().on_hover_text(crate::i18n::tr_label(label)).clicked() {
+ *selected = !*selected;
+ }
+ scenario::publish_rect(&format!("dialog:{row}:{label}"), response.rect);
+ response
+}
+
+#[cfg(test)]
+#[path = "choice_tests.rs"]
+mod tests;
diff --git a/crates/ui-egui/src/ui_kit/choice_tests.rs b/crates/ui-egui/src/ui_kit/choice_tests.rs
new file mode 100644
index 0000000000..869c7e4c01
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/choice_tests.rs
@@ -0,0 +1,45 @@
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::scenario;
+use egui::Ui;
+
+#[test]
+fn segmented_click_changes_selection_and_keeps_all_choices_visible() {
+ let ctx = crate::fonts::test_context();
+ let mut selected = 0;
+ let mut draw = |ui: &mut Ui| {
+ row(ui, "Continuity", |ui| segmented(ui, &mut selected, &["G1", "G2", "G3"]));
+ };
+ frame(&ctx, vec![], &mut draw);
+ let pos = scenario::handle_at("dialog:Continuity:G2").unwrap();
+ frame(&ctx, pointer(pos, true), &mut draw);
+ frame(&ctx, pointer(pos, false), &mut draw);
+ assert_eq!(selected, 1);
+ let control = scenario::rect_of("dialog:control:Continuity").unwrap();
+ for option in ["G1", "G2", "G3"] {
+ assert!(control.contains(scenario::handle_at(&format!("dialog:Continuity:{option}")).unwrap()));
+ }
+}
+
+#[test]
+fn optional_field_keeps_empty_default_and_options_use_two_columns() {
+ let ctx = crate::fonts::test_context();
+ let mut value = String::new();
+ let (mut flip, mut copy) = (false, true);
+ frame(&ctx, vec![], |ui| {
+ row(ui, "Depth", |ui| hint_field(ui, &mut value, "to the next face"));
+ options(ui, "options", &mut [("Flip", &mut flip), ("Create Copy", &mut copy)]);
+ });
+ assert!(value.is_empty(), "displaying a hint must not introduce a parameter");
+ let first = scenario::handle_at("dialog:Flip").unwrap();
+ let second = scenario::handle_at("dialog:Create Copy").unwrap();
+ assert_eq!(first.y, second.y);
+ assert!(second.x > first.x);
+ let mut draw = |ui: &mut Ui| options(ui, "options", &mut [("Flip", &mut flip), ("Create Copy", &mut copy)]);
+ frame(&ctx, vec![], &mut draw);
+ let first = scenario::handle_at("dialog:Flip").unwrap();
+ frame(&ctx, pointer(first, true), &mut draw);
+ frame(&ctx, pointer(first, false), &mut draw);
+ assert!(flip && copy);
+}
diff --git a/crates/ui-egui/src/ui_kit/fields.rs b/crates/ui-egui/src/ui_kit/fields.rs
new file mode 100644
index 0000000000..12f830e2ce
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/fields.rs
@@ -0,0 +1,248 @@
+//! Fields elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::{
+ layout::{label, publish},
+ metrics::*,
+ text::paint_text,
+};
+use crate::{scenario, theme::Tokens};
+use egui::{Response, RichText, Ui, vec2};
+
+/// Expression editor with the application's existing completion and number-focus behaviour.
+/// Values carry their own unit text ("20 mm", "45 deg"): there is no unit suffix. Returns accepted Enter.
+/// Tokens: `control_height, control_fill, form_inset, font_label, space_4; scope tokens`.
+pub fn field(ui: &mut Ui, value: &mut String) -> bool {
+ editor(ui, value, "", true).0
+}
+
+/// Expression editor with empty-value hint. Tokens: `same as field`.
+pub fn hint_field(ui: &mut Ui, value: &mut String, hint: &str) -> bool {
+ editor(ui, value, hint, true).0
+}
+
+/// Names, thread designations and plain numeric counts do not accept expression completion.
+/// Plain text editor without expression completion; returns (Enter, changed). Tokens: `same as field`.
+pub fn text_field(ui: &mut Ui, value: &mut String, hint: &str) -> (bool, bool) {
+ let (enter, changed, _) = editor(ui, value, hint, false);
+ (enter, changed)
+}
+
+/// Expression field for a single-value popup which keeps ownership of keyboard focus.
+/// Tokens: field tokens. Preserves the legacy Edit Dimension focus behavior.
+pub fn focused_field(ui: &mut Ui, value: &mut String) -> bool {
+ let (enter, _, response) = editor(ui, value, "", true);
+ response.request_focus();
+ enter
+}
+
+/// Multiline plain text with a stable focus ID. The caller owns Enter/Shift+Enter routing.
+/// Tokens: control_height, control_fill, form_inset and font_label.
+pub fn multiline_text_field(ui: &mut Ui, label: &str, id: egui::Id, value: &mut String) -> Response {
+ super::layout::sized_row(ui, label, row_height() * 3.0, |ui| {
+ let t = Tokens::get();
+ let response = ui.add_sized(
+ vec2(dimension(ui.available_width()), row_height() * 3.0),
+ egui::TextEdit::multiline(value)
+ .id(id)
+ .desired_rows(3)
+ .font(egui::FontId::monospace(t.font_label))
+ .background_color(t.control_fill)
+ .margin(vec2(t.form_inset, 0.0)),
+ );
+ publish(ui, &response, egui::WidgetType::TextEdit);
+ response
+ })
+}
+
+/// Supplied entry in a searchable dropdown. Handles are optional stable application aliases.
+pub struct SearchOption<'a> {
+ pub value: &'a str,
+ pub label: &'a str,
+ pub handle: Option<&'a str>,
+}
+
+/// Searchable dropdown with an optional custom-value action and loading message.
+/// Returns a chosen value; callers keep domain-specific validation and discovery.
+/// Tokens: control_height, space_24, font_label and scope control tokens.
+pub fn searchable_dropdown(
+ ui: &mut Ui,
+ id: &str,
+ current: &str,
+ filter: &mut String,
+ options: &[SearchOption<'_>],
+ custom: Option<&str>,
+ pending: Option<&str>,
+) -> Option<String> {
+ let mut chosen = None;
+ let row = label(ui).to_owned();
+ let response = egui::ComboBox::from_id_salt(id)
+ .width(dimension(ui.available_width()))
+ .height(Tokens::get().space_24 * 14.0)
+ .selected_text(current)
+ .icon(dropdown_arrow)
+ .close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
+ .show_ui(ui, |ui| {
+ let search = ui.add(
+ egui::TextEdit::singleline(filter)
+ .id_salt(format!("{id}_search"))
+ .hint_text(crate::i18n::tr_label("Search"))
+ .desired_width(f32::INFINITY),
+ );
+ scenario::publish_handle(&format!("dialog:{row} search"), search.rect.center());
+ if let Some(custom) = custom {
+ let response = ui.selectable_label(false, custom);
+ scenario::publish_handle(&format!("dialog:{row} file"), response.rect.center());
+ if response.clicked() {
+ chosen = Some(filter.trim().to_owned());
+ ui.close();
+ }
+ return;
+ }
+ let query = filter.to_lowercase();
+ egui::ScrollArea::vertical()
+ .id_salt(format!("{id}_list"))
+ .max_height(Tokens::get().space_24 * 10.0)
+ .min_scrolled_height(Tokens::get().space_24 * 10.0)
+ .auto_shrink([false, false])
+ .show(ui, |ui| {
+ for option in options.iter().filter(|o| o.label.to_lowercase().contains(&query)) {
+ let response = ui.selectable_label(current == option.label, option.label);
+ if let Some(handle) = option.handle {
+ scenario::publish_handle(handle, response.rect.center());
+ }
+ if response.clicked() {
+ chosen = Some(option.value.to_owned());
+ ui.close();
+ }
+ }
+ if let Some(pending) = pending {
+ ui.label(pending);
+ }
+ });
+ })
+ .response;
+ publish(ui, &response, egui::WidgetType::ComboBox);
+ chosen
+}
+
+/// Completion/focus implementation shared by field variants. Tokens: `same as field`.
+fn editor(ui: &mut Ui, value: &mut String, hint: &str, completion: bool) -> (bool, bool, Response) {
+ let t = Tokens::get();
+ let width = dimension(ui.available_width());
+ let font = egui::FontId::monospace(t.font_label);
+ let line_height = ui.fonts_mut(|fonts| fonts.row_height(&font)) + ui.spacing().extra_text_line_spacing;
+ // Plex Mono's taller metrics must fit the 24 pt field without pushing the next row down.
+ // Margins use whole logical pixels; round down so the editor cannot grow beyond its row.
+ let margin_y = ((row_height() - line_height) * 0.5).floor().clamp(0.0, t.space_4);
+ let response = ui.add_sized(
+ vec2(width, row_height()),
+ egui::TextEdit::singleline(value)
+ .hint_text(hint)
+ .font(font)
+ .background_color(t.control_fill)
+ .margin(vec2(t.form_inset, margin_y))
+ .clip_text(true),
+ );
+ crate::theme::TabAccent::number_focus(ui, &response);
+ let label = crate::i18n::tr_label(label(ui));
+ response.widget_info(|| {
+ let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), label);
+ info.current_text_value = Some(value.clone());
+ info
+ });
+ scenario::publish_handle(&format!("dialog:{}", self::label(ui)), response.rect.center());
+ scenario::publish_rect(&format!("dialog:widget:{}", self::label(ui)), response.rect);
+ // A completion's Enter accepts the suggestion, rather than submitting the dialog.
+ let completed = completion && crate::params_dialog::complete(ui, &response, value);
+ (!completed && response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)), response.changed(), response)
+}
+
+/// The one dropdown arrow every kit dropdown draws (the kit chevron, dimmed), instead of egui's triangle.
+fn dropdown_arrow(ui: &Ui, rect: egui::Rect, _visuals: &egui::style::WidgetVisuals, _open: bool) {
+ crate::icons::paint_ink(ui.painter(), rect, "chevron", Tokens::get().text_dim);
+}
+
+/// Native dropdown with kit arrow and scenario option handles. Tokens: `text_dim; scope control/font tokens`.
+pub fn dropdown(ui: &mut Ui, id: &str, selected: &mut usize, options: &[&str]) -> Response {
+ let text = options.get(*selected).copied().map(crate::i18n::tr_label).unwrap_or("");
+ let row = label(ui).to_string();
+ let response =
+ egui::ComboBox::from_id_salt(id).width(dimension(ui.available_width())).selected_text(text).icon(dropdown_arrow).show_ui(ui, |ui| {
+ for (index, option) in options.iter().enumerate() {
+ let response = ui.selectable_value(selected, index, crate::i18n::tr_label(option));
+ scenario::publish_handle(&format!("dialog:{row}:{option}"), response.rect.center());
+ }
+ });
+ publish(ui, &response.response, egui::WidgetType::ComboBox);
+ response.response
+}
+
+/// Filled point/curve/edge selection target. Tokens: `control_height, control_radius, selected_bg/ink, accent, form_inset, space_24/8, font_label, text_dim`.
+pub fn selection_field(ui: &mut Ui, text: &str, active: bool) -> Response {
+ selection_field_state(ui, text, active, true)
+}
+
+/// Selection target with explicit filled state. Tokens: `same as selection_field`.
+pub fn selection_field_state(ui: &mut Ui, text: &str, active: bool, filled: bool) -> Response {
+ let t = Tokens::get();
+ let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::CLICK);
+ ui.painter().rect(rect, t.control_radius, t.selected_bg, egui::Stroke::new(if active { 1.0 } else { 0.0 }, t.accent), egui::StrokeKind::Inside);
+ let end = if filled { t.space_24 } else { t.space_8 };
+ let text_rect = egui::Rect::from_min_max(
+ rect.min + vec2(t.form_inset.min(rect.width()), 0.0),
+ egui::pos2((rect.right() - end).max(rect.left() + t.form_inset.min(rect.width())), rect.bottom()),
+ );
+ paint_text(ui, text_rect, text, crate::fonts::medium(t.font_label), if filled { t.selected_ink } else { t.text_dim }, false);
+ publish(ui, &response, egui::WidgetType::Button);
+ scenario::publish_rect(&format!("dialog:field:{}", label(ui)), rect);
+ scenario::publish_count(&format!("dialog:selection:{}:filled", label(ui)), f64::from(filled));
+ response
+}
+
+/// Two labelled expression values in one aligned row, e.g. X/Y. Returns accepted Enter.
+/// Tokens: row/label column metrics, space_8 and field's font/control tokens.
+/// Two labelled numeric fields in one row; returns accepted Enter. Tokens: `row/field tokens, space_8, dialog_label`.
+pub fn value_pair(ui: &mut Ui, label: &str, values: [&mut String; 2], axes: [&str; 2]) -> bool {
+ value_pair_named(ui, label, values, axes, axes)
+}
+
+/// Paired values with compact axis captions and independent stable field names.
+/// Tokens: value_pair tokens. Use when existing scenario/accessibility names differ from X/Y.
+pub fn value_pair_named(ui: &mut Ui, label: &str, values: [&mut String; 2], axes: [&str; 2], names: [&str; 2]) -> bool {
+ let t = Tokens::get();
+ super::row(ui, label, |ui| {
+ let width = ((dimension(ui.available_width()) - t.space_8) / 2.0).max(0.0);
+ let mut enter = false;
+ ui.spacing_mut().item_spacing.x = t.space_8;
+ for ((axis, value), name) in axes.into_iter().zip(values).zip(names) {
+ ui.allocate_ui_with_layout(vec2(width, row_height()), egui::Layout::left_to_right(egui::Align::Center), |ui| {
+ ui.set_clip_rect(ui.clip_rect().intersect(ui.max_rect()));
+ ui.label(RichText::new(axis).size(t.font_label).color(t.dialog_label));
+ enter |= super::layout::named_control(ui, name, |ui| field(ui, value));
+ });
+ }
+ enter
+ })
+}
+
+/// Variable-radius location editor. Tokens: scope's control and typography tokens.
+/// Retains the established 0.01 step, fractional range and locale parser.
+/// Locale-aware variable-radius position editor. Tokens: `scope control/font tokens`.
+pub fn fraction_field(ui: &mut Ui, value: &mut f64) -> Response {
+ let response = ui.add(egui::DragValue::new(value).speed(0.01).range(0.01..=0.99).fixed_decimals(2).custom_parser(crate::prefs::parse_number));
+ scenario::publish_rect(&format!("dialog:fraction:{}", label(ui)), response.rect);
+ scenario::publish_handle(&format!("dialog:fraction:{}", label(ui)), response.rect.center());
+ response
+}
+
+/// How full a surface blend leaves one end (-0.9 to 3, 0 is the plain bridge): a dragged number
+/// with two decimals and the locale's number parser. Tokens: scope's control and font tokens.
+pub fn bulge_field(ui: &mut Ui, value: &mut f64) -> Response {
+ let response = ui.add(egui::DragValue::new(value).speed(0.01).range(-0.9..=3.0).fixed_decimals(2).custom_parser(crate::prefs::parse_number));
+ scenario::publish_rect(&format!("dialog:bulge:{}", label(ui)), response.rect);
+ scenario::publish_handle(&format!("dialog:bulge:{}", label(ui)), response.rect.center());
+ response
+}
+
+#[cfg(test)]
+#[path = "fields_tests.rs"]
+mod tests;
diff --git a/crates/ui-egui/src/ui_kit/fields_tests.rs b/crates/ui-egui/src/ui_kit/fields_tests.rs
new file mode 100644
index 0000000000..71a45fe3fd
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/fields_tests.rs
@@ -0,0 +1,78 @@
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::scenario;
+use egui::Ui;
+
+#[test]
+fn tab_visits_expression_fields_in_row_order() {
+ let ctx = crate::fonts::test_context();
+ let mut first = "1".to_string();
+ let mut second = String::new();
+ let mut draw = |ui: &mut Ui| {
+ row(ui, "First value", |ui| {
+ field(ui, &mut first);
+ });
+ row(ui, "Second value", |ui| {
+ field(ui, &mut second);
+ });
+ };
+ frame(&ctx, vec![], &mut draw);
+ let first_pos = scenario::handle_at("dialog:First value").unwrap();
+ frame(&ctx, pointer(first_pos, true), &mut draw);
+ frame(&ctx, pointer(first_pos, false), &mut draw);
+ frame(&ctx, key(egui::Key::Tab), &mut draw);
+ frame(&ctx, vec![egui::Event::Text("2".to_string())], &mut draw);
+ assert_eq!(first, "1");
+ assert_eq!(second, "2");
+}
+
+#[test]
+fn multiline_text_retains_focus_id_and_three_line_geometry() {
+ let ctx = crate::fonts::test_context();
+ let id = egui::Id::new("multiline_test");
+ let mut value = "First\nSecond".to_string();
+ let mut draw = |ui: &mut Ui| {
+ multiline_text_field(ui, "Text", id, &mut value);
+ };
+ frame(&ctx, vec![], &mut draw);
+ let row = scenario::rect_of("dialog:row:Text").unwrap();
+ assert_eq!(row.height(), 3.0 * crate::theme::Tokens::get().control_height);
+ let at = scenario::handle_at("dialog:Text").unwrap();
+ frame(&ctx, pointer(at, true), &mut draw);
+ frame(&ctx, pointer(at, false), &mut draw);
+ assert!(ctx.memory(|m| m.has_focus(id)));
+}
+
+#[test]
+fn searchable_dropdown_filters_selects_and_accepts_custom_values() {
+ for custom in [false, true] {
+ let ctx = crate::fonts::test_context();
+ let mut filter = if custom { "/fonts/face.ttf".into() } else { "tw".into() };
+ let mut chosen = None;
+ let options = [
+ SearchOption { value: "one", label: "One", handle: Some("search:one") },
+ SearchOption { value: "two", label: "Two", handle: Some("search:two") },
+ ];
+ let mut draw = |ui: &mut Ui| {
+ row(ui, "Font", |ui| {
+ if let Some(value) =
+ searchable_dropdown(ui, "search_test", "One", &mut filter, &options, custom.then_some("Use this font file"), None)
+ {
+ chosen = Some(value);
+ }
+ });
+ };
+ frame(&ctx, vec![], &mut draw);
+ let at = scenario::handle_at("dialog:Font").unwrap();
+ frame(&ctx, pointer(at, true), &mut draw);
+ frame(&ctx, pointer(at, false), &mut draw);
+ frame(&ctx, vec![], &mut draw);
+ assert!(scenario::handle_at("dialog:Font search").is_some());
+ assert!(scenario::handle_at("search:one").is_none(), "filter hides unmatched entries");
+ let pick = scenario::handle_at(if custom { "dialog:Font file" } else { "search:two" }).unwrap();
+ frame(&ctx, pointer(pick, true), &mut draw);
+ frame(&ctx, pointer(pick, false), &mut draw);
+ assert_eq!(chosen.as_deref(), Some(if custom { "/fonts/face.ttf" } else { "two" }));
+ }
+}
diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rs
new file mode 100644
index 0000000000..e26a4683b7
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/gallery.rs
@@ -0,0 +1,432 @@
+//! Layout/paint reference for every element in both themes. No window or GPU required.
+use super::*;
+use crate::{scenario, theme::Tokens};
+use egui::{Ui, vec2};
+
+const ELEMENTS: &[&str] = &[
+ "header",
+ "row",
+ "caption",
+ "hint",
+ "note",
+ "section",
+ "divider",
+ "field",
+ "focused_field",
+ "hint_field",
+ "text_field",
+ "multiline_text_field",
+ "searchable_dropdown",
+ "text_emphasis",
+ "value_pair_named",
+ "dropdown",
+ "selection_field",
+ "selection_field_state",
+ "segmented",
+ "segmented_compact",
+ "segmented_states",
+ "segmented_icons",
+ "checkbox",
+ "checkbox_row",
+ "checkbox_grid",
+ "options",
+ "footer",
+ "footer_apply",
+ "footer_status",
+ "button_pair",
+ "primary",
+ "secondary",
+ "small",
+ "icon",
+ "list_row",
+ "value_pair",
+ "fraction",
+ "status_header",
+ "tool_choices",
+ "toggle_icon",
+];
+
+/// Each example publishes a named rect and at least one handle (except non-interactive dividers).
+fn example(ui: &mut Ui, name: &str) -> (&'static str, Option<&'static str>) {
+ let mut value = "12 mm".to_owned();
+ let mut second = "25 mm".to_owned();
+ let mut selected = 0;
+ let mut checked = true;
+ match name {
+ "header" => {
+ header(ui, "fillet", "Fillet", || {});
+ ("dialog:header", Some("dialog:close"))
+ }
+ "row" => {
+ row(ui, "Gallery", |ui| {
+ field(ui, &mut value);
+ });
+ ("dialog:row:Gallery", Some("dialog:Gallery"))
+ }
+ "caption" => {
+ caption(ui, "Gallery", "Helper text");
+ ("dialog:caption:Gallery", None)
+ }
+ "hint" => {
+ hint(ui, "gallery", "Pick a point or curve");
+ ("dialog:hint:gallery", Some("dialog:hint:gallery"))
+ }
+ "note" => {
+ note(ui, "gallery", "Counts include the original. Center balances copies; Flip chooses the extra side for even totals.");
+ ("dialog:note:gallery", None)
+ }
+ "section" => {
+ section(ui, "gallery", "Options", true, |_| {});
+ ("dialog:section:Options", Some("dialog:section:Options"))
+ }
+ "divider" => {
+ divider(ui, "gallery");
+ ("dialog:divider:gallery", None)
+ }
+ "multiline_text_field" => {
+ multiline_text_field(ui, "Gallery", egui::Id::new("gallery_text"), &mut value);
+ ("dialog:widget:Gallery", Some("dialog:Gallery"))
+ }
+ "searchable_dropdown" => {
+ row(ui, "Gallery", |ui| {
+ searchable_dropdown(
+ ui,
+ "gallery_search",
+ "One",
+ &mut String::new(),
+ &[SearchOption { value: "one", label: "One", handle: None }],
+ None,
+ None,
+ );
+ });
+ ("dialog:row:Gallery", Some("dialog:Gallery"))
+ }
+ "text_emphasis" => {
+ row(ui, "Gallery", |ui| text_emphasis(ui, &mut checked, &mut false));
+ ("dialog:row:Gallery", Some("dialog:Bold"))
+ }
+ "value_pair_named" => {
+ value_pair_named(ui, "Position", [&mut value, &mut second], ["X", "Y"], ["Distance X", "Distance Y"]);
+ ("dialog:row:Position", Some("dialog:Distance X"))
+ }
+ "field"
+ | "focused_field"
+ | "hint_field"
+ | "text_field"
+ | "fraction"
+ | "dropdown"
+ | "selection_field"
+ | "selection_field_state"
+ | "segmented"
+ | "segmented_compact"
+ | "segmented_states"
+ | "segmented_icons"
+ | "checkbox"
+ | "primary"
+ | "secondary"
+ | "small" => {
+ row(ui, "Gallery", |ui| match name {
+ "field" => {
+ field(ui, &mut value);
+ }
+ "focused_field" => {
+ focused_field(ui, &mut value);
+ }
+ "hint_field" => {
+ hint_field(ui, &mut value, "Length");
+ }
+ "text_field" => {
+ text_field(ui, &mut value, "Name");
+ }
+ "fraction" => {
+ fraction_field(ui, &mut 0.5);
+ }
+ "dropdown" => {
+ dropdown(ui, "gallery", &mut selected, &["One", "Two"]);
+ }
+ "selection_field" => {
+ selection_field(ui, "Point 1", true);
+ }
+ "selection_field_state" => {
+ selection_field_state(ui, "Select", false, false);
+ }
+ "segmented" => {
+ segmented(ui, &mut selected, &["One", "Two"]);
+ }
+ "segmented_compact" => {
+ segmented_compact(ui, &mut selected, &["Left", "Center", "Right"]);
+ }
+ "segmented_states" => {
+ segmented_states(ui, &mut selected, &["One", "Two"], &[true, true]);
+ }
+ "segmented_icons" => {
+ segmented_icons(ui, &mut selected, &[IconSegment { key: "normal", icon: "normal", tip: "Normal".into() }], &[]);
+ }
+ "checkbox" => {
+ checkbox(ui, "Option", &mut checked);
+ }
+ "primary" => {
+ primary_button(ui, "Create");
+ }
+ "secondary" => {
+ secondary_button(ui, "Add");
+ }
+ "small" => {
+ small_button(ui, "×");
+ }
+ _ => {}
+ });
+ let handle = match name {
+ "primary" => "dialog:button:Create",
+ "secondary" => "dialog:button:Gallery:Add",
+ "small" => "dialog:button:Gallery:×",
+ "fraction" => "dialog:fraction:Gallery",
+ _ => "dialog:Gallery",
+ };
+ ("dialog:row:Gallery", Some(handle))
+ }
+ "checkbox_row" => {
+ checkbox_row(ui, "gallery", "Option", true);
+ ("sketch_palette:toggle:gallery", Some("sketch_palette:toggle:gallery"))
+ }
+ "checkbox_grid" | "options" => {
+ let mut second = false;
+ let mut items = [("First", &mut checked), ("Second", &mut second)];
+ if name == "options" {
+ options(ui, "gallery", &mut items);
+ } else {
+ checkbox_grid(ui, &mut items, 2);
+ }
+ ("dialog:checkbox:First", Some("dialog:First"))
+ }
+ "footer" | "footer_apply" | "footer_status" => {
+ if name == "footer_status" {
+ footer_with_status(ui, "OK", "Cancel", true, None, Some("Computing…"));
+ } else {
+ footer(ui, "OK", "Cancel", true, (name == "footer_apply").then_some("Apply"));
+ }
+ ("dialog:footer", Some(if name == "footer_apply" { "dialog:apply" } else { "dialog:ok" }))
+ }
+ "button_pair" => {
+ button_pair(
+ ui,
+ "sketch_palette",
+ [false, true],
+ [PairButton { key: "look_at", label: "ui.look_at", icon: Some("lookat") }, PairButton { key: "slice", label: "Slice", icon: None }],
+ );
+ ("sketch_palette:look_at", Some("sketch_palette:look_at"))
+ }
+ "icon" => {
+ icon_button(ui, "Remove", "close");
+ ("dialog:button:Remove", Some("dialog:button:Remove"))
+ }
+ "list_row" => {
+ list_row(ui, "picked", "Point 1");
+ ("dialog:list:picked", Some("dialog:list:picked:remove"))
+ }
+ "value_pair" => {
+ value_pair(ui, "Position", [&mut value, &mut second], ["X", "Y"]);
+ ("dialog:row:Position", Some("dialog:Y"))
+ }
+ "toggle_icon" => {
+ toggle_icon(ui, "Alignment", "Center", &mut checked, "pattern_center");
+ ("dialog:Alignment:Center", Some("dialog:Alignment:Center"))
+ }
+ "tool_choices" => {
+ tool_choices(ui, "Line", "line", &[ToolChoice { key: "line", icon: "normal", label: "Line", enabled: true }]);
+ ("sketch_palette:feature:line", Some("sketch_palette:feature:line"))
+ }
+ "status_header" => {
+ ui.spacing_mut().item_spacing.y = 0.0;
+ status_header(
+ ui,
+ "sketch_palette",
+ "Sketch 1",
+ StatusHeader { icon: "sketch", text: "2 degrees of freedom", complete: false, fraction: 0.5 },
+ );
+ ("sketch_palette:meter", None)
+ }
+ _ => panic!("missing gallery example {name}"),
+ }
+}
+
+#[test]
+fn every_element_has_geometry_and_stays_in_its_allocation_in_both_themes() {
+ let previous = crate::theme::is_dark();
+ for dark in [false, true] {
+ crate::theme::set_dark(dark);
+ for &name in ELEMENTS {
+ let ctx = crate::fonts::test_context();
+ ctx.set_visuals(if dark { egui::Visuals::dark() } else { egui::Visuals::light() });
+ for _ in 0..3 {
+ scenario::clear_handles();
+ let mut allocation = egui::Rect::NOTHING;
+ let mut published = ("", None);
+ let mut output = ctx.run_ui(
+ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(400.0, 600.0))), ..Default::default() },
+ |ui| {
+ ui.set_width(320.0);
+ allocation = ui
+ .scope(|ui| {
+ scope(ui, |ui| {
+ published = example(ui, name);
+ })
+ })
+ .response
+ .rect;
+ },
+ );
+ output.textures_delta.clear();
+ let rect = scenario::rect_of(published.0).unwrap_or_else(|| panic!("{name}: missing {}", published.0));
+ assert!(rect.is_finite() && rect.is_positive(), "{name}: {rect:?}");
+ assert!(allocation.expand(1.0).contains_rect(rect), "{name}: {rect:?} outside {allocation:?}");
+ if let Some(handle) = published.1 {
+ assert!(
+ rect.contains(scenario::handle_at(handle).unwrap_or_else(|| panic!("{name}: missing {handle}"))),
+ "{name}: handle outside {rect:?}"
+ );
+ }
+ if published.0.starts_with("dialog:row:") {
+ assert_eq!(rect.height(), Tokens::get().control_height, "{name}");
+ }
+ for shape in output.shapes {
+ // Native icon-only buttons keep an empty text shape. It has no vertices;
+ // its sentinel bounds do not describe any painted pixels.
+ if matches!(&shape.shape, egui::Shape::Text(text) if text.galley.num_vertices == 0) {
+ continue;
+ }
+ let painted = shape.shape.visual_bounding_rect().intersect(shape.clip_rect);
+ if painted.is_positive() {
+ assert!(allocation.expand(1.0).contains_rect(painted), "{name}: paint {painted:?} outside {allocation:?}: {:?}", shape.shape);
+ }
+ }
+ }
+ }
+ }
+ crate::theme::set_dark(previous);
+}
+
+#[test]
+fn apply_does_not_submit_and_obeys_validation() {
+ for enabled in [false, true] {
+ let ctx = crate::fonts::test_context();
+ let mut action = Action::None;
+ let mut draw = |ui: &mut Ui| {
+ action = footer(ui, "OK", "Cancel", enabled, Some("Apply"));
+ };
+ super::test_support::frame(&ctx, vec![], &mut draw);
+ let at = scenario::handle_at("dialog:apply").unwrap();
+ super::test_support::frame(&ctx, super::test_support::pointer(at, true), &mut draw);
+ super::test_support::frame(&ctx, super::test_support::pointer(at, false), &mut draw);
+ assert_eq!(action, if enabled { Action::Apply } else { Action::None });
+ }
+}
+
+#[test]
+fn picked_item_remove_and_paired_values_have_independent_targets() {
+ let ctx = crate::fonts::test_context();
+ let mut removed = false;
+ let mut draw = |ui: &mut Ui| {
+ removed = list_row(ui, "point-1", "Point 1").clicked();
+ };
+ super::test_support::frame(&ctx, vec![], &mut draw);
+ let at = scenario::handle_at("dialog:list:point-1:remove").unwrap();
+ super::test_support::frame(&ctx, super::test_support::pointer(at, true), &mut draw);
+ super::test_support::frame(&ctx, super::test_support::pointer(at, false), &mut draw);
+ assert!(removed);
+
+ let mut x = String::new();
+ let mut y = String::new();
+ let mut draw = |ui: &mut Ui| {
+ value_pair(ui, "Position", [&mut x, &mut y], ["X", "Y"]);
+ };
+ super::test_support::frame(&ctx, vec![], &mut draw);
+ let row = scenario::rect_of("dialog:row:Position").unwrap();
+ let first = scenario::handle_at("dialog:X").unwrap();
+ let second = scenario::handle_at("dialog:Y").unwrap();
+ assert_eq!(row.height(), Tokens::get().control_height);
+ assert!(row.contains(first) && row.contains(second) && first.x < second.x);
+ super::test_support::frame(&ctx, super::test_support::pointer(second, true), &mut draw);
+ super::test_support::frame(&ctx, super::test_support::pointer(second, false), &mut draw);
+ super::test_support::frame(&ctx, vec![egui::Event::Text("25".into())], &mut draw);
+ assert_eq!(x, "");
+ assert_eq!(y, "25");
+}
+
+#[test]
+fn gallery_rows_share_a_label_column_after_measurement_in_both_themes() {
+ let previous = crate::theme::is_dark();
+ for dark in [false, true] {
+ crate::theme::set_dark(dark);
+ let ctx = crate::fonts::test_context();
+ let mut value = "3".to_owned();
+ for _ in 0..3 {
+ super::test_support::frame(&ctx, vec![], |ui| {
+ row(ui, "Edges", |ui| {
+ selection_field(ui, "Edge 1", true);
+ });
+ row(ui, "Counterbore depth", |ui| {
+ field(ui, &mut value);
+ });
+ });
+ }
+ let first = scenario::rect_of("dialog:control:Edges").unwrap();
+ let second = scenario::rect_of("dialog:control:Counterbore depth").unwrap();
+ assert_eq!(first.left(), second.left());
+ assert_eq!(first.height(), Tokens::get().control_height);
+ assert_eq!(second.height(), Tokens::get().control_height);
+ let width = scenario::rect_of("dialog:label:Edges").unwrap().width();
+ assert!(width >= Tokens::get().form_label_width && width <= Tokens::get().form_label_width * 1.6);
+ }
+ crate::theme::set_dark(previous);
+}
+
+#[test]
+fn compound_row_actions_preserve_the_original_field_handle() {
+ let ctx = crate::fonts::test_context();
+ let mut value = "3 mm".to_owned();
+ let mut expected = None;
+ super::test_support::frame(&ctx, vec![], |ui| {
+ row(ui, "Mid Radius", |ui| {
+ ui.horizontal(|ui| {
+ ui.allocate_ui_with_layout(
+ egui::vec2(Tokens::get().space_24 * 3.0, row_height()),
+ egui::Layout::left_to_right(egui::Align::Center),
+ |ui| {
+ field(ui, &mut value);
+ },
+ );
+ expected = scenario::handle_at("dialog:Mid Radius");
+ small_button(ui, "×");
+ });
+ });
+ });
+ assert_eq!(scenario::handle_at("dialog:Mid Radius"), expected);
+ assert!(expected.is_some());
+ assert_ne!(scenario::handle_at("dialog:button:Mid Radius:×"), expected);
+}
+
+#[test]
+fn emphasis_and_compact_modes_keep_independent_actions_in_both_themes() {
+ for dark in [false, true] {
+ let ctx = crate::fonts::test_context();
+ ctx.set_visuals(if dark { egui::Visuals::dark() } else { egui::Visuals::light() });
+ let mut bold = false;
+ let mut italic = false;
+ let mut selected = 0;
+ let mut draw = |ui: &mut Ui| {
+ row(ui, "Style", |ui| text_emphasis(ui, &mut bold, &mut italic));
+ row(ui, "Alignment", |ui| {
+ segmented_compact(ui, &mut selected, &["Long translated left", "Long translated centre", "Long translated right"]);
+ });
+ };
+ super::test_support::frame(&ctx, vec![], &mut draw);
+ for handle in ["dialog:Bold", "dialog:Italic", "dialog:Alignment:Long translated centre"] {
+ let at = scenario::handle_at(handle).unwrap();
+ super::test_support::frame(&ctx, super::test_support::pointer(at, true), &mut draw);
+ super::test_support::frame(&ctx, super::test_support::pointer(at, false), &mut draw);
+ }
+ assert!(bold && italic);
+ assert_eq!(selected, 1);
+ }
+}
diff --git a/crates/ui-egui/src/ui_kit/layout.rs b/crates/ui-egui/src/ui_kit/layout.rs
new file mode 100644
index 0000000000..e52a096e73
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/layout.rs
@@ -0,0 +1,200 @@
+//! Layout elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::{metrics::*, text::paint_text};
+use crate::{scenario, theme::Tokens};
+use egui::{Response, RichText, Ui, vec2};
+
+pub(super) const FORM: &str = "sc_dense_form";
+
+pub(super) const LABEL: &str = "sc_form_label";
+
+/// Mark a form without global state: children inherit this tag through their UI stack.
+/// Inherited form styling and label-column identity. Tokens: `space_4/8, form_gap_y, control_height, font_label, accent, selected_bg, dialog_rule, control_fill/border/radius, text`.
+pub fn scope<R>(ui: &mut Ui, add: impl FnOnce(&mut Ui) -> R) -> R {
+ ui.scope_builder(egui::UiBuilder::new().ui_stack_info(egui::UiStackInfo::default().with_tag(FORM)), |ui| {
+ let t = Tokens::get();
+ ui.spacing_mut().item_spacing = vec2(t.space_4, t.form_gap_y);
+ ui.spacing_mut().interact_size.y = row_height();
+ ui.spacing_mut().button_padding = vec2(t.space_8, t.space_4);
+ ui.style_mut().text_styles.insert(egui::TextStyle::Body, egui::FontId::proportional(t.font_label));
+ ui.style_mut().text_styles.insert(egui::TextStyle::Button, egui::FontId::proportional(t.font_label));
+ let visuals = ui.visuals_mut();
+ visuals.selection.stroke = egui::Stroke::new(1.0, t.accent);
+ visuals.selection.bg_fill = t.selected_bg;
+ visuals.widgets.noninteractive.bg_stroke = egui::Stroke::new(1.0, t.dialog_rule);
+ for state in [&mut visuals.widgets.inactive, &mut visuals.widgets.hovered, &mut visuals.widgets.active, &mut visuals.widgets.open] {
+ state.bg_fill = t.control_fill;
+ state.weak_bg_fill = t.control_fill;
+ state.bg_stroke = egui::Stroke::new(1.0, t.control_border);
+ state.corner_radius = t.control_radius.into();
+ state.expansion = 0.0;
+ state.fg_stroke.color = t.text;
+ }
+ ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Truncate);
+ add(ui)
+ })
+ .inner
+}
+
+/// Detect an inherited form scope. Tokens: `none`.
+pub(crate) fn contains(ui: &Ui) -> bool {
+ ui.stack().iter().any(|node| node.tags().contains(FORM))
+}
+
+/// Read the enclosing row accessibility label. Tokens: `none`.
+pub(super) fn label(ui: &Ui) -> &str {
+ ui.stack().iter().find_map(|node| node.tags().get_downcast::<String>(LABEL)).map(String::as_str).unwrap_or("")
+}
+
+/// Publish accessibility and scenario geometry. Tokens: `none`.
+pub(super) fn publish(ui: &Ui, response: &Response, kind: egui::WidgetType) {
+ let label = label(ui);
+ response.widget_info(|| egui::WidgetInfo::labeled(kind, ui.is_enabled(), crate::i18n::tr_label(label)));
+ publish_geometry(ui, response);
+}
+
+/// Aligned label/control row, 24 pt today. Tokens: `control_height, form_label_width, font_label, dialog_label, space_8`.
+pub fn row<R>(ui: &mut Ui, text: &str, control: impl FnOnce(&mut Ui) -> R) -> R {
+ sized_row(ui, text, row_height(), control)
+}
+
+/// Internal form geometry for controls which need several lines (e.g. text areas).
+pub(super) fn sized_row<R>(ui: &mut Ui, text: &str, height: f32, control: impl FnOnce(&mut Ui) -> R) -> R {
+ let t = Tokens::get();
+ let width = dimension(ui.available_width());
+ let (rect, _) = ui.allocate_exact_size(vec2(width, height), egui::Sense::hover());
+ let label_width = label_column(ui, text, width);
+ let label_rect = egui::Rect::from_min_size(rect.min, vec2(label_width, rect.height()));
+ ui.scope_builder(egui::UiBuilder::new().max_rect(label_rect).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
+ // Left aligned in the label column, as in the design.
+ ui.add(egui::Label::new(RichText::new(crate::i18n::tr_label(text)).size(t.font_label).color(t.dialog_label)).truncate())
+ .on_hover_text(crate::i18n::tr_label(text));
+ });
+ let control_rect = egui::Rect::from_min_max(egui::pos2((label_rect.right() + t.space_8).min(rect.right()), rect.top()), rect.max);
+ let result = ui
+ .scope_builder(
+ egui::UiBuilder::new()
+ .id_salt(text)
+ .max_rect(control_rect)
+ .layout(egui::Layout::left_to_right(egui::Align::Center))
+ .ui_stack_info(egui::UiStackInfo::default().with_tag_value(LABEL, text.to_string())),
+ |ui| {
+ ui.set_clip_rect(ui.clip_rect().intersect(control_rect));
+ ui.spacing_mut().text_edit_width = control_rect.width();
+ control(ui)
+ },
+ )
+ .inner;
+ scenario::publish_rect(&format!("dialog:row:{text}"), rect);
+ scenario::publish_rect(&format!("dialog:label:{text}"), label_rect);
+ scenario::publish_rect(&format!("dialog:control:{text}"), control_rect);
+ scenario::publish_handle(&format!("dialog:row:{text}"), rect.center());
+ result
+}
+
+/// A dim one-line caption in the control column of the row labelled `aligned_to`, directly under that
+/// row's control. It says in words what a colour or an icon shows, so colour is never the only cue.
+/// Dim helper beneath a row control. Tokens: `form_icon_size, font_small, text_dim, space_8; label-column tokens`.
+pub fn caption(ui: &mut Ui, aligned_to: &str, text: &str) {
+ let t = Tokens::get();
+ let width = dimension(ui.available_width());
+ let (rect, _) = ui.allocate_exact_size(vec2(width, t.form_icon_size), egui::Sense::hover());
+ let left = (rect.left() + label_column(ui, aligned_to, width) + t.space_8).min(rect.right());
+ let text_rect = egui::Rect::from_min_max(egui::pos2(left, rect.top()), rect.max);
+ paint_text(ui, text_rect, text, egui::FontId::proportional(t.font_small), t.text_dim, false);
+ scenario::publish_rect(&format!("dialog:caption:{aligned_to}"), text_rect);
+}
+
+/// Memory belongs to the enclosing dialog ID; animation is avoided so each row keeps its fixed height.
+/// Persisted disclosure with a rule and uppercase title. Tokens: `control_height, space_2, radius_sm, hover, dialog_rule, form_section_icon_size, form_gap_y, font_caption, font_section_tracking, text_dim`.
+pub fn section<R>(ui: &mut Ui, id: impl egui::AsIdSalt, title: &str, default_open: bool, add: impl FnOnce(&mut Ui) -> R) -> Option<R> {
+ let t = Tokens::get();
+ ui.add_space(t.space_2);
+ let id = ui.make_persistent_id(id);
+ let mut open = ui.ctx().data_mut(|data| data.get_persisted::<bool>(id)).unwrap_or(default_open);
+ let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::click());
+ // The section's top rule is the border of its header row.
+ ui.painter().hline(rect.x_range(), rect.top(), egui::Stroke::new(1.0, t.dialog_rule));
+ if response.hovered() || response.has_focus() {
+ ui.painter().rect_filled(rect.shrink2(vec2(0.0, 1.0)), t.radius_sm, t.hover);
+ }
+ let icon_rect = egui::Rect::from_center_size(
+ egui::pos2(rect.left() + t.form_section_icon_size / 2.0, rect.center().y),
+ vec2(t.form_section_icon_size, t.form_section_icon_size),
+ );
+ crate::icons::paint_ink(ui.painter(), icon_rect, if open { "chevron" } else { "chevron_right" }, t.text_dim);
+ let text_rect = egui::Rect::from_min_max(egui::pos2((icon_rect.right() + t.form_gap_y).min(rect.right()), rect.top()), rect.max);
+ paint_text(ui, text_rect, &crate::i18n::tr_label(title).to_uppercase(), crate::fonts::semibold(t.font_caption), t.text_dim, true);
+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::CollapsingHeader, ui.is_enabled(), open, crate::i18n::tr_label(title)));
+ scenario::publish_handle(&format!("dialog:section:{title}"), response.rect.center());
+ scenario::publish_rect(&format!("dialog:section:{title}"), rect);
+ if response.clicked() {
+ open = !open;
+ }
+ ui.ctx().data_mut(|data| data.insert_persisted(id, open));
+ open.then(|| ui.push_id(id, add).inner)
+}
+
+/// Dim helper line beneath a header. Tokens: control_height, font_small and text_dim.
+/// Helper text below a card header. Tokens: `control_height, font_small, text_dim`.
+pub fn hint(ui: &mut Ui, key: &str, text: &str) -> Response {
+ let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());
+ paint_text(ui, rect, text, egui::FontId::proportional(Tokens::get().font_small), Tokens::get().text_dim, false);
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ scenario::publish_rect(&format!("dialog:hint:{key}"), rect);
+ scenario::publish_handle(&format!("dialog:hint:{key}"), rect.center());
+ response.on_hover_text(text)
+}
+
+/// Wrapping explanatory text for a card's body (a rule or a caveat too long for the single-line `hint`).
+/// Tokens: `font_small, text_dim, space_4`.
+pub fn note(ui: &mut Ui, key: &str, text: &str) -> Response {
+ let t = Tokens::get();
+ let width = dimension(ui.available_width());
+ let galley = ui.painter().layout(text.to_string(), egui::FontId::proportional(t.font_small), t.text_dim, width);
+ let (rect, response) = ui.allocate_exact_size(vec2(width, galley.size().y + t.space_4 * 2.0), egui::Sense::hover());
+ ui.painter().galley(egui::pos2(rect.left(), rect.top() + t.space_4), galley, t.text_dim);
+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));
+ scenario::publish_rect(&format!("dialog:note:{key}"), rect);
+ response
+}
+
+/// Picked-item list entry with a remove action. Returns that action's Response.
+/// Tokens: control_height, space_8, font_label, text and icon-button tokens.
+/// Picked-item row with a remove action. Tokens: `control_height, space_8, font_label, text; icon-button tokens`.
+pub fn list_row(ui: &mut Ui, key: &str, text: &str) -> Response {
+ let t = Tokens::get();
+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());
+ let remove = egui::Rect::from_min_max(egui::pos2((rect.right() - row_height()).max(rect.left()), rect.top()), rect.max);
+ let label = egui::Rect::from_min_max(rect.min, egui::pos2((remove.left() - t.space_8).max(rect.left()), rect.bottom()));
+ paint_text(ui, label, text, egui::FontId::proportional(t.font_label), t.text, false);
+ let response = ui.push_id(key, |ui| super::icon_button_at(ui, remove, "close", "Remove")).inner;
+ scenario::publish_rect(&format!("dialog:list:{key}"), rect);
+ scenario::publish_handle(&format!("dialog:list:{key}:remove"), remove.center());
+ response
+}
+
+/// Full-width rule; Tokens: dialog_rule. Use between groups without extra padding.
+/// Full-width rule without extra padding. Tokens: `dialog_rule`.
+pub fn divider(ui: &mut Ui, key: &str) {
+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), 1.0), egui::Sense::hover());
+ ui.painter().hline(rect.x_range(), rect.top(), egui::Stroke::new(1.0, Tokens::get().dialog_rule));
+ scenario::publish_rect(&format!("dialog:divider:{key}"), rect);
+}
+
+/// Give a compound row's subfield its accessible name without allocating layout space.
+/// Name a subfield without allocating another row. Tokens: `none`.
+pub(super) fn named_control<R>(ui: &mut Ui, label: &str, add: impl FnOnce(&mut Ui) -> R) -> R {
+ ui.scope_builder(egui::UiBuilder::new().id_salt(label).ui_stack_info(egui::UiStackInfo::default().with_tag_value(LABEL, label.to_owned())), add)
+ .inner
+}
+
+/// Publish geometry without replacing native accessibility. Tokens: `none`.
+pub(super) fn publish_geometry(ui: &Ui, response: &Response) {
+ let label = label(ui);
+ scenario::publish_handle(&format!("dialog:{label}"), response.rect.center());
+ scenario::publish_rect(&format!("dialog:widget:{label}"), response.rect);
+}
+
+#[cfg(test)]
+#[path = "layout_tests.rs"]
+mod tests;
diff --git a/crates/ui-egui/src/ui_kit/layout_tests.rs b/crates/ui-egui/src/ui_kit/layout_tests.rs
new file mode 100644
index 0000000000..a673948565
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/layout_tests.rs
@@ -0,0 +1,104 @@
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::{scenario, theme::Tokens};
+use egui::Ui;
+
+#[test]
+fn row_height_and_label_column_are_fixed_for_long_labels_and_expressions() {
+ let ctx = crate::fonts::test_context();
+ let mut value = "width / 2 + 10 mm".to_string();
+ for _ in 0..3 {
+ frame(&ctx, vec![], |ui| {
+ row(ui, "A long parameter label that must elide", |ui| {
+ field(ui, &mut value);
+ });
+ row(ui, "Radius", |ui| {
+ field(ui, &mut value);
+ });
+ });
+ }
+ let first = scenario::rect_of("dialog:row:A long parameter label that must elide").unwrap();
+ let second = scenario::rect_of("dialog:row:Radius").unwrap();
+ let label = scenario::rect_of("dialog:label:Radius").unwrap();
+ let control = scenario::rect_of("dialog:control:Radius").unwrap();
+ assert_eq!(first.height(), Tokens::get().control_height);
+ assert_eq!(second.height(), Tokens::get().control_height);
+ // The design's grid: 24 pt controls with a 5 pt row gap and a 70 pt label column (wider only for long labels).
+ assert!(
+ (second.top() - first.bottom() - Tokens::get().form_gap_y).abs() < 0.01,
+ "Plex Mono fields must retain the row gap: {first:?}, {second:?}"
+ );
+ // The long label widens the column for every row, up to 1.6 times the design's width.
+ assert_eq!(label.width(), Tokens::get().form_label_width * 1.6);
+ assert_eq!(scenario::rect_of("dialog:label:A long parameter label that must elide").unwrap().width(), label.width());
+ assert!(control.left() > label.right());
+ assert!(second.contains_rect(control));
+ assert_eq!(value, "width / 2 + 10 mm");
+}
+
+#[test]
+fn section_toggles_persist_per_dialog() {
+ let ctx = crate::fonts::test_context();
+ let mut a = 0;
+ let mut b = 0;
+ let mut draw = |ui: &mut Ui| {
+ ui.push_id("fillet", |ui| {
+ section(ui, "opts", "Options", false, |_| a += 1);
+ });
+ ui.push_id("hole", |ui| {
+ section(ui, "opts", "Hole options", false, |_| b += 1);
+ });
+ };
+ frame(&ctx, vec![], &mut draw);
+ let pos = scenario::handle_at("dialog:section:Options").unwrap();
+ frame(&ctx, pointer(pos, true), &mut draw);
+ frame(&ctx, pointer(pos, false), &mut draw);
+ frame(&ctx, vec![], &mut draw);
+ assert!(a >= 2);
+ assert_eq!(b, 0);
+ let before = a;
+ frame(&ctx, pointer(pos, true), |ui| {
+ ui.push_id("fillet", |ui| {
+ section(ui, "opts", "Options", false, |_| a += 1);
+ });
+ });
+ frame(&ctx, pointer(pos, false), |ui| {
+ ui.push_id("fillet", |ui| {
+ section(ui, "opts", "Options", false, |_| a += 1);
+ });
+ });
+ assert_eq!(a, before + 1);
+}
+
+#[test]
+fn short_labels_keep_the_designs_label_column_and_long_ones_widen_it_for_every_row() {
+ fn widths(labels: [&str; 2]) -> (f32, f32) {
+ let ctx = egui::Context::default();
+ crate::fonts::setup_fonts(&ctx);
+ let mut value = String::new();
+ for _ in 0..3 {
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ ui.set_width(300.0);
+ scope(ui, |ui| {
+ for label in labels {
+ row(ui, label, |ui| {
+ field(ui, &mut value);
+ });
+ }
+ });
+ });
+ output.textures_delta.clear();
+ }
+ (
+ scenario::rect_of(&format!("dialog:label:{}", labels[0])).unwrap().width(),
+ scenario::rect_of(&format!("dialog:label:{}", labels[1])).unwrap().width(),
+ )
+ }
+ let t = Tokens::get();
+ let (a, b) = widths(["Edges", "Radius"]);
+ assert_eq!((a, b), (t.form_label_width, t.form_label_width));
+ let (a, b) = widths(["Edges", "Counterbore depth"]);
+ assert_eq!(a, b, "one column per form");
+ assert!(a > t.form_label_width && a <= t.form_label_width * 1.6, "{a}");
+}
diff --git a/crates/ui-egui/src/ui_kit/metrics.rs b/crates/ui-egui/src/ui_kit/metrics.rs
new file mode 100644
index 0000000000..ef80614b85
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/metrics.rs
@@ -0,0 +1,59 @@
+//! Metrics elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::layout::FORM;
+use crate::theme::Tokens;
+use egui::Ui;
+
+/// Row height for controls. Tokens: `control_height`.
+pub fn row_height() -> f32 {
+ Tokens::get().control_height
+}
+
+/// Feature heading height. Tokens: `form_header_height`.
+pub fn header_height() -> f32 {
+ Tokens::get().form_header_height
+}
+
+/// Sanitize an input dimension. Tokens: `none`.
+pub(super) fn dimension(value: f32) -> f32 {
+ if value.is_finite() { value.max(0.0) } else { 0.0 }
+}
+
+/// Allocate exactly one control-height row. Long labels elide; controls cannot widen the card.
+/// The design's label column is `form_label_width` wide; a dialog with longer labels widens the
+/// column for all of its rows (up to 1.6 times that), so the controls still line up and labels
+/// are not elided. The widest label of the last pass sizes the column, so it settles within
+/// two frames and shrinks again when the long rows go away.
+/// Shared label width, capped at 1.6x. Tokens: `form_label_width, font_label, dialog_label, space_4`.
+pub(super) fn label_column(ui: &Ui, text: &str, row_width: f32) -> f32 {
+ let t = Tokens::get();
+ let base = t.form_label_width;
+ let natural = ui
+ .painter()
+ .layout_no_wrap(crate::i18n::tr_label(text).to_string(), egui::FontId::proportional(t.font_label), t.dialog_label)
+ .size()
+ .x
+ .ceil();
+ let widest = match ui.stack().iter().find(|node| node.tags().contains(FORM)).map(|node| node.id) {
+ Some(form) => {
+ let key = form.with("label_column");
+ let pass = ui.ctx().cumulative_pass_nr();
+ let (seen, current, previous) = ui.ctx().data(|d| d.get_temp::<(u64, f32, f32)>(key)).unwrap_or((pass, 0.0, 0.0));
+ let (current, previous) = if seen == pass {
+ (current, previous)
+ } else if seen + 1 == pass {
+ (0.0, current)
+ } else {
+ (0.0, 0.0)
+ };
+ let current = current.max(natural);
+ ui.ctx().data_mut(|d| d.insert_temp(key, (pass, current, previous)));
+ current.max(previous)
+ }
+ None => natural,
+ };
+ (widest + t.space_4).clamp(base, base * 1.6).min(row_width * 0.5)
+}
+
+#[cfg(test)]
+#[path = "metrics_tests.rs"]
+mod tests;
diff --git a/crates/ui-egui/src/ui_kit/metrics_tests.rs b/crates/ui-egui/src/ui_kit/metrics_tests.rs
new file mode 100644
index 0000000000..62f696d195
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/metrics_tests.rs
@@ -0,0 +1,23 @@
+use crate::ui_kit::metrics::dimension;
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::scenario;
+
+#[test]
+fn non_finite_and_tiny_row_widths_are_sanitized() {
+ assert_eq!(dimension(f32::NAN), 0.0);
+ assert_eq!(dimension(f32::INFINITY), 0.0);
+ assert_eq!(dimension(-10.0), 0.0);
+ let ctx = crate::fonts::test_context();
+ for width in [0.0, 1.0, 12.0] {
+ frame(&ctx, vec![], |ui| {
+ ui.set_width(width);
+ row(ui, "Tiny", |ui| {
+ let mut value = String::new();
+ field(ui, &mut value);
+ });
+ });
+ assert!(scenario::rect_of("dialog:row:Tiny").unwrap().is_finite());
+ }
+}
diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rs
new file mode 100644
index 0000000000..4f415d8282
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/mod.rs
@@ -0,0 +1,26 @@
+//! Tokenised dense card library. Import elements through `crate::ui_kit`.
+//! `Panel` owns card composition; rows own aligned label/control columns and retain egui focus.
+//! Geometry, typography and colours come from `theme::Tokens`. See `docs/ui-kit.md`.
+pub mod actions;
+pub mod choice;
+pub mod fields;
+pub mod layout;
+pub mod metrics;
+pub(crate) mod panel;
+pub mod status;
+pub mod text;
+
+pub use actions::*;
+pub use choice::*;
+pub use fields::*;
+pub use layout::*;
+pub use metrics::{header_height, row_height};
+pub use panel::header;
+pub(crate) use panel::{ComputeStatus, FeatureOptions, Panel, Part};
+pub use status::*;
+
+#[cfg(test)]
+mod gallery;
+#[cfg(test)]
+#[path = "test_support_tests.rs"]
+mod test_support;
diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rs
new file mode 100644
index 0000000000..5a2bf0ab7c
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/panel.rs
@@ -0,0 +1,257 @@
+//! Panel elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use super::{actions::icon_button_at, metrics::*, text::paint_text};
+use crate::{scenario, theme::Tokens};
+use egui::{Ui, vec2};
+
+/// Feature title/icon/close band. Tokens: `form_header_height, form_icon_size, form_close_size, form_inset, font_label, text, dialog_rule, space_8/10; icon_button_at tokens`.
+pub fn header(ui: &mut Ui, icon: &str, title: &str, on_close: impl FnOnce()) {
+ let t = Tokens::get();
+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), header_height()), egui::Sense::hover());
+ // Design: padding 0 8 0 10, an 18 pt icon, a 7 pt gap, a 22 pt close button.
+ let icon_rect = egui::Rect::from_center_size(
+ egui::pos2(rect.left() + t.space_10 + t.form_icon_size / 2.0, rect.center().y),
+ vec2(t.form_icon_size, t.form_icon_size),
+ );
+ crate::icons::paint_icon(ui.painter(), icon_rect, icon, 1.0);
+ let close_rect = egui::Rect::from_center_size(
+ egui::pos2((rect.right() - t.space_8 - t.form_close_size / 2.0).max(rect.left()), rect.center().y),
+ vec2(t.form_close_size, t.form_close_size),
+ );
+ let close = icon_button_at(ui, close_rect, "close", "Close");
+ scenario::publish_handle("dialog:close", close.rect.center());
+ if close.clicked() {
+ on_close();
+ }
+ let left = (icon_rect.right() + t.form_inset).min(close_rect.left());
+ let title_rect = egui::Rect::from_min_max(egui::pos2(left, rect.top()), egui::pos2(close_rect.left().max(left), rect.bottom()));
+ paint_text(ui, title_rect, title, crate::fonts::semibold(t.font_label), t.text, false);
+ let title_response = ui.interact(title_rect, ui.make_persistent_id("title_text"), egui::Sense::hover());
+ title_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ scenario::publish_rect("dialog:header", rect);
+ ui.painter().hline(rect.x_range(), rect.bottom(), egui::Stroke::new(1.0, t.dialog_rule));
+}
+
+/// A bounded docked or floating card. Uses form_card_width and the caller's tokenised frame.
+/// Window IDs and content scopes are retained so moving a card does not reset field focus.
+pub(crate) struct Panel<'a> {
+ title: &'a str,
+ id: egui::Id,
+ anchor: egui::Pos2,
+ viewport: egui::Rect,
+ side: crate::frame::Side,
+ frame: egui::Frame,
+ width: f32,
+}
+
+pub(crate) struct FeatureOptions<'a> {
+ pub icon: &'a str,
+ pub title: &'a str,
+ pub drag_key: &'a str,
+ pub moved: egui::Vec2,
+ pub docked: egui::Pos2,
+ pub apply_label: Option<&'a str>,
+}
+
+/// State read after rendering the fields, just as in the original feature card.
+pub(crate) struct ComputeStatus {
+ pub text: Option<String>,
+ pub busy: bool,
+ pub applying: bool,
+}
+
+pub(crate) enum Part {
+ Header,
+ Body,
+ Footer,
+}
+
+impl<'a> Panel<'a> {
+ /// Feature surface; Tokens: dialog_body and shell_card/dock_frame's border/shadow tokens.
+ pub(crate) fn feature_frame(ctx: &egui::Context, layout: crate::shell::LayoutMode, side: crate::frame::Side) -> egui::Frame {
+ let t = Tokens::get();
+ if layout == crate::shell::LayoutMode::Floating {
+ crate::frame::shell_card(t.dialog_body).inner_margin(0.0)
+ } else {
+ crate::frame::dock_frame(ctx, side).fill(t.dialog_body).inner_margin(0.0)
+ }
+ }
+
+ /// Palette surface; Tokens: panel, sketch_palette_alpha, radius_xl and shell/dock tokens.
+ pub(crate) fn palette_frame(ctx: &egui::Context, layout: crate::shell::LayoutMode) -> egui::Frame {
+ let t = Tokens::get();
+ if layout == crate::shell::LayoutMode::Floating {
+ crate::frame::shell_card(t.panel.gamma_multiply(t.sketch_palette_alpha)).corner_radius(t.radius_xl).inner_margin(0.0)
+ } else {
+ crate::frame::dock_frame(ctx, crate::frame::Side::Right).fill(t.panel.gamma_multiply(t.sketch_palette_alpha)).inner_margin(0.0)
+ }
+ }
+
+ pub(crate) fn new(title: &'a str, id: egui::Id, anchor: egui::Pos2, viewport: egui::Rect, side: crate::frame::Side, frame: egui::Frame) -> Self {
+ Self { title, id, anchor, viewport, side, frame, width: Tokens::get().form_card_width }
+ }
+
+ pub(crate) fn width(mut self, width: f32) -> Self {
+ self.width = width;
+ self
+ }
+
+ /// The painted anchor also drives dragging, including the shell's edge clearance.
+ fn bounded_anchor(&self) -> egui::Pos2 {
+ let viewport = self.viewport;
+ let width = self.width.min(viewport.width().max(0.0));
+ let x = match self.side {
+ crate::frame::Side::Right => {
+ self.anchor.x.clamp(viewport.left() + width, (viewport.right() - Tokens::get().space_8).max(viewport.left() + width))
+ }
+ crate::frame::Side::Left => self.anchor.x.clamp(viewport.left(), viewport.right() - width),
+ };
+ egui::pos2(x, self.anchor.y.clamp(viewport.top(), viewport.bottom()))
+ }
+
+ pub(crate) fn window(&self) -> egui::Window<'a> {
+ let gap = crate::shell::SHELL_GAP;
+ let frame = self.frame;
+ let viewport = self.viewport;
+ let anchor = self.bounded_anchor();
+ let side = self.side;
+ let margin = frame.total_margin();
+ let width = self.width.min(viewport.width().max(0.0));
+ let inner_width = (width - margin.sum().x).max(0.0);
+ let height = (viewport.bottom() - anchor.y - gap).max(0.0);
+ // Keep drawing safe when even the header/footer cannot fit. egui clips the contents to
+ // the remaining viewport; the normal small-height case still keeps both actions visible.
+ egui::Window::new(self.title)
+ .enabled(!crate::issue_report::cad_input_blocked())
+ .id(self.id)
+ .title_bar(false)
+ .pivot(match side {
+ crate::frame::Side::Right => egui::Align2::RIGHT_TOP,
+ crate::frame::Side::Left => egui::Align2::LEFT_TOP,
+ })
+ .fixed_pos(anchor)
+ .constrain(false)
+ .collapsible(false)
+ .resizable(false)
+ .min_width(inner_width)
+ .max_width(inner_width)
+ .default_width(inner_width)
+ .min_height(0.0)
+ .max_height((height - margin.sum().y).max(0.0))
+ .scroll(false)
+ .frame(frame)
+ .default_height(0.0)
+ .fade_in(false)
+ .fade_out(false)
+ .order(egui::Order::Middle)
+ }
+
+ /// Feature header, scrolling padded body, pinned actions, drag target and compute status.
+ /// Tokens: form_header_height, form_footer_height, space_6/8/10/14/16, dialog_body.
+ pub(crate) fn feature(
+ &self,
+ ui: &mut Ui,
+ heading: FeatureOptions<'_>,
+ disabled: bool,
+ valid: bool,
+ body: impl FnOnce(&mut Ui) -> ComputeStatus,
+ ) -> (bool, super::Action) {
+ super::scope(ui, |ui| {
+ let t = Tokens::get();
+ let min = ui.cursor().min;
+ let band = egui::Rect::from_min_size(min, vec2(ui.available_width(), super::header_height()));
+ crate::frame::drag_dock(ui, band, heading.drag_key, heading.moved, self.bounded_anchor() - heading.docked);
+ let mut close = false;
+ header(ui, heading.icon, heading.title, || close = true);
+ let bottom = self.viewport.bottom() - crate::shell::SHELL_GAP - self.frame.inner_margin.bottomf() - self.frame.stroke.width;
+ let footer_height = t.form_footer_height;
+ let fields_height = (bottom - ui.cursor().top() - footer_height).max(0.0);
+ let fields_rect = egui::Rect::from_min_size(ui.cursor().min, vec2(ui.available_width(), fields_height));
+ let state = ui
+ .scope_builder(egui::UiBuilder::new().max_rect(fields_rect), |ui| {
+ egui::ScrollArea::vertical()
+ .id_salt("feature_fields")
+ .min_scrolled_height(0.0)
+ .max_height(fields_height)
+ .show(ui, |ui| {
+ if disabled {
+ ui.disable();
+ }
+ egui::Frame::NONE
+ .inner_margin(egui::Margin {
+ left: t.space_10 as i8,
+ right: t.space_10 as i8,
+ top: t.space_8 as i8,
+ bottom: t.space_6 as i8,
+ })
+ .show(ui, body)
+ .inner
+ })
+ .inner
+ })
+ .inner;
+ let action = super::footer_with_status(ui, "OK", "Cancel", valid && !state.applying, heading.apply_label, state.text.as_deref());
+ if state.busy {
+ let rect = egui::Rect::from_min_size(
+ egui::pos2(ui.min_rect().left(), ui.min_rect().bottom() - super::row_height()),
+ vec2(t.space_16, super::row_height()),
+ );
+ egui::Spinner::new().size(t.space_14).paint_at(ui, rect);
+ let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));
+ ui.interact(rect, ui.id().with("compute_status"), egui::Sense::hover()).on_hover_text(status);
+ ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));
+ }
+ (close, action)
+ })
+ }
+
+ /// Palette composition retains its compact padding and whole-card scrolling on short views.
+ /// Tokens: space_24 and form_footer_height; header/body/footer own their historical padding.
+ pub(crate) fn palette(&self, ui: &mut Ui, bottom: f32, top: f32, mut add: impl FnMut(&mut Ui, Part)) {
+ let t = Tokens::get();
+ ui.set_max_height((bottom - ui.cursor().top()).max(0.0));
+ super::scope(ui, |ui| {
+ ui.spacing_mut().item_spacing.y = 0.0;
+ let height = (bottom - top - self.frame.total_margin().sum().y).max(0.0);
+ let short = height < t.space_24 * 6.0;
+ let mut contents = |ui: &mut Ui| {
+ add(ui, Part::Header);
+ let body_height = (bottom - ui.cursor().top() - t.form_footer_height).max(0.0);
+ let mut body = |ui: &mut Ui| {
+ egui::Frame::NONE.inner_margin(egui::Margin::symmetric(t.space_10 as i8, t.space_4 as i8)).show(ui, |ui| add(ui, Part::Body));
+ };
+ if short {
+ body(ui);
+ } else {
+ let body_rect = egui::Rect::from_min_size(ui.cursor().min, vec2(ui.available_width(), body_height));
+ let scroll = ui
+ .scope_builder(egui::UiBuilder::new().max_rect(body_rect), |ui| {
+ egui::ScrollArea::vertical()
+ .id_salt("sc_palette_options")
+ .max_height(body_height)
+ .min_scrolled_height(0.0)
+ .auto_shrink([false, true])
+ .show(ui, body)
+ })
+ .inner;
+ scenario::publish_rect("sketch_palette:options", scroll.inner_rect);
+ }
+ add(ui, Part::Footer);
+ };
+ if short {
+ let scroll = egui::ScrollArea::vertical()
+ .id_salt("sc_palette_content")
+ .max_height(height)
+ .min_scrolled_height(0.0)
+ .auto_shrink([false, true])
+ .show(ui, contents);
+ scenario::publish_rect("sketch_palette:options", scroll.inner_rect);
+ } else {
+ contents(ui);
+ }
+ });
+ }
+}
+
+#[cfg(test)]
+#[path = "panel_tests.rs"]
+mod tests;
diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rs
new file mode 100644
index 0000000000..46a7ac7c15
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/panel_tests.rs
@@ -0,0 +1,194 @@
+use crate::ui_kit::test_support::*;
+use crate::ui_kit::*;
+
+use crate::{scenario, theme::Tokens};
+use egui::Ui;
+
+#[test]
+fn checkbox_grid_and_close_header_are_clickable() {
+ let ctx = crate::fonts::test_context();
+ let (mut first, mut second, mut closed) = (false, true, false);
+ let mut draw = |ui: &mut Ui| {
+ header(ui, "extrude", "Extrude", || closed = true);
+ checkbox_grid(ui, &mut [("First option", &mut first), ("Second option", &mut second)], 2);
+ };
+ frame(&ctx, vec![], &mut draw);
+ let first_pos = scenario::handle_at("dialog:First option").unwrap();
+ let second_pos = scenario::handle_at("dialog:Second option").unwrap();
+ assert!((first_pos.y - second_pos.y).abs() < 0.01);
+ assert!(second_pos.x > first_pos.x);
+ frame(&ctx, pointer(first_pos, true), &mut draw);
+ frame(&ctx, pointer(first_pos, false), &mut draw);
+ let close = scenario::handle_at("dialog:close").unwrap();
+ frame(&ctx, pointer(close, true), &mut draw);
+ frame(&ctx, pointer(close, false), &mut draw);
+ assert!(first && second && closed);
+}
+
+#[test]
+fn heading_weight_field_surfaces_and_disclosures_follow_tokens_in_both_themes() {
+ fn inspect(shape: &egui::Shape, t: Tokens, title: &mut usize, section: &mut usize, fields: &mut usize) {
+ match shape {
+ egui::Shape::Text(text) => {
+ if text.galley.job.text == "3 mm" {
+ assert_eq!(text.galley.job.sections.first().unwrap().format.font_id.family, egui::FontFamily::Monospace);
+ }
+ if text.galley.job.text == "Fillet" {
+ assert_eq!(text.galley.job.sections.first().unwrap().format.font_id, crate::fonts::semibold(t.font_label));
+ *title += 1;
+ }
+ if text.galley.job.text == "OPTIONS" {
+ let format = &text.galley.job.sections.first().unwrap().format;
+ assert_eq!(format.font_id, crate::fonts::semibold(t.font_caption));
+ assert!(format.extra_letter_spacing > 0.0);
+ *section += 1;
+ }
+ }
+ egui::Shape::Rect(rect) if rect.fill == t.control_fill && rect.stroke.width == 1.0 && rect.stroke.color == t.control_border => {
+ *fields += 1
+ }
+ egui::Shape::Vec(shapes) => {
+ for shape in shapes {
+ inspect(shape, t, title, section, fields);
+ }
+ }
+ _ => {}
+ }
+ }
+ let previous = crate::theme::is_dark();
+ for dark in [false, true] {
+ crate::theme::set_dark(dark);
+ let ctx = crate::fonts::test_context();
+ ctx.set_visuals(if dark { egui::Visuals::dark() } else { egui::Visuals::light() });
+ let mut value = "3 mm".to_string();
+ let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
+ ui.set_width(300.0);
+ scope(ui, |ui| {
+ header(ui, "fillet", "Fillet", || {});
+ row(ui, "Radius", |ui| {
+ field(ui, &mut value);
+ });
+ section(ui, "options", "Options", true, |_| {});
+ });
+ });
+ output.textures_delta.clear();
+ let (mut title, mut section, mut fields) = (0, 0, 0);
+ for shape in &output.shapes {
+ inspect(&shape.shape, Tokens::get(), &mut title, &mut section, &mut fields);
+ }
+ assert_eq!(scenario::rect_of("dialog:header").unwrap().height(), Tokens::get().form_header_height);
+ assert_eq!(title, 1, "the semibold heading is painted once");
+ assert_eq!(section, 1, "semibold small caps are letter spaced and painted once");
+ assert!(fields > 0, "the actual text editor has a token field fill and one pixel border");
+ }
+ crate::theme::set_dark(previous);
+}
+
+#[test]
+fn panel_keeps_actions_and_body_geometry_in_both_layouts() {
+ for layout in [crate::shell::LayoutMode::Docked, crate::shell::LayoutMode::Floating] {
+ let ctx = crate::fonts::test_context();
+ let vp = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(640.0, 480.0));
+ for _ in 0..3 {
+ scenario::clear_handles();
+ let mut output = ctx.run_ui(egui::RawInput { screen_rect: Some(vp), ..Default::default() }, |_| {
+ let side = crate::frame::Side::Right;
+ let frame = Panel::feature_frame(&ctx, layout, side);
+ let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
+ let panel = Panel::new("Fillet", egui::Id::new("gallery_feature"), anchor, vp, side, frame);
+ panel.window().show(&ctx, |ui| {
+ panel.feature(
+ ui,
+ FeatureOptions {
+ icon: "fillet",
+ title: "Fillet",
+ drag_key: "gallery",
+ moved: egui::Vec2::ZERO,
+ docked: anchor,
+ apply_label: Some("Apply"),
+ },
+ false,
+ true,
+ |ui| {
+ let mut radius = "3 mm".to_owned();
+ row(ui, "Radius", |ui| {
+ field(ui, &mut radius);
+ });
+ ComputeStatus { text: None, busy: false, applying: false }
+ },
+ );
+ });
+ });
+ output.textures_delta.clear();
+ }
+ let header = scenario::rect_of("dialog:header").unwrap();
+ let body = scenario::rect_of("dialog:row:Radius").unwrap();
+ let footer = scenario::rect_of("dialog:footer").unwrap();
+ assert_eq!(header.height(), Tokens::get().form_header_height);
+ assert_eq!(body.height(), Tokens::get().control_height);
+ assert_eq!(footer.height(), Tokens::get().form_footer_height);
+ assert!(body.top() >= header.bottom());
+ assert!(footer.top() >= body.bottom());
+ assert!(vp.contains_rect(header) && vp.contains_rect(body) && vp.contains_rect(footer));
+ assert!(footer.contains(scenario::handle_at("dialog:ok").unwrap()));
+ assert!(footer.contains(scenario::handle_at("dialog:apply").unwrap()));
+ }
+}
+
+#[test]
+fn palette_scrolls_short_views_and_retains_its_status_and_action_handles() {
+ for layout in [crate::shell::LayoutMode::Docked, crate::shell::LayoutMode::Floating] {
+ for height in [125.0, 480.0] {
+ let ctx = crate::fonts::test_context();
+ let vp = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(640.0, height));
+ for _ in 0..3 {
+ scenario::clear_handles();
+ let mut output = ctx.run_ui(egui::RawInput { screen_rect: Some(vp), ..Default::default() }, |_| {
+ let frame = Panel::palette_frame(&ctx, layout);
+ let bottom = vp.bottom() - crate::shell::SHELL_GAP;
+ let panel = Panel::new(
+ "Options",
+ egui::Id::new("gallery_palette"),
+ egui::pos2(vp.right() - crate::shell::SHELL_GAP, 0.0),
+ vp,
+ crate::frame::Side::Right,
+ frame,
+ );
+ panel.window().show(&ctx, |ui| {
+ panel.palette(ui, bottom, 0.0, |ui, part| match part {
+ Part::Header => {
+ status_header(
+ ui,
+ "sketch_palette",
+ "Sketch 1",
+ StatusHeader { icon: "sketch", text: "Fully constrained", complete: true, fraction: 1.0 },
+ );
+ }
+ Part::Body => {
+ checkbox_row(ui, "snap", "Snap", true);
+ }
+ Part::Footer => {
+ button_pair(
+ ui,
+ "sketch_palette",
+ [false, false],
+ [
+ PairButton { key: "look_at", label: "ui.look_at", icon: Some("lookat") },
+ PairButton { key: "slice", label: "Slice", icon: None },
+ ],
+ );
+ }
+ });
+ });
+ });
+ output.textures_delta.clear();
+ }
+ let scroll = scenario::rect_of("sketch_palette:options").unwrap();
+ assert!(scroll.is_finite() && scroll.is_positive());
+ assert!(vp.contains_rect(scroll));
+ assert!(scenario::handle_at("sketch_palette:toggle:snap").is_some());
+ assert!(scenario::handle_at("sketch_palette:look_at").is_some());
+ assert!(scenario::handle_at("sketch_palette:slice").is_some());
+ }
+ }
+}
diff --git a/crates/ui-egui/src/ui_kit/status.rs b/crates/ui-egui/src/ui_kit/status.rs
new file mode 100644
index 0000000000..fd5fdc6cd0
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/status.rs
@@ -0,0 +1,47 @@
+//! Status heading and constraint meter; Tokens: font_label, text, text_dim, accent, dialog_rule, sketch_accent, spacing.
+use crate::{fonts::RichTextExt as _, theme::Tokens};
+use egui::{RichText, Stroke, vec2};
+
+/// Status content for a named card. `key` is the scenario namespace, `fraction` is clamped.
+pub struct StatusHeader<'a> {
+ pub icon: &'a str,
+ pub text: &'a str,
+ pub complete: bool,
+ pub fraction: f32,
+}
+
+/// Card identity, status dot/text and progress meter; use for solver/selection state.
+/// Tokens: font_label, text/dim, accent, dialog_rule, sketch_accent, form_icon_size, spacing.
+/// Name, status dot/text and meter for a card. Tokens: `font_label, text/dim, accent, dialog_rule, sketch_accent, form_icon_size, space_3/4/6/8/10`.
+pub fn status_header(ui: &mut egui::Ui, key: &str, name: &str, status: StatusHeader<'_>) -> egui::Response {
+ let fraction = if status.fraction.is_finite() { status.fraction.clamp(0.0, 1.0) } else { 0.0 };
+ let t = Tokens::get();
+ let response = egui::Frame::NONE
+ .inner_margin(egui::Margin::symmetric(t.space_10 as i8, t.space_8 as i8))
+ .show(ui, |ui| {
+ ui.spacing_mut().item_spacing = vec2(t.space_4, t.space_4);
+ ui.spacing_mut().interact_size.y = t.form_icon_size;
+ ui.horizontal(|ui| {
+ let (rect, _) = ui.allocate_exact_size(vec2(t.form_icon_size, t.form_icon_size), egui::Sense::hover());
+ crate::icons::paint(ui.painter(), rect, status.icon, t.icon, t.icon_fill, t.sketch_accent);
+ ui.add(egui::Label::new(RichText::new(name).semibold().size(t.font_label)).truncate()).on_hover_text(name);
+ });
+ ui.horizontal(|ui| {
+ let (dot, _) = ui.allocate_exact_size(vec2(t.space_10, t.space_10), egui::Sense::hover());
+ ui.painter().circle_filled(dot.center(), t.space_10 / 2.0, if status.complete { t.text } else { t.accent });
+ ui.add(egui::Label::new(RichText::new(status.text).size(t.font_label).color(t.text_dim)).wrap());
+ });
+ let (meter, _) = ui.allocate_exact_size(vec2(ui.available_width(), t.space_6), egui::Sense::hover());
+ ui.painter().rect_filled(meter, t.space_3, t.dialog_rule);
+ if fraction > 0.0 {
+ ui.painter().rect_filled(egui::Rect::from_min_size(meter.min, vec2(meter.width() * fraction, meter.height())), t.space_3, t.text);
+ }
+ crate::scenario::publish_rect(&format!("{key}:meter"), meter);
+ crate::scenario::publish_count(&format!("{key}:constrained_fraction"), f64::from(fraction));
+ })
+ .response;
+ ui.painter().hline(ui.max_rect().x_range(), ui.cursor().top(), Stroke::new(1.0, t.dialog_rule));
+ crate::scenario::publish_rect(&format!("{key}:status_header"), response.rect);
+ crate::scenario::publish_handle(&format!("{key}:status_header"), response.rect.center());
+ response
+}
diff --git a/crates/ui-egui/src/ui_kit/test_support_tests.rs b/crates/ui-egui/src/ui_kit/test_support_tests.rs
new file mode 100644
index 0000000000..add28dd195
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/test_support_tests.rs
@@ -0,0 +1,51 @@
+use super::*;
+use crate::scenario;
+use egui::{Ui, vec2};
+
+pub(crate) fn frame(ctx: &egui::Context, events: Vec<egui::Event>, mut add: impl FnMut(&mut Ui)) {
+ scenario::clear_handles();
+ let mut output = ctx.run_ui(
+ egui::RawInput {
+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0))),
+ events,
+ focused: true,
+ ..Default::default()
+ },
+ |ui| {
+ ui.set_width(280.0);
+ scope(ui, &mut add);
+ },
+ );
+ // These tests exercise layout/input without a renderer.
+ output.textures_delta.clear();
+}
+
+pub(crate) fn pointer(pos: egui::Pos2, pressed: bool) -> Vec<egui::Event> {
+ vec![
+ egui::Event::PointerMoved(pos),
+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() },
+ ]
+}
+
+pub(crate) fn key(key: egui::Key) -> Vec<egui::Event> {
+ vec![egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }]
+}
+
+/// The cursor the frame asks the platform for: the pointer is at `pos` for the whole frame.
+pub(crate) fn frame_cursor(ctx: &egui::Context, pos: egui::Pos2, mut add: impl FnMut(&mut Ui)) -> egui::CursorIcon {
+ scenario::clear_handles();
+ let mut output = ctx.run_ui(
+ egui::RawInput {
+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 400.0))),
+ events: vec![egui::Event::PointerMoved(pos)],
+ focused: true,
+ ..Default::default()
+ },
+ |ui| {
+ ui.set_width(280.0);
+ scope(ui, &mut add);
+ },
+ );
+ output.textures_delta.clear();
+ output.platform_output.cursor_icon
+}
diff --git a/crates/ui-egui/src/ui_kit/text.rs b/crates/ui-egui/src/ui_kit/text.rs
new file mode 100644
index 0000000000..bc24a1d356
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit/text.rs
@@ -0,0 +1,21 @@
+//! Text elements for dense cards; see `docs/ui-kit.md` for tokens and usage.
+use crate::theme::Tokens;
+use egui::Ui;
+
+/// Paint one pixel-aligned text run with the requested interface weight.
+/// Clipped, device-pixel-snapped weighted text. Tokens: `font_section_tracking; caller supplies font/ink tokens`.
+pub(super) fn paint_text(ui: &Ui, rect: egui::Rect, text: &str, font: egui::FontId, ink: egui::Color32, spaced: bool) {
+ let size = font.size;
+ let mut format = egui::TextFormat::simple(font, ink);
+ if spaced {
+ format.extra_letter_spacing = size * Tokens::get().font_section_tracking;
+ }
+ let job = egui::text::LayoutJob::single_section(text.to_string(), format);
+ let galley = ui.fonts_mut(|fonts| fonts.layout_job(job));
+ // Snap to whole device pixels: a fractional origin blurs every glyph edge.
+ let ppp = ui.ctx().pixels_per_point().max(0.5);
+ let snap = |v: f32| (v * ppp).round() / ppp;
+ let at = egui::pos2(snap(rect.left()), snap(rect.center().y - galley.size().y / 2.0));
+ let painter = ui.painter().with_clip_rect(ui.clip_rect().intersect(rect));
+ painter.galley(at, galley, ink);
+}
diff --git a/crates/ui-egui/src/ui_kit_guard_tests.rs b/crates/ui-egui/src/ui_kit_guard_tests.rs
new file mode 100644
index 0000000000..e4e41865fa
--- /dev/null
+++ b/crates/ui-egui/src/ui_kit_guard_tests.rs
@@ -0,0 +1,140 @@
+//! Dense panels compose kit elements. Legacy, non-dense paths have bounded allowances.
+use std::path::Path;
+use syn::visit::{self, Visit};
+
+/// Counts may shrink; additions need a specific reason. Dense-only files have no allowance.
+const ALLOWED: &[(&str, usize, &str)] = &[
+ ("dialogs.rs", 13, "retired non-dense window and explicitly guarded legacy selection/field helpers"),
+ ("dialogs_assembly.rs", 6, "non-dense Drive Joint slider, Motion Study compute and joint browser actions"),
+ ("dialogs_plastic.rs", 1, "non-dense Manage Rules active-rule checkbox"),
+ ("dialogs_sheet.rs", 4, "non-dense Manage Rules and flat-pattern export actions"),
+];
+
+#[derive(Default)]
+struct Guard {
+ found: Vec<String>,
+ aliases: Vec<String>,
+}
+
+impl<'ast> Visit<'ast> for Guard {
+ fn visit_item(&mut self, item: &'ast syn::Item) {
+ let attrs = match item {
+ syn::Item::Mod(i) => &i.attrs,
+ syn::Item::Fn(i) => &i.attrs,
+ _ => return visit::visit_item(self, item),
+ };
+ if !attrs
+ .iter()
+ .any(|a| a.path().is_ident("test") || (a.path().is_ident("cfg") && a.parse_args::<syn::Path>().is_ok_and(|p| p.is_ident("test"))))
+ {
+ visit::visit_item(self, item);
+ }
+ }
+
+ fn visit_expr_method_call(&mut self, call: &'ast syn::ExprMethodCall) {
+ if matches!(
+ call.method.to_string().as_str(),
+ "checkbox" | "button" | "small_button" | "selectable_label" | "selectable_value" | "radio_value" | "toggle_value"
+ ) {
+ self.found.push(format!(".{}", call.method));
+ }
+ visit::visit_expr_method_call(self, call);
+ }
+
+ fn visit_expr_call(&mut self, call: &'ast syn::ExprCall) {
+ if let syn::Expr::Path(path) = call.func.as_ref() {
+ let names: Vec<_> = path.path.segments.iter().map(|s| s.ident.to_string()).collect();
+ if names.iter().any(|n| matches!(n.as_str(), "ComboBox" | "Button" | "Slider" | "Checkbox" | "RadioButton") || self.aliases.contains(n)) {
+ self.found.push(names.join("::"));
+ }
+ }
+ visit::visit_expr_call(self, call);
+ }
+}
+
+fn violations(source: &str) -> Vec<String> {
+ fn aliases(tree: &syn::UseTree, out: &mut Vec<String>) {
+ match tree {
+ syn::UseTree::Path(p) => aliases(&p.tree, out),
+ syn::UseTree::Group(g) => {
+ for tree in &g.items {
+ aliases(tree, out);
+ }
+ }
+ syn::UseTree::Rename(r) if matches!(r.ident.to_string().as_str(), "ComboBox" | "Button" | "Slider" | "Checkbox" | "RadioButton") => {
+ out.push(r.rename.to_string())
+ }
+ _ => {}
+ }
+ }
+ let ast = syn::parse_file(source).unwrap();
+ let mut guard = Guard::default();
+ for item in &ast.items {
+ if let syn::Item::Use(u) = item {
+ aliases(&u.tree, &mut guard.aliases);
+ }
+ }
+ guard.visit_file(&ast);
+ guard.found
+}
+
+#[test]
+fn dense_panels_use_ui_kit_elements() {
+ let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
+ let mut failures = Vec::new();
+ fn scan(dir: &Path, prefix: &str, failures: &mut Vec<String>) {
+ for entry in std::fs::read_dir(dir).unwrap() {
+ let path = entry.unwrap().path();
+ let name = path.file_name().unwrap().to_str().unwrap();
+ let relative = format!("{prefix}{name}");
+ if path.is_dir() {
+ if name != "ui_kit" {
+ scan(&path, &format!("{relative}/"), failures);
+ }
+ continue;
+ }
+ if path.extension().is_none_or(|e| e != "rs") || name.ends_with("_tests.rs") {
+ continue;
+ }
+ let source = std::fs::read_to_string(&path).unwrap();
+ // Covers dense adapters and every future Panel caller, including imported Panel aliases.
+ if name != "dialogs_dense.rs" && name != "sketch_palette.rs" && !source.contains("ui_kit") {
+ continue;
+ }
+ let found = violations(&source);
+ let allowed = ALLOWED.iter().find(|(file, _, _)| *file == relative).map_or(0, |(_, count, _)| *count);
+ if found.len() > allowed {
+ failures.push(format!("{relative}: {} raw widgets, at most {allowed} allowed: {found:?}", found.len()));
+ }
+ }
+ }
+ scan(&root, "", &mut failures);
+ failures.sort();
+ assert!(failures.is_empty(), "Use crate::ui_kit, or document a bounded legacy-path allowance:\n{}", failures.join("\n"));
+}
+
+#[test]
+fn guard_detects_multiline_and_aliased_widget_calls_but_skips_tests() {
+ assert_eq!(
+ violations(
+ r#"
+ use egui::ComboBox as Combo;
+ fn show(ui: &mut Ui) {
+ ui.checkbox(
+ value, "Label"
+ );
+ ui.button("Go");
+ ui.selectable_label(false, "Item");
+ ui.add(egui::Slider::new(value, range));
+ ui.add(egui::Button::new("Go"));
+ egui::ComboBox::from_id_salt("id");
+ Combo::from_id_salt("alias");
+ }
+ #[cfg(test)] mod tests { fn sample() { ui.button("ignored"); } }
+ fn after() { ui.small_button("Remove"); }
+ "#
+ )
+ .len(),
+ 8
+ );
+}
diff --git a/crates/ui-egui/src/update.rs b/crates/ui-egui/src/update.rs
index f38e997ea5..6b958de4f8 100644
--- a/crates/ui-egui/src/update.rs
+++ b/crates/ui-egui/src/update.rs
@@ -12,6 +12,7 @@
//! The host provides the HTTP client (`Services::http_get`), so this crate stays portable and
//! the browser build never checks (it updates itself through its service worker).
+use crate::fonts::RichTextExt as _;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::sync::mpsc::{Receiver, TryRecvError};
@@ -803,7 +804,12 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
.show(ctx, |ui| {
ui.set_width(WINDOW_W);
ui.set_max_width(WINDOW_W);
- ui.label(RichText::new(crate::i18n::format("update.available", &[("version", release.version())])).strong().size(15.0));
+ ui.label(
+ RichText::new(crate::i18n::format("update.available", &[("version", release.version())]))
+ .semibold()
+ .color(crate::theme::Tokens::get().text)
+ .size(crate::theme::Tokens::get().font_subtitle),
+ );
ui.label(RichText::new(crate::i18n::format("update.you_have", &[("version", current_version())])).color(t.text_dim));
ui.add_space(6.0);
egui::Frame::group(ui.style()).show(ui, |ui| {
@@ -833,7 +839,11 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
});
ui.add_space(4.0);
} else if let Some(name) = asset.as_ref().filter(|_| app.updater.installed.as_ref().is_none_or(|r| r.is_err())) {
- ui.label(RichText::new(crate::i18n::format("update.file", &[("file", name)])).size(11.0).color(t.text_dim));
+ ui.label(
+ RichText::new(crate::i18n::format("update.file", &[("file", name)]))
+ .size(crate::theme::Tokens::get().font_small)
+ .color(t.text_dim),
+ );
}
if let Some((_, progress)) = &app.updater.job {
let done = progress.done.load(std::sync::atomic::Ordering::Relaxed);
@@ -851,9 +861,16 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
}
match &app.updater.installed {
Some(Ok(install::Outcome::Restart(_))) => {
- ui.label(RichText::new(crate::i18n::format("update.installed", &[("version", release.version())])).strong());
+ ui.label(
+ RichText::new(crate::i18n::format("update.installed", &[("version", release.version())]))
+ .semibold()
+ .color(crate::theme::Tokens::get().text),
+ );
ui.horizontal(|ui| {
- let r = ui.add(egui::Button::new(RichText::new(crate::i18n::tr("update.restart")).strong()).fill(t.accent));
+ let r = ui.add(
+ egui::Button::new(RichText::new(crate::i18n::tr("update.restart")).semibold().color(crate::theme::Tokens::get().text))
+ .fill(t.accent),
+ );
crate::scenario::publish_rect("update:restart", r.rect);
if r.clicked() {
action = Some("restart");
@@ -885,14 +902,18 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
install::Method::Dmg => crate::i18n::tr("update.download_open"),
_ => crate::i18n::tr("update.update_now"),
};
- let r = ui.add(egui::Button::new(RichText::new(label).strong()).fill(t.accent));
+ let r = ui.add(egui::Button::new(RichText::new(label).semibold().color(crate::theme::Tokens::get().text)).fill(t.accent));
crate::scenario::publish_rect("update:install", r.rect);
if r.clicked() {
action = Some("install");
}
}
let download = if kind.system_managed() { crate::i18n::tr("update.release_page") } else { crate::i18n::tr("update.download") };
- let r = if one_click { ui.button(download) } else { ui.add(egui::Button::new(RichText::new(download).strong()).fill(t.accent)) };
+ let r = if one_click {
+ ui.button(download)
+ } else {
+ ui.add(egui::Button::new(RichText::new(download).semibold().color(crate::theme::Tokens::get().text)).fill(t.accent))
+ };
crate::scenario::publish_rect("update:download", r.rect);
if r.clicked() {
action = Some("download");
@@ -968,7 +989,7 @@ pub fn prefs_rows(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
} else {
crate::i18n::format("update.prefs_dev", &[("version", current_version())])
};
- ui.add(egui::Label::new(RichText::new(note).size(11.0).color(t.text_dim)).wrap());
+ ui.add(egui::Label::new(RichText::new(note).size(crate::theme::Tokens::get().font_small).color(t.text_dim)).wrap());
ui.end_row();
if let Some(v) = offered_or_newer(app)
&& offered(app).is_none()
@@ -1132,7 +1153,7 @@ fn markdown(ui: &mut egui::Ui, src: &str, t: &Tokens) {
let (text, font, color) = match span {
Span::Text(s) => (s.as_str(), FontId::proportional(size), if strong { t.text } else { body }),
Span::Strong(s) => (s.as_str(), FontId::proportional(size), t.text),
- Span::Code(s) => (s.as_str(), FontId::monospace(size - 1.0), body),
+ Span::Code(s) => (s.as_str(), FontId::monospace(size - (t.font_body - t.font_small)), body),
Span::Link { text, .. } => (text.as_str(), FontId::proportional(size), t.accent),
};
job.append(text, 0.0, egui::TextFormat { font_id: font, color, ..Default::default() });
@@ -1155,7 +1176,7 @@ fn markdown(ui: &mut egui::Ui, src: &str, t: &Tokens) {
ui.horizontal_wrapped(|ui| {
ui.add_space(indent);
for (text, url) in targets {
- ui.hyperlink_to(RichText::new(text).size(11.5), url).on_hover_text(url);
+ ui.hyperlink_to(RichText::new(text).size(t.font_caption), url).on_hover_text(url);
}
});
};
@@ -1165,10 +1186,10 @@ fn markdown(ui: &mut egui::Ui, src: &str, t: &Tokens) {
match block {
Block::Heading(spans) => {
ui.add_space(4.0);
- ui.add(egui::Label::new(job(&spans, 14.0, true, width)).wrap());
+ ui.add(egui::Label::new(job(&spans, t.font_heading, true, width)).wrap());
}
Block::Paragraph(spans) => {
- ui.add(egui::Label::new(job(&spans, 12.5, false, width)).wrap());
+ ui.add(egui::Label::new(job(&spans, t.font_label, false, width)).wrap());
links(ui, &spans, 0.0);
ui.add_space(3.0);
}
@@ -1176,8 +1197,8 @@ fn markdown(ui: &mut egui::Ui, src: &str, t: &Tokens) {
let indent = 6.0 + 12.0 * depth.min(4) as f32;
ui.horizontal_top(|ui| {
ui.add_space(indent);
- ui.label(RichText::new("•").size(12.5));
- ui.add(egui::Label::new(job(&spans, 12.5, false, width - indent - 14.0)).wrap());
+ ui.label(RichText::new("•").size(crate::theme::Tokens::get().font_label));
+ ui.add(egui::Label::new(job(&spans, t.font_label, false, width - indent - 14.0)).wrap());
});
links(ui, &spans, indent + 14.0);
}
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index e4c413c2c8..5fe8c208c8 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -1,6 +1,7 @@
//! The 3D viewport: navigation, GPU (or CPU fallback) rendering, picking, overlays, the axis
//! view and the navigation bar.
+use crate::fonts::RichTextExt as _;
use egui::{Align2, Color32, FontId, Pos2, Rect, Sense, Shape, Stroke, pos2, vec2};
use serde_json::json;
use solidcraft_engine::Sel;
@@ -3011,7 +3012,7 @@ fn transient_messages(app: &mut SolveApp, ui: &egui::Ui, viewport: Rect) {
if let Some(r) = paint_toast(ui, free, msg, error, false) {
crate::scenario::publish_rect("toast", r);
free.max.y = r.top() - t.space_8;
- // A click opens every message of the run, to read and copy (#2763).
+ // Open the run's messages from the tokenised status toast.
crate::scenario::publish_handle("status:chip", r.center());
if ui.interact(r, egui::Id::new("sc_status_chip"), Sense::click()).on_hover_text(crate::i18n::tr("messages.chip_hint")).clicked() {
app.messages.open = true;
@@ -3041,7 +3042,7 @@ fn paint_toast(ui: &egui::Ui, free: Rect, text: String, error: bool, computing:
}
let t = Tokens::get();
let painter = ui.painter().with_clip_rect(free);
- let galley = painter.layout(text, FontId::proportional(t.font_label), t.text, (free.width() - 40.0).min(440.0));
+ let galley = painter.layout(text, crate::fonts::medium(t.font_label), t.text, (free.width() - 40.0).min(440.0));
let size = galley.size() + vec2(40.0, 16.0);
if !size.is_finite() || size.x > free.width() || size.y > free.height() {
return None;
@@ -3874,7 +3875,7 @@ fn view_menu(app: &mut SolveApp, ui: &mut egui::Ui, button: Rect) -> bool {
let r = area.show(ui.ctx(), |ui| {
egui::Frame::popup(ui.style()).show(ui, |ui| {
ui.set_width(220.0);
- ui.label(egui::RichText::new(crate::i18n::tr_label("VIEW")).strong().size(t.font_caption));
+ ui.label(egui::RichText::new(crate::i18n::tr_label("VIEW")).semibold().color(crate::theme::Tokens::get().text).size(t.font_caption));
ui.label(app.tr("ui.graphics_preset"));
crate::prefs::graphics_preset_selector(app, ui);
ui.separator();
@@ -4355,7 +4356,7 @@ mod tests {
draw.hover = Some((b, None));
for mode in [0, 1, 2] {
crate::sketch_palette::set_mode(&mut h.app, mode);
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut output = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.ctx().layer_painter(egui::LayerId::background());
crate::tools::preview(&h.app, &draw, &painter, &proj);
@@ -4580,7 +4581,7 @@ mod tests {
#[test]
fn edge_between_two_faces_picks_along_its_whole_length() {
for style in [0u8, 2] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
app.run("solid.box", json!({"length":200,"width":120,"height":160})).unwrap();
app.ui.show_origin = false;
@@ -4653,7 +4654,7 @@ mod tests {
#[test]
fn holding_space_pans_instead_of_dragging_geometry() {
for preset in crate::prefs::NAV_PRESETS.iter().map(|p| p.id) {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = preset.into();
app.ui.show_origin = false;
@@ -4681,7 +4682,7 @@ mod tests {
fn ctrl_left_drag_from_empty_space_orbits_in_every_preset() {
for preset in crate::prefs::NAV_PRESETS.iter().map(|p| p.id) {
for action in ["orbit", "tool", "point", "click"] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = preset.into();
app.ui.show_origin = false;
@@ -4737,7 +4738,7 @@ mod tests {
#[test]
fn openscad_left_drag_preserves_editing_and_selection() {
for action in ["point", "box", "tool"] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = crate::prefs::OPENSCAD_NAV.into();
app.ui.show_origin = false;
@@ -4795,7 +4796,7 @@ mod tests {
(egui::PointerButton::Secondary, true),
(egui::PointerButton::Middle, true),
] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = crate::prefs::OPENSCAD_NAV.into();
hover_frame(&mut app, &ctx, vec![]);
@@ -4840,7 +4841,7 @@ mod tests {
#[test]
fn touchpad_modifier_motion_navigates_without_buttons_or_document_changes() {
for alt in [false, true] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = "touchpad".into();
let p = pos2(350.0, 300.0);
@@ -4893,7 +4894,7 @@ mod tests {
#[test]
fn touchpad_motion_does_not_move_the_camera_under_a_canvas_triad() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut s = solidcraft_engine::Session::default();
s.execute("solid.box", &json!({"length":20,"width":20,"height":20})).unwrap();
s.selection = vec![Sel::Body { name: "Body1".into() }];
@@ -4924,7 +4925,7 @@ mod tests {
#[test]
fn touchpad_motion_preserves_input_ownership_and_rearms_without_jumping() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = "touchpad".into();
app.preferences.orbit_around = crate::prefs::OrbitAround::Cursor;
@@ -4976,7 +4977,7 @@ mod tests {
#[test]
fn touchpad_focus_and_preset_changes_discard_old_motion() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(false);
app.preferences.nav = "touchpad".into();
let alt = egui::Modifiers { alt: true, ..Default::default() };
@@ -5054,7 +5055,7 @@ mod tests {
fn hover_stays_off_between_navigation_events_and_returns_on_release() {
for gpu in [false, true] {
for button in [egui::PointerButton::Middle, egui::PointerButton::Secondary, egui::PointerButton::Primary] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(gpu);
if button == egui::PointerButton::Primary {
app.viewport.nav = Some(NavMode::Orbit);
@@ -5103,7 +5104,7 @@ mod tests {
#[test]
fn device_navigation_keeps_face_hover_current_for_a_stationary_or_moving_pointer() {
for gpu in [false, true] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = device_face_app(gpu);
hover_frame(&mut app, &ctx, vec![]);
let p = projection(&app, app.viewport.rect.unwrap()).to_screen(Vec3::ZERO).unwrap();
@@ -5131,7 +5132,7 @@ mod tests {
fn device_navigation_allows_face_clicks_and_preserves_modifier_selection() {
for gpu in [false, true] {
for (modifiers, add) in [(egui::Modifiers::NONE, false), (egui::Modifiers::SHIFT, true), (egui::Modifiers::CTRL, true)] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = device_face_app(gpu);
let existing = Sel::Body { name: "Body1".into() };
app.session.selection = vec![existing.clone()];
@@ -5170,7 +5171,7 @@ mod tests {
fn device_navigation_keeps_hover_and_click_picking() {
use crate::space_mouse::{DeviceMotion, Motion};
for gpu in [false, true] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut s = solidcraft_engine::Session::default();
s.execute("solid.box", &json!({"length": 40, "width": 30, "height": 20})).unwrap();
let mut app = SolveApp::new(s, crate::Services::default());
@@ -5209,7 +5210,7 @@ mod tests {
#[test]
fn hover_stays_off_during_spin_and_animated_views() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = hover_app(true);
hover_frame(&mut app, &ctx, vec![]);
let p = projection(&app, app.viewport.rect.unwrap()).to_screen(Vec3::ZERO).unwrap();
@@ -5828,7 +5829,7 @@ mod tests {
#[test]
fn trackpad_gestures_over_dialogs_do_not_move_the_view() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
assert!(app.preferences.trackpad_pan);
crate::help::run(&mut app, &ctx, "shortcuts");
@@ -5885,7 +5886,7 @@ mod tests {
#[test]
fn shortcuts_window_wheel_does_not_zoom_the_viewport() {
for smooth in [true, false] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
app.preferences.smooth_wheel_zoom = smooth;
app.preferences.trackpad_pan = false;
@@ -6307,8 +6308,7 @@ mod tests {
h.app.ui.perspective = perspective;
h.app.run("solid.box", json!({"length":80,"width":50,"height":20})).unwrap();
h.app.fit_view();
- // Fit resolves after measuring the floating browser and history cards.
- h.frames(2);
+ h.frames(2); // Fit resolves against the measured floating shell before the drag.
let rect = h.app.viewport.rect.unwrap();
let at = rect.center() + offset;
let proj = projection(&h.app, rect);
diff --git a/crates/ui-egui/src/viewport_overlays_tests.rs b/crates/ui-egui/src/viewport_overlays_tests.rs
index b07fbd424c..0d371637e0 100644
--- a/crates/ui-egui/src/viewport_overlays_tests.rs
+++ b/crates/ui-egui/src/viewport_overlays_tests.rs
@@ -62,7 +62,7 @@ fn compass_negative_ends_are_hollow_and_positive_ends_are_chunkier() {
for dark in [false, true] {
let t = Tokens::themed(dark, crate::theme::ColorVision::Off);
for (name, direction, positive) in [("x", Vec3::X, true), ("-x", -Vec3::X, false)] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let c = pos2(100.0, 100.0);
let original = c + vec2(38.0, 0.0);
let painted = c + (original - c) * 0.84;
@@ -74,7 +74,19 @@ fn compass_negative_ends_are_hollow_and_positive_ends_are_chunkier() {
if positive {
assert_eq!(end.fill, t.triad[0]);
assert_eq!(end.radius, 11.0);
- assert!(output.shapes.iter().any(|s| matches!(&s.shape, Shape::Text(text) if text.galley.text() == "X")));
+ let letters: Vec<_> = output
+ .shapes
+ .iter()
+ .filter_map(|s| match &s.shape {
+ Shape::Text(text) if text.galley.text() == "X" => Some(text),
+ _ => None,
+ })
+ .collect();
+ assert_eq!(letters.len(), 1, "each axis letter is painted once");
+ let letter = letters[0];
+ assert_eq!(letter.galley.job.sections[0].format.font_id, crate::fonts::bold(Tokens::get().font_compass));
+ assert_eq!(letter.pos.x.fract(), 0.0);
+ assert_eq!(letter.pos.y.fract(), 0.0);
} else {
assert_eq!(end.fill, Color32::TRANSPARENT);
assert_eq!(end.stroke.width, 2.4);
@@ -167,7 +179,7 @@ fn toast_stays_in_free_content_above_history_and_navigation() {
#[test]
fn toast_card_uses_shell_tokens_wraps_and_rejects_hostile_rects() {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let t = Tokens::get();
let free = Rect::from_min_size(pos2(30.0, 30.0), vec2(200.0, 200.0));
for (error, computing) in [(false, false), (true, false), (false, true)] {
@@ -293,7 +305,7 @@ fn a_hovered_compass_end_turns_white_and_its_letter_takes_the_axis_colour() {
for dark in [false, true] {
let t = Tokens::themed(dark, crate::theme::ColorVision::Off);
for (name, direction, positive) in [("x", Vec3::X, true), ("-x", -Vec3::X, false)] {
- let ctx = egui::Context::default();
+ let ctx = crate::fonts::test_context();
let c = pos2(100.0, 100.0);
let original = c + vec2(38.0, 0.0);
let painted = c + (original - c) * 0.84;
diff --git a/crates/ui-egui/tests/icon_audit.rs b/crates/ui-egui/tests/icon_audit.rs
new file mode 100644
index 0000000000..aff59880e0
--- /dev/null
+++ b/crates/ui-egui/tests/icon_audit.rs
@@ -0,0 +1,469 @@
+//! Runtime icon discovery: use the same headless UI and requests as control clients.
+use std::collections::BTreeMap;
+use std::path::PathBuf;
+
+use serde_json::{Value, json};
+use solidcraft_ui_egui::{icon_svg, scenario::Harness, workspace};
+
+fn click(h: &mut Harness, handle: &str) {
+ h.step(&json!({"click":{"handle":handle}})).unwrap_or_else(|e| panic!("{handle}: {e}"));
+}
+
+fn escape(h: &mut Harness) {
+ h.step(&json!({"key":"Escape"})).unwrap();
+ h.call("ui.menu", json!({"close":true}));
+ h.app.params = None;
+ h.app.design_properties = None;
+}
+
+fn collect(h: &mut Harness, surface: &str, requested: &mut BTreeMap<String, bool>) {
+ let reply = h.call("ui.icon_audit", json!({}));
+ use std::io::Write as _;
+ let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/icon-audit");
+ std::fs::create_dir_all(&dir).unwrap();
+ let mut evidence = std::fs::OpenOptions::new().create(true).append(true).open(dir.join("surfaces.txt")).unwrap();
+ writeln!(
+ evidence,
+ "{surface}\tpanel={:?}\ttool={:?}\t{}",
+ h.app.dialog.as_ref().map(|d| &d.kind),
+ h.app.tool.as_ref().map(|t| t.cmd),
+ reply["result"]["requested"]
+ )
+ .unwrap();
+ for item in reply["result"]["requested"].as_array().expect("audit requests") {
+ let name = item["name"].as_str().unwrap();
+ let placeholder = item["placeholder"].as_bool().unwrap();
+ if placeholder && !requested.contains_key(name) {
+ eprintln!("{surface}: {name} fell back to the placeholder");
+ }
+ requested.insert(name.to_owned(), placeholder);
+ }
+}
+
+fn menu(h: &mut Harness, target: Value, surface: &str, requested: &mut BTreeMap<String, bool>) {
+ // Open on empty canvas so the picker cannot replace the prepared face/edge/sketch
+ // selection with whatever happens to lie under the menu's anchor.
+ let selection = h.app.session.selection.clone();
+ let viewport = target["type"] == "viewport";
+ let rect = h.app.viewport.rect.expect("a viewport");
+ let reply = h.call("ui.menu", json!({"x":rect.right()-8.0,"y":rect.bottom()-8.0,"target":target}));
+ assert_eq!(reply["ok"], true, "{surface}: {reply}");
+ h.frames(3);
+ let reply = h.call("ui.menu", json!({}));
+ assert_eq!(reply["result"]["open"], true, "{surface}: {reply}");
+ if viewport {
+ assert_eq!(h.app.session.selection, selection, "{surface}: menu anchor replaced the prepared selection");
+ }
+ assert!(!reply["result"]["items"].as_array().unwrap().is_empty(), "{surface}: empty menu did not exercise its target");
+ for item in reply["result"]["items"].as_array().unwrap().iter().chain(reply["result"]["radial"].as_array().unwrap()) {
+ let id = item["id"].as_str().unwrap();
+ let blank = item["icon"].as_str().unwrap().is_empty();
+ // Planned workspace rows deliberately have no artwork until their workspace exists.
+ let intentional = id == "-" || id.starts_with('#') || (id == "ui.workspace" && item["shortcut"] == "coming later");
+ assert!(!blank || intentional, "{surface}: icon-less menu item {item}");
+ assert_eq!(item["placeholder"], false, "{surface}: {item}");
+ }
+ collect(h, surface, requested);
+ escape(h);
+}
+
+fn ribbon(h: &mut Harness, requested: &mut BTreeMap<String, bool>) {
+ for tab in workspace::visible_tabs(&h.app) {
+ click(h, &format!("tab:{tab}"));
+ let panels = solidcraft_ui_egui::scenario::handles(&format!("panel:{tab}:"));
+ assert!(!panels.is_empty(), "no panels on {tab}");
+ for (handle, _) in panels {
+ click(h, &handle);
+ collect(h, &handle, requested);
+ for (family, at) in solidcraft_ui_egui::scenario::handles("create_family:") {
+ h.call("ui.move", json!({"x":at.x,"y":at.y}));
+ h.frames(20);
+ collect(h, &family, requested);
+ }
+ escape(h);
+ }
+ }
+}
+
+fn panels(h: &mut Harness, requested: &mut BTreeMap<String, bool>) {
+ for command in solidcraft_engine::command_specs() {
+ let panel = solidcraft_ui_egui::dialogs::Dialog::for_command(&h.app, command.id).is_some()
+ || solidcraft_ui_egui::tools::Tool::for_command(command.id).is_some()
+ || matches!(command.id, "parameters.change" | "document.metadata" | "material.properties.validate");
+ if !panel {
+ continue;
+ }
+ if matches!(command.id, "canvas.insert" | "canvas.decal") {
+ h.step(&json!({"make_image":"audit-canvas.png"})).unwrap();
+ h.step(&json!({"choose_file":"audit-canvas.png"})).unwrap();
+ }
+ let info = command.info(&h.app.session);
+ let surface = format!("tool panel:{} enabled={} reason={:?}", command.id, info.enabled, info.disabled_reason);
+ assert_eq!(h.call("ui.start", json!({"command":command.id}))["ok"], true, "{}", command.id);
+ h.frames(2);
+ collect(h, &surface, requested);
+ escape(h);
+ }
+}
+
+fn context_rows(h: &mut Harness, prefix: &str, requested: &mut BTreeMap<String, bool>) {
+ for (handle, _) in solidcraft_ui_egui::scenario::handles(prefix) {
+ if handle == "timeline:rollback" {
+ continue;
+ }
+ h.step(&json!({"click":{"handle":handle},"button":"right"})).unwrap();
+ collect(h, &handle, requested);
+ escape(h);
+ }
+}
+
+#[test]
+fn requested_menu_icons_have_artwork_and_match_manifest() {
+ let evidence = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/icon-audit/surfaces.txt");
+ if evidence.exists() {
+ std::fs::remove_file(&evidence).unwrap();
+ }
+ let mut h = Harness::new();
+ h.app.home.open = false;
+ h.app.services.install_app = Some(solidcraft_ui_egui::install::InstallApp {
+ offer: Box::new(|| Some(solidcraft_ui_egui::install::Offer::Prompt)),
+ prompt: Box::new(|| {}),
+ });
+ h.app.preferences.radial_context_menu = true;
+ assert_eq!(h.call("ui.icon_audit", json!({"reset":true}))["ok"], true);
+ h.app.session.run_script(&solidcraft_engine::sample::script()).unwrap();
+ h.frames(3);
+ let mut requested = BTreeMap::new();
+ collect(&mut h, "initial browser and timeline", &mut requested);
+
+ ribbon(&mut h, &mut requested);
+ click(&mut h, "appbar:file");
+ assert!(h.widget("Export Current View as DXF…").is_some(), "painted File rows retain accessible action labels");
+ collect(&mut h, "File", &mut requested);
+ escape(&mut h);
+ click(&mut h, "appbar:help");
+ collect(&mut h, "Help", &mut requested);
+ escape(&mut h);
+ menu(&mut h, json!({"type":"workspace"}), "workspace", &mut requested);
+ solidcraft_ui_egui::render_workspace::enter(&mut h.app, true).unwrap();
+ h.frames(3);
+ ribbon(&mut h, &mut requested);
+ solidcraft_ui_egui::render_workspace::enter(&mut h.app, false).unwrap();
+ h.frames(3);
+
+ let body = h.app.session.model.state().bodies.first().unwrap().name.clone();
+ let sketch = h.app.session.world_state().sketches.first().unwrap().feature;
+ for target in [
+ json!({"type":"viewport"}),
+ json!({"type":"body","name":body}),
+ json!({"type":"sketch","id":sketch}),
+ json!({"type":"component","id":0}),
+ json!({"type":"origin"}),
+ json!({"type":"origin_plane","name":"XY"}),
+ json!({"type":"units"}),
+ json!({"type":"named_views"}),
+ json!({"type":"named_view","name":"Top"}),
+ json!({"type":"toolbar"}),
+ json!({"type":"toolbar_command","id":"solid.extrude"}),
+ json!({"type":"folder","component":0,"scope":"c0","folder":"bodies"}),
+ json!({"type":"folder","component":0,"scope":"c0","folder":"sketches"}),
+ json!({"type":"folder","component":0,"scope":"c0","folder":"construction"}),
+ json!({"type":"section"}),
+ json!({"type":"canvas","id":1}),
+ ] {
+ menu(&mut h, target.clone(), &target.to_string(), &mut requested);
+ }
+ for selection in [
+ json!({"type":"face","body":body,"index":0,"point":[0,0,0]}),
+ json!({"type":"edge","body":body,"index":0,"point":[0,0,0]}),
+ json!({"type":"vertex","body":body,"point":[0,0,0]}),
+ json!({"type":"external_sketch_curve","sketch":sketch,"id":"l1"}),
+ ] {
+ h.app.run("select.set", json!({"items":[selection]})).unwrap();
+ menu(&mut h, json!({"type":"viewport"}), &selection.to_string(), &mut requested);
+ }
+ h.app.run("select.clear", json!({})).unwrap();
+
+ // Keep history traversal in a small fixture, independent of viewport/browser selection.
+ let mut history = Harness::new();
+ history.app.home.open = false;
+ for name in ["History A", "History B"] {
+ history.app.run("solid.box", json!({"length":10,"width":10,"height":10,"name":name})).unwrap();
+ }
+ history.frames(3);
+ // Named feature history has independent menus in both layout preferences.
+ for left in [false, true] {
+ history.app.preferences.timeline_left = left;
+ history.frames(3);
+ context_rows(&mut history, "timeline:", &mut requested);
+ }
+ let features = history.app.session.doc.features.iter().take(2).map(|f| f.id).collect::<Vec<_>>();
+ let group = history.app.run("timeline.group", json!({"features":features,"name":"Audit history folder"})).unwrap()["group"].as_u64().unwrap();
+ history.frames(3);
+ context_rows(&mut history, "timeline-folder:", &mut requested);
+ history.app.tree.picked_timeline_groups.clear();
+ history.app.run("select.set", json!({"items":features.iter().map(|id| json!({"type":"feature","id":id})).collect::<Vec<_>>()})).unwrap();
+ history.frames(3);
+ history.step(&json!({"widget":"2 selected"})).unwrap();
+ collect(&mut history, "history feature selection", &mut requested);
+ escape(&mut history);
+ history.app.run("select.clear", json!({})).unwrap();
+ history.app.tree.picked_timeline_groups = vec![group];
+ history.frames(3);
+ history.step(&json!({"widget":"1 selected"})).unwrap();
+ collect(&mut history, "history folder selection", &mut requested);
+ escape(&mut history);
+ history.app.tree.picked_timeline_groups.clear();
+ // Document tabs currently expose close buttons and an overflow list, but no
+ // right-click menu (in this branch or origin/main).
+ h.step(&json!({"click":{"handle":"tab:design:0"},"button":"right"})).unwrap();
+ escape(&mut h);
+
+ // Overflow uses egui's nested panel menus. Open each visible panel submenu.
+ h.call("ui.resize", json!({"width":360,"height":1000}));
+ let mut overflow_count = 0;
+ let mut overflow_rows = 0;
+ for tab in workspace::visible_tabs(&h.app) {
+ // The tabs were clicked above at full width; narrow layouts can clip their hit regions.
+ h.app.ui.tab = tab.into();
+ h.frames(3);
+ if solidcraft_ui_egui::scenario::handle_at("toolbar:overflow").is_some() {
+ overflow_count += 1;
+ click(&mut h, "toolbar:overflow");
+ collect(&mut h, "overflow", &mut requested);
+ for panel in workspace::panels(tab) {
+ if let Some([x, y]) = h.widget(panel) {
+ h.call("ui.move", json!({"x":x,"y":y}));
+ h.frames(20);
+ overflow_rows += solidcraft_ui_egui::scenario::handles("toolbar:").iter().filter(|(name, _)| name != "toolbar:overflow").count();
+ collect(&mut h, &format!("overflow:{tab}:{panel}"), &mut requested);
+ }
+ }
+ escape(&mut h);
+ }
+ }
+ assert!(overflow_count > 0, "the narrow traversal must actually open overflow menus");
+ assert!(overflow_rows > 0, "overflow submenus must actually draw command rows");
+ h.call("ui.resize", json!({"width":1600,"height":1000}));
+ // Browser grouping and construction planes add row-specific menus.
+ let group = h.app.run("browser.group", json!({"component":0,"folder":"bodies","items":[body]})).unwrap()["group"].as_u64().unwrap();
+ menu(&mut h, json!({"type":"group","scope":"c0","id":group}), "body group", &mut requested);
+ h.app.run("construct.plane.offset", json!({"base":"XY","offset":25,"name":"Audit plane"})).unwrap();
+ let plane = h.app.session.doc.features.last().unwrap().id;
+ menu(&mut h, json!({"type":"plane","id":plane}), "construction plane", &mut requested);
+ // Actual hit lists at body corners and face centres (including overlapping origin planes).
+ h.app.fit_view();
+ h.frames(3);
+ for world in [[0.0, 0.0, 0.0], [40.0, 25.0, 8.0], [40.0, 25.0, 22.0]] {
+ let [x, y] = h.at(&json!({"world":world})).unwrap();
+ assert_eq!(h.call("ui.selectOther", json!({"x":x,"y":y}))["ok"], true);
+ collect(&mut h, "Select Other", &mut requested);
+ h.call("ui.selectOther", json!({"close":true}));
+ }
+
+ // Search every command by its full label so results beyond the first page are painted.
+ for command in solidcraft_engine::command_specs() {
+ solidcraft_ui_egui::shortcut_box::open(&mut h.app, None);
+ h.app.sbox.text = command.label.to_owned();
+ h.frames(2);
+ collect(&mut h, command.id, &mut requested);
+ escape(&mut h);
+ }
+ // Every registered command is also started through its interactive entry point. Some
+ // require geometry or an active sketch; the second pass supplies sketch context.
+ for sketching in [false, true] {
+ if sketching {
+ h.app.run("sketch.edit", json!({"sketch":sketch})).unwrap();
+ h.frames(3);
+ ribbon(&mut h, &mut requested);
+ for selection in [json!({"type":"sketch_curve","id":"l1"}), json!({"type":"sketch_point","id":"p1"})] {
+ h.app.run("select.set", json!({"items":[selection]})).unwrap();
+ menu(&mut h, json!({"type":"viewport"}), "sketch entity", &mut requested);
+ }
+ h.app.run("select.clear", json!({})).unwrap();
+ }
+ panels(&mut h, &mut requested);
+ }
+ // Sheet and assembly contexts expose contextual tabs and browser row kinds that
+ // a single solid part cannot offer. Use repository-owned public sample recipes.
+ for sample in solidcraft_engine::sample::samples().into_iter().filter(|s| matches!(s.name, "Sheet Metal Bracket" | "Hinge Assembly")) {
+ let mut sample_h = Harness::new();
+ sample_h.app.home.open = false;
+ sample_h.app.session.run_script(&(sample.script)()).unwrap();
+ sample_h.frames(3);
+ ribbon(&mut sample_h, &mut requested);
+ let joints = sample_h.app.session.doc.assembly.joints.iter().map(|j| j.id).collect::<Vec<_>>();
+ for id in joints {
+ menu(&mut sample_h, json!({"type":"joint","id":id}), "assembly joint", &mut requested);
+ }
+ let paths = sample_h.app.session.doc.occurrences.iter().map(|o| (o.id, o.component)).collect::<Vec<_>>();
+ for (id, component) in paths {
+ menu(&mut sample_h, json!({"type":"component","id":component}), "component", &mut requested);
+ menu(&mut sample_h, json!({"type":"occurrence","path":[id]}), "occurrence", &mut requested);
+ }
+ context_rows(&mut sample_h, "row:", &mut requested);
+ panels(&mut sample_h, &mut requested);
+ collect(&mut sample_h, sample.name, &mut requested);
+ }
+ let mut geometry = Harness::new();
+ geometry.app.home.open = false;
+ geometry.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"Audit block"})).unwrap();
+ geometry.app.run("solid.split_body", json!({"body":"Audit block","plane":{"origin":[5,0,0],"normal":[1,0,0]}})).unwrap();
+ geometry.frames(3);
+ collect(&mut geometry, "Split feature history", &mut requested);
+ geometry.app.run("sketch.create", json!({"plane":"XY","name":"Wall profile"})).unwrap();
+ geometry.app.run("sketch.line", json!({"points":[[20,0],[30,0]]})).unwrap();
+ geometry.app.run("sketch.finish", json!({})).unwrap();
+ geometry.app.run("surface.extrude", json!({"sketch":"Wall profile","curves":["l1"],"distance":10,"body_name":"Audit surface"})).unwrap();
+ let mesh = geometry.dir.join("audit.obj");
+ std::fs::write(&mesh, "o Audit mesh\nv 40 0 0\nv 50 0 0\nv 40 10 0\nv 40 0 10\nf 1 3 2\nf 1 2 4\nf 1 4 3\nf 2 3 4\n").unwrap();
+ geometry.app.run("file.insert_mesh", json!({"path":mesh})).unwrap();
+ geometry.frames(3);
+ let bodies = geometry.app.session.model.state().bodies.iter().map(|b| b.name.clone()).collect::<Vec<_>>();
+ assert!(bodies.iter().any(|b| b == "Audit surface"));
+ for name in bodies {
+ menu(&mut geometry, json!({"type":"body","name":name}), &format!("solid/surface/mesh body {name}"), &mut requested);
+ geometry.app.run("select.set", json!({"items":[{"type":"body","name":name}]})).unwrap();
+ menu(&mut geometry, json!({"type":"viewport"}), &format!("solid/surface/mesh viewport {name}"), &mut requested);
+ }
+ panels(&mut geometry, &mut requested);
+ // Home recent-file context menus have their own native popup dispatch.
+ let path = geometry.dir.join("audit.solidcraft");
+ geometry.app.run("file.save", json!({"path":path})).unwrap();
+ geometry.app.home.recent = vec![path.to_string_lossy().into_owned()];
+ geometry.app.home.open = true;
+ geometry.frames(3);
+ context_rows(&mut geometry, "home:recent:", &mut requested);
+ click(&mut geometry, "appbar:file");
+ geometry.step(&json!({"widget":geometry.app.tr("ui.open_recent")})).expect("click Open Recent submenu");
+ geometry.frames(20);
+ assert!(geometry.widget(geometry.app.tr("ui.clear_recent")).is_some(), "the recent-design submenu must be open");
+ collect(&mut geometry, "File recent designs", &mut requested);
+ escape(&mut geometry);
+ // Populate actual document slots, then click the same overflow launcher as a person.
+ let mut documents = Harness::new();
+ for _ in 0..12 {
+ solidcraft_ui_egui::documents::open_tab(&mut documents.app, solidcraft_engine::Session::default()).unwrap();
+ }
+ documents.app.home.open = false;
+ documents.call("ui.resize", json!({"width":640,"height":1000}));
+ click(&mut documents, "tab:overflow");
+ documents.frames(3);
+ assert!(documents.ctx.data(|d| d.get_temp::<bool>(egui::Id::new("sc_doc_more"))).unwrap_or(false), "the document list must actually be open");
+ collect(&mut documents, "document overflow list (active icon is a selection marker)", &mut requested);
+ // Diagnostic badges and Copy Error/Warning Message only appear on troubled features.
+ for failing in [false, true] {
+ let mut diagnostics = Harness::new();
+ diagnostics.app.home.open = false;
+ if failing {
+ diagnostics.app.session.run_script(&solidcraft_engine::sample::script()).unwrap();
+ diagnostics.app.run("parameters.change", json!({"name":"width","expression":"5 mm"})).unwrap();
+ } else {
+ diagnostics.app.run("solid.box", json!({"length":10,"width":10,"height":10,"body_name":"One"})).unwrap();
+ diagnostics.app.run("solid.fillet", json!({"edges":[[5,0,10]],"radius":20,"fit":"reduce","body":"One"})).unwrap();
+ }
+ for left in [false, true] {
+ diagnostics.app.preferences.timeline_left = left;
+ diagnostics.frames(3);
+ context_rows(&mut diagnostics, "timeline:", &mut requested);
+ collect(&mut diagnostics, if failing { "failed history" } else { "warning history" }, &mut requested);
+ }
+ }
+ // Existing scenarios actually interact with dimension editors, corner popups, sketch
+ // palette controls and overlapping sketch hit lists, in addition to opening their tools.
+ for (name, source) in [
+ ("dimensions and constraints", include_str!("scenarios/s11_sketch_constraints.json")),
+ ("corner popup", include_str!("scenarios/sketch_corner_window.json")),
+ ("sketch palette", include_str!("scenarios/sketch_palette_linetype_icons.json")),
+ ("sketch Select Other", include_str!("scenarios/select_other_coincident_lines.json")),
+ ("canvas calibration", include_str!("scenarios/s19_canvas_calibrate.json")),
+ ] {
+ let mut scenario = Harness::new();
+ scenario.run(&serde_json::from_str(source).unwrap()).unwrap_or_else(|e| panic!("{name}: {e}"));
+ collect(&mut scenario, name, &mut requested);
+ }
+ icon_svg::audit::stop();
+ let manifest = requested.iter().map(|(name, placeholder)| format!("{name}\t{placeholder}\n")).collect::<String>();
+ let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/icons/ui/design/requested_icons.txt");
+ if std::env::var("UPDATE_ICON_MANIFEST").as_deref() == Ok("1") {
+ std::fs::write(&path, &manifest).unwrap();
+ } else {
+ let expected = std::fs::read_to_string(&path).unwrap_or_default();
+ assert_eq!(
+ expected, manifest,
+ "Runtime icon discovery changed. Regenerate with UPDATE_ICON_MANIFEST=1 cargo test -p solidcraft-ui-egui --test icon_audit"
+ );
+ }
+ let missing = requested.iter().filter(|(_, placeholder)| **placeholder).map(|(name, _)| name).collect::<Vec<_>>();
+ assert!(missing.is_empty(), "Runtime placeholder requests (see surface diagnostics above): {missing:?}");
+}
+
+#[test]
+fn audit_is_opt_in_drains_and_records_resolved_aliases() {
+ icon_svg::audit::stop();
+ icon_svg::resolve("extrude");
+ assert!(icon_svg::audit::take().is_empty());
+ icon_svg::audit::start();
+ icon_svg::resolve("surface_extrude");
+ icon_svg::resolve("surface_extrude");
+ icon_svg::resolve("missing_audit_test_icon");
+ let requests = icon_svg::audit::take();
+ assert_eq!(requests.len(), 2);
+ assert!(requests.iter().any(|r| r.name == "surface_extrude" && r.master == "extrude" && !r.placeholder));
+ assert!(requests.iter().any(|r| r.name == "missing_audit_test_icon" && r.master == "placeholder" && r.placeholder));
+ assert!(icon_svg::audit::take().is_empty());
+ icon_svg::audit::stop();
+}
+
+/// Review evidence uses the application's actual SVG renderer, without a window or screenshot.
+#[test]
+fn offset_mode_artwork_review() {
+ use solidcraft_ui_egui::theme::{ColorVision, Tokens};
+ let names = ["offset", "offset_two_sides", "offset_symmetric", "sketch_chamfer", "sketch_chamfer_two_distances", "split_body"];
+ let mut sheet = tiny_skia::Pixmap::new(400, names.len() as u32 * 88).unwrap();
+ for (row, name) in names.iter().enumerate() {
+ let resolved = icon_svg::resolve(name);
+ assert!(!resolved.placeholder, "{name}");
+ for (column, dark) in [false, true].into_iter().enumerate() {
+ let [r, g, b, _] = Tokens::themed(dark, ColorVision::Off).panel.to_array();
+ let mut background = tiny_skia::Paint::default();
+ background.set_color_rgba8(r, g, b, 255);
+ sheet.fill_rect(
+ tiny_skia::Rect::from_xywh(column as f32 * 200.0, row as f32 * 88.0, 200.0, 88.0).unwrap(),
+ &background,
+ tiny_skia::Transform::identity(),
+ None,
+ );
+ let mut x = column as i32 * 200 + 8;
+ for px in [64, 24, 16] {
+ let look = icon_svg::Look { dark, accent: resolved.accent, vision: ColorVision::Off };
+ let pm = icon_svg::render(icon_svg::doc_for(resolved.master, px).unwrap(), look, px).unwrap();
+ sheet.draw_pixmap(x, row as i32 * 88 + 8, pm.as_ref(), &tiny_skia::PixmapPaint::default(), tiny_skia::Transform::identity(), None);
+ x += px as i32 + 16;
+ }
+ }
+ }
+ let dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../target/icon-audit");
+ std::fs::create_dir_all(&dir).unwrap();
+ image::save_buffer(dir.join("offset-review.png"), sheet.data(), sheet.width(), sheet.height(), image::ColorType::Rgba8).unwrap();
+}
+
+#[test]
+fn overflow_icons_with_many_pins_at_200_points() {
+ let mut h = Harness::new();
+ icon_svg::audit::start();
+ let steps = serde_json::from_str(include_str!("scenarios/s48_toolbar_many_pins.json")).unwrap();
+ if let Err(error) = h.run(&steps) {
+ h.step(&json!({"debug":"widgets"})).unwrap();
+ h.step(&json!({"debug":"handles"})).unwrap();
+ panic!("{error}");
+ }
+ let requested = icon_svg::audit::take();
+ icon_svg::audit::stop();
+ let manifest =
+ std::fs::read_to_string(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../assets/icons/ui/design/requested_icons.txt")).unwrap();
+ for icon in requested {
+ assert!(!icon.placeholder, "{}", icon.name);
+ assert!(manifest.lines().any(|line| line == format!("{}\tfalse", icon.name)), "{} is absent from runtime discovery", icon.name);
+ }
+}
diff --git a/crates/ui-egui/tests/scenarios/s18_3d_sketch_pipe.json b/crates/ui-egui/tests/scenarios/s18_3d_sketch_pipe.json
index 5d336b53ff..aa988c99d7 100644
--- a/crates/ui-egui/tests/scenarios/s18_3d_sketch_pipe.json
+++ b/crates/ui-egui/tests/scenarios/s18_3d_sketch_pipe.json
@@ -64,6 +64,7 @@
"sketching": true
}
},
+ {"click": {"handle": "sketch_palette:options_fold"}},
{
"widget": "3D Sketch"
},
diff --git a/crates/ui-egui/tests/scenarios/s30_pattern_a_hole.json b/crates/ui-egui/tests/scenarios/s30_pattern_a_hole.json
index 070754ea0a..4ae595fd57 100644
--- a/crates/ui-egui/tests/scenarios/s30_pattern_a_hole.json
+++ b/crates/ui-egui/tests/scenarios/s30_pattern_a_hole.json
@@ -110,8 +110,7 @@
}
},
{
- "widget": "20 mm",
- "near": "Spacing"
+ "click": {"handle": "dialog:Spacing"}
},
{
"key": "A",
diff --git a/crates/ui-egui/tests/scenarios/s35_construction_mode.json b/crates/ui-egui/tests/scenarios/s35_construction_mode.json
index 9237adab0d..6b9a023d9a 100644
--- a/crates/ui-egui/tests/scenarios/s35_construction_mode.json
+++ b/crates/ui-egui/tests/scenarios/s35_construction_mode.json
@@ -1,5 +1,5 @@
[
- {"note": "Construction mode like Fusion: with nothing selected, X (or the palette's Construction linetype) makes new curves construction until switched back; with a selection X converts it. The palette's linetype buttons still carry their old glyphs ('--', '- -', '-.-') as an invisible accessible label and hit target. A drawn icon (icons.rs) now paints over each, in the construction orange for construction and centerline. The widgets below are still reached by the glyph."},
+ {"note": "With nothing selected, X or the palette Construction icon sets the drawing mode until switched back. With a selection, X converts it. The four Line Type icon segments use named handles."},
{"start": "sketch.create"},
{"click": {"plane": "XY"}},
{"expect": {"dialog": null}},
@@ -20,13 +20,13 @@
{"expect": {"query": {"command": "sketch.inspect", "path": ["curves", 4], "value": null}}},
{"key": "Y", "cmd": true},
{"shot": "s35_construction_mode"},
- {"widget": "—"},
+ {"click": {"handle": "dialog:Line Type:normal"}},
{"start": "sketch.circle.center"},
{"click": {"sketch": [40, 10]}},
{"click": {"sketch": [45, 10]}},
{"key": "Escape"},
{"expect": {"query": {"command": "sketch.inspect", "path": ["curves", 5, "construction"], "value": false}}},
- {"widget": "- -"},
+ {"click": {"handle": "dialog:Line Type:construction"}},
{"start": "sketch.line"},
{"click": {"sketch": [0, 30]}},
{"click": {"sketch": [30, 30]}},
diff --git a/crates/ui-egui/tests/scenarios/s36_sketch_palette_visible.json b/crates/ui-egui/tests/scenarios/s36_sketch_palette_visible.json
index 087dad03e5..6531a36fd7 100644
--- a/crates/ui-egui/tests/scenarios/s36_sketch_palette_visible.json
+++ b/crates/ui-egui/tests/scenarios/s36_sketch_palette_visible.json
@@ -1,10 +1,10 @@
[
{
- "note": "The Sketch Palette shows docked at the right whenever a sketch is active and no command dialog is open, comes back when the dialog closes, and goes with the sketch."
+ "note": "The sketch card stays at the right while editing, including after closing Parameters, and goes with the sketch. Finish Sketch is reached from the Sketch ribbon."
},
{
"expect": {
- "not_shown": "SKETCH PALETTE"
+ "hidden_handles": ["sketch_palette:status_header"]
}
},
{
@@ -13,7 +13,7 @@
{
"expect": {
"dialog": "Sketch",
- "not_shown": "SKETCH PALETTE"
+ "hidden_handles": ["sketch_palette:status_header"]
}
},
{
@@ -25,7 +25,7 @@
"expect": {
"sketching": true,
"dialog": null,
- "shown": "SKETCH PALETTE"
+ "shown_handles": ["sketch_palette:status_header"]
}
},
{
@@ -38,7 +38,7 @@
},
{
"expect": {
- "shown": "SKETCH PALETTE"
+ "shown_handles": ["sketch_palette:status_header"]
}
},
{
@@ -66,9 +66,10 @@
{
"widget": "Close window"
},
+ {"click": {"handle": "tab:SKETCH"}},
{
"expect": {
- "shown": "SKETCH PALETTE"
+ "shown_handles": ["sketch_palette:status_header"]
}
},
{
@@ -79,7 +80,7 @@
},
{
"expect": {
- "shown": "SKETCH PALETTE"
+ "shown_handles": ["sketch_palette:status_header"]
}
},
{
@@ -93,7 +94,7 @@
{
"expect": {
"sketching": false,
- "not_shown": "SKETCH PALETTE"
+ "hidden_handles": ["sketch_palette:status_header"]
}
}
]
\ No newline at end of file
diff --git a/crates/ui-egui/tests/scenarios/s37_browser_chevrons.json b/crates/ui-egui/tests/scenarios/s37_browser_chevrons.json
index c151e7ae9d..ecb428306b 100644
--- a/crates/ui-egui/tests/scenarios/s37_browser_chevrons.json
+++ b/crates/ui-egui/tests/scenarios/s37_browser_chevrons.json
@@ -318,6 +318,10 @@
]
}
},
+ {"note": "Close the already checked upper folders so the component rows fit in the Browser without scrolling."},
+ {"click": {"handle": "fold:Document Settings"}},
+ {"click": {"handle": "fold:Named Views"}},
+ {"click": {"handle": "fold:Origin"}},
{
"note": "Expanded rows now scroll within the floating card, above the History strip."
},
diff --git a/crates/ui-egui/tests/scenarios/s37_construction_geometries_toggle.json b/crates/ui-egui/tests/scenarios/s37_construction_geometries_toggle.json
index 67d1ce6efc..c612af8daf 100644
--- a/crates/ui-egui/tests/scenarios/s37_construction_geometries_toggle.json
+++ b/crates/ui-egui/tests/scenarios/s37_construction_geometries_toggle.json
@@ -9,6 +9,7 @@
{"call": "engine.execute", "params": {"command": "sketch.centerline", "params": {"curves": ["l6"], "value": true}}},
{"call": "ui.view", "params": {"view": "top"}},
{"call": "ui.view", "params": {"view": "fit"}},
+ {"click": {"handle": "sketch_palette:options_fold"}},
{"expect": {"shown": "Construction Geometries"}},
{"expect": {"query": {"command": "sketch.options", "path": ["options", "show_construction"], "value": true}}},
diff --git a/crates/ui-egui/tests/scenarios/s49_sheet_metal_flange_per_edge.json b/crates/ui-egui/tests/scenarios/s49_sheet_metal_flange_per_edge.json
index 9139297870..1a7c01eac4 100644
--- a/crates/ui-egui/tests/scenarios/s49_sheet_metal_flange_per_edge.json
+++ b/crates/ui-egui/tests/scenarios/s49_sheet_metal_flange_per_edge.json
@@ -89,6 +89,7 @@
]
}
},
+ {"click": {"handle": "dialog:section:Advanced"}},
{
"click": {
"handle": "dialog:Edge 2 angle"
diff --git a/crates/ui-egui/tests/scenarios/sketch_dialog_keeps_the_palette.json b/crates/ui-egui/tests/scenarios/sketch_dialog_keeps_the_palette.json
index f47a3179d5..920499dbba 100644
--- a/crates/ui-egui/tests/scenarios/sketch_dialog_keeps_the_palette.json
+++ b/crates/ui-egui/tests/scenarios/sketch_dialog_keeps_the_palette.json
@@ -1,5 +1,5 @@
[
- {"note": "A command dialog opened while a sketch is being edited no longer hides the Sketch Palette. The dialog docks at the left edge of the viewport, the palette keeps the right edge, and neither covers the other. Finish Sketch and the Sketch Status readout stay reachable the whole time."},
+ {"note": "A command dialog opened while a sketch is being edited no longer hides the Sketch Palette. The dialog docks at the left edge of the viewport, the palette keeps the right edge, and neither covers the other. The palette card, constraint status and ribbon Finish Sketch stay reachable the whole time."},
{"start": "sketch.create"},
{"click": {"plane": "XY"}},
{"start": "sketch.rectangle.two_point"},
@@ -8,14 +8,15 @@
{"key": "Escape"},
{"expect": {"sketching": true}},
{"expect": {"dialog": null}},
- {"expect": {"shown_handles": ["sketch_palette:finish"]}},
+ {"expect": {"shown_handles": ["sketch_palette:status_header", "button:sketch.finish"]}},
{"start": "inspect.measure"},
- {"expect": {"dialog": "Measure"}},
- {"expect": {"shown_handles": ["sketch_palette:finish"]}},
+ {"expect": {"dialog": "Measure", "shown_handles": ["sketch_palette:status_header"]}},
+ {"click": {"handle": "tab:SKETCH"}},
+ {"expect": {"shown_handles": ["sketch_palette:status_header", "button:sketch.finish"]}},
{"expect": {"disjoint": ["sketch_palette:outer", "dialog:outer"]}},
{"shot": "sketch_dialog_keeps_the_palette"},
{"widget": "Close"},
{"expect": {"dialog": null}},
{"expect": {"sketching": true}},
- {"expect": {"shown_handles": ["sketch_palette:finish"]}}
+ {"expect": {"shown_handles": ["sketch_palette:status_header", "button:sketch.finish"]}}
]
diff --git a/crates/ui-egui/tests/scenarios/sketch_palette_linetype_icons.json b/crates/ui-egui/tests/scenarios/sketch_palette_linetype_icons.json
index b0215d7d16..b0cf173c09 100644
--- a/crates/ui-egui/tests/scenarios/sketch_palette_linetype_icons.json
+++ b/crates/ui-egui/tests/scenarios/sketch_palette_linetype_icons.json
@@ -1,17 +1,17 @@
[
{
- "note": "The Sketch Palette's Normal/Construction/Centerline selector (not the toolbar's separate CREATE panel icons) now paints a real drawn icon over each of its three old text glyphs ('--', '- -', '-.-'), in the construction orange for construction and centerline. The glyphs stay as the invisible accessible label and hit target, unchanged. The widgets below are still reached by the glyph, exactly as in s35_construction_mode.json. This exercises the Centerline button's mode switch through this widget. No scenario previously did that: with nothing selected, a click sets the drawing mode until it is switched back, the same way s35 exercises Construction's."
+ "note": "The palette exposes four icon segments named normal, construction, centerline and infinite. Centerline drawing makes no profiles; returning to Normal produces a closed profile."
},
{"start": "sketch.create"},
{"click": {"plane": "XY"}},
{"expect": {"dialog": null}},
- {"widget": "-·-"},
+ {"click": {"handle": "dialog:Line Type:centerline"}},
{"start": "sketch.rectangle.two_point"},
{"click": {"sketch": [0, 0]}},
{"click": {"sketch": [30, 20]}},
{"key": "Escape"},
{"expect": {"query": {"command": "sketch.inspect", "path": ["profiles"], "value": []}}},
- {"widget": "—"},
+ {"click": {"handle": "dialog:Line Type:normal"}},
{"start": "sketch.rectangle.two_point"},
{"click": {"sketch": [0, 40]}},
{"click": {"sketch": [30, 60]}},
diff --git a/crates/ui-egui/tests/scenarios/sketch_pattern_rect_window.json b/crates/ui-egui/tests/scenarios/sketch_pattern_rect_window.json
index 52952f2787..bf8e5af7e6 100644
--- a/crates/ui-egui/tests/scenarios/sketch_pattern_rect_window.json
+++ b/crates/ui-egui/tests/scenarios/sketch_pattern_rect_window.json
@@ -68,7 +68,9 @@
{"start": "sketch.pattern.rectangular"},
{"click": {"sketch": [105, 0]}},
{"click": {"handle": "dialog:Direction"}},
- {"click": {"axis": "Y"}},
+ {"note": "The dense dialog covers the old viewport axis target. Pick the same Y axis through Origin in the Browser."},
+ {"click": {"handle": "fold:Origin"}},
+ {"click": {"browser": "Y"}},
{"click": {"handle": "dialog:Quantity"}},
{"key": "A", "cmd": true},
{"text": "4"},
diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md
index 585c47a948..e016760197 100644
--- a/docs/book/src/SUMMARY.md
+++ b/docs/book/src/SUMMARY.md
@@ -23,6 +23,7 @@
- [Contributing](dev/contributing.md)
- [Architecture](dev/architecture.md)
+- [UI kit](dev/ui-kit.md)
- [Extensible library proposal](dev/libraries.md)
- [Local scalar libraries](dev/local-libraries.md)
- [The command engine](dev/commands.md)
diff --git a/docs/book/src/dev/ui-kit.md b/docs/book/src/dev/ui-kit.md
new file mode 100644
index 0000000000..263899c506
--- /dev/null
+++ b/docs/book/src/dev/ui-kit.md
@@ -0,0 +1 @@
+{{#include ../../../ui-kit.md}}
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index dcf72886f5..dd82e6b015 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -129,7 +129,8 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.
| `ui.click` | `x`, `y` (screen points), `button?`: left/right/middle, `shift?`, `ctrl?`, `double?` | real pointer input |
| `ui.move` | `x`, `y`, `shift?`, `alt?`, `ctrl?`, `cmd?` | pointer movement without a button; modifiers apply until the next synthetic move/click; a move with omitted modifiers releases them. With `nav: "touchpad"`, Shift pans and Alt/Option orbits. |
| `ui.drag` | `x0`, `y0`, `x1`, `y1`, `button?`, `shift?`, `ctrl?`, `steps?`, `hold?`, `hold_end?` | press, move, release; a left drag on the model is a box selection (left to right: window, right to left: crossing); with OpenSCAD navigation, plain left-drag on empty space orbits, Shift+left-drag box-selects, and drags starting on sketch geometry edit it; `hold` keeps the button down that many frames first (a right press-and-hold opens the marking menu, releasing over a direction picks it), `hold_end` that many frames at the end (a sketch drag shows its snap) |
-| `ui.menu` | `x?`, `y?`, `target?`, `close?` | with a point: open a context menu there as a right-click would (the viewport's marking menu, or a browser menu with `target: {"type": "body", "name"} \| {"type": "sketch", "id"} \| {"type": "component", "id"}`); without: the open menu (`radial` and `items`: id, label, shortcut, enabled) |
+| `ui.menu` | `x?`, `y?`, `target?`, `close?` | with a point: open a context menu there as a right-click would (the viewport's marking menu, or a browser menu with `target: {"type": "body", "name"} \| {"type": "sketch", "id"} \| {"type": "component", "id"}`); without: the open menu (`radial` and `items`: id, label, shortcut, enabled, icon, placeholder; blank icons on headings/separators have `placeholder: false`) |
+| `ui.icon_audit` | `reset?`, `stop?` | `reset: true` enables collection on the UI thread and clears previous requests; returns `{requested: [{name, master, placeholder}]}` sorted by requested id. Each read drains names collected since the previous read/reset. Collection stays enabled until `stop: true` (which returns pending names before disabling it). Includes aliases, variable/table ids and cached paints. |
| `ui.menuPick` | `item`: id or label | runs an item of the open menu, as clicking it does |
| `ui.selectOther` | `x?`, `y?`, `pick?`, `add?`, `hover?`, `close?` | Select Other: with a point, list everything pickable there (as holding the left button does); `pick`: select row `pick` (`add`: as Shift-click; with a dialog open, into its active input); `hover`: light a row up; without: the open list (`open`, `at`, `total`: everything under the cursor, `rows`: label, icon, sel, at most 20 per kind, nearest first) |
| `ui.rename` | `text?`, `commit?` (default true) | finishes the rename box a Rename item opened |
@@ -139,7 +140,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.
| `ui.sketchToScreen` | `points`: `[[x, y]…]` in active-sketch coordinates | their screen points (null when behind the camera) |
| `ui.dialogInput` | `index` | what clicking an input's Select chip does: picks go to that input |
| `ui.at` | `world: [x,y,z]` \| `sketch: [x,y]` \| `plane: "XY"` \| `axis: "Z"` \| `dimension: "d1"` (its value text) \| `handle: "arrow"` (a manipulator handle, see `scenario::publish_handle`) | the screen point (a scenario step's target; see `crates/ui-egui/src/scenario.rs`) |
-| `ui.handles` | `prefix?` | the handles drawn last frame, `[{name, x, y}]`: toolbar buttons and drop-down items `toolbar:<command id>` (the button alone: `button:<command id>`; a drop-down row: `dropdown:<command id>`, highlighted `dropdown_hot:<command id>`, its pin `dropdown_pin:<command id>`; Customize Toolbar's check boxes `customize:<command id>`), ribbon tabs `tab:<name>` (MODEL, SURFACE, ASSEMBLE, INSERT, INSPECT, MANAGE, VIEW; contextual SKETCH and SHEET METAL; workspace RENDER), panel labels `panel:<tab>:<panel>` (also `ribbon:section:<TAB>:<SECTION>`), workspace column `ribbon:workspace`, command-search launcher `ribbon:search`, browser rows `row:<label>` and fold arrows `fold:<label>`, manipulator handles; signed-axis tips `axis_view:z`, `axis_view:-y`; optional cube facets `navigation_cube:top`, `navigation_cube:top_front_right`, controls `navigation_cube:control:home` (and other actions), plus signed-axis aliases for visible cube faces; Preferences navigator picker `prefs:navigator`, options `prefs:navigator:Signed axes` and `prefs:navigator:Cube`; in the Motion Study dialog, where the chart puts its first and last step `motion:chart_start` and `motion:chart_end`, the Check collisions button `motion:check` and each collision found `motion:collision:<n>` |
+| `ui.handles` | `prefix?` | the handles drawn last frame, `[{name, x, y}]`: toolbar buttons and drop-down items `toolbar:<command id>` (the button alone: `button:<command id>`; a drop-down row: `dropdown:<command id>`, highlighted `dropdown_hot:<command id>`, its pin `dropdown_pin:<command id>`; Customize Toolbar's check boxes `customize:<command id>`), ribbon tabs `tab:<name>` (MODEL, SURFACE, ASSEMBLE, INSERT, INSPECT, MANAGE, VIEW; contextual SKETCH and SHEET METAL; workspace RENDER), panel labels `panel:<tab>:<panel>` (also `ribbon:section:<TAB>:<SECTION>`), document overflow list `tab:overflow`, workspace column `ribbon:workspace`, command-search launcher `ribbon:search`, browser rows `row:<label>` and fold arrows `fold:<label>`, manipulator handles; signed-axis tips `axis_view:z`, `axis_view:-y`; optional cube facets `navigation_cube:top`, `navigation_cube:top_front_right`, controls `navigation_cube:control:home` (and other actions), plus signed-axis aliases for visible cube faces; Preferences navigator picker `prefs:navigator`, options `prefs:navigator:Signed axes` and `prefs:navigator:Cube`; in the Motion Study dialog, where the chart puts its first and last step `motion:chart_start` and `motion:chart_end`, the Check collisions button `motion:check` and each collision found `motion:collision:<n>` |
| `ui.editFeature` | `feature` (id or name) | what double-clicking a timeline item does: rolls back to it and opens its dialog filled in (sketches open in sketch mode) |
| `ui.scroll` | `x`, `y`, `delta?` | wheel zoom at the cursor |
| `ui.key` | `key` (egui key name, `Enter`, `Escape`…), `cmd?`, `shift?` | |
diff --git a/docs/fonts.md b/docs/fonts.md
new file mode 100644
index 0000000000..18888191b7
--- /dev/null
+++ b/docs/fonts.md
@@ -0,0 +1,42 @@
+# Interface fonts
+
+SolidCraft bundles IBM Plex Sans as its default interface font on desktop and web.
+The unmodified variable font provides regular (400), medium (500), semibold (600)
+and bold (700) faces. Titles and selected labels use semibold; compass letters
+and the primary OK action use bold. Selection fields and status messages use
+medium. Numeric fields and sketch dimensions use IBM Plex Mono Regular.
+
+Both fonts are licensed under the SIL Open Font License 1.1. Their licence texts
+are in `assets/fonts/ibm-plex-sans/OFL.txt` and
+`assets/fonts/ibm-plex-mono/OFL.txt`; provenance is recorded in
+[ATTRIBUTION.md](../ATTRIBUTION.md).
+
+The `ui_font` preference puts the chosen font first in every sans family,
+including the three weighted families. A chosen static font retains its own
+weight; SolidCraft does not simulate bold by drawing text twice. Clearing the
+preference restores Plex. Monospace fields keep Plex Mono.
+
+Egui's symbol and emoji fallbacks remain available. Desktop also appends the
+available Japanese/Chinese, Hangul and Thai system fonts to every family, ordered
+for the selected language. The web app installs Plex at startup and adds its
+bundled Japanese font asynchronously when needed, preserving the interface faces
+and any font preference.
+
+## Type scale and metrics
+
+Text sizes come from `theme::Tokens`, with identical values in the light and dark
+palettes in `assets/styles/ui/palettes.rs`. The compact scale runs from
+`font_badge` (9.5 pt) through `font_heading` (14 pt). Special roles preserve the
+existing designs: `font_triad` (8), `font_compass` (13.5), `font_subtitle` (15),
+`font_intro` (16), `font_article_heading` (17), `font_title` (22), and
+`font_display` (26). Scaled labels derive from these tokens. Weight helpers in
+`fonts.rs` choose the family independently of size.
+
+Dense forms also use tokens for control height/radius, label width, row gap,
+header/footer/card dimensions, icons, text insets, checkbox and action heights,
+and section letter spacing. Existing `space_*` tokens supply shared padding.
+The `font_literals_tests` source guard scans production Rust, including the
+viewport icon sources, and rejects numeric font sizes, private font families
+outside `fonts.rs`, and direct dense-form spacing literals. Its small per-file
+allowance table documents graphic spinner diameters; it permits no text sizes.
+Run it with `cargo test -p solidcraft-ui-egui --lib font_literals_tests`.
diff --git a/docs/sketch-tool-panel-review.md b/docs/sketch-tool-panel-review.md
new file mode 100644
index 0000000000..c0d59c2e96
--- /dev/null
+++ b/docs/sketch-tool-panel-review.md
@@ -0,0 +1,214 @@
+# Sketch tool panel review
+
+Inventory before the port, checked against `solidcraft-cli commands`, `dialogs::Kind`,
+the sketch tool dispatchers, and all sketch sources' window/area helpers.
+Control requests below are JSON lines sent to an already running app. Add the launch
+token to the first request on each connection and use distinct request IDs.
+
+Common setup **S**:
+
+```json
+{"id":1,"method":"engine.execute","params":{"command":"sketch.create","params":{"plane":"XY"}}}
+{"id":2,"method":"engine.execute","params":{"command":"sketch.rectangle.two_point","params":{"p0":[10,10],"p1":[40,30]}}}
+{"id":3,"method":"ui.view","params":{"view":"top"}}
+{"id":4,"method":"ui.view","params":{"view":"fit"}}
+```
+
+**Start C** means the exact request
+`{"id":5,"method":"ui.start","params":{"command":"C"}}`, replacing C with the
+literal command in the table. Panels open without selections. To exercise them,
+click their named selection fields and the rectangle's curves/corners in the canvas;
+`ui.selection` reports inputs and selected IDs, `ui.at` maps world coordinates
+to screen coordinates, and `ui.click {x,y}` sends the pick. Cancel between cases.
+
+| Panel | Source before port | How to open | Existing rows | Existing footer |
+| --- | --- | --- | --- | --- |
+| Create Sketch | `dialogs.rs` | Fresh design, Start `sketch.create` | Plane; attachment failure and explicit fixed-plane fallback | Cancel; picking a plane creates immediately |
+| Scale | `sketch_modify_ui.rs`, shared window in `dialogs.rs` | S; Start `sketch.scale` | Entities, Base point, Factor | OK, Cancel |
+| Offset | same | S; Start `sketch.offset` | Curves, Direction icons, Distance, Distance 2 (Two Sides), Flip (except Symmetric), Chain | OK, Cancel |
+| Mirror | same | S; Start `sketch.mirror` | Entities, Mirror line, selection step/guidance | OK, Cancel |
+| Move/Copy | same | S; Start `sketch.move` with no text selected | Entities, Center, X Distance, Y Distance, Angle, Create Copy | OK, Cancel |
+| Rectangular Pattern | same; edits from `sketch_pattern_tree.rs` | S; Start `sketch.pattern.rectangular` | Entities; Direction, Quantity, Spacing, Alignment icons; Direction 2, Quantity 2, Spacing 2, Alignment 2 icons; guidance | OK, Cancel |
+| Circular Pattern | same; edits from `sketch_pattern_tree.rs` | S; Start `sketch.pattern.circular` | Entities, Center, Quantity, Total angle, Alignment icons, guidance | OK, Cancel |
+| Fillet | same | S; Start `sketch.fillet` | Corners, Radius | OK, Cancel |
+| Equal-distance Chamfer | same | S; Start `sketch.chamfer.equal_distance` | Corner, Chamfer Type icons, Distance | OK, Cancel |
+| Two-distance Chamfer | same | S; Start `sketch.chamfer.two_distance` | Corner, Chamfer Type icons, Distance 1, Distance 2, Flip | OK, Cancel |
+| Distance-angle Chamfer | same | S; Start `sketch.chamfer.distance_angle` | Corner, Chamfer Type icons, Distance 1, Angle, Flip | OK, Cancel |
+| Text / Edit Text | `sketch_text.rs`, shared window | S; Start `sketch.text`, then `ui.at {"world":[50,20,0]}` and `ui.click` the returned position; editing uses Start `sketch.edit_text`, then pick a text outline | Text (multiline), Font (search/list/file), Style, Alignment, X, Y, Height, Angle, Letter Spacing, Line Spacing, Path, Reverse (on path) | OK, Cancel; live edits collapse into one undo step |
+| Move/Copy Text | `sketch_text_move.rs`, shared window | Create text as above; close its editor with OK; select a text outline; Start `sketch.move` | Distance X, Distance Y, Angle, Create Copy | OK, Cancel |
+| Edit Dimension (panel form) | `dialogs.rs` | `Dialog::edit_param`; legacy programmatic UI constructor, no current control-channel entry point. Interactive dimensions use the inline editor below | Parameter name, expression | OK, Cancel |
+| Redefine Sketch Plane | `sketch_attachment_ui.rs` | Create sketch; finish sketch; select its browser/context-menu Redefine Sketch Plane action (control recipe below) | Attachment status; author placement repair; XY/XZ/YZ or construction planes; selected-face reattach; saved/selected fixed plane; preview/error | Apply (commits and closes), Cancel |
+
+Not separate popup panels: `sketch_tools.rs` and `tools.rs` drawing/trim/extend/
+break/stretch/project/include state machines; drawing family choices already use
+the kit in `sketch_palette.rs`. Polygon Sides, slot Width, conic Rho, arc Sweep,
+and other dimension boxes in `sketch_dims.rs` are inline canvas value editors.
+`dim_view.rs` is also an inline editor anchored to the dimension/pointer, with
+focus-loss commit/cancel and no panel actions. These stay inline. The pattern tree
+opens the same modify dialog, not another window.
+
+Positioning follows feature dialogs: right when alone; left while a sufficiently
+wide sketch viewport shows the palette at right. Narrow viewports hide the palette
+while the dialog is open. Preserve `palette_rect` / `dialog_rect` and their tests.
+
+The port uses command-spec icons and labels, close X, a guidance hint, kit selection
+fields and picked-item lists, expression/unit fields, paired X/Y values, Options
+sections and the shared pinned footer. Numeric defaults and command builders are
+unchanged. The rectangular pattern's two directions now use stacked dense sections;
+its references and independent alignment controls remain available. Old field
+handles, including Distance X/Y, X/Y Distance and text controls, are retained.
+
+Final footer actions:
+
+- Create Sketch: disabled OK plus Cancel; choosing a plane still creates immediately.
+- New offset, mirror and rectangular/circular patterns: OK / Apply / Cancel. Apply
+ commits one operation, retains numeric options, clears picks and waits for another
+ selection. This also works when evaluation finishes asynchronously.
+- Editing a stored sketch pattern: OK / Cancel; edits keep the same pattern ID.
+- Other modify tools, text, text move/copy, Edit Dimension and plane reattachment:
+ OK / Cancel. Reattachment's former Apply already committed and closed; its new
+ equivalent is OK.
+
+Dropped affordances: the legacy collapse minus/plus and expand chevrons (−/+/»/«)
+are removed from sketch dialogs; the separate footer info glyph is replaced by the
+header hint. The reattachment panel uses the shared close X. Full guidance is also
+available by hovering a clipped hint.
+
+New kit elements: `focused_field` (retains single-value popup focus),
+`multiline_text_field` (three-line text row),
+`searchable_dropdown` / `SearchOption` (font search, family list, font-file choice,
+loading state), `value_pair_named` (X/Y with established field names),
+`text_emphasis` (B/I toggles), and `segmented_compact` (alignment choices remain
+visible when long labels would otherwise switch to a dropdown). All have gallery
+examples in both themes; multiline focus and search/custom selection have direct
+interaction tests. Existing `hint` now exposes its full text on hover. `Panel`
+uses the same bounded anchor for painting and dragging, preserving exact title-drag movement at the
+shell clearance (the existing Create Sketch regression catches this).
+
+No raw interactive widgets remain in the ported sketch panels. Raw canvas value
+editors in `sketch_dims.rs` and `dim_view.rs` remain because their focus and placement
+belong to drawing/dimension gestures. Existing non-sketch legacy dialogs still
+use `frame::docked_on` and `dock_frame`, so those shared helpers remain in use.
+The `dialogs.rs` raw-widget allowance shrinks from 14 to 13; no sketch-panel
+allowance was added. The other existing allowances are assembly 6, plastic 1,
+and sheet metal 4, for their documented non-dense paths. No artwork, font or icon
+asset was added; headers reuse registry metadata. Eight new message templates have
+translations in all 13 catalogs.
+
+No native app or screenshot is produced in this worktree, as instructed. Visual
+review in the owner's running app remains necessary; headless tests prove layout,
+interaction and parameter behavior, not final screenshot acceptance.
+
+## Additional exact control recipes
+
+The window-free tests use the same routes. These recipes are source-checked;
+execute them in the owner's already running app and inspect the result there.
+`ui.at` returns `[x,y]`; copy those two numbers into the following `ui.click`.
+Use `ui.key {"key":"Escape"}` to close between cases.
+
+Preselect a source after S, before starting scale, move, offset or a pattern:
+
+```json
+{"id":10,"method":"engine.execute","params":{"command":"select.set","params":{"items":[{"type":"sketch_curve","id":"l1"}]}}}
+{"id":11,"method":"ui.start","params":{"command":"sketch.offset"}}
+```
+
+Replace `sketch.offset` with the literal command from the inventory. For fillet or
+chamfer, preselect `{"type":"sketch_point","id":"p1"}` instead. `l1` and `p1`
+are the first rectangle's IDs in a fresh design; the rectangle command response
+also reports the exact `sides` and `corners` IDs for a non-empty design. For mirror,
+start `sketch.mirror` with only `l1` selected, then pick the left rectangle edge:
+
+```json
+{"id":12,"method":"ui.dialogInput","params":{"index":1}}
+{"id":13,"method":"ui.at","params":{"world":[10,20,0]}}
+```
+
+Send `{"id":14,"method":"ui.click","params":{"x":X,"y":Y}}` using response 13.
+For circular pattern, start `sketch.pattern.circular`, use input index 1, and map
+`[0,0,0]` instead to pick its centre. Rectangular directions are optional; pick a
+straight edge with `ui.dialogInput` index 1 or 2 to replace either default direction.
+
+To open Edit Text deterministically without placing it with the pointer:
+
+```json
+{"id":20,"method":"engine.execute","params":{"command":"sketch.text","params":{"text":"II","at":[50,20],"height":8}}}
+{"id":21,"method":"engine.execute","params":{"command":"select.set","params":{"items":[{"type":"sketch_curve","id":"FIRST_CURVE_FROM_RESPONSE_20"}]}}}
+{"id":22,"method":"ui.start","params":{"command":"sketch.edit_text"}}
+```
+
+Substitute the first string in response 20's `curves` array. To open Move/Copy Text,
+close the text editor with OK, select a current text outline (live editing can
+regenerate its curve IDs), and send:
+
+```json
+{"id":23,"method":"ui.start","params":{"command":"sketch.move"}}
+```
+
+Plane reattachment, for S's sketch ID 1 in a fresh design:
+
+```json
+{"id":30,"method":"engine.execute","params":{"command":"sketch.finish","params":{}}}
+{"id":31,"method":"ui.menu","params":{"x":700,"y":400,"target":{"type":"sketch","id":1}}}
+{"id":32,"method":"ui.menuPick","params":{"item":"ui.redefineSketch"}}
+```
+
+Use the `sketch` ID returned by `sketch.create` instead of 1 in an existing design.
+The panel offers XY/XZ/YZ, construction planes, selected-face attachment and the
+explicit fixed-plane repair actions. It runs `sketch.redefine` on OK.
+
+To reopen an existing pattern, run either pattern command with a source (for
+example `sketch.pattern.rectangular {"entities":["l1"],"count":3,"spacing":20}`),
+select one of the returned copy curves, then:
+
+```json
+{"id":40,"method":"ui.menu","params":{"x":700,"y":400,"target":{"type":"viewport"}}}
+{"id":41,"method":"ui.menuPick","params":{"item":"ui.editSketchPattern"}}
+```
+
+Double-clicking the pattern's browser row or canvas badge opens this same panel.
+`sketch_pattern_tree.rs` contains the browser route; no duplicate window exists.
+The panel-only `Dialog::edit_param` constructor has no current public control route;
+its card, expression parameters and OK are covered by `dialogs_sketch_tests.rs`.
+The interactive `sketch.dimension` and double-click dimension routes continue to
+open their inline canvas editor, deliberately outside this panel port.
+
+## Validation
+
+Every Cargo command uses
+`CARGO_TARGET_DIR=/Users/dane/GitHub/solidcraft-dialogs/target CARGO_INCREMENTAL=0`.
+Commands run sequentially, without `nice`, temporary targets, standalone test
+binaries, a native app launch, screenshots or process-management commands.
+
+| Check | Result | Evidence |
+| --- | --- | --- |
+| `cargo run -p solidcraft-cli -- commands` | Passed; registry used for inventory | `/private/tmp/solidcraft-sketch-commands.json` (subsequent CLI registry capture) |
+| `cargo test -p solidcraft-ui-egui --lib sketch_ --no-fail-fast` | 228 passed | `/private/tmp/solidcraft-sketch-tests.log` |
+| `cargo test -p solidcraft-ui-egui --lib dialogs --no-fail-fast` | 191 passed | `/private/tmp/solidcraft-dialog-tests.log` |
+| `cargo test -p solidcraft-ui-egui --lib browser --no-fail-fast` | 39 passed | `/private/tmp/solidcraft-browser-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib frame::tests --no-fail-fast` | 3 passed, including exact title-drag displacement | `/private/tmp/solidcraft-frame-tests-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib apply_off_thread_tests --no-fail-fast` | 4 passed | `/private/tmp/solidcraft-apply_off_thread_tests-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib sketch_attachment_ui_tests --no-fail-fast` | 8 passed | `/private/tmp/solidcraft-sketch_attachment_ui_tests-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib ui_kit --no-fail-fast` | 22 passed, including gallery, new field interactions and panel guard | `/private/tmp/solidcraft-ui_kit-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib font_literals_tests --no-fail-fast` | 2 passed | `/private/tmp/solidcraft-font_literals_tests-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib colour_tokens_tests --no-fail-fast` | 5 passed | `/private/tmp/solidcraft-colour_tokens_tests-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib i18n --no-fail-fast` | 33 passed | `/private/tmp/solidcraft-i18n-final-check.log` |
+| `cargo test -p solidcraft-ui-egui --lib shell --no-fail-fast` | 16 passed | `/private/tmp/solidcraft-shell-final-check.log` |
+| `cargo fmt` | Passed | No output; subsequent `git diff --check` passed |
+| `cargo clippy -p solidcraft-ui-egui --all-targets -- -D warnings` | Passed | `/private/tmp/solidcraft-clippy.log` |
+| `cargo check -p solidcraft-ui-egui --target wasm32-unknown-unknown` | Passed | `/private/tmp/solidcraft-wasm.log` |
+| `cargo xtask assets` | Passed; 387 files attributed | `/private/tmp/solidcraft-assets.log` |
+| `cargo xtask layers` | Passed; 16 crates, no violations | `/private/tmp/solidcraft-layers.log` |
+| `cargo test -p solidcraft-ui-egui --lib` (one full run) | 1252 passed, the 8 reported baseline failures, 1 already-ignored test; **no additional failures** | `/private/tmp/solidcraft-ui-lib-tests.log` |
+
+The full-library command returned 101 solely for the eight baseline failures
+identified in the task. No additional failing tests were found. No test was newly
+ignored or disabled. No `cargo xtask ci` result is claimed: this task ran the
+explicitly requested separate gates and one full UI-library test command.
+The native screenshot/recording acceptance remains for the owner, as instructed;
+passing these checks does not assert visual acceptance of every panel.
+
+Work remains on `ui/sketch-tool-panels`, based on `a4dc6afc` (the UI kit extraction).
+This branch has no configured tracking upstream. No commit, push, PR, rebase or
+merge was performed. Generated feature/license documents and design formats were
+not changed.
diff --git a/docs/ui-kit.md b/docs/ui-kit.md
new file mode 100644
index 0000000000..489a5012e0
--- /dev/null
+++ b/docs/ui-kit.md
@@ -0,0 +1,110 @@
+# SolidCraft UI kit
+
+`crates/ui-egui/src/ui_kit/` is the tokenised library used to assemble dense feature dialogs and the sketch palette. This extraction preserves their existing layout, painting, focus, accessibility labels and scenario identities. Sketch tool panels use the same composition and elements.
+
+## Module tree
+
+```text
+ui_kit/
+ mod.rs overview and the one caller import path
+ metrics.rs row/header dimensions, sanitising and label-column maths
+ text.rs weighted, clipped, pixel-snapped text
+ layout.rs form scope, aligned rows, captions, hints, sections, dividers, picked lists
+ panel.rs bounded windows, surfaces, feature/palette composition and compute status
+ fields.rs expressions, plain text, units, dropdowns, selections and paired values
+ choice.rs text/icon segments, checkboxes, wrapped modes and icon toggles
+ actions.rs buttons, equal secondary pairs, keyboard and OK/Apply/Cancel footers
+ status.rs supplied name/status/icon and constraint meter
+ gallery.rs test-only light/dark element examples and geometry/interaction checks
+ *_tests.rs moved concern tests, Panel regressions and shared test input helpers
+```
+
+## Rules
+
+- Use one caller import path: `crate::ui_kit::{...}`. Implementation modules are organised by concern; panels do not import their internals.
+- Colours, fonts, dimensions and spacing come from `theme::Tokens`. No local font sizes, families, colours or design metrics.
+- Rows use `control_height` (24 pt today). A shared label column starts at `form_label_width`, widens to at most 1.6 times that value and never exceeds half the row. Label measurements settle across frames.
+- Build cards with `Panel`. Right-hand feature cards keep `space_8` clearance from the viewport edge. It owns the bounded window, feature header/drag target, scrolling body padding, pinned actions, compute status and keyboard routing. Its palette composition retains the existing palette padding and whole-card scrolling on short viewports. Supply `FeatureOptions::apply_label` for a tool card that also needs Apply. Use `feature_frame` or `palette_frame` for the existing docked/floating surfaces.
+- Panels use kit elements instead of raw egui controls. Application logic supplies values, command metadata and enabled state; it receives responses/actions and runs the existing commands.
+- Arguments put `ui` first, then the label/key (when not inherited from `row`), then the value and options. Buttons/targets return `Response`; choices report clicks; expression editors report accepted Enter (`text_field` additionally returns changed). Containers return their closure result. Existing Enter semantics intentionally distinguish completion from submission.
+- Scenario names and accessibility labels are API: preserve them. New elements publish geometry without overwriting the native accessible label or checked state.
+- `footer(..., None)` retains the original OK/Cancel layout. `Some("Apply")` adds the third action and returns `Action::Apply`; the panel decides whether to keep the operation open.
+
+## Elements
+
+All calls below use `crate::ui_kit::`; snippets assume local values and normal enclosing form scope. `control_*` means `control_fill`, `control_border` and/or `control_radius` as used by that element.
+
+| Module / element | Purpose | Tokens | Example |
+| --- | --- | --- | --- |
+| `metrics::row_height` | Row height for controls | `control_height` | `row_height()` |
+| `metrics::header_height` | Feature heading height | `form_header_height` | `header_height()` |
+| `layout::scope` | Inherited form styling and label-column identity | `space_4/8, form_gap_y, control_height, font_label, accent, selected_bg, dialog_rule, control_fill/border/radius, text` | `scope(ui, \|ui\| { /* elements */ })` |
+| `layout::row` | Aligned label/control row, 24 pt today | `control_height, form_label_width, font_label, dialog_label, space_8` | `row(ui, "Radius", \|ui\| number_field(ui, &mut radius, "mm"))` |
+| `layout::caption` | Dim helper beneath a row control | `form_icon_size, font_small, text_dim, space_8; label-column tokens` | `caption(ui, "Line Type", "Construction")` |
+| `layout::section` | Persisted disclosure with a rule and uppercase title | `control_height, space_2, radius_sm, hover, dialog_rule, form_section_icon_size, form_gap_y, font_caption, font_section_tracking, text_dim` | `section(ui, "advanced", "Advanced", false, \|ui\| {})` |
+| `layout::hint` | Helper text below a card header | `control_height, font_small, text_dim` | `hint(ui, "pick", "Pick a point")` |
+| `layout::note` | Wrapping explanatory text in a card body, for rules or caveats too long for a hint | `font_small, text_dim, space_4` | `note(ui, "pattern", "Counts include the original.")` |
+| `layout::list_row` | Picked-item row with a remove action | `control_height, space_8, font_label, text; icon-button tokens` | `list_row(ui, "point-1", "Point 1").clicked()` |
+| `layout::divider` | Full-width rule without extra padding | `dialog_rule` | `divider(ui, "group")` |
+| `panel::header` | Feature title/icon/close band | `form_header_height, form_icon_size, form_close_size, form_inset, font_label, text, dialog_rule, space_8/10; icon_button_at tokens` | `header(ui, "fillet", "Fillet", || {})` |
+| `fields::field` | Expression editor; the value carries its unit text ("20 mm", "45 deg"), there is no unit suffix; returns accepted Enter | `control_height, control_fill, form_inset, font_label, text_dim, space_4; scope tokens` | `field(ui, &mut expression)` |
+| `fields::focused_field` | Single-value expression popup retaining keyboard focus | `field tokens` | `focused_field(ui, &mut expression)` |
+| `fields::hint_field` | Expression editor with empty-value hint | `same as field` | `hint_field(ui, &mut depth, "To the next face")` |
+| `fields::text_field` | Plain text editor without expression completion; returns (Enter, changed) | `same as field` | `text_field(ui, &mut name, "Name")` |
+| `fields::multiline_text_field` | Three-line plain-text row with stable focus ID; caller routes Enter | `control_height, control_fill, form_inset, font_label; row tokens` | `multiline_text_field(ui, "Text", id, &mut text)` |
+| `fields::searchable_dropdown`, `SearchOption` | Search/list dropdown with optional custom-value action and loading message | `control_height, space_24, font_label; scope control tokens` | `searchable_dropdown(ui, "font", current, &mut filter, &choices, custom, pending)` |
+| `fields::value_pair_named` | Paired X/Y captions retaining independent accessible/scenario names | `value_pair tokens` | `value_pair_named(ui, "Position", [x, y], ["X", "Y"], ["Distance X", "Distance Y"], "mm")` |
+| `choice::text_emphasis` | Compact bold/italic toggles with localized accessible names | `scope font/control tokens` | `text_emphasis(ui, &mut bold, &mut italic)` |
+| `fields::dropdown` | Native dropdown with kit arrow and scenario option handles | `text_dim; scope control/font tokens` | `dropdown(ui, "operation", &mut operation, &["Join", "Cut"])` |
+| `fields::selection_field` | Filled point/curve/edge selection target | `control_height, control_radius, selected_bg/ink, accent, form_inset, space_24/8, font_label, text_dim` | `selection_field(ui, "Point 1", active)` |
+| `fields::selection_field_state` | Selection target with explicit filled state | `same as selection_field` | `selection_field_state(ui, "Select", active, false)` |
+| `fields::value_pair` | Two labelled numeric fields in one row; returns accepted Enter | `row/field tokens, space_8, dialog_label` | `value_pair(ui, "Position", [&mut x, &mut y], ["X", "Y"], "mm")` |
+| `fields::fraction_field` | Locale-aware variable-radius position editor | `scope control/font tokens` | `fraction_field(ui, &mut position)` |
+| `choice::segmented` | Equal text choices, falling back to dropdown when labels cannot fit | `control_height, control_fill/border/radius, font_label, selected_bg/ink, hover, text, space_8` | `segmented(ui, &mut mode, &["One", "Two"])` |
+| `choice::segmented_compact` | Always-visible short choices; long translations clip and retain tooltips and per-choice handles | `segmented tokens, space_4` | `segmented_compact(ui, &mut alignment, &labels)` |
+| `choice::segmented_states` | Segmented choices with mixed per-choice state | `same as segmented` | `segmented_states(ui, &mut mode, &["One", "Two"], &states)` |
+| `choice::segmented_icons` | Equal icon choices with mixed state | `segmented tokens, space_4/12, icon/fill, accent; icon palette` | `segmented_icons(ui, &mut mode, &icons, &states)` |
+| `choice::checkbox_grid` | Compact checkbox options in bounded columns | `form_checkbox_height, control_fill/border, radius_sm, accent, on_accent, font_body, text, space_2/3/6/8/14` | `checkbox_grid(ui, &mut [("Flip", &mut flip)], 2)` |
+| `choice::options` | Expanded two-column Options disclosure | `section and checkbox_grid tokens` | `options(ui, "options", &mut [("Flip", &mut flip)])` |
+| `choice::checkbox_row` | Full-row target with label left and box right; returns clicked | `control_height, control_radius, hover, radius_sm, accent, control_fill/border, on_accent, font_label, text, space_2/3/6/14` | `checkbox_row(ui, "snap", "Snap", snap)` |
+| `choice::checkbox` | Inline native checkbox retaining existing accessibility and sizing | `scope control/font/accent tokens` | `checkbox(ui, "Flip", &mut flip)` |
+| `choice::tool_choices` | Wrapped command-variant icons, supplied with enabled state | `sketch_mode_size/radius/border/tint, sketch_accent, control_fill/border, icon/fill, space_4/6` | `tool_choices(ui, "Line", current, &choices)` |
+| `actions::icon_button_at` | Icon action inside an existing rectangle | `form_icon_inset, text, text_dim; icon palette` | `icon_button_at(ui, rect, "close", "Close")` |
+| `actions::keyboard` | Esc cancels; unowned Enter submits only when valid | `none` | `keyboard(ui.ctx(), valid)` |
+| `actions::footer` | Pinned OK / optional Apply / Cancel; returns Action | `form_footer_height, form_button_height, dialog_footer/rule, radius_lg, control_*, accent, on_accent, font_label, space_6/10/12/16` | `footer(ui, "OK", "Cancel", valid, Some("Apply"))` |
+| `actions::footer_with_status` | Footer with stable button IDs and compute text | `footer tokens, text_dim, space_4/8` | `footer_with_status(ui, "OK", "Cancel", valid, None, status)` |
+| `actions::button_pair` | Equal-width secondary actions with optional icons and selected state | `form_button_height, control_*, selected_bg, hover, font_label, text, icon/fill, accent, sketch_footer_icon_size, space_4/6/10` | `button_pair(ui, "card", states, buttons)` |
+| `actions::secondary_button` | Ordinary secondary action preserving native sizing | `scope font/control/spacing tokens` | `secondary_button(ui, "Add")` |
+| `actions::primary_button` | Accent action outside the footer | `accent, on_accent; scope tokens` | `primary_button(ui, "Create")` |
+| `actions::small_button` | Compact inline action preserving native sizing | `scope font/control tokens` | `small_button(ui, "×")` |
+| `actions::icon_button` | Allocated control-height icon action | `control_height; icon_button_at tokens` | `icon_button(ui, "Remove", "close")` |
+| `status::status_header` | Name, status dot/text and meter for a card | `font_label, text/dim, accent, dialog_rule, sketch_accent, form_icon_size, space_3/4/6/8/10` | `status_header(ui, "card", "Sketch 1", status)` |
+| `panel::Panel` | Docked/floating window and both card compositions | `form_card_width`, frame/header/body/footer tokens above | `Panel::new(title, id, anchor, viewport, side, frame).window()` |
+| `choice::toggle_icon` | Independent pattern direction/centering icon | `control_height`, `space_3/4/24`, `icon/fill`, `accent`, scope tokens | `toggle_icon(ui, "Alignment", "Center", &mut on, "pattern_center")` |
+| `choice::IconSegment`, `ToolChoice` | Supplied icon/command-choice metadata | Read by their drawing element | `IconSegment { key, icon, tip }` |
+| `actions::Action`, `PairButton` | Footer result and equal-action metadata | Read by their drawing element | `Action::Apply` |
+| `status::StatusHeader` | Supplied icon, status text, completeness and meter fraction | Read by `status_header` | `StatusHeader { icon, text, complete, fraction }` |
+
+## Adding an element
+
+1. Add its one implementation to the appropriate concern file. Document what it is, when to use it and the tokens it reads. Re-export it from `mod.rs`; keep panel callers on the single import path.
+2. Add a light/dark example to `gallery.rs`, with stable scenario geometry/handles. Cover row height, label alignment and effective paint bounds, plus interaction if the element introduces an action. The moved regression tests live beside each concern in `*_tests.rs`.
+3. Add an element-table row here. Reuse existing artwork; any new file asset needs an exact `ATTRIBUTION.md` row and the asset authoring workflow.
+4. Run the gallery and widget/font/colour guards. The font metric guard scans the entire kit; the colour guard scans subdirectories too. The panel guard discovers sources that use the kit, including new Panel callers. Allowances are only for documented legacy non-dense paths; a new dense element needs no guard allowance because its raw implementation lives inside the kit.
+
+## Remaining legacy raw controls
+
+The bounded allowances in `ui_kit_guard_tests.rs` cover:
+
+| Source | Maximum calls | Reason |
+| --- | ---: | --- |
+| `dialogs.rs` | 13 | Retired window controls, legacy selection chips, the legacy combo and its choices, guarded legacy checkboxes and parameter-table Add. Dense error actions and pattern toggles now use kit elements. |
+| `dialogs_assembly.rs` | 6 | Non-dense Drive Joint slider, Motion Study compute action and joint-browser actions. |
+| `dialogs_plastic.rs` | 1 | Non-dense Manage Rules active-rule checkbox. |
+| `dialogs_sheet.rs` | 4 | Non-dense Manage Rules checkbox/delete and flat-pattern exports. |
+
+Other retired non-sketch dialog sources keep their existing raw controls; they are outside this dense-panel port. Sketch modify, text, text move and attachment panels have no raw-control allowance. Dense adapters, the sketch palette and future sources using the kit are scanned recursively. Kit implementations themselves own the raw widgets and require no allowances. Guarded legacy text editors in `dialogs.rs` and `dialogs_plastic.rs` also remain for the old path.
+
+## Verification and legacy boundaries
+
+`ui_kit::gallery` renders every element in light and dark without a native window. Moved tests cover geometry, labels, field focus/completion, disclosures and actions. Panel tests cover both card layouts and short-height scrolling. `ui_kit_guard_tests` rejects raw controls in dense sources; the small allowance table names the remaining retired dialog paths. Standard font/colour guards, clippy, wasm, assets and layers still apply.
diff --git a/tests/tools/test_icon_review.py b/tests/tools/test_icon_review.py
index dcd50f8571..7481ca1c7a 100644
--- a/tests/tools/test_icon_review.py
+++ b/tests/tools/test_icon_review.py
@@ -66,6 +66,24 @@ def review_fixture():
class IconReviewTest(unittest.TestCase):
+ def test_runtime_manifest_discovers_variable_ids_and_reports_actual_placeholder(self):
+ with review_fixture() as (root, design, get, post):
+ manifest = design / 'requested_icons.txt'
+ before = get('/api/review')['rev']
+ manifest.write_text('box_alias\tfalse\nonly_in_menu_table\ttrue\n')
+ page = get('/')
+ self.assertIn('data-id="only_in_menu_table"', page)
+ self.assertIn('3 discovered icon ids · 2 with artwork · 1 missing', page)
+ self.assertIn('runtime audit', page)
+ self.assertNotEqual(get('/api/review')['rev'], before)
+ # Even existing artwork can fail to parse in the runtime renderer.
+ manifest.write_text('box_alias\ttrue\nonly_in_menu_table\tfalse\n')
+ self.assertIn('3 discovered icon ids · 1 with artwork · 2 missing', get('/'))
+ # A newly repaired id is discoverable even without any source literal.
+ manifest.write_text('box_alias\tfalse\nonly_in_menu_table\tfalse\n')
+ (design / 'svg/model/only_in_menu_table.svg').write_text(SVG)
+ self.assertIn('3 discovered icon ids · 3 with artwork · 0 missing', get('/'))
+
def test_inline_clips_and_masks_are_scoped_to_each_preview_and_dashes_use_guides(self):
with review_fixture() as (root, design, get, post):
for name in ('environment_map', 'new', 'draft', 'bounding_solid', 'extend'):
diff --git a/xtask/src/licences.rs b/xtask/src/licences.rs
index d69123893d..b43914071e 100644
--- a/xtask/src/licences.rs
+++ b/xtask/src/licences.rs
@@ -172,7 +172,13 @@ fn render(root: &Path, crates: &[Crate]) -> String {
Source: https://github.com/liberationfonts\n\n\
- BIZUDPGothic-Regular.ttf (assets/fonts/biz-udp-gothic/BIZUDPGothic-Regular.ttf)\n \
Copyright 2022 The BIZ UDGothic Project Authors (https://github.com/googlefonts/morisawa-biz-ud-mincho)\n \
- Source: https://github.com/googlefonts/morisawa-biz-ud-gothic\n\n"
+ Source: https://github.com/googlefonts/morisawa-biz-ud-gothic\n\n\
+ - IBMPlexSans-Variable.ttf (assets/fonts/ibm-plex-sans/IBMPlexSans-Variable.ttf)\n \
+ Copyright 2017 IBM Corp. with Reserved Font Name \"Plex\"\n \
+ Source: https://github.com/IBM/plex\n\n\
+ - IBMPlexMono-Regular.ttf (assets/fonts/ibm-plex-mono/IBMPlexMono-Regular.ttf)\n \
+ Copyright 2017 IBM Corp. with Reserved Font Name \"Plex\"\n \
+ Source: https://github.com/IBM/plex\n\n"
);
let ofl_path = root.join("assets/fonts/biz-udp-gothic/OFL.txt");
let fallback_path = root.join("assets/fonts/liberation-sans/OFL.txt");