SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Preferences: the tab colour strip names the tabs as the ribbon does (#8027)
semmelrinde292177e085a2
diff --git a/assets/locales/pending/form-tab-name.json b/assets/locales/pending/form-tab-name.jsonnew file mode 100644index 0000000000..3cdf89e80b--- /dev/null+++ b/assets/locales/pending/form-tab-name.json@@ -0,0 +1,38 @@+{+ "en": {+ "ui.heading_form": "FORM"+ },+ "ar": {+ "ui.heading_form": "تشكيل"+ },+ "de": {+ "ui.heading_form": "FORM"+ },+ "es": {+ "ui.heading_form": "FORMA"+ },+ "fr": {+ "ui.heading_form": "FORME"+ },+ "he": {+ "ui.heading_form": "צורה"+ },+ "it": {+ "ui.heading_form": "FORMA"+ },+ "ja": {+ "ui.heading_form": "フォーム"+ },+ "ko": {+ "ui.heading_form": "폼"+ },+ "vi": {+ "ui.heading_form": "TẠO HÌNH"+ },+ "zh": {+ "ui.heading_form": "造型"+ },+ "zh-TW": {+ "ui.heading_form": "造型"+ }+}diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex ebede2ff5e..a340f0d893 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -5034,6 +5034,39 @@ mod tests {.collect()}+ /// The Interface page's tab colour strip names each tab as the ribbon does, in every language.+ #[test]+ fn tab_accent_strip_names_the_tabs_as_the_ribbon_does() {+ use crate::workspace::tab_name;+ fn texts(shape: &egui::Shape, out: &mut Vec<String>) {+ match shape {+ egui::Shape::Text(text) => out.push(text.galley.job.text.clone()),+ egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| texts(shape, out)),+ _ => {}+ }+ }+ let h = crate::scenario::Harness::new();+ for (lang, want) in [+ ("en", ["Model", "Surface", "Mesh", "Form", "Sheet Metal", "Render"]),+ ("de", ["Modell", "Fläche", "Mesh", "Form", "Blech", "Rendern"]),+ ("fr", ["Modèle", "Surface", "Maillage", "Forme", "Tôlerie", "Rendu"]),+ ] {+ let _scope = crate::i18n::scope(lang);+ let got = ["MODEL", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER"].map(tab_name);+ assert_eq!(got, want, "{lang}");+ let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(900.0, 200.0));+ let mut out = h.ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| {+ crate::ui_kit::scope(ui, crate::ui_kit::tab_accent_strip);+ });+ out.textures_delta.clear();+ let mut painted = Vec::new();+ out.shapes.iter().for_each(|shape| texts(&shape.shape, &mut painted));+ for name in want {+ assert!(painted.iter().any(|p| p == name), "{lang}: the strip paints {painted:?}, not {name}");+ }+ }+ }+/// Origin plane names (#6491): Top, Front and Right are names shown in the browser, the/// dialogs' chips and the plane choices; the planes' ids, the commands and the design keep XY,/// XZ and YZ. Saved, refused when unknown, and taken back by Cancel and Restore Defaults.diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rsindex 6c03cc9d6b..509a20d193 100644--- a/crates/ui-egui/src/toolbar.rs+++ b/crates/ui-egui/src/toolbar.rs@@ -966,16 +966,7 @@ fn ribbon_button_galley(painter: &egui::Painter, label: &str, width: f32, color:/// Ribbon headings use the translated labels, with normal word casing instead of registry caps.fn ribbon_label(app: &SolveApp, label: &str) -> String {- let label = app- .tr_label(crate::workspace::tab_label(label))- .split_whitespace()- .map(|word| {- let lower = word.to_lowercase();- let mut chars = lower.chars();- chars.next().map(|c| c.to_uppercase().collect::<String>() + chars.as_str()).unwrap_or_default()- })- .collect::<Vec<_>>()- .join(" ");+ let label = crate::workspace::word_cased(app.tr_label(crate::workspace::tab_label(label)));// Partial catalogs may already translate the word-cased name (for example "Model").app.tr_label(&label).to_string()}diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rsindex 254c72ee42..42595ed47c 100644--- a/crates/ui-egui/src/ui_kit/preferences.rs+++ b/crates/ui-egui/src/ui_kit/preferences.rs@@ -591,16 +591,16 @@ pub(crate) fn tab_accent_strip(ui: &mut Ui) {}let t = Tokens::get();super::text(ui, crate::i18n::tr("prefs.tab_accent_note"), super::Text::Hint("tab_accent"));- let names =- [("MODEL", "Model"), ("SURFACE", "Surface"), ("MESH", "Mesh"), ("FORM", "Form"), ("SHEET METAL", "Sheet Metal"), ("RENDER", "Render")];+ // Named as the ribbon names its tabs, so each reads as its tab does in every language.+ let names = ["MODEL", "SURFACE", "MESH", "FORM", "SHEET METAL", "RENDER"];let (r, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24 + t.space_8), Sense::hover());let width = r.width() / names.len() as f32;- for (i, (name, display_label)) in names.iter().enumerate() {+ for (i, name) in names.iter().enumerate() {let rect = Rect::from_min_size(r.min + vec2(i as f32 * width, 0.0), vec2((width - t.space_6).max(0.0), t.space_6));let accent = crate::theme::TabAccent::for_tab(&t, name);ui.painter().rect_filled(rect, t.radius_sm, accent.color);let label = Rect::from_min_size(pos2(rect.left(), rect.bottom() + t.space_4), vec2(rect.width(), t.space_16));- centred_text(ui.painter(), label, crate::i18n::tr_label(display_label), FontId::proportional(t.font_small), t.form_dim);+ centred_text(ui.painter(), label, &crate::workspace::tab_name(name), FontId::proportional(t.font_small), t.form_dim);}}diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rsindex d253662e21..76b1a21859 100644--- a/crates/ui-egui/src/workspace.rs+++ b/crates/ui-egui/src/workspace.rs@@ -13,6 +13,25 @@ pub fn tab_label(tab: &str) -> &str {tab.strip_prefix("RENDER ").unwrap_or(tab)}+/// A tab's registry name in normal word casing: "SHEET METAL" → "Sheet Metal".+pub fn word_cased(name: &str) -> String {+ name.split_whitespace()+ .map(|word| {+ let lower = word.to_lowercase();+ let mut chars = lower.chars();+ chars.next().map(|c| c.to_uppercase().collect::<String>() + chars.as_str()).unwrap_or_default()+ })+ .collect::<Vec<_>>()+ .join(" ")+}++/// A ribbon tab's name as the ribbon shows it, in the current language: "SHEET METAL" reads+/// "Sheet Metal", or "Blech" in German. A partial catalog may translate only the word-cased name.+pub fn tab_name(tab: &str) -> String {+ let cased = word_cased(crate::i18n::tr_label(tab_label(tab)));+ crate::i18n::tr_label(&cased).to_string()+}+pub const TABS: &[&str] = &["MODEL", "SURFACE", "ASSEMBLE", "INSERT", "INSPECT", "MANAGE", "VIEW"];/// Reading order of the compact, three-column constraint gallery. Icons come from each spec.