From 07160d93661e94a68fcb48d158a2eeb471572e5e Mon Sep 17 00:00:00 2001 From: Nathan Dane Date: Sat, 31 Oct 2026 22:05:20 +0000 Subject: [PATCH] Preferences redesign 3/11: page structure, aliases and profile card (#9875) (#9907) * claim: #9875 * Preferences: split pages and preserve aliases and profiles * Preferences: preserve moved-page regressions and complete translations * Preferences: retain newly added settings in profiles * Preferences: target Tools in tool-cursor persistence tests --- .../pending/preferences-structure.json | 175 ++++ crates/ui-egui/src/agent_chat/panel.rs | 4 +- crates/ui-egui/src/agent_chat/settings.rs | 2 +- crates/ui-egui/src/hole_place_ui_tests.rs | 6 +- crates/ui-egui/src/measurement_ui_tests.rs | 6 +- crates/ui-egui/src/navigation_bar_tests.rs | 2 +- crates/ui-egui/src/prefs.rs | 823 ++++++++++++------ crates/ui-egui/src/prefs/design.rs | 83 +- crates/ui-egui/src/prefs/general.rs | 21 +- crates/ui-egui/src/prefs/graphics.rs | 23 +- crates/ui-egui/src/prefs/interface.rs | 229 +++-- crates/ui-egui/src/prefs/navigation.rs | 32 +- crates/ui-egui/src/prefs/sketch.rs | 7 +- crates/ui-egui/src/prefs/tools.rs | 58 ++ crates/ui-egui/src/prefs_search.rs | 34 +- crates/ui-egui/src/settings_profiles.rs | 178 +++- crates/ui-egui/src/settings_profiles_tests.rs | 181 ++++ crates/ui-egui/src/shell_tests.rs | 16 +- crates/ui-egui/src/space_mouse.rs | 2 +- crates/ui-egui/src/space_mouse_offer.rs | 8 +- crates/ui-egui/src/tool_cursor.rs | 26 +- crates/ui-egui/src/ui_kit/panel.rs | 35 +- crates/ui-egui/src/ui_kit/panel_tests.rs | 40 + crates/ui-egui/src/ui_kit/preferences.rs | 10 + crates/ui-egui/src/workspace.rs | 6 +- .../tests/scenarios/agent_chat_home_page.json | 2 +- .../scenarios/colour_vision_setting.json | 8 +- .../tests/scenarios/dialog_buttons_top.json | 2 +- .../tests/scenarios/preferences_search.json | 11 +- .../tests/scenarios/prefs_theme_files.json | 2 +- .../tests/scenarios/prefs_viewport_theme.json | 2 +- .../tests/scenarios/s45_preferences.json | 4 +- .../scenarios/s46_preferences_fixed_size.json | 45 +- docs/control-protocol.md | 2 +- 34 files changed, 1501 insertions(+), 584 deletions(-) create mode 100644 assets/locales/pending/preferences-structure.json create mode 100644 crates/ui-egui/src/prefs/tools.rs diff --git a/assets/locales/pending/preferences-structure.json b/assets/locales/pending/preferences-structure.json new file mode 100644 index 000000000..7b4e0def8 --- /dev/null +++ b/assets/locales/pending/preferences-structure.json @@ -0,0 +1,175 @@ +{ + "ar": { + "prefs.structure.appearance": "المظهر", + "prefs.structure.appearance_note": "الألوان والنصوص وإمكانية الوصول.", + "prefs.structure.in_profile": "ضمن ملف التعريف", + "prefs.structure.layout": "التخطيط", + "prefs.structure.layout_note": "مواضع أجزاء النافذة.", + "prefs.structure.look": "المظهر", + "prefs.structure.measure_pointer": "القياس والمؤشر", + "prefs.structure.mouse3d": "فأرة ثلاثية الأبعاد", + "prefs.structure.mouse3d_note": "SpaceMouse وSpaceNavigator.", + "prefs.structure.navigation_note": "الفأرة ولوحة اللمس. للفأرة ثلاثية الأبعاد صفحة خاصة بها.", + "prefs.structure.profile": "ملف التعريف", + "prefs.structure.profile_edited": "تغيّر منذ الحفظ", + "prefs.structure.profile_hover": "محفوظ في ملفات تعريف الإعدادات", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "رسم", + "prefs.structure.tools": "الأدوات", + "prefs.structure.tools_note": "كيفية عمل أدوات النمذجة.", + "prefs.structure.work": "العمل" + }, + "de": { + "prefs.structure.appearance": "Erscheinungsbild", + "prefs.structure.appearance_note": "Farben, Text und Barrierefreiheit.", + "prefs.structure.in_profile": "Im Profil", + "prefs.structure.layout": "Layout", + "prefs.structure.layout_note": "Anordnung der Fensterbereiche.", + "prefs.structure.look": "Ansicht", + "prefs.structure.measure_pointer": "Messen und Zeiger", + "prefs.structure.mouse3d": "3D-Maus", + "prefs.structure.mouse3d_note": "SpaceMouse und SpaceNavigator.", + "prefs.structure.navigation_note": "Maus und Trackpad. Die 3D-Maus hat eine eigene Seite.", + "prefs.structure.profile": "Profil", + "prefs.structure.profile_edited": "Seit dem Speichern geändert", + "prefs.structure.profile_hover": "Wird in Einstellungsprofilen gespeichert", + "prefs.structure.scale_percent": "{percent} %", + "prefs.structure.sketch": "Skizze", + "prefs.structure.tools": "Werkzeuge", + "prefs.structure.tools_note": "Verhalten der Modellierungswerkzeuge.", + "prefs.structure.work": "Arbeit" + }, + "en": { + "prefs.structure.appearance": "Appearance", + "prefs.structure.appearance_note": "Colors, text and accessibility.", + "prefs.structure.in_profile": "In profile", + "prefs.structure.layout": "Layout", + "prefs.structure.layout_note": "Where the parts of the window sit.", + "prefs.structure.look": "Look", + "prefs.structure.measure_pointer": "Measure and pointer", + "prefs.structure.mouse3d": "3D mouse", + "prefs.structure.mouse3d_note": "SpaceMouse and SpaceNavigator.", + "prefs.structure.navigation_note": "Mouse and trackpad. The 3D mouse has its own page.", + "prefs.structure.profile": "Profile", + "prefs.structure.profile_edited": "Changed since saved", + "prefs.structure.profile_hover": "Saved in settings profiles", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "Sketch", + "prefs.structure.tools": "Tools", + "prefs.structure.tools_note": "How modeling tools behave.", + "prefs.structure.work": "Work" + }, + "en-GB": { + "prefs.structure.appearance_note": "Colours, text and accessibility.", + "prefs.structure.tools_note": "How modelling tools behave." + }, + "fi": { + "prefs.structure.scale_percent": "{percent} %" + }, + "fr": { + "prefs.structure.scale_percent": "{percent} %" + }, + "he": { + "prefs.structure.appearance": "מראה", + "prefs.structure.appearance_note": "צבעים, טקסט ונגישות.", + "prefs.structure.in_profile": "כלול בפרופיל", + "prefs.structure.layout": "פריסה", + "prefs.structure.layout_note": "מיקום חלקי החלון.", + "prefs.structure.look": "מראה", + "prefs.structure.measure_pointer": "מדידה ומצביע", + "prefs.structure.mouse3d": "עכבר תלת־ממדי", + "prefs.structure.mouse3d_note": "SpaceMouse ו־SpaceNavigator.", + "prefs.structure.navigation_note": "עכבר ומשטח מגע. לעכבר התלת־ממדי יש עמוד משלו.", + "prefs.structure.profile": "פרופיל", + "prefs.structure.profile_edited": "השתנה מאז השמירה", + "prefs.structure.profile_hover": "נשמר בפרופילי הגדרות", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "סקיצה", + "prefs.structure.tools": "כלים", + "prefs.structure.tools_note": "אופן הפעולה של כלי המידול.", + "prefs.structure.work": "עבודה" + }, + "ja": { + "prefs.structure.appearance": "外観", + "prefs.structure.appearance_note": "色、文字、アクセシビリティ。", + "prefs.structure.in_profile": "プロファイルに保存", + "prefs.structure.layout": "レイアウト", + "prefs.structure.layout_note": "ウィンドウ内の配置。", + "prefs.structure.look": "表示", + "prefs.structure.measure_pointer": "計測とポインター", + "prefs.structure.mouse3d": "3Dマウス", + "prefs.structure.mouse3d_note": "SpaceMouse と SpaceNavigator。", + "prefs.structure.navigation_note": "マウスとトラックパッド。3Dマウスは専用ページにあります。", + "prefs.structure.profile": "プロファイル", + "prefs.structure.profile_edited": "保存後に変更あり", + "prefs.structure.profile_hover": "設定プロファイルに保存されます", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "スケッチ", + "prefs.structure.tools": "ツール", + "prefs.structure.tools_note": "モデリングツールの動作。", + "prefs.structure.work": "作業" + }, + "ko": { + "prefs.structure.appearance": "모양", + "prefs.structure.appearance_note": "색상, 텍스트 및 접근성.", + "prefs.structure.in_profile": "프로필에 포함", + "prefs.structure.layout": "레이아웃", + "prefs.structure.layout_note": "창 구성 요소의 위치.", + "prefs.structure.look": "보기", + "prefs.structure.measure_pointer": "측정 및 포인터", + "prefs.structure.mouse3d": "3D 마우스", + "prefs.structure.mouse3d_note": "SpaceMouse 및 SpaceNavigator.", + "prefs.structure.navigation_note": "마우스와 트랙패드. 3D 마우스는 별도 페이지에 있습니다.", + "prefs.structure.profile": "프로필", + "prefs.structure.profile_edited": "저장 후 변경됨", + "prefs.structure.profile_hover": "설정 프로필에 저장됨", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "스케치", + "prefs.structure.tools": "도구", + "prefs.structure.tools_note": "모델링 도구의 동작.", + "prefs.structure.work": "작업" + }, + "tr": { + "prefs.structure.scale_percent": "%{percent}" + }, + "vi": { + "prefs.structure.appearance": "Giao diện", + "prefs.structure.appearance_note": "Màu sắc, văn bản và khả năng tiếp cận.", + "prefs.structure.in_profile": "Trong hồ sơ", + "prefs.structure.layout": "Bố cục", + "prefs.structure.layout_note": "Vị trí các phần của cửa sổ.", + "prefs.structure.look": "Hiển thị", + "prefs.structure.measure_pointer": "Đo lường và con trỏ", + "prefs.structure.mouse3d": "Chuột 3D", + "prefs.structure.mouse3d_note": "SpaceMouse và SpaceNavigator.", + "prefs.structure.navigation_note": "Chuột và bàn di chuột. Chuột 3D có trang riêng.", + "prefs.structure.profile": "Hồ sơ", + "prefs.structure.profile_edited": "Đã thay đổi kể từ lần lưu", + "prefs.structure.profile_hover": "Được lưu trong hồ sơ cài đặt", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "Phác thảo", + "prefs.structure.tools": "Công cụ", + "prefs.structure.tools_note": "Cách các công cụ dựng mô hình hoạt động.", + "prefs.structure.work": "Công việc" + }, + "zh": { + "prefs.structure.appearance": "外观", + "prefs.structure.appearance_note": "颜色、文字和无障碍。", + "prefs.structure.in_profile": "包含在配置中", + "prefs.structure.layout": "布局", + "prefs.structure.layout_note": "窗口各部分的位置。", + "prefs.structure.look": "外观", + "prefs.structure.measure_pointer": "测量和指针", + "prefs.structure.mouse3d": "3D 鼠标", + "prefs.structure.mouse3d_note": "SpaceMouse 和 SpaceNavigator。", + "prefs.structure.navigation_note": "鼠标和触控板。3D 鼠标有单独的页面。", + "prefs.structure.profile": "配置", + "prefs.structure.profile_edited": "保存后已更改", + "prefs.structure.profile_hover": "保存在设置配置中", + "prefs.structure.scale_percent": "{percent}%", + "prefs.structure.sketch": "草图", + "prefs.structure.tools": "工具", + "prefs.structure.tools_note": "建模工具的行为。", + "prefs.structure.work": "工作" + } +} diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rs index d1a94f2a0..fd264d006 100644 --- a/crates/ui-egui/src/agent_chat/panel.rs +++ b/crates/ui-egui/src/agent_chat/panel.rs @@ -1070,7 +1070,7 @@ fn switcher(app: &mut SolveApp, ui: &mut egui::Ui) { add = true; } if ui_kit::list_picker(ui, "settings", tr("ui.ai_settings"), false).clicked() { - crate::prefs::open_at(app, crate::prefs::PAGE_AI); + crate::prefs::open_at(app, crate::prefs::PAGE_ASSISTANT); } }) }) @@ -1808,7 +1808,7 @@ fn conversation(app: &mut SolveApp, ui: &mut egui::Ui) { if agents::entries(app).is_empty() && app.agent_chat.detecting.is_none() { ui_kit::assistant_empty(ui, tr("ui.agent_chat_setup_title"), tr("ui.agent_chat_setup_body"), |ui| { if ui_kit::primary_button(ui, tr("ui.agent_chat_open_settings")).clicked() { - crate::prefs::open_at(app, crate::prefs::PAGE_AI); + crate::prefs::open_at(app, crate::prefs::PAGE_ASSISTANT); } }); } else { diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rs index 8b406642f..98527212b 100644 --- a/crates/ui-egui/src/agent_chat/settings.rs +++ b/crates/ui-egui/src/agent_chat/settings.rs @@ -321,7 +321,7 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) { if !cfg!(target_arch = "wasm32") && app.preferences.ai_features { #[cfg(not(target_arch = "wasm32"))] { - let browsing = !crate::prefs_search::querying(ui) || app.prefs_window.section == crate::prefs::PAGE_AI; + let browsing = !crate::prefs_search::querying(ui) || app.prefs_window.section == crate::prefs::PAGE_ASSISTANT; if browsing && app.agent_chat.detection.is_none() && app.agent_chat.detecting.is_none() { refresh(app, &ui.ctx().clone()); } diff --git a/crates/ui-egui/src/hole_place_ui_tests.rs b/crates/ui-egui/src/hole_place_ui_tests.rs index 771842b8c..9f3acacb5 100644 --- a/crates/ui-egui/src/hole_place_ui_tests.rs +++ b/crates/ui-egui/src/hole_place_ui_tests.rs @@ -328,11 +328,11 @@ fn tapped_thread_depth_field_keeps_focus_and_typing_separate_from_acceptance() { assert_eq!(h.app.session.doc.to_json(), original, "Cancel preserves the accepted design"); } -/// The upstream Preferences split must retain both Hole controls on Design. +/// The Preferences split must retain both Hole controls on Tools. #[test] fn hole_design_preferences_keep_both_controls_and_cancel_after_page_split() { let mut h = Harness::new(); - h.call("ui.prefs", json!({"language":"en", "open":"Design"})); + h.call("ui.prefs", json!({"language":"en", "open":"Tools"})); let page = rect_of("prefs:page_body").unwrap(); for label in ["Snap to face and edge centers", "Move holes by clicking or dragging"] { let mut point = None; @@ -353,7 +353,7 @@ fn hole_design_preferences_keep_both_controls_and_cancel_after_page_split() { h.call("ui.scroll", json!({"x":page.center().x,"y":page.center().y,"delta":-100})); h.frames(12); } - let p = point.unwrap_or_else(|| panic!("Hole preference missing from Design: {label}")); + let p = point.unwrap_or_else(|| panic!("Hole preference missing from Tools: {label}")); h.call("ui.click", json!({"x":p.x,"y":p.y})); } assert!(h.app.preferences.hole_snaps && h.app.preferences.hole_moves); diff --git a/crates/ui-egui/src/measurement_ui_tests.rs b/crates/ui-egui/src/measurement_ui_tests.rs index 2008e5bc0..c893c8157 100644 --- a/crates/ui-egui/src/measurement_ui_tests.rs +++ b/crates/ui-egui/src/measurement_ui_tests.rs @@ -224,7 +224,7 @@ fn measurement_axis_distances_can_be_disabled_saved_and_restored_in_preferences( assert!(serde_json::from_value::(json!({})).unwrap().measure_axis_distances, "existing settings get the default-on option"); let mut h = vertex_measurement([0., 0., 0.], [-3., 4., -12.]); let measurement = result(&h).clone(); - h.call("ui.prefs", json!({"open":"Graphics"})); + h.call("ui.prefs", json!({"open":"Tools"})); // The kit's 24 pt rows scroll inside the bounded Preferences page. let page = crate::scenario::rect_of("prefs:page_body").unwrap(); for _ in 0..8 { @@ -248,11 +248,11 @@ fn measurement_axis_distances_can_be_disabled_saved_and_restored_in_preferences( let mut restored = crate::SolveApp::new(Default::default(), Default::default()); restored.load_prefs(&h.app.prefs()); assert!(!restored.preferences.measure_axis_distances, "disabled preference survives restart"); - h.call("ui.prefs", json!({"open":"Graphics","measure_axis_distances":true})); + h.call("ui.prefs", json!({"open":"Tools","measure_axis_distances":true})); assert!(crate::scenario::handle_at("measure:label:x").is_some()); h.call("ui.prefs", json!({"button":"cancel"})); assert!(!h.app.preferences.measure_axis_distances, "Cancel restores the saved choice"); - h.call("ui.prefs", json!({"open":"Graphics"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.measure_axis_distances); h.call("ui.prefs", json!({"button":"apply"})); diff --git a/crates/ui-egui/src/navigation_bar_tests.rs b/crates/ui-egui/src/navigation_bar_tests.rs index 9dbaf8d94..dbccc573a 100644 --- a/crates/ui-egui/src/navigation_bar_tests.rs +++ b/crates/ui-egui/src/navigation_bar_tests.rs @@ -471,7 +471,7 @@ fn navigation_context_menus_customise_hide_reset_and_remove() { match action { "customise" => { assert!(h.app.prefs_window.open); - assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_INTERFACE); + assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_LAYOUT); assert!(crate::scenario::rect_of("prefs:navbar:preview").is_some()); } "hide" => assert!(!h.app.ui.show_navigation_bar), diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index 8d03cdf38..a4dcb0a95 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -28,6 +28,7 @@ mod interface; mod navbar; mod navigation; mod sketch; +mod tools; use crate::SolveApp; use crate::theme::Tokens; @@ -285,68 +286,110 @@ pub fn choose_nav_preset(prefs: &mut Prefs, preset: &NavPreset) { } } /// Stable control-channel names; presentation labels may be shorter. -pub const PAGES: &[&str] = &["General", "Interface", "Design", "Navigation", "Keyboard Shortcuts", "Sketch", "Graphics", "AI", "Plugins"]; +pub const PAGES: &[&str] = + &["General", "Appearance", "Layout", "Graphics", "Design", "Sketch", "Tools", "Navigation", "3D mouse", "Shortcuts", "Assistant", "Plugins"]; pub const PAGE_GENERAL: usize = 0; -pub const PAGE_INTERFACE: usize = 1; -pub const PAGE_DESIGN: usize = 2; -pub const PAGE_NAVIGATION: usize = 3; -pub const PAGE_SHORTCUTS: usize = 4; +pub const PAGE_APPEARANCE: usize = 1; +pub const PAGE_LAYOUT: usize = 2; +pub const PAGE_GRAPHICS: usize = 3; +pub const PAGE_DESIGN: usize = 4; pub const PAGE_SKETCH: usize = 5; -pub const PAGE_GRAPHICS: usize = 6; -pub const PAGE_AI: usize = 7; -pub const PAGE_PLUGINS: usize = 8; +pub const PAGE_TOOLS: usize = 6; +pub const PAGE_NAVIGATION: usize = 7; +pub const PAGE_MOUSE3D: usize = 8; +pub const PAGE_SHORTCUTS: usize = 9; +pub const PAGE_ASSISTANT: usize = 10; +pub const PAGE_PLUGINS: usize = 11; /// What Preferences accepts for `parameter_list_rows`: `parameters.complete` answers at most 200. pub const PARAMETER_LIST_ROWS: std::ops::RangeInclusive = 5..=200; const WINDOW_PAGES: &[ui_kit::WindowPage] = &[ - ui_kit::WindowPage { icon: "settings", label: "ui.general", group: None, handle: "prefs:page:General", scroll: true, draw: window_page::<0> }, + ui_kit::WindowPage { + icon: "settings", + label: "ui.general", + group: None, + handle: "prefs:page:General", + scroll: true, + draw: window_page::, + }, ui_kit::WindowPage { icon: "settings_palette", - label: "prefs.interface", - group: None, - handle: "prefs:page:Interface", + label: "prefs.structure.appearance", + group: Some("prefs.structure.look"), + handle: "prefs:page:Appearance", scroll: true, - draw: window_page::<1>, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "settings_monitor", + label: "prefs.structure.layout", + group: None, + handle: "prefs:page:Layout", + scroll: true, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "settings_monitor", + label: "ui.graphics", + group: None, + handle: "prefs:page:Graphics", + scroll: true, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "ws_design", + label: "ui.design", + group: Some("prefs.structure.work"), + handle: "prefs:page:Design", + scroll: true, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "sketch", + label: "prefs.structure.sketch", + group: None, + handle: "prefs:page:Sketch", + scroll: true, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "settings", + label: "prefs.structure.tools", + group: None, + handle: "prefs:page:Tools", + scroll: true, + draw: window_page::, }, - ui_kit::WindowPage { icon: "ws_design", label: "ui.design", group: None, handle: "prefs:page:Design", scroll: true, draw: window_page::<2> }, ui_kit::WindowPage { icon: "settings_mouse", label: "ui.navigation", group: Some("prefs.input"), handle: "prefs:page:Navigation", scroll: true, - draw: window_page::<3>, + draw: window_page::, + }, + ui_kit::WindowPage { + icon: "settings_mouse", + label: "prefs.structure.mouse3d", + group: None, + handle: "prefs:page:3D mouse", + scroll: true, + draw: window_page::, }, ui_kit::WindowPage { icon: "settings_keyboard", label: "prefs.shortcuts", group: None, - handle: "prefs:page:Keyboard Shortcuts", + handle: "prefs:page:Shortcuts", scroll: false, - draw: window_page::<4>, - }, - ui_kit::WindowPage { - icon: "sketch", - label: "prefs.sketch_selection", - group: None, - handle: "prefs:page:Sketch", - scroll: true, - draw: window_page::<5>, - }, - ui_kit::WindowPage { - icon: "settings_monitor", - label: "ui.graphics", - group: Some("prefs.display"), - handle: "prefs:page:Graphics", - scroll: true, - draw: window_page::<6>, + draw: window_page::, }, ui_kit::WindowPage { icon: "assistant", label: "prefs.assistant", group: Some("prefs.extend"), - handle: "prefs:page:AI", + handle: "prefs:page:Assistant", scroll: true, - draw: window_page::<7>, + draw: window_page::, }, ui_kit::WindowPage { icon: "settings_plug", @@ -354,10 +397,30 @@ const WINDOW_PAGES: &[ui_kit::WindowPage] = &[ group: None, handle: "prefs:page:Plugins", scroll: true, - draw: window_page::<8>, + draw: window_page::, }, ]; +/// Former page names remain usable through both ui.prefs and scenario handles. +const PAGE_ALIASES: &[(&str, usize)] = &[ + ("AI", PAGE_ASSISTANT), + ("Interface", PAGE_APPEARANCE), + ("Interface/navigation bar", PAGE_LAYOUT), + ("Keyboard Shortcuts", PAGE_SHORTCUTS), + ("Selection", PAGE_SKETCH), + ("Sketch & selection", PAGE_SKETCH), + ("Sketch and selection", PAGE_SKETCH), +]; + +fn page_path(index: usize) -> String { + let Some(page) = WINDOW_PAGES.get(index) else { return String::new() }; + let group = WINDOW_PAGES.get(..=index).and_then(|pages| pages.iter().rev().find_map(|page| page.group)); + match group { + Some(group) => format!("{} > {}", crate::i18n::tr(group), crate::i18n::tr(page.label)), + None => crate::i18n::tr(page.label).to_owned(), + } +} + fn search_header(ui: &mut egui::Ui, app: &mut SolveApp) { let typed = drive_search(ui, app); let (field, _) = @@ -471,8 +534,12 @@ fn clear_search(app: &mut SolveApp) { } fn window_page(ui: &mut egui::Ui, app: &mut SolveApp) { - if let Some(rect) = crate::scenario::rect_of("prefs:page:Sketch") { - crate::scenario::publish_target("prefs:page:Selection", rect); + for (alias, index) in PAGE_ALIASES { + if let Some(page) = WINDOW_PAGES.get(*index) + && let Some(rect) = crate::scenario::rect_of(page.handle) + { + crate::scenario::publish_target(&format!("prefs:page:{alias}"), rect); + } } if let Some(page) = app.prefs_window.land_on.take() { if app.prefs_window.section != page { @@ -913,7 +980,7 @@ preference_settings! { /// Show the radial ring and enable hold/flick gestures for viewport context menus. radial_context_menu: bool = false, PAGE_NAVIGATION => check("Radial context menu"); /// Work on the model directly in the viewport (pull a face to extrude or cut); off by default. - direct_interaction: bool = false, PAGE_NAVIGATION => check("Direct interaction", "Work on the model directly in the viewport. Press a flat face or a profile and pull: up extrudes, down into a body cuts, and sideways movement sets the step size"); + direct_interaction: bool = false, PAGE_TOOLS => check("Direct interaction", "Work on the model directly in the viewport. Press a flat face or a profile and pull: up extrudes, down into a body cuts, and sideways movement sets the step size"); /// Mouse gestures: a ring of tools on the right button. mouse_gestures: crate::mouse_gesture::Config = Default::default(), PAGE_NAVIGATION; /// The wheel zooms out when turned forward. @@ -925,37 +992,37 @@ preference_settings! { /// read, so an existing choice survives the upgrade; this version only writes `false`. orbit_cursor: bool = false, PAGE_NAVIGATION; /// Whether a connected 3D mouse moves the view. - space_mouse_enabled: bool = true, PAGE_NAVIGATION => check("Navigate with the 3D mouse"); + space_mouse_enabled: bool = true, PAGE_MOUSE3D => check("Navigate with the 3D mouse"); /// Whether a picture of the connected 3D mouse, moving as it does, sits in the 3D view's lower /// left corner. Off by default. - space_mouse_in_view: bool = false, PAGE_NAVIGATION => check_id("ui.3d_mouse_show_in_view"); + space_mouse_in_view: bool = false, PAGE_MOUSE3D => check_id("ui.3d_mouse_show_in_view"); /// 3D mouse orbit: traced (on) turns the view around the model in the middle of the view when /// the turn begins (else the middle of the bodies in view), marked by a faint ball; classic /// (off, the default) turns it around the view's centre, as it did before. - space_mouse_model_pivot: bool = false, PAGE_NAVIGATION; + space_mouse_model_pivot: bool = false, PAGE_MOUSE3D; /// Whether the 3D mouse also turns the view while a sketch is edited and still seen square on /// (#2227), as the mouse can. Off (the default): the cap pans and zooms a square-on sketch and /// turns it only after the view is tilted away from it. - space_mouse_sketch_orbit: bool = false, PAGE_NAVIGATION => check_id("ui.3d_mouse_sketch_orbit"); + space_mouse_sketch_orbit: bool = false, PAGE_MOUSE3D => check_id("ui.3d_mouse_sketch_orbit"); /// Speed multiplier for 3D mouse navigation. - space_mouse_speed: f32 = 1.0, PAGE_NAVIGATION; + space_mouse_speed: f32 = 1.0, PAGE_MOUSE3D; /// Per physical axis of the cap (push X, Y, Z, then tilt X, Y, Z), whether it moves the view /// the other way. - space_mouse_reverse: [bool; 6] = [false; 6], PAGE_NAVIGATION; + space_mouse_reverse: [bool; 6] = [false; 6], PAGE_MOUSE3D; /// Per physical axis of the cap, a multiplier on top of `space_mouse_speed`; 0 switches it off. - space_mouse_axis_speed: [f32; 6] = [1.0; 6], PAGE_NAVIGATION; + space_mouse_axis_speed: [f32; 6] = [1.0; 6], PAGE_MOUSE3D; /// Per physical axis of the cap, which of its motions drives it (`space_mouse::reassigned`), /// applied after calibration; each motion drives exactly one axis. - space_mouse_axis_source: [usize; 6] = crate::space_mouse::SAME_AXES, PAGE_NAVIGATION; + space_mouse_axis_source: [usize; 6] = crate::space_mouse::SAME_AXES, PAGE_MOUSE3D; /// Which program reads the 3D mouse when spacenavd and the device itself are both there (Linux). - space_mouse_driver: SpaceMouseDriver = SpaceMouseDriver::default(), PAGE_NAVIGATION; + space_mouse_driver: SpaceMouseDriver = SpaceMouseDriver::default(), PAGE_MOUSE3D; /// Where the 3D mouse picture sits in the 3D view, when it is shown there (`space_mouse_in_view`). - space_mouse_ghost_position: SpaceMouseGhost = SpaceMouseGhost::default(), PAGE_NAVIGATION; + space_mouse_ghost_position: SpaceMouseGhost = SpaceMouseGhost::default(), PAGE_MOUSE3D; /// The user turned the calibration offer off for good ("Never show again"). Unlike closing the /// card, which only records that device, this stops every offer, for every device: it is one flag, /// not kept per device key. Like the settings beside it, the dialog's Restore Defaults puts it back /// (the 3D mouse section's own restore leaves it). - space_mouse_offer_never: bool = false, PAGE_NAVIGATION; + space_mouse_offer_never: bool = false, PAGE_MOUSE3D; /// Per 3D mouse (`space_mouse::Input::device`), the calibration that puts its axes on /// 3Dconnexion's. A device without one is read as it reports. Page resets keep calibrations. #[serde(deserialize_with = "calibrations_that_read")] @@ -974,9 +1041,9 @@ preference_settings! { /// A device's own app on this computer moves the view (the navigation bridge, docs/3d-mouse.md): /// the desktop app connects to it on `nav_bridge_port`. Off unless asked for, so the app /// doesn't connect to whatever else listens on that port. - nav_bridge_enabled: bool = false, PAGE_NAVIGATION; + nav_bridge_enabled: bool = false, PAGE_MOUSE3D; /// The loopback port the device app listens on (0: none). - nav_bridge_port: u16 = 8765, PAGE_NAVIGATION; + nav_bridge_port: u16 = 8765, PAGE_MOUSE3D; /// Anti-aliasing samples (applies on restart). msaa: u32 = 4, PAGE_GRAPHICS; /// Share shading and Continuity; false preserves their independent legacy behavior. @@ -1022,7 +1089,7 @@ preference_settings! { /// Off by default; View ▸ View angles and `view.angle_readout` turn it on. show_view_angles: bool = false, PAGE_GRAPHICS; /// Show world X/Y/Z component dimensions beside the total distance in Measure. - measure_axis_distances: bool = true, PAGE_GRAPHICS => check_id("settings.measure_axis_distances"); + measure_axis_distances: bool = true, PAGE_TOOLS => check_id("settings.measure_axis_distances"); /// Perspective view's vertical field of view in radians (#5364), 15° to 90°. The view reads a /// saved value outside that range as the default ([`perspective_fov`]). perspective_fov: f64 = PERSPECTIVE_FOV, PAGE_GRAPHICS, accept(15f64.to_radians()..=90f64.to_radians()); @@ -1064,112 +1131,112 @@ preference_settings! { /// The largest design file opened or saved, in MB (#4086): from the default (256) up to 16 GB. max_design_file_mb: u64 = DEFAULT_DESIGN_MB, PAGE_GENERAL; /// Explicit assembly Move uses joint handles; off keeps the previous Move panel. - assembly_move_handles: bool = true, PAGE_DESIGN => check_id("joint_move.use_handles"); + assembly_move_handles: bool = true, PAGE_TOOLS => check_id("joint_move.use_handles"); /// Degrees per step near the assembly Move ring. - joint_rotation_coarse: f64 = 10.0, PAGE_DESIGN; + joint_rotation_coarse: f64 = 10.0, PAGE_TOOLS; /// Degrees per step after pulling the cursor outside the precision guide. - joint_rotation_fine: f64 = 0.1, PAGE_DESIGN; + joint_rotation_fine: f64 = 0.1, PAGE_TOOLS; /// `dark`, `light` or `system` (follow the operating system), or a theme file's id: a /// built-in one (`gruvbox-dark`, …) or one of `custom_themes` (#2255). - theme: String = "dark".into(), PAGE_INTERFACE; + theme: String = "dark".into(), PAGE_APPEARANCE; /// The 3D view's colours: the theme's own, or the Light or Dark theme's whatever the window /// uses (#4146). - viewport_theme: crate::theme::ViewportTheme = crate::theme::ViewportTheme::Theme, PAGE_INTERFACE; + viewport_theme: crate::theme::ViewportTheme = crate::theme::ViewportTheme::Theme, PAGE_APPEARANCE; /// The 3D view's background, one colour for the whole application (#7688), or `None` (the /// default) for the theme's gradient. - viewport_background: Option<[u8; 3]> = None, PAGE_INTERFACE; + viewport_background: Option<[u8; 3]> = None, PAGE_APPEARANCE; /// The application bar's logo in the theme's accent instead of the theme's logo colours. - logo_accent: bool = false, PAGE_INTERFACE; + logo_accent: bool = false, PAGE_APPEARANCE; /// Imported theme files (`theme_files`), kept here so they also work in the browser. #[serde(deserialize_with = "themes_that_read")] custom_themes: Vec = Vec::new(); /// Desktop: a `solidcraft-theme/1` file another tool writes, followed as the theme and /// reloaded when it changes (#7573). Empty (the default): no file is followed. - theme_follow: String = String::new(), PAGE_INTERFACE; + theme_follow: String = String::new(), PAGE_APPEARANCE; /// Per-theme overrides. Raw JSON retains entries from newer or hand-edited settings. - theme_options: BTreeMap> = BTreeMap::new(), PAGE_INTERFACE; + theme_options: BTreeMap> = BTreeMap::new(), PAGE_APPEARANCE; /// Interface language: a registered locale ID, or `system` to follow the system's language /// on every start (#10138). A saved language keeps winning, so existing users don't change. language: String = "system".into(), 0; /// Shared workspace composition; system windows and popups retain their purpose. - layout: crate::shell::LayoutMode = Default::default(), PAGE_INTERFACE; + layout: crate::shell::LayoutMode = Default::default(), PAGE_LAYOUT; /// Ordered view controls and their appearance. #[serde(default)] - navigation_bar: crate::navigation_bar::NavigationBar = Default::default(), PAGE_INTERFACE; + navigation_bar: crate::navigation_bar::NavigationBar = Default::default(), PAGE_LAYOUT; /// Show command names beneath ribbon icons, independently of workspace layout. - ribbon_labels: bool = true, PAGE_INTERFACE; + ribbon_labels: bool = true, PAGE_LAYOUT; /// Show engine-derived persistent selection in the ribbon; off retains neutral buttons. - persistent_ribbon_pressed: bool = true, PAGE_INTERFACE => check_id("prefs.persistent_ribbon_pressed"); - viewport_analysis_status: bool = true, PAGE_INTERFACE => check_id("prefs.viewport_analysis_status"); - viewport_section_status: bool = true, PAGE_INTERFACE => check_id("prefs.viewport_section_status"); - viewport_status_details: bool = true, PAGE_INTERFACE => check_id("prefs.viewport_status_details"); - viewport_status_summary: bool = true, PAGE_INTERFACE => check_id("prefs.viewport_status_summary"); + persistent_ribbon_pressed: bool = true, PAGE_LAYOUT => check_id("prefs.persistent_ribbon_pressed"); + viewport_analysis_status: bool = true, PAGE_GRAPHICS => check_id("prefs.viewport_analysis_status"); + viewport_section_status: bool = true, PAGE_GRAPHICS => check_id("prefs.viewport_section_status"); + viewport_status_details: bool = true, PAGE_GRAPHICS => check_id("prefs.viewport_status_details"); + viewport_status_summary: bool = true, PAGE_GRAPHICS => check_id("prefs.viewport_status_summary"); /// Keep the SKETCH tab in the ribbon, right after MODEL, while no sketch is open; its drawing /// tools then start a sketch first (#7904). - sketch_tab_always: bool = false, PAGE_INTERFACE => check_id("prefs.sketch_tab_always"); + sketch_tab_always: bool = false, PAGE_LAYOUT => check_id("prefs.sketch_tab_always"); /// Each design tab keeps its open dialog or tool, and its toolbar tab, while another design is /// shown, and has them back when it is shown again (#9360). Off by default: a switch cancels /// them and shows the MODEL tab. - keep_work_on_tab_switch: bool = false, PAGE_INTERFACE => check_id("prefs.keep_work_on_tab_switch"); + keep_work_on_tab_switch: bool = false, PAGE_LAYOUT => check_id("prefs.keep_work_on_tab_switch"); /// Hovering a result in Search commands shows the command's place in the ribbon: its tab, /// its button or its row in a section's drop-down (#7287). A command started from the search /// blinks there, and a running command that sits in a drop-down marks its section label. Off /// by default: the ribbon stays as it was. - ribbon_reveal: bool = false, PAGE_INTERFACE => check_id("prefs.ribbon_reveal"); + ribbon_reveal: bool = false, PAGE_LAYOUT => check_id("prefs.ribbon_reveal"); /// Where a dialog's OK and Cancel sit: under its inputs (the default) or in its title row (#6708). - dialog_buttons: crate::ui_kit::DialogButtons = Default::default(), PAGE_INTERFACE; + dialog_buttons: crate::ui_kit::DialogButtons = Default::default(), PAGE_LAYOUT; /// 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; + toast_place: crate::viewport::ToastPlace = Default::default(), PAGE_LAYOUT; /// Toolbar tabs hidden by the person. An empty list keeps every existing tab visible. - hidden_toolbar_tabs: Vec = Vec::new(), PAGE_INTERFACE; + hidden_toolbar_tabs: Vec = Vec::new(), PAGE_LAYOUT; /// Show the ribbon's panel drop-downs as a grid of large icons, their names in the tooltips, /// instead of a list of small icons with names (#4739). - ribbon_icon_grid: bool = false, PAGE_INTERFACE; + ribbon_icon_grid: bool = false, PAGE_LAYOUT; /// Leave the commands the ribbon shows as buttons (pinned ones) out of its panel drop-downs, /// which then list only the rest (#4739). - ribbon_menus_skip_pinned: bool = false, PAGE_INTERFACE => check_tr("ui.ribbon_menus_skip_pinned"); + ribbon_menus_skip_pinned: bool = false, PAGE_LAYOUT => check_tr("ui.ribbon_menus_skip_pinned"); /// Interface scale (1 = 100 %). - ui_scale: f32 = 1.0, PAGE_INTERFACE, accept(0.5..=2.5); + ui_scale: f32 = 1.0, PAGE_APPEARANCE, accept(0.5..=2.5); /// Interface font: an installed font family (or a font file), or empty for the built-in one /// (#1290). Menus, dialogs and labels use it; glyphs it lacks fall back as before. - ui_font: String = String::new(), PAGE_INTERFACE; + ui_font: String = String::new(), PAGE_APPEARANCE; /// While a dialog or a sketch is open, OK and Cancel in the view's top right corner, with the /// axis view moved down below them (#6709). Off by default. - view_confirm_corner: bool = false, PAGE_INTERFACE => check_id("prefs.view_confirm_corner"); + view_confirm_corner: bool = false, PAGE_LAYOUT => check_id("prefs.view_confirm_corner"); /// A thin bar along the window's bottom edge: what is being edited, the open sketch's state /// and the design's units (#7243). Off by default. - status_bar: bool = false, PAGE_INTERFACE => check_id("prefs.status_bar"); + status_bar: bool = false, PAGE_LAYOUT => check_id("prefs.status_bar"); /// The selection's length, area or distance in the view's bottom right corner (#7000). Off by /// default. - quick_measure: bool = false, PAGE_INTERFACE => check_id("prefs.quick_measure"); + quick_measure: bool = false, PAGE_GRAPHICS => check_id("prefs.quick_measure"); /// Put the feature history to the left of the browser instead of below the viewport. - timeline_left: bool = false, PAGE_INTERFACE; + timeline_left: bool = false, PAGE_LAYOUT; /// Measured outer width; the contents react to this width without a names mode. - timeline_left_width: f32 = 130.0, PAGE_INTERFACE; + timeline_left_width: f32 = 130.0, PAGE_LAYOUT; /// Share the browser column, vertically, instead of a separate left column. - timeline_under_browser: bool = false, PAGE_INTERFACE; + timeline_under_browser: bool = false, PAGE_LAYOUT; /// Compact history: the browser lists each component's features in history order with the /// marker, and neither timeline is shown. - history_in_browser: bool = false, PAGE_INTERFACE; + history_in_browser: bool = false, PAGE_LAYOUT; /// Fold the shared-column history to its header. - timeline_collapsed: bool = false, PAGE_INTERFACE; + timeline_collapsed: bool = false, PAGE_LAYOUT; /// The browser's share of the column's height when History sits under it, which the user /// drags at the seam between the two cards (#7371). - browser_share: f32 = DEFAULT_BROWSER_SHARE, PAGE_INTERFACE; + browser_share: f32 = DEFAULT_BROWSER_SHARE, PAGE_LAYOUT; /// Whether the browser beside the vertical history is collapsed to its rail. - timeline_left_browser_collapsed: bool = false, PAGE_INTERFACE; + timeline_left_browser_collapsed: bool = false, PAGE_LAYOUT; /// Whether the History at the left lists a sketch under the feature built from it. - history_sketches: HistorySketches = HistorySketches::default(), PAGE_INTERFACE; + history_sketches: HistorySketches = HistorySketches::default(), PAGE_LAYOUT; /// A Play History button in the History controls, between Previous and Next (#3688). Off /// gives the four controls History had before; right-clicking the controls toggles it too. - history_play_button: bool = true, PAGE_INTERFACE => check_id("prefs.history_play_button"); + history_play_button: bool = true, PAGE_LAYOUT => check_id("prefs.history_play_button"); /// The vertical history (left, or under the browser) starts with the active component's Bodies /// folder and the Origin, as the browser shows them (#6490). The bottom strip is unchanged. - timeline_origin_bodies: bool = false, PAGE_INTERFACE; + timeline_origin_bodies: bool = false, PAGE_LAYOUT; /// Width of the browser sidebar, which /// the user drags wider or narrower at its right edge. - browser_width: f32 = DEFAULT_BROWSER_WIDTH, PAGE_INTERFACE; + browser_width: f32 = DEFAULT_BROWSER_WIDTH, PAGE_LAYOUT; /// Render shell preference, independent of the document and Design history. render_shots_strip: bool = true; render_inspector_side: String = "right".into(); @@ -1181,23 +1248,23 @@ preference_settings! { render_library_recent: std::collections::VecDeque<(String, String)> = Default::default(); /// Draw the parts browser on a translucent card over the 3D view instead of a column of its /// own, so the workspace keeps the whole window width. - browser_float: bool = false, PAGE_INTERFACE; + browser_float: bool = false, PAGE_LAYOUT; /// The browser card folded to its header with the chevron in that header, kept from one run /// to the next like the toolbar's pins (#8692). - browser_collapsed: bool = false, PAGE_INTERFACE; + browser_collapsed: bool = false, PAGE_LAYOUT; /// Whether the browser card is always shown or kept out of sight until the pointer comes to /// it, as the navigation bar's "Hide until hovered" does (#8692). - browser_show: crate::browser::BrowserShow = Default::default(), PAGE_INTERFACE; + browser_show: crate::browser::BrowserShow = Default::default(), PAGE_LAYOUT; /// Where command dialogs open: at the view's edge, or in the left column in place of the /// browser and the History there (#6707). - dialog_place: crate::dialog_column::DialogPlace = Default::default(), PAGE_INTERFACE; + dialog_place: crate::dialog_column::DialogPlace = Default::default(), PAGE_LAYOUT; /// The names the browser, dialogs and lists show for the origin planes (#6491). - origin_plane_names: OriginPlaneNames = OriginPlaneNames::default(), PAGE_INTERFACE; + origin_plane_names: OriginPlaneNames = OriginPlaneNames::default(), PAGE_DESIGN; /// When components' bodies sit in a Bodies folder in the browser (#4217). - browser_bodies_folders: BodiesFolders = BodiesFolders::Several, PAGE_INTERFACE; + browser_bodies_folders: BodiesFolders = BodiesFolders::Several, PAGE_LAYOUT; /// Each tree row's eye between its fold arrow and its radio, as before #8718, instead of in a /// column at the rows' right end. Off by default. - browser_eye_left: bool = false, PAGE_INTERFACE => check_id("prefs.browser_eye_left"); + browser_eye_left: bool = false, PAGE_LAYOUT => check_id("prefs.browser_eye_left"); /// The wheel zooms toward the point under the cursor (else toward the view's centre). zoom_to_cursor: bool = true, PAGE_NAVIGATION => check("Zoom to the cursor", "The wheel zooms toward the point under the cursor (off: toward the view's center)"); /// Speed multiplier for wheel zoom, independent of the 3D mouse. @@ -1230,35 +1297,35 @@ preference_settings! { stand_up_unknown: StandUpUnknown = StandUpUnknown::default(), PAGE_DESIGN; /// Extrude: with a profile picked, a face, vertex or parallel plane picked off its plane /// switches the extent to To Object (off: picks only add profiles, as before). - extrude_auto_to_object: bool = false, PAGE_DESIGN => check("Extrude to a picked target", "In Extrude, with a profile picked, picking a face, vertex or parallel plane off its plane switches the extent to To Object"); + extrude_auto_to_object: bool = false, PAGE_TOOLS => check("Extrude to a picked target", "In Extrude, with a profile picked, picking a face, vertex or parallel plane off its plane switches the extent to To Object"); /// Extrude turns the view to isometric each time it opens, so the depth can be seen (#9176). /// Off (the default): the view stays as it is. - extrude_view_isometric: bool = false, PAGE_DESIGN => check_id("prefs.extrude_view_isometric"); + extrude_view_isometric: bool = false, PAGE_TOOLS => check_id("prefs.extrude_view_isometric"); /// With `extrude_view_isometric`: when Extrude closes (OK or Cancel) the view goes back to /// where it was before it turned (#9176). Off (the default): it stays isometric. - extrude_view_return: bool = false, PAGE_DESIGN => check_id("prefs.extrude_view_return"); + extrude_view_return: bool = false, PAGE_TOOLS => check_id("prefs.extrude_view_return"); /// Feature windows choose Join, New Body or Cut from what their material touches (`op_auto`, /// #6901). Off: they keep the operation they open with (Extrude its own Join or Cut), as before. - auto_operation: bool = true, PAGE_DESIGN => check_id("prefs.auto_operation"); + auto_operation: bool = true, PAGE_TOOLS => check_id("prefs.auto_operation"); /// Placing a Single hole snaps to the middle of the face and the centres of its round edges /// (`hole_place`). Off by default: a hole goes where it is clicked. - hole_snaps: bool = false, PAGE_DESIGN => check("Snap to face and edge centres"); + hole_snaps: bool = false, PAGE_TOOLS => check("Snap to face and edge centres"); /// A placed Single hole has a handle that drags it, and a pick elsewhere on a face that has a /// hole moves the hole there (`hole_place`). Off by default: a second pick on its face takes /// the hole out, and a hole is moved by taking it out and picking again. - hole_moves: bool = false, PAGE_DESIGN => check("Move holes by clicking or dragging"); + hole_moves: bool = false, PAGE_TOOLS => check("Move holes by clicking or dragging"); /// The browser's Origin folder starts hidden in designs that don't keep its eye themselves. hide_origin: bool = false, PAGE_DESIGN => check_tr("ui.hide_origin_by_default"); /// Handles on the preview of a feature placed on a face (Rest, Boss, Snap Fit): a marker that /// drags it across the model and a ring that turns it. Off by default: the feature is then placed /// by its click only, as before, and its Position input takes faces only. - placement_handles: bool = false, PAGE_DESIGN => check("Placement handles", "Handles on the preview of a Rest, Boss or Snap Fit: drag the marker to move it across the model, turn it by its ring"); + placement_handles: bool = false, PAGE_TOOLS => check("Placement handles", "Handles on the preview of a Rest, Boss or Snap Fit: drag the marker to move it across the model, turn it by its ring"); /// The files a design names (linked designs, font files) may be on any network location, for /// organisations that keep their designs on file servers. Off (the default): only on the /// servers in `network_hosts`, or one the user allows when asked (`network_prompt`). - network_locations: bool = false, PAGE_DESIGN => check_tr("prefs.network_locations"); + network_locations: bool = false, PAGE_GENERAL => check_tr("prefs.network_locations"); /// The servers the files a design names may be on ("Always allow this server"). - network_hosts: Vec = Vec::new(), PAGE_DESIGN; + network_hosts: Vec = Vec::new(), PAGE_GENERAL; /// What a middle-button double-click in the view does: `home`, `fit` or `off`. middle_double_click: String = "home".into(), PAGE_NAVIGATION; /// A view chosen on the navigator (a cube face, corner or arrow, an axis tip) also frames the @@ -1274,7 +1341,7 @@ preference_settings! { /// panels, the compass and the navigation bar, as before. home_fit_size: f32 = 1.0, PAGE_NAVIGATION, accept(0.1..=1.0); /// Colour vision mode (#778): `off`, `protan`, `deutan` or `tritan`. - color_vision: crate::theme::ColorVision = crate::theme::ColorVision::Off, PAGE_INTERFACE; + color_vision: crate::theme::ColorVision = crate::theme::ColorVision::Off, PAGE_APPEARANCE; /// Check for updates at start and once a day (docs/updates.md). check_updates: bool = true, 0; /// When the last update check ran, and the versions skipped or put off (`update::Memo`). @@ -1313,19 +1380,19 @@ preference_settings! { custom_slicers: Vec = Vec::new(); /// AI features (docs/agent-chat.md): the master switch. Off: no AI button, shortcut, menu /// entry or panel, and nothing is looked for or started. - ai_features: bool = true, PAGE_AI; + ai_features: bool = true, PAGE_ASSISTANT; /// The Assistant button in the application bar (the shortcut and View menu entry stay). - ai_toolbar_button: bool = true, PAGE_AI; + ai_toolbar_button: bool = true, PAGE_ASSISTANT; /// An agent's slow commands over the control channel (MCP) compute off the window thread, /// so the window stays live while they run (#1989, [`crate::control_job`]). Off: they run on /// the window thread, and the window waits for each, as before (the default). - agent_off_thread: bool = false, PAGE_AI; + agent_off_thread: bool = false, PAGE_ASSISTANT; /// Let AI agents connect: the localhost control channel (MCP) opens on the default port at /// start-up, unless `--control`/`SOLIDCRAFT_CONTROL_PORT` name one. Read at start-up. - agent_control: bool = true, PAGE_AI; + agent_control: bool = true, PAGE_ASSISTANT; /// Add SolidCraft's MCP server to the AI apps installed on this computer at start-up /// ([`crate::ai_connect`]); off takes the entries out again. - connect_ai_apps: bool = true, PAGE_AI; + connect_ai_apps: bool = true, PAGE_ASSISTANT; /// Agents the user added (the installed ones are found by themselves). API keys are never /// here: they live in the system keychain. agents: Vec = Vec::new(); @@ -1336,26 +1403,26 @@ preference_settings! { /// When SolidCraft starts: connect the agent started last (`agent_last`, else the one a new /// conversation starts with), and open the panel (#7009). Off by default: an agent starts /// only when a message is sent or Connect is pressed, and the panel opens when asked for. - agent_connect_at_start: bool = false, PAGE_AI; - agent_chat_open_at_start: bool = false, PAGE_AI; + agent_connect_at_start: bool = false, PAGE_ASSISTANT; + agent_chat_open_at_start: bool = false, PAGE_ASSISTANT; /// How much the agent may do without asking (`ask`, `edits`, `all`), and per agent. - ai_permissions: crate::agent_chat::agents::Mode = crate::agent_chat::agents::Mode::Edits, PAGE_AI; - agent_permissions: std::collections::BTreeMap = Default::default(), PAGE_AI; + ai_permissions: crate::agent_chat::agents::Mode = crate::agent_chat::agents::Mode::Edits, PAGE_ASSISTANT; + agent_permissions: std::collections::BTreeMap = Default::default(), PAGE_ASSISTANT; /// The model last chosen in the chat, per agent: put back when the agent offers it again. agent_models: std::collections::BTreeMap = Default::default(); /// "Always allow" answers: per agent, the tools it may use without asking. agent_always_allow: std::collections::BTreeMap> = Default::default(); /// The side the panel docks on (`left` or `right`), its width, and whether it is folded to a strip. - agent_chat_side: String = "right".into(), PAGE_AI; - agent_chat_width: f32 = 380.0, PAGE_AI; - agent_chat_minimized: bool = false, PAGE_AI; + agent_chat_side: String = "right".into(), PAGE_ASSISTANT; + agent_chat_width: f32 = 380.0, PAGE_ASSISTANT; + agent_chat_minimized: bool = false, PAGE_ASSISTANT; /// Whether the chat is in its own window instead of the side panel, and that window's place /// and size as the system last reported them (`[x, y, width, height]`, points; `x` can be /// negative or past the main screen when the window sits on another one). - agent_chat_popped: bool = false, PAGE_AI; - agent_chat_window: Option<[f32; 4]> = None, PAGE_AI; + agent_chat_popped: bool = false, PAGE_ASSISTANT; + agent_chat_window: Option<[f32; 4]> = None, PAGE_ASSISTANT; /// Changes the agent may make for one message; 0 is no limit. - agent_chat_turn_limit: u32 = crate::agent_chat::gate::DEFAULT_TURN_LIMIT, PAGE_AI; + agent_chat_turn_limit: u32 = crate::agent_chat::gate::DEFAULT_TURN_LIMIT, PAGE_ASSISTANT; // ---- Sketch / selection modifier bindings (classic defaults; alternate mapping is opt-in) ---- /// Modifier that suppresses sketch auto-snap while drawing or dragging a sketch point. @@ -1438,7 +1505,7 @@ preference_settings! { /// fixed screen size at every zoom, as before. hide_constraint_glyphs_zoomed_out: bool = true, PAGE_SKETCH => check_id("prefs.hide_constraint_glyphs_zoomed_out"); /// Drive Joints shows the moved parts' old place as a ghost (its Show ghost box, #5905). - drive_joints_ghost: bool = true, PAGE_DESIGN; + drive_joints_ghost: bool = true, PAGE_TOOLS; /// Plugin ids turned off (Preferences › Plugins). An installed plugin whose id is absent is on. disabled_plugins: std::collections::BTreeSet = std::collections::BTreeSet::new(), PAGE_PLUGINS; } @@ -1583,6 +1650,14 @@ pub fn open_at(app: &mut SolveApp, page: usize) { app.prefs_window.section = page.min(PAGES.len() - 1); } +/// The sidebar is drawn before the selected page: defer its Profiles action until that page +/// callback, and leave any search before showing General's existing profile controls. +pub(crate) fn open_profiles(app: &mut SolveApp) { + clear_search(app); + open_at(app, PAGE_GENERAL); + app.prefs_window.land_on = Some(PAGE_GENERAL); +} + /// Every setting the dialog changes, for Cancel and Restore Defaults. #[derive(Clone)] struct Snapshot { @@ -2000,14 +2075,16 @@ fn defaults(app: &mut SolveApp, page: usize) { app.autosave_minutes = 5.0; set_autosave(app); } - PAGE_INTERFACE => { + PAGE_APPEARANCE => { app.prefs_window.follow.launch = None; app.ui.dark = true; + } + PAGE_LAYOUT => { app.ui.layout = app.preferences.layout; app.ui.show_navigation_bar = true; } - PAGE_AI => app.ui.agent_cursor = Default::default(), - PAGE_NAVIGATION => app.ui.tool_cursor = false, + PAGE_ASSISTANT => app.ui.agent_cursor = Default::default(), + PAGE_TOOLS => app.ui.tool_cursor = false, PAGE_DESIGN => {} PAGE_SHORTCUTS => crate::keymap::reset(app, None), PAGE_GRAPHICS => { @@ -2471,14 +2548,23 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) { .apply_enabled(pending); let window = if capturing { window.keep_open_on_escape() } else { window }; let mut selected = app.prefs_window.section; - let (closed, action) = window.show_pages_with_header(ctx, &mut selected, WINDOW_PAGES, app, search_header, clear_search, |ui| { - if ui_kit::button(ui, crate::i18n::tr("ui.restore_defaults"), ui_kit::Button::Normal) - .on_hover_text(crate::i18n::tr("ui.reset_the_settings_on_this_page")) - .clicked() - { - button = Some("defaults"); - } - }); + let (closed, action) = window.show_pages_with_header( + ctx, + &mut selected, + WINDOW_PAGES, + app, + search_header, + clear_search, + Some((Tokens::get().control_height * 3.0, crate::settings_profiles::sidebar)), + |ui| { + if ui_kit::button(ui, crate::i18n::tr("ui.restore_defaults"), ui_kit::Button::Normal) + .on_hover_text(crate::i18n::tr("ui.reset_the_settings_on_this_page")) + .clicked() + { + button = Some("defaults"); + } + }, + ); if let Some(rect) = crate::scenario::rect_of("dialog:page_body") { crate::scenario::publish_rect("prefs:page_body", rect); } @@ -2559,19 +2645,19 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { // Paint only the pages that match. A first pass is invisible, so the 3D mouse rows and the // agent list cannot draw on top of the setting that did match. let mut keep = vec![false; WINDOW_PAGES.len()]; - for (index, item) in WINDOW_PAGES.iter().enumerate() { - crate::prefs_search::begin_page(ui, index, crate::i18n::tr(item.label)); + for (index, _) in WINDOW_PAGES.iter().enumerate() { + crate::prefs_search::begin_page(ui, index, &page_path(index)); let before = crate::prefs_search::hits(ui); let mut probe = crate::prefs_search::detached_child(ui, ("prefs-search-probe", index), true); draw_page(app, &mut probe, index, t); keep[index] = crate::prefs_search::hits(ui) > before; } crate::prefs_search::rewind_search_layout(ui); - for (index, item) in WINDOW_PAGES.iter().enumerate() { + for (index, _) in WINDOW_PAGES.iter().enumerate() { if !keep.get(index).copied().unwrap_or(false) { continue; } - crate::prefs_search::begin_page(ui, index, crate::i18n::tr(item.label)); + crate::prefs_search::begin_page(ui, index, &page_path(index)); let before = crate::prefs_search::hits(ui); let mut child = crate::prefs_search::detached_child(ui, ("prefs-search-page", index), false); draw_page(app, &mut child, index, t); @@ -2581,8 +2667,8 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { ui.label(egui::RichText::new(crate::i18n::tr("prefs.search_empty")).size(t.font_body).color(t.form_dim)); } } else { - let label = WINDOW_PAGES.get(app.prefs_window.section).map(|item| crate::i18n::tr(item.label)).unwrap_or(""); - crate::prefs_search::begin_page(ui, app.prefs_window.section, label); + let label = page_path(app.prefs_window.section); + crate::prefs_search::begin_page(ui, app.prefs_window.section, &label); draw_page(app, ui, app.prefs_window.section, t); } crate::prefs_search::store_nav(ui); @@ -2590,11 +2676,20 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { fn draw_page(app: &mut SolveApp, ui: &mut egui::Ui, index: usize, t: &Tokens) { match index { - PAGE_SHORTCUTS => crate::keymap::page(app, ui), - PAGE_AI => crate::agent_chat::settings::page(app, ui), + PAGE_SHORTCUTS => { + ui_kit::settings_heading_with_tag(ui, app.tr("prefs.shortcuts"), "", Some(crate::settings_profiles::tag)); + crate::keymap::page(app, ui); + } + PAGE_ASSISTANT => crate::agent_chat::settings::page(app, ui), PAGE_PLUGINS => crate::plugins::page(app, ui), PAGE_GENERAL => general::show(app, ui), - PAGE_INTERFACE => interface::interface(app, ui, t), + PAGE_APPEARANCE => interface::appearance(app, ui, t), + PAGE_LAYOUT => interface::layout(app, ui), + PAGE_TOOLS => tools::show(app, ui), + PAGE_MOUSE3D => { + ui_kit::settings_heading(ui, app.tr("prefs.structure.mouse3d"), app.tr("prefs.structure.mouse3d_note")); + space_mouse_section(app, ui); + } PAGE_DESIGN => design::show(app, ui), PAGE_NAVIGATION => navigation::show(app, ui, t), PAGE_GRAPHICS => graphics::show(app, ui), @@ -2604,16 +2699,13 @@ fn draw_page(app: &mut SolveApp, ui: &mut egui::Ui, index: usize, t: &Tokens) { } fn page_index(name: &str) -> Option { - match name.to_ascii_lowercase().as_str() { - "selection" | "sketch & selection" | "sketch and selection" => Some(PAGE_SKETCH), - "interface/navigation bar" => Some(PAGE_INTERFACE), - "assistant" => Some(PAGE_AI), - "shortcuts" => Some(PAGE_SHORTCUTS), - _ => PAGES.iter().position(|x| x.eq_ignore_ascii_case(name)), - } + PAGES + .iter() + .position(|page| page.eq_ignore_ascii_case(name)) + .or_else(|| PAGE_ALIASES.iter().find_map(|(alias, page)| alias.eq_ignore_ascii_case(name).then_some(*page))) } -/// The 3D mouse's settings under Navigation, drawn with the same settings kit as the sections above +/// The 3D mouse page's settings, drawn with the same settings kit as the sections above /// it: whether it moves the view and shows in it, where the picture goes, its speed, the driver and /// calibration, each axis, the picture with its dead zone, and what its buttons do. A section like the /// others, so it folds with its header and stays as the user last left it. @@ -2621,6 +2713,30 @@ fn space_mouse_section(app: &mut SolveApp, ui: &mut egui::Ui) { ui_kit::settings_section(ui, "space_mouse", crate::i18n::tr("ui.3d_mouse_section"), |ui| space_mouse_rows(app, ui)); } +/// A device's own app on this computer driving the view (the navigation bridge): on or off, its +/// port, and whether an app is connected. Part of the 3D mouse section (`space_mouse_rows`). +fn nav_bridge(app: &mut SolveApp, ui: &mut egui::Ui) { + let (label, tip, port) = (app.tr("ui.nav_bridge").to_owned(), app.tr("ui.nav_bridge_tip").to_owned(), app.tr("ui.nav_bridge_port").to_owned()); + let status = match (&app.space_mouse.bridge, app.preferences.nav_bridge_enabled) { + (_, false) => None, + (Some(name), true) => Some((format!("{} · {name}", app.tr("ui.nav_bridge_connected")), false)), + (None, true) => Some((app.tr("ui.nav_bridge_waiting").to_owned(), true)), + }; + ui.horizontal_wrapped(|ui| { + ui_kit::checkbox(ui, &label, &mut app.preferences.nav_bridge_enabled).on_hover_text(&tip); + if let Some((status, waiting)) = &status { + ui_kit::settings_badge(ui, status, *waiting); + } + }); + ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| { + ui_kit::row(ui, &port, |ui| { + ui.add_enabled_ui(app.preferences.nav_bridge_enabled, |ui| { + ui_kit::number_field(ui, &mut app.preferences.nav_bridge_port, 1..=u16::MAX, 1.0, ""); + }); + }); + }); +} + /// The label column the Navigation page's forms share (`prefs/navigation.rs`). const FORM_LABEL_WIDTH: f32 = 150.0; @@ -2747,7 +2863,7 @@ fn space_mouse_rows(app: &mut SolveApp, ui: &mut egui::Ui) { }); // A device whose own app drives the view instead (the navigation bridge). ui_kit::divider(ui, "nav_bridge"); - navigation::nav_bridge(app, ui); + nav_bridge(app, ui); // The rarely needed settings sit behind one disclosure, closed until the reader opens it. ui_kit::section(ui, "space_mouse_advanced", crate::i18n::tr_label("Advanced"), false, |ui| { ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| { @@ -3400,11 +3516,11 @@ fn looks_like_theme(text: &str) -> bool { text.trim_start().starts_with('{') && text.contains(crate::theme_files::FORMAT) } -/// Ctrl/Cmd+V on the Interface page with a theme file's text on the clipboard imports it, like +/// Ctrl/Cmd+V on the Appearance page with a theme file's text on the clipboard imports it, like /// Import… with a file (#8226). Called before the global Copy and Paste shortcuts, which would /// otherwise paste copied components; the paste is taken out of the input once it is a theme's. pub fn take_theme_paste(app: &mut SolveApp, ctx: &egui::Context) { - if !app.prefs_window.open || app.prefs_window.section != PAGE_INTERFACE { + if !app.prefs_window.open || app.prefs_window.section != PAGE_APPEARANCE { return; } let Some(text) = ctx.input(|i| i.events.iter().find_map(|e| if let egui::Event::Paste(t) = e { Some(t.clone()) } else { None })) else { @@ -4057,8 +4173,7 @@ fn apply_preferences(app: &mut SolveApp, new: Prefs, p: &serde_json::Value) -> R #[cfg(test)] pub(crate) fn reveal_preference(h: &mut crate::scenario::Harness, handle: &str) { - // Interface includes the toolbar-tab choices as well as the existing font controls. - // Keep small scroll steps so a target cannot be skipped, with a bounded longer page. + // Keep small scroll steps so a target cannot be skipped on a long Preferences page. for _ in 0..32 { let page = crate::scenario::rect_of("dialog:page_body").expect("preference body"); let visible = crate::scenario::rect_of(handle) @@ -4174,7 +4289,7 @@ mod tests { let initial = h.call("ui.prefs", json!({})); assert_eq!(initial["result"]["navigation_bar"], serde_json::to_value(NavigationBar::default()).unwrap()); let edit = json!({"navigation_bar":{"slots":["zoom", "future", "zoom", "display"], "position":"bottom_right", "size":"regular", "labels":"labels", "idle":"always"}}); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); let reply = h.call("ui.prefs", edit); assert_eq!(reply["ok"], true, "{reply}"); assert_eq!(reply["result"]["navigation_bar"]["slots"], json!(["zoom", "future", "display"])); @@ -4197,7 +4312,7 @@ mod tests { assert_eq!(restored.preferences.navigation_bar, NavigationBar::default(), "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default()); - h.call("ui.prefs", json!({"open":"Interface","navigation_bar":{"slots":[]}})); + h.call("ui.prefs", json!({"open":"Layout","navigation_bar":{"slots":[]}})); assert!(h.app.preferences.navigation_bar.slots.is_empty()); h.call("ui.prefs", json!({"button":"defaults"})); assert_eq!(h.app.preferences.navigation_bar, NavigationBar::default()); @@ -4408,27 +4523,32 @@ mod tests { let mut h = crate::scenario::Harness::new(); h.app.home.open = false; h.call("ui.resize", json!({"width":width,"height":1100})); - h.call("ui.prefs", json!({"open":"Interface"})); - h.frames(20); - for _ in 0..2 { - let body = crate::scenario::rect_of("prefs:page_body").unwrap(); - let window = crate::scenario::rect_of("prefs:window").unwrap(); - let t = crate::theme::Tokens::get(); - let inset = t.space_16 + t.space_4 + crate::ui_kit::navigation_popup_frame().stroke.width; - assert!((body.right() - (window.right() - inset)).abs() < 0.5, "{width}: page {body:?} leaves unused window content {window:?}"); - for key in ["theme", "layout", "navigation_bar", "scale", "colour_vision"] { - let section = crate::scenario::rect_of(&format!("prefs:section:{key}")).unwrap(); - assert!( - (section.left() - body.left()).abs() < 0.5 && (section.right() - body.right()).abs() < 0.5, - "{key} at {width}: {section:?} vs {body:?}" - ); - } - for key in ["prefs:navbar:stage", "dialog:divider:scale_font", "dialog:row:Font"] { - let row = crate::scenario::rect_of(key).unwrap(); - assert!((row.right() - body.right()).abs() < 0.5, "{key} at {width}: {row:?} vs {body:?}"); - } - h.call("ui.scroll", json!({"x":body.center().x,"y":body.center().y,"delta":-600})); + for (page, sections, rows) in [ + ("Appearance", &["theme", "scale", "colour_vision"][..], &["dialog:divider:scale_font", "dialog:row:Font"][..]), + ("Layout", &["layout", "navigation_bar"][..], &["prefs:navbar:stage"][..]), + ] { + h.call("ui.prefs", json!({"open":page})); h.frames(20); + for _ in 0..2 { + let body = crate::scenario::rect_of("prefs:page_body").unwrap(); + let window = crate::scenario::rect_of("prefs:window").unwrap(); + let t = crate::theme::Tokens::get(); + let inset = t.space_16 + t.space_4 + crate::ui_kit::navigation_popup_frame().stroke.width; + assert!((body.right() - (window.right() - inset)).abs() < 0.5, "{width}: {page}"); + for key in sections { + let section = crate::scenario::rect_of(&format!("prefs:section:{key}")).unwrap(); + assert!( + (section.left() - body.left()).abs() < 0.5 && (section.right() - body.right()).abs() < 0.5, + "{key} at {width}: {section:?} vs {body:?}" + ); + } + for key in rows { + let row = crate::scenario::rect_of(key).unwrap(); + assert!((row.right() - body.right()).abs() < 0.5, "{key} at {width}: {row:?} vs {body:?}"); + } + h.call("ui.scroll", json!({"x":body.center().x,"y":body.center().y,"delta":-600})); + h.frames(20); + } } } } @@ -4670,7 +4790,7 @@ mod tests { h.app.home.open = false; h.app.space_mouse.device = Some("spacenavd".into()); h.app.space_mouse.drivers = Some(DriversPresent { spacenavd: true, direct: false, denied: false }); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(3); assert!(h.app.prefs_window.open); } @@ -4683,7 +4803,7 @@ mod tests { h.app.home.open = false; // After a driver change and before any reading: no device, so nothing starts. h.app.space_mouse.device = None; - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(5); assert!(crate::i18n::tr("ui.3d_mouse_calibrate_wait").starts_with("Move the 3D mouse")); crate::space_mouse_calibration::start(&mut h.app); @@ -4730,40 +4850,26 @@ mod tests { panic!("{handle} never came into view"); } - /// The page's rows share one label column, widened by the longest label in the form. The 3D - /// mouse section brought longer labels, which moved every control (Orbit around's among them) to - /// the right and turned its three buttons into a dropdown. Measured: each row's control left edge and - /// width with the section open and folded, at the window sizes the app is used at. #[test] fn folding_the_3d_mouse_section_does_not_move_the_controls_of_the_rows_above_it() { - let mut report = Vec::new(); for width in [900, 1100, 1318, 1600, 1920] { let mut h = crate::scenario::Harness::new(); h.app.home.open = false; - h.app.space_mouse.device = Some("hid 046d:c62b".into()); - h.call("ui.resize", serde_json::json!({"width": width, "height": 900})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + h.call("ui.resize", json!({"width":width,"height":900})); + open_at(&mut h.app, PAGE_NAVIGATION); h.frames(6); - let rows = ["Orbit around", "Middle double-click", "View navigator"]; - let control = |name: &str| crate::scenario::rect_of(&format!("dialog:control:{name}")).map(|r| (r.left(), r.width())); - let buttons = || crate::scenario::rect_of("dialog:segments:Orbit around").is_some(); - let (open, open_form) = (rows.map(control), buttons()); + let rows = ["Middle double-click", "View navigator"]; + let controls = || rows.map(|name| crate::scenario::rect_of(&format!("dialog:control:{name}"))); + let before = controls(); + assert!(before.iter().all(Option::is_some)); + open_at(&mut h.app, PAGE_MOUSE3D); + h.frames(6); + assert!(h.widget("Middle double-click").is_none()); scroll_to_and_click(&mut h, "dialog:section:3D mouse"); - // Back to the top, where the rows above are on screen again. - h.app.synthetic.push(egui::Event::MouseWheel { - unit: egui::MouseWheelUnit::Point, - delta: egui::vec2(0.0, 5000.0), - modifiers: egui::Modifiers::NONE, - phase: egui::TouchPhase::Move, - }); + open_at(&mut h.app, PAGE_NAVIGATION); h.frames(6); - let (folded, folded_form) = (rows.map(control), buttons()); - eprintln!("window {width}: open {open:?} buttons {open_form}; folded {folded:?} buttons {folded_form}"); - if folded != open || folded_form != open_form { - report.push(format!("window {width}: open {open:?} buttons {open_form}, folded {folded:?} buttons {folded_form}")); - } + assert_eq!(controls(), before); } - assert!(report.is_empty(), "{}", report.join("\n")); } /// The meter in a view axis row shows the motion chosen in its "driven by" menu, calibrated or not. @@ -4838,6 +4944,8 @@ mod tests { assert!(h.app.preferences.space_mouse_model_pivot, "traced is opt-in"); scroll_to_and_click(&mut h, "prefs:3d_mouse_orbit_classic"); assert!(!h.app.preferences.space_mouse_model_pivot, "classic again"); + open_at(&mut h.app, PAGE_NAVIGATION); + h.frames(4); assert!(!h.app.preferences.zoom_stop_at_model, "stop-at-model zoom is off by default"); scroll_to_and_click(&mut h, "prefs:zoom_stop_at_model"); assert!(h.app.preferences.zoom_stop_at_model, "stop-at-model zoom is opt-in"); @@ -4866,13 +4974,16 @@ mod tests { assert!(other.preferences.zoom_stop_at_model && other.preferences.space_mouse_model_pivot); assert!(other.preferences.zoom_to_cursor, "enabling model navigation leaves wheel zoom alone"); control(&mut app, &json!({"button": "defaults"})).unwrap(); - assert!(!app.preferences.zoom_stop_at_model && !app.preferences.space_mouse_model_pivot); + assert!(!app.preferences.zoom_stop_at_model); + assert!(app.preferences.space_mouse_model_pivot, "Navigation defaults leave 3D mouse settings alone"); + control(&mut app, &json!({"open":"3D mouse", "button":"defaults"})).unwrap(); + assert!(!app.preferences.space_mouse_model_pivot); assert!(app.preferences.zoom_to_cursor, "Navigation defaults still anchor the wheel"); control(&mut app, &json!({"button": "cancel"})).unwrap(); assert!(app.preferences.zoom_stop_at_model && app.preferences.space_mouse_model_pivot, "Cancel restores the last Apply"); } - /// Opens Preferences on the Navigation page with the 3D mouse section open and these settings + /// Opens Preferences on the 3D mouse page with its section open and these settings /// changed from their defaults, as a person who changed them would find it. fn changed_3d_mouse_settings(device: Option<&str>) -> crate::scenario::Harness { let mut h = crate::scenario::Harness::new(); @@ -4891,7 +5002,7 @@ mod tests { p.space_mouse_ghost_position = SpaceMouseGhost::LeftWindow; p.space_mouse_in_view = true; h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(36); open_advanced(&mut h); h @@ -4912,7 +5023,7 @@ mod tests { h.app.space_mouse.device = Some("hid 046d:c62b".into()); h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd: true, direct: true, denied: false }); h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(36); let drawn = |name: &str| crate::scenario::rect_of(&format!("dialog:row:{name}")).is_some(); let (driver, axes) = (crate::i18n::tr("ui.3d_mouse_driver"), crate::i18n::tr("ui.3d_mouse_button").replace("{number}", "1")); @@ -4993,7 +5104,7 @@ mod tests { h.step(&serde_json::json!({"click": {"handle": "dialog:cancel"}})).unwrap(); h.frames(6); assert!(!h.app.prefs_window.open, "the dialog closed"); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(6); assert!(!h.app.space_mouse.restore_pending, "the question is not asked again on its own"); assert_eq!(h.app.preferences, before); @@ -5042,7 +5153,7 @@ mod tests { card.frames(5); // Preferences'. let mut prefs = harness(); - crate::prefs::open_at(&mut prefs.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut prefs.app, crate::prefs::PAGE_MOUSE3D); prefs.frames(6); prefs.frames(30); assert!(prefs.app.space_mouse.calibrating.is_none()); @@ -5080,7 +5191,7 @@ mod tests { h.app.space_mouse.device = Some(device.into()); h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd: true, direct, denied: false }); h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(6); h.frames(30); open_advanced(&mut h); @@ -5118,7 +5229,7 @@ mod tests { // The axis assignment is changed, so its reset button is enabled and drawn. h.app.preferences.space_mouse_axis_source = [1, 0, 2, 3, 4, 5]; h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(6); scroll_to_and_click(&mut h, &format!("dialog:section:{}", crate::i18n::Locale::for_language(catalog.id).text("Advanced"))); h.frames(10); @@ -5259,7 +5370,7 @@ mod tests { h.app.space_mouse.device = None; h.app.space_mouse.drivers = Some(crate::space_mouse::DriversPresent { spacenavd: true, direct: false, denied: false }); h.call("ui.resize", serde_json::json!({"width": 1600, "height": 4000})); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); h.frames(5); assert!(crate::scenario::rect_of("dialog:section:3D mouse").is_some(), "the section is drawn with the kit's header"); assert!(crate::scenario::rect_of("dialog:section:3D mouse:count").is_none()); @@ -5564,38 +5675,57 @@ mod tests { ("default_units", json!("ft"), PAGE_DESIGN), ("length_decimals", json!(5), PAGE_DESIGN), ("angle_decimals", json!(4), PAGE_DESIGN), - ("theme", json!("light"), PAGE_INTERFACE), - ("ui_scale", json!(1.25), PAGE_INTERFACE), - ("ui_font", json!("test font"), PAGE_INTERFACE), - ("layout", json!("compact"), PAGE_INTERFACE), - ("ribbon_labels", json!(false), PAGE_INTERFACE), - ("persistent_ribbon_pressed", json!(false), PAGE_INTERFACE), - ("viewport_analysis_status", json!(false), PAGE_INTERFACE), - ("viewport_section_status", json!(false), PAGE_INTERFACE), - ("viewport_status_details", json!(false), PAGE_INTERFACE), - ("viewport_status_summary", json!(false), PAGE_INTERFACE), - ("sketch_tab_always", json!(true), PAGE_INTERFACE), - ("keep_work_on_tab_switch", json!(true), PAGE_INTERFACE), - ("ribbon_reveal", json!(true), PAGE_INTERFACE), - ("dialog_buttons", json!("top"), PAGE_INTERFACE), - ("toast_place", json!("centre"), PAGE_INTERFACE), - ("ribbon_icon_grid", json!(true), PAGE_INTERFACE), - ("ribbon_menus_skip_pinned", json!(true), PAGE_INTERFACE), - ("timeline_left", json!(true), PAGE_INTERFACE), - ("timeline_under_browser", json!(true), PAGE_INTERFACE), - ("history_sketches", json!("under_feature"), PAGE_INTERFACE), - ("history_play_button", json!(false), PAGE_INTERFACE), - ("browser_float", json!(true), PAGE_INTERFACE), - ("browser_collapsed", json!(true), PAGE_INTERFACE), - ("browser_show", json!("hover"), PAGE_INTERFACE), - ("dialog_place", json!("left_column"), PAGE_INTERFACE), - ("color_vision", json!("protan"), PAGE_INTERFACE), - ("viewport_theme", json!("light"), PAGE_INTERFACE), - ("viewport_background", json!([255, 255, 255]), PAGE_INTERFACE), - ("view_confirm_corner", json!(true), PAGE_INTERFACE), - ("status_bar", json!(true), PAGE_INTERFACE), - ("browser_eye_left", json!(true), PAGE_INTERFACE), - ("quick_measure", json!(true), PAGE_INTERFACE), + ("theme", json!("light"), PAGE_APPEARANCE), + ("ui_scale", json!(1.25), PAGE_APPEARANCE), + ("ui_font", json!("test font"), PAGE_APPEARANCE), + ("layout", json!("compact"), PAGE_LAYOUT), + ("ribbon_labels", json!(false), PAGE_LAYOUT), + ("persistent_ribbon_pressed", json!(false), PAGE_LAYOUT), + ("viewport_analysis_status", json!(false), PAGE_GRAPHICS), + ("viewport_section_status", json!(false), PAGE_GRAPHICS), + ("viewport_status_details", json!(false), PAGE_GRAPHICS), + ("viewport_status_summary", json!(false), PAGE_GRAPHICS), + ("sketch_tab_always", json!(true), PAGE_LAYOUT), + ("keep_work_on_tab_switch", json!(true), PAGE_LAYOUT), + ("ribbon_reveal", json!(true), PAGE_LAYOUT), + ("dialog_buttons", json!("top"), PAGE_LAYOUT), + ("toast_place", json!("centre"), PAGE_LAYOUT), + ("ribbon_icon_grid", json!(true), PAGE_LAYOUT), + ("ribbon_menus_skip_pinned", json!(true), PAGE_LAYOUT), + ("timeline_left", json!(true), PAGE_LAYOUT), + ("timeline_under_browser", json!(true), PAGE_LAYOUT), + ("history_sketches", json!("under_feature"), PAGE_LAYOUT), + ("history_play_button", json!(false), PAGE_LAYOUT), + ("browser_float", json!(true), PAGE_LAYOUT), + ("browser_collapsed", json!(true), PAGE_LAYOUT), + ("browser_show", json!("hover"), PAGE_LAYOUT), + ("dialog_place", json!("left_column"), PAGE_LAYOUT), + ("color_vision", json!("protan"), PAGE_APPEARANCE), + ("viewport_theme", json!("light"), PAGE_APPEARANCE), + ("viewport_background", json!([255, 255, 255]), PAGE_APPEARANCE), + ("view_confirm_corner", json!(true), PAGE_LAYOUT), + ("status_bar", json!(true), PAGE_LAYOUT), + ("browser_eye_left", json!(true), PAGE_LAYOUT), + ("quick_measure", json!(true), PAGE_GRAPHICS), + ("origin_plane_names", json!("top_front_right"), PAGE_DESIGN), + ("direct_interaction", json!(true), PAGE_TOOLS), + ("hole_snaps", json!(true), PAGE_TOOLS), + ("hole_moves", json!(true), PAGE_TOOLS), + ("extrude_auto_to_object", json!(true), PAGE_TOOLS), + ("extrude_view_isometric", json!(true), PAGE_TOOLS), + ("extrude_view_return", json!(true), PAGE_TOOLS), + ("auto_operation", json!(false), PAGE_TOOLS), + ("placement_handles", json!(true), PAGE_TOOLS), + ("assembly_move_handles", json!(false), PAGE_TOOLS), + ("joint_rotation_coarse", json!(12.0), PAGE_TOOLS), + ("joint_rotation_fine", json!(0.2), PAGE_TOOLS), + ("drive_joints_ghost", json!(false), PAGE_TOOLS), + ("measure_axis_distances", json!(false), PAGE_TOOLS), + ("network_locations", json!(true), PAGE_GENERAL), + ("network_hosts", json!(["files.studio"]), PAGE_GENERAL), + ("nav_bridge_enabled", json!(true), PAGE_MOUSE3D), + ("nav_bridge_port", json!(9876), PAGE_MOUSE3D), + ("space_mouse_speed", json!(2.0), PAGE_MOUSE3D), ("nav", json!("blender"), PAGE_NAVIGATION), ("look_at_anim", json!(false), PAGE_NAVIGATION), ("selection_shift_add_only", json!(true), PAGE_SKETCH), @@ -5632,7 +5762,7 @@ mod tests { for name in ["Sketch", "Selection", "Sketch & selection"] { assert_eq!(page_index(name), Some(PAGE_SKETCH)); } - assert_eq!(page_index("Assistant"), Some(PAGE_AI)); + assert_eq!(page_index("Assistant"), Some(PAGE_ASSISTANT)); assert_eq!(page_index("Shortcuts"), Some(PAGE_SHORTCUTS)); let mut app = SolveApp::new(Default::default(), Default::default()); app.ui.agent_cursor.show = false; @@ -5642,7 +5772,7 @@ mod tests { assert!(!app.ui.agent_cursor.show); assert!(app.ui.pick_bodies); assert!(!app.session.auto_project); - defaults(&mut app, PAGE_AI); + defaults(&mut app, PAGE_ASSISTANT); let expected = SolveApp::new(Default::default(), Default::default()).ui.agent_cursor.show; assert_eq!(app.ui.agent_cursor.show, expected); defaults(&mut app, PAGE_SKETCH); @@ -5650,6 +5780,141 @@ mod tests { assert!(app.session.auto_project); } + #[test] + fn preferences_structure_order_groups_and_unique_field_homes() { + assert_eq!( + PAGES, + [ + "General", + "Appearance", + "Layout", + "Graphics", + "Design", + "Sketch", + "Tools", + "Navigation", + "3D mouse", + "Shortcuts", + "Assistant", + "Plugins" + ] + ); + assert_eq!(WINDOW_PAGES.len(), PAGES.len()); + let groups: Vec<_> = WINDOW_PAGES.iter().enumerate().filter_map(|(i, p)| p.group.map(|g| (i, crate::i18n::tr(g)))).collect(); + assert_eq!(groups, [(PAGE_APPEARANCE, "Look"), (PAGE_DESIGN, "Work"), (PAGE_NAVIGATION, "Input"), (PAGE_ASSISTANT, "Extend")]); + let mut fields = std::collections::BTreeSet::new(); + for (field, page) in FIELD_PAGES { + assert!(fields.insert(field), "duplicate home for {field}"); + assert!(page.is_none_or(|p| p < PAGES.len()), "invalid page for {field}"); + } + let saved = serde_json::to_value(Prefs::default()).unwrap(); + assert_eq!(fields.len(), saved.as_object().unwrap().len(), "every stored field has exactly one metadata entry"); + for (i, name) in PAGES.iter().enumerate() { + assert_eq!(crate::i18n::tr(WINDOW_PAGES[i].label), *name); + assert_eq!(WINDOW_PAGES[i].handle, format!("prefs:page:{name}")); + } + } + + #[test] + fn preferences_all_canonical_and_legacy_pages_open_and_publish_real_alias_handles() { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + h.call("ui.resize", json!({"width":1600,"height":1200})); + for (name, index) in PAGES.iter().enumerate().map(|(i, n)| (*n, i)).chain(PAGE_ALIASES.iter().copied()) { + assert_eq!(page_index(name), Some(index)); + let reply = h.call("ui.prefs", json!({"open":name})); + assert!(reply["error"].is_null(), "{name}: {reply}"); + assert_eq!(reply["result"]["dialog"], PAGES[index]); + open_at(&mut h.app, index); + h.frames(4); + assert_eq!(h.app.prefs_window.section, index); + assert_eq!(crate::scenario::rect_of(&format!("prefs:page:{name}")), crate::scenario::rect_of(WINDOW_PAGES[index].handle)); + assert!(crate::scenario::rect_of(&format!("prefs:page:{name}")).is_some()); + } + for (alias, index) in PAGE_ALIASES { + open_at(&mut h.app, *index); + h.frames(4); + h.step(&json!({"click":{"handle":format!("prefs:page:{alias}")}})).unwrap(); + assert_eq!(h.app.prefs_window.section, *index, "{alias} is clickable"); + } + } + + #[test] + fn preferences_moved_controls_have_one_drawn_home() { + let cases = [ + ("Show tool at cursor", PAGE_TOOLS), + ("Direct interaction", PAGE_TOOLS), + ("Show X/Y/Z distances", PAGE_TOOLS), + ("Move holes by clicking or dragging", PAGE_TOOLS), + ("Extrude to a picked target", PAGE_TOOLS), + ("Turn the view to isometric when Extrude opens", PAGE_TOOLS), + ("Go back to the earlier view when Extrude closes", PAGE_TOOLS), + ("Placement handles", PAGE_TOOLS), + ("Navigate with the 3D mouse", PAGE_MOUSE3D), + ("Origin plane names", PAGE_DESIGN), + ("Status bar", PAGE_LAYOUT), + ("Color vision", PAGE_APPEARANCE), + ("Quick measurement in the view's corner", PAGE_GRAPHICS), + ("Show viewport analysis status", PAGE_GRAPHICS), + ("Show viewport section status", PAGE_GRAPHICS), + ("Live viewport details", PAGE_GRAPHICS), + ("Fold viewport status items", PAGE_GRAPHICS), + ("Allow network locations in designs", PAGE_GENERAL), + ("Print face highlight", PAGE_GENERAL), + ]; + let mut found = vec![Vec::new(); cases.len()]; + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + for page in 0..PAGES.len() { + open_at(&mut h.app, page); + h.frames(4); + for (i, (label, _)) in cases.iter().enumerate() { + if h.widget(label).is_some() { + found[i].push(page); + } + } + } + for ((label, page), actual) in cases.iter().zip(found) { + assert_eq!(actual, [*page], "{label} must have exactly one Preferences home"); + } + } + + #[test] + fn preferences_session_resets_follow_their_new_pages_only() { + for page in 0..PAGES.len() { + let mut app = SolveApp::new(Default::default(), Default::default()); + app.autosave_minutes = 9.0; + app.ui.dark = false; + app.prefs_window.follow.launch = Some("theme.json".into()); + app.ui.layout = crate::shell::LayoutMode::Docked; + app.ui.show_navigation_bar = false; + app.ui.tool_cursor = true; + app.ui.visual_style = 2; + app.ui.show_grid = false; + app.ui.ground_shadow = false; + app.ui.perspective = true; + app.session.auto_project = false; + app.ui.pick_bodies = true; + app.ui.agent_cursor.show = true; + app.keymap.custom.insert("solid.extrude".into(), vec!["X".into()]); + defaults(&mut app, page); + assert_eq!(app.autosave_minutes, if page == PAGE_GENERAL { 5.0 } else { 9.0 }); + assert_eq!(app.ui.dark, page == PAGE_APPEARANCE); + assert_eq!(app.prefs_window.follow.launch.is_none(), page == PAGE_APPEARANCE); + assert_eq!(app.ui.layout == crate::shell::LayoutMode::Floating, page == PAGE_LAYOUT); + assert_eq!(app.ui.show_navigation_bar, page == PAGE_LAYOUT); + assert_eq!(app.ui.tool_cursor, page != PAGE_TOOLS); + assert_eq!(app.ui.visual_style, if page == PAGE_GRAPHICS { 0 } else { 2 }); + assert_eq!(app.ui.show_grid, page == PAGE_GRAPHICS); + assert_eq!(app.ui.ground_shadow, page == PAGE_GRAPHICS); + assert_eq!(app.ui.perspective, page != PAGE_GRAPHICS); + assert_eq!(app.session.auto_project, page == PAGE_SKETCH); + assert_eq!(app.ui.pick_bodies, page != PAGE_SKETCH); + assert_eq!(app.ui.agent_cursor.show, page != PAGE_ASSISTANT); + assert_eq!(app.keymap.custom.is_empty(), page == PAGE_SHORTCUTS); + } + } + fn hole_preset_row(name: &str) -> serde_json::Value { serde_json::json!({ "name": name, "style": "counterbore", "extent": "distance", @@ -5773,7 +6038,7 @@ mod tests { let mut other = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default()); other.load_prefs(&app.prefs()); assert_eq!(other.preferences.ui_font, family); - super::defaults(&mut app, super::PAGE_INTERFACE); + super::defaults(&mut app, super::PAGE_APPEARANCE); assert_eq!(app.preferences.ui_font, ""); } @@ -5824,13 +6089,13 @@ mod tests { let saved = lenient(&json!({"browser_bodies_folders": bad, "theme": "light"})); assert_eq!((saved.browser_bodies_folders, saved.theme.as_str()), (BodiesFolders::Several, "light"), "{bad}"); } - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); reveal_preference(&mut h, "dialog:Bodies folders:Always"); h.step(&json!({"click": {"handle": "dialog:Bodies folders:Always"}})).unwrap(); assert_eq!(h.app.preferences.browser_bodies_folders, BodiesFolders::Always); h.call("ui.prefs", json!({"button": "cancel"})); assert_eq!(h.app.preferences.browser_bodies_folders, BodiesFolders::Never, "Cancel puts it back"); - defaults(&mut h.app, PAGE_INTERFACE); + defaults(&mut h.app, PAGE_LAYOUT); assert_eq!(h.app.preferences.browser_bodies_folders, BodiesFolders::Several, "Interface's Restore Defaults"); } @@ -7336,7 +7601,7 @@ mod tests { #[test] fn control_channel_holds_unapplied_changes_out_of_the_saved_settings() { let mut h = crate::scenario::Harness::new(); - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); h.call("ui.prefs", json!({"sketch_tab_always": true})); let saved = saved_prefs(&h.app); assert!(h.app.preferences.sketch_tab_always); @@ -7569,7 +7834,7 @@ mod tests { let rows = || crate::browser::drawn_rows().into_iter().map(|(label, ..)| label).collect::>(); assert!(OriginPlaneNames::PLANES.iter().all(|p| rows().iter().any(|r| r == p)), "{:?}", rows()); let design = h.app.session.doc.to_json(); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Design"})); super::reveal_preference(&mut h, "prefs:origin_plane_names:top_front_right"); h.step(&json!({"click":{"handle":"prefs:origin_plane_names:top_front_right"}})).unwrap(); assert_eq!(h.app.preferences.origin_plane_names, TopFrontRight); @@ -7604,10 +7869,10 @@ mod tests { let before = h.app.preferences.clone(); assert!(control(&mut h.app, &json!({"origin_plane_names":"top", "nav":"solidworks"})).is_err()); assert_eq!(h.app.preferences, before, "an unknown naming fails atomically"); - h.call("ui.prefs", json!({"open":"Interface","origin_plane_names":"xyz"})); + h.call("ui.prefs", json!({"open":"Design","origin_plane_names":"xyz"})); h.call("ui.prefs", json!({"button":"cancel"})); assert_eq!(h.app.preferences.origin_plane_names, TopFrontRight, "Cancel takes it back"); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Design"})); h.call("ui.prefs", json!({"button":"defaults"})); assert_eq!(h.app.preferences.origin_plane_names, Xyz, "Restore Defaults: XY, XZ and YZ"); h.frames(2); @@ -7641,10 +7906,14 @@ mod tests { for step in steps.iter().take(transition) { h.step(step).unwrap(); } - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); + let page = crate::scenario::rect_of("prefs:page_body").unwrap(); + h.call("ui.scroll", json!({"x":page.center().x,"y":page.center().y,"delta":-10000})); + h.frames(60); let at = h.widget("Under their feature").unwrap(); let page = crate::scenario::rect_of("prefs:page_body").unwrap(); assert!(!page.contains(egui::pos2(at[0] as f32, at[1] as f32)), "the real control begins scrolled out of view"); + assert!((at[1] as f32) < page.top(), "scrolling to the bottom puts the target above the viewport"); assert_eq!(h.app.preferences.history_sketches, HistorySketches::InOrder); h.step(&json!({"widget":"Under their feature", "near":"Sketches"})).unwrap(); assert_eq!(h.app.preferences.history_sketches, HistorySketches::UnderFeature); @@ -7661,7 +7930,7 @@ mod tests { for step in steps.iter().skip(transition + 2) { h.step(step).unwrap(); } - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); h.step(&json!({"widget":"Navigation"})).unwrap(); assert_eq!(h.app.prefs_window.section, PAGE_NAVIGATION, "sidebar navigation remains a real click"); h.step(&json!({"widget":"Cancel"})).unwrap(); @@ -7676,7 +7945,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); h.call("ui.prefs", json!({"timeline_left": true, "timeline_under_browser": true})); let design = h.app.session.doc.to_json(); - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); let row = h.app.tr("prefs.history_sketches").to_string(); let under = h.app.tr("prefs.history_sketches_under_feature").to_string(); let handle = format!("dialog:{row}:{under}"); @@ -7696,7 +7965,7 @@ mod tests { let before = h.app.preferences.clone(); assert!(control(&mut h.app, &json!({"history_sketches": "sideways"})).is_err()); assert_eq!(h.app.preferences, before, "an unknown value changes nothing"); - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); h.call("ui.prefs", json!({"button": "defaults"})); assert_eq!(h.app.preferences.history_sketches, HistorySketches::InOrder); h.call("ui.prefs", json!({"button": "cancel"})); @@ -7710,7 +7979,7 @@ mod tests { assert_eq!(old.dialog_buttons, DialogButtons::Bottom, "settings from before keep the footer"); assert_eq!(lenient(&json!({"dialog_buttons": "sideways"})).dialog_buttons, DialogButtons::Bottom); let mut h = crate::scenario::Harness::new(); - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); super::reveal_preference(&mut h, "prefs:dialog_buttons:top"); h.step(&json!({"click": {"handle": "prefs:dialog_buttons:top"}})).unwrap(); assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Top); @@ -7725,7 +7994,7 @@ mod tests { let before = h.app.preferences.clone(); assert!(control(&mut h.app, &json!({"dialog_buttons": "sideways"})).is_err()); assert_eq!(h.app.preferences, before, "an unknown value changes nothing"); - h.call("ui.prefs", json!({"open": "Interface"})); + h.call("ui.prefs", json!({"open": "Layout"})); h.call("ui.prefs", json!({"button": "defaults"})); assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Bottom); h.call("ui.prefs", json!({"button": "cancel"})); @@ -7824,7 +8093,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); let design = h.app.session.doc.to_json(); let revision = h.app.session.revision; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); super::reveal_preference(&mut h, "prefs:persistent_ribbon_pressed"); let checkbox = crate::scenario::handle_at("prefs:persistent_ribbon_pressed").unwrap(); h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y})); @@ -7835,7 +8104,7 @@ mod tests { assert!(restored.preferences.persistent_ribbon_pressed, "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert!(h.app.preferences.persistent_ribbon_pressed); - h.call("ui.prefs", json!({"open":"Interface","persistent_ribbon_pressed":false,"button":"apply"})); + h.call("ui.prefs", json!({"open":"Layout","persistent_ribbon_pressed":false,"button":"apply"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.persistent_ribbon_pressed); h.call("ui.prefs", json!({"button":"cancel"})); @@ -7856,7 +8125,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); let design = h.app.session.doc.to_json(); let revision = h.app.session.revision; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Graphics"})); super::reveal_preference(&mut h, "prefs:viewport_analysis_status"); let checkbox = crate::scenario::handle_at("prefs:viewport_analysis_status").unwrap(); h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y})); @@ -7867,7 +8136,7 @@ mod tests { assert!(restored.preferences.viewport_analysis_status, "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert!(h.app.preferences.viewport_analysis_status); - h.call("ui.prefs", json!({"open":"Interface","viewport_analysis_status":false,"button":"apply"})); + h.call("ui.prefs", json!({"open":"Graphics","viewport_analysis_status":false,"button":"apply"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.viewport_analysis_status); h.call("ui.prefs", json!({"button":"cancel"})); @@ -7890,7 +8159,7 @@ mod tests { crate::documents::open_tab(&mut app, other).unwrap(); let before: Vec<_> = std::iter::once(&app.session).chain(app.docs.background()).map(|s| (s.status_items(), s.revision, s.undo.len())).collect(); - super::control(&mut app, &json!({"open":"Interface","viewport_analysis_status":false})).unwrap(); + super::control(&mut app, &json!({"open":"Graphics","viewport_analysis_status":false})).unwrap(); assert!(!app.preferences.viewport_analysis_status); assert!(!app.preferences.persistent_ribbon_pressed); assert!(std::iter::once(&app.session).chain(app.docs.background()).all(|s| !s.single_surface_analysis())); @@ -7909,7 +8178,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); let design = h.app.session.doc.to_json(); let revision = h.app.session.revision; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Graphics"})); super::reveal_preference(&mut h, "prefs:viewport_section_status"); let checkbox = crate::scenario::handle_at("prefs:viewport_section_status").unwrap(); h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y})); @@ -7920,7 +8189,7 @@ mod tests { assert!(restored.preferences.viewport_section_status, "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert!(h.app.preferences.viewport_section_status); - h.call("ui.prefs", json!({"open":"Interface","viewport_section_status":false,"button":"apply"})); + h.call("ui.prefs", json!({"open":"Graphics","viewport_section_status":false,"button":"apply"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.viewport_section_status); h.call("ui.prefs", json!({"button":"cancel"})); @@ -7941,7 +8210,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); let design = h.app.session.doc.to_json(); let revision = h.app.session.revision; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Graphics"})); super::reveal_preference(&mut h, "prefs:viewport_status_details"); let checkbox = crate::scenario::handle_at("prefs:viewport_status_details").unwrap(); h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y})); @@ -7952,7 +8221,7 @@ mod tests { assert!(restored.preferences.viewport_status_details, "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert!(h.app.preferences.viewport_status_details); - h.call("ui.prefs", json!({"open":"Interface","viewport_status_details":false,"button":"apply"})); + h.call("ui.prefs", json!({"open":"Graphics","viewport_status_details":false,"button":"apply"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.viewport_status_details); h.call("ui.prefs", json!({"button":"cancel"})); @@ -7973,7 +8242,7 @@ mod tests { let mut h = crate::scenario::Harness::new(); let design = h.app.session.doc.to_json(); let revision = h.app.session.revision; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Graphics"})); super::reveal_preference(&mut h, "prefs:viewport_status_summary"); let checkbox = crate::scenario::handle_at("prefs:viewport_status_summary").unwrap(); h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y})); @@ -7984,7 +8253,7 @@ mod tests { assert!(restored.preferences.viewport_status_summary, "a change that was not applied is not saved (#9730)"); h.call("ui.prefs", json!({"button":"cancel"})); assert!(h.app.preferences.viewport_status_summary); - h.call("ui.prefs", json!({"open":"Interface","viewport_status_summary":false,"button":"apply"})); + h.call("ui.prefs", json!({"open":"Graphics","viewport_status_summary":false,"button":"apply"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(h.app.preferences.viewport_status_summary); h.call("ui.prefs", json!({"button":"cancel"})); @@ -8009,7 +8278,7 @@ mod tests { crate::documents::open_tab(&mut app, other).unwrap(); let before: Vec<_> = std::iter::once(&app.session).chain(app.docs.background()).map(|s| (s.status_items(), s.revision, s.undo.len())).collect(); - super::control(&mut app, &json!({"open":"Interface","viewport_section_status":false})).unwrap(); + super::control(&mut app, &json!({"open":"Graphics","viewport_section_status":false})).unwrap(); assert!(!app.preferences.viewport_section_status); assert!(!app.preferences.persistent_ribbon_pressed); assert!(std::iter::once(&app.session).chain(app.docs.background()).all(|s| !s.single_surface_analysis())); diff --git a/crates/ui-egui/src/prefs/design.rs b/crates/ui-egui/src/prefs/design.rs index f1debeab1..e2448e0e3 100644 --- a/crates/ui-egui/src/prefs/design.rs +++ b/crates/ui-egui/src/prefs/design.rs @@ -82,70 +82,39 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { }); }, ); - setting::extrude_auto_to_object(app, ui); - // Extrude's view (#9176): isometric when it opens, and back afterwards only with that. - setting::extrude_view_isometric(app, ui); - let isometric = app.preferences.extrude_view_isometric; - ui.add_enabled_ui(isometric, |ui| setting::extrude_view_return(app, ui)); - let auto = setting::auto_operation(app, ui); - crate::scenario::publish_handle("prefs:auto_operation", auto.rect.center()); - ui_kit::text(ui, app.tr("prefs.auto_operation_note"), ui_kit::Text::Hint("auto_operation")); - setting::hide_origin(app, ui); - ui_kit::text(ui, app.tr("ui.hide_origin_note"), ui_kit::Text::Hint("hide_origin")); - }); - ui_kit::settings_section(ui, "joint_move", app.tr("joint_move.settings"), |ui| { - setting::assembly_move_handles(app, ui); - ui_kit::text(ui, app.tr("joint_move.legacy_hint"), ui_kit::Text::Hint("joint_move_legacy")); - ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| { - ui_kit::row(ui, app.tr("joint_move.coarse"), |ui| { - ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_coarse, 0.001..=180.0, 0.1); - }); - ui_kit::row(ui, app.tr("joint_move.fine"), |ui| { - ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_fine, 0.001..=180.0, 0.01); - }); - }); - ui_kit::text(ui, app.tr("joint_move.precision"), ui_kit::Text::Hint("joint_move")); - }); - // The Hole command's own settings, under its name. - ui_kit::settings_section(ui, "create_hole", crate::i18n::tr_label("Create Hole"), |ui| { - setting::hole_snaps(app, ui); - ui_kit::text( - ui, - crate::i18n::tr_label("A Single hole snaps to the middle of its face and to the centres of its round edges"), - ui_kit::Text::Hint("hole_snaps"), - ); - setting::hole_moves(app, ui); - ui_kit::text( - ui, - crate::i18n::tr_label( - "A placed Single hole has a handle to drag it, and picking its face again moves the hole there instead of taking it out", - ), - ui_kit::Text::Hint("hole_moves"), - ); - }); - ui_kit::settings_section(ui, "placement", app.tr("prefs.placement"), |ui| { - setting::placement_handles(app, ui); }); + origin_plane_names(app, ui); ui_kit::settings_section(ui, "linked_designs", app.tr("prefs.linked_designs"), |ui| { setting::update_changed_links(app, ui); setting::double_click_components(app, ui); setting::insert_lists_open_designs(app, ui); }); - // Where the files a design names may be: never a network location the user hasn't allowed. - ui_kit::settings_section(ui, "network_locations", app.tr("prefs.network_locations_section"), |ui| { - setting::network_locations(app, ui); - ui_kit::text(ui, app.tr("prefs.network_locations_note"), ui_kit::Text::Hint("network_locations")); - let mut remove = None; - for (i, host) in app.preferences.network_hosts.iter().enumerate() { - ui.horizontal(|ui| { - ui_kit::text(ui, &format!("\\\\{host}"), ui_kit::Text::Hint("network_host")); - if ui_kit::button(ui, app.tr("prefs.network_host_remove"), ui_kit::Button::Small).clicked() { - remove = Some(i); - } - }); +} + +/// Origin plane names: each choice shows the three names it gives (`XY / XZ / YZ`), with a note +/// that only the names shown change. +fn origin_plane_names(app: &mut SolveApp, ui: &mut egui::Ui) { + ui_kit::settings_section(ui, "origin_plane_names", app.tr("prefs.origin_plane_names"), |ui| { + let choices: Vec = + OriginPlaneNames::ALL.iter().map(|names| OriginPlaneNames::PLANES.map(|plane| names.label(plane)).join(" / ")).collect(); + let options: Vec<&str> = choices.iter().map(String::as_str).collect(); + let mut selected = OriginPlaneNames::ALL.iter().position(|names| *names == app.preferences.origin_plane_names).unwrap_or(0); + if ui_kit::settings_segments(ui, app.tr("prefs.origin_plane_names"), &mut selected, &options) + && let Some(names) = OriginPlaneNames::ALL.get(selected) + { + app.preferences.origin_plane_names = *names; } - if let Some(i) = remove.filter(|i| *i < app.preferences.network_hosts.len()) { - app.preferences.network_hosts.remove(i); + // Handles that don't depend on the language, by the choice's saved value. + for (choice, key) in choices.iter().zip(["xyz", "top_front_right"]) { + if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{choice}", app.tr("prefs.origin_plane_names"))) { + crate::scenario::publish_handle(&format!("prefs:origin_plane_names:{key}"), at); + } } + let top = OriginPlaneNames::TopFrontRight; + let note = + crate::i18n::format("prefs.origin_plane_names_note", &[("top", top.label("XY")), ("front", top.label("XZ")), ("right", top.label("YZ"))]); + ui_kit::text(ui, ¬e, ui_kit::Text::Hint("origin_plane_names")); + setting::hide_origin(app, ui); + ui_kit::text(ui, app.tr("ui.hide_origin_note"), ui_kit::Text::Hint("hide_origin")); }); } diff --git a/crates/ui-egui/src/prefs/general.rs b/crates/ui-egui/src/prefs/general.rs index e7bc9dfee..934a664bc 100644 --- a/crates/ui-egui/src/prefs/general.rs +++ b/crates/ui-egui/src/prefs/general.rs @@ -4,7 +4,8 @@ use super::*; pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { let t = Tokens::get(); let labels = t.space_24 * 6.0 + t.space_6; - ui_kit::settings_heading(ui, app.tr("prefs.general"), app.tr("prefs.general_note")); + ui_kit::settings_heading_with_tag(ui, app.tr("prefs.general"), app.tr("prefs.general_note"), Some(crate::settings_profiles::tag)); + crate::settings_profiles::section(app, ui, labels); ui_kit::settings_section(ui, "language", app.tr("ui.language"), |ui| { ui_kit::settings_form(ui, labels, |ui| { ui_kit::row(ui, app.tr("prefs.interface_language"), |ui| { @@ -39,7 +40,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { }); }); }); - crate::settings_profiles::section(app, ui, labels); ui_kit::settings_section(ui, "saving", app.tr("prefs.saving"), |ui| { ui_kit::settings_block_hint(ui, app.tr("ui.autosave_every"), crate::i18n::tr_label("0 turns it off"), labels, |ui| { ui.horizontal(|ui| { @@ -70,6 +70,23 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { }); }); ui_kit::settings_section(ui, "file_size", app.tr("prefs.max_file_size"), |ui| file_size_rows(app, ui, labels)); + // Where the files a design names may be: never a network location the user hasn't allowed. + ui_kit::settings_section(ui, "network_locations", app.tr("prefs.network_locations_section"), |ui| { + setting::network_locations(app, ui); + ui_kit::text(ui, app.tr("prefs.network_locations_note"), ui_kit::Text::Hint("network_locations")); + let mut remove = None; + for (i, host) in app.preferences.network_hosts.iter().enumerate() { + ui.horizontal(|ui| { + ui_kit::text(ui, &format!("\\\\{host}"), ui_kit::Text::Hint("network_host")); + if ui_kit::button(ui, app.tr("prefs.network_host_remove"), ui_kit::Button::Small).clicked() { + remove = Some(i); + } + }); + } + if let Some(i) = remove.filter(|i| *i < app.preferences.network_hosts.len()) { + app.preferences.network_hosts.remove(i); + } + }); ui_kit::settings_section(ui, "slicer", app.tr("ui.slicer"), |ui| { ui_kit::settings_block(ui, app.tr("ui.slicer"), labels, |ui| { let (single, tip) = (app.tr("ui.slicer_single_instance").to_string(), app.tr("ui.slicer_single_instance_tip").to_string()); diff --git a/crates/ui-egui/src/prefs/graphics.rs b/crates/ui-egui/src/prefs/graphics.rs index 4ad69d0e6..d4d42d436 100644 --- a/crates/ui-egui/src/prefs/graphics.rs +++ b/crates/ui-egui/src/prefs/graphics.rs @@ -189,12 +189,29 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { right.add_enabled_ui(app.ui.show_grid, |ui| { setting::grid_follows_view(app, ui); }); - let response = setting::measure_axis_distances(app, right); - crate::scenario::publish_rect("prefs:measure_axis_distances", response.rect); - response.on_hover_text(app.tr("settings.measure_axis_distances_help")); } }); ui_kit::settings_form(ui, t.space_24 * 6.0 + t.space_6, |ui| { + ui_kit::row(ui, "", |ui| { + let check = setting::quick_measure(app, ui).on_hover_text(app.tr("prefs.quick_measure_note")); + crate::scenario::publish_target("prefs:quick_measure", check.rect); + }); + ui_kit::row(ui, "", |ui| { + let check = setting::viewport_analysis_status(app, ui).on_hover_text(app.tr("prefs.viewport_analysis_status_help")); + crate::scenario::publish_target("prefs:viewport_analysis_status", check.rect); + }); + ui_kit::row(ui, "", |ui| { + let check = setting::viewport_section_status(app, ui).on_hover_text(app.tr("prefs.viewport_section_status_help")); + crate::scenario::publish_target("prefs:viewport_section_status", check.rect); + }); + ui_kit::row(ui, "", |ui| { + let check = setting::viewport_status_details(app, ui).on_hover_text(app.tr("prefs.viewport_status_details_help")); + crate::scenario::publish_target("prefs:viewport_status_details", check.rect); + }); + ui_kit::row(ui, "", |ui| { + let check = setting::viewport_status_summary(app, ui).on_hover_text(app.tr("prefs.viewport_status_summary_help")); + crate::scenario::publish_target("prefs:viewport_status_summary", check.rect); + }); ui_kit::row(ui, app.tr_label("Visual style"), |ui| { let mut selected = usize::from(app.ui.visual_style.min(3)); ui_kit::dropdown(ui, "pref_style", &mut selected, &["Shaded with edges", "Shaded", "Wireframe", "Shaded with hidden edges"]); diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rs index 47b066e30..06e7e8e55 100644 --- a/crates/ui-egui/src/prefs/interface.rs +++ b/crates/ui-egui/src/prefs/interface.rs @@ -1,34 +1,13 @@ -//! Interface settings composition, using shared controls and previews. +//! Appearance and Layout settings composition, using shared controls and previews. use super::*; -/// Origin plane names: each choice shows the three names it gives (`XY / XZ / YZ`), with a note -/// that only the names shown change. -fn origin_plane_names(app: &mut SolveApp, ui: &mut egui::Ui) { - ui_kit::settings_section(ui, "origin_plane_names", app.tr("prefs.origin_plane_names"), |ui| { - let choices: Vec = - OriginPlaneNames::ALL.iter().map(|names| OriginPlaneNames::PLANES.map(|plane| names.label(plane)).join(" / ")).collect(); - let options: Vec<&str> = choices.iter().map(String::as_str).collect(); - let mut selected = OriginPlaneNames::ALL.iter().position(|names| *names == app.preferences.origin_plane_names).unwrap_or(0); - if ui_kit::settings_segments(ui, app.tr("prefs.origin_plane_names"), &mut selected, &options) - && let Some(names) = OriginPlaneNames::ALL.get(selected) - { - app.preferences.origin_plane_names = *names; - } - // Handles that don't depend on the language, by the choice's saved value. - for (choice, key) in choices.iter().zip(["xyz", "top_front_right"]) { - if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{choice}", app.tr("prefs.origin_plane_names"))) { - crate::scenario::publish_handle(&format!("prefs:origin_plane_names:{key}"), at); - } - } - let top = OriginPlaneNames::TopFrontRight; - let note = - crate::i18n::format("prefs.origin_plane_names_note", &[("top", top.label("XY")), ("front", top.label("XZ")), ("right", top.label("YZ"))]); - ui_kit::text(ui, ¬e, ui_kit::Text::Hint("origin_plane_names")); - }); -} - -pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { - ui_kit::settings_heading(ui, app.tr("prefs.interface"), app.tr("prefs.interface_note")); +pub(super) fn appearance(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { + ui_kit::settings_heading_with_tag( + ui, + app.tr("prefs.structure.appearance"), + app.tr("prefs.structure.appearance_note"), + Some(crate::settings_profiles::tag), + ); ui_kit::settings_section(ui, "theme", app.tr("ui.theme"), |ui| { theme_row(app, ui); theme_options_row(app, ui); @@ -73,6 +52,97 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { } }); }); + ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| { + ui_kit::settings_pair( + ui, + |ui| { + let response = ui_kit::slider( + ui, + &mut app.preferences.ui_scale, + 0.5..=2.5, + ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() }, + ); + crate::scenario::publish_target("prefs:scale", response.rect); + ui.horizontal_wrapped(|ui| { + let locale = crate::i18n::Locale::for_language(&app.preferences.language); + for value in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] { + let percent = format!("{:.0}", value * 100.0); + if ui_kit::button( + ui, + locale.format("prefs.structure.scale_percent", &[("percent", &percent)]), + if (app.preferences.ui_scale - value).abs() < 0.001 { ui_kit::Button::SmallSelected } else { ui_kit::Button::Small }, + ) + .clicked() + { + app.preferences.ui_scale = value; + } + } + }); + ui_kit::text(ui, app.tr("prefs.scale_note"), ui_kit::Text::Hint("scale")); + app.preferences.ui_scale + }, + ui_kit::scale_specimen, + ); + ui_kit::divider(ui, "scale_font"); + if !cfg!(target_arch = "wasm32") { + ui_kit::settings_font_row(ui, crate::i18n::tr("prefs.font"), |ui, part| { + if part == 0 { + ui_font_row(app, ui); + return; + } + if ui_kit::button(ui, app.tr("prefs.choose_font"), ui_kit::Button::Normal).clicked() { + app.pick_open_for(&["ttf", "otf", "ttc"], |app, path| { + if let Some(path) = path { + if crate::fonts::ui_font(&path).is_some() { + app.preferences.ui_font = path; + } else { + app.set_status(crate::i18n::tr("prefs.font_unreadable"), true); + } + } + }); + } + if ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Ghost).clicked() { + app.preferences.ui_font.clear(); + } + }); + ui_kit::font_specimen(ui, app.tr("prefs.font_sample")); + ui_kit::text(ui, app.tr("prefs.font_fallback"), ui_kit::Text::Hint("font_fallback")); + } + }); + ui_kit::settings_section(ui, "colour_vision", app.tr("ui.colour_vision"), |ui| { + let mode = app.preferences.color_vision; + ui.horizontal_wrapped(|ui| { + let modes = crate::theme::ColorVision::ALL; + let labels: Vec<_> = modes.iter().map(|m| crate::i18n::tr(m.label_id())).collect(); + let mut selected = modes.iter().position(|m| *m == mode).unwrap_or(0); + if ui_kit::settings_segments(ui, app.tr("ui.colour_vision_mode"), &mut selected, &labels) + && let Some(mode) = modes.get(selected) + { + app.preferences.color_vision = *mode; + } + if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", app.tr("ui.colour_vision_mode"))) { + crate::scenario::publish_target("prefs:color_vision", rect); + } + ui_kit::status_palette_sample(ui, app.preferences.color_vision); + }); + // What the modes recolour, in the mode being chosen (#7152): the status chips above keep + // their colours in every mode. + ui_kit::colour_vision_sample(ui, &crate::theme::Tokens::get_in(app.preferences.color_vision)); + if app.preferences.color_vision != mode { + ui.ctx().request_repaint(); + } + ui_kit::text(ui, app.tr("ui.colour_vision_note"), ui_kit::Text::Hint("colour_vision")); + }); +} + +pub(super) fn layout(app: &mut SolveApp, ui: &mut egui::Ui) { + let t = Tokens::get(); + ui_kit::settings_heading_with_tag( + ui, + app.tr("prefs.structure.layout"), + app.tr("prefs.structure.layout_note"), + Some(crate::settings_profiles::tag), + ); ui_kit::settings_section(ui, "layout", app.tr("prefs.layout"), |ui| { ui_kit::settings_pair( ui, @@ -99,22 +169,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { let check = setting::persistent_ribbon_pressed(app, ui).on_hover_text(app.tr("prefs.persistent_ribbon_pressed_help")); crate::scenario::publish_target("prefs:persistent_ribbon_pressed", check.rect); }); - ui_kit::row(ui, "", |ui| { - let check = setting::viewport_analysis_status(app, ui).on_hover_text(app.tr("prefs.viewport_analysis_status_help")); - crate::scenario::publish_target("prefs:viewport_analysis_status", check.rect); - }); - ui_kit::row(ui, "", |ui| { - let check = setting::viewport_section_status(app, ui).on_hover_text(app.tr("prefs.viewport_section_status_help")); - crate::scenario::publish_target("prefs:viewport_section_status", check.rect); - }); - ui_kit::row(ui, "", |ui| { - let check = setting::viewport_status_details(app, ui).on_hover_text(app.tr("prefs.viewport_status_details_help")); - crate::scenario::publish_target("prefs:viewport_status_details", check.rect); - }); - ui_kit::row(ui, "", |ui| { - let check = setting::viewport_status_summary(app, ui).on_hover_text(app.tr("prefs.viewport_status_summary_help")); - crate::scenario::publish_target("prefs:viewport_status_summary", check.rect); - }); // The SKETCH tab outside a sketch too (#7904). ui_kit::row(ui, "", |ui| { let check = setting::sketch_tab_always(app, ui).on_hover_text(app.tr("prefs.sketch_tab_always_note")); @@ -297,11 +351,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { let check = setting::status_bar(app, ui).on_hover_text(app.tr("prefs.status_bar_note")); crate::scenario::publish_target("prefs:status_bar", check.rect); }); - // The selection's measurement in the view's corner (#7000). - ui_kit::row(ui, "", |ui| { - let check = setting::quick_measure(app, ui).on_hover_text(app.tr("prefs.quick_measure_note")); - crate::scenario::publish_target("prefs:quick_measure", check.rect); - }); ui_kit::text(ui, app.tr("prefs.layout_note"), ui_kit::Text::Hint("layout")); ui_kit::text(ui, app.tr("prefs.history_sketches_note"), ui_kit::Text::Hint("history_sketches")); ui_kit::LayoutPreview { @@ -321,7 +370,6 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { ui_kit::layout_preview, ); }); - origin_plane_names(app, ui); super::navbar::show(app, ui); // The same choice as the toolbar's own menu (the plus after the tabs, or right-click a tab). ui_kit::settings_section(ui, "toolbar_tabs", app.tr("prefs.toolbar_tabs"), |ui| { @@ -334,83 +382,4 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { } } }); - ui_kit::settings_section(ui, "scale", app.tr("prefs.scale_text"), |ui| { - ui_kit::settings_pair( - ui, - |ui| { - let response = ui_kit::slider( - ui, - &mut app.preferences.ui_scale, - 0.5..=2.5, - ui_kit::Slider { step: Some(0.05), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() }, - ); - crate::scenario::publish_target("prefs:scale", response.rect); - ui.horizontal_wrapped(|ui| { - for value in [0.75, 1.0, 1.1, 1.25, 1.5, 2.0] { - if ui_kit::button( - ui, - format!("{:.0}%", value * 100.0), - if (app.preferences.ui_scale - value).abs() < 0.001 { ui_kit::Button::SmallSelected } else { ui_kit::Button::Small }, - ) - .clicked() - { - app.preferences.ui_scale = value; - } - } - }); - ui_kit::text(ui, app.tr("prefs.scale_note"), ui_kit::Text::Hint("scale")); - app.preferences.ui_scale - }, - ui_kit::scale_specimen, - ); - ui_kit::divider(ui, "scale_font"); - if !cfg!(target_arch = "wasm32") { - ui_kit::settings_font_row(ui, crate::i18n::tr("prefs.font"), |ui, part| { - if part == 0 { - ui_font_row(app, ui); - return; - } - if ui_kit::button(ui, app.tr("prefs.choose_font"), ui_kit::Button::Normal).clicked() { - app.pick_open_for(&["ttf", "otf", "ttc"], |app, path| { - if let Some(path) = path { - if crate::fonts::ui_font(&path).is_some() { - app.preferences.ui_font = path; - } else { - app.set_status(crate::i18n::tr("prefs.font_unreadable"), true); - } - } - }); - } - if ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Ghost).clicked() { - app.preferences.ui_font.clear(); - } - }); - ui_kit::font_specimen(ui, app.tr("prefs.font_sample")); - ui_kit::text(ui, app.tr("prefs.font_fallback"), ui_kit::Text::Hint("font_fallback")); - } - }); - ui_kit::settings_section(ui, "colour_vision", app.tr("ui.colour_vision"), |ui| { - let mode = app.preferences.color_vision; - ui.horizontal_wrapped(|ui| { - let modes = crate::theme::ColorVision::ALL; - let labels: Vec<_> = modes.iter().map(|m| crate::i18n::tr(m.label_id())).collect(); - let mut selected = modes.iter().position(|m| *m == mode).unwrap_or(0); - if ui_kit::settings_segments(ui, app.tr("ui.colour_vision_mode"), &mut selected, &labels) - && let Some(mode) = modes.get(selected) - { - app.preferences.color_vision = *mode; - } - if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", app.tr("ui.colour_vision_mode"))) { - crate::scenario::publish_target("prefs:color_vision", rect); - } - ui_kit::status_palette_sample(ui, app.preferences.color_vision); - }); - // What the modes recolour, in the mode being chosen (#7152): the status chips above keep - // their colours in every mode. - ui_kit::colour_vision_sample(ui, &crate::theme::Tokens::get_in(app.preferences.color_vision)); - if app.preferences.color_vision != mode { - ui.ctx().request_repaint(); - } - ui_kit::text(ui, app.tr("ui.colour_vision_note"), ui_kit::Text::Hint("colour_vision")); - }); } diff --git a/crates/ui-egui/src/prefs/navigation.rs b/crates/ui-egui/src/prefs/navigation.rs index 6f87e29bc..070035b5f 100644 --- a/crates/ui-egui/src/prefs/navigation.rs +++ b/crates/ui-egui/src/prefs/navigation.rs @@ -2,7 +2,7 @@ use super::*; pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { - ui_kit::settings_heading(ui, app.tr("prefs.navigation"), app.tr("prefs.navigation_note")); + ui_kit::settings_heading_with_tag(ui, app.tr("prefs.navigation"), app.tr("prefs.structure.navigation_note"), Some(crate::settings_profiles::tag)); ui_kit::settings_section(ui, "mouse", app.tr("prefs.mouse_heading"), |ui| { let mut gestures: Vec<_> = nav_preset(&app.preferences.nav) .bindings @@ -137,7 +137,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { .on_hover_text(if touchpad { crate::i18n::tr("nav.touchpad.scroll") } else { crate::i18n::tr("ui.trackpad_pan_tip") }); }); setting::radial_context_menu(app, ui); - setting::direct_interaction(app, ui); }); }); ui_kit::row(ui, app.tr("prefs.trackpad_zoom_modifier"), |ui| { @@ -159,8 +158,6 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { }) .on_hover_text(crate::i18n::tr("prefs.trackpad_zoom_modifier.help")); }); - let cursor = ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor); - crate::scenario::publish_target("view:tool_cursor", cursor.rect); ui_kit::divider(ui, "navigation_view_controls"); ui_kit::settings_form(ui, 150.0, |ui| { setting::wheel_zoom_speed(app, ui); @@ -221,31 +218,4 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) { // The existing ring editor is part of the real product and remains available. crate::mouse_gesture::nav_rows(app, ui, t); }); - // The 3D mouse is a section like the ones above: the driver, calibration, axes, picture and buttons - // (`prefs::space_mouse_section`). - space_mouse_section(app, ui); -} - -/// A device's own app on this computer driving the view (the navigation bridge): on or off, its -/// port, and whether an app is connected. Part of the 3D mouse section (`space_mouse_rows`). -pub(super) fn nav_bridge(app: &mut SolveApp, ui: &mut egui::Ui) { - let (label, tip, port) = (app.tr("ui.nav_bridge").to_owned(), app.tr("ui.nav_bridge_tip").to_owned(), app.tr("ui.nav_bridge_port").to_owned()); - let status = match (&app.space_mouse.bridge, app.preferences.nav_bridge_enabled) { - (_, false) => None, - (Some(name), true) => Some((format!("{} · {name}", app.tr("ui.nav_bridge_connected")), false)), - (None, true) => Some((app.tr("ui.nav_bridge_waiting").to_owned(), true)), - }; - ui.horizontal_wrapped(|ui| { - ui_kit::checkbox(ui, &label, &mut app.preferences.nav_bridge_enabled).on_hover_text(&tip); - if let Some((status, waiting)) = &status { - ui_kit::settings_badge(ui, status, *waiting); - } - }); - ui_kit::settings_form(ui, FORM_LABEL_WIDTH, |ui| { - ui_kit::row(ui, &port, |ui| { - ui.add_enabled_ui(app.preferences.nav_bridge_enabled, |ui| { - ui_kit::number_field(ui, &mut app.preferences.nav_bridge_port, 1..=u16::MAX, 1.0, ""); - }); - }); - }); } diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs index 3dceac304..23210022d 100644 --- a/crates/ui-egui/src/prefs/sketch.rs +++ b/crates/ui-egui/src/prefs/sketch.rs @@ -3,7 +3,12 @@ use super::*; pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { let t = Tokens::get(); - ui_kit::settings_heading(ui, app.tr("prefs.sketch_selection_heading"), app.tr("prefs.sketch_selection_note")); + ui_kit::settings_heading_with_tag( + ui, + app.tr("prefs.structure.sketch"), + app.tr("prefs.sketch_selection_note"), + Some(crate::settings_profiles::tag), + ); ui_kit::settings_section(ui, "sketch", app.tr("prefs.sketching"), |ui| { ui_kit::checkbox(ui, app.tr("prefs.sketch_tracking_guides"), &mut app.preferences.sketch_tracking_guides) .on_hover_text(app.tr("prefs.sketch_tracking_guides_note")); diff --git a/crates/ui-egui/src/prefs/tools.rs b/crates/ui-egui/src/prefs/tools.rs new file mode 100644 index 000000000..0ba3a8f38 --- /dev/null +++ b/crates/ui-egui/src/prefs/tools.rs @@ -0,0 +1,58 @@ +//! Existing modelling-tool controls, regrouped without changing their semantics. +use super::*; + +pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { + let t = Tokens::get(); + ui_kit::settings_heading(ui, app.tr("prefs.structure.tools"), app.tr("prefs.structure.tools_note")); + // The Hole command's own settings, under its name. + ui_kit::settings_section(ui, "create_hole", crate::i18n::tr_label("Create Hole"), |ui| { + setting::hole_snaps(app, ui); + ui_kit::text( + ui, + crate::i18n::tr_label("A Single hole snaps to the middle of its face and to the centres of its round edges"), + ui_kit::Text::Hint("hole_snaps"), + ); + setting::hole_moves(app, ui); + ui_kit::text( + ui, + crate::i18n::tr_label( + "A placed Single hole has a handle to drag it, and picking its face again moves the hole there instead of taking it out", + ), + ui_kit::Text::Hint("hole_moves"), + ); + }); + ui_kit::settings_section(ui, "extrude", app.tr_label("Extrude"), |ui| { + setting::extrude_auto_to_object(app, ui); + // Extrude's view (#9176): isometric when it opens, and back afterwards only with that. + setting::extrude_view_isometric(app, ui); + let isometric = app.preferences.extrude_view_isometric; + ui.add_enabled_ui(isometric, |ui| setting::extrude_view_return(app, ui)); + let auto = setting::auto_operation(app, ui); + crate::scenario::publish_handle("prefs:auto_operation", auto.rect.center()); + ui_kit::text(ui, app.tr("prefs.auto_operation_note"), ui_kit::Text::Hint("auto_operation")); + }); + ui_kit::settings_section(ui, "placement", app.tr("prefs.placement"), |ui| { + setting::placement_handles(app, ui); + }); + ui_kit::settings_section(ui, "joint_move", app.tr("joint_move.settings"), |ui| { + setting::assembly_move_handles(app, ui); + ui_kit::text(ui, app.tr("joint_move.legacy_hint"), ui_kit::Text::Hint("joint_move_legacy")); + ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| { + ui_kit::row(ui, app.tr("joint_move.coarse"), |ui| { + ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_coarse, 0.001..=180.0, 0.1); + }); + ui_kit::row(ui, app.tr("joint_move.fine"), |ui| { + ui_kit::settings_number(ui, &mut app.preferences.joint_rotation_fine, 0.001..=180.0, 0.01); + }); + }); + ui_kit::text(ui, app.tr("joint_move.precision"), ui_kit::Text::Hint("joint_move")); + }); + ui_kit::settings_section(ui, "measure_pointer", app.tr("prefs.structure.measure_pointer"), |ui| { + let response = setting::measure_axis_distances(app, ui); + crate::scenario::publish_rect("prefs:measure_axis_distances", response.rect); + response.on_hover_text(app.tr("settings.measure_axis_distances_help")); + let cursor = ui_kit::checkbox(ui, crate::i18n::tr_label("Show tool at cursor"), &mut app.ui.tool_cursor); + crate::scenario::publish_target("view:tool_cursor", cursor.rect); + setting::direct_interaction(app, ui); + }); +} diff --git a/crates/ui-egui/src/prefs_search.rs b/crates/ui-egui/src/prefs_search.rs index ad9514bf4..72796dd1b 100644 --- a/crates/ui-egui/src/prefs_search.rs +++ b/crates/ui-egui/src/prefs_search.rs @@ -783,6 +783,13 @@ mod tests { h.step(&serde_json::json!({"key": "ArrowUp"})).expect("previous match"); h.frames(1); assert_eq!(crate::scenario::handle_at("prefs:search:current"), first, "Up moves back"); + let (_, _, hits) = nav(&h.ctx); + let cursor = hits + .iter() + .position(|hit| hit.page == crate::prefs::PAGE_NAVIGATION && hit.label == "Reverse zoom direction") + .expect("the Navigation setting remains keyboard reachable"); + set_cursor(&h.ctx, cursor); + h.frames(2); h.step(&serde_json::json!({"key": "Enter"})).expect("open"); h.frames(2); assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_NAVIGATION, "Enter opens the match's page"); @@ -905,7 +912,7 @@ mod tests { fn preferences_search_finds_settings_in_rows_without_a_label() { let mut h = crate::scenario::Harness::new(); h.app.home.open = false; - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_INTERFACE); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_LAYOUT); h.frames(2); // Drawn, not merely present: a hidden row's controls still exist, far off screen. let drawn = |h: &crate::scenario::Harness, label: &str| { @@ -939,4 +946,29 @@ mod tests { h.frames(4); assert!(!drawn(&h, "Status bar"), "a miss shows nothing"); } + #[test] + fn moved_preferences_search_paths_and_enter_follow_window_groups() { + for (query, path, page) in [ + ("Direct interaction", "Work > Tools", crate::prefs::PAGE_TOOLS), + ("Navigate with the 3D mouse", "Input > 3D mouse", crate::prefs::PAGE_MOUSE3D), + ("Origin plane names", "Work > Design", crate::prefs::PAGE_DESIGN), + ("Status bar", "Look > Layout", crate::prefs::PAGE_LAYOUT), + ] { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL); + h.app.prefs_window.filter = query.into(); + h.frames(4); + assert!(h.widget(path).is_some(), "{query} shows {path}"); + let (_, _, hits) = nav(&h.ctx); + let index = hits.iter().position(|hit| hit.page == page && hit.label == query).expect("moved control is keyboard reachable"); + set_cursor(&h.ctx, index); + h.frames(2); + h.step(&serde_json::json!({"key":"Enter"})).unwrap(); + h.frames(2); + assert_eq!(h.app.prefs_window.section, page); + assert!(h.app.prefs_window.filter.is_empty()); + assert!(h.widget(query).is_some()); + } + } } diff --git a/crates/ui-egui/src/settings_profiles.rs b/crates/ui-egui/src/settings_profiles.rs index f0c82d5c2..ce3b30993 100644 --- a/crates/ui-egui/src/settings_profiles.rs +++ b/crates/ui-egui/src/settings_profiles.rs @@ -1,8 +1,8 @@ //! Settings profiles (#6237): the input and interface settings kept together under a name, such -//! as "Laptop" and "Large monitor", and switched at once. A profile holds the preferences of the -//! Interface, Navigation and Sketch pages and the language, the keyboard shortcuts, the toolbar -//! and the S box favourites, and the imported theme it uses. Machine-specific settings stay out: -//! the 3D mouse, graphics, recent files and the AI pages. +//! as "Laptop" and "Large monitor", and switched at once. A profile holds the original Interface, +//! Navigation and Sketch preference keys and the language, keyboard shortcuts, toolbar, +//! S box favourites, and imported theme it uses. Page moves preserve that stored key set; +//! device-specific 3D mouse keys, graphics, recent files and Assistant settings stay out. //! //! A profile is kept, exported and imported as one `solidcraft-profile/1` document. Every //! document is checked by [`sanitize`] first: unknown keys are dropped, sizes are capped, and a @@ -34,24 +34,108 @@ const MAX_THEMES: usize = 4; /// Most characters in a command id or a key name. const MAX_ID: usize = 200; -/// The Preferences pages whose settings a profile holds. -const PAGES: [usize; 3] = [prefs::PAGE_INTERFACE, prefs::PAGE_NAVIGATION, prefs::PAGE_SKETCH]; -/// Settings a profile holds from other pages. -const ALSO: [&str; 1] = ["language"]; - -/// Settings of those pages that belong to the computer, not the person: the 3D mouse (its -/// calibration, driver and axes) and the cursor flag older releases saved. -fn machine_specific(key: &str) -> bool { - key.starts_with("space_mouse_") || key == "orbit_cursor" -} +/// The 93 stored keys from the pre-split Interface, Navigation and Sketch pages, plus +/// language, excluding space_mouse_* and orbit_cursor. Page moves and title tags must never +/// change profile contents (including the bridge, origin names and direct interaction). +const PROFILE_KEYS: &[&str] = &[ + "browser_bodies_folders", + "browser_collapsed", + "browser_eye_left", + "browser_float", + "browser_share", + "browser_show", + "browser_width", + "center_arc_follows_cursor", + "color_vision", + "dialog_buttons", + "dialog_place", + "direct_interaction", + "free_orbit", + "free_orbit_upright", + "hidden_toolbar_tabs", + "hide_constraint_glyphs_zoomed_out", + "history_in_browser", + "history_play_button", + "history_sketches", + "keep_work_on_tab_switch", + "language", + "layout", + "line_drag_draws_one", + "line_hover_tangent_arc", + "logo_accent", + "look_at_anim", + "look_at_speed", + "manipulator_free_alt", + "middle_double_click", + "mouse_gestures", + "nav", + "nav_bridge_enabled", + "nav_bridge_port", + "navigation_bar", + "navigator_style", + "orbit_around", + "orbit_reverse", + "origin_plane_names", + "pan_reverse_x", + "pan_reverse_y", + "persistent_ribbon_pressed", + "prefer_free_sketch_points", + "project_options_dialog", + "quick_measure", + "radial_context_menu", + "ribbon_icon_grid", + "ribbon_labels", + "ribbon_menus_skip_pinned", + "ribbon_reveal", + "right_drag_orbits", + "select_other_hidden", + "selection_shift_add_only", + "shortcut_cycles_modes", + "sketch_align_points", + "sketch_auto_dimensions", + "sketch_auto_locate", + "sketch_conflict_colour", + "sketch_construction_lines", + "sketch_exit_view", + "sketch_open_look_at", + "sketch_recent_snap", + "sketch_state_icons", + "sketch_tab_always", + "sketch_tracking_guides", + "sketch_tracking_points", + "smooth_wheel_zoom", + "status_bar", + "suppress_sketch_snap", + "theme", + "theme_follow", + "theme_options", + "timeline_collapsed", + "timeline_left", + "timeline_left_browser_collapsed", + "timeline_left_width", + "timeline_origin_bodies", + "timeline_under_browser", + "toast_place", + "trackpad_pan", + "trackpad_zoom_modifier", + "ui_font", + "ui_scale", + "view_confirm_corner", + "viewport_analysis_status", + "viewport_background", + "viewport_section_status", + "viewport_status_details", + "viewport_status_summary", + "viewport_theme", + "wheel_zoom_speed", + "zoom_reverse", + "zoom_stop_at_model", + "zoom_to_cursor", +]; /// The preferences a profile holds, by their stored key. pub fn keys() -> impl Iterator { - prefs::FIELD_PAGES - .iter() - .filter(|(key, page)| ALSO.contains(key) || page.is_some_and(|page| PAGES.contains(&page))) - .map(|(key, _)| *key) - .filter(|key| !machine_specific(key)) + prefs::FIELD_PAGES.iter().map(|(key, _)| *key).filter(|key| PROFILE_KEYS.contains(key)) } /// The kept profiles, which one was applied or saved last, and the Preferences section's state. @@ -520,3 +604,59 @@ pub(crate) fn section(app: &mut SolveApp, ui: &mut egui::Ui, labels: f32) { } }); } + +/// The pinned profile switcher on every Preferences page. Actions use the same commands as +/// General > Profiles; saving a new name remains in that existing section. +pub(crate) fn sidebar(ui: &mut egui::Ui, app: &mut SolveApp) { + ui_kit::divider(ui, "profile_sidebar"); + ui_kit::text(ui, app.tr("prefs.structure.profile"), ui_kit::Text::Heading("profile_sidebar")); + let active = app.settings_profiles.active.clone(); + let edited = active.as_ref().is_some_and(|name| app.settings_profiles.get(name).is_ok_and(|doc| *doc != capture(app, name))); + let current = active.clone().unwrap_or_else(|| app.tr_label("None").to_string()); + let names = app.settings_profiles.names(); + let mut apply = None; + let mut save = false; + ui.horizontal(|ui| { + let t = crate::theme::Tokens::get(); + let width = ui.available_width() - if edited { t.space_16 + ui.spacing().item_spacing.x } else { 0.0 }; + let response = ui_kit::settings_control_width(ui, width, |ui| { + ui_kit::dropdown_menu(ui, "profile_sidebar", ¤t, |ui| { + for name in &names { + if ui_kit::list_picker(ui, name, name, active.as_ref() == Some(name)).clicked() { + apply = Some(name.clone()); + } + } + if let Some(name) = &active + && ui_kit::button(ui, app.tr("prefs.profile_save"), ui_kit::Button::Normal).clicked() + { + save = true; + apply = None; + app.settings_profiles.draft = name.clone(); + ui.close(); + } + if ui_kit::button(ui, app.tr("prefs.profiles"), ui_kit::Button::Normal).clicked() { + prefs::open_profiles(app); + ui.close(); + } + }) + }); + crate::scenario::publish_target("prefs:profile", response.rect); + if edited { + let dot = ui_kit::status_line(ui, "●", ui_kit::StatusTone::Warning).on_hover_text(app.tr("prefs.structure.profile_edited")); + crate::scenario::publish_target("prefs:profile:edited", dot.rect); + } + }); + if let Some(name) = apply { + app.settings_profiles.draft = name.clone(); + act(app, "settings.profile.apply", json!({"name":name}), "prefs.profile_applied"); + } else if save && let Some(name) = active { + act(app, "settings.profile.save", json!({"name":name}), "prefs.profile_saved"); + } +} + +/// Page-title tag. Membership is descriptive; the stable key list above governs storage. +pub(crate) fn tag(ui: &mut egui::Ui) { + let response = + ui_kit::workspace_chip(ui, crate::i18n::tr("prefs.structure.in_profile")).on_hover_text(crate::i18n::tr("prefs.structure.profile_hover")); + crate::scenario::publish_target("prefs:in_profile", response.rect); +} diff --git a/crates/ui-egui/src/settings_profiles_tests.rs b/crates/ui-egui/src/settings_profiles_tests.rs index 5292a0bd6..c9fc6dead 100644 --- a/crates/ui-egui/src/settings_profiles_tests.rs +++ b/crates/ui-egui/src/settings_profiles_tests.rs @@ -35,9 +35,12 @@ fn a_profile_holds_input_and_interface_settings_but_not_the_machine() { "space_mouse_calibrations", "space_mouse_driver", "space_mouse_speed", + "dark_parts_shading", "msaa", "window_system", "default_units", + "extrude_view_isometric", + "extrude_view_return", "update", "agents", "custom_themes", @@ -344,3 +347,181 @@ fn choosing_a_profile_in_preferences_applies_it() { assert_eq!(h.app.settings_profiles.active.as_deref(), Some("Large monitor")); assert!(h.app.preferences.zoom_reverse); } + +#[test] +fn profile_keys_preserve_the_literal_pre_split_baseline() { + let expected = [ + "browser_bodies_folders", + "browser_collapsed", + "browser_eye_left", + "browser_float", + "browser_share", + "browser_show", + "browser_width", + "center_arc_follows_cursor", + "color_vision", + "dialog_buttons", + "dialog_place", + "direct_interaction", + "free_orbit", + "free_orbit_upright", + "hidden_toolbar_tabs", + "hide_constraint_glyphs_zoomed_out", + "history_in_browser", + "history_play_button", + "history_sketches", + "keep_work_on_tab_switch", + "language", + "layout", + "line_drag_draws_one", + "line_hover_tangent_arc", + "logo_accent", + "look_at_anim", + "look_at_speed", + "manipulator_free_alt", + "middle_double_click", + "mouse_gestures", + "nav", + "nav_bridge_enabled", + "nav_bridge_port", + "navigation_bar", + "navigator_style", + "orbit_around", + "orbit_reverse", + "origin_plane_names", + "pan_reverse_x", + "pan_reverse_y", + "persistent_ribbon_pressed", + "prefer_free_sketch_points", + "project_options_dialog", + "quick_measure", + "radial_context_menu", + "ribbon_icon_grid", + "ribbon_labels", + "ribbon_menus_skip_pinned", + "ribbon_reveal", + "right_drag_orbits", + "select_other_hidden", + "selection_shift_add_only", + "shortcut_cycles_modes", + "sketch_align_points", + "sketch_auto_dimensions", + "sketch_auto_locate", + "sketch_conflict_colour", + "sketch_construction_lines", + "sketch_exit_view", + "sketch_open_look_at", + "sketch_recent_snap", + "sketch_state_icons", + "sketch_tab_always", + "sketch_tracking_guides", + "sketch_tracking_points", + "smooth_wheel_zoom", + "status_bar", + "suppress_sketch_snap", + "theme", + "theme_follow", + "theme_options", + "timeline_collapsed", + "timeline_left", + "timeline_left_browser_collapsed", + "timeline_left_width", + "timeline_origin_bodies", + "timeline_under_browser", + "toast_place", + "trackpad_pan", + "trackpad_zoom_modifier", + "ui_font", + "ui_scale", + "view_confirm_corner", + "viewport_analysis_status", + "viewport_background", + "viewport_section_status", + "viewport_status_details", + "viewport_status_summary", + "viewport_theme", + "wheel_zoom_speed", + "zoom_reverse", + "zoom_stop_at_model", + "zoom_to_cursor", + ]; + let mut actual: Vec<_> = keys().collect(); + actual.sort_unstable(); + assert_eq!(expected.len(), 93); + assert_eq!(actual, expected); +} + +#[test] +fn moved_profile_settings_survive_saved_roundtrip_and_apply() { + let mut h = Harness::new(); + let defaults = crate::prefs::Prefs::default(); + assert!(!defaults.keep_work_on_tab_switch && !defaults.line_hover_tangent_arc); + for (key, page) in [("keep_work_on_tab_switch", crate::prefs::PAGE_LAYOUT), ("line_hover_tangent_arc", crate::prefs::PAGE_SKETCH)] { + let homes: Vec<_> = crate::prefs::FIELD_PAGES.iter().filter_map(|(field, page)| (*field == key).then_some(*page)).collect(); + assert_eq!(homes, [Some(page)], "{key} keeps its new page home"); + } + h.app.preferences.nav_bridge_enabled = true; + h.app.preferences.nav_bridge_port = 9876; + h.app.preferences.origin_plane_names = crate::prefs::OriginPlaneNames::TopFrontRight; + h.app.preferences.direct_interaction = true; + h.app.preferences.quick_measure = true; + h.app.preferences.viewport_analysis_status = false; + h.app.preferences.keep_work_on_tab_switch = true; + h.app.preferences.line_hover_tangent_arc = true; + run(&mut h, "settings.profile.save", json!({"name":"Moved"})); + let saved = h.app.settings_profiles.prefs(); + let doc = h.app.settings_profiles.list[0].clone(); + assert_eq!(doc["preferences"]["keep_work_on_tab_switch"], true); + assert_eq!(doc["preferences"]["line_hover_tangent_arc"], true); + assert!(doc["preferences"].get("dark_parts_shading").is_none()); + assert_eq!(sanitize(&doc).unwrap(), doc); + h.app.settings_profiles.load(&serde_json::from_str::(&serde_json::to_string(&saved).unwrap()).unwrap()); + assert_eq!(h.app.settings_profiles.list[0], doc); + h.app.preferences.nav_bridge_enabled = false; + h.app.preferences.nav_bridge_port = 8765; + h.app.preferences.origin_plane_names = crate::prefs::OriginPlaneNames::Xyz; + h.app.preferences.direct_interaction = false; + h.app.preferences.quick_measure = false; + h.app.preferences.viewport_analysis_status = true; + h.app.preferences.keep_work_on_tab_switch = false; + h.app.preferences.line_hover_tangent_arc = false; + let out = run(&mut h, "settings.profile.apply", json!({"name":"Moved"})); + assert_eq!(out["skipped"], json!([])); + assert!(h.app.preferences.keep_work_on_tab_switch && h.app.preferences.line_hover_tangent_arc); + assert_eq!(capture(&h.app, "Moved"), doc); +} + +#[test] +fn profile_sidebar_switches_saves_and_marks_edits_with_existing_commands() { + let mut h = Harness::new(); + h.app.home.open = false; + run(&mut h, "settings.profile.save", json!({"name":"Laptop"})); + h.app.preferences.zoom_reverse = true; + run(&mut h, "settings.profile.save", json!({"name":"Desk"})); + h.call("ui.prefs", json!({"open":"Tools"})); + h.frames(3); + assert!(crate::scenario::rect_of("prefs:profile:edited").is_none()); + h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap(); + h.frames(2); + h.step(&json!({"click":{"handle":"dialog:list:Laptop"}})).unwrap(); + h.frames(3); + assert_eq!(h.app.settings_profiles.active.as_deref(), Some("Laptop")); + assert!(!h.app.preferences.zoom_reverse); + h.app.preferences.direct_interaction = true; + h.frames(3); + assert!(crate::scenario::rect_of("prefs:profile:edited").is_some()); + h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap(); + h.frames(2); + h.step(&json!({"widget":"Save"})).unwrap(); + h.frames(3); + assert!(crate::scenario::rect_of("prefs:profile:edited").is_none()); + assert!(h.app.prefs_window.open, "saving a profile keeps Preferences open"); + let saved = run(&mut h, "settings.profile.export", json!({"name":"Laptop"})); + assert_eq!(saved["profile"]["preferences"]["direct_interaction"], true); + h.step(&json!({"click":{"handle":"prefs:profile"}})).unwrap(); + h.frames(2); + let profiles_label = h.app.tr("prefs.profiles").to_string(); + h.step(&json!({"widget":profiles_label})).unwrap(); + h.frames(3); + assert_eq!(h.app.prefs_window.section, crate::prefs::PAGE_GENERAL); +} diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rs index d78e478e0..2cb1a4062 100644 --- a/crates/ui-egui/src/shell_tests.rs +++ b/crates/ui-egui/src/shell_tests.rs @@ -592,7 +592,7 @@ fn compact_layout_is_saved_and_survives_cancel_apply_defaults_and_bad_input() { let design = h.app.session.doc.to_json(); let undo = h.app.session.undo.len(); let camera = h.app.cam; - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); crate::prefs::reveal_preference(&mut h, "dialog:Workspace:Compact"); h.step(&json!({"click":{"handle":"dialog:Workspace:Compact"}})).unwrap(); h.call("ui.prefs", json!({"button":"ok"})); @@ -609,15 +609,15 @@ fn compact_layout_is_saved_and_survives_cancel_apply_defaults_and_bad_input() { restored.load_prefs(&h.app.prefs()); assert_eq!(restored.ui.layout, LayoutMode::Docked); assert_eq!(restored.preferences.layout, LayoutMode::Docked); - h.call("ui.prefs", json!({"open":"Interface","layout":"floating"})); + h.call("ui.prefs", json!({"open":"Layout","layout":"floating"})); h.call("ui.prefs", json!({"button":"cancel"})); assert_eq!(h.app.ui.layout, LayoutMode::Docked); - h.call("ui.prefs", json!({"open":"Interface","layout":"floating"})); + h.call("ui.prefs", json!({"open":"Layout","layout":"floating"})); h.call("ui.prefs", json!({"button":"apply"})); h.call("ui.prefs", json!({"layout":"compact"})); h.call("ui.prefs", json!({"button":"cancel"})); assert_eq!(h.app.ui.layout, LayoutMode::Floating); - h.call("ui.prefs", json!({"open":"Interface","layout":"compact"})); + h.call("ui.prefs", json!({"open":"Layout","layout":"compact"})); h.call("ui.prefs", json!({"button":"defaults"})); assert_eq!(h.app.ui.layout, LayoutMode::Floating); assert_eq!(h.app.preferences.layout, LayoutMode::Floating); @@ -929,7 +929,7 @@ fn the_view_corner_answers_a_dialog_in_the_left_column() { } } -/// Dialogs is an Interface preference: set from the page or the control channel, saved, +/// Dialogs is a Layout preference: set from the page or the control channel, saved, /// refused when unknown, and Cancel and Restore Defaults put it back. A dialog already open /// moves with it. #[test] @@ -941,7 +941,7 @@ fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() { h.settle(); let right = h.app.viewport.dialog_rect.unwrap(); assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); crate::prefs::reveal_preference(&mut h, "dialog:Dialogs:In the left column"); h.step(&json!({"click":{"handle":"dialog:Dialogs:In the left column"}})).unwrap(); assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn); @@ -952,10 +952,10 @@ fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() { let mut restored = crate::SolveApp::new(Default::default(), Default::default()); restored.load_prefs(&h.app.prefs()); assert_eq!(restored.preferences.dialog_place, DialogPlace::LeftColumn); - h.call("ui.prefs", json!({"open":"Interface","dialog_place":"edge"})); + h.call("ui.prefs", json!({"open":"Layout","dialog_place":"edge"})); h.call("ui.prefs", json!({"button":"cancel"})); assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); h.call("ui.prefs", json!({"button":"defaults"})); assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge); h.call("ui.prefs", json!({"button":"ok"})); diff --git a/crates/ui-egui/src/space_mouse.rs b/crates/ui-egui/src/space_mouse.rs index 3e8552fde..7dd0a9145 100644 --- a/crates/ui-egui/src/space_mouse.rs +++ b/crates/ui-egui/src/space_mouse.rs @@ -307,7 +307,7 @@ pub fn buttons_hook(app: &mut SolveApp, ctx: &egui::Context, seen: Buttons, raw: fn run_button_job(app: &mut SolveApp, job: &ButtonJob, modifiers: egui::Modifiers, raw: &mut egui::RawInput) { match job { // Navigation, where the 3D mouse's section is. - ButtonJob::Settings => crate::prefs::open_at(app, crate::prefs::PAGE_NAVIGATION), + ButtonJob::Settings => crate::prefs::open_at(app, crate::prefs::PAGE_MOUSE3D), ButtonJob::View(view) => app.animate_view(view), ButtonJob::Key(ButtonKey::Esc) => { for pressed in [true, false] { diff --git a/crates/ui-egui/src/space_mouse_offer.rs b/crates/ui-egui/src/space_mouse_offer.rs index 07013f06f..1effc7b7d 100644 --- a/crates/ui-egui/src/space_mouse_offer.rs +++ b/crates/ui-egui/src/space_mouse_offer.rs @@ -222,7 +222,7 @@ pub fn act(app: &mut SolveApp, ctx: &egui::Context, offer: &Offer, action: Actio app.preferences.space_mouse_offered.insert(offer.device.clone()); if action == Action::Calibrate { // The calibration window lives with Preferences, at Navigation. - crate::prefs::open_at(app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(app, crate::prefs::PAGE_MOUSE3D); crate::space_mouse_calibration::start(app); } } @@ -391,7 +391,7 @@ mod preferences_tests { h.app.space_mouse.device = Some("hid 046d:c62b".into()); h.frames(3); if open_first { - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); } for _ in 0..frames_before { h.frame(); @@ -879,7 +879,7 @@ mod preferences_tests { h.app.preferences.space_mouse_calibrations.insert("hid 046d:c62b".into(), calibration); h.app.space_mouse.device = Some("hid 046d:c62b".into()); if prefs_open { - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); } run(&mut h, 2.0); assert_eq!(crate::space_mouse::calibration(&h.app), Some(calibration)); @@ -918,7 +918,7 @@ mod preferences_tests { let mut h = spacenavd_harness(); run(&mut h, 2.0); assert!(card_up(&h)); - crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_NAVIGATION); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_MOUSE3D); run(&mut h, 3.0); assert!(!card_up(&h), "no card over Preferences"); h.app.prefs_window.open = false; diff --git a/crates/ui-egui/src/tool_cursor.rs b/crates/ui-egui/src/tool_cursor.rs index 7249b3643..aeffb0355 100644 --- a/crates/ui-egui/src/tool_cursor.rs +++ b/crates/ui-egui/src/tool_cursor.rs @@ -95,10 +95,10 @@ mod tests { } #[test] - fn navigation_preference_restores_tool_badge_on_cancel_and_defaults() { + fn tools_preference_restores_tool_badge_on_cancel_and_defaults() { let mut h = Harness::new(); h.app.home.open = false; - h.call("ui.prefs", json!({"open":"Navigation"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.frames(4); crate::prefs::reveal_preference(&mut h, "view:tool_cursor"); h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap(); @@ -106,7 +106,7 @@ mod tests { h.call("ui.prefs", json!({"button":"cancel"})); assert!(!h.app.ui.tool_cursor); h.app.ui.tool_cursor = true; - h.call("ui.prefs", json!({"open":"Navigation"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.call("ui.prefs", json!({"button":"defaults"})); assert!(!h.app.ui.tool_cursor); h.call("ui.prefs", json!({"button":"cancel"})); @@ -114,10 +114,10 @@ mod tests { } #[test] - fn navigation_preference_keeps_applied_tool_badge_after_restart() { + fn tools_preference_keeps_applied_tool_badge_after_restart() { let mut h = Harness::new(); h.app.home.open = false; - h.call("ui.prefs", json!({"open":"Navigation"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.frames(4); crate::prefs::reveal_preference(&mut h, "view:tool_cursor"); h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap(); @@ -129,7 +129,7 @@ mod tests { assert!(restarted.ui.tool_cursor, "an explicitly enabled tool badge survives a restart"); // Turning it off must replace a previously saved true value too. - h.call("ui.prefs", json!({"open":"Navigation"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.frames(4); crate::prefs::reveal_preference(&mut h, "view:tool_cursor"); h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap(); @@ -140,11 +140,11 @@ mod tests { } #[test] - fn navigation_preference_does_not_save_unapplied_tool_badge_changes() { + fn tools_preference_does_not_save_unapplied_tool_badge_changes() { let mut h = Harness::new(); h.app.home.open = false; let saved = |h: &Harness| serde_json::from_str::(&h.app.prefs()).unwrap()["tool_cursor"].clone(); - h.call("ui.prefs", json!({"open":"Navigation"})); + h.call("ui.prefs", json!({"open":"Tools"})); h.frames(4); crate::prefs::reveal_preference(&mut h, "view:tool_cursor"); h.step(&json!({"click":{"handle":"view:tool_cursor"}})).unwrap(); @@ -179,21 +179,21 @@ mod tests { fn badge_shows_the_running_tool_beside_the_pointer() { let mut h = Harness::new(); h.settle(); - // Off by default: a running tool shows no badge until Navigation preferences turn it on. + // Off by default: a running tool shows no badge until Tools preferences turn it on. assert!(!h.app.ui.tool_cursor, "the badge is on by default"); h.step(&json!({"start": "sketch.create"})).unwrap(); let (_, badge) = hover_middle(&mut h); assert!(badge.is_none(), "off by default, yet a badge is drawn at {badge:?}"); h.step(&json!({"key": "Escape"})).unwrap(); h.settle(); - // The board's Display menu omits this preference; Navigation keeps its checkbox. - h.call("ui.prefs", json!({"open":"Navigation"})); + // The board's Display menu omits this preference; Tools keeps its checkbox. + h.call("ui.prefs", json!({"open":"Tools"})); h.frames(4); crate::prefs::reveal_preference(&mut h, "view:tool_cursor"); h.step(&json!({"click": {"handle": "view:tool_cursor"}})).unwrap(); h.call("ui.prefs", json!({"button":"ok"})); h.frames(2); - assert!(h.app.ui.tool_cursor, "the Navigation preferences checkbox did not turn the badge on"); + assert!(h.app.ui.tool_cursor, "the Tools preferences checkbox did not turn the badge on"); let (_, badge) = hover_middle(&mut h); assert!(badge.is_none(), "no tool runs, yet a badge is drawn at {badge:?}"); @@ -214,7 +214,7 @@ mod tests { // The coordinate readout starts READOUT below and right of the pointer: no overlap. assert!(badge.bottom() < at.y + READOUT.y, "the badge {badge:?} covers the readout under {at:?}"); - // Turned off in Navigation preferences. + // Turned off in Tools preferences. h.app.ui.tool_cursor = false; let (_, badge) = hover_middle(&mut h); assert!(badge.is_none(), "turned off, yet a badge is drawn at {badge:?}"); diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rs index d6251fa70..a9d3c0914 100644 --- a/crates/ui-egui/src/ui_kit/panel.rs +++ b/crates/ui-egui/src/ui_kit/panel.rs @@ -1106,7 +1106,7 @@ impl<'a> Window<'a> { state: &mut S, left: impl FnOnce(&mut Ui), ) -> (bool, super::Action) { - self.show_pages_inner(ctx, selected, pages, state, None, None, left) + self.show_pages_inner(ctx, selected, pages, state, None, None, None, left) } /// Page navigation with a strip above the page body (Preferences search). @@ -1119,9 +1119,10 @@ impl<'a> Window<'a> { state: &mut S, header: fn(&mut Ui, &mut S), on_select: fn(&mut S), + sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>, left: impl FnOnce(&mut Ui), ) -> (bool, super::Action) { - self.show_pages_inner(ctx, selected, pages, state, Some(header), Some(on_select), left) + self.show_pages_inner(ctx, selected, pages, state, Some(header), Some(on_select), sidebar_footer, left) } fn show_pages_inner( @@ -1132,13 +1133,14 @@ impl<'a> Window<'a> { state: &mut S, header: Option, on_select: Option, + sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>, left: impl FnOnce(&mut Ui), ) -> (bool, super::Action) { self.body_padding = false; self.page_chrome = true; let rows = self.page_rows; let padding = self.page_padding; - self.show_with_left(ctx, true, |ui| page_list_sized(ui, selected, pages, state, rows, padding, header, on_select), left) + self.show_with_left(ctx, true, |ui| page_list_sized(ui, selected, pages, state, rows, padding, header, on_select, sidebar_footer), left) } /// The same bounded card frame, either movable or an input-blocking modal. @@ -1206,7 +1208,7 @@ pub(crate) struct WindowPage { #[cfg(test)] pub(super) fn page_list(ui: &mut Ui, selected: &mut usize, pages: &[WindowPage], state: &mut S) { - page_list_sized(ui, selected, pages, state, 16.0, egui::Margin::same(Tokens::get().space_16 as i8), None, None); + page_list_sized(ui, selected, pages, state, 16.0, egui::Margin::same(Tokens::get().space_16 as i8), None, None, None); } fn page_list_sized( @@ -1218,6 +1220,7 @@ fn page_list_sized( padding: egui::Margin, header: Option, on_select: Option, + sidebar_footer: Option<(f32, fn(&mut Ui, &mut S))>, ) { let t = Tokens::get(); // The search strip, the gap under it, and the following item spacing sit above the page. @@ -1237,10 +1240,19 @@ fn page_list_sized( t.secondary_vline(ui.painter(), nav.right(), nav.y_range(), t.dialog_rule); scenario::publish_rect("dialog:pages", nav); *selected = (*selected).min(pages.len().saturating_sub(1)); - ui.scope_builder(egui::UiBuilder::new().max_rect(nav.shrink2(vec2(t.space_8, t.space_6))), |ui| { + let nav_inner = nav.shrink2(vec2(t.space_8, t.space_6)); + let footer_height = sidebar_footer.map_or(0.0, |(height, _)| dimension(height).min(nav_inner.height())); + let list = egui::Rect::from_min_max(nav_inner.min, egui::pos2(nav_inner.right(), nav_inner.bottom() - footer_height)); + ui.scope_builder(egui::UiBuilder::new().max_rect(list), |ui| { ui.set_clip_rect(ui.clip_rect().intersect(nav)); ui.spacing_mut().item_spacing.y = t.space_2; - egui::ScrollArea::vertical().id_salt("window_pages").show(ui, |ui| { + let selection_id = ui.id().with("page_selection"); + let changed = ui.data_mut(|data| { + let previous = data.get_temp::(selection_id); + data.insert_temp(selection_id, *selected); + previous != Some(*selected) + }); + egui::ScrollArea::vertical().id_salt("window_pages").max_height(list.height()).show(ui, |ui| { for (index, page) in pages.iter().enumerate() { if let Some(group) = page.group { ui.add_space(t.space_8); @@ -1258,6 +1270,9 @@ fn page_list_sized( } } let on = *selected == index; + if on && changed && sidebar_footer.is_some() && !list.contains_rect(rect) { + response.scroll_to_me(Some(egui::Align::Center)); + } if on || response.hovered() || response.has_focus() { ui.painter().rect_filled(rect, t.control_radius, if on { t.selected_bg } else { t.hover }); } @@ -1283,6 +1298,14 @@ fn page_list_sized( } }); }); + if let Some((_, footer)) = sidebar_footer { + let rect = egui::Rect::from_min_max(egui::pos2(nav_inner.left(), list.bottom()), nav_inner.max); + ui.scope_builder(egui::UiBuilder::new().id_salt("pages_footer").max_rect(rect), |ui| { + ui.set_clip_rect(ui.clip_rect().intersect(rect)); + footer(ui, state); + }); + scenario::publish_rect("dialog:pages_footer", rect); + } let content = egui::Rect::from_min_max(egui::pos2(nav.right(), body.top()), body.max); let padding = egui::epaint::MarginF32 { left: padding.leftf().min(content.width() / 2.0), diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rs index 616c86d1b..ea676ffd2 100644 --- a/crates/ui-egui/src/ui_kit/panel_tests.rs +++ b/crates/ui-egui/src/ui_kit/panel_tests.rs @@ -856,6 +856,19 @@ fn preferences_preserves_every_page_and_footer_in_both_themes() { } assert!(scenario::rect_of("prefs:page_body").is_some()); assert!(h.widget(h.app.tr("ui.restore_defaults")).is_some()); + let footer = scenario::rect_of("dialog:pages_footer").expect("pinned profile footer"); + assert!(nav.contains_rect(footer)); + assert!(footer.contains_rect(scenario::rect_of("prefs:profile").expect("real switcher"))); + let tagged = [ + crate::prefs::PAGE_GENERAL, + crate::prefs::PAGE_APPEARANCE, + crate::prefs::PAGE_LAYOUT, + crate::prefs::PAGE_SKETCH, + crate::prefs::PAGE_NAVIGATION, + crate::prefs::PAGE_SHORTCUTS, + ] + .contains(&index); + assert_eq!(scenario::rect_of("prefs:in_profile").is_some(), tagged, "{page}"); } } crate::theme::set_dark(previous); @@ -1281,3 +1294,30 @@ fn a_left_panel_in_an_inside_out_view_keeps_an_anchor() { let anchor = panel.bounded_anchor(&ctx); assert!(anchor.x.is_finite() && anchor.y.is_finite(), "{anchor:?}"); } + +#[test] +fn page_sidebar_footer_stays_visible_when_the_page_list_scrolls() { + for theme in ["light", "dark"] { + let mut h = crate::scenario::Harness::new(); + h.app.home.open = false; + h.app.preferences.theme = theme.into(); + h.call("ui.resize", serde_json::json!({"width":1200,"height":620})); + crate::prefs::open_at(&mut h.app, crate::prefs::PAGE_GENERAL); + h.frames(6); + let footer = scenario::rect_of("dialog:pages_footer").unwrap(); + let nav = scenario::rect_of("dialog:pages").unwrap(); + h.frame_with(vec![ + egui::Event::PointerMoved(egui::pos2(nav.center().x, nav.top() + 30.0)), + egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(0.0, -1000.0), + modifiers: egui::Modifiers::NONE, + phase: egui::TouchPhase::Move, + }, + ]); + h.frames(60); + assert_eq!(scenario::rect_of("dialog:pages_footer"), Some(footer)); + assert!(footer.contains_rect(scenario::rect_of("prefs:profile").unwrap())); + assert!(nav.contains_rect(scenario::rect_of("prefs:page:Plugins").unwrap()), "last page is reachable in {theme}"); + } +} diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rs index 64c0ec6ec..0275e5ee7 100644 --- a/crates/ui-egui/src/ui_kit/preferences.rs +++ b/crates/ui-egui/src/ui_kit/preferences.rs @@ -355,6 +355,10 @@ pub(crate) fn settings_scroll(ui: &mut Ui, id: impl egui::AsIdSalt, add: impl } pub(crate) fn settings_heading(ui: &mut Ui, title: &str, description: &str) { + settings_heading_with_tag(ui, title, description, None); +} + +pub(crate) fn settings_heading_with_tag(ui: &mut Ui, title: &str, description: &str, tag: Option) { if crate::prefs_search::querying(ui) { return; } @@ -364,6 +368,12 @@ pub(crate) fn settings_heading(ui: &mut Ui, title: &str, description: &str) { let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_16 + t.space_3), Sense::hover()); response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title)); paint_text(ui, rect, title, crate::fonts::semibold(t.font_intro), t.form_ink, false); + if let Some(tag) = tag { + let width = ui.painter().layout_no_wrap(title.to_owned(), crate::fonts::semibold(t.font_intro), t.form_ink).size().x; + let start = (rect.left() + width + t.space_8).min(rect.right()); + let tag_rect = Rect::from_min_max(egui::pos2(start, rect.top()), rect.max); + ui.scope_builder(egui::UiBuilder::new().max_rect(tag_rect), tag); + } super::text(ui, description, super::Text::Hint("settings_heading")); }); } diff --git a/crates/ui-egui/src/workspace.rs b/crates/ui-egui/src/workspace.rs index 51663b773..2ed4a389d 100644 --- a/crates/ui-egui/src/workspace.rs +++ b/crates/ui-egui/src/workspace.rs @@ -1050,8 +1050,8 @@ mod tests { assert!(crate::scenario::handle_at("tab:MODEL").is_none()); assert_eq!(h.app.ui.tab, "SURFACE", "the first tab still shown is selected"); - // Settings › Interface lists the standard tabs too. - h.call("ui.prefs", json!({"open":"Interface"})); + // Settings › Layout lists the standard tabs too. + h.call("ui.prefs", json!({"open":"Layout"})); crate::prefs::reveal_preference(&mut h, "prefs:toolbar_tab:MODEL"); h.step(&json!({"click":{"handle":"prefs:toolbar_tab:MODEL"}})).unwrap(); assert!(h.app.preferences.hidden_toolbar_tabs.is_empty()); @@ -1177,7 +1177,7 @@ mod tests { assert_eq!(visible_tabs(&h.app), ["SKETCH"]); assert_eq!(h.app.ui.tab, "SKETCH"); - h.call("ui.prefs", json!({"open":"Interface"})); + h.call("ui.prefs", json!({"open":"Layout"})); h.call("ui.prefs", json!({"button":"defaults"})); h.call("ui.prefs", json!({"button":"ok"})); assert!(h.app.preferences.hidden_toolbar_tabs.is_empty()); diff --git a/crates/ui-egui/tests/scenarios/agent_chat_home_page.json b/crates/ui-egui/tests/scenarios/agent_chat_home_page.json index cf74cb229..19128c3fc 100644 --- a/crates/ui-egui/tests/scenarios/agent_chat_home_page.json +++ b/crates/ui-egui/tests/scenarios/agent_chat_home_page.json @@ -3,7 +3,7 @@ {"call": "ui.home", "params": {"open": true}}, {"expect": {"home": true}}, {"call": "ui.prefs", "params": {"open": "AI"}}, - {"expect": {"home": true, "prefs": {"dialog": "AI"}}}, + {"expect": {"home": true, "prefs": {"dialog": "Assistant"}}}, {"until": {"not_shown": "Looking for agents…"}}, {"expect": {"shown": "Add agent…"}}, {"click": {"handle": "prefs:ai_add"}}, diff --git a/crates/ui-egui/tests/scenarios/colour_vision_setting.json b/crates/ui-egui/tests/scenarios/colour_vision_setting.json index 5d3b47ca6..dab7d3ef5 100644 --- a/crates/ui-egui/tests/scenarios/colour_vision_setting.json +++ b/crates/ui-egui/tests/scenarios/colour_vision_setting.json @@ -2,23 +2,23 @@ {"note": "Colour vision lives on Interface: choices apply immediately; Cancel restores them, OK keeps them, and Interface defaults reset them. Page scrolling preserves the fixed window width."}, {"click": {"handle": "titlebar:preferences"}}, {"expect": {"prefs": {"dialog": "General", "color_vision": "off"}, "same_width": "prefs:window"}}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}}, {"call": "ui.inspect", "params": {}}, - {"expect": {"shown": "Color vision", "prefs": {"dialog": "Interface"}, "same_width": "prefs:window"}}, + {"expect": {"shown": "Color vision", "prefs": {"dialog": "Appearance"}, "same_width": "prefs:window"}}, {"widget": "Deutan"}, {"expect": {"prefs": {"color_vision": "deutan"}, "same_width": "prefs:window"}}, {"widget": "Cancel"}, {"expect": {"prefs": {"dialog": null, "color_vision": "off"}}}, {"key": "Comma", "cmd": true}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}}, {"call": "ui.inspect", "params": {}}, {"widget": "Tritan"}, {"widget": "OK"}, {"expect": {"prefs": {"dialog": null, "color_vision": "tritan"}}}, {"key": "Comma", "cmd": true}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}}, {"call": "ui.inspect", "params": {}}, {"expect": {"shown": "Tritan", "same_width": "prefs:window"}}, diff --git a/crates/ui-egui/tests/scenarios/dialog_buttons_top.json b/crates/ui-egui/tests/scenarios/dialog_buttons_top.json index 68a01d46f..23bf145a2 100644 --- a/crates/ui-egui/tests/scenarios/dialog_buttons_top.json +++ b/crates/ui-egui/tests/scenarios/dialog_buttons_top.json @@ -3,7 +3,7 @@ {"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch1"}}}, {"call": "engine.execute", "params": {"command": "sketch.rectangle.two_point", "params": {"p0": [0, 0], "p1": [40, 30]}}}, {"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}}, - {"call": "ui.prefs", "params": {"open": "Interface"}}, + {"call": "ui.prefs", "params": {"open": "Layout"}}, {"widget": "Top", "near": "Dialog buttons"}, {"widget": "OK"}, {"expect": {"prefs": {"dialog": null, "dialog_buttons": "top"}}}, diff --git a/crates/ui-egui/tests/scenarios/preferences_search.json b/crates/ui-egui/tests/scenarios/preferences_search.json index e635dfc32..5c653fd3f 100644 --- a/crates/ui-egui/tests/scenarios/preferences_search.json +++ b/crates/ui-egui/tests/scenarios/preferences_search.json @@ -2,12 +2,19 @@ {"note": "With Preferences open and nothing being edited, typing focuses Search preferences and the letters are the query. Enter opens that setting on its own page."}, {"click": {"handle": "titlebar:preferences"}}, {"expect": {"shown": "Restore Defaults", "prefs": {"dialog": "General"}}}, - {"text": "zo"}, + {"text": "Reverse zoom direction"}, {"frames": 3}, {"expect": {"shown": "Reverse zoom direction", "not_shown": "Units of new designs"}}, {"key": "Enter"}, {"frames": 2}, - {"expect": {"shown": "Reverse zoom direction", "prefs": {"dialog": "Navigation"}}}, + {"expect": {"shown": "Reverse zoom direction", "shown_handles": ["prefs:revealed"], "prefs": {"dialog": "Navigation"}}}, + {"call": "ui.prefs", "params": {"open": "General"}}, + {"text": "Direct interaction"}, + {"frames": 3}, + {"expect": {"shown": "Work > Tools"}}, + {"key": "Enter"}, + {"frames": 2}, + {"expect": {"shown": "Direct interaction", "prefs": {"dialog": "Tools"}}}, {"key": "Escape"}, {"expect": {"not_shown": "Restore Defaults", "prefs": {"dialog": null}}} ] diff --git a/crates/ui-egui/tests/scenarios/prefs_theme_files.json b/crates/ui-egui/tests/scenarios/prefs_theme_files.json index 0ee06eae9..f9e4d5a57 100644 --- a/crates/ui-egui/tests/scenarios/prefs_theme_files.json +++ b/crates/ui-egui/tests/scenarios/prefs_theme_files.json @@ -2,7 +2,7 @@ {"note": "#2255: theme tiles offer the built-in themes; choosing one applies it immediately, and Cancel restores the previous theme."}, {"click": {"handle": "titlebar:preferences"}}, {"expect": {"prefs": {"dialog": "General", "theme": "dark", "dark": true}}}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"click": {"handle": "prefs:theme:light"}}, {"expect": {"prefs": {"theme": "light", "dark": false}, "shown_handles": ["prefs:theme"]}}, {"click": {"handle": "prefs:theme:gruvbox-dark"}}, diff --git a/crates/ui-egui/tests/scenarios/prefs_viewport_theme.json b/crates/ui-egui/tests/scenarios/prefs_viewport_theme.json index 6d150bafc..ab63a0ab3 100644 --- a/crates/ui-egui/tests/scenarios/prefs_viewport_theme.json +++ b/crates/ui-egui/tests/scenarios/prefs_viewport_theme.json @@ -1,7 +1,7 @@ [ {"note": "#4146: under the theme tiles, Viewport draws the 3D view in the Light or Dark theme's colours whatever the window uses; it applies at once, and Cancel puts it back."}, {"click": {"handle": "titlebar:preferences"}}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"expect": {"prefs": {"theme": "dark", "dark": true, "viewport_theme": "theme", "viewport_dark": true}}}, {"widget": "Light", "near": "Viewport"}, {"expect": {"prefs": {"theme": "dark", "dark": true, "viewport_theme": "light", "viewport_dark": false}}}, diff --git a/crates/ui-egui/tests/scenarios/s45_preferences.json b/crates/ui-egui/tests/scenarios/s45_preferences.json index 7f11e0c56..9dc110b34 100644 --- a/crates/ui-egui/tests/scenarios/s45_preferences.json +++ b/crates/ui-egui/tests/scenarios/s45_preferences.json @@ -2,7 +2,7 @@ {"note": "#36: one Preferences dialog, from the gear at the top right (and Ctrl+,). Changes apply at once; Cancel puts them back, OK keeps them."}, {"click": {"handle": "titlebar:preferences"}}, {"expect": {"shown": "Restore Defaults", "prefs": {"dialog": "General", "theme": "dark", "dark": true}}}, - {"widget": "Interface"}, + {"widget": "Appearance"}, {"click": {"handle": "prefs:theme"}}, {"click": {"handle": "prefs:theme:light"}}, {"expect": {"prefs": {"theme": "light", "dark": false}}}, @@ -12,7 +12,7 @@ {"key": "Comma", "cmd": true}, {"expect": {"prefs": {"dialog": "General"}}}, {"widget": "Shortcuts"}, - {"expect": {"shown": "Reset All", "prefs": {"dialog": "Keyboard Shortcuts"}}}, + {"expect": {"shown": "Reset All", "prefs": {"dialog": "Shortcuts"}}}, {"widget": "Navigation"}, {"widget": "Fusion"}, {"widget": "Tinkercad"}, diff --git a/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json b/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json index 87a2316d1..a6ca40c8d 100644 --- a/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json +++ b/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json @@ -2,27 +2,62 @@ {"note": "#290: Preferences keeps one size on every page; descriptions wrap inside it, and the kit footer keeps Cancel / Apply / OK flush right inside its action inset."}, {"click": {"handle": "titlebar:preferences"}}, {"expect": {"prefs": {"dialog": "General"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}, "spans": {"inner": "prefs:footer", "outer": "prefs:window", "axis": "x", "tol": 12}}}, - {"widget": "Interface"}, - {"expect": {"prefs": {"dialog": "Interface"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, + {"widget": "Appearance"}, + {"expect": {"prefs": {"dialog": "Appearance"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, + {"widget": "Layout"}, + {"expect": {"prefs": {"dialog": "Layout"}, "same_width": "prefs:window"}}, + {"widget": "Tools"}, + {"expect": {"prefs": {"dialog": "Tools"}, "same_width": "prefs:window"}}, + {"widget": "3D mouse"}, + {"expect": {"prefs": {"dialog": "3D mouse"}, "same_width": "prefs:window"}}, {"widget": "Navigation"}, {"expect": {"prefs": {"dialog": "Navigation"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "Fusion"}, {"widget": "SolidWorks"}, {"expect": {"prefs": {"nav": "solidworks"}, "same_width": "prefs:window"}}, {"widget": "Shortcuts"}, - {"expect": {"prefs": {"dialog": "Keyboard Shortcuts"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, + {"expect": {"prefs": {"dialog": "Shortcuts"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "Design"}, {"expect": {"prefs": {"dialog": "Design"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "Graphics"}, {"expect": {"prefs": {"dialog": "Graphics"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, - {"widget": "Sketch & selection"}, + {"widget": "Sketch"}, {"expect": {"prefs": {"dialog": "Sketch"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "Assistant"}, - {"expect": {"prefs": {"dialog": "AI"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, + {"expect": {"prefs": {"dialog": "Assistant"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "Plugins"}, {"expect": {"prefs": {"dialog": "Plugins"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, {"widget": "General"}, {"expect": {"prefs": {"dialog": "General"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}}, + {"note": "Repeat the twelve-page structure in the light theme, retaining real legacy handles."}, + {"call": "ui.prefs", "params": {"theme": "light", "open": "General"}}, + {"call": "ui.prefs", "params": {"open": "Appearance"}}, + {"expect": {"prefs": {"dialog": "Appearance"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Layout"}}, + {"expect": {"prefs": {"dialog": "Layout"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Graphics"}}, + {"expect": {"prefs": {"dialog": "Graphics"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Design"}}, + {"expect": {"prefs": {"dialog": "Design"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Sketch"}}, + {"expect": {"prefs": {"dialog": "Sketch"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Tools"}}, + {"expect": {"prefs": {"dialog": "Tools"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Navigation"}}, + {"expect": {"prefs": {"dialog": "Navigation"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "3D mouse"}}, + {"expect": {"prefs": {"dialog": "3D mouse"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Shortcuts"}}, + {"expect": {"prefs": {"dialog": "Shortcuts"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Assistant"}}, + {"expect": {"prefs": {"dialog": "Assistant"}, "same_width": "prefs:window"}}, + {"call": "ui.prefs", "params": {"open": "Plugins"}}, + {"expect": {"prefs": {"dialog": "Plugins"}, "same_width": "prefs:window"}}, + {"click": {"handle": "prefs:page:Interface"}}, + {"expect": {"prefs": {"dialog": "Appearance"}}}, + {"call": "ui.prefs", "params": {"open": "Shortcuts"}}, + {"click": {"handle": "prefs:page:Keyboard Shortcuts"}}, + {"expect": {"prefs": {"dialog": "Shortcuts"}}}, {"widget": "Cancel"}, {"expect": {"prefs": {"dialog": null}}} ] diff --git a/docs/control-protocol.md b/docs/control-protocol.md index de08bdb6f..036a97a70 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -540,7 +540,7 @@ and output schema types live in `solidcraft_engine::schema::ui_prefs` (`PrefsPar Other `ui.prefs` parameters: -- `open` (a page: General, Interface, Design, Navigation, Keyboard Shortcuts, Sketch, Graphics, AI, Plugins; Shortcuts, Assistant and Sketch & selection are aliases, and the former Selection page opens Sketch) opens the Preferences dialog there +- `open` opens Preferences at General; Look: Appearance, Layout, Graphics; Work: Design, Sketch, Tools; Input: Navigation, 3D mouse, Shortcuts; or Extend: Assistant, Plugins. Names are case-insensitive. Legacy aliases remain accepted: Interface → Appearance, Interface/navigation bar → Layout, Keyboard Shortcuts → Shortcuts, AI → Assistant, and Selection, Sketch & selection or Sketch and selection → Sketch. Replies use the canonical page name. The corresponding legacy `prefs:page:` scenario handles also remain aliases of the canonical page rows. - `button`: `ok`, `cancel`, `apply`, `defaults` - `stand_up: true` stands up a just-opened Y-up file, `stand_up: false` leaves it as it is ("Leave it": the offer, dialog or note, closes and `offer_stand_up` stays on) - the dialog's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never`