From 8372c476abb43a3fd51f24569da53008f25b4d66 Mon Sep 17 00:00:00 2001 From: raykholo Date: Tue, 27 Oct 2026 12:41:08 +0000 Subject: [PATCH] Add the built-in CGA theme (#7593) (#7594) --- assets/styles/ui/themes/cga.json | 215 ++++++++++++++++++++++++++++++ attribution/pending/cga-theme.md | 1 + crates/ui-egui/src/theme_files.rs | 34 ++++- 3 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 assets/styles/ui/themes/cga.json create mode 100644 attribution/pending/cga-theme.md diff --git a/assets/styles/ui/themes/cga.json b/assets/styles/ui/themes/cga.json new file mode 100644 index 000000000..56bc8b3e9 --- /dev/null +++ b/assets/styles/ui/themes/cga.json @@ -0,0 +1,215 @@ +{ + "base": "dark", + "colors": { + "accent": "#55ffff", + "accent_soft": "#ff55ff", + "agent_busy": "#55ffff", + "agent_ok": "#55ff55", + "app_bar": "#000000", + "app_bar_hover": "#ffffff18", + "app_bar_hover_button": "#ffffff22", + "app_bar_hover_strong": "#ffffff30", + "app_bar_hover_subtle": "#ffffff10", + "app_bar_separator": "#00aaaa", + "app_bar_tab_active": "#aa00aa", + "app_bar_text": "#ffffff", + "axis_x": "#ff5555", + "axis_y": "#55ff55", + "axis_z": "#5555ff", + "bend_down": "#ffff55", + "bend_up": "#55ff55", + "body": "#aa00aa", + "body_edge": "#55ffff", + "body_selected": "#ffff55", + "border": "#55ffff", + "box_crossing": "#ff55ff", + "box_window": "#55ffff", + "chip": "#aa00aa", + "construction_geom": "#aaaaaa", + "construction_plane": "#ffff5522", + "continuity": [ + "#55ff55", + "#5555ff", + "#ffff55", + "#ff55ff" + ], + "control_border": "#55ffff", + "control_fill": "#000000", + "cube_border": "#55ffff", + "cube_face": "#000000", + "cube_hover": "#aa00aa", + "cube_text": "#ffffff", + "dialog_bg": "#000000", + "dialog_body": "#000000", + "dialog_border": "#55ffff", + "dialog_footer": "#000000", + "dialog_label": "#55ffff", + "dialog_rule": "#00aaaa", + "dimension": "#ffffff", + "dimension_driven": "#aaaaaa", + "error": "#ff5555", + "field": "#000000", + "file_background": "#000000", + "file_border": "#55ffff", + "file_dim": "#55ffff", + "file_image_tint": "#ffffff", + "file_primary": "#000000", + "file_primary_border": "#55ffff", + "file_primary_ink": "#55ffff", + "file_rail": "#000000", + "file_rail_hover": "#aa00aa", + "file_rail_ink": "#ffffff", + "file_recovery": "#000000", + "file_recovery_border": "#ff55ff", + "file_recovery_ink": "#ff55ff", + "file_recovery_well": "#000000", + "file_surface": "#000000", + "form_accent": "#aa0000", + "form_dim": "#55ffff", + "form_error": "#ff5555", + "form_error_fill": "#000000", + "form_fill": "#ff5555", + "form_ink": "#ffffff", + "form_primary": "#ff55ff", + "form_soft": "#000000", + "form_success": "#55ff55", + "form_success_fill": "#000000", + "form_tab_ink": "#ff5555", + "glyph_bg": "#000000", + "glyph_edge": "#ff55ff", + "glyph_text": "#ff55ff", + "grid": "#555555", + "grid_major": "#00aaaa", + "hover": "#aa00aa", + "hover_edge": "#ffffff", + "hover_edge_halo": "#000000", + "hover_profile": "#ffffff40", + "hover_profile_edge": "#ffffff", + "icon": "#ffffff", + "icons.agent": "#ff55ff", + "icons.highlight": "#ffffff", + "icons.marker_halo": "#000000cc", + "interference": "#ff5555", + "logo": [ + "#ffffff", + "#55ffff", + "#ff55ff" + ], + "manipulator": "#55ffff", + "mesh_accent": "#00aa00", + "mesh_fill": "#55ff55", + "mesh_ink": "#55ff55", + "mesh_soft": "#000000", + "on_accent": "#000000", + "origin_plane": "#55ffff20", + "origin_plane_edge": "#55ffff80", + "origin_plane_hover": "#ff55ff40", + "origin_point": "#ffffff", + "overlay": "#000000", + "panel": "#000000", + "panel_header": "#000000", + "preview_add": "#55ffff", + "preview_cut": "#ff555566", + "preview_new": "#ffff55", + "preview_sketch": "#55ff55", + "profile_fill": "#55ffff22", + "render_accent": "#aaaaaa", + "render_fill": "#ffffff", + "render_ink": "#ffffff", + "render_soft": "#000000", + "rubber_band": "#55ffff", + "section_cap": "#ffff55", + "sel_edge": "#ffff55", + "sel_edge_rim": "#000000", + "sel_face": "#ffff55", + "sel_profile": "#ffff55", + "sel_profile_edge": "#ffff55", + "sel_vertex": "#ffff55", + "selected_bg": "#ff55ff", + "selected_ink": "#000000", + "sheet_fill": "#aaaaaa", + "sheet_ink": "#aaaaaa", + "sheet_soft": "#000000", + "sketch": "#55ffff", + "sketch_accent": "#ff55ff", + "sketch_centerline": "#ffff55", + "sketch_construction": "#aaaaaa", + "sketch_fixed": "#ffffff", + "sketch_halo": "#000000", + "sketch_ink": "#ff55ff", + "sketch_locked": "#55ff55", + "sketch_lost": "#ff5555", + "sketch_point": "#ffffff", + "sketch_point_free": "#55ffff", + "sketch_projected": "#ff55ff", + "sketch_soft": "#000000", + "surface_accent": "#aa5500", + "surface_fill": "#ffff55", + "surface_ink": "#ffff55", + "surface_soft": "#000000", + "tab_on_fill_dark": "#000000", + "text": "#ffffff", + "text_dim": "#55ffff", + "timeline": "#000000", + "timeline_item": "#000000", + "timeline_item_error": "#aa0000", + "timeline_marker": "#55ffff", + "toolbar": "#000000", + "viewport_bottom": "#000000", + "viewport_top": "#000000", + "warning": "#ffff55" + }, + "format": "solidcraft-theme/1", + "name": "CGA", + "radii": { + "radius_sm": 0, + "radius_md": 0, + "radius_lg": 0, + "radius_xl": 0, + "control_radius": 0, + "sketch_mode_radius": 0 + }, + "icon_palette": { + "ink": "#000000", + "line": "#ffffff", + "passive-1": "#ffffff", + "passive-2": "#aaaaaa", + "passive-3": "#555555", + "guide": "#55ffff", + "solid": [ + "#ffffff", + "#55ffff", + "#00aaaa" + ], + "surface": [ + "#ffffff", + "#ffff55", + "#aa5500" + ], + "mesh": [ + "#ffffff", + "#55ff55", + "#00aa00" + ], + "form": [ + "#ffffff", + "#ff5555", + "#aa0000" + ], + "sketch": [ + "#ffffff", + "#ff55ff", + "#aa00aa" + ], + "constraint": [ + "#ffffff", + "#ff55ff", + "#aa00aa" + ], + "construction": [ + "#ffffff", + "#ffff55", + "#aa5500" + ] + } +} diff --git a/attribution/pending/cga-theme.md b/attribution/pending/cga-theme.md new file mode 100644 index 000000000..c358789e7 --- /dev/null +++ b/attribution/pending/cga-theme.md @@ -0,0 +1 @@ +| assets/styles/ui/themes/cga.json | SolidCraft contributors | original SolidCraft theme file using the 16 colours of the IBM Color Graphics Adapter (black, cyan, magenta, and white of its high-intensity palette 1 for the interface) | MIT OR Apache-2.0 | diff --git a/crates/ui-egui/src/theme_files.rs b/crates/ui-egui/src/theme_files.rs index caa8217f7..dbe6bde90 100644 --- a/crates/ui-egui/src/theme_files.rs +++ b/crates/ui-egui/src/theme_files.rs @@ -610,8 +610,8 @@ pub fn export(name: &str, base: Base, t: &Tokens) -> Value { json!({"format": FORMAT, "name": name, "base": base, "colors": colors, "radii": radii, "borders": borders, "icon_palette": icon_palette}) } -/// The theme files that come with SolidCraft (original files; Gruvbox, Tokyo Night, Solarized, Nord, Nosferatu and Catppuccin map open-source palettes, MIT; Okibi and Akari map the Okibi design system; Clay and Clay Dark are original warm paper and charcoal palettes). -const BUILTIN: [(&str, &str); 24] = [ +/// The theme files that come with SolidCraft (original files; Gruvbox, Tokyo Night, Solarized, Nord, Nosferatu and Catppuccin map open-source palettes, MIT; Okibi and Akari map the Okibi design system; Clay and Clay Dark are original warm paper and charcoal palettes; CGA keeps to the 16 colours of the IBM Color Graphics Adapter). +const BUILTIN: [(&str, &str); 25] = [ ("gruvbox-dark", include_str!("../../../assets/styles/ui/themes/gruvbox-dark.json")), ("gruvbox-dark-hard", include_str!("../../../assets/styles/ui/themes/gruvbox-dark-hard.json")), ("gruvbox-dark-soft", include_str!("../../../assets/styles/ui/themes/gruvbox-dark-soft.json")), @@ -636,6 +636,7 @@ const BUILTIN: [(&str, &str); 24] = [ ("akari", include_str!("../../../assets/styles/ui/themes/akari.json")), ("clay", include_str!("../../../assets/styles/ui/themes/clay.json")), ("clay-dark", include_str!("../../../assets/styles/ui/themes/clay-dark.json")), + ("cga", include_str!("../../../assets/styles/ui/themes/cga.json")), ]; /// The built-in themes, read once (one that fails to read is left out; a test reads them all). @@ -825,6 +826,35 @@ mod tests { } } + /// CGA uses only the 16 colours of the IBM Color Graphics Adapter (alpha only on translucent + /// tokens) and sets every colour, so nothing falls back to Dark's palette. + #[test] + fn cga_uses_only_the_sixteen_cga_colours() { + const CGA: [&str; 16] = [ + "000000", "0000aa", "00aa00", "00aaaa", "aa0000", "aa00aa", "aa5500", "aaaaaa", "555555", "5555ff", "55ff55", "55ffff", "ff5555", + "ff55ff", "ffff55", "ffffff", + ]; + fn colours<'a>(v: &'a Value, out: &mut Vec<&'a str>) { + match v { + Value::String(s) if s.starts_with('#') => out.push(s), + Value::Array(a) => a.iter().for_each(|v| colours(v, out)), + Value::Object(o) => o.values().for_each(|v| colours(v, out)), + _ => {} + } + } + let text = BUILTIN.iter().find(|(id, _)| *id == "cga").map(|(_, text)| *text).unwrap(); + let file: Value = serde_json::from_str(text).unwrap(); + let mut found = Vec::new(); + colours(&file, &mut found); + assert!(found.len() > keys().len(), "CGA sets every colour and its icon palette"); + for c in found { + let rgb = c.get(1..7).unwrap_or_default().to_ascii_lowercase(); + assert!(CGA.contains(&rgb.as_str()) && parse_color(c).is_some(), "{c} is not a CGA colour"); + } + let theme = find("cga", &[]).unwrap(); + assert_eq!((theme.name.as_str(), theme.colors.len()), ("CGA", keys().len()), "CGA sets every colour"); + } + /// #4868: a theme that sets none of the File view's colours (all the built-in ones) gets them /// from its own palette, readable: the rail and primary action from its accent, the page from /// its panel, not Dark's or Light's blue and grey. One it does set stays as set.