From b2d727f4b24b02e113ec1dea1ef9009355d7b0ac Mon Sep 17 00:00:00 2001 From: Karl Von Richter Date: Thu, 29 Oct 2026 13:32:21 +0000 Subject: [PATCH] Toolbar: choose visible tabs while preserving all defaults (#5717) (#8594) * claim: #5717 * ui(feat): let users choose visible toolbar tabs Keep Sheet Metal and Weldments visible by default while adding persisted tab visibility controls and restoring specialty tabs for designs that use them. Signed-off-by: Karl Von Richter * ui(fix): respect hidden toolbar tabs in every design Remove feature-based visibility overrides for Sheet Metal and Weldments. Keep all tabs visible by default and preserve the user choice across feature creation, opening designs, selection and undo. Signed-off-by: Karl Von Richter --------- Signed-off-by: Karl Von Richter --- assets/icons/ui/design/requested_icons.txt | 1 + assets/locales/pending/toolbar-tabs.json | 188 +++++++++++++++++ crates/ui-egui/src/context_menu.rs | 9 +- crates/ui-egui/src/prefs.rs | 39 +++- crates/ui-egui/src/prefs/interface.rs | 11 + crates/ui-egui/src/toolbar.rs | 40 +++- crates/ui-egui/src/toolbar_custom.rs | 36 +++- crates/ui-egui/src/workspace.rs | 222 ++++++++++++++++++++- docs/book/src/guide/ui-tour.md | 5 + docs/control-protocol.md | 3 +- docs/ribbon-layout.md | 6 +- 11 files changed, 531 insertions(+), 29 deletions(-) create mode 100644 assets/locales/pending/toolbar-tabs.json diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt index 08639d4f8..ddb72f14d 100644 --- a/assets/icons/ui/design/requested_icons.txt +++ b/assets/icons/ui/design/requested_icons.txt @@ -224,6 +224,7 @@ settings_monitor false settings_mouse false settings_palette false settings_plug false +sheet false sheet_rules false shell false shield false diff --git a/assets/locales/pending/toolbar-tabs.json b/assets/locales/pending/toolbar-tabs.json new file mode 100644 index 000000000..384538274 --- /dev/null +++ b/assets/locales/pending/toolbar-tabs.json @@ -0,0 +1,188 @@ +{ + "en": { + "prefs.toolbar_tabs": "Toolbar tabs", + "ui.tab_assemble": "Assemble", + "ui.tab_manage": "Manage", + "ui.tab_sheet_metal": "Sheet Metal", + "ui.tab_view": "View", + "ui.tab_weldments": "Weldments", + "ui.toolbar_tabs_hidden": "Every toolbar tab is hidden. Click + or right-click here to show one." + }, + "cs": { + "ui.tab_assemble": "Sestava", + "ui.tab_manage": "Správa", + "ui.tab_sheet_metal": "Plech", + "ui.tab_view": "Pohled" + }, + "da": { + "ui.tab_assemble": "Samling", + "ui.tab_manage": "Administrér", + "ui.tab_sheet_metal": "Plade", + "ui.tab_view": "Visning" + }, + "de": { + "ui.tab_assemble": "Zusammenbau", + "ui.tab_manage": "Verwalten", + "ui.tab_sheet_metal": "Blech", + "ui.tab_view": "Ansicht", + "prefs.toolbar_tabs": "Werkzeugleisten-Registerkarten", + "ui.toolbar_tabs_hidden": "Alle Werkzeugleisten-Registerkarten sind ausgeblendet. Klicken Sie auf + oder hier mit der rechten Maustaste, um eine einzublenden.", + "ui.tab_weldments": "Schweissteile" + }, + "es": { + "ui.tab_assemble": "Ensamblar", + "ui.tab_manage": "Gestionar", + "ui.tab_sheet_metal": "Chapa", + "ui.tab_view": "Vista" + }, + "fr": { + "ui.tab_assemble": "Assembler", + "ui.tab_manage": "Gérer", + "ui.tab_sheet_metal": "Tôlerie", + "ui.tab_view": "Vue" + }, + "gl": { + "ui.tab_assemble": "Ensamblar", + "ui.tab_manage": "Xestionar", + "ui.tab_sheet_metal": "Chapa", + "ui.tab_view": "Vista" + }, + "hu": { + "ui.tab_assemble": "Összeszerelés", + "ui.tab_manage": "Kezelés", + "ui.tab_sheet_metal": "Lemez", + "ui.tab_view": "Nézet" + }, + "id": { + "ui.tab_assemble": "Rakit", + "ui.tab_manage": "Kelola", + "ui.tab_sheet_metal": "Pelat Logam", + "ui.tab_view": "Tampilan" + }, + "it": { + "ui.tab_assemble": "Assembla", + "ui.tab_manage": "Gestisci", + "ui.tab_sheet_metal": "Lamiera", + "ui.tab_view": "Vista" + }, + "ja": { + "prefs.toolbar_tabs": "ツールバーのタブ", + "ui.tab_assemble": "アセンブリ", + "ui.tab_manage": "管理", + "ui.tab_sheet_metal": "板金", + "ui.tab_view": "表示", + "ui.toolbar_tabs_hidden": "ツールバーのタブはすべて非表示です。+ をクリックするか、ここを右クリックして表示します。", + "ui.tab_weldments": "溶接構造" + }, + "ko": { + "ui.tab_assemble": "조립", + "ui.tab_manage": "관리", + "ui.tab_sheet_metal": "판금", + "ui.tab_view": "보기", + "prefs.toolbar_tabs": "도구 모음 탭", + "ui.toolbar_tabs_hidden": "모든 도구 모음 탭이 숨겨져 있습니다. +를 클릭하거나 여기를 마우스 오른쪽 버튼으로 클릭하여 표시하세요.", + "ui.tab_weldments": "용접 구조물" + }, + "ms": { + "ui.tab_assemble": "Pasang", + "ui.tab_manage": "Urus", + "ui.tab_sheet_metal": "Logam Kepingan", + "ui.tab_view": "Pandangan" + }, + "nb": { + "ui.tab_assemble": "Monter", + "ui.tab_manage": "Administrer", + "ui.tab_sheet_metal": "Plate", + "ui.tab_view": "Visning" + }, + "nl": { + "ui.tab_assemble": "Samenstellen", + "ui.tab_manage": "Beheren", + "ui.tab_sheet_metal": "Plaatwerk", + "ui.tab_view": "Weergave" + }, + "pl": { + "ui.tab_assemble": "Złożenie", + "ui.tab_manage": "Zarządzanie", + "ui.tab_sheet_metal": "Blacha", + "ui.tab_view": "Widok" + }, + "pt-BR": { + "ui.tab_assemble": "Montar", + "ui.tab_manage": "Gerenciar", + "ui.tab_sheet_metal": "Chapa Metálica", + "ui.tab_view": "Vista" + }, + "ro": { + "ui.tab_assemble": "Asamblare", + "ui.tab_manage": "Gestionare", + "ui.tab_sheet_metal": "Tablă", + "ui.tab_view": "Vizualizare" + }, + "ru": { + "ui.tab_assemble": "Сборка", + "ui.tab_manage": "Управление", + "ui.tab_sheet_metal": "Листовой Металл", + "ui.tab_view": "Вид" + }, + "sv": { + "ui.tab_assemble": "Montera", + "ui.tab_manage": "Hantera", + "ui.tab_sheet_metal": "Plåt", + "ui.tab_view": "Vy" + }, + "tr": { + "ui.tab_assemble": "Montaj", + "ui.tab_manage": "Yönet", + "ui.tab_sheet_metal": "Sac Metal", + "ui.tab_view": "Görünüm" + }, + "uk": { + "ui.tab_assemble": "Складання", + "ui.tab_manage": "Керування", + "ui.tab_sheet_metal": "Листовий Метал", + "ui.tab_view": "Вид" + }, + "vi": { + "ui.tab_assemble": "Lắp Ráp", + "ui.tab_manage": "Quản Lý", + "ui.tab_sheet_metal": "Kim Loại Tấm", + "ui.tab_view": "Góc Nhìn", + "prefs.toolbar_tabs": "Thẻ thanh công cụ", + "ui.toolbar_tabs_hidden": "Tất cả các thẻ thanh công cụ đều bị ẩn. Nhấp vào + hoặc nhấp chuột phải tại đây để hiện một thẻ.", + "ui.tab_weldments": "Kết Cấu Hàn" + }, + "zh": { + "prefs.toolbar_tabs": "工具栏选项卡", + "ui.tab_assemble": "装配", + "ui.tab_manage": "管理", + "ui.tab_sheet_metal": "钣金", + "ui.tab_view": "视图", + "ui.toolbar_tabs_hidden": "所有工具栏选项卡均已隐藏。点击 + 或在此处右键单击即可显示。", + "ui.tab_weldments": "焊件" + }, + "zh-TW": { + "ui.tab_assemble": "組裝", + "ui.tab_manage": "管理", + "ui.tab_sheet_metal": "鈑金", + "ui.tab_view": "檢視" + }, + "ar": { + "prefs.toolbar_tabs": "علامات تبويب شريط الأدوات", + "ui.toolbar_tabs_hidden": "جميع علامات تبويب شريط الأدوات مخفية. انقر على + أو انقر هنا بزر الفأرة الأيمن لإظهار إحداها.", + "ui.tab_weldments": "اللحامات", + "ui.tab_assemble": "التجميع", + "ui.tab_manage": "إدارة", + "ui.tab_view": "العرض", + "ui.tab_sheet_metal": "الصفائح المعدنية" + }, + "he": { + "prefs.toolbar_tabs": "לשוניות סרגל הכלים", + "ui.toolbar_tabs_hidden": "כל לשוניות סרגל הכלים מוסתרות. לחצו על + או לחצו כאן לחיצה ימנית כדי להציג לשונית.", + "ui.tab_weldments": "ריתוכים", + "ui.tab_assemble": "הרכבה", + "ui.tab_manage": "ניהול", + "ui.tab_view": "תצוגה", + "ui.tab_sheet_metal": "פח" + } +} diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs index 7c6fc5e81..66711152c 100644 --- a/crates/ui-egui/src/context_menu.rs +++ b/crates/ui-egui/src/context_menu.rs @@ -1513,7 +1513,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) { let _ = app.run("browser.visibility", json!({"visible": true, "paths": [p["path"]], "isolate": true})); } "ui.canvasVisible" => drop(app.run("canvas.edit", p)), - "ui.toolbarPin" | "ui.toolbarRemove" | "ui.toolbarReset" | "ui.toolbarCustomize" | "ui.shortcutPin" => { + "ui.toolbarPin" | "ui.toolbarRemove" | "ui.toolbarReset" | "ui.toolbarCustomize" | "ui.toolbarTab" | "ui.shortcutPin" => { crate::toolbar_custom::run(app, &item.id, &p) } "ui.historyPlayButton" => { @@ -1920,7 +1920,7 @@ pub fn open_for(app: &mut SolveApp, at: Pos2, target: Target) { /// A button's menu: a click opens it, and a click on the same button while it is open closes it. pub fn toggle_for(app: &mut SolveApp, opener: Rect, at: Pos2, target: Target) { - if app.viewport.context_menu.is_some() && app.menu.target == target && app.menu.opener == Some(opener) { + if open_from(app, opener, &target) { close(app); } else { open_for(app, at, target); @@ -1928,6 +1928,11 @@ pub fn toggle_for(app: &mut SolveApp, opener: Rect, at: Pos2, target: Target) { } } +/// The button's menu is open, so the button can show it pressed. +pub fn open_from(app: &SolveApp, opener: Rect, target: &Target) -> bool { + app.viewport.context_menu.is_some() && app.menu.target == *target && app.menu.opener == Some(opener) +} + pub fn close(app: &mut SolveApp) { app.viewport.context_menu = None; app.menu.flick = false; diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index 637d61ec8..eaf91e646 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -976,6 +976,8 @@ preference_settings! { /// Where notices and offers stack: the view's bottom-right corner (the default) or the bottom /// centre, as before #7893. toast_place: crate::viewport::ToastPlace = Default::default(), PAGE_INTERFACE; + /// Toolbar tabs hidden by the person. An empty list keeps every existing tab visible. + hidden_toolbar_tabs: Vec = Vec::new(), PAGE_INTERFACE; /// Interface scale (1 = 100 %). ui_scale: f32 = 1.0, PAGE_INTERFACE, accept(0.5..=2.5); /// Interface font: an installed font family (or a font file), or empty for the built-in one @@ -3060,12 +3062,29 @@ fn limit_disabled_plugins(mut p: Prefs) -> Prefs { p } +/// Keep only known hidden tabs, each once, so a hand-edited preferences +/// file cannot carry a huge or nonsense list. `set` still refuses those instead of dropping them. +fn limit_toolbar_tabs(mut p: Prefs) -> Prefs { + fn known_once(list: Vec, allowed: &[&str]) -> Vec { + let mut kept: Vec = Vec::new(); + for tab in list { + if allowed.contains(&tab.as_str()) && !kept.contains(&tab) { + kept.push(tab); + } + } + kept + } + let allowed: Vec<&str> = crate::workspace::choosable_tabs().collect(); + p.hidden_toolbar_tabs = known_once(std::mem::take(&mut p.hidden_toolbar_tabs), &allowed); + p +} + /// Saved preferences, keeping every one that still reads. A value this version doesn't /// understand (a setting a newer or older release saved differently, a hand edit) falls back to /// its default on its own instead of discarding all of them. pub fn lenient(saved: &serde_json::Value) -> Prefs { if let Ok(p) = serde_json::from_value::(saved.clone()) { - return limit_disabled_plugins(migrate(p)); + return limit_toolbar_tabs(limit_disabled_plugins(migrate(p))); } let Ok(mut cur) = serde_json::to_value(Prefs::default()) else { return Prefs::default() }; if let (Some(o), Some(src)) = (cur.as_object_mut(), saved.as_object()) { @@ -3079,7 +3098,7 @@ pub fn lenient(saved: &serde_json::Value) -> Prefs { } } } - serde_json::from_value(cur).map(migrate).map(limit_disabled_plugins).unwrap_or_default() + serde_json::from_value(cur).map(migrate).map(limit_disabled_plugins).map(limit_toolbar_tabs).unwrap_or_default() } /// Set preferences from JSON (control channel); returns them all. @@ -3171,6 +3190,13 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result = crate::workspace::choosable_tabs().collect(); + if !once(&new.hidden_toolbar_tabs, &allowed) { + return Err(format!("`hidden_toolbar_tabs` lists toolbar tabs, each once: {}", allowed.join(", "))); + } if !accepted::ui_scale(&new) || !accepted::look_at_speed(&new) { return Err("`ui_scale` must be 0.5…2.5 and `look_at_speed` 0.25…4".into()); } @@ -3210,7 +3236,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result