SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
One set of X, Y and Z colours for the origin axes, view triad and Move gizmo (#976) (#4430)
HiroKenEzb1d4293cf038
diff --git a/assets/icons/ui/source/navigation.rs b/assets/icons/ui/source/navigation.rsindex 611c3f558a..2a4ac4c00d 100644--- a/assets/icons/ui/source/navigation.rs+++ b/assets/icons/ui/source/navigation.rs@@ -152,11 +152,11 @@ pub(crate) fn curved_arrow(painter: &egui::Painter, at: Pos2, clockwise: bool, hpub(crate) const AXIS_RADIUS: f32 = 15.0;pub(crate) fn axis_tip(painter: &egui::Painter, c: Pos2, name: &str, d: &Vec3, at: Pos2, depth: f64, hovered: bool, t: Tokens) {let col = if d.x != 0.0 {- t.triad[0]+ t.axis_x} else if d.y != 0.0 {- t.triad[1]+ t.axis_y} else {- t.triad[2]+ t.axis_z};let positive = !name.starts_with('-');let light = t.panel.r() > 128;diff --git a/assets/styles/ui/palettes.rs b/assets/styles/ui/palettes.rsindex 13875f323e..cf1fda870a 100644--- a/assets/styles/ui/palettes.rs+++ b/assets/styles/ui/palettes.rs@@ -155,9 +155,11 @@ impl Tokens {origin_plane_edge: Color32::from_rgba_unmultiplied_const(214, 140, 84, 200),origin_plane_hover: Color32::from_rgba_unmultiplied_const(120, 130, 230, 150),origin_point: Color32::from_rgb(214, 215, 218),- axis_x: Color32::from_rgb(255, 0, 0),- axis_y: Color32::from_rgb(0, 255, 0),- axis_z: Color32::from_rgb(2, 2, 248),+ // The one set of X, Y and Z colours (#976), equal to the engine's `view::colors::AXIS_*`+ // so a headless picture draws its origin axes as the window does.+ axis_x: Color32::from_rgb(220, 60, 60),+ axis_y: Color32::from_rgb(60, 170, 60),+ axis_z: Color32::from_rgb(60, 100, 230),construction_plane: Color32::from_rgba_unmultiplied_const(249, 184, 134, 70),construction_geom: icon_primary(crate::icon_svg::CONSTRUCTION_PRIMARY[0]),body: Color32::from_rgb(176, 186, 198),@@ -220,8 +222,6 @@ impl Tokens {sketch_lost: Color32::from_rgb(200, 60, 90),sketch_construction: Color32::from_rgb(230, 130, 40),sketch_centerline: Color32::from_rgb(200, 110, 60),- triad: [Color32::from_rgb(220, 60, 60), Color32::from_rgb(60, 170, 60), Color32::from_rgb(60, 100, 230)],- gizmo: [Color32::from_rgb(225, 70, 60), Color32::from_rgb(80, 190, 80), Color32::from_rgb(70, 130, 240)],bend_up: Color32::from_rgb(30, 140, 50),bend_down: Color32::from_rgb(200, 90, 20),interference: Color32::from_rgb(235, 45, 40),@@ -377,9 +377,8 @@ impl Tokens {let mut t = self;let positive = [0.20, 0.45, 0.90];let negative = [0.85, 0.40, 0.05];- t.triad[0] = Color32::from_rgb(200, 40, 40);- t.triad[1] = Color32::from_rgb(120, 210, 80);- t.gizmo[1] = Color32::from_rgb(140, 220, 90);+ t.axis_x = Color32::from_rgb(200, 40, 40);+ t.axis_y = Color32::from_rgb(120, 210, 80);t.preview_sketch = Color32::from_rgb(80, 185, 145);t.analysis.draft = [positive, [0.95, 0.90, 0.60], negative];t.analysis.access = [positive, negative];diff --git a/assets/styles/ui/themes/amber-phosphor.json b/assets/styles/ui/themes/amber-phosphor.jsonindex b514247b75..d31514e2a8 100644--- a/assets/styles/ui/themes/amber-phosphor.json+++ b/assets/styles/ui/themes/amber-phosphor.json@@ -65,11 +65,6 @@"form_success": "#d4902f","form_success_fill": "#3b280d","form_tab_ink": "#cf8d31",- "gizmo": [- "#f3a535",- "#ffad38",- "#9b6922"- ],"glyph_bg": "#201607","glyph_edge": "#e0d1ac","glyph_text": "#e0d1ac",@@ -189,11 +184,6 @@"timeline_item_error": "#46300f","timeline_marker": "#9b6922","toolbar": "#100b04",- "triad": [- "#f3a535",- "#ffad38",- "#9b6922"- ],"viewport_bottom": "#090603","viewport_top": "#090603","warning": "#ffd274"diff --git a/assets/styles/ui/themes/blueprint.json b/assets/styles/ui/themes/blueprint.jsonindex 5c2b939939..e2d49c2718 100644--- a/assets/styles/ui/themes/blueprint.json+++ b/assets/styles/ui/themes/blueprint.json@@ -65,11 +65,6 @@"form_success": "#6ee0bb","form_success_fill": "#153e47","form_tab_ink": "#b6a9e4",- "gizmo": [- "#ec9e99",- "#9ddab7",- "#91c8ff"- ],"glyph_bg": "#0a233e","glyph_edge": "#ff968d","glyph_text": "#ff968d",@@ -189,11 +184,6 @@"timeline_item_error": "#422d40","timeline_marker": "#94b2cb","toolbar": "#0c223c",- "triad": [- "#ec9e99",- "#9ddab7",- "#91c8ff"- ],"viewport_bottom": "#143b67","viewport_top": "#143b67","warning": "#f0d18c"diff --git a/assets/styles/ui/themes/catppuccin-mocha.json b/assets/styles/ui/themes/catppuccin-mocha.jsonindex 801f73e5e4..b8f217453c 100644--- a/assets/styles/ui/themes/catppuccin-mocha.json+++ b/assets/styles/ui/themes/catppuccin-mocha.json@@ -65,11 +65,6 @@"form_success": "#a6e3a1","form_success_fill": "#353f42","form_tab_ink": "#b4befe",- "gizmo": [- "#f38ba8",- "#a6e3a1",- "#477dc8"- ],"glyph_bg": "#313244","glyph_edge": "#fc93b0","glyph_text": "#fc93b0",@@ -189,11 +184,6 @@"timeline_item_error": "#51384b","timeline_marker": "#a6adc8","toolbar": "#1e1e2e",- "triad": [- "#f38ba8",- "#a6e3a1",- "#477dc8"- ],"viewport_bottom": "#11111b","viewport_top": "#11111b","warning": "#f9e2af"diff --git a/assets/styles/ui/themes/cupertino.json b/assets/styles/ui/themes/cupertino.jsonindex 322e200970..cadc2199e9 100644--- a/assets/styles/ui/themes/cupertino.json+++ b/assets/styles/ui/themes/cupertino.json@@ -18,9 +18,9 @@"app_bar_separator": "#b4b4b8","app_bar_tab_active": "#f4f4f4","app_bar_text": "#242426",- "axis_x": "#ff0000",- "axis_y": "#00ff00",- "axis_z": "#0202f8",+ "axis_x": "#e95049",+ "axis_y": "#35a754",+ "axis_z": "#297fdb","bend_down": "#bd843f","bend_up": "#36934d","body": "#b6bbc3",@@ -65,11 +65,6 @@"form_success": "#237b38","form_success_fill": "#e6f3e8","form_tab_ink": "#75559f",- "gizmo": [- "#ed514b",- "#36ad59",- "#2184e9"- ],"glyph_bg": "#ffffff","glyph_edge": "#d73339","glyph_text": "#d73339",@@ -189,11 +184,6 @@"timeline_item_error": "#f8dedb","timeline_marker": "#63636b","toolbar": "#ececec",- "triad": [- "#e95049",- "#35a754",- "#297fdb"- ],"viewport_bottom": "#d9dce2","viewport_top": "#f5f5f7","warning": "#ad7400"diff --git a/assets/styles/ui/themes/graphite.json b/assets/styles/ui/themes/graphite.jsonindex 82bfe6d7da..3f96ec69f9 100644--- a/assets/styles/ui/themes/graphite.json+++ b/assets/styles/ui/themes/graphite.json@@ -65,11 +65,6 @@"form_success": "#83c69b","form_success_fill": "#35423e","form_tab_ink": "#a796cb",- "gizmo": [- "#ed7777",- "#83c69b",- "#2878a9"- ],"glyph_bg": "#303338","glyph_edge": "#e57071","glyph_text": "#e57071",@@ -189,11 +184,6 @@"timeline_item_error": "#553a3d","timeline_marker": "#a0a6b0","toolbar": "#25272b",- "triad": [- "#ed7777",- "#83c69b",- "#2878a9"- ],"viewport_bottom": "#17191d","viewport_top": "#17191d","warning": "#dbb879"diff --git a/assets/styles/ui/themes/green-phosphor.json b/assets/styles/ui/themes/green-phosphor.jsonindex 9ac21ea057..fe4d23605f 100644--- a/assets/styles/ui/themes/green-phosphor.json+++ b/assets/styles/ui/themes/green-phosphor.json@@ -65,11 +65,6 @@"form_success": "#39d45c","form_success_fill": "#133b20","form_tab_ink": "#36b95c",- "gizmo": [- "#c1f3ba",- "#4dff79",- "#599b70"- ],"glyph_bg": "#09200e","glyph_edge": "#afd5b6","glyph_text": "#afd5b6",@@ -189,11 +184,6 @@"timeline_item_error": "#21462a","timeline_marker": "#5b9b6a","toolbar": "#061009",- "triad": [- "#c1f3ba",- "#4dff79",- "#599b70"- ],"viewport_bottom": "#010703","viewport_top": "#010703","warning": "#d1ffad"diff --git a/assets/styles/ui/themes/gruvbox-dark-hard.json b/assets/styles/ui/themes/gruvbox-dark-hard.jsonindex e76952a95c..9a55880c5c 100644--- a/assets/styles/ui/themes/gruvbox-dark-hard.json+++ b/assets/styles/ui/themes/gruvbox-dark-hard.json@@ -84,16 +84,6 @@"bend_up": "#b8bb26","bend_down": "#fe8019","interference": "#fb4934",- "triad": [- "#fb4934",- "#b8bb26",- "#83a598"- ],- "gizmo": [- "#fb4934",- "#b8bb26",- "#83a598"- ],"icons.agent": "#d3869b","surface_fill": "#fe9755","surface_soft": "#382c20",diff --git a/assets/styles/ui/themes/gruvbox-dark-soft.json b/assets/styles/ui/themes/gruvbox-dark-soft.jsonindex cd4229ed08..46886b6b10 100644--- a/assets/styles/ui/themes/gruvbox-dark-soft.json+++ b/assets/styles/ui/themes/gruvbox-dark-soft.json@@ -85,16 +85,6 @@"bend_up": "#b8bb26","bend_down": "#fe8019","interference": "#fb4934",- "triad": [- "#fb4934",- "#b8bb26",- "#83a598"- ],- "gizmo": [- "#fb4934",- "#b8bb26",- "#83a598"- ],"icons.agent": "#d3869b","surface_fill": "#fe9755","surface_soft": "#4a3a2c",diff --git a/assets/styles/ui/themes/gruvbox-dark.json b/assets/styles/ui/themes/gruvbox-dark.jsonindex 8e356c0482..c1df0ef53f 100644--- a/assets/styles/ui/themes/gruvbox-dark.json+++ b/assets/styles/ui/themes/gruvbox-dark.json@@ -85,16 +85,6 @@"bend_up": "#b8bb26","bend_down": "#fe8019","interference": "#fb4934",- "triad": [- "#fb4934",- "#b8bb26",- "#83a598"- ],- "gizmo": [- "#fb4934",- "#b8bb26",- "#83a598"- ],"icons.agent": "#d3869b","surface_fill": "#fe9755","surface_soft": "#423326",diff --git a/assets/styles/ui/themes/gruvbox-light-hard.json b/assets/styles/ui/themes/gruvbox-light-hard.jsonindex 0baa3612d1..d1ca6d8312 100644--- a/assets/styles/ui/themes/gruvbox-light-hard.json+++ b/assets/styles/ui/themes/gruvbox-light-hard.json@@ -84,16 +84,6 @@"bend_up": "#79740e","bend_down": "#af3a03","interference": "#cc241d",- "triad": [- "#cc241d",- "#98971a",- "#458588"- ],- "gizmo": [- "#cc241d",- "#98971a",- "#458588"- ],"icons.agent": "#8f3f71","surface_fill": "#df663c","surface_soft": "#f3e6c6",diff --git a/assets/styles/ui/themes/gruvbox-light-soft.json b/assets/styles/ui/themes/gruvbox-light-soft.jsonindex bec7dc40f3..5e2b883e8e 100644--- a/assets/styles/ui/themes/gruvbox-light-soft.json+++ b/assets/styles/ui/themes/gruvbox-light-soft.json@@ -84,16 +84,6 @@"bend_up": "#79740e","bend_down": "#af3a03","interference": "#cc241d",- "triad": [- "#cc241d",- "#98971a",- "#458588"- ],- "gizmo": [- "#cc241d",- "#98971a",- "#458588"- ],"icons.agent": "#8f3f71","surface_fill": "#df663c","surface_soft": "#edd7ad",diff --git a/assets/styles/ui/themes/gruvbox-light.json b/assets/styles/ui/themes/gruvbox-light.jsonindex 848c754ac1..f2c28197c9 100644--- a/assets/styles/ui/themes/gruvbox-light.json+++ b/assets/styles/ui/themes/gruvbox-light.json@@ -84,16 +84,6 @@"bend_up": "#79740e","bend_down": "#af3a03","interference": "#cc241d",- "triad": [- "#cc241d",- "#98971a",- "#458588"- ],- "gizmo": [- "#cc241d",- "#98971a",- "#458588"- ],"icons.agent": "#8f3f71","surface_fill": "#df663c","surface_soft": "#f5e2b7",diff --git a/assets/styles/ui/themes/high-contrast.json b/assets/styles/ui/themes/high-contrast.jsonindex 961e53303a..ec2c1523bf 100644--- a/assets/styles/ui/themes/high-contrast.json+++ b/assets/styles/ui/themes/high-contrast.json@@ -65,11 +65,6 @@"form_success": "#40e080","form_success_fill": "#0b2616","form_tab_ink": "#df8fff",- "gizmo": [- "#ff6666",- "#40e080",- "#0070d0"- ],"glyph_bg": "#151515","glyph_edge": "#fa8a86","glyph_text": "#fa8a86",@@ -189,11 +184,6 @@"timeline_item_error": "#3d1818","timeline_marker": "#cccccc","toolbar": "#000000",- "triad": [- "#ff6666",- "#40e080",- "#0070d0"- ],"viewport_bottom": "#000000","viewport_top": "#000000","warning": "#ffcc00"diff --git a/assets/styles/ui/themes/nord.json b/assets/styles/ui/themes/nord.jsonindex fdf3bb5704..744abda812 100644--- a/assets/styles/ui/themes/nord.json+++ b/assets/styles/ui/themes/nord.json@@ -65,11 +65,6 @@"form_success": "#a3be8c","form_success_fill": "#424b4d","form_tab_ink": "#c3a5bd",- "gizmo": [- "#bf616a",- "#a3be8c",- "#5e81ac"- ],"glyph_bg": "#3b4252","glyph_edge": "#f9959c","glyph_text": "#f9959c",@@ -189,11 +184,6 @@"timeline_item_error": "#513f4a","timeline_marker": "#a4b0c2","toolbar": "#2e3440",- "triad": [- "#bf616a",- "#a3be8c",- "#5e81ac"- ],"viewport_bottom": "#242f40","viewport_top": "#242f40","warning": "#ebcb8b"diff --git a/assets/styles/ui/themes/nosferatu.json b/assets/styles/ui/themes/nosferatu.jsonindex 7904adcc3f..394d8e2401 100644--- a/assets/styles/ui/themes/nosferatu.json+++ b/assets/styles/ui/themes/nosferatu.json@@ -65,11 +65,6 @@"form_success": "#50fa7b","form_success_fill": "#2f4d42","form_tab_ink": "#d6acff",- "gizmo": [- "#ff5555",- "#50fa7b",- "#8456b8"- ],"glyph_bg": "#343746","glyph_edge": "#fc827b","glyph_text": "#fc827b",@@ -189,11 +184,6 @@"timeline_item_error": "#5c343d","timeline_marker": "#a1a4c4","toolbar": "#282a36",- "triad": [- "#ff5555",- "#50fa7b",- "#8456b8"- ],"viewport_bottom": "#1d1e29","viewport_top": "#1d1e29","warning": "#f1fa8c"diff --git a/assets/styles/ui/themes/one-dark.json b/assets/styles/ui/themes/one-dark.jsonindex 1dd88440cf..18f2673698 100644--- a/assets/styles/ui/themes/one-dark.json+++ b/assets/styles/ui/themes/one-dark.json@@ -65,11 +65,6 @@"form_success": "#8fdb9a","form_success_fill": "#2c4a33","form_tab_ink": "#c97fdf",- "gizmo": [- "#e06c75",- "#98c379",- "#61afef"- ],"glyph_bg": "#282c34","glyph_edge": "#f57f87","glyph_text": "#f57f87",@@ -189,11 +184,6 @@"timeline_item_error": "#5c343d","timeline_marker": "#abb2bf","toolbar": "#21252b",- "triad": [- "#e06c75",- "#98c379",- "#61afef"- ],"viewport_bottom": "#282c34","viewport_top": "#282c34","warning": "#e5c07b"diff --git a/assets/styles/ui/themes/platinum-9.json b/assets/styles/ui/themes/platinum-9.jsonindex 39999dac88..d98fa09aef 100644--- a/assets/styles/ui/themes/platinum-9.json+++ b/assets/styles/ui/themes/platinum-9.json@@ -18,9 +18,9 @@"app_bar_separator": "#aaaaaa","app_bar_tab_active": "#e6e6e6","app_bar_text": "#222222",- "axis_x": "#ff0000",- "axis_y": "#00ff00",- "axis_z": "#0202f8",+ "axis_x": "#dc3c3c",+ "axis_y": "#3caa3c",+ "axis_z": "#3c64e6","bend_down": "#c85a14","bend_up": "#1e8c32","body": "#adadb6",@@ -65,11 +65,6 @@"form_success": "#336633","form_success_fill": "#e2ecdf","form_tab_ink": "#6d4e7d",- "gizmo": [- "#e1463c",- "#50be50",- "#4682f0"- ],"glyph_bg": "#ffffff","glyph_edge": "#ab2125","glyph_text": "#ab2125",@@ -189,11 +184,6 @@"timeline_item_error": "#f2dddd","timeline_marker": "#666666","toolbar": "#dddddd",- "triad": [- "#dc3c3c",- "#3caa3c",- "#3c64e6"- ],"viewport_bottom": "#ffffff","viewport_top": "#ffffff","warning": "#997722"diff --git a/assets/styles/ui/themes/solarized-light.json b/assets/styles/ui/themes/solarized-light.jsonindex 00813ef7cf..18534f817a 100644--- a/assets/styles/ui/themes/solarized-light.json+++ b/assets/styles/ui/themes/solarized-light.json@@ -65,11 +65,6 @@"form_success": "#859900","form_success_fill": "#dcdbb1","form_tab_ink": "#565a9d",- "gizmo": [- "#dc322f",- "#859900",- "#346e88"- ],"glyph_bg": "#e3ddc9","glyph_edge": "#da2f2d","glyph_text": "#da2f2d",@@ -189,11 +184,6 @@"timeline_item_error": "#eabcad","timeline_marker": "#657b83","toolbar": "#eee8d5",- "triad": [- "#dc322f",- "#859900",- "#346e88"- ],"viewport_bottom": "#fdf6e3","viewport_top": "#fdf6e3","warning": "#b58900"diff --git a/assets/styles/ui/themes/solidcraft-95.json b/assets/styles/ui/themes/solidcraft-95.jsonindex 2d37e5c256..8e58b07f02 100644--- a/assets/styles/ui/themes/solidcraft-95.json+++ b/assets/styles/ui/themes/solidcraft-95.json@@ -65,11 +65,6 @@"form_success": "#008000","form_success_fill": "#c0dcc0","form_tab_ink": "#7d007d",- "gizmo": [- "#ff0000",- "#00ff00",- "#0000ff"- ],"glyph_bg": "#ffffff","glyph_edge": "#800000","glyph_text": "#800000",@@ -189,11 +184,6 @@"timeline_item_error": "#ffffc0","timeline_marker": "#000000","toolbar": "#c0c0c0",- "triad": [- "#ff0000",- "#00ff00",- "#0000ff"- ],"viewport_bottom": "#008080","viewport_top": "#008080","warning": "#ffff00"diff --git a/assets/styles/ui/themes/tokyo-night.json b/assets/styles/ui/themes/tokyo-night.jsonindex 9f3bb52e8c..2608ea9d21 100644--- a/assets/styles/ui/themes/tokyo-night.json+++ b/assets/styles/ui/themes/tokyo-night.json@@ -65,11 +65,6 @@"form_success": "#9ece6a","form_success_fill": "#303932","form_tab_ink": "#bb9af7",- "gizmo": [- "#f7768e",- "#9ece6a",- "#4775ce"- ],"glyph_bg": "#24283b","glyph_edge": "#f6758d","glyph_text": "#f6758d",@@ -189,11 +184,6 @@"timeline_item_error": "#4f313f","timeline_marker": "#9aa5ce","toolbar": "#1a1b26",- "triad": [- "#f7768e",- "#9ece6a",- "#4775ce"- ],"viewport_bottom": "#151722","viewport_top": "#151722","warning": "#e0af68"diff --git a/crates/engine/src/view.rs b/crates/engine/src/view.rsindex 59fa0408d6..e4baa83c5c 100644--- a/crates/engine/src/view.rs+++ b/crates/engine/src/view.rs@@ -30,6 +30,8 @@ pub mod colors {pub const PROFILE: Rgb = Rgb(255, 196, 120);pub const GRID: Rgb = Rgb(196, 202, 212);pub const GRID_MAJOR: Rgb = Rgb(170, 178, 190);+ /// The origin axes: the light theme's X, Y and Z, the one set every axis in the UI is drawn+ /// with (#976).pub const AXIS_X: Rgb = Rgb(220, 60, 60);pub const AXIS_Y: Rgb = Rgb(60, 170, 60);pub const AXIS_Z: Rgb = Rgb(60, 100, 230);diff --git a/crates/ui-egui/src/colour_tokens_tests.rs b/crates/ui-egui/src/colour_tokens_tests.rsindex d6b3bc849d..c3747f84e5 100644--- a/crates/ui-egui/src/colour_tokens_tests.rs+++ b/crates/ui-egui/src/colour_tokens_tests.rs@@ -21,8 +21,7 @@ fn moved_colours_keep_the_values_they_were_drawn_with() {assert_eq!(t.sketch_lost, rgb(colors::SKETCH_LOST));assert_eq!(t.sketch_construction, rgb(colors::SKETCH_CONSTRUCTION));assert_eq!(t.sketch_centerline, rgb(colors::SKETCH_CENTERLINE));- assert_eq!(t.triad, [rgb(colors::AXIS_X), rgb(colors::AXIS_Y), rgb(colors::AXIS_Z)]);- assert_eq!(t.gizmo, [Color32::from_rgb(225, 70, 60), Color32::from_rgb(80, 190, 80), Color32::from_rgb(70, 130, 240)]);+ assert_eq!(t.axes(), [rgb(colors::AXIS_X), rgb(colors::AXIS_Y), rgb(colors::AXIS_Z)]);assert_eq!(t.interference, Color32::from_rgb(235, 45, 40));// The shader's former literals, bit for bit.assert_eq!(t.analysis.draft, [[0.20, 0.75, 0.30], [0.95, 0.80, 0.15], [0.85, 0.22, 0.20]]);@@ -38,6 +37,83 @@ fn moved_colours_keep_the_values_they_were_drawn_with() {assert_eq!((d.bend_up, d.bend_down), (Color32::from_rgb(110, 200, 120), Color32::from_rgb(240, 150, 80)));}+/// The solid colours of the lines and outlines in a frame (not fills, not missing strokes).+fn stroke_colours(shapes: &[egui::epaint::ClippedShape]) -> std::collections::BTreeSet<[u8; 4]> {+ fn walk(s: &egui::Shape, out: &mut std::collections::BTreeSet<[u8; 4]>) {+ let stroke = match s {+ egui::Shape::LineSegment { stroke, .. } => Some(stroke.color),+ egui::Shape::Path(p) => match p.stroke.color {+ egui::epaint::ColorMode::Solid(c) if p.stroke.width > 0.0 => Some(c),+ _ => None,+ },+ egui::Shape::Vec(v) => {+ v.iter().for_each(|s| walk(s, out));+ None+ }+ _ => None,+ };+ if let Some(c) = stroke.filter(|c| *c != Color32::TRANSPARENT) {+ out.insert(c.to_array());+ }+ }+ let mut out = std::collections::BTreeSet::new();+ shapes.iter().for_each(|s| walk(&s.shape, &mut out));+ out+}++/// Every axis is drawn in one set of X, Y and Z colours, the `axis_*` tokens (#976), in both+/// themes and every colour vision mode: the Move gizmo's arrows, squares and rings, the view+/// triad's ends, and the headless picture's origin axes, as the origin axes, the navigation+/// cube's triad, 3D sketch triads and joint origins draw them.+#[test]+fn every_axis_is_drawn_in_one_set_of_colours() {+ use crate::theme::{ColorVision, set_dark, set_vision};+ use egui::{Pos2, Rect, vec2};+ use solidcraft_engine::geom::Vec3;+ let ctx = crate::fonts::test_context();+ let rect = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0));+ let cam = solidcraft_engine::render::Camera::default();+ let proj = crate::viewport::Proj { cam, vp: cam.view_proj(4.0 / 3.0, 100.0), rect };+ let triad = crate::gizmo::Triad { center: Vec3::ZERO, translate: true, rotate: true };+ for (dark, mode) in [false, true].into_iter().flat_map(|d| ColorVision::ALL.map(|m| (d, m))) {+ set_dark(dark);+ set_vision(mode);+ let t = Tokens::themed(dark, mode);+ let axes: std::collections::BTreeSet<[u8; 4]> = t.axes().iter().map(|c| c.to_array()).collect();+ assert_eq!(axes.len(), 3, "dark {dark}, {mode:?}: three different axis colours");++ let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(rect), ..Default::default() }, |ui| {+ let painter = ui.painter().clone();+ crate::gizmo::show(ui, &painter, &proj, egui::Id::new("one_set_gizmo"), &triad, 1.0);+ });+ out.textures_delta.clear();+ let mut gizmo = stroke_colours(&out.shapes);+ gizmo.remove(&Color32::from_gray(60).to_array()); // the centre ball's neutral rim+ assert_eq!(gizmo, axes, "dark {dark}, {mode:?}: the Move gizmo");++ let c = Pos2::new(100.0, 100.0);+ for (name, d, want) in [("x", Vec3::X, t.axis_x), ("y", Vec3::Y, t.axis_y), ("z", Vec3::Z, t.axis_z)] {+ let at = c + vec2(32.0, 0.0);+ let mut out =+ ctx.run_ui(egui::RawInput::default(), |ui| crate::icons::navigation::axis_tip(ui.painter(), c, name, &d, at, 0.5, false, t));+ out.textures_delta.clear();+ let end = out.shapes.iter().find_map(|s| match &s.shape {+ egui::Shape::Circle(e) if e.center == at => Some(e.fill),+ _ => None,+ });+ assert_eq!(end, Some(want), "dark {dark}, {mode:?}: the view triad's {name} end");+ }++ assert_eq!(+ crate::viewport::scene_palette(dark, mode).axes.map(|c| [c.0, c.1, c.2, 255]),+ t.axes().map(|c| c.to_array()),+ "dark {dark}, {mode:?}: the picture"+ );+ }+ set_dark(true);+ set_vision(ColorVision::Off);+}+/// The analysis colours reach the shader in the order its `ana_c` array reads them.#[test]fn analysis_colours_reach_the_shader_in_its_order() {diff --git a/crates/ui-egui/src/colour_vision_tests.rs b/crates/ui-egui/src/colour_vision_tests.rsindex 794d522870..7f19052e39 100644--- a/crates/ui-egui/src/colour_vision_tests.rs+++ b/crates/ui-egui/src/colour_vision_tests.rs@@ -290,9 +290,8 @@ fn groups(t: &Tokens) -> Vec<Group> {group("validation status", &[("form_success", t.form_success), ("error", t.error)], &[("panel", t.panel)]),group("validation surfaces", &[("form_success_fill", t.form_success_fill), ("form_error_fill", t.form_error_fill)], &[]),group("UI text", &[("error", t.error), ("warning", t.warning), ("text", t.text)], &[("panel", t.panel)]),- group("origin axes", &[("axis_x", t.axis_x), ("axis_y", t.axis_y), ("axis_z", t.axis_z)], &[("viewport_top", t.viewport_top)]),- group("view triad", &[("triad[0]", t.triad[0]), ("triad[1]", t.triad[1]), ("triad[2]", t.triad[2])], &[("viewport_top", t.viewport_top)]),- group("gizmo", &[("gizmo[0]", t.gizmo[0]), ("gizmo[1]", t.gizmo[1]), ("gizmo[2]", t.gizmo[2])], &[("viewport_top", t.viewport_top)]),+ // Every axis drawn: origin, view triad, navigation cube, Move gizmo… (one set, #976).+ group("axes", &[("axis_x", t.axis_x), ("axis_y", t.axis_y), ("axis_z", t.axis_z)], &[("viewport_top", t.viewport_top)]),group("bend lines", &[("bend_up", t.bend_up), ("bend_down", t.bend_down)], &[("viewport_top", t.viewport_top)]),group("box select", &[("box_window", t.box_window), ("box_crossing", t.box_crossing)], &[("viewport_top", t.viewport_top)]),group(@@ -564,7 +563,7 @@ fn token_fields(t: &Tokens) -> BTreeSet<String> {out}-/// A group member's token field (`triad[0]` is part of `triad`).+/// A group member's token field (`continuity[0]` is part of `continuity`).fn field_of(name: &str) -> &str {name.split('[').next().unwrap_or(name)}@@ -699,7 +698,7 @@ fn off_gives_the_theme_unchanged() {}}-/// The token fields whose `Debug` text differs (`triad`, `analysis.draft`…), so a field cannot+/// The token fields whose `Debug` text differs (`continuity`, `analysis.draft`…), so a field cannot/// change in a mode by accident.fn changed_fields(a: &Tokens, b: &Tokens) -> BTreeSet<String> {let (la, lb) = (format!("{a:#?}"), format!("{b:#?}"));@@ -733,8 +732,8 @@ fn changed_fields(a: &Tokens, b: &Tokens) -> BTreeSet<String> {fn each_mode_changes_only_its_table() {let set = |s: &[&str]| s.iter().map(|x| x.to_string()).collect::<BTreeSet<_>>();let red_green_both = [- "triad",- "gizmo",+ "axis_x",+ "axis_y","analysis.draft","analysis.access","analysis.hatch",diff --git a/crates/ui-egui/src/gizmo.rs b/crates/ui-egui/src/gizmo.rsindex a1e125f11d..b02e442868 100644--- a/crates/ui-egui/src/gizmo.rs+++ b/crates/ui-egui/src/gizmo.rs@@ -259,7 +259,7 @@ pub fn show(ui: &mut egui::Ui, painter: &egui::Painter, proj: &Proj, id: egui::Ilet hovered = if state.is_none() { pointer.filter(|_| ui.rect_contains_pointer(proj.rect)).and_then(|p| hit(&sh, p)) } else { None };let active = state.map(|s| s.handle).or(hovered);let hot = |h: Handle| active == Some(h);- let col = |h: Handle, i: usize| if hot(h) { tk.accent } else { tk.gizmo[i.min(2)] };+ let col = |h: Handle, i: usize| if hot(h) { tk.accent } else { tk.axes()[i.min(2)] };for (i, pts) in &sh.rings {painter.add(Shape::line(pts.clone(), Stroke::new(if hot(Handle::Ring(*i)) { 3.0 } else { 1.8 }, col(Handle::Ring(*i), *i))));}diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex 27b5231f18..975428bd29 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -637,6 +637,9 @@ pub struct Tokens {pub origin_plane_edge: Color32,pub origin_plane_hover: Color32,pub origin_point: Color32,+ /// The X, Y and Z colours, one set for every axis drawn (#976): the origin axes, the view+ /// triad, the navigation cube's triad, the Move gizmo, a 3D sketch point's triad, joint+ /// origins, measured distances along the axes and the headless picture's origin axes.pub axis_x: Color32,pub axis_y: Color32,pub axis_z: Color32,@@ -735,10 +738,6 @@ pub struct Tokens {pub sketch_lost: Color32,pub sketch_construction: Color32,pub sketch_centerline: Color32,- /// The view triad's X, Y and Z (and the CPU scene's origin axes).- pub triad: [Color32; 3],- /// The move gizmo's X, Y and Z.- pub gizmo: [Color32; 3],/// Sheet metal flat pattern: bend up, bend down.pub bend_up: Color32,pub bend_down: Color32,@@ -768,6 +767,11 @@ impl Tokens {egui::Shadow { offset: [0, self.space_2 as i8], blur: self.space_8 as u8, spread: 0, color: self.app_bar.gamma_multiply(0.18) }}+ /// The X, Y and Z axis colours, in that order.+ pub const fn axes(&self) -> [Color32; 3] {+ [self.axis_x, self.axis_y, self.axis_z]+ }+/// The tokens of the current theme and colour vision mode.pub fn get() -> Tokens {Tokens::themed(is_dark(), vision())diff --git a/crates/ui-egui/src/theme_files.rs b/crates/ui-egui/src/theme_files.rsindex c766e152e4..00f546eb73 100644--- a/crates/ui-egui/src/theme_files.rs+++ b/crates/ui-egui/src/theme_files.rs@@ -6,7 +6,7 @@//!//! ```json//! {"format": "solidcraft-theme/1", "name": "Mine", "base": "dark",-//! "colors": {"panel": "#282828", "triad": ["#fb4934", "#b8bb26", "#83a598"]}}+//! "colors": {"panel": "#282828", "axis_x": "#fb4934", "axis_y": "#b8bb26", "axis_z": "#83a598"}}//! ```use std::collections::BTreeMap;@@ -315,10 +315,16 @@ theme_keys! {app_bar_hover_button, app_bar_hover_strong, app_bar_tab_active,form_ink, form_dim, form_primary, form_error, form_error_fill, form_success, form_success_fill, dialog_body, dialog_footer, dialog_rule, control_fill, control_border, dialog_label, selected_ink, selected_bg,],- many: [triad, gizmo, continuity, logo],+ many: [continuity, logo],icons: [highlight, agent, marker_halo],}+/// Keys of theme files from before every axis took one set of colours (#976): the view triad's+/// and the Move gizmo's X, Y and Z. Each still reads, as a list of three, and sets `axis_x`,+/// `axis_y` and `axis_z`, `triad` over `gizmo` and a file's own `axis_*` keys over both. An+/// export never writes them.+const LEGACY_AXES: [&str; 2] = ["gizmo", "triad"];+/// `#rrggbb` or `#rrggbbaa` (alpha not premultiplied).fn parse_color(s: &str) -> Option<Color32> {let hex = s.trim().strip_prefix('#')?;@@ -395,6 +401,12 @@ pub fn from_value(v: &Value) -> Result<ThemeFile, String> {let mut probe = Tokens::light();let mut bad = Vec::new();for (k, c) in &src {+ if LEGACY_AXES.contains(&k.as_str()) {+ if let Err(e) = colors_of(c, 3) {+ bad.push(format!("`{k}` {e}"));+ }+ continue;+ }match slot(&mut probe, k) {None => bad.push(format!("`{k}` is not a theme colour")),Some(s) => {@@ -461,6 +473,13 @@ fn slug(name: &str) -> String {/// that this version can't read (a hand edit) is skipped, never an error.pub fn resolve(theme: &ThemeFile) -> Tokens {let mut t = if theme.base.is_dark() { Tokens::dark() } else { Tokens::light() };+ for k in LEGACY_AXES {+ if let Some(Ok(c)) = theme.colors.get(k).map(|v| colors_of(v, 3))+ && let [x, y, z] = c[..]+ {+ (t.axis_x, t.axis_y, t.axis_z) = (x, y, z);+ }+ }for (k, v) in &theme.colors {if let Some(s) = slot(&mut t, k)&& let Ok(c) = colors_for_key(k, v, s.len())@@ -842,14 +861,35 @@ mod tests {#[test]fn a_short_file_sets_only_its_colours() {- let t = parse(r##"{"format":"solidcraft-theme/1","name":"My Theme!","base":"light","colors":{"panel":"#102030","triad":["#ff0000","#00ff00","#0000ff80"]}}"##).unwrap();+ let t = parse(r##"{"format":"solidcraft-theme/1","name":"My Theme!","base":"light","colors":{"panel":"#102030","axis_z":"#0000ff80"}}"##)+ .unwrap();assert_eq!((t.id.as_str(), t.name.as_str(), t.base), ("my-theme", "My Theme!", Base::Light));let p = resolve(&t);assert_eq!(p.panel, Color32::from_rgb(0x10, 0x20, 0x30));- assert_eq!(p.triad[2], Color32::from_rgba_unmultiplied(0, 0, 255, 0x80));+ assert_eq!(p.axis_z, Color32::from_rgba_unmultiplied(0, 0, 255, 0x80));assert_eq!(p.text, Tokens::light().text);}+ /// A theme file written before the axes were one set (#976) still reads: its view triad and+ /// Move gizmo lists colour every axis, the triad over the gizmo and `axis_*` over both.+ #[test]+ fn older_triad_and_gizmo_keys_colour_every_axis() {+ let file = |colors: &str| {+ resolve(&parse(&format!(r#"{{"format":"solidcraft-theme/1","name":"Old","base":"dark","colors":{{{colors}}}}}"#)).unwrap())+ };+ let (r, g, b, w) =+ (Color32::from_rgb(0xfb, 0x49, 0x34), Color32::from_rgb(0xb8, 0xbb, 0x26), Color32::from_rgb(0x83, 0xa5, 0x98), Color32::WHITE);+ let triad = r##""triad":["#fb4934","#b8bb26","#83a598"]"##;+ let gizmo = r##""gizmo":["#ffffff","#ffffff","#ffffff"]"##;+ assert_eq!(file(triad).axes(), [r, g, b]);+ assert_eq!(file(gizmo).axes(), [w, w, w]);+ assert_eq!(file(&format!("{gizmo},{triad}")).axes(), [r, g, b], "the triad over the gizmo");+ assert_eq!(file(&format!(r##"{triad},"axis_y":"#ffffff""##)).axes(), [r, w, b], "a file's own axis key wins");+ assert!(!keys().iter().any(|k| LEGACY_AXES.contains(k)), "an export writes axis_x, axis_y and axis_z only");+ let e = parse(r##"{"format":"solidcraft-theme/1","name":"x","base":"dark","colors":{"gizmo":["#000000"]}}"##).unwrap_err();+ assert!(e.contains("`gizmo` must be a list of 3 colours"), "{e}");+ }+#[test]fn older_exports_keep_active_overrides_without_retired_ui_settings() {let mut file = export("Older theme", Base::Dark, &Tokens::dark());diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rsindex 3608231479..c42763b7a3 100644--- a/crates/ui-egui/src/ui_kit/preferences.rs+++ b/crates/ui-egui/src/ui_kit/preferences.rs@@ -670,8 +670,8 @@ pub(crate) fn colour_vision_sample(ui: &mut egui::Ui, t: &Tokens) {// X along and Y up from one corner, as the view triad draws them.p.rect_filled(cell, t.radius_sm, t.viewport_top);let o = cell.left_bottom() + egui::vec2(t.space_12, -(t.space_4 + t.space_3));- p.line_segment([o, egui::pos2(cell.right() - t.space_10, o.y)], line(t.triad[0]));- p.line_segment([o, egui::pos2(o.x, cell.top() + t.space_6)], line(t.triad[1]));+ p.line_segment([o, egui::pos2(cell.right() - t.space_10, o.y)], line(t.axis_x));+ p.line_segment([o, egui::pos2(o.x, cell.top() + t.space_6)], line(t.axis_y));}3 => {// Dashed, as the flat pattern draws them.diff --git a/crates/ui-egui/src/ui_kit/preferences_figures.rs b/crates/ui-egui/src/ui_kit/preferences_figures.rsindex bb68d703bc..523a7dad0b 100644--- a/crates/ui-egui/src/ui_kit/preferences_figures.rs+++ b/crates/ui-egui/src/ui_kit/preferences_figures.rs@@ -143,7 +143,7 @@ pub(crate) fn paint_orientation(p: &Painter, rect: Rect, y_up: bool) {face(&p, ground, t.form_dim.gamma_multiply(0.035));p.add(Shape::closed_line(ground.to_vec(), Stroke::new(c.width(0.8), t.form_dim.gamma_multiply(0.20))));for (x, y, index, label) in orientation_axes(y_up) {- let colour = t.triad.get(index).copied().unwrap_or(t.form_ink);+ let colour = t.axes().get(index).copied().unwrap_or(t.form_ink);let end = c.at(x, y);// A halo keeps every shaft distinct from the subtle ground and the other axes.p.line_segment([centre, end], Stroke::new(c.width(4.2), t.viewport_top));diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex 18e84ec77c..e5471e2699 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -4620,7 +4620,7 @@ pub(crate) fn scene_palette(dark: bool, mode: crate::theme::ColorVision) -> solisketch_lost: rgb(t.sketch_lost),sketch_construction: rgb(t.sketch_construction),sketch_centerline: rgb(t.sketch_centerline),- axes: t.triad.map(rgb),+ axes: t.axes().map(rgb),cap: rgb(t.section_cap),analysis: t.analysis,}@@ -5619,7 +5619,7 @@ mod tests {/// window's theme (#974) and colour vision mode (#778). The light theme's tokens are the engine's own colours, so a/// light picture in Off is unchanged; otherwise each part takes the token the window draws it/// with. Sketch states follow what the window does with them (`sketch_color`) and the axes the- /// mode's triad, so the two can't drift apart.+ /// mode's axis colours, so the two can't drift apart.#[test]fn pictures_are_drawn_in_the_windows_theme() {use crate::theme::ColorVision;@@ -5635,7 +5635,7 @@ mod tests {assert_ne!(p.background, Palette::DEFAULT.background);for (dark, mode) in [false, true].into_iter().flat_map(|d| ColorVision::ALL.map(|m| (d, m))) {let (p, t) = (scene_palette(dark, mode), Tokens::themed(dark, mode));- assert_eq!(p.axes, t.triad.map(rgb), "dark {dark}, {mode:?}: the axes");+ assert_eq!(p.axes, t.axes().map(rgb), "dark {dark}, {mode:?}: the axes");assert_eq!(p.analysis, t.analysis, "dark {dark}, {mode:?}: the surface analysis");for (tag, cpu) in [(colors::SKETCH, p.sketch),@@ -8802,7 +8802,7 @@ mod tests {let t = Tokens::themed(false, ColorVision::Protan);assert_eq!((rg.sketch_projected, rg.sketch_locked), (rgb(t.sketch_projected), rgb(t.sketch_locked)));assert_ne!(rg.sketch_projected, off.sketch_projected, "the red-green table changes projected lines in light");- assert_eq!((rg.axes[0], rg.axes[1], rg.axes[2]), (rgb(t.triad[0]), rgb(t.triad[1]), off.axes[2]));+ assert_eq!((rg.axes[0], rg.axes[1], rg.axes[2]), (rgb(t.axis_x), rgb(t.axis_y), off.axes[2]));assert_eq!((rg.sketch, rg.background, rg.grid, rg.body), (off.sketch, off.background, off.grid, off.body));let by = scene_palette(false, ColorVision::Tritan);assert_eq!(by.sketch_locked, rgb(Tokens::themed(false, ColorVision::Tritan).sketch_locked));diff --git a/crates/ui-egui/src/viewport_overlays_tests.rs b/crates/ui-egui/src/viewport_overlays_tests.rsindex 3134920763..64ca91f298 100644--- a/crates/ui-egui/src/viewport_overlays_tests.rs+++ b/crates/ui-egui/src/viewport_overlays_tests.rs@@ -72,7 +72,7 @@ fn compass_negative_ends_are_hollow_and_positive_ends_are_chunkier() {let circles: Vec<_> = output.shapes.iter().filter_map(|s| if let Shape::Circle(c) = &s.shape { Some(c) } else { None }).collect();let end = circles.iter().find(|circle| circle.center == painted).unwrap();if positive {- assert_eq!(end.fill, t.triad[0]);+ assert_eq!(end.fill, t.axis_x);assert_eq!(end.radius, 11.0);let letters: Vec<_> = output.shapes@@ -317,7 +317,7 @@ fn a_hovered_compass_end_turns_white_and_its_letter_takes_the_axis_colour() {if !dark {// White would vanish on the light compass: an axis-coloured outline keeps it visible.assert!(- circles.iter().any(|circle| circle.center == painted && circle.stroke.color == t.triad[0] && circle.stroke.width >= 2.0),+ circles.iter().any(|circle| circle.center == painted && circle.stroke.color == t.axis_x && circle.stroke.width >= 2.0),"{name}: the hovered end is outlined in its axis colour on the light theme");}@@ -325,8 +325,10 @@ fn a_hovered_compass_end_turns_white_and_its_letter_takes_the_axis_colour() {if positive {assert!(!letters.is_empty()- && letters.iter().all(|text| text.override_text_color == Some(t.triad[0])- || text.galley.job.sections.iter().all(|s| s.format.color == t.triad[0])),+ && letters+ .iter()+ .all(|text| text.override_text_color == Some(t.axis_x)+ || text.galley.job.sections.iter().all(|s| s.format.color == t.axis_x)),"the letter takes the axis colour");} else {diff --git a/docs/book/src/guide/ui-tour.md b/docs/book/src/guide/ui-tour.mdindex 634535f43c..95d42e94d8 100644--- a/docs/book/src/guide/ui-tour.md+++ b/docs/book/src/guide/ui-tour.md@@ -138,7 +138,9 @@ colours and corner radii by name:"accent": "#83a598","viewport_top": "#32302f","viewport_bottom": "#32302f",- "triad": ["#fb4934", "#b8bb26", "#83a598"]+ "axis_x": "#fb4934",+ "axis_y": "#b8bb26",+ "axis_z": "#83a598"},"radii": {"radius_sm": 2,@@ -151,8 +153,11 @@ colours and corner radii by name:}```-Colours are `#rrggbb`, or `#rrggbbaa` for translucent ones. A few colours, such as the view-triad's X, Y and Z, take a list. Any colour the file leaves out keeps the base palette's value.+Colours are `#rrggbb`, or `#rrggbbaa` for translucent ones. A few colours, such as the four+Continuity Analysis seams (`continuity`), take a list. Any colour the file leaves out keeps the+base palette's value. `axis_x`, `axis_y` and `axis_z` colour every X, Y and Z axis: the origin,+the view triad, the navigation cube and the Move gizmo. A file from an earlier version may set+`triad` or `gizmo` instead; it still reads, and those colours now go to every axis.`radii` is optional. Its six keys above accept integers from 0 to 32 in logical UI points;zero makes square corners. Omitted keys keep today's base values: 4, 6, 8, 10, 6 and 7,