SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
claim: preferences redesign (#4608)
Nathan Dane971b28c98200
diff --git a/ATTRIBUTION.md b/ATTRIBUTION.mdindex d13f541a09..9ce7a9d427 100644--- a/ATTRIBUTION.md+++ b/ATTRIBUTION.md@@ -196,6 +196,11 @@ Editable drawing code, native projects and shipped exports are collected under `| assets/icons/ui/design/svg/flat/redo.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 || assets/icons/ui/design/svg/flat/save.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 || assets/icons/ui/design/svg/flat/settings.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |+| assets/icons/ui/design/svg/flat/settings_keyboard.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |+| assets/icons/ui/design/svg/flat/settings_monitor.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |+| assets/icons/ui/design/svg/flat/settings_mouse.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |+| assets/icons/ui/design/svg/flat/settings_palette.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |+| assets/icons/ui/design/svg/flat/settings_plug.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 || assets/icons/ui/design/svg/flat/spin.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 || assets/icons/ui/design/svg/flat/style.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 || assets/icons/ui/design/svg/flat/undo.svg | SolidCraft contributors | single-colour application/navigation icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |diff --git a/assets/icons/ui/design/svg/flat/settings_keyboard.svg b/assets/icons/ui/design/svg/flat/settings_keyboard.svgnew file mode 100644index 0000000000..9a21a1ff8b--- /dev/null+++ b/assets/icons/ui/design/svg/flat/settings_keyboard.svg@@ -0,0 +1,8 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Keyboard shortcuts</title>+ <path d="M13 16L51 16A5 5 0 0 1 56 21L56 43A5 5 0 0 1 51 48L13 48A5 5 0 0 1 8 43L8 21A5 5 0 0 1 13 16Z" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+ <circle cx="20" cy="27" r="2.8" fill="currentColor"/>+ <circle cx="32" cy="27" r="2.8" fill="currentColor"/>+ <circle cx="44" cy="27" r="2.8" fill="currentColor"/>+ <path d="M20 39L44 39" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+</svg>diff --git a/assets/icons/ui/design/svg/flat/settings_monitor.svg b/assets/icons/ui/design/svg/flat/settings_monitor.svgnew file mode 100644index 0000000000..6dab2d49e2--- /dev/null+++ b/assets/icons/ui/design/svg/flat/settings_monitor.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Graphics display</title>+ <path d="M13 10L51 10A5 5 0 0 1 56 15L56 37A5 5 0 0 1 51 42L13 42A5 5 0 0 1 8 37L8 15A5 5 0 0 1 13 10ZM32 42L32 54M24 54L40 54" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+</svg>diff --git a/assets/icons/ui/design/svg/flat/settings_mouse.svg b/assets/icons/ui/design/svg/flat/settings_mouse.svgnew file mode 100644index 0000000000..8a2d20ed9e--- /dev/null+++ b/assets/icons/ui/design/svg/flat/settings_mouse.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Mouse navigation</title>+ <path d="M32 8A13 13 0 0 1 45 21L45 43A13 13 0 0 1 19 43L19 21A13 13 0 0 1 32 8ZM32 8L32 24" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+</svg>diff --git a/assets/icons/ui/design/svg/flat/settings_palette.svg b/assets/icons/ui/design/svg/flat/settings_palette.svgnew file mode 100644index 0000000000..3265a83675--- /dev/null+++ b/assets/icons/ui/design/svg/flat/settings_palette.svg@@ -0,0 +1,7 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Interface palette</title>+ <path d="M32 8C18.75 8 8 18.75 8 32C8 45.25 18.75 56 32 56C37 56 39 52.5 36.5 49C34 45.5 36 42 40 42L45 42C51.1 42 56 37.1 56 31C56 19 45 8 32 8Z" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+ <circle cx="21" cy="29" r="2.8" fill="currentColor"/>+ <circle cx="29" cy="20" r="2.8" fill="currentColor"/>+ <circle cx="41" cy="23" r="2.8" fill="currentColor"/>+</svg>diff --git a/assets/icons/ui/design/svg/flat/settings_plug.svg b/assets/icons/ui/design/svg/flat/settings_plug.svgnew file mode 100644index 0000000000..9b26c2d20c--- /dev/null+++ b/assets/icons/ui/design/svg/flat/settings_plug.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">+ <title>Plugins</title>+ <path d="M24 8L24 21M40 8L40 21M16 21L48 21L48 29A16 16 0 0 1 16 29L16 21ZM32 45L32 56" fill="none" stroke="currentColor" stroke-width="5.6" stroke-linejoin="round" stroke-linecap="round"/>+</svg>diff --git a/assets/icons/ui/source/glyphs.rs b/assets/icons/ui/source/glyphs.rsindex 241bd18cbb..fe232b2737 100644--- a/assets/icons/ui/source/glyphs.rs+++ b/assets/icons/ui/source/glyphs.rs@@ -99,14 +99,23 @@ pub(crate) fn breadcrumb(p: &egui::Painter, c: egui::Pos2, col: Color32) {}pub(crate) fn brand_mark(p: &egui::Painter, c: Pos2) {- let s = 20.0 / 412.217;+ brand_mark_styled(p, c, 20.0, crate::theme::Tokens::get().logo, true);+}++/// The same original mark as a single quiet silhouette, without face seams or outlines.+pub(crate) fn brand_mark_silhouette(p: &egui::Painter, c: Pos2, height: f32, ink: Color32) {+ brand_mark_styled(p, c, height, [ink; 4], false);+}++fn brand_mark_styled(p: &egui::Painter, c: Pos2, height: f32, colours: [Color32; 4], edges: bool) {+ let s = height / 412.217;let m = |pts: &[(f32, f32)]| -> Vec<egui::Pos2> { pts.iter().map(|&(x, y)| pos2(c.x + (x - 178.5) * s, c.y + (y - 206.1) * s)).collect() };// egui only fills convex shapes, so each face is a few overlapping convex pieces.let face = |col: Color32, pts: &[(f32, f32)]| {p.add(egui::Shape::convex_polygon(m(pts), col, Stroke::NONE));};// The faces are separated by gaps that show the application bar, not by white lines.- let [light, mid, dark, _] = crate::theme::Tokens::get().logo;+ let [light, mid, dark, _] = colours;let edge_col = crate::theme::Tokens::get().app_bar;face(light, &[(3.5, 105.9), (177.0, 5.8), (263.4, 55.6), (263.8, 156.0), (177.0, 406.4)]);face(light, &[(177.0, 206.1), (263.8, 156.0), (350.5, 206.2), (350.5, 306.3), (177.0, 406.4)]);@@ -117,6 +126,9 @@ pub(crate) fn brand_mark(p: &egui::Painter, c: Pos2) {face(dark, &[(263.8, 256.2), (350.5, 206.2), (350.5, 306.3), (177.0, 406.4)]);face(dark, &[(177.0, 206.1), (177.0, 406.4), (350.5, 306.3)]);face(dark, &[(263.8, 55.9), (263.8, 156.0), (177.1, 105.9)]);+ if !edges {+ return;+ }// White edge lines.let edge = Stroke::new(10.0 * s, edge_col);let line = |pts: &[(f32, f32)]| {diff --git a/assets/locales/en.json b/assets/locales/en.jsonindex 0d4b657b36..a2ae34bde1 100644--- a/assets/locales/en.json+++ b/assets/locales/en.json@@ -434,6 +434,29 @@"Z angle": "Z angle","Z distance": "Z distance","Zebra": "Zebra",+ "ai.prefs.availability": "Assistant controls",+ "ai.prefs.background_commands": "Run agent commands in the background",+ "ai.prefs.follow_camera": "Turn the camera to sketches",+ "ai.prefs.follow_camera_off": "Automatic camera following is off.",+ "ai.prefs.follow_camera_on": "The camera turns to face sketches the agent creates.",+ "ai.prefs.intro": "Agents, permissions and how their work appears.",+ "ai.prefs.make_default": "Use by default",+ "ai.prefs.no_agents": "No agents yet. Add an agent or refresh to find installed agents.",+ "ai.prefs.no_saved_approvals": "No saved approvals.",+ "ai.prefs.override_all_warning": "This agent may save, overwrite, export or replace the design without asking.",+ "ai.prefs.permission_all": "Allow everything",+ "ai.prefs.permission_all_summary": "Available SolidCraft tools run without asking.",+ "ai.prefs.permission_ask": "Ask before changes",+ "ai.prefs.permission_ask_summary": "Approve every design change and file action.",+ "ai.prefs.permission_edits": "Allow model edits",+ "ai.prefs.permission_edits_summary": "Model edits run; file and destructive actions still ask.",+ "ai.prefs.permission_scope": "For SolidCraft tools only. The agent’s shell and file edits use its own permissions.",+ "ai.prefs.pointer_preview_hidden": "Pointer hidden",+ "ai.prefs.pointer_preview_speed": "Agent pointer · {speed}",+ "ai.prefs.pointer_speed": "Motion speed",+ "ai.prefs.privacy_note": "Only your chosen agent or endpoint receives the conversation. Endpoint keys are stored in your system keychain.",+ "ai.prefs.show_pointer": "Show agent pointer",+ "ai.prefs.turn_limit_hint": "Maximum design-changing tool calls the Assistant may make for one message.","angle, height": "angle, height","appearance.dielectric_ior": "Dielectric IOR","appearance.metallic": "Metallic",@@ -1021,8 +1044,130 @@"pattern.flip_direction": "Flip direction","pick a hole to seat it, or OK places it at the origin": "pick a hole to seat it, or OK places it at the origin","pick one or two vertices, edges or faces": "pick one or two vertices, edges or faces",+ "prefs.add_item": "Add the item",+ "prefs.alt_frees_manipulators": "Alt / Option also frees manipulator arrows",+ "prefs.anti_aliasing_note": "Smooths jagged edges.",+ "prefs.applies_on_restart": "Applies on restart",+ "prefs.assistant": "Assistant",+ "prefs.axes": "Axes",+ "prefs.axis": "Axis",+ "prefs.bottom": "Bottom",+ "prefs.browser": "Browser",+ "prefs.built_in": "Built in",+ "prefs.button_left": "Left drag",+ "prefs.button_middle": "Middle drag",+ "prefs.button_right": "Right drag",+ "prefs.choose_font": "Choose font file…",+ "prefs.click": "Click",+ "prefs.contact_shading": "Soft contact shading",+ "prefs.contact_shading_note": "Soft shading where parts come close.",+ "prefs.context_menu": "Context menu",+ "prefs.context_menu_ring": "Context menu · hold for the radial menu","prefs.cpu": "CPU (software)",+ "prefs.crash_reports": "Open crash reports…",+ "prefs.crash_reports_note": "Reports are kept on this computer, with the design and commands that reproduce the problem.",+ "prefs.ctrl_cmd": "Ctrl / Cmd",+ "prefs.curved_surfaces": "Curved surfaces",+ "prefs.curves": "Curved surfaces",+ "prefs.dead_zone_note": "The hatched band is the dead zone: motion inside it is ignored.",+ "prefs.default": "default",+ "prefs.design": "Design defaults",+ "prefs.design_note": "What new designs start with. Open designs keep their own.",+ "prefs.devices": "3D mouse",+ "prefs.display": "Display",+ "prefs.edges": "Edges and shading",+ "prefs.extend": "Extend",+ "prefs.extra_navigation": "Ctrl+left drag on empty space orbits; hold Space to pan.",+ "prefs.follows_os": "Follows the OS",+ "prefs.font": "Font",+ "prefs.font_fallback": "Glyphs the chosen font lacks fall back to the built-in font, so no label shows an empty box.",+ "prefs.font_sample": "The quick brown fox · Ø12.50 mm · 45.0° · 0123456789",+ "prefs.font_unreadable": "The selected font could not be read.",+ "prefs.general": "General",+ "prefs.general_note": "Language, saving and updates.",+ "prefs.gesture_orbit": "Orbit",+ "prefs.gesture_pan": "Pan",+ "prefs.gesture_zoom": "Zoom",+ "prefs.graphics": "Graphics",+ "prefs.graphics_note": "Trade speed for smoothness. Each choice shows its effect on a sample.",+ "prefs.graphics_presets_note": "Presets set the choices below together.",+ "prefs.history": "History",+ "prefs.hold_stop_snapping": "Hold to stop snapping",+ "prefs.icons_only": "Icons only",+ "prefs.imported_file": "Imported file",+ "prefs.input": "Input",+ "prefs.interface": "Interface",+ "prefs.interface_language": "Interface language",+ "prefs.interface_note": "How SolidCraft looks and where its parts sit.",+ "prefs.interval_minutes": "{n} min",+ "prefs.labels": "Labels",+ "prefs.layout": "Layout",+ "prefs.layout_note": "Compact docks panels to the window edges. Browser translucency is available in Floating. Change the Assistant side on the Assistant page.",+ "prefs.left": "Left",+ "prefs.left_click": "Left click",+ "prefs.live_input": "Live input",+ "prefs.live_preview": "Live preview",+ "prefs.minutes": "minutes","prefs.minutes_suffix": " min",+ "prefs.mouse": "Mouse and trackpad",+ "prefs.mouse_heading": "Mouse",+ "prefs.mouse_mapping": "Mouse mapping",+ "prefs.navigation": "Navigation",+ "prefs.navigation_note": "How the mouse, trackpad and 3D mouse move the view.",+ "prefs.not_on_gpu": "not on this GPU",+ "prefs.on": "On",+ "prefs.opaque": "Opaque",+ "prefs.orbit_snap": "Hold Shift during orbit to snap to an axis.",+ "prefs.orientation": "Orientation",+ "prefs.overall_speed": "Overall speed",+ "prefs.preview_choices": "Preview of your choices",+ "prefs.quality_default": "default",+ "prefs.quality_fastest": "fastest",+ "prefs.quality_slowest": "slowest",+ "prefs.quality_smoother": "smoother",+ "prefs.reports_saved": "{n} saved",+ "prefs.right_click": "Right click",+ "prefs.saving": "Autosave and recovery",+ "prefs.scale_note": "Also Ctrl + / Ctrl − in the window. Buttons are 28 px at 100%.",+ "prefs.scale_text": "Scale and text",+ "prefs.select": "Select",+ "prefs.select_one_item": "Select one item",+ "prefs.selecting": "Selecting",+ "prefs.shift": "Shift",+ "prefs.shift_add_ctrl_toggle": "Shift adds only; Ctrl / Cmd toggles",+ "prefs.shift_add_note": "On: Shift adds, Ctrl / Cmd toggles. Off (default): both toggle.",+ "prefs.shortcuts": "Shortcuts",+ "prefs.sketch_selection": "Sketch & selection",+ "prefs.sketch_selection_heading": "Sketch and selection",+ "prefs.sketch_selection_note": "How sketches snap and how clicks select.",+ "prefs.sketching": "Sketching",+ "prefs.snap_drawing_note": "While drawing or dragging a sketch point.",+ "prefs.source": "Source",+ "prefs.speed": "Speed",+ "prefs.stand_up_note": "After a STEP or IGES file opens with Z up, offer a quarter turn about X.",+ "prefs.status_done": "Done",+ "prefs.status_error": "Error",+ "prefs.status_selected": "Selected",+ "prefs.status_warning": "Warning",+ "prefs.supersampling_brief": "Draws the view larger and filters it down: very crisp, and heavier.",+ "prefs.tab_accent_note": "The accent follows the active tab",+ "prefs.theme_file": "theme file",+ "prefs.timeline_half_hour": "−30 min",+ "prefs.timeline_now": "now",+ "prefs.timeline_quarter_hour": "−15",+ "prefs.toggle_item": "Add the item, or take it out again",+ "prefs.toolbar": "Toolbar",+ "prefs.translucent": "Translucent",+ "prefs.under_browser": "Under browser",+ "prefs.under_cursor": "Under cursor",+ "prefs.units_precision": "Units and precision",+ "prefs.updates": "Updates",+ "prefs.view": "View behavior",+ "prefs.viewport": "Viewport",+ "prefs.wheel": "Wheel",+ "prefs.wheel_trackpad": "Wheel and trackpad",+ "prefs.workspace": "Workspace",+ "prefs.zoom_toward_cursor": "Zoom, toward the cursor","properties.title": "Properties: {name}","recovery.days_ago": "{count} days ago","recovery.detail": "{file} · {features} features · autosaved {when}",@@ -1093,7 +1238,7 @@"search.suggest": "Did you mean {label}?","search.try": "Type a command name, a feature in this design, or a parameter. To run a command with values, type its id and a JSON object: {example}","search.valid": "Valid",- "settings.display_quality_note": "Finer levels draw curved faces and edges smoother and take longer to mesh. Only the viewport changes, never the design or exports.",+ "settings.display_quality_note": "Only the display. Designs and exports are not affected.","settings.frame_rate_note": "Shows frames per second in the view's bottom-right corner. While it is on, the view redraws continuously.","settings.measure_axis_distances": "Show X/Y/Z distances","settings.measure_axis_distances_help": "Show world-axis component dimensions alongside the total distance while Measure is open.",diff --git a/assets/locales/ja.json b/assets/locales/ja.jsonindex 402bde41f9..b7978f8597 100644--- a/assets/locales/ja.json+++ b/assets/locales/ja.json@@ -434,6 +434,29 @@"Z angle": "Z角度","Z distance": "Z距離","Zebra": "ゼブラ",+ "ai.prefs.availability": "アシスタントの操作",+ "ai.prefs.background_commands": "エージェントのコマンドをバックグラウンドで実行",+ "ai.prefs.follow_camera": "カメラをスケッチに向ける",+ "ai.prefs.follow_camera_off": "カメラの自動追従はオフです。",+ "ai.prefs.follow_camera_on": "エージェントが作成するスケッチにカメラを向けます。",+ "ai.prefs.intro": "エージェント、権限、作業の表示方法を設定します。",+ "ai.prefs.make_default": "既定にする",+ "ai.prefs.no_agents": "エージェントはまだありません。追加するか、更新してインストール済みのエージェントを検索してください。",+ "ai.prefs.no_saved_approvals": "保存された許可はありません。",+ "ai.prefs.override_all_warning": "このエージェントは確認せずに設計を保存、上書き、書き出し、置換できます。",+ "ai.prefs.permission_all": "すべて許可",+ "ai.prefs.permission_all_summary": "利用可能なSolidCraftツールを確認せず実行します。",+ "ai.prefs.permission_ask": "変更前に確認",+ "ai.prefs.permission_ask_summary": "設計の変更とファイル操作を毎回確認します。",+ "ai.prefs.permission_edits": "モデル編集を許可",+ "ai.prefs.permission_edits_summary": "モデル編集は自動実行。ファイル操作や破壊的な操作は確認します。",+ "ai.prefs.permission_scope": "SolidCraftツールのみに適用されます。エージェントのシェルやファイル編集には、そのエージェント自身の権限設定が適用されます。",+ "ai.prefs.pointer_preview_hidden": "ポインターは非表示",+ "ai.prefs.pointer_preview_speed": "エージェントのポインター · {speed}",+ "ai.prefs.pointer_speed": "移動速度",+ "ai.prefs.privacy_note": "会話は選択したエージェントまたはエンドポイントにのみ送信されます。エンドポイントのキーはシステムのキーチェーンに保存されます。",+ "ai.prefs.show_pointer": "エージェントのポインターを表示",+ "ai.prefs.turn_limit_hint": "アシスタントが1件のメッセージで行える、設計を変更するツール呼び出しの上限です。","angle, height": "角度, 高さ","appearance.dielectric_ior": "誘電体の屈折率","appearance.metallic": "金属度",@@ -1021,8 +1044,130 @@"pattern.flip_direction": "方向を反転","pick a hole to seat it, or OK places it at the origin": "配置先の穴を選択するか、[OK]を押すと原点に配置します。","pick one or two vertices, edges or faces": "1つまたは2つの頂点、エッジ、面を選択",+ "prefs.add_item": "項目を追加",+ "prefs.alt_frees_manipulators": "Alt / Option でマニピュレーターの矢印も自由に動かす",+ "prefs.anti_aliasing_note": "輪郭のぎざぎざを滑らかにします。",+ "prefs.applies_on_restart": "再起動後に適用",+ "prefs.assistant": "アシスタント",+ "prefs.axes": "軸",+ "prefs.axis": "軸",+ "prefs.bottom": "下",+ "prefs.browser": "ブラウザー",+ "prefs.built_in": "組み込み",+ "prefs.button_left": "左ドラッグ",+ "prefs.button_middle": "中央ドラッグ",+ "prefs.button_right": "右ドラッグ",+ "prefs.choose_font": "フォントファイルを選択…",+ "prefs.click": "クリック",+ "prefs.contact_shading": "柔らかな接触陰影",+ "prefs.contact_shading_note": "部品が近接する部分に柔らかな陰影を付けます。",+ "prefs.context_menu": "コンテキストメニュー",+ "prefs.context_menu_ring": "コンテキストメニュー · 長押しで放射状メニュー","prefs.cpu": "CPU(ソフトウェア)",+ "prefs.crash_reports": "クラッシュレポートを開く…",+ "prefs.crash_reports_note": "問題を再現する設計とコマンドを含むレポートをこのコンピューターに保存します。",+ "prefs.ctrl_cmd": "Ctrl / Cmd",+ "prefs.curved_surfaces": "曲面",+ "prefs.curves": "曲面",+ "prefs.dead_zone_note": "斜線の帯はデッドゾーンです。この範囲内の動きは無視されます。",+ "prefs.default": "既定",+ "prefs.design": "設計の既定値",+ "prefs.design_note": "新しいデザインの初期設定です。開いているデザインはそれぞれの設定を保持します。",+ "prefs.devices": "3D マウス",+ "prefs.display": "表示",+ "prefs.edges": "エッジと陰影",+ "prefs.extend": "拡張",+ "prefs.extra_navigation": "何もない場所でCtrl+左ドラッグすると回転し、Spaceを押しながらドラッグすると移動します。",+ "prefs.follows_os": "OS の設定に従う",+ "prefs.font": "フォント",+ "prefs.font_fallback": "選択したフォントにない文字は組み込みフォントで表示し、ラベルが空の四角になるのを防ぎます。",+ "prefs.font_sample": "いろはにほへと · Ø12.50 mm · 45.0° · 0123456789",+ "prefs.font_unreadable": "選択したフォントを読み込めませんでした。",+ "prefs.general": "一般",+ "prefs.general_note": "言語、保存、更新。",+ "prefs.gesture_orbit": "回転",+ "prefs.gesture_pan": "移動",+ "prefs.gesture_zoom": "ズーム",+ "prefs.graphics": "グラフィックス",+ "prefs.graphics_note": "速度と滑らかさのバランスを調整します。各選択肢の効果をサンプルで確認できます。",+ "prefs.graphics_presets_note": "プリセットは以下の設定をまとめて変更します。",+ "prefs.history": "履歴",+ "prefs.hold_stop_snapping": "押している間スナップを解除",+ "prefs.icons_only": "アイコンのみ",+ "prefs.imported_file": "読み込んだファイル",+ "prefs.input": "入力",+ "prefs.interface": "インターフェース",+ "prefs.interface_language": "表示言語",+ "prefs.interface_note": "SolidCraft の外観と各パネルの配置。",+ "prefs.interval_minutes": "{n} 分",+ "prefs.labels": "ラベル",+ "prefs.layout": "レイアウト",+ "prefs.layout_note": "コンパクトではパネルをウィンドウの端に固定します。ブラウザーの半透明表示はフローティングで使用できます。アシスタントの配置はアシスタントページで変更します。",+ "prefs.left": "左",+ "prefs.left_click": "左クリック",+ "prefs.live_input": "現在の入力",+ "prefs.live_preview": "ライブプレビュー",+ "prefs.minutes": "分","prefs.minutes_suffix": " min",+ "prefs.mouse": "マウスとトラックパッド",+ "prefs.mouse_heading": "マウス",+ "prefs.mouse_mapping": "マウスの割り当て",+ "prefs.navigation": "ナビゲーション",+ "prefs.navigation_note": "マウス、トラックパッド、3Dマウスによるビューの操作。",+ "prefs.not_on_gpu": "この GPU は非対応",+ "prefs.on": "オン",+ "prefs.opaque": "不透明",+ "prefs.orbit_snap": "回転中にShiftを押すと軸にスナップします。",+ "prefs.orientation": "方向",+ "prefs.overall_speed": "全体の速度",+ "prefs.preview_choices": "選択した設定のプレビュー",+ "prefs.quality_default": "既定",+ "prefs.quality_fastest": "最速",+ "prefs.quality_slowest": "最も低速",+ "prefs.quality_smoother": "より滑らか",+ "prefs.reports_saved": "{n} 件保存済み",+ "prefs.right_click": "右クリック",+ "prefs.saving": "自動保存と復元",+ "prefs.scale_note": "ウィンドウ内では Ctrl + / Ctrl − でも変更できます。100% のボタンは 28 px です。",+ "prefs.scale_text": "拡大率と文字",+ "prefs.select": "選択",+ "prefs.select_one_item": "項目を 1 つ選択",+ "prefs.selecting": "選択",+ "prefs.shift": "Shift",+ "prefs.shift_add_ctrl_toggle": "Shift は追加のみ、Ctrl / Cmd は選択を切り替え",+ "prefs.shift_add_note": "オン:Shift は追加、Ctrl / Cmd は選択を切り替えます。オフ(既定):どちらも選択を切り替えます。",+ "prefs.shortcuts": "ショートカット",+ "prefs.sketch_selection": "スケッチと選択",+ "prefs.sketch_selection_heading": "スケッチと選択",+ "prefs.sketch_selection_note": "スケッチのスナップとクリックによる選択。",+ "prefs.sketching": "スケッチ",+ "prefs.snap_drawing_note": "スケッチの描画中または点のドラッグ中に使用します。",+ "prefs.source": "入力元",+ "prefs.speed": "速度",+ "prefs.stand_up_note": "STEP または IGES ファイルを Z 上向きで開いた後、X 軸周りに 90° 回転するか確認します。",+ "prefs.status_done": "完了",+ "prefs.status_error": "エラー",+ "prefs.status_selected": "選択中",+ "prefs.status_warning": "警告",+ "prefs.supersampling_brief": "大きく描画して縮小するため、非常に鮮明になりますが負荷も増えます。",+ "prefs.tab_accent_note": "アクセント色はアクティブなタブに従います",+ "prefs.theme_file": "テーマファイル",+ "prefs.timeline_half_hour": "−30 分",+ "prefs.timeline_now": "現在",+ "prefs.timeline_quarter_hour": "−15",+ "prefs.toggle_item": "項目を追加、または選択から外す",+ "prefs.toolbar": "ツールバー",+ "prefs.translucent": "半透明",+ "prefs.under_browser": "ブラウザー下",+ "prefs.under_cursor": "カーソル下",+ "prefs.units_precision": "単位と精度",+ "prefs.updates": "更新",+ "prefs.view": "ビューの動作",+ "prefs.viewport": "ビューポート",+ "prefs.wheel": "ホイール",+ "prefs.wheel_trackpad": "ホイールとトラックパッド",+ "prefs.workspace": "ワークスペース",+ "prefs.zoom_toward_cursor": "カーソルに向かってズーム","properties.title": "プロパティ: {name}","recovery.days_ago": "{count}日前","recovery.detail": "{file} · {features}フィーチャー · 自動保存: {when}",@@ -1093,7 +1238,7 @@"search.suggest": "{label} ですか?","search.try": "コマンド名、このデザインのフィーチャー、またはパラメーターを入力します。値を指定して実行するには、IDとJSONオブジェクトを入力します:{example}","search.valid": "有効",- "settings.display_quality_note": "細かいほど曲面とエッジが滑らかに表示されますが、メッシュの生成に時間がかかります。変わるのはビューポートだけで、設計やエクスポートは変わりません。",+ "settings.display_quality_note": "表示だけに影響します。設計や書き出しは変わりません。","settings.frame_rate_note": "ビューの右下に 1 秒あたりのフレーム数を表示します。オンの間、ビューは常に再描画されます。","settings.measure_axis_distances": "計測のX・Y・Z距離を表示","settings.measure_axis_distances_help": "計測ダイアログを開いている間、2点間距離に加えてワールドX・Y・Z軸方向の寸法線と距離を表示します。",diff --git a/assets/locales/zh.json b/assets/locales/zh.jsonindex d93043135f..993a86cc6e 100644--- a/assets/locales/zh.json+++ b/assets/locales/zh.json@@ -434,6 +434,29 @@"Z angle": "Z 角度","Z distance": "Z 距离","Zebra": "斑马纹",+ "ai.prefs.availability": "助手控制",+ "ai.prefs.background_commands": "在后台执行代理命令",+ "ai.prefs.follow_camera": "将相机转向草图",+ "ai.prefs.follow_camera_off": "相机自动跟随已关闭。",+ "ai.prefs.follow_camera_on": "相机将转向代理创建的草图。",+ "ai.prefs.intro": "设置代理、权限及其工作方式。",+ "ai.prefs.make_default": "设为默认",+ "ai.prefs.no_agents": "尚无代理。添加代理或刷新以查找已安装的代理。",+ "ai.prefs.no_saved_approvals": "没有已保存的批准。",+ "ai.prefs.override_all_warning": "此代理可在不询问的情况下保存、覆盖、导出或替换设计。",+ "ai.prefs.permission_all": "全部允许",+ "ai.prefs.permission_all_summary": "可用的 SolidCraft 工具无需询问即可运行。",+ "ai.prefs.permission_ask": "更改前询问",+ "ai.prefs.permission_ask_summary": "每次设计更改和文件操作均需批准。",+ "ai.prefs.permission_edits": "允许模型编辑",+ "ai.prefs.permission_edits_summary": "模型编辑自动执行;文件及破坏性操作仍需询问。",+ "ai.prefs.permission_scope": "仅适用于 SolidCraft 工具。代理的终端和文件编辑使用其自身权限。",+ "ai.prefs.pointer_preview_hidden": "指针已隐藏",+ "ai.prefs.pointer_preview_speed": "代理指针 · {speed}",+ "ai.prefs.pointer_speed": "移动速度",+ "ai.prefs.privacy_note": "对话仅发送给所选代理或端点。端点密钥保存在系统钥匙串中。",+ "ai.prefs.show_pointer": "显示代理指针",+ "ai.prefs.turn_limit_hint": "助手针对一条消息可调用的设计更改工具次数上限。","angle, height": "角度、高度","appearance.dielectric_ior": "电介质折射率","appearance.metallic": "金属度",@@ -1021,8 +1044,130 @@"pattern.flip_direction": "反转方向","pick a hole to seat it, or OK places it at the origin": "选择一个孔放置,或单击确定放置在原点","pick one or two vertices, edges or faces": "选择一个或两个顶点、边或面",+ "prefs.add_item": "添加项目",+ "prefs.alt_frees_manipulators": "Alt / Option 也可自由拖动操纵器箭头",+ "prefs.anti_aliasing_note": "平滑锯齿边缘。",+ "prefs.applies_on_restart": "重启后生效",+ "prefs.assistant": "助手",+ "prefs.axes": "坐标轴",+ "prefs.axis": "轴",+ "prefs.bottom": "底部",+ "prefs.browser": "浏览器",+ "prefs.built_in": "内置",+ "prefs.button_left": "左键拖动",+ "prefs.button_middle": "中键拖动",+ "prefs.button_right": "右键拖动",+ "prefs.choose_font": "选择字体文件…",+ "prefs.click": "单击",+ "prefs.contact_shading": "柔和接触阴影",+ "prefs.contact_shading_note": "在零件相近处添加柔和阴影。",+ "prefs.context_menu": "上下文菜单",+ "prefs.context_menu_ring": "上下文菜单 · 按住显示环形菜单","prefs.cpu": "CPU(软件)",+ "prefs.crash_reports": "打开崩溃报告…",+ "prefs.crash_reports_note": "报告与重现问题的设计和命令一起保存在此计算机上。",+ "prefs.ctrl_cmd": "Ctrl / Cmd",+ "prefs.curved_surfaces": "曲面",+ "prefs.curves": "曲面",+ "prefs.dead_zone_note": "斜线区域为死区:此范围内的移动将被忽略。",+ "prefs.default": "默认",+ "prefs.design": "设计默认值",+ "prefs.design_note": "新建设计的初始设置。已打开的设计保留各自的设置。",+ "prefs.devices": "3D 鼠标",+ "prefs.display": "显示",+ "prefs.edges": "边缘与着色",+ "prefs.extend": "扩展",+ "prefs.extra_navigation": "在空白处按住Ctrl并用鼠标左键拖动可旋转;按住空格键可平移。",+ "prefs.follows_os": "跟随操作系统",+ "prefs.font": "字体",+ "prefs.font_fallback": "所选字体缺少的字符会使用内置字体,避免标签显示为空方框。",+ "prefs.font_sample": "字体示例 · Ø12.50 mm · 45.0° · 0123456789",+ "prefs.font_unreadable": "无法读取所选字体。",+ "prefs.general": "常规",+ "prefs.general_note": "语言、保存和更新。",+ "prefs.gesture_orbit": "环绕",+ "prefs.gesture_pan": "平移",+ "prefs.gesture_zoom": "缩放",+ "prefs.graphics": "图形",+ "prefs.graphics_note": "在速度与平滑度之间取舍。每个选项均以示例展示效果。",+ "prefs.graphics_presets_note": "预设会同时设置以下选项。",+ "prefs.history": "历史",+ "prefs.hold_stop_snapping": "按住以停用吸附",+ "prefs.icons_only": "仅图标",+ "prefs.imported_file": "已导入文件",+ "prefs.input": "输入",+ "prefs.interface": "界面",+ "prefs.interface_language": "界面语言",+ "prefs.interface_note": "SolidCraft 的外观和面板布局。",+ "prefs.interval_minutes": "{n} 分钟",+ "prefs.labels": "标签",+ "prefs.layout": "布局",+ "prefs.layout_note": "紧凑模式将面板停靠在窗口边缘。浏览器半透明仅适用于浮动模式。助手面板的位置在助手页面中设置。",+ "prefs.left": "左侧",+ "prefs.left_click": "左键单击",+ "prefs.live_input": "实时输入",+ "prefs.live_preview": "实时预览",+ "prefs.minutes": "分钟","prefs.minutes_suffix": " min",+ "prefs.mouse": "鼠标与触控板",+ "prefs.mouse_heading": "鼠标",+ "prefs.mouse_mapping": "鼠标映射",+ "prefs.navigation": "导航",+ "prefs.navigation_note": "鼠标、触控板和3D鼠标如何移动视图。",+ "prefs.not_on_gpu": "此 GPU 不支持",+ "prefs.on": "开启",+ "prefs.opaque": "不透明",+ "prefs.orbit_snap": "旋转时按住Shift可捕捉到坐标轴。",+ "prefs.orientation": "方向",+ "prefs.overall_speed": "整体速度",+ "prefs.preview_choices": "所选设置预览",+ "prefs.quality_default": "默认",+ "prefs.quality_fastest": "最快",+ "prefs.quality_slowest": "最慢",+ "prefs.quality_smoother": "更平滑",+ "prefs.reports_saved": "已保存 {n} 份",+ "prefs.right_click": "右键单击",+ "prefs.saving": "自动保存和恢复",+ "prefs.scale_note": "也可在窗口中使用 Ctrl + / Ctrl −。100% 时按钮高度为 28 像素。",+ "prefs.scale_text": "缩放与文字",+ "prefs.select": "选择",+ "prefs.select_one_item": "选择一个项目",+ "prefs.selecting": "选择",+ "prefs.shift": "Shift",+ "prefs.shift_add_ctrl_toggle": "Shift 仅添加;Ctrl / Cmd 切换选择",+ "prefs.shift_add_note": "开启:Shift 添加,Ctrl / Cmd 切换选择。关闭(默认):两者均切换选择。",+ "prefs.shortcuts": "快捷键",+ "prefs.sketch_selection": "草图与选择",+ "prefs.sketch_selection_heading": "草图和选择",+ "prefs.sketch_selection_note": "草图如何捕捉,以及单击如何选择。",+ "prefs.sketching": "草图",+ "prefs.snap_drawing_note": "在绘制或拖动草图点时使用。",+ "prefs.source": "来源",+ "prefs.speed": "速度",+ "prefs.stand_up_note": "以 Z 轴向上打开 STEP 或 IGES 文件后,询问是否绕 X 轴旋转 90°。",+ "prefs.status_done": "完成",+ "prefs.status_error": "错误",+ "prefs.status_selected": "已选择",+ "prefs.status_warning": "警告",+ "prefs.supersampling_brief": "以更高分辨率绘制后滤波缩小:更清晰,但负载更高。",+ "prefs.tab_accent_note": "强调色跟随当前选项卡",+ "prefs.theme_file": "主题文件",+ "prefs.timeline_half_hour": "−30 分钟",+ "prefs.timeline_now": "现在",+ "prefs.timeline_quarter_hour": "−15",+ "prefs.toggle_item": "添加项目,或取消选择",+ "prefs.toolbar": "工具栏",+ "prefs.translucent": "半透明",+ "prefs.under_browser": "浏览器下方",+ "prefs.under_cursor": "光标下方",+ "prefs.units_precision": "单位与精度",+ "prefs.updates": "更新",+ "prefs.view": "视图行为",+ "prefs.viewport": "视口",+ "prefs.wheel": "滚轮",+ "prefs.wheel_trackpad": "滚轮与触控板",+ "prefs.workspace": "工作区",+ "prefs.zoom_toward_cursor": "朝光标缩放","properties.title": "属性:{name}","recovery.days_ago": "{count} 天前","recovery.detail": "{file} · {features} 个特征 · 自动保存于 {when}",@@ -1093,7 +1238,7 @@"search.suggest": "您是否想找 {label}?","search.try": "输入命令名称、此设计中的特征或参数。要带值运行命令,请输入其ID和JSON对象:{example}","search.valid": "有效",- "settings.display_quality_note": "级别越精细,曲面和边显示越平滑,但网格生成耗时更长。只影响视口,不影响设计或导出。",+ "settings.display_quality_note": "仅影响显示,不影响设计和导出。","settings.frame_rate_note": "在视图右下角显示每秒帧数。开启时视图会持续重绘。","settings.measure_axis_distances": "显示 X/Y/Z 距离","settings.measure_axis_distances_help": "测量对话框打开时,在总距离之外显示沿世界坐标轴方向的尺寸线和距离。",diff --git a/assets/styles/ui/palettes.rs b/assets/styles/ui/palettes.rsindex 33f4e3d80d..e0404a74a8 100644--- a/assets/styles/ui/palettes.rs+++ b/assets/styles/ui/palettes.rs@@ -310,12 +310,12 @@ impl Tokens {t.render_ink = Color32::from_rgb(224, 116, 174);t.render_soft = Color32::from_rgb(64, 35, 54);t.tab_on_fill_dark = Color32::BLACK;- t.dialog_body = Color32::from_rgb(59, 68, 83);+ t.dialog_body = Color32::from_rgb(39, 43, 52);t.dialog_footer = Color32::from_rgb(47, 52, 62);t.dialog_rule = Color32::from_rgb(53, 59, 71);- t.control_fill = Color32::from_rgb(39, 43, 52);+ t.control_fill = Color32::from_rgb(28, 31, 38);t.control_border = Color32::from_rgb(74, 82, 98);- t.dialog_label = Color32::from_rgb(180, 187, 200);+ t.dialog_label = t.text;t.selected_ink = Color32::from_rgb(156, 199, 245);t.selected_bg = Color32::from_rgb(42, 70, 110);t.construction_geom = icon_primary(crate::icon_svg::CONSTRUCTION_PRIMARY[1]);@@ -340,8 +340,8 @@ impl Tokens {t.dimension_driven = Color32::from_rgb(142, 150, 164);t.sketch_point_free = Color32::from_rgb(92, 150, 255);t.profile_fill = Color32::from_rgba_unmultiplied_const(120, 150, 200, 40);- t.dialog_bg = Color32::from_rgb(59, 68, 83);- t.dialog_border = Color32::from_rgb(72, 83, 99);+ t.dialog_bg = Color32::from_rgb(39, 43, 52);+ t.dialog_border = Color32::from_rgb(63, 69, 82);t.chip = Color32::from_rgb(59, 101, 168);t.glyph_bg = Color32::from_rgb(44, 50, 60);t.glyph_edge = Color32::from_rgb(200, 130, 120);@@ -357,7 +357,7 @@ impl Tokens {t.bend_up = Color32::from_rgb(110, 200, 120);t.bend_down = Color32::from_rgb(240, 150, 80);t.form_ink = t.text;- t.form_dim = t.text_dim;+ t.form_dim = Color32::from_rgb(180, 187, 200);t.form_primary = t.accent;t.form_error = t.error;t.form_error_fill = t.timeline_item_error;diff --git a/crates/ui-egui/src/agent_chat/panel.rs b/crates/ui-egui/src/agent_chat/panel.rsindex b225fbe49f..5c38eac453 100644--- a/crates/ui-egui/src/agent_chat/panel.rs+++ b/crates/ui-egui/src/agent_chat/panel.rs@@ -883,20 +883,6 @@ fn desktop_body(app: &mut SolveApp, ui: &mut egui::Ui) {}}-#[cfg(not(target_arch = "wasm32"))]-pub(super) fn login_chip(ui: &mut egui::Ui, login: &str) {- let t = Tokens::get();- let (text, color) = match login {- "signed_in" => (tr("ui.agent_chat_signed_in"), t.accent),- "key" => (tr("ui.agent_chat_key_in_env"), t.accent),- "signed_out" => (tr("ui.agent_chat_not_signed_in"), t.warning),- _ => return,- };- egui::Frame::NONE.stroke(Stroke::new(1.0, color)).corner_radius(8.0).inner_margin(egui::Margin::symmetric(6, 1)).show(ui, |ui| {- ui.label(RichText::new(text).color(color).size(crate::theme::Tokens::get().font_small));- });-}-/// The header's second row: the agent this conversation uses (a compact switcher), the agent's/// own mode when it has modes, and the state of its login.#[cfg(not(target_arch = "wasm32"))]diff --git a/crates/ui-egui/src/agent_chat/settings.rs b/crates/ui-egui/src/agent_chat/settings.rsindex 7d035be7c8..224634eef5 100644--- a/crates/ui-egui/src/agent_chat/settings.rs+++ b/crates/ui-egui/src/agent_chat/settings.rs@@ -101,86 +101,143 @@ fn test_line(ui: &mut egui::Ui, test: &Option<&Test>) {}}-/// The AI page of Settings.+/// The Assistant page of Settings. Copy stays close to its control; full security details+/// remain accessible on hover, and high-risk permissions always retain a visible warning.pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {- let r = ui_kit::checkbox(ui, tr("ui.ai_show_features"), &mut app.preferences.ai_features);- crate::scenario::publish_handle("prefs:ai_features", r.rect.center());- ui_kit::text(ui, tr("ui.ai_show_features_note"), ui_kit::Text::Note("features"));- if cfg!(target_arch = "wasm32") {- ui_kit::text(ui, tr("ui.agent_chat_desktop_only"), ui_kit::Text::Note("desktop"));- return;- }- // Any agent's control requests, the chat's or an outside MCP client's (#1989).- let r = ui_kit::checkbox(ui, tr("ui.agent_off_thread"), &mut app.preferences.agent_off_thread);- crate::scenario::publish_handle("prefs:agent_off_thread", r.rect.center());- ui_kit::text(ui, tr("ui.agent_off_thread_note"), ui_kit::Text::Note("off_thread"));- if !app.preferences.ai_features {- return;- }- let r = ui_kit::checkbox(ui, tr("ui.ai_toolbar_button"), &mut app.preferences.ai_toolbar_button);- crate::scenario::publish_handle("prefs:ai_toolbar_button", r.rect.center());- ui_kit::text(ui, tr("ui.ai_toolbar_button_note"), ui_kit::Text::Note("toolbar"));- #[cfg(not(target_arch = "wasm32"))]- {- if app.agent_chat.detection.is_none() && app.agent_chat.detecting.is_none() {- refresh(app, &ui.ctx().clone());+ ui_kit::settings_heading(ui, tr("prefs.assistant"), tr("ai.prefs.intro"));+ ui_kit::settings_section(ui, "assistant_availability", tr("ai.prefs.availability"), |ui| {+ let response =+ ui_kit::checkbox(ui, tr("ui.ai_show_features"), &mut app.preferences.ai_features).on_hover_text(tr("ui.ai_show_features_note"));+ crate::scenario::publish_handle("prefs:ai_features", response.rect.center());+ if !cfg!(target_arch = "wasm32") {+ if app.preferences.ai_features {+ let response = ui_kit::checkbox(ui, tr("ui.ai_toolbar_button"), &mut app.preferences.ai_toolbar_button)+ .on_hover_text(tr("ui.ai_toolbar_button_note"));+ crate::scenario::publish_handle("prefs:ai_toolbar_button", response.rect.center());+ }+ let response = ui_kit::checkbox(ui, tr("ai.prefs.background_commands"), &mut app.preferences.agent_off_thread)+ .on_hover_text(tr("ui.agent_off_thread_note"));+ crate::scenario::publish_handle("prefs:agent_off_thread", response.rect.center());}- agents_section(app, ui);- }- ui_kit::section(ui, "permissions", tr("ui.ai_permissions"), true, |ui| {- for mode in Mode::ALL {- let r = ui_kit::list_picker(ui, mode.id(), mode.label(), app.preferences.ai_permissions == mode);- crate::scenario::publish_handle(&format!("prefs:ai_mode:{}", mode.id()), r.rect.center());- if r.clicked() {- app.preferences.ai_permissions = mode;+ if cfg!(target_arch = "wasm32") {+ ui_kit::text(ui, tr("ui.agent_chat_desktop_only"), ui_kit::Text::Hint("desktop"));+ }+ });+ if !cfg!(target_arch = "wasm32") && app.preferences.ai_features {+ #[cfg(not(target_arch = "wasm32"))]+ {+ if app.agent_chat.detection.is_none() && app.agent_chat.detecting.is_none() {+ refresh(app, &ui.ctx().clone());}- ui_kit::text(- ui,- tr(match mode {- Mode::Ask => "ui.ai_mode_ask_note",- Mode::Edits => "ui.ai_mode_edits_note",- Mode::All => "ui.ai_mode_all_note",- }),- ui_kit::Text::Note(mode.id()),- );+ agents_section(app, ui);+ }+ permissions_section(app, ui);+ panel_section(app, ui);+ }+ pointer_section(app, ui);+}++fn permissions_section(app: &mut SolveApp, ui: &mut egui::Ui) {+ ui_kit::settings_section(ui, "permissions", tr("ui.ai_permissions"), |ui| {+ let mut selected = Mode::ALL.iter().position(|mode| *mode == app.preferences.ai_permissions).unwrap_or(0);+ let choices = [+ ui_kit::SettingsChoice {+ key: "prefs:ai_mode:ask",+ title: tr("ai.prefs.permission_ask"),+ summary: tr("ai.prefs.permission_ask_summary"),+ detail: tr("ui.ai_mode_ask_note"),+ },+ ui_kit::SettingsChoice {+ key: "prefs:ai_mode:edits",+ title: tr("ai.prefs.permission_edits"),+ summary: tr("ai.prefs.permission_edits_summary"),+ detail: tr("ui.ai_mode_edits_note"),+ },+ ui_kit::SettingsChoice {+ key: "prefs:ai_mode:all",+ title: tr("ai.prefs.permission_all"),+ summary: tr("ai.prefs.permission_all_summary"),+ detail: tr("ui.ai_mode_all_note"),+ },+ ];+ if ui_kit::settings_choices(ui, &choices, &mut selected)+ && let Some(mode) = Mode::ALL.get(selected)+ {+ app.preferences.ai_permissions = *mode;}if app.preferences.ai_permissions == Mode::All {ui_kit::text(ui, tr("ui.ai_mode_all_warning"), ui_kit::Text::Report("permissions_warning", true));}- ui_kit::text(ui, tr("ui.ai_modes_scope"), ui_kit::Text::Note("scope"));- ui_kit::section(ui, "always_allowed", tr("ui.ai_always_allowed"), true, |ui| {- let remembered: Vec<_> =- app.preferences.agent_always_allow.iter().filter(|(_, v)| !v.is_empty()).map(|(k, v)| (k.clone(), v.clone())).collect();+ ui_kit::text(ui, tr("ai.prefs.permission_scope"), ui_kit::Text::Hint("scope")).on_hover_text(tr("ui.ai_modes_scope"));+ let remembered: Vec<_> = app+ .preferences+ .agent_always_allow+ .iter()+ .filter(|(_, tools)| !tools.is_empty())+ .map(|(agent, tools)| (agent.clone(), tools.clone()))+ .collect();+ ui_kit::section_count(ui, "always_allowed", tr("ui.ai_always_allowed"), false, Some(remembered.len()), |ui| {if remembered.is_empty() {- ui_kit::text(ui, tr("ui.ai_always_allowed_none"), ui_kit::Text::Note("none"));+ ui_kit::text(ui, tr("ai.prefs.no_saved_approvals"), ui_kit::Text::Hint("none")).on_hover_text(tr("ui.ai_always_allowed_none"));}- let names: std::collections::HashMap<_, _> = agents::entries(app).into_iter().map(|e| (e.id, e.name)).collect();+ let names: std::collections::HashMap<_, _> = agents::entries(app).into_iter().map(|entry| (entry.id, entry.name)).collect();for (agent, tools) in remembered {- ui_kit::label_actions(ui, names.get(&agent).unwrap_or(&agent), |ui| {- if ui_kit::button(ui, tr("ui.ai_reset"), ui_kit::Button::Small).clicked() {- app.preferences.agent_always_allow.remove(&agent);- }+ let t = crate::theme::Tokens::get();+ ui_kit::settings_block(ui, names.get(&agent).unwrap_or(&agent), t.space_24 * 6.0 + t.space_6, |ui| {+ ui.horizontal(|ui| {+ if ui_kit::button(ui, tr("ui.ai_reset"), ui_kit::Button::Small).clicked() {+ app.preferences.agent_always_allow.remove(&agent);+ }+ ui_kit::settings_short_note(ui, &tools.join(", "));+ });});- ui_kit::text(ui, &tools.join(", "), ui_kit::Text::Report(&agent, false));}});});- ui_kit::section(ui, "panel", tr("ui.ai_panel"), true, |ui| {- ui_kit::row(ui, tr("ui.agent_chat_side"), |ui| {- let p = &mut app.preferences;- let mut selected = if p.agent_chat_popped { 2 } else { usize::from(p.agent_chat_side != "left") };- let options = [tr("ui.agent_chat_left"), tr("ui.agent_chat_right"), tr("ui.agent_chat_own_window")];- if ui_kit::segmented(ui, &mut selected, &options, Default::default()) {- p.agent_chat_popped = selected == 2;- if selected < 2 {- p.agent_chat_side = if selected == 0 { "left" } else { "right" }.into();+}++fn panel_section(app: &mut SolveApp, ui: &mut egui::Ui) {+ let t = crate::theme::Tokens::get();+ ui_kit::settings_section(ui, "panel", tr("ui.ai_panel"), |ui| {+ ui_kit::settings_form(ui, t.space_24 * 6.0 + t.space_6, |ui| {+ ui_kit::row(ui, tr("ui.agent_chat_side"), |ui| {+ let p = &mut app.preferences;+ let mut selected = if p.agent_chat_popped { 2 } else { usize::from(p.agent_chat_side != "left") };+ let options = [tr("ui.agent_chat_left"), tr("ui.agent_chat_right"), tr("ui.agent_chat_own_window")];+ if ui_kit::segmented(ui, &mut selected, &options, ui_kit::Segments { intrinsic: true, ..Default::default() }) {+ p.agent_chat_popped = selected == 2;+ if selected < 2 {+ p.agent_chat_side = if selected == 0 { "left" } else { "right" }.into();+ }}- }- });- ui_kit::row(ui, tr("ui.agent_chat_turn_limit"), |ui| {- ui_kit::number_field(ui, &mut app.preferences.agent_chat_turn_limit, 1..=200, 1.0, "");+ });+ ui_kit::row(ui, tr("ui.agent_chat_turn_limit"), |ui| {+ ui_kit::settings_number(ui, &mut app.preferences.agent_chat_turn_limit, 1..=200, 1.0).on_hover_text(tr("ai.prefs.turn_limit_hint"));+ });});- ui_kit::text(ui, tr("ui.agent_chat_privacy_note"), ui_kit::Text::Note("privacy"));+ ui_kit::text(ui, tr("ai.prefs.privacy_note"), ui_kit::Text::Hint("privacy"));+ });+}++fn pointer_section(app: &mut SolveApp, ui: &mut egui::Ui) {+ ui_kit::settings_section(ui, "agent_pointer", tr("ui.agent_cursor"), |ui| {+ ui_kit::settings_pair(+ ui,+ |ui| {+ ui_kit::checkbox(ui, tr("ai.prefs.show_pointer"), &mut app.ui.agent_cursor.show)+ .on_hover_text(crate::i18n::tr_label("Show the pointer an AI agent moves (#35)"));+ ui.add_enabled_ui(app.ui.agent_cursor.show, |ui| {+ let speed_label_width = ui_kit::ContentWidth::label(ui, tr("ai.prefs.pointer_speed")) + crate::theme::Tokens::get().space_4;+ ui_kit::settings_block(ui, tr("ai.prefs.pointer_speed"), speed_label_width, |ui| {+ crate::agent_cursor::speed_slider(ui, &mut app.ui.agent_cursor.speed);+ });+ ui_kit::checkbox(ui, tr("ai.prefs.follow_camera"), &mut app.ui.agent_cursor.follow_camera)+ .on_hover_text(crate::i18n::tr_label("Follow the camera (Look At sketches)"));+ });+ (app.ui.agent_cursor.show, app.ui.agent_cursor.speed.label(), app.ui.agent_cursor.follow_camera)+ },+ |ui, (visible, speed, follow)| ui_kit::settings_pointer_preview(ui, visible, crate::i18n::tr_label(&speed), follow),+ );});}@@ -195,65 +252,88 @@ fn agents_section(app: &mut SolveApp, ui: &mut egui::Ui) {let default = if all.iter().any(|e| &e.id == d) { Some(d.clone()) } else { all.first().map(|e| e.id.clone()) };let mut remove: Option<String> = None;let mut test: Option<agents::Entry> = None;- ui_kit::section(ui, "agents", tr("ui.ai_agents"), true, |ui| {+ let t = crate::theme::Tokens::get();+ ui_kit::settings_section(ui, "agents", tr("ui.ai_agents"), |ui| {if app.agent_chat.detecting.is_some() {- ui_kit::text(ui, tr("ui.agent_chat_detecting"), ui_kit::Text::Note("detecting"));+ ui_kit::text(ui, tr("ui.agent_chat_detecting"), ui_kit::Text::Hint("detecting"));} else if all.is_empty() {- ui_kit::text(ui, tr("ui.agent_chat_none_found"), ui_kit::Text::Note("none"));+ ui_kit::empty_box(ui, "assistant_agents", tr("ai.prefs.no_agents"));}- for e in &all {- ui_kit::section(ui, &e.id, &e.name, true, |ui| {- ui_kit::text(ui, &e.detail(), ui_kit::Text::Report("detail", false));- super::panel::login_chip(ui, e.login);- if !e.found {- ui_kit::text(ui, tr("ui.ai_added"), ui_kit::Text::Note("added"));+ for (index, entry) in all.iter().enumerate() {+ ui.push_id(&entry.id, |ui| {+ if index > 0 {+ ui_kit::divider(ui, "agent_divider");}- ui.horizontal_wrapped(|ui| {- if ui_kit::list_picker(ui, &e.id, tr("ui.ai_default"), default.as_deref() == Some(e.id.as_str())).clicked() {- app.preferences.agent_default = e.id.clone();- }- });- ui_kit::row(ui, tr("ui.ai_permissions"), |ui| {- let cur = app.preferences.agent_permissions.get(&e.id).copied();- let shown = cur.map_or_else(|| tr("ui.ai_mode_global").to_string(), |m| m.label().to_string());- let mut pick: Option<Option<Mode>> = None;- ui_kit::dropdown_menu(ui, ("sc_ai_mode", &e.id), &shown, |ui| {- if ui_kit::list_picker(ui, "global", tr("ui.ai_mode_global"), cur.is_none()).clicked() {- pick = Some(None);+ ui_kit::settings_block(ui, &entry.name, t.space_24 * 6.0 + t.space_6, |ui| {+ ui.horizontal_wrapped(|ui| {+ let is_default = default.as_deref() == Some(entry.id.as_str());+ let choice = ui_kit::button(+ ui,+ tr(if is_default { "ui.ai_default" } else { "ai.prefs.make_default" }),+ if is_default { ui_kit::Button::SmallSelected } else { ui_kit::Button::Small },+ );+ crate::scenario::publish_target(&format!("dialog:list:{}", entry.id), choice.rect);+ if choice.clicked() {+ app.preferences.agent_default = entry.id.clone();}- for m in Mode::ALL {- if ui_kit::list_picker(ui, m.id(), m.label(), cur == Some(m)).clicked() {- pick = Some(Some(m));- }+ let test_button = ui_kit::button(ui, tr("ui.ai_test"), ui_kit::Button::Small);+ crate::scenario::publish_handle(&format!("prefs:ai_test:{}", entry.id), test_button.rect.center());+ if test_button.on_hover_text(tr(if entry.kind == Kind::Acp { "ui.ai_test_acp_tip" } else { "ui.ai_test_api_tip" })).clicked()+ {+ test = Some(entry.clone());}- });- match pick {- Some(Some(m)) => {- app.preferences.agent_permissions.insert(e.id.clone(), m);+ if !entry.found && ui_kit::button(ui, tr("ui.ai_remove"), ui_kit::Button::Ghost).clicked() {+ remove = Some(entry.id.clone());}- Some(None) => {- app.preferences.agent_permissions.remove(&e.id);+ match entry.login {+ "signed_in" => ui_kit::settings_badge(ui, tr("ui.agent_chat_signed_in"), false),+ "key" => ui_kit::settings_badge(ui, tr("ui.agent_chat_key_in_env"), false),+ "signed_out" => ui_kit::settings_badge(ui, tr("ui.agent_chat_not_signed_in"), true),+ _ => {}}- None => {}- }- });- ui.horizontal_wrapped(|ui| {- let b = ui_kit::button(ui, tr("ui.ai_test"), ui_kit::Button::Normal);- crate::scenario::publish_handle(&format!("prefs:ai_test:{}", e.id), b.rect.center());- if b.on_hover_text(tr(if e.kind == Kind::Acp { "ui.ai_test_acp_tip" } else { "ui.ai_test_api_tip" })).clicked() {- test = Some(e.clone());- }- if !e.found && ui_kit::button(ui, tr("ui.ai_remove"), ui_kit::Button::Normal).clicked() {- remove = Some(e.id.clone());+ if !entry.found {+ ui_kit::settings_badge(ui, tr("ui.ai_added"), false);+ }+ });+ ui_kit::settings_short_note(ui, &entry.detail());+ ui_kit::settings_form(ui, t.form_label_width + t.space_16, |ui| {+ ui_kit::row(ui, tr("ui.ai_permissions"), |ui| {+ let current = app.preferences.agent_permissions.get(&entry.id).copied();+ let shown = current.map_or_else(|| tr("ui.ai_mode_global").to_owned(), |mode| mode.label().to_owned());+ let mut pick: Option<Option<Mode>> = None;+ ui_kit::dropdown_menu(ui, ("sc_ai_mode", &entry.id), &shown, |ui| {+ if ui_kit::list_picker(ui, "global", tr("ui.ai_mode_global"), current.is_none()).clicked() {+ pick = Some(None);+ }+ for mode in Mode::ALL {+ if ui_kit::list_picker(ui, mode.id(), mode.label(), current == Some(mode)).clicked() {+ pick = Some(Some(mode));+ }+ }+ });+ match pick {+ Some(Some(mode)) => {+ app.preferences.agent_permissions.insert(entry.id.clone(), mode);+ }+ Some(None) => {+ app.preferences.agent_permissions.remove(&entry.id);+ }+ None => {}+ }+ });+ });+ if app.preferences.agent_permissions.get(&entry.id) == Some(&Mode::All) {+ ui_kit::text(ui, tr("ai.prefs.override_all_warning"), ui_kit::Text::Report("agent_permissions_warning", true))+ .on_hover_text(tr("ui.ai_mode_all_warning"));}+ test_line(ui, &app.agent_chat.settings.tests.get(&entry.id));});- test_line(ui, &app.agent_chat.settings.tests.get(&e.id));});}ui.horizontal_wrapped(|ui| {- let b = ui_kit::button(ui, tr("ui.ai_add_agent"), ui_kit::Button::Normal);- crate::scenario::publish_handle("prefs:ai_add", b.rect.center());- if b.clicked() {+ let button = ui_kit::icon_label_button(ui, tr("ui.ai_add_agent"), "plus", true, false);+ crate::scenario::publish_handle("prefs:ai_add", button.rect.center());+ if button.clicked() {open_add(app);}if ui_kit::button(ui, tr("ui.agent_chat_refresh"), ui_kit::Button::Enabled(app.agent_chat.detecting.is_none())).clicked() {diff --git a/crates/ui-egui/src/colour_vision_tests.rs b/crates/ui-egui/src/colour_vision_tests.rsindex 821a4081f7..172da1e22c 100644--- a/crates/ui-egui/src/colour_vision_tests.rs+++ b/crates/ui-egui/src/colour_vision_tests.rs@@ -875,7 +875,7 @@ fn the_sections_messages_are_in_every_catalog() {let ids: Vec<&str> = ColorVision::ALL.into_iter().flat_map(|m| [m.label_id(), m.help_id()])- .chain(crate::prefs::COLOUR_VISION_SAMPLE)+ .chain(crate::ui_kit::COLOUR_VISION_SAMPLE).chain(["ui.colour_vision", "ui.colour_vision_mode", "ui.colour_vision_sample", "ui.colour_vision_note"]).collect();for (lang, text) in [@@ -1013,22 +1013,22 @@ fn random_values_never_panic_and_only_the_four_ids_are_taken() {}#[test]-fn cancel_puts_the_mode_back_ok_keeps_it_and_restore_defaults_resets_graphics_only() {+fn cancel_puts_the_mode_back_ok_keeps_it_and_restore_defaults_resets_interface_only() {let mut app = app();let control = |app: &mut crate::SolveApp, p: serde_json::Value| crate::prefs::control(app, &p).unwrap();- control(&mut app, json!({"open": "Graphics"}));+ control(&mut app, json!({"open": "Interface"}));control(&mut app, json!({"color_vision": "protan"}));assert_eq!(app.preferences.color_vision, ColorVision::Protan);control(&mut app, json!({"button": "cancel"}));assert_eq!(app.preferences.color_vision, ColorVision::Off);- control(&mut app, json!({"open": "Graphics"}));+ control(&mut app, json!({"open": "Interface"}));control(&mut app, json!({"color_vision": "tritan", "button": "ok"}));assert_eq!(app.preferences.color_vision, ColorVision::Tritan);// Restore Defaults on another page leaves it.control(&mut app, json!({"open": "General"}));control(&mut app, json!({"button": "defaults"}));assert_eq!(app.preferences.color_vision, ColorVision::Tritan);- control(&mut app, json!({"open": "Graphics"}));+ control(&mut app, json!({"open": "Interface"}));control(&mut app, json!({"button": "defaults"}));assert_eq!(app.preferences.color_vision, ColorVision::Off);control(&mut app, json!({"button": "ok"}));diff --git a/crates/ui-egui/src/crash_ui.rs b/crates/ui-egui/src/crash_ui.rsindex 44f8a8ebe3..130f058f4b 100644--- a/crates/ui-egui/src/crash_ui.rs+++ b/crates/ui-egui/src/crash_ui.rs@@ -17,6 +17,11 @@ pub struct CrashUi {}impl CrashUi {+ /// Cached report count; rendering preferences never reads the filesystem.+ pub(crate) fn saved_count(&self) -> usize {+ self.reports.len()+ }+/// Read the reports again (when the window opens or changes; never every frame).pub fn refresh(&mut self) {let dir = self.dir_path();diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rsindex 1c560d66cd..69862415fa 100644--- a/crates/ui-egui/src/keymap.rs+++ b/crates/ui-egui/src/keymap.rs@@ -197,23 +197,34 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {}let mut action: Option<(String, &str)> = None;ui_kit::scope(ui, |ui| {- let filter =- ui_kit::search_field(ui, egui::Id::new("sc_keymap_filter"), &mut app.keymap.filter, crate::i18n::tr_label("Filter commands or keys"));+ let actions = [+ ui_kit::SearchAction { label: app.tr_label("Reset All"), icon: None, visible: !app.keymap.read_only, tooltip: None },+ ui_kit::SearchAction { label: app.tr_label("Import…"), icon: Some("import_tray"), visible: !app.keymap.read_only, tooltip: None },+ ui_kit::SearchAction {+ label: app.tr_label("Export…"),+ icon: Some("export_tray"),+ visible: true,+ tooltip: Some(app.tr_label("Keys, S box favourites and the toolbar, as a file")),+ },+ ];+ let (filter, toolbar_action) = ui_kit::search_actions_row(+ ui,+ egui::Id::new("sc_keymap_filter"),+ &mut app.keymap.filter,+ crate::i18n::tr_label("Filter commands or keys"),+ &actions,+ );crate::scenario::publish_target("keymap:filter", filter.rect);- ui.horizontal_wrapped(|ui| {- if !app.keymap.read_only && ui_kit::button(ui, app.tr_label("Reset All"), ui_kit::Button::Normal).clicked() {- action = Some((String::new(), "reset_all"));- }- if ui_kit::button(ui, app.tr_label("Export…"), ui_kit::Button::Normal)- .on_hover_text(app.tr_label("Keys, S box favourites and the toolbar, as a file"))- .clicked()- {- action = Some((String::new(), "export"));- }- if !app.keymap.read_only && ui_kit::button(ui, app.tr_label("Import…"), ui_kit::Button::Normal).clicked() {- action = Some((String::new(), "import"));- }- });+ if let Some(index) = toolbar_action {+ action = Some((+ String::new(),+ match index {+ 0 => "reset_all",+ 1 => "import",+ _ => "export",+ },+ ));+ }if let Some(m) = &app.keymap.message {ui_kit::text(ui, m, ui_kit::Text::Report("keymap_message", true));}@@ -231,72 +242,87 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {}ui_kit::text(ui, app.tr_label("Select Other: hold the left button still on the model (or right-click › Select Other…) to list everything under the cursor; click again on the same spot to select the next thing there. Double-click the middle button to go Home (Preferences › Navigation)."), ui_kit::Text::Note("navigation"));let q = app.keymap.filter.to_lowercase();- egui::ScrollArea::vertical()- .id_salt("sc_keymap_scroll")- .max_height(crate::theme::Tokens::get().control_height * 14.0)- .auto_shrink([false, true])- .show(ui, |ui| {- let columns = [- ui_kit::Column::new("Command", 1.5),- ui_kit::Column::new(crate::i18n::tr("keymap.command_id"), 1.8),- ui_kit::Column::new("Keyboard Shortcuts", 1.0),- ui_kit::Column::new("", 1.2),- ];- ui_kit::table(ui, "keymap", &columns, crate::i18n::tr("keymap.empty"), |ui, table| {- for c in command_specs() {- let key = effective(app, c.id).unwrap_or_default();- let translated_label = app.tr_label(c.label);- if !q.is_empty() && ![c.label, c.id, key.as_str(), translated_label].iter().any(|s| s.to_lowercase().contains(&q)) {- continue;- }- table.row(ui, c.id, app.keymap.capturing.as_deref() == Some(c.id), |row| {- row.cell(|ui| {- ui_kit::text(ui, translated_label, ui_kit::Text::Cell);- });- row.cell(|ui| {- ui_kit::text(ui, c.id, ui_kit::Text::Cell);- });- let capturing = app.keymap.capturing.as_deref() == Some(c.id);- let changed = app.keymap.custom.contains_key(c.id);- let text = if capturing {- app.tr_label("press a key…").to_string()- } else if key.is_empty() {- "—".to_string()+ let commands = command_specs();+ let t = crate::theme::Tokens::get();+ let key_width = commands+ .iter()+ .map(|c| {+ let key = effective(app, c.id).unwrap_or_default();+ ui_kit::ContentWidth::button(ui, &key)+ })+ .fold(ui_kit::ContentWidth::button(ui, app.tr_label("press a key…")), f32::max)+ .max(ui_kit::ContentWidth::label(ui, app.tr_label("Keyboard Shortcuts")) + t.space_8);+ let action_width = if app.keymap.read_only {+ t.control_height+ } else {+ ui_kit::ContentWidth::button(ui, app.tr_label("Clear")) + ui_kit::ContentWidth::button(ui, app.tr_label("Reset")) + t.space_4+ };+ ui_kit::settings_scroll(ui, "sc_keymap_scroll", |ui| {+ let columns = [+ ui_kit::Column::new("Command", 1.5).flex().min_content_width(t.form_label_width),+ ui_kit::Column::new(crate::i18n::tr("keymap.command_id"), 1.8).flex().min_content_width(t.form_label_width),+ ui_kit::Column::new("Keyboard Shortcuts", 1.0).flex().min_content_width(key_width),+ ui_kit::Column::new("", 0.0).icon_only().min_content_width(action_width),+ ];+ ui_kit::table(ui, "keymap", &columns, crate::i18n::tr("keymap.empty"), |ui, table| {+ for c in commands {+ let key = effective(app, c.id).unwrap_or_default();+ let translated_label = app.tr_label(c.label);+ if !q.is_empty() && ![c.label, c.id, key.as_str(), translated_label].iter().any(|s| s.to_lowercase().contains(&q)) {+ continue;+ }+ table.row(ui, c.id, app.keymap.capturing.as_deref() == Some(c.id), |row| {+ row.cell(|ui| {+ ui_kit::text(ui, translated_label, ui_kit::Text::Cell);+ });+ row.cell(|ui| {+ ui_kit::text(ui, c.id, ui_kit::Text::Cell);+ });+ let capturing = app.keymap.capturing.as_deref() == Some(c.id);+ let changed = app.keymap.custom.contains_key(c.id);+ let text = if capturing {+ app.tr_label("press a key…").to_string()+ } else if key.is_empty() {+ "—".to_string()+ } else {+ key.clone()+ };+ row.cell(|ui| {+ if app.keymap.read_only {+ ui_kit::text(ui, &text, ui_kit::Text::Cell);} else {- key.clone()- };- row.cell(|ui| {- if app.keymap.read_only {- ui_kit::text(ui, &text, ui_kit::Text::Cell);+ let capture = if key.is_empty() && !capturing {+ let (rect, _) = ui.allocate_exact_size(egui::vec2(t.control_height, t.control_height), egui::Sense::hover());+ ui_kit::quiet_icon_button_at(ui, rect, "plus", app.tr_label("Click, then press the new key"))} else {- let capture = ui_kit::button(ui, &text, ui_kit::Button::Normal)- .on_hover_text(app.tr_label("Click, then press the new key"));- crate::scenario::publish_target(&format!("keymap:capture:{}", c.id), capture.rect);- if capture.clicked() {- action = Some((c.id.to_string(), "capture"));- }- }- });- row.cell(|ui| {- if !app.keymap.read_only {- ui.horizontal(|ui| {- let clear = ui_kit::button(ui, app.tr_label("Clear"), ui_kit::Button::Enabled(!key.is_empty()));- crate::scenario::publish_target(&format!("keymap:clear:{}", c.id), clear.rect);- if clear.clicked() {- action = Some((c.id.to_string(), "clear"));- }- let reset = ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Enabled(changed));- crate::scenario::publish_target(&format!("keymap:reset:{}", c.id), reset.rect);- if reset.clicked() {- action = Some((c.id.to_string(), "reset"));- }- });+ ui_kit::button(ui, &text, ui_kit::Button::Normal).on_hover_text(app.tr_label("Click, then press the new key"))+ };+ crate::scenario::publish_target(&format!("keymap:capture:{}", c.id), capture.rect);+ if capture.clicked() {+ action = Some((c.id.to_string(), "capture"));}- });+ }});- }- });+ row.cell(|ui| {+ if !app.keymap.read_only {+ ui.horizontal(|ui| {+ let clear = ui_kit::button(ui, app.tr_label("Clear"), ui_kit::Button::Enabled(!key.is_empty()));+ crate::scenario::publish_target(&format!("keymap:clear:{}", c.id), clear.rect);+ if clear.clicked() {+ action = Some((c.id.to_string(), "clear"));+ }+ let reset = ui_kit::button(ui, app.tr_label("Reset"), ui_kit::Button::Enabled(changed));+ crate::scenario::publish_target(&format!("keymap:reset:{}", c.id), reset.rect);+ if reset.clicked() {+ action = Some((c.id.to_string(), "reset"));+ }+ });+ }+ });+ });+ }});+ });});match action {Some((id, "capture")) => {diff --git a/crates/ui-egui/src/mouse_gesture.rs b/crates/ui-egui/src/mouse_gesture.rsindex c8f09a8313..4fc2b729b9 100644--- a/crates/ui-egui/src/mouse_gesture.rs+++ b/crates/ui-egui/src/mouse_gesture.rs@@ -572,41 +572,36 @@ fn apply(list: &mut Vec<String>, op: Op) -> bool {/// The rows of Preferences › Navigation that belong to gestures: the switch, the button that/// opens the editor, and what the mouse mode has to be.pub(crate) fn nav_rows(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {- let note = |ui: &mut egui::Ui, s: &str| {- ui.label("");- ui.add(egui::Label::new(egui::RichText::new(crate::i18n::tr_label(s)).size(t.font_small).color(t.text_dim)).wrap());- ui.end_row();- };- ui.label(crate::i18n::tr_label("Mouse gestures"));- ui.horizontal(|ui| {- crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Ring of tools on the right button"), &mut app.preferences.mouse_gestures.enabled);- let customize = crate::ui_kit::button(ui, crate::i18n::tr_label("Customize…"), crate::ui_kit::Button::Normal);- crate::scenario::publish_handle("gestures:customize", customize.rect.center());- if customize.clicked() {- app.gesture.editor.open = true;- app.gesture.editor.studio = Studio::of(app);- }- });- ui.end_row();- if app.preferences.nav != MOUSE_MODE {- ui.label("");+ crate::ui_kit::settings_block(ui, crate::i18n::tr_label("Mouse gestures"), t.space_24 * 6.0 + t.space_6, |ui| {ui.horizontal_wrapped(|ui| {- ui.colored_label(- t.warning,+ crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Ring of tools on the right button"), &mut app.preferences.mouse_gestures.enabled);+ let customize = crate::ui_kit::button(ui, crate::i18n::tr_label("Customize…"), crate::ui_kit::Button::Normal);+ crate::scenario::publish_handle("gestures:customize", customize.rect.center());+ if customize.clicked() {+ app.gesture.editor.open = true;+ app.gesture.editor.studio = Studio::of(app);+ }+ });+ if app.preferences.nav != MOUSE_MODE {+ crate::ui_kit::text(+ ui,crate::i18n::tr_label("Mouse gestures only work with the SolidWorks mouse mode (the wheel orbits, Ctrl + wheel pans)."),+ crate::ui_kit::Text::Hint("mouse_gesture_mode"),);if crate::ui_kit::button(ui, crate::i18n::tr_label("Use the SolidWorks mouse mode"), crate::ui_kit::Button::Normal).clicked() {app.preferences.nav = MOUSE_MODE.to_string();app.preferences.zoom_reverse = crate::prefs::nav_preset(MOUSE_MODE).reverse_zoom;}- });- ui.end_row();- } else if app.preferences.mouse_gestures.enabled {- note(- ui,- "With gestures on, the right button no longer orbits the view: hold it and move to open the ring, then touch a tool's zone. A plain right-click still opens the menu.",- );- }+ } else if app.preferences.mouse_gestures.enabled {+ crate::ui_kit::text(+ ui,+ crate::i18n::tr_label(+ "With gestures on, the right button no longer orbits the view: hold it and move to open the ring, then touch a tool's zone. A plain right-click still opens the menu.",+ ),+ crate::ui_kit::Text::Hint("mouse_gesture_help"),+ );+ }+ });}/// The customization window: pick a studio, then how many tools its ring holds, which, and indiff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex a71a1fc1c6..c68d20460a 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -1,12 +1,5 @@-//! Preferences, one dialog, opened from the gear at the top right of the-//! window, File › Preferences or Ctrl+, (Cmd+, on macOS): General (theme, UI scale, units of new-//! designs, autosave, display precision, timeline layout, the agent cursor), Navigation (mouse presets, zoom-//! direction, zoom to the cursor, orbit centre, Look At animation), Keyboard Shortcuts (search,-//! rebind, conflicts; `keymap`), Design (default modelling orientation, Y up or Z up), Graphics-//! (visual style, grid, shadow, perspective, anti-aliasing, colour vision), Sketch and Selection.-//! Changes apply at once; Cancel puts back what was there when the dialog opened, OK keeps them,-//! Apply keeps them and stays open, and Restore Defaults resets the page shown. Everything is-//! kept between runs, except anti-aliasing, which needs a restart.+//! Grouped preferences composed with the shared UI kit. Changes apply immediately; Cancel+//! restores the opening snapshot, Apply keeps editing, and Defaults affects the current page.use egui::{Modifiers, Pos2};use serde::{Deserialize, Serialize};@@ -25,6 +18,13 @@ pub fn stored(get: impl Fn(&str) -> Option<String>) -> Option<String> {get(STORAGE_KEY).or_else(|| get(LEGACY_STORAGE_KEY))}+mod design;+mod general;+mod graphics;+mod interface;+mod navigation;+mod sketch;+use crate::SolveApp;use crate::theme::Tokens;use crate::tool_modifiers::ModifierCombo;@@ -208,28 +208,82 @@ impl Prefs {pub fn nav_preset(id: &str) -> &'static NavPreset {NAV_PRESETS.iter().find(|p| p.id == id).unwrap_or(&NAV_PRESETS[0])}-/// The dialog's pages, in order.-pub const PAGES: [&str; 9] = ["General", "Navigation", "Keyboard Shortcuts", "Design", "Graphics", "Sketch", "Selection", "AI", "Plugins"];-// Keep every existing page and its scenario identity; only their presentation is shared.+/// Stable control-channel names; presentation labels may be shorter.+pub const PAGES: [&str; 9] = ["General", "Interface", "Design", "Navigation", "Keyboard Shortcuts", "Sketch", "Graphics", "AI", "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_SKETCH: usize = 5;+pub const PAGE_GRAPHICS: usize = 6;+pub const PAGE_AI: usize = 7;+pub const PAGE_PLUGINS: usize = 8;const WINDOW_PAGES: [ui_kit::WindowPage<SolveApp>; 9] = [- ui_kit::WindowPage { icon: "settings", label: "ui.general", handle: "prefs:page:General", scroll: true, draw: window_page::<0> },- ui_kit::WindowPage { icon: "orbit", label: "ui.navigation", handle: "prefs:page:Navigation", scroll: true, draw: window_page::<1> },+ 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_palette",+ label: "prefs.interface",+ group: None,+ handle: "prefs:page:Interface",+ scroll: true,+ draw: window_page::<1>,+ },+ 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>,+ },ui_kit::WindowPage {- icon: "settings",- label: "ui.keyboard_shortcuts",+ icon: "settings_keyboard",+ label: "prefs.shortcuts",+ group: None,handle: "prefs:page:Keyboard Shortcuts",scroll: false,- draw: window_page::<2>,+ 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>,+ },+ ui_kit::WindowPage {+ icon: "assistant",+ label: "prefs.assistant",+ group: Some("prefs.extend"),+ handle: "prefs:page:AI",+ scroll: true,+ draw: window_page::<7>,+ },+ ui_kit::WindowPage {+ icon: "settings_plug",+ label: "ui.plugins",+ group: None,+ handle: "prefs:page:Plugins",+ scroll: true,+ draw: window_page::<8>,},- ui_kit::WindowPage { icon: "ws_design", label: "ui.design", handle: "prefs:page:Design", scroll: true, draw: window_page::<3> },- ui_kit::WindowPage { icon: "style", label: "ui.graphics", handle: "prefs:page:Graphics", scroll: true, draw: window_page::<4> },- ui_kit::WindowPage { icon: "sketch", label: "ui.sketch", handle: "prefs:page:Sketch", scroll: true, draw: window_page::<5> },- ui_kit::WindowPage { icon: "select", label: "ui.selection", handle: "prefs:page:Selection", scroll: true, draw: window_page::<6> },- ui_kit::WindowPage { icon: "assistant", label: "ui.ai_button", handle: "prefs:page:AI", scroll: true, draw: window_page::<7> },- ui_kit::WindowPage { icon: "library", label: "ui.plugins", handle: "prefs:page:Plugins", scroll: true, draw: window_page::<8> },];fn window_page<const INDEX: usize>(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);+ }if app.prefs_window.section != INDEX {app.keymap.read_only = false;app.prefs_window.section = INDEX;@@ -237,11 +291,6 @@ fn window_page<const INDEX: usize>(ui: &mut egui::Ui, app: &mut SolveApp) {page(app, ui, &Tokens::get());}-pub const PAGE_AI: usize = 7;-pub const PAGE_PLUGINS: usize = 8;-pub const PAGE_SHORTCUTS: usize = 2;-pub const PAGE_DESIGN: usize = 3;-pub const PAGE_GRAPHICS: usize = 4;pub const THEMES: [(&str, &str); 3] = [("dark", "Dark"), ("light", "Light"), ("system", "System")];pub const MSAA: [u32; 4] = [1, 2, 4, 8];/// Supersampling factors (#1288): off, 1.5× and 2× the viewport's pixels each way.@@ -375,40 +424,40 @@ macro_rules! preference_settings {preference_settings! {/// Units of new designs.- default_units: String = "mm".into(), 0;+ default_units: String = "mm".into(), PAGE_DESIGN;/// Mouse mapping: `fusion`, `solidworks` or `inventor`.- nav: String = "fusion".into(), 1;+ nav: String = "fusion".into(), PAGE_NAVIGATION;/// Opt in to rotation through both poles with roll, without the Shift axis-snap spring./// Independent of mouse bindings; false also preserves existing saved presets' behavior.- free_orbit: bool = false, 1 => check_tr("nav.free_orbit.label");+ free_orbit: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit.label");/// View orientation widget: original signed axes (default) or compact cube.- navigator_style: NavigatorStyle = NavigatorStyle::default(), 1;+ navigator_style: NavigatorStyle = NavigatorStyle::default(), PAGE_NAVIGATION;/// Show the radial ring and enable hold/flick gestures for viewport context menus.- radial_context_menu: bool = false, 1 => check("Radial context menu");+ radial_context_menu: bool = false, PAGE_NAVIGATION => check("Radial context menu");/// Mouse gestures: a ring of tools on the right button.- mouse_gestures: crate::mouse_gesture::Config = Default::default(), 1;+ mouse_gestures: crate::mouse_gesture::Config = Default::default(), PAGE_NAVIGATION;/// The wheel zooms out when turned forward.- zoom_reverse: bool = false, 1 => check("Reverse zoom direction");+ zoom_reverse: bool = false, PAGE_NAVIGATION => check("Reverse zoom direction");/// What an orbit turns around.- orbit_around: OrbitAround = OrbitAround::default(), 1;+ orbit_around: OrbitAround = OrbitAround::default(), PAGE_NAVIGATION;/// The cursor preference as releases before the origin option saved it (`true` = the point/// under the cursor). [`migrate`] folds it into `orbit_around` when saved preferences are/// read, so an existing choice survives the upgrade; this version only writes `false`.- orbit_cursor: bool = false, 1;+ orbit_cursor: bool = false, PAGE_NAVIGATION;/// Whether a connected 3D mouse moves the view.- space_mouse_enabled: bool = true, 1 => check("Navigate with SpaceNavigator / SpaceMouse");+ space_mouse_enabled: bool = true, PAGE_NAVIGATION => check("Navigate with SpaceNavigator / SpaceMouse");/// Speed multiplier for 3D mouse navigation.- space_mouse_speed: f32 = 1.0, 1 => enabled_slider(space_mouse_enabled, "3D mouse speed", 0.25..=3.0, 0.05, |v| format!("{v:.2}×"));+ space_mouse_speed: f32 = 1.0, PAGE_NAVIGATION;/// 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], 1;+ space_mouse_reverse: [bool; 6] = [false; 6], PAGE_NAVIGATION;/// 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], 1;+ space_mouse_axis_speed: [f32; 6] = [1.0; 6], PAGE_NAVIGATION;/// 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, 1;+ space_mouse_axis_source: [usize; 6] = crate::space_mouse::SAME_AXES, PAGE_NAVIGATION;/// Which program reads the 3D mouse when spacenavd and the device itself are both there (Linux).- space_mouse_driver: SpaceMouseDriver = SpaceMouseDriver::default(), 1;+ space_mouse_driver: SpaceMouseDriver = SpaceMouseDriver::default(), PAGE_NAVIGATION;/// 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")]@@ -433,59 +482,59 @@ preference_settings! {/// 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");/// Decimals shown for lengths and angles.- length_decimals: u8 = 2, 0 => number("ui.length_decimals", 0..=6);- angle_decimals: u8 = 1, 0 => number("ui.angle_decimals", 0..=6);+ length_decimals: u8 = 2, PAGE_DESIGN;+ angle_decimals: u8 = 1, PAGE_DESIGN;/// `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(), 0;+ theme: String = "dark".into(), PAGE_INTERFACE;/// Imported theme files (`theme_files`), kept here so they also work in the browser.custom_themes: Vec<crate::theme_files::ThemeFile> = Vec::new();/// Interface language (a registered locale ID).language: String = "en".into(), 0;/// Shared workspace composition; system windows and popups retain their purpose.- layout: crate::shell::LayoutMode = Default::default(), 0;+ layout: crate::shell::LayoutMode = Default::default(), PAGE_INTERFACE;/// Show command names beneath ribbon icons, independently of workspace layout.- ribbon_labels: bool = true, 0 => check_tr("ui.ribbon_labels");+ ribbon_labels: bool = true, PAGE_INTERFACE;/// Interface scale (1 = 100 %).- ui_scale: f32 = 1.0, 0, accept(0.5..=2.5) => slider("ui.ui_scale", 0.5..=2.5, 0.05, |v| format!("{:.0} %", v * 100.0), "prefs:scale");+ ui_scale: f32 = 1.0, PAGE_INTERFACE, accept(0.5..=2.5);/// Interface font: an installed font family (or a font file), or empty for the built-in one/// (#1290). Menus, dialogs and labels use it; glyphs it lacks fall back as before.- ui_font: String = String::new(), 0;+ ui_font: String = String::new(), PAGE_INTERFACE;/// Put the feature history to the left of the browser instead of below the viewport.- timeline_left: bool = false, 0;+ timeline_left: bool = false, PAGE_INTERFACE;/// Measured outer width; the contents react to this width without a names mode.- timeline_left_width: f32 = 130.0, 0;+ timeline_left_width: f32 = 130.0, PAGE_INTERFACE;/// Share the browser column, vertically, instead of a separate left column.- timeline_under_browser: bool = false, 0;+ timeline_under_browser: bool = false, PAGE_INTERFACE;/// Fold the shared-column history to its header.- timeline_collapsed: bool = false, 0;+ timeline_collapsed: bool = false, PAGE_INTERFACE;/// Whether the browser beside the vertical history is collapsed to its rail.- timeline_left_browser_collapsed: bool = false, 0;+ timeline_left_browser_collapsed: bool = false, PAGE_INTERFACE;/// Width of the browser sidebar, which/// the user drags wider or narrower at its right edge.- browser_width: f32 = DEFAULT_BROWSER_WIDTH, 0;+ browser_width: f32 = DEFAULT_BROWSER_WIDTH, PAGE_INTERFACE;/// 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, 0 => check("Float it over the workspace");+ browser_float: bool = false, PAGE_INTERFACE;/// The wheel zooms toward the point under the cursor (else toward the view's centre).- zoom_to_cursor: bool = true, 1 => check("Zoom to the cursor", "The wheel zooms toward the point under the cursor (off: 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 centre)");/// Spread discrete wheel input across frames (off: apply each event immediately).- smooth_wheel_zoom: bool = true, 1 => check("Smooth wheel zoom", "Turn off to apply each wheel event immediately, without a smoothing tail");+ smooth_wheel_zoom: bool = true, PAGE_NAVIGATION => check("Smooth wheel zoom", "Turn off to apply each wheel event immediately, without a smoothing tail");/// Two-finger trackpad scroll pans (off: it zooms like the wheel); pinch always zooms.- trackpad_pan: bool = true, 1;+ trackpad_pan: bool = true, PAGE_NAVIGATION;/// Horizontal trackpad and thumb-wheel scrolling pans the view the other way (#2007).- pan_reverse_x: bool = false, 1 => check("Reverse horizontal pan direction", "Horizontal two-finger scrolling and the thumb wheel pan the other way");+ pan_reverse_x: bool = false, PAGE_NAVIGATION => check("Reverse horizontal pan direction", "Horizontal two-finger scrolling and the thumb wheel pan the other way");/// View changes (axis view, Look At, Home) animate; `look_at_speed` scales how fast.- look_at_anim: bool = true, 1 => check("Animate view changes", "Axis view, Look At, Home and Fit");- look_at_speed: f32 = 1.0, 1, accept(0.25..=4.0) => enabled_slider(look_at_anim, "Animation speed", 0.5..=3.0, 0.25, |v| format!("{v:.2}×"));+ look_at_anim: bool = true, PAGE_NAVIGATION => check("Animate view changes", "Axis view, Look At, Home and Fit");+ look_at_speed: f32 = 1.0, PAGE_NAVIGATION, accept(0.25..=4.0) => enabled_slider(look_at_anim, "Animation speed", 0.5..=3.0, 0.25, |v| format!("{v:.2}×"));/// Default modelling orientation: `z` (Z up) or `y` (Y up) (#3).up_axis: String = "z".into(), PAGE_DESIGN;/// After a STEP or IGES file opens, offer to stand a Y-up part up (`stand_up`).offer_stand_up: bool = true, PAGE_DESIGN => check("Offer to stand up Y-up files", "After a STEP or IGES file opens with Z up, offer a quarter turn about X");/// What a middle-button double-click in the view does: `home`, `fit` or `off`.- middle_double_click: String = "home".into(), 1;+ middle_double_click: String = "home".into(), PAGE_NAVIGATION;/// Colour vision mode (#778): `off`, `protan`, `deutan` or `tritan`.- color_vision: crate::theme::ColorVision = crate::theme::ColorVision::Off, PAGE_GRAPHICS;+ color_vision: crate::theme::ColorVision = crate::theme::ColorVision::Off, PAGE_INTERFACE;/// 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`).@@ -539,12 +588,12 @@ preference_settings! {// ---- Sketch / selection modifier bindings (classic defaults; alternate mapping is opt-in) ----/// Modifier that suppresses sketch auto-snap while drawing or dragging a sketch point./// Default: Alt/Option. Set to Ctrl/Cmd for the alternate mapping.- suppress_sketch_snap: ModifierCombo = ModifierCombo::CTRL_ALT, 5;+ suppress_sketch_snap: ModifierCombo = ModifierCombo::CTRL_ALT, PAGE_SKETCH;/// Whether Alt/Option also frees gizmo / canvas manipulator arrows (Primary always does).- manipulator_free_alt: bool = true, 5;+ manipulator_free_alt: bool = true, PAGE_SKETCH;/// When true: Shift+click adds without removing; Primary toggles./// When false (default): Shift and Primary both toggle.- selection_shift_add_only: bool = false, 6;+ selection_shift_add_only: bool = false, PAGE_SKETCH;/// Plugin ids turned off (Preferences › Plugins). An installed plugin whose id is absent is on.disabled_plugins: std::collections::BTreeSet<String> = std::collections::BTreeSet::new(), PAGE_PLUGINS;}@@ -659,42 +708,78 @@ impl Snapshot {/// ones, with Import…, Export… (the theme on now as a complete file, to start a new one from)/// and Remove (an imported theme). Like the other preferences, a choice applies at once.fn theme_row(app: &mut SolveApp, ui: &mut egui::Ui) {- let choices = theme_choices(app);- let current = choices.iter().find(|(id, _)| *id == app.preferences.theme).map_or_else(|| app.preferences.theme.clone(), |(_, name)| name.clone());- let imported = app.preferences.custom_themes.iter().any(|t| t.id == app.preferences.theme);+ let mut choices = theme_choices(app);+ choices.sort_by_key(|(id, _)| match id.as_str() {+ "light" => 0,+ "dark" => 1,+ "system" => 2,+ _ => 3,+ });+ let mut tile_action: Option<(&str, String)> = None;+ let mut action_theme: Option<String> = None;let mut chosen: Option<String> = None;let mut action: Option<&str> = None;- ui_kit::row(ui, app.tr("ui.theme"), |ui| {- let combo = ui_kit::dropdown_menu(ui, "pref_theme", ¤t, |ui| {- for (id, name) in &choices {- let item = ui_kit::list_picker(ui, id, name, app.preferences.theme == *id);- crate::scenario::publish_handle(&format!("prefs:theme:{id}"), item.rect.center());- if item.clicked() {+ ui_kit::theme_rail(+ ui,+ |ui| {+ for (id, label) in &choices {+ let palette = match id.as_str() {+ "light" | "system" => Tokens::light(),+ "dark" => Tokens::dark(),+ _ => crate::theme_files::find(id, &app.preferences.custom_themes).map(crate::theme_files::resolve).unwrap_or_else(Tokens::dark),+ };+ let custom = app.preferences.custom_themes.iter().any(|t| t.id == *id);+ let note = app.tr(if id == "system" {+ "prefs.follows_os"+ } else if custom {+ "prefs.imported_file"+ } else {+ "prefs.built_in"+ });+ let response = ui_kit::option_card(+ ui,+ label,+ Some(note),+ app.preferences.theme == *id,+ true,+ ui_kit::PreferenceFigure::Theme { palette: palette.into(), system: id == "system" },+ );+ crate::scenario::publish_target(&format!("prefs:theme_tile:{id}"), response.rect);+ crate::scenario::publish_target(&format!("prefs:theme:{id}"), response.rect);+ if app.preferences.theme == *id {+ crate::scenario::publish_target("prefs:theme", response.rect);+ }+ if response.clicked() {chosen = Some(id.clone());}+ ui_kit::Menu::context(&response, |ui| {+ ui_kit::Menu::show(ui, Tokens::get().form_card_width, |ui| {+ if ui_kit::MenuItem::new("theme_export", app.tr_label("Export…"), "export").show(ui).clicked() {+ tile_action = Some(("export", id.clone()));+ ui.close();+ }+ if custom {+ let mut remove = ui_kit::MenuItem::new("theme_remove", app.tr_label("Remove"), "delete");+ remove.danger = true;+ if remove.show(ui).clicked() {+ tile_action = Some(("remove", id.clone()));+ ui.close();+ }+ }+ });+ });}- });- crate::scenario::publish_handle("prefs:theme", combo.rect.center());- });- ui.horizontal_wrapped(|ui| {- if ui_kit::button(ui, app.tr_label("Import…"), ui_kit::Button::Normal)- .on_hover_text(app.tr_label("Add a theme file (.json) and use it"))- .clicked()- {- action = Some("import");- }- if ui_kit::button(ui, app.tr_label("Export…"), ui_kit::Button::Normal)- .on_hover_text(app.tr_label("Save the theme on now as a complete theme file, to start a new one from"))- .clicked()- {- action = Some("export");- }- if imported- && ui_kit::button(ui, app.tr_label("Remove"), ui_kit::Button::Normal).on_hover_text(app.tr_label("Remove this imported theme")).clicked()- {- action = Some("remove");- }- });+ },+ |ui| {+ if ui_kit::theme_import_tile(ui, app.tr_label("Import…"), app.tr("prefs.theme_file")).clicked() {+ action = Some("import");+ }+ },+ );+ if let Some((kind, id)) = tile_action {+ action = Some(kind);+ action_theme = Some(id);+ }if let Some(id) = chosen {select_theme(app, &id);}@@ -711,7 +796,8 @@ fn theme_row(app: &mut SolveApp, ui: &mut egui::Ui) {}}),Some("export") => {- let file = current_theme_file(app);+ let system_dark = ui.ctx().system_theme().map_or(app.ui.dark, |theme| theme == egui::Theme::Dark);+ let file = theme_file(app, action_theme.as_deref().unwrap_or(&app.preferences.theme), system_dark);let name = file.get("name").and_then(serde_json::Value::as_str).unwrap_or("Theme").to_string();let text = serde_json::to_string_pretty(&file).unwrap_or_default();app.pick_save(&format!("{name}.json"), &["json"], move |app, path| {@@ -723,7 +809,7 @@ fn theme_row(app: &mut SolveApp, ui: &mut egui::Ui) {});}Some("remove") => {- let id = app.preferences.theme.clone();+ let id = action_theme.unwrap_or_else(|| app.preferences.theme.clone());if let Err(e) = remove_theme(app, &id) {app.set_status(e, true);}@@ -752,7 +838,7 @@ fn ui_font_row(app: &mut SolveApp, ui: &mut egui::Ui) {None,families.is_none().then(|| crate::i18n::tr_label("Listing the installed fonts…")),);- if let Some(rect) = crate::scenario::rect_of(&format!("dialog:widget:{}", crate::i18n::tr_label("Interface font"))) {+ if let Some(rect) = crate::scenario::rect_of(&format!("dialog:widget:{}", crate::i18n::tr("prefs.font"))) {crate::scenario::publish_handle("prefs:ui_font", rect.center());}if let Some(name) = chosen {@@ -771,13 +857,15 @@ fn defaults(app: &mut SolveApp, page: usize) {reset_preferences(&mut app.preferences, page);match page {0 => {- app.ui.dark = true;- app.ui.layout = app.preferences.layout;- app.ui.agent_cursor = Default::default();app.autosave_minutes = 5.0;set_autosave(app);}- 1 | PAGE_DESIGN | PAGE_AI => {}+ PAGE_INTERFACE => {+ app.ui.dark = true;+ app.ui.layout = app.preferences.layout;+ }+ PAGE_AI => app.ui.agent_cursor = Default::default(),+ PAGE_NAVIGATION | PAGE_DESIGN => {}PAGE_SHORTCUTS => crate::keymap::reset(app, None),PAGE_GRAPHICS => {app.ui.visual_style = 0;@@ -788,12 +876,11 @@ fn defaults(app: &mut SolveApp, page: usize) {save_graphics(app);}}- 5 => {+ PAGE_SKETCH => {app.session.auto_project = true;- }- _ => {app.ui.pick_bodies = false;}+ _ => {}}}@@ -1048,17 +1135,19 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {return;}if app.prefs_window.snapshot.is_none() {+ app.crashes.refresh();app.prefs_window.snapshot = Some(Snapshot::take(app));}unfold(ctx);let mut button: Option<&str> = None;let before = app.preferences.clone();let capturing = crate::keymap::capturing(app);- let window = ui_kit::Window::new(egui::Id::new("sc_prefs"), "settings", app.tr("ui.preferences")).cards(3.0).fields().actions(- "OK",- "Cancel",- Some("Apply"),- );+ let window = ui_kit::Window::new(egui::Id::new("sc_prefs"), "settings", app.tr("ui.preferences"))+ .cards(10.0 / 3.0)+ .page_rows(24.0)+ .page_padding(egui::vec2(Tokens::get().space_16 + Tokens::get().space_4, Tokens::get().space_16))+ .fields()+ .actions("OK", "Cancel", Some("Apply"));let window = if capturing { window.keep_open_on_escape() } else { window };let mut selected = app.prefs_window.section;let (closed, action) = window.show_pages(ctx, &mut selected, &WINDOW_PAGES, app, |ui| {@@ -1144,522 +1233,22 @@ fn page(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {return;}match app.prefs_window.section {- 0 => {- ui_kit::row(ui, app.tr("ui.language"), |ui| {- ui_kit::dropdown_menu(ui, "pref_language", crate::i18n::Locale::for_language(&app.preferences.language).name(), |ui| {- for locale in crate::i18n::LOCALES {- if ui_kit::list_picker(ui, locale.id, locale.name, app.preferences.language == locale.id).clicked() {- app.preferences.language = locale.id.into();- }- }- });- });- theme_row(app, ui);- ui_kit::row(ui, app.tr("ui.workspace_layout"), |ui| {- let mut selected = usize::from(app.ui.layout == crate::shell::LayoutMode::Docked);- if ui_kit::segmented(- ui,- &mut selected,- &[crate::i18n::tr("ui.layout_floating"), crate::i18n::tr("ui.layout_compact")],- Default::default(),- ) {- let _ = app.run("view.layout", json!({"mode": if selected == 1 { "compact" } else { "floating" }}));- }- });- setting::ribbon_labels(app, ui);- setting::ui_scale(app, ui);- if !cfg!(target_arch = "wasm32") {- ui_kit::row(ui, app.tr_label("Interface font"), |ui| ui_font_row(app, ui));- }- ui_kit::row(ui, app.tr("ui.feature_history"), |ui| {- let mut selected = if app.preferences.timeline_left { if app.preferences.timeline_under_browser { 2 } else { 1 } } else { 0 };- if ui_kit::segmented(- ui,- &mut selected,- &[- crate::i18n::tr("ui.timeline_bottom"),- crate::i18n::tr("ui.timeline_left_sidebar"),- crate::i18n::tr("ui.history_below_browser"),- ],- Default::default(),- ) {- let _ = app.run("view.history_layout", json!({"dock": match selected { 1=>"left",2=>"under_browser",_=>"bottom" }}));- }- });- ui_kit::text(ui, app.tr("ui.timeline_left_note"), ui_kit::Text::Note("timeline"));- ui_kit::row(ui, app.tr_label("Parts browser"), |ui| {- ui.add_enabled_ui(app.ui.layout == crate::shell::LayoutMode::Floating, |ui| setting::browser_float(app, ui));- });- ui_kit::text(- ui,- app.tr_label("The tree draws on a translucent card over the 3D view instead of a column of its own."),- ui_kit::Text::Note("browser"),- );- ui_kit::row(ui, app.tr("ui.units_of_new_designs"), |ui| {- let mut selected = UNITS.iter().position(|u| *u == app.preferences.default_units).unwrap_or(0);- ui_kit::dropdown(ui, "pref_units", &mut selected, &UNITS);- if let Some(unit) = UNITS.get(selected) {- app.preferences.default_units = (*unit).into();- }- });- ui_kit::row(ui, app.tr("ui.autosave_every"), |ui| {- if ui_kit::number_field(ui, &mut app.autosave_minutes, 0.0..=120.0, 0.5, crate::i18n::tr("prefs.minutes_suffix")).changed() {- set_autosave(app);- }- });- ui_kit::text(ui, crate::i18n::tr_label("0 turns it off"), ui_kit::Text::Note("autosave"));- setting::length_decimals(app, ui);- setting::angle_decimals(app, ui);- ui_kit::row(ui, app.tr("ui.agent_cursor"), |ui| {- ui_kit::checkbox(ui, crate::i18n::tr_label("Show the pointer an AI agent moves (#35)"), &mut app.ui.agent_cursor.show);- });- ui_kit::row(ui, app.tr("ui.agent_cursor_speed"), |ui| {- ui.add_enabled_ui(app.ui.agent_cursor.show, |ui| {- crate::agent_cursor::speed_slider(ui, &mut app.ui.agent_cursor.speed);- });- });- ui.add_enabled_ui(app.ui.agent_cursor.show, |ui| {- ui_kit::checkbox(ui, crate::i18n::tr_label("Follow the camera (Look At sketches)"), &mut app.ui.agent_cursor.follow_camera);- });- crate::update::prefs_rows(app, ui);- }- 1 => {- ui_kit::row(ui, app.tr_label("Pan, zoom, orbit"), |ui| {- ui_kit::dropdown_menu(ui, "pref_nav", nav_preset(&app.preferences.nav).translated_label(), |ui| {- for p in &NAV_PRESETS {- if ui_kit::list_picker(ui, p.id, p.translated_label(), app.preferences.nav == p.id).clicked() {- app.preferences.nav = p.id.into();- app.preferences.zoom_reverse = p.reverse_zoom;- }- }- });- });- if app.preferences.nav == TOUCHPAD_NAV {- ui_kit::text(ui, crate::i18n::tr("nav.touchpad.help"), ui_kit::Text::Note("navigation"));- } else {- let snap_help =- if app.preferences.free_orbit || app.preferences.nav == OPENSCAD_NAV { "" } else { "; hold Shift during orbit to snap" };- let raw_help = format!(- "{}; Ctrl+left drag on empty space orbits{snap_help}; hold Space to pan; the wheel zooms",- nav_preset(&app.preferences.nav).help- );- ui_kit::text(ui, crate::i18n::tr_label(&raw_help), ui_kit::Text::Note("navigation"));- }- let free_orbit = setting::free_orbit(app, ui);- crate::scenario::publish_rect("prefs:free_orbit", free_orbit.rect);- crate::scenario::publish_handle("prefs:free_orbit", free_orbit.rect.center());- if app.preferences.free_orbit {- ui_kit::text(ui, crate::i18n::tr("nav.free_orbit.help"), ui_kit::Text::Note("free_orbit"));- }- setting::radial_context_menu(app, ui);- crate::mouse_gesture::nav_rows(app, ui, t);- ui_kit::row(ui, app.tr_label("View navigator"), |ui| {- let picker =- ui_kit::dropdown_menu(ui, "pref_navigator_style", crate::i18n::tr_label(app.preferences.navigator_style.label()), |ui| {- for style in NavigatorStyle::ALL {- let r = ui_kit::list_picker(- ui,- style.label(),- crate::i18n::tr_label(style.label()),- app.preferences.navigator_style == style,- );- crate::scenario::publish_target(&format!("prefs:navigator:{}", style.label()), r.rect);- if r.clicked() {- app.preferences.navigator_style = style;- }- }- });- crate::scenario::publish_target("prefs:navigator", picker.rect);- });- setting::zoom_reverse(app, ui);- setting::zoom_to_cursor(app, ui);- setting::smooth_wheel_zoom(app, ui);- let touchpad = app.preferences.nav == TOUCHPAD_NAV;- ui.add_enabled_ui(!touchpad, |ui| {- ui_kit::checkbox(ui, crate::i18n::tr_label("Two-finger scroll pans"), &mut app.preferences.trackpad_pan).on_hover_text(if touchpad {- crate::i18n::tr("nav.touchpad.scroll")- } else {- crate::i18n::tr_label(- "Trackpad gestures pan (off: they zoom like the wheel); mouse wheel zooms, thumb wheel pans sideways, pinch always zooms",- )- });- });- setting::pan_reverse_x(app, ui);- ui_kit::row(ui, app.tr_label("Orbit around"), |ui| {- let modes = [OrbitAround::Origin, OrbitAround::ViewCentre, OrbitAround::Cursor];- let mut selected = modes.iter().position(|m| *m == app.preferences.orbit_around).unwrap_or(1);- if ui_kit::segmented(- ui,- &mut selected,- &[crate::i18n::tr_label("Origin"), crate::i18n::tr_label("View centre"), crate::i18n::tr_label("Point under the cursor")],- Default::default(),- ) && let Some(mode) = modes.get(selected)- {- app.preferences.orbit_around = *mode;- }- });- ui_kit::row(ui, app.tr_label("Middle double-click"), |ui| {- let current = MiddleDoubleClick::of(app);- ui_kit::dropdown_menu(ui, "pref_middle_double_click", crate::i18n::tr_label(current.label()), |ui| {- for (m, id, label) in MiddleDoubleClick::ALL { if ui_kit::list_picker(ui, id, crate::i18n::tr_label(label), current == m).clicked() { app.preferences.middle_double_click = id.into(); } }- }).on_hover_text(crate::i18n::tr_label("Double-clicking the middle button in the view: Home (the home view, framing what is shown), Fit (frame what is shown, keeping the orientation) or nothing"));- });- setting::look_at_anim(app, ui);- setting::look_at_speed(app, ui);- setting::space_mouse_enabled(app, ui);- setting::space_mouse_speed(app, ui);- // Rows say what they do to the view, through the mapping navigation uses; the choices- // are the device's calibrated motions. Neither names a kind of device.- let mapping = app.space_mouse.mapping;- let rows: Vec<(String, bool)> = (0..6)- .map(|row| {- let label = crate::space_mouse::row_label(mapping, row);- let text = crate::i18n::Locale::for_language(&app.preferences.language).format(label, &[("n", &(row + 1).to_string())]);- (text, label == "ui.space_mouse_view_off")- })- .collect();- let (driven_by, driven_by_label) = (app.tr("ui.space_mouse_driven_by").to_owned(), app.tr("ui.space_mouse_driven_by_label").to_owned());- let off_tip = app.tr("ui.space_mouse_view_off_tip").to_owned();- let motions: Vec<String> = crate::space_mouse::MOTIONS.iter().map(|motion| app.tr(motion).to_owned()).collect();- ui_kit::row(ui, app.tr("ui.space_mouse_view_axis"), |ui| {- let header = format!("{} · {} · {}", crate::i18n::tr_label("Invert"), crate::i18n::tr_label("Speed"), driven_by_label);- ui_kit::text(ui, &header, ui_kit::Text::Note("space_mouse_rows"));- });- for (axis, (name, off)) in rows.iter().enumerate() {- let group = ui_kit::row(ui, name, |ui| {- ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {- // Invert and speed do nothing on a row the driver turns off. The motion- // choice below stays live, so a motion can still be swapped out of it.- ui.add_enabled_ui(!off, |ui| {- ui.horizontal(|ui| {- if let Some(reverse) = app.preferences.space_mouse_reverse.get_mut(axis) {- ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);- }- if let Some(speed) = app.preferences.space_mouse_axis_speed.get_mut(axis) {- ui_kit::slider(- ui,- speed,- 0.0..=3.0,- ui_kit::Slider { step: Some(0.05), format: |v| format!("{v:.2}×"), ..Default::default() },- );- }- });- });- })- .response- });- if *off {- group.on_hover_text(&off_tip);- }- ui_kit::row(ui, &driven_by_label, |ui| {- ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {- let source = &mut app.preferences.space_mouse_axis_source;- let current = source.get(axis).copied().unwrap_or(axis);- let mut chosen = current;- ui_kit::dropdown_menu(ui, ("sc_space_mouse_source", axis), motions.get(current).map_or("", String::as_str), |ui| {- for (from, name) in motions.iter().enumerate() {- if ui_kit::list_picker(ui, name, name, chosen == from).clicked() {- chosen = from;- }- }- })- .on_hover_text(&driven_by);- if chosen != current {- crate::space_mouse::reassign(source, axis, chosen);- }- });- });- }- ui_kit::row(ui, "", |ui| {- let reassigned = app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES;- ui.add_enabled_ui(app.preferences.space_mouse_enabled && reassigned, |ui| {- if ui_kit::button(ui, app.tr("ui.space_mouse_reset_axes"), ui_kit::Button::Normal).clicked() {- app.preferences.space_mouse_axis_source = crate::space_mouse::SAME_AXES;- }- });- });- // Only where the reader has seen the choice: Linux, with spacenavd and the device both there.- if let Some(present) = app.space_mouse.drivers.filter(|present| present.spacenavd || present.direct) {- let [label, auto, direct, only_spacenavd, only_direct] =- ["driver", "driver_auto", "driver_direct", "driver_only_spacenavd", "driver_only_direct"]- .map(|key| app.tr(&format!("ui.space_mouse_{key}")).to_owned());- let driver = &mut app.preferences.space_mouse_driver;- ui_kit::row(ui, &label, |ui| match (present.spacenavd, present.direct) {- (true, true) => {- let name = |driver| match driver {- SpaceMouseDriver::Automatic => auto.as_str(),- SpaceMouseDriver::Spacenavd => "spacenavd",- SpaceMouseDriver::Direct => direct.as_str(),- };- ui_kit::dropdown_menu(ui, "sc_space_mouse_driver", name(*driver), |ui| {- for choice in SpaceMouseDriver::ALL {- if ui_kit::list_picker(ui, name(choice), name(choice), *driver == choice).clicked() {- *driver = choice;- }- }- });- }- (true, false) => {- ui_kit::text(ui, &only_spacenavd, ui_kit::Text::Note("space_mouse_driver"));- }- (false, _) => {- ui_kit::text(ui, &only_direct, ui_kit::Text::Note("space_mouse_driver"));- }- });- }- ui_kit::row(ui, app.tr("ui.space_mouse_calibration"), |ui| {- let device = app.space_mouse.device.clone();- let saved = device.as_ref().is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));- ui.add_enabled_ui(app.preferences.space_mouse_enabled && device.is_some(), |ui| {- if ui_kit::button(ui, app.tr("ui.space_mouse_calibrate"), ui_kit::Button::Normal)- .on_hover_text(app.tr("ui.space_mouse_calibrate_tip"))- .clicked()- {- crate::space_mouse_calibration::start(app);- }- if saved- && ui_kit::button(ui, app.tr("ui.space_mouse_forget"), ui_kit::Button::Normal).clicked()- && let Some(device) = &device- {- app.preferences.space_mouse_calibrations.remove(device);- }- });- let status = match (&device, saved) {- (None, _) => app.tr("ui.space_mouse_none").to_owned(),- (Some(device), true) => format!("{} ({device})", app.tr("ui.space_mouse_calibrated")),- (Some(device), false) => format!("{} ({device})", app.tr("ui.space_mouse_not_calibrated")),- };- ui_kit::text(ui, &status, ui_kit::Text::Report("calibration_status", false));- });- let enabled = app.preferences.space_mouse_enabled;- let (label, tip) = (app.tr("ui.space_mouse_dead_zone").to_owned(), app.tr("ui.space_mouse_dead_zone_tip").to_owned());- let (device, raw) = (app.space_mouse.device.clone(), app.space_mouse.raw.into());- if let Some(calibration) = device.and_then(|device| app.preferences.space_mouse_calibrations.get_mut(&device)) {- ui_kit::row(ui, &label, |ui| {- ui.add_enabled_ui(enabled, |ui| {- ui_kit::slider(- ui,- &mut calibration.dead_zone_share,- 0.0..=solidcraft_space_mouse::MAX_DEAD_ZONE_SHARE,- ui_kit::Slider { step: Some(0.01), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },- )- .on_hover_text(tip);- });- });- crate::space_mouse_calibration::dead_zone_pads(ui, calibration, raw);- }- ui_kit::text(- ui,- crate::i18n::tr_label("Move and rotate the view together; sketches use pan and zoom only."),- ui_kit::Text::Note("space_mouse"),- );- }- PAGE_DESIGN => {- ui_kit::row(ui, app.tr_label("Default modelling orientation"), |ui| {- let mut selected = usize::from(app.preferences.up_axis == "y");- if ui_kit::segmented(ui, &mut selected, &[crate::i18n::tr_label("Z up"), crate::i18n::tr_label("Y up")], Default::default()) {- app.preferences.up_axis = if selected == 1 { "y" } else { "z" }.into();- }- });- ui_kit::text(- ui,- crate::i18n::tr_label("Which axis points up in the views (axis view, Home, Look At). Designs are unchanged."),- ui_kit::Text::Note("orientation"),- );- setting::offer_stand_up(app, ui);- }- PAGE_GRAPHICS => {- ui_kit::row(ui, app.tr("ui.graphics_preset"), |ui| graphics_preset_selector(app, ui));- 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"]);- app.ui.visual_style = selected as u8;- });- ui_kit::checkbox(ui, crate::i18n::tr_label("Grid"), &mut app.ui.show_grid);- ui.add_enabled_ui(app.ui.show_grid, |ui| {- setting::grid_follows_view(app, ui);- });- ui_kit::checkbox(ui, crate::i18n::tr_label("Ground shadow"), &mut app.ui.ground_shadow);- ambient_occlusion_checkbox(app, ui, "Ambient occlusion");- ui_kit::checkbox(ui, crate::i18n::tr_label("Perspective view"), &mut app.ui.perspective);- ui_kit::section(ui, "colour_vision", app.tr("ui.colour_vision"), true, |ui| {- let mode = app.preferences.color_vision;- ui_kit::row(ui, app.tr("ui.colour_vision_mode"), |ui| {- let response = ui_kit::dropdown_menu(ui, "pref_color_vision", crate::i18n::tr(mode.label_id()), |ui| {- for m in crate::theme::ColorVision::ALL {- if ui_kit::list_picker(ui, m.id(), crate::i18n::tr(m.label_id()), app.preferences.color_vision == m)- .on_hover_text(crate::i18n::tr(m.help_id()))- .clicked()- {- app.preferences.color_vision = m;- }- }- });- crate::scenario::publish_handle("prefs:color_vision", response.rect.center());- });- if app.preferences.color_vision != mode {- ui.ctx().request_repaint();- }- ui_kit::text(ui, app.tr("ui.colour_vision_sample"), ui_kit::Text::Inline);- colour_vision_sample(ui, t);- ui_kit::text(ui, app.tr("ui.colour_vision_note"), ui_kit::Text::Note("colour_vision"));- });- ui_kit::row(ui, app.tr("ui.anti_aliasing"), |ui| {- ui_kit::dropdown_menu(ui, "pref_msaa", &format!("{}×", app.preferences.msaa), |ui| {- for m in MSAA {- let ok = app.msaa_supported.is_empty() || app.msaa_supported.contains(&m);- let r = ui- .add_enabled_ui(ok, |ui| ui_kit::list_picker(ui, &m.to_string(), &format!("{m}×"), app.preferences.msaa == m))- .inner- .on_disabled_hover_text(app.tr("settings.msaa_unsupported"));- if r.clicked() {- app.preferences.msaa = m;- }- }- });- });- ui_kit::text(ui, app.tr("settings.msaa_applies_on_restart"), ui_kit::Text::Note("msaa"));- ui_kit::row(ui, app.tr("ui.display_quality"), |ui| {- use solidcraft_engine::doc::display_quality::DisplayQuality;- let label = |q: DisplayQuality| crate::i18n::tr(&format!("ui.display_quality_{}", q.id())).to_string();- let current = DisplayQuality::parse(&app.preferences.display_quality).unwrap_or_default();- ui_kit::dropdown_menu(ui, "pref_display_quality", &label(current), |ui| {- for q in DisplayQuality::ALL {- if ui_kit::list_picker(ui, q.id(), &label(q), current == q).clicked() {- app.preferences.display_quality = q.id().into();- }- }- });- });- ui_kit::text(ui, app.tr("settings.display_quality_note"), ui_kit::Text::Note("quality"));- ui_kit::row(ui, app.tr("ui.supersampling"), |ui| {- let ss_label = |f: f32| if f > 1.0 { format!("{f}×") } else { crate::i18n::tr("ui.supersampling_off").into() };- ui_kit::dropdown_menu(ui, "pref_ssaa", &ss_label(app.preferences.supersampling), |ui| {- for f in SUPERSAMPLING {- if ui_kit::list_picker(ui, &f.to_string(), &ss_label(f), app.preferences.supersampling == f).clicked() {- app.preferences.supersampling = f;- }- }- });- });- ui.add_enabled_ui(app.preferences.supersampling > 1.0, |ui| {- setting::supersampling_adaptive(app, ui);- });- ui_kit::text(ui, app.tr("settings.supersampling_note"), ui_kit::Text::Note("supersampling"));- ui_kit::row(ui, app.tr_label("Renderer"), |ui| {- let renderer = match (&app.viewport.gpu, &app.help.gpu) {- (Some(_), Some(g)) => format!("GPU: {g}"),- (Some(_), None) => "GPU".into(),- _ => crate::i18n::tr("prefs.cpu").into(),- };- ui_kit::text(ui, &renderer, ui_kit::Text::Inline);- });- 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"));- setting::show_frame_rate(app, ui);- ui_kit::text(ui, app.tr("settings.frame_rate_note"), ui_kit::Text::Note("frame_rate"));- }- 5 => {- let mut auto = app.session.auto_project;- if ui_kit::checkbox(ui, crate::i18n::tr_label("Project face edges into new sketches"), &mut auto).changed() {- let _ = app.run("sketch.auto_project", json!({"value": auto}));- }- ui_kit::section(ui, "sketch_modifiers", crate::i18n::tr_label("Sketch modifiers"), true, |ui| {- ui_kit::row(ui, crate::i18n::tr_label("Suppress auto-snap while drawing / dragging"), |ui| {- let combo = &mut app.preferences.suppress_sketch_snap;- ui_kit::dropdown_menu(ui, "pref_suppress_sketch_snap", &combo.label(), |ui| {- for choice in ModifierCombo::SNAP_SUPPRESS_CHOICES {- if ui_kit::list_picker(ui, &choice.label(), &choice.label(), *combo == choice).clicked() {- *combo = choice;- }- }- });- });- ui_kit::text(ui, crate::i18n::tr_label("ui.suppress_auto_snap_note"), ui_kit::Text::Note("suppress_snap"));- ui_kit::checkbox(ui, crate::i18n::tr_label("Manipulator free drag also on Alt/Option"), &mut app.preferences.manipulator_free_alt)- .on_hover_text(crate::i18n::tr_label(- "On: Alt/Option or Ctrl/Cmd on extrude / gizmo arrows disables value snapping. Off: Ctrl/Cmd only.",- ));- });- }- _ => {- ui_kit::checkbox(ui, crate::i18n::tr_label("Click selects whole bodies"), &mut app.ui.pick_bodies);- ui_kit::section(ui, "selection_modifiers", crate::i18n::tr_label("Selection modifiers"), true, |ui| {- ui_kit::checkbox(ui, crate::i18n::tr_label("Shift+click adds without removing"), &mut app.preferences.selection_shift_add_only)- .on_hover_text(crate::i18n::tr_label("On: Shift adds items, Ctrl/Cmd toggles. Off (default): Shift and Ctrl/Cmd both toggle."));- });- }+ PAGE_GENERAL => general::show(app, ui),+ PAGE_INTERFACE => interface::interface(app, ui, t),+ PAGE_DESIGN => design::show(app, ui),+ PAGE_NAVIGATION => navigation::show(app, ui, t),+ PAGE_GRAPHICS => graphics::show(app, ui),+ PAGE_SKETCH => sketch::show(app, ui),+ _ => {}}}-/// The names under the Colour vision sample (message ids).-pub(crate) const COLOUR_VISION_SAMPLE: [&str; 6] =- ["ui.colour_vision_fixed", "ui.colour_vision_projected", "ui.axes", "Bends", "ui.draft", "ui.colour_vision_failed"];--/// The Colour vision sample (#778): fixed and projected sketch lines, the X and Y axes, bends up-/// and down, Draft Analysis and a failed feature, each drawn as it is where it appears, in the-/// colours on now. One fixed-size area, so the grid row is as tall as what it draws.-fn colour_vision_sample(ui: &mut egui::Ui, t: &Tokens) {- const W: f32 = 72.0;- const LINE: f32 = 4.0;- let (area, _) = ui.allocate_exact_size(egui::vec2(W * COLOUR_VISION_SAMPLE.len() as f32, 50.0), egui::Sense::hover());- let p = ui.painter_at(area);- let line = |c| egui::Stroke::new(LINE, c);- for (i, name) in COLOUR_VISION_SAMPLE.iter().enumerate() {- let cell = egui::Rect::from_min_size(area.min + egui::vec2(W * i as f32, 0.0), egui::vec2(W - 8.0, 32.0));- let (a, b) = (cell.left_center() + egui::vec2(8.0, 0.0), cell.right_center() - egui::vec2(8.0, 0.0));- match i {- 0 | 1 => {- p.rect_filled(cell, 3.0, t.viewport_top);- p.line_segment([a, b], line(if i == 0 { t.sketch_locked } else { t.sketch_projected }));- }- 2 => {- // X along and Y up from one corner, as the view triad draws them.- p.rect_filled(cell, 3.0, t.viewport_top);- let o = cell.left_bottom() + egui::vec2(12.0, -7.0);- p.line_segment([o, egui::pos2(cell.right() - 10.0, o.y)], line(t.triad[0]));- p.line_segment([o, egui::pos2(o.x, cell.top() + 6.0)], line(t.triad[1]));- }- 3 => {- // Dashed, as the flat pattern draws them.- p.rect_filled(cell, 3.0, t.viewport_top);- for (dy, c) in [(-7.0, t.bend_up), (7.0, t.bend_down)] {- p.extend(egui::Shape::dashed_line(&[a + egui::vec2(0.0, dy), b + egui::vec2(0.0, dy)], line(c), 8.0, 5.0));- }- }- 4 => {- // The three bands of Draft Analysis; in a mode the negative one is striped.- let w = cell.width() / 3.0;- for (k, c) in t.analysis.draft.iter().enumerate() {- let band = egui::Rect::from_min_size(cell.min + egui::vec2(w * k as f32, 0.0), egui::vec2(w, cell.height()));- p.rect_filled(band, 0.0, crate::theme::srgb(*c));- if k == 2 && t.analysis.hatch {- let stripes = p.with_clip_rect(band);- let dark = crate::theme::srgb(c.map(|x| x * 0.6));- let mut x = band.left() - band.height();- while x < band.right() {- stripes.line_segment(- [egui::pos2(x, band.bottom()), egui::pos2(x + band.height(), band.top())],- egui::Stroke::new(2.0, dark),- );- x += 9.0;- }- }- }- }- _ => {- // A failed feature on the timeline.- p.rect(cell.shrink2(egui::vec2(10.0, 3.0)), 3.0, t.timeline_item_error, egui::Stroke::new(1.0, t.error), egui::StrokeKind::Inside);- }- }- p.text(- cell.center_bottom() + egui::vec2(0.0, 3.0),- egui::Align2::CENTER_TOP,- crate::i18n::tr(name),- egui::FontId::proportional(crate::theme::Tokens::get().font_small),- t.text_dim,- );+fn page_index(name: &str) -> Option<usize> {+ match name.to_ascii_lowercase().as_str() {+ "selection" | "sketch & selection" | "sketch and selection" => Some(PAGE_SKETCH),+ "assistant" => Some(PAGE_AI),+ "shortcuts" => Some(PAGE_SHORTCUTS),+ _ => PAGES.iter().position(|x| x.eq_ignore_ascii_case(name)),}}@@ -1673,7 +1262,7 @@ pub fn control(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::let mut rest = p.as_object().cloned().unwrap_or_default();if let Some(page) = rest.remove("open") {let name = page.as_str().unwrap_or("General");- let i = PAGES.iter().position(|x| x.eq_ignore_ascii_case(name)).ok_or_else(|| format!("no page `{name}` ({})", PAGES.join(", ")))?;+ let i = page_index(name).ok_or_else(|| format!("no page `{name}` ({})", PAGES.join(", ")))?;open_at(app, i);if app.prefs_window.snapshot.is_none() {app.prefs_window.snapshot = Some(Snapshot::take(app));@@ -1782,10 +1371,15 @@ fn remove_theme(app: &mut SolveApp, id: &str) -> Result<(), String> {/// The theme on now as a complete theme file, a starting point for a new one.fn current_theme_file(app: &SolveApp) -> serde_json::Value {+ theme_file(app, &app.preferences.theme, app.ui.dark)+}++/// Export the tile the user chose, without applying it or changing the dialog snapshot.+fn theme_file(app: &SolveApp, id: &str, system_dark: bool) -> serde_json::Value {use crate::theme_files::{Base, export, find, resolve};- match find(&app.preferences.theme, &app.preferences.custom_themes) {+ match find(id, &app.preferences.custom_themes) {Some(f) => export(&f.name, f.base, &resolve(f)),- None if app.ui.dark => export("Dark", Base::Dark, &crate::theme::Tokens::dark()),+ None if id == "dark" || (id == "system" && system_dark) => export("Dark", Base::Dark, &crate::theme::Tokens::dark()),None => export("Light", Base::Light, &crate::theme::Tokens::light()),}}@@ -1919,8 +1513,116 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valuserde_json::to_value(&app.preferences).map_err(|e| e.to_string())}+#[cfg(test)]+pub(crate) fn reveal_preference(h: &mut crate::scenario::Harness, handle: &str) {+ for _ in 0..16 {+ let page = crate::scenario::rect_of("dialog:page_body").expect("preference body");+ let visible = crate::scenario::rect_of(handle)+ .map(|r| page.contains_rect(r))+ .unwrap_or_else(|| crate::scenario::handle_at(handle).is_some_and(|p| page.shrink(crate::theme::Tokens::get().space_16).contains(p)));+ if visible {+ return;+ }+ h.call("ui.scroll", json!({"x":page.center().x,"y":page.center().y,"delta":-100}));+ h.frames(20);+ }+ panic!("preference {handle} was not revealed");+}+#[cfg(test)]mod tests {+ #[test]+ fn display_quality_cards_show_increasing_facet_detail() {+ let mut app = super::SolveApp::new(Default::default(), Default::default());+ super::open_at(&mut app, super::PAGE_GRAPHICS);+ let ctx = crate::fonts::test_context();+ let mut shapes = Vec::new();+ for _ in 0..3 {+ let mut out = ctx.run_ui(+ egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 1000.0))), ..Default::default() },+ |ui| super::show(&mut app, ui.ctx()),+ );+ shapes = std::mem::take(&mut out.shapes);+ out.textures_delta.clear();+ }+ let mut previous = 0;+ for label in ["Coarse", "Normal", "Fine", "Ultra"] {+ let card = crate::scenario::rect_of(&format!("prefs:option:{label}")).expect("quality card");+ let facets = shapes+ .iter()+ .filter_map(|shape| {+ if let egui::Shape::Path(path) = &shape.shape {+ path.points.iter().all(|p| card.contains(*p)).then_some(path.points.len())+ } else {+ None+ }+ })+ .max()+ .unwrap_or(0);+ assert!(facets > previous, "{label} must visibly add detail to the preceding quality: {facets} <= {previous}");+ previous = facets;+ }+ }++ #[test]+ fn moved_preferences_reset_only_on_their_new_page() {+ use super::*;+ let fields = [+ ("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),+ ("timeline_left", json!(true), PAGE_INTERFACE),+ ("timeline_under_browser", json!(true), PAGE_INTERFACE),+ ("browser_float", json!(true), PAGE_INTERFACE),+ ("color_vision", json!("protan"), PAGE_INTERFACE),+ ("nav", json!("blender"), PAGE_NAVIGATION),+ ("look_at_anim", json!(false), PAGE_NAVIGATION),+ ("selection_shift_add_only", json!(true), PAGE_SKETCH),+ ("suppress_sketch_snap", json!(ModifierCombo::NONE), PAGE_SKETCH),+ ("msaa", json!(8), PAGE_GRAPHICS),+ ];+ let defaults = serde_json::to_value(Prefs::default()).unwrap();+ for (field, value, owner) in fields {+ for page in 0..PAGES.len() {+ let mut data = defaults.clone();+ data[field] = value.clone();+ let mut prefs: Prefs = serde_json::from_value(data).unwrap();+ reset_preferences(&mut prefs, page);+ let result = serde_json::to_value(prefs).unwrap();+ assert_eq!(result[field], if page == owner { defaults[field].clone() } else { value.clone() }, "{field}, page {page}");+ }+ }+ }++ #[test]+ fn page_aliases_and_transient_defaults_follow_the_new_groups() {+ use super::*;+ 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("Shortcuts"), Some(PAGE_SHORTCUTS));+ let mut app = SolveApp::new(Default::default(), Default::default());+ app.ui.agent_cursor.show = false;+ app.ui.pick_bodies = true;+ app.session.auto_project = false;+ defaults(&mut app, PAGE_GENERAL);+ assert!(!app.ui.agent_cursor.show);+ assert!(app.ui.pick_bodies);+ assert!(!app.session.auto_project);+ defaults(&mut app, PAGE_AI);+ 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);+ assert!(!app.ui.pick_bodies);+ assert!(app.session.auto_project);+ }+/// The interface font (#1290): a font that can be read, or empty for the built-in one; saved/// with the others and reset by Restore Defaults.#[test]@@ -1937,7 +1639,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, 0);+ super::defaults(&mut app, super::PAGE_INTERFACE);assert_eq!(app.preferences.ui_font, "");}@@ -1945,6 +1647,17 @@ mod tests {/// next frame draws with their colours (dark following the base), an export gives the theme/// back complete, imported themes are saved with the preferences, Remove falls back to the/// base and Cancel takes an import back.+ #[test]+ fn system_theme_tile_export_uses_os_brightness_without_selecting_it() {+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ app.preferences.theme = "light".into();+ app.ui.dark = false;+ assert_eq!(theme_file(&app, "system", true)["base"], "dark");+ assert_eq!(theme_file(&app, "system", false)["base"], "light");+ assert_eq!(app.preferences.theme, "light");+ assert!(!app.ui.dark);+ }+#[test]fn theme_files_import_apply_export_save_and_remove() {use crate::theme::{ColorVision, Tokens};@@ -1990,7 +1703,7 @@ mod tests {assert!(h.call("ui.prefs", json!({"theme_remove": "paper"}))["error"].is_string());h.call("ui.prefs", json!({"theme": "dark"}));- h.call("ui.prefs", json!({"open": "General"}));+ h.call("ui.prefs", json!({"open": "Interface"}));h.call("ui.prefs", json!({"theme_import": file}));let out = h.call("ui.prefs", json!({"button": "cancel"}));assert_eq!(out["result"]["theme"], "dark", "{out}");@@ -2009,7 +1722,8 @@ mod tests {let body = egui::Id::new("sc_prefs").with("collapsing");let folded = |h: &crate::scenario::Harness| CollapsingState::load(&h.ctx, body).is_some_and(|s| !s.is_open());let mut h = crate::scenario::Harness::new();- h.call("ui.prefs", json!({"open":"General"}));+ h.call("ui.prefs", json!({"open":"Interface"}));+ super::reveal_preference(&mut h, "prefs:ui_font");let combo = crate::scenario::handle_at("prefs:ui_font").unwrap();h.call("ui.click", json!({"x":combo.x,"y":combo.y}));let builtin = crate::scenario::handle_at("prefs:font_builtin").expect("the font list is open");@@ -2024,7 +1738,7 @@ mod tests {let mut state = CollapsingState::load_with_default_open(&h.ctx, body, true);state.set_open(false);state.store(&h.ctx);- h.call("ui.prefs", json!({"open":"General"}));+ h.call("ui.prefs", json!({"open":"Interface"}));h.frames(2);assert!(!folded(&h), "a folded Preferences window unfolds when it opens");assert!(crate::scenario::rect_of("prefs:ok").is_some());@@ -2187,6 +1901,7 @@ mod tests {let design = h.app.session.doc.to_json();let nav = h.app.preferences.nav.clone();h.call("ui.prefs", json!({"open":"Navigation"}));+ super::reveal_preference(&mut h, "prefs:navigator");let picker = crate::scenario::rect_of("prefs:navigator").unwrap().center();h.call("ui.click", json!({"x":picker.x,"y":picker.y}));let cube = crate::scenario::rect_of("prefs:navigator:Cube").unwrap().center();@@ -2247,6 +1962,14 @@ mod tests {assert!(!old.radial_context_menu && old.zoom_reverse && old.nav == "solidworks");let mut h = crate::scenario::Harness::new();h.call("ui.prefs", json!({"open":"Navigation"}));+ for _ in 0..16 {+ let page = crate::scenario::rect_of("dialog:page_body").expect("Navigation page body");+ if h.widget("Radial context menu").is_some_and(|[x, y]| page.contains(egui::pos2(x as f32, y as f32))) {+ break;+ }+ h.call("ui.scroll", json!({"x":page.center().x,"y":page.center().y,"delta":-100}));+ h.frames(20);+ }h.step(&json!({"widget":"Radial context menu"})).unwrap();assert!(h.app.preferences.radial_context_menu, "the actual checkbox enables radial menus");let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());@@ -2298,7 +2021,7 @@ mod tests {control(&mut app, &json!({"open": "Sketch", "button": "defaults"})).unwrap();assert_eq!(app.preferences.suppress_sketch_snap, ModifierCombo::CTRL_ALT);assert!(app.preferences.manipulator_free_alt);- assert!(app.preferences.selection_shift_add_only, "Selection page setting stays until that page resets");+ assert!(!app.preferences.selection_shift_add_only, "the merged Sketch & selection page resets both sets of modifiers");control(&mut app, &json!({"button": "cancel"})).unwrap();assert_eq!(app.preferences.suppress_sketch_snap, ModifierCombo::CTRL);}@@ -2677,8 +2400,9 @@ mod ui_scale_regression_tests {#[test]fn dragging_the_scale_slider_keeps_its_window_still_until_release() {let mut h = crate::scenario::Harness::new();- h.call("ui.prefs", json!({"open":"General"}));+ h.call("ui.prefs", json!({"open":"Interface"}));let window = crate::scenario::rect_of("prefs:window").unwrap();+ super::reveal_preference(&mut h, "prefs:scale");let slider = crate::scenario::rect_of("prefs:scale").unwrap();let a = pos2(slider.left() + 20.0, slider.center().y);let b = pos2(slider.left() + 90.0, slider.center().y);@@ -2722,6 +2446,7 @@ mod ambient_occlusion_tests {let camera = h.app.cam;let design = h.app.session.doc.to_json();h.call("ui.prefs", json!({"open":"Graphics"}));+ super::reveal_preference(&mut h, "view:ambient_occlusion");let checkbox = crate::scenario::handle_at("view:ambient_occlusion").unwrap();h.call("ui.click", json!({"x":checkbox.x,"y":checkbox.y}));assert!(h.app.preferences.ambient_occlusion);diff --git a/crates/ui-egui/src/prefs/design.rs b/crates/ui-egui/src/prefs/design.rsnew file mode 100644index 0000000000..72477178ce--- /dev/null+++ b/crates/ui-egui/src/prefs/design.rs@@ -0,0 +1,52 @@+//! New-design defaults, with inline precision specimens.+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.design"), app.tr("prefs.design_note"));+ ui_kit::settings_section(ui, "units", app.tr("prefs.units_precision"), |ui| {+ ui_kit::settings_form(ui, t.space_24 * 7.0 + t.space_2, |ui| {+ ui_kit::row(ui, app.tr("ui.units_of_new_designs"), |ui| {+ let mut selected = UNITS.iter().position(|u| *u == app.preferences.default_units).unwrap_or(0);+ ui_kit::segmented(ui, &mut selected, &UNITS, ui_kit::Segments { intrinsic: true, ..Default::default() });+ if let Some(unit) = UNITS.get(selected) {+ app.preferences.default_units = (*unit).into();+ }+ });+ ui_kit::row(ui, app.tr("ui.length_decimals"), |ui| {+ ui_kit::settings_number(ui, &mut app.preferences.length_decimals, 0..=6, 1.0);+ ui.add_space(t.space_6);+ let sample = format_length(+ 12.5 * unit_scale(&app.preferences.default_units).0,+ &app.preferences.default_units,+ app.preferences.length_decimals,+ );+ ui_kit::settings_precision_sample(ui, &sample);+ });+ ui_kit::row(ui, app.tr("ui.angle_decimals"), |ui| {+ ui_kit::settings_number(ui, &mut app.preferences.angle_decimals, 0..=6, 1.0);+ ui.add_space(t.space_6);+ ui_kit::settings_precision_sample(ui, &format!("{:.*}°", usize::from(app.preferences.angle_decimals.min(6)), 45.0));+ });+ });+ });+ ui_kit::settings_section(ui, "orientation", app.tr("prefs.orientation"), |ui| {+ ui.horizontal_wrapped(|ui| {+ for (id, label, y_up) in [("z", "Z up", false), ("y", "Y up", true)] {+ let subtitle = Some(if id == "z" { app.tr("prefs.default") } else { "" });+ if ui_kit::option_card(ui, app.tr_label(label), subtitle, app.preferences.up_axis == id, true, ui_kit::PreferenceFigure::UpAxis(y_up))+ .clicked()+ {+ app.preferences.up_axis = id.into();+ }+ }+ });+ ui_kit::text(+ ui,+ crate::i18n::tr_label("Which axis points up in the views (axis view, Home, Look At). Designs are unchanged."),+ ui_kit::Text::Hint("orientation"),+ );+ setting::offer_stand_up(app, ui);+ ui_kit::text(ui, app.tr("prefs.stand_up_note"), ui_kit::Text::Hint("stand_up"));+ });+}diff --git a/crates/ui-egui/src/prefs/general.rs b/crates/ui-egui/src/prefs/general.rsnew file mode 100644index 0000000000..b2a6188376--- /dev/null+++ b/crates/ui-egui/src/prefs/general.rs@@ -0,0 +1,48 @@+//! General preferences, composed from shared settings form blocks.+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_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| {+ ui_kit::settings_control_width(ui, t.form_card_width - t.space_4, |ui| {+ ui_kit::dropdown_menu(ui, "pref_language", crate::i18n::Locale::for_language(&app.preferences.language).name(), |ui| {+ for locale in crate::i18n::LOCALES {+ if ui_kit::list_picker(ui, locale.id, locale.name, app.preferences.language == locale.id).clicked() {+ app.preferences.language = locale.id.into();+ }+ }+ });+ });+ });+ });+ });+ 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| {+ if ui_kit::settings_number(ui, &mut app.autosave_minutes, 0.0..=120.0, 0.5).changed() {+ set_autosave(app);+ }+ ui_kit::settings_inline_note(ui, app.tr("prefs.minutes"));+ });+ ui_kit::settings_autosave_timeline(ui, app.autosave_minutes);+ });+ ui_kit::settings_block(ui, app.tr_label("Crash reports"), labels, |ui| {+ ui.horizontal(|ui| {+ let count = app.crashes.saved_count();+ let label = crate::i18n::format("prefs.reports_saved", &[("n", &count.to_string())]);+ ui_kit::settings_badge(ui, &label, count > 0);+ if ui_kit::button(ui, app.tr("prefs.crash_reports"), ui_kit::Button::Normal).clicked() {+ crate::crash_ui::open(app);+ }+ });+ ui_kit::text(ui, app.tr("prefs.crash_reports_note"), ui_kit::Text::Hint("crash_reports"));+ });+ });+ ui_kit::settings_section(ui, "updates", app.tr("prefs.updates"), |ui| {+ ui_kit::settings_block(ui, app.tr("update.prefs_label"), labels, |ui| crate::update::prefs_rows(app, ui));+ });+}diff --git a/crates/ui-egui/src/prefs/graphics.rs b/crates/ui-egui/src/prefs/graphics.rsnew file mode 100644index 0000000000..606b42754c--- /dev/null+++ b/crates/ui-egui/src/prefs/graphics.rs@@ -0,0 +1,157 @@+//! Graphics preferences use the shared settings form and illustrative option cards.+use super::*;++pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {+ let t = crate::theme::Tokens::get();+ ui_kit::settings_heading(ui, app.tr("prefs.graphics"), app.tr("prefs.graphics_note"));+ ui.horizontal_wrapped(|ui| {+ let response =+ ui.allocate_ui_with_layout(egui::vec2(t.form_card_width + t.space_24 * 2.0, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ let presets = ["performance", "quality", "custom"];+ let mut selected = presets.iter().position(|preset| *preset == graphics_preset(&app.preferences)).unwrap_or(2);+ let labels = [app.tr("ui.graphics_performance"), app.tr("ui.graphics_quality"), app.tr("ui.graphics_custom")];+ let changed = ui_kit::segmented(ui, &mut selected, &labels, ui_kit::Segments::default());+ if changed && let Some(preset) = presets.get(selected).filter(|preset| **preset != "custom") {+ let _ = app.run("view.graphics_preset", json!({"preset":preset}));+ }+ });+ let rect = response.response.rect;+ crate::scenario::publish_handle("view:graphics_preset", rect.center());+ for (index, preset) in ["performance", "quality", "custom"].into_iter().enumerate() {+ crate::scenario::publish_handle(+ &format!("view:graphics_preset:{preset}"),+ egui::pos2(rect.left() + rect.width() * (index as f32 + 0.5) / 3.0, rect.center().y),+ );+ }+ response.response.on_hover_text(app.tr("ui.graphics_preset_help"));+ });+ ui_kit::text(ui, app.tr("prefs.graphics_presets_note"), ui_kit::Text::Hint("preset"));+ ui_kit::settings_section(ui, "quality", app.tr("prefs.curved_surfaces"), |ui| {+ use solidcraft_engine::doc::display_quality::DisplayQuality;+ ui_kit::text(ui, app.tr("ui.display_quality"), ui_kit::Text::Heading("display_quality"));+ let current = DisplayQuality::parse(&app.preferences.display_quality).unwrap_or_default();+ ui.horizontal_wrapped(|ui| {+ for ((q, facets), note) in DisplayQuality::ALL.into_iter().zip([5, 8, 14, 64]).zip([+ "prefs.quality_fastest",+ "prefs.quality_default",+ "prefs.quality_smoother",+ "prefs.quality_slowest",+ ]) {+ if ui_kit::option_card(+ ui,+ crate::i18n::tr(&format!("ui.display_quality_{}", q.id())),+ Some(app.tr(note)),+ current == q,+ true,+ ui_kit::PreferenceFigure::Quality(facets),+ )+ .clicked()+ {+ app.preferences.display_quality = q.id().into();+ }+ }+ });+ ui_kit::text(ui, app.tr("settings.display_quality_note"), ui_kit::Text::Hint("quality"));+ });+ ui_kit::settings_section(ui, "edges", app.tr("prefs.edges"), |ui| {+ ui.horizontal(|ui| {+ ui_kit::text(ui, app.tr("ui.anti_aliasing"), ui_kit::Text::Heading("antialiasing"));+ ui_kit::settings_badge(ui, app.tr("prefs.applies_on_restart"), true);+ });+ ui.horizontal_wrapped(|ui| {+ for m in MSAA {+ let enabled = app.msaa_supported.is_empty() || app.msaa_supported.contains(&m);+ let label = if m == 1 { app.tr("ui.colour_vision_off").to_owned() } else { format!("{m}×") };+ let response = ui_kit::option_card(+ ui,+ &label,+ if enabled { None } else { Some(app.tr("prefs.not_on_gpu")) },+ app.preferences.msaa == m,+ enabled,+ ui_kit::PreferenceFigure::Antialiasing(m),+ )+ .on_hover_text(app.tr("settings.msaa_applies_on_restart"));+ crate::scenario::publish_target(&format!("prefs:msaa:{m}"), response.rect);+ if enabled && response.clicked() {+ app.preferences.msaa = m;+ }+ }+ });+ ui_kit::text(ui, app.tr("prefs.anti_aliasing_note"), ui_kit::Text::Hint("msaa"));+ ui.add_space(t.space_6);+ ui_kit::text(ui, app.tr("ui.supersampling"), ui_kit::Text::Heading("supersampling"));+ ui.horizontal_wrapped(|ui| {+ ui.allocate_ui_with_layout(egui::vec2(t.form_card_width - t.space_24, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ let mut selected = SUPERSAMPLING.iter().position(|f| *f == app.preferences.supersampling).unwrap_or(0);+ if ui_kit::segmented(ui, &mut selected, &[app.tr("ui.colour_vision_off"), "1.5×", "2×"], ui_kit::Segments::default())+ && let Some(factor) = SUPERSAMPLING.get(selected)+ {+ app.preferences.supersampling = *factor;+ }+ });+ ui.add_enabled_ui(app.preferences.supersampling > 1.0, |ui| {+ setting::supersampling_adaptive(app, ui);+ });+ });+ ui_kit::text(ui, app.tr("prefs.supersampling_brief"), ui_kit::Text::Hint("supersampling"))+ .on_hover_text(app.tr("settings.supersampling_note"));+ ui.add_space(t.space_6);+ ui_kit::text(ui, app.tr_label("Ambient occlusion"), ui_kit::Text::Heading("contact_shading"));+ ui.horizontal_wrapped(|ui| {+ for (on, label) in [(false, "ui.colour_vision_off"), (true, "prefs.contact_shading")] {+ let response = ui_kit::option_card(+ ui,+ app.tr(label),+ None,+ app.preferences.ambient_occlusion == on,+ true,+ ui_kit::PreferenceFigure::ContactShading(on),+ );+ if on != app.preferences.ambient_occlusion {+ crate::scenario::publish_handle("view:ambient_occlusion", response.rect.center());+ }+ if response.clicked() {+ let _ = app.run("view.ambient_occlusion", json!({"enabled":on}));+ }+ }+ });+ ui_kit::text(ui, app.tr("prefs.contact_shading_note"), ui_kit::Text::Hint("ao"));+ });+ ui_kit::settings_section(ui, "viewport", app.tr("prefs.viewport"), |ui| {+ ui.columns(2, |columns| {+ if let Some(left) = columns.get_mut(0) {+ ui_kit::checkbox(left, crate::i18n::tr_label("Grid"), &mut app.ui.show_grid);+ ui_kit::checkbox(left, crate::i18n::tr_label("Perspective view"), &mut app.ui.perspective);+ setting::show_frame_rate(app, left).on_hover_text(app.tr("settings.frame_rate_note"));+ }+ if let Some(right) = columns.get_mut(1) {+ ui_kit::checkbox(right, crate::i18n::tr_label("Ground shadow"), &mut app.ui.ground_shadow);+ 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, 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"]);+ app.ui.visual_style = selected as u8;+ });+ });+ });+ ui.horizontal(|ui| {+ ui_kit::text(ui, app.tr_label("Renderer"), ui_kit::Text::Inline);+ let renderer = match (&app.viewport.gpu, &app.help.gpu) {+ (Some(_), Some(g)) => {+ ui_kit::settings_badge(ui, "GPU", false);+ g.to_owned()+ }+ (Some(_), None) => "GPU".into(),+ _ => crate::i18n::tr("prefs.cpu").into(),+ };+ ui_kit::text(ui, &renderer, ui_kit::Text::Inline);+ });+}diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rsnew file mode 100644index 0000000000..34d13978f4--- /dev/null+++ b/crates/ui-egui/src/prefs/interface.rs@@ -0,0 +1,148 @@+//! Interface settings composition, using shared controls and previews.+use super::*;+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"));+ ui_kit::settings_section(ui, "theme", app.tr("ui.theme"), |ui| {+ theme_row(app, ui);+ ui_kit::tab_accent_strip(ui);+ });+ ui_kit::settings_section(ui, "layout", app.tr("prefs.layout"), |ui| {+ ui_kit::settings_pair(+ ui,+ |ui| {+ ui_kit::settings_form(ui, t.form_label_width + t.space_16 + t.space_6, |ui| {+ ui_kit::row(ui, app.tr("prefs.workspace"), |ui| {+ let mut selected = usize::from(app.ui.layout == crate::shell::LayoutMode::Docked);+ if ui_kit::segmented(+ ui,+ &mut selected,+ &[crate::i18n::tr("ui.layout_floating"), crate::i18n::tr("ui.layout_compact")],+ Default::default(),+ ) {+ let _ = app.run("view.layout", json!({"mode": if selected == 1 { "compact" } else { "floating" }}));+ }+ });+ ui_kit::row(ui, app.tr("prefs.toolbar"), |ui| {+ let mut selected = usize::from(!app.preferences.ribbon_labels);+ if ui_kit::segmented(ui, &mut selected, &[app.tr("prefs.labels"), app.tr("prefs.icons_only")], Default::default()) {+ app.preferences.ribbon_labels = selected == 0;+ }+ });+ ui_kit::row(ui, app.tr("prefs.history"), |ui| {+ let mut selected = if app.preferences.timeline_left { if app.preferences.timeline_under_browser { 2 } else { 1 } } else { 0 };+ if ui_kit::segmented(+ ui,+ &mut selected,+ &[crate::i18n::tr("prefs.bottom"), crate::i18n::tr("prefs.left"), crate::i18n::tr("prefs.under_browser")],+ ui_kit::Segments { proportional: true, compact: true, ..Default::default() },+ ) {+ let _ = app.run("view.history_layout", json!({"dock": match selected { 1=>"left",2=>"under_browser",_=>"bottom" }}));+ }+ });+ for (short, legacy) in [+ ("prefs.bottom", "ui.timeline_bottom"),+ ("prefs.left", "ui.timeline_left_sidebar"),+ ("prefs.under_browser", "ui.history_below_browser"),+ ] {+ let row = app.tr("prefs.history");+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:{row}:{}", app.tr(short))) {+ crate::scenario::publish_handle(&format!("dialog:{row}:{}", app.tr(legacy)), at);+ }+ }+ ui_kit::row(ui, app.tr("prefs.browser"), |ui| {+ ui.add_enabled_ui(app.ui.layout == crate::shell::LayoutMode::Floating, |ui| {+ let mut selected = usize::from(app.preferences.browser_float);+ if ui_kit::segmented(ui, &mut selected, &[app.tr("prefs.opaque"), app.tr("prefs.translucent")], Default::default()) {+ app.preferences.browser_float = selected == 1;+ }+ });+ });+ ui_kit::text(ui, app.tr("prefs.layout_note"), ui_kit::Text::Hint("layout"));+ ui_kit::LayoutPreview {+ compact: app.ui.layout == crate::shell::LayoutMode::Docked,+ labels: app.preferences.ribbon_labels,+ history: if app.preferences.timeline_left { if app.preferences.timeline_under_browser { 2 } else { 1 } } else { 0 },+ translucent: app.preferences.browser_float,+ }+ })+ },+ ui_kit::layout_preview,+ );+ });+ 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);+ });+ 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.rsnew file mode 100644index 0000000000..0aef83d89a--- /dev/null+++ b/crates/ui-egui/src/prefs/navigation.rs@@ -0,0 +1,341 @@+//! Navigation preferences, composed from the shared settings controls and figures.+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_section(ui, "mouse", app.tr("prefs.mouse_heading"), |ui| {+ let mut gestures: Vec<_> = nav_preset(&app.preferences.nav)+ .bindings+ .iter()+ .filter(|binding| !(crate::mouse_gesture::active(app) && binding.button == NavButton::Right))+ .map(|binding| {+ let button = match binding.button {+ NavButton::Left => "prefs.button_left",+ NavButton::Middle => "prefs.button_middle",+ NavButton::Right => "prefs.button_right",+ };+ let mut keys = Vec::new();+ if binding.keys.shift {+ keys.push("Shift");+ }+ if binding.keys.ctrl {+ keys.push("Ctrl/Cmd");+ }+ if binding.keys.alt {+ keys.push("Alt/Option");+ }+ keys.push(crate::i18n::tr(button));+ let action = match binding.mode {+ NavMode::Orbit => "prefs.gesture_orbit",+ NavMode::Pan => "prefs.gesture_pan",+ NavMode::Zoom => "prefs.gesture_zoom",+ };+ (keys.into_iter().map(str::to_owned).collect::<Vec<_>>(), crate::i18n::tr(action).to_string())+ })+ .collect();+ gestures.extend([+ (+ vec![app.tr("prefs.wheel").to_owned()],+ app.tr(if app.preferences.zoom_to_cursor { "prefs.zoom_toward_cursor" } else { "prefs.gesture_zoom" }).to_owned(),+ ),+ (vec![app.tr("prefs.left_click").to_owned()], app.tr("prefs.select").to_owned()),+ (+ vec![app.tr("prefs.right_click").to_owned()],+ app.tr(if app.preferences.mouse_gestures.enabled && app.preferences.nav == crate::mouse_gesture::MOUSE_MODE {+ "prefs.context_menu_ring"+ } else {+ "prefs.context_menu"+ })+ .to_owned(),+ ),+ ]);+ ui_kit::settings_mouse_mapping(ui, &gestures, |ui| {+ ui_kit::settings_form(ui, 110.0, |ui| {+ ui_kit::row(ui, app.tr("prefs.mouse_mapping"), |ui| {+ let picker = ui_kit::dropdown_menu(ui, "pref_nav", nav_preset(&app.preferences.nav).translated_label(), |ui| {+ for preset in &NAV_PRESETS {+ if ui_kit::list_picker(ui, preset.id, preset.translated_label(), app.preferences.nav == preset.id).clicked() {+ app.preferences.nav = preset.id.into();+ app.preferences.zoom_reverse = preset.reverse_zoom;+ }+ }+ });+ crate::scenario::publish_target("dialog:Pan, zoom, orbit", picker.rect);+ picker.on_hover_text(crate::i18n::tr_label(nav_preset(&app.preferences.nav).help));+ });+ });+ });+ // These are real navigation options absent from the static board; retain them below+ // the illustrated mapping rather than enlarging the diagram or repeating its legend.+ let free_orbit = setting::free_orbit(app, ui);+ crate::scenario::publish_target("prefs:free_orbit", free_orbit.rect);+ if app.preferences.free_orbit {+ ui_kit::text(ui, crate::i18n::tr("nav.free_orbit.help"), ui_kit::Text::Hint("free_orbit"));+ }+ let help = if app.preferences.nav == TOUCHPAD_NAV {+ app.tr("nav.touchpad.help").to_owned()+ } else if !app.preferences.free_orbit && app.preferences.nav != OPENSCAD_NAV {+ format!("{} {}", app.tr("prefs.extra_navigation"), app.tr("prefs.orbit_snap"))+ } else {+ app.tr("prefs.extra_navigation").to_owned()+ };+ ui_kit::text(ui, &help, ui_kit::Text::Hint("navigation"));+ });+ ui_kit::settings_section(ui, "orbit_pivot", app.tr_label("Orbit around"), |ui| {+ ui.horizontal_wrapped(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_8;+ for (index, (mode, label)) in+ [(OrbitAround::Origin, "Origin"), (OrbitAround::ViewCentre, "View centre"), (OrbitAround::Cursor, "prefs.under_cursor")]+ .into_iter()+ .enumerate()+ {+ if ui_kit::option_card(+ ui,+ app.tr_label(label),+ None,+ app.preferences.orbit_around == mode,+ true,+ ui_kit::PreferenceFigure::Pivot(index),+ )+ .clicked()+ {+ app.preferences.orbit_around = mode;+ }+ }+ });+ });+ ui_kit::settings_section(ui, "wheel_trackpad", app.tr("prefs.wheel_trackpad"), |ui| {+ // Board order is column-major in meaning: zoom behavior at left, gesture behavior at+ // right. Each checkbox keeps its original shared-control label and scenario target.+ let width = (ui.available_width() - (t.space_16 + t.space_4)) * 0.5;+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_16 + t.space_4;+ ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ setting::zoom_to_cursor(app, ui);+ setting::zoom_reverse(app, ui);+ setting::pan_reverse_x(app, ui);+ });+ ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ setting::smooth_wheel_zoom(app, ui);+ let touchpad = app.preferences.nav == TOUCHPAD_NAV;+ ui.add_enabled_ui(!touchpad, |ui| {+ ui_kit::checkbox(ui, crate::i18n::tr_label("Two-finger scroll pans"), &mut app.preferences.trackpad_pan).on_hover_text(if touchpad {+ crate::i18n::tr("nav.touchpad.scroll")+ } else {+ crate::i18n::tr_label("Trackpad gestures pan (off: they zoom like the wheel); mouse wheel zooms, thumb wheel pans sideways, pinch always zooms")+ });+ });+ setting::radial_context_menu(app, ui);+ });+ });+ ui_kit::divider(ui, "navigation_view_controls");+ ui_kit::settings_form(ui, 150.0, |ui| {+ ui_kit::row(ui, app.tr_label("View navigator"), |ui| {+ let mut selected = usize::from(app.preferences.navigator_style == NavigatorStyle::Cube);+ if ui_kit::segmented(+ ui,+ &mut selected,+ &[app.tr("prefs.axes"), crate::i18n::tr_label("Cube")],+ ui_kit::Segments { intrinsic: true, ..Default::default() },+ ) {+ app.preferences.navigator_style = if selected == 0 { NavigatorStyle::Axes } else { NavigatorStyle::Cube };+ }+ if let Some(rect) = crate::scenario::rect_of(&format!("dialog:segments:{}", crate::i18n::tr_label("View navigator"))) {+ crate::scenario::publish_target("prefs:navigator", rect);+ for (label, key) in [(app.tr("prefs.axes"), "Signed axes"), (crate::i18n::tr_label("Cube"), "Cube")] {+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:{}:{label}", crate::i18n::tr_label("View navigator"))) {+ crate::scenario::publish_target(+ &format!("prefs:navigator:{key}"),+ egui::Rect::from_center_size(at, egui::vec2(t.space_24, t.control_height)),+ );+ }+ }+ }+ });+ ui_kit::row(ui, app.tr_label("Middle double-click"), |ui| {+ let current = MiddleDoubleClick::of(app);+ ui_kit::settings_control_width(ui, t.form_label_width * 2.0 + t.space_24 * 2.0 + t.space_12, |ui| {+ ui_kit::dropdown_menu(ui, "pref_middle_double_click", crate::i18n::tr_label(current.label()), |ui| {+ for (mode, id, label) in MiddleDoubleClick::ALL {+ if ui_kit::list_picker(ui, id, crate::i18n::tr_label(label), current == mode).clicked() {+ app.preferences.middle_double_click = id.into();+ }+ }+ }).on_hover_text(crate::i18n::tr_label("Double-clicking the middle button in the view: Home (the home view, framing what is shown), Fit (frame what is shown, keeping the orientation) or nothing"));+ });+ });+ setting::look_at_anim(app, ui);+ setting::look_at_speed(app, ui);+ });+ // The existing ring editor is part of the real product and remains available.+ crate::mouse_gesture::nav_rows(app, ui, t);+ });+ ui_kit::settings_section(ui, "devices", app.tr("prefs.devices"), |ui| {+ ui.horizontal_wrapped(|ui| {+ setting::space_mouse_enabled(app, ui);+ let device = app.space_mouse.device.as_ref();+ let saved = device.is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));+ let status = match device {+ None => app.tr("ui.space_mouse_none").to_owned(),+ Some(device) => format!("{} · {device}", app.tr(if saved { "ui.space_mouse_calibrated" } else { "ui.space_mouse_not_calibrated" })),+ };+ ui_kit::settings_badge(ui, &status, !saved);+ });+ let mapping = app.space_mouse.mapping;+ let rows: Vec<(String, bool)> = (0..6)+ .map(|row| {+ let label = crate::space_mouse::row_label(mapping, row);+ let text = crate::i18n::Locale::for_language(&app.preferences.language).format(label, &[("n", &(row + 1).to_string())]);+ (text, label == "ui.space_mouse_view_off")+ })+ .collect();+ let driven_by = app.tr("ui.space_mouse_driven_by").to_owned();+ let off_tip = app.tr("ui.space_mouse_view_off_tip").to_owned();+ let motions: Vec<String> = crate::space_mouse::MOTIONS.iter().map(|motion| app.tr(motion).to_owned()).collect();+ let calibration = app.space_mouse.device.as_ref().and_then(|device| app.preferences.space_mouse_calibrations.get(device));+ let raw: [i16; 6] = app.space_mouse.raw.into();+ let travel = calibration.map(|calibration| calibration.travel(raw));+ let zones = calibration.map(|calibration| calibration.dead_zone_shares());+ ui_kit::settings_axis_header(ui);+ for (axis, (name, off)) in rows.iter().enumerate() {+ ui.push_id(("space_mouse_axis", axis), |ui| {+ let from = app.preferences.space_mouse_axis_source.get(axis).copied().unwrap_or(axis);+ let value = travel+ .and_then(|travel| travel.get(from).copied())+ .unwrap_or_else(|| f32::from(raw.get(from).copied().unwrap_or(0)) / f32::from(crate::space_mouse::FULL_SCALE));+ let zone = zones.and_then(|zones| zones.get(from).copied()).unwrap_or([20.0 / f32::from(crate::space_mouse::FULL_SCALE); 2]);+ let enabled = app.preferences.space_mouse_enabled;+ let preferences = &mut app.preferences;+ let source = &mut preferences.space_mouse_axis_source;+ let reverse = preferences.space_mouse_reverse.get_mut(axis);+ let speed = preferences.space_mouse_axis_speed.get_mut(axis);+ ui_kit::settings_axis_row(+ ui,+ name,+ value,+ zone,+ |ui| {+ ui.add_enabled_ui(enabled && !off, |ui| {+ if let Some(reverse) = reverse {+ ui_kit::checkbox(ui, crate::i18n::tr_label("Invert"), reverse);+ }+ });+ },+ |ui| {+ ui.add_enabled_ui(enabled && !off, |ui| {+ if let Some(speed) = speed {+ ui_kit::settings_axis_gain(ui, speed);+ }+ });+ },+ |ui| {+ ui.add_enabled_ui(enabled, |ui| {+ let current = source.get(axis).copied().unwrap_or(axis);+ let mut chosen = current;+ ui_kit::dropdown_menu(ui, ("sc_space_mouse_source", axis), motions.get(current).map_or("", String::as_str), |ui| {+ for (from, name) in motions.iter().enumerate() {+ if ui_kit::list_picker(ui, name, name, chosen == from).clicked() {+ chosen = from;+ }+ }+ })+ .on_hover_text(if *off { &off_tip } else { &driven_by });+ if chosen != current {+ crate::space_mouse::reassign(source, axis, chosen);+ }+ });+ },+ );+ });+ }+ ui_kit::settings_form(ui, 100.0, |ui| {+ ui_kit::row(ui, app.tr("prefs.overall_speed"), |ui| {+ ui.add_enabled_ui(app.preferences.space_mouse_enabled, |ui| {+ ui_kit::slider(+ ui,+ &mut app.preferences.space_mouse_speed,+ 0.25..=3.0,+ ui_kit::Slider { step: Some(0.05), format: |value| format!("{value:.2}×"), ..Default::default() },+ );+ });+ });+ });+ ui_kit::text(ui, app.tr("prefs.dead_zone_note"), ui_kit::Text::Hint("space_mouse_zone"));+ // Only where the reader has seen the choice: Linux, with spacenavd and the device both there.+ if let Some(present) = app.space_mouse.drivers.filter(|present| present.spacenavd || present.direct) {+ let [label, auto, direct, only_spacenavd, only_direct] =+ ["driver", "driver_auto", "driver_direct", "driver_only_spacenavd", "driver_only_direct"]+ .map(|key| app.tr(&format!("ui.space_mouse_{key}")).to_owned());+ let driver = &mut app.preferences.space_mouse_driver;+ ui_kit::row(ui, &label, |ui| match (present.spacenavd, present.direct) {+ (true, true) => {+ let name = |driver| match driver {+ SpaceMouseDriver::Automatic => auto.as_str(),+ SpaceMouseDriver::Spacenavd => "spacenavd",+ SpaceMouseDriver::Direct => direct.as_str(),+ };+ ui_kit::dropdown_menu(ui, "sc_space_mouse_driver", name(*driver), |ui| {+ for choice in SpaceMouseDriver::ALL {+ if ui_kit::list_picker(ui, name(choice), name(choice), *driver == choice).clicked() {+ *driver = choice;+ }+ }+ });+ }+ (true, false) => {+ ui_kit::text(ui, &only_spacenavd, ui_kit::Text::Hint("space_mouse_driver"));+ }+ (false, _) => {+ ui_kit::text(ui, &only_direct, ui_kit::Text::Hint("space_mouse_driver"));+ }+ });+ }+ ui.horizontal_wrapped(|ui| {+ let device = app.space_mouse.device.clone();+ let saved = device.as_ref().is_some_and(|device| app.preferences.space_mouse_calibrations.contains_key(device));+ ui.add_enabled_ui(app.preferences.space_mouse_enabled && device.is_some(), |ui| {+ if ui_kit::button(ui, app.tr("ui.space_mouse_calibrate"), ui_kit::Button::Normal)+ .on_hover_text(app.tr("ui.space_mouse_calibrate_tip"))+ .clicked()+ {+ crate::space_mouse_calibration::start(app);+ }+ });+ ui.add_enabled_ui(app.preferences.space_mouse_enabled && saved, |ui| {+ if ui_kit::button(ui, app.tr("ui.space_mouse_forget"), ui_kit::Button::Ghost).clicked()+ && let Some(device) = &device+ {+ app.preferences.space_mouse_calibrations.remove(device);+ }+ });+ let reassigned = app.preferences.space_mouse_axis_source != crate::space_mouse::SAME_AXES;+ ui.add_enabled_ui(app.preferences.space_mouse_enabled && reassigned, |ui| {+ if ui_kit::button(ui, app.tr("ui.space_mouse_reset_axes"), ui_kit::Button::Ghost).clicked() {+ app.preferences.space_mouse_axis_source = crate::space_mouse::SAME_AXES;+ }+ });+ });+ let enabled = app.preferences.space_mouse_enabled;+ let (label, tip) = (app.tr("ui.space_mouse_dead_zone").to_owned(), app.tr("ui.space_mouse_dead_zone_tip").to_owned());+ let (device, raw) = (app.space_mouse.device.clone(), app.space_mouse.raw.into());+ if let Some(calibration) = device.and_then(|device| app.preferences.space_mouse_calibrations.get_mut(&device)) {+ ui_kit::row(ui, &label, |ui| {+ ui.add_enabled_ui(enabled, |ui| {+ ui_kit::slider(+ ui,+ &mut calibration.dead_zone_share,+ 0.0..=solidcraft_space_mouse::MAX_DEAD_ZONE_SHARE,+ ui_kit::Slider { step: Some(0.01), format: |v| format!("{:.0} %", v * 100.0), ..Default::default() },+ )+ .on_hover_text(tip);+ });+ });+ crate::space_mouse_calibration::dead_zone_pads(ui, calibration, raw);+ }+ ui_kit::text(+ ui,+ crate::i18n::tr_label("Move and rotate the view together; sketches use pan and zoom only."),+ ui_kit::Text::Hint("space_mouse"),+ );+ });+}diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rsnew file mode 100644index 0000000000..67cd1ec4ac--- /dev/null+++ b/crates/ui-egui/src/prefs/sketch.rs@@ -0,0 +1,44 @@+//! Sketch and selection preferences with their live modifier legend.+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_section(ui, "sketch", app.tr("prefs.sketching"), |ui| {+ let mut auto = app.session.auto_project;+ if ui_kit::checkbox(ui, crate::i18n::tr_label("Project face edges into new sketches"), &mut auto).changed() {+ let _ = app.run("sketch.auto_project", json!({"value": auto}));+ }+ ui_kit::settings_block_hint(ui, app.tr("prefs.hold_stop_snapping"), app.tr("prefs.snap_drawing_note"), t.space_24 * 8.0 + t.space_8, |ui| {+ let combo = &mut app.preferences.suppress_sketch_snap;+ ui_kit::settings_control_width(ui, t.space_24 * 7.0 + t.space_12, |ui| {+ ui_kit::dropdown_menu(ui, "pref_suppress_sketch_snap", &combo.label(), |ui| {+ for choice in ModifierCombo::SNAP_SUPPRESS_CHOICES {+ if ui_kit::list_picker(ui, &choice.label(), &choice.label(), *combo == choice).clicked() {+ *combo = choice;+ }+ }+ });+ });+ });+ ui_kit::checkbox(ui, app.tr("prefs.alt_frees_manipulators"), &mut app.preferences.manipulator_free_alt).on_hover_text(crate::i18n::tr_label(+ "On: Alt/Option or Ctrl/Cmd on extrude / gizmo arrows disables value snapping. Off: Ctrl/Cmd only.",+ ));+ });+ ui_kit::settings_section(ui, "selection", app.tr("prefs.selecting"), |ui| {+ ui_kit::checkbox(ui, crate::i18n::tr_label("Click selects whole bodies"), &mut app.ui.pick_bodies);+ let click = app.tr("prefs.click");+ let shift = app.tr("prefs.shift");+ let ctrl = app.tr("prefs.ctrl_cmd");+ let one = app.tr("prefs.select_one_item");+ let toggle = app.tr("prefs.toggle_item");+ let add = app.tr("prefs.add_item");+ ui_kit::settings_bindings(+ ui,+ &[(&[click], one), (&[shift, click], if app.preferences.selection_shift_add_only { add } else { toggle }), (&[ctrl, click], toggle)],+ );+ ui_kit::checkbox(ui, app.tr("prefs.shift_add_ctrl_toggle"), &mut app.preferences.selection_shift_add_only)+ .on_hover_text(crate::i18n::tr_label("On: Shift adds items, Ctrl/Cmd toggles. Off (default): Shift and Ctrl/Cmd both toggle."));+ ui_kit::text(ui, app.tr("prefs.shift_add_note"), ui_kit::Text::Hint("selection_modifiers"));+ });+}diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rsindex e11dc3dfdf..2ea1fd301a 100644--- a/crates/ui-egui/src/shell_tests.rs+++ b/crates/ui-egui/src/shell_tests.rs@@ -534,8 +534,9 @@ 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":"General"}));- h.step(&json!({"click":{"handle":"dialog:Workspace layout:Compact"}})).unwrap();+ h.call("ui.prefs", json!({"open":"Interface"}));+ 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"}));h.settle();assert!(h.app.dialog.is_some(), "changing layout keeps the active tool");@@ -550,15 +551,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":"General","layout":"floating"}));+ h.call("ui.prefs", json!({"open":"Interface","layout":"floating"}));h.call("ui.prefs", json!({"button":"cancel"}));assert_eq!(h.app.ui.layout, LayoutMode::Docked);- h.call("ui.prefs", json!({"open":"General","layout":"floating"}));+ h.call("ui.prefs", json!({"open":"Interface","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":"General","layout":"compact"}));+ h.call("ui.prefs", json!({"open":"Interface","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);@@ -655,7 +656,7 @@ fn ribbon_labels_are_saved_independently_and_icon_only_commands_remain_reachablerestored.load_prefs(&h.app.prefs());assert!(!restored.preferences.ribbon_labels);assert_eq!(restored.ui.layout, mode);- h.call("ui.prefs", json!({"open":"General","ribbon_labels":true}));+ h.call("ui.prefs", json!({"open":"Interface","ribbon_labels":true}));h.call("ui.prefs", json!({"button":"cancel"}));assert!(!h.app.preferences.ribbon_labels);}diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rsindex 01c91e31e0..33a37e29f3 100644--- a/crates/ui-egui/src/ui_kit/actions.rs+++ b/crates/ui-egui/src/ui_kit/actions.rs@@ -29,7 +29,16 @@ pub(crate) fn icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &icon_button_colored(ui, rect, icon, label, None)}+/// Quiet secondary action: a small, muted glyph with the normal full-size hit target.+pub(crate) fn quiet_icon_button_at(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str) -> Response {+ icon_button_presentation(ui, rect, icon, label, None, true)+}+pub(super) fn icon_button_colored(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str, ink: Option<egui::Color32>) -> Response {+ icon_button_presentation(ui, rect, icon, label, ink, false)+}++fn icon_button_presentation(ui: &mut Ui, rect: egui::Rect, icon: &str, label: &str, ink: Option<egui::Color32>, quiet: bool) -> Response {let t = Tokens::get();let response = ui.interact(rect, ui.make_persistent_id(("icon_button", icon, label)), egui::Sense::click());if response.clicked() {@@ -40,9 +49,15 @@ pub(super) fn icon_button_colored(ui: &mut Ui, rect: egui::Rect, icon: &str, lab}crate::icons::paint_ink(ui.painter(),- rect.shrink(t.form_icon_inset),+ if quiet { egui::Rect::from_center_size(rect.center(), vec2(t.space_12, t.space_12)) } else { rect.shrink(t.form_icon_inset) },icon,- ink.unwrap_or(if response.hovered() || response.has_focus() { t.form_ink } else { t.form_dim }),+ ink.unwrap_or(if response.hovered() || response.has_focus() {+ t.form_ink+ } else if quiet {+ t.form_dim.lerp_to_gamma(t.control_fill, 0.35)+ } else {+ t.form_dim+ }),);response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), crate::i18n::tr_label(label)));pointer_on_hover(ui, &response);@@ -256,6 +271,8 @@ pub enum Button {Primary,Small,Enabled(bool),+ Ghost,+ SmallSelected,}fn button_widget(label: egui::WidgetText, options: Button) -> egui::Button<'static> {@@ -266,6 +283,10 @@ fn button_widget(label: egui::WidgetText, options: Button) -> egui::Button<'statlet ink = if crate::theme::contrast_ratio(t.on_accent, t.form_primary) >= 4.5 { t.on_accent } else { t.tab_on_fill_dark };egui::Button::new(label.color(ink)).fill(t.form_primary)}+ Button::Ghost => egui::Button::new(label).frame(false),+ Button::SmallSelected => {+ egui::Button::new(label.color(t.selected_ink)).small().fill(t.selected_bg).stroke(egui::Stroke::new(1.0, t.form_primary))+ }_ => egui::Button::new(label),}}diff --git a/crates/ui-egui/src/ui_kit/choice.rs b/crates/ui-egui/src/ui_kit/choice.rsindex ef9036e3f6..a3bc35a7b5 100644--- a/crates/ui-egui/src/ui_kit/choice.rs+++ b/crates/ui-egui/src/ui_kit/choice.rs@@ -15,10 +15,12 @@ pub(crate) struct Segments<'a> {pub states: &'a [bool],pub compact: bool,pub primary: bool,+ pub intrinsic: bool,+ pub proportional: bool,}pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], config: Segments<'_>) -> bool {- let Segments { states, compact, primary } = config;+ let Segments { states, compact, primary, intrinsic, proportional } = config;let t = Tokens::get();let segment_width = dimension(ui.available_width()) / options.len().max(1) as f32;let widest = options@@ -27,18 +29,30 @@ pub(crate) fn segmented(ui: &mut Ui, selected: &mut usize, options: &[&str], conui.painter().layout_no_wrap(crate::i18n::tr_label(option).to_string(), crate::fonts::semibold(t.font_label), t.form_ink).size().x}).fold(0.0, f32::max);- if !compact && widest + 2.0 * t.space_8 > segment_width {+ if !intrinsic && !proportional && !compact && widest + 2.0 * t.space_8 > segment_width {let before = *selected;let id = format!("segments_fallback_{}", label(ui));dropdown(ui, &id, selected, options);return *selected != before;}- let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), row_height()), egui::Sense::hover());+ let natural: Vec<_> = options+ .iter()+ .map(|option| {+ ui.painter().layout_no_wrap((*option).to_owned(), crate::fonts::semibold(t.font_label), t.form_ink).size().x.ceil() + t.space_16+ })+ .collect();+ let total = natural.iter().sum::<f32>();+ let desired = if intrinsic { total.min(dimension(ui.available_width())) } else { dimension(ui.available_width()) };+ let (rect, _) = ui.allocate_exact_size(vec2(desired, row_height()), egui::Sense::hover());ui.painter().rect_filled(rect, t.control_radius, t.control_fill);- let width = rect.width() / options.len().max(1) as f32;+ let equal_width = rect.width() / options.len().max(1) as f32;let mut clicked = false;+ let mut x = rect.left();for (index, option) in options.iter().enumerate() {- let segment = egui::Rect::from_min_size(rect.min + vec2(index as f32 * width, 0.0), vec2(width, rect.height()));+ let width =+ if (intrinsic || proportional) && total > 0.0 { natural.get(index).copied().unwrap_or(0.0) * rect.width() / total } else { equal_width };+ let segment = egui::Rect::from_min_size(egui::pos2(x, rect.top()), vec2(width, rect.height()));+ x += width;let response = ui.interact(segment, ui.make_persistent_id(("segment", index)), egui::Sense::click());let on = states.get(index).copied().unwrap_or(*selected == index);let rounding = egui::CornerRadius {diff --git a/crates/ui-egui/src/ui_kit/gallery.rs b/crates/ui-egui/src/ui_kit/gallery.rsindex 03e4db8610..fde92bbe3c 100644--- a/crates/ui-egui/src/ui_kit/gallery.rs+++ b/crates/ui-egui/src/ui_kit/gallery.rs@@ -29,6 +29,95 @@ macro_rules! element {// One entry per element/variant: names, rendering and geometry expectations stay together.const ELEMENTS: &[Element] = &[+ element!("settings_form", |ui, state| {+ settings_form(ui, Tokens::get().form_label_width, |ui| {+ row(ui, "Sample", |ui| {+ field(ui, &mut state.value);+ });+ });+ }),+ element!("settings_composition", |ui, _| {+ settings_heading(ui, "Interface", "Appearance and workspace");+ settings_section(ui, "gallery_settings", "Layout", |ui| {+ settings_pair(+ ui,+ |ui| {+ text(ui, "Controls", Text::Inline);+ },+ |ui, ()| layout_preview(ui, LayoutPreview { compact: true, labels: false, history: 2, translucent: false }),+ )+ });+ }),+ element!("settings_permission_choices", |ui, state| {+ settings_choices(+ ui,+ &[+ SettingsChoice {+ key: "gallery:ask",+ title: "Ask first",+ summary: "Confirm changes before they run.",+ detail: "Full permission details",+ },+ SettingsChoice {+ key: "gallery:edits",+ title: "Allow edits",+ summary: "Ask before running other tools.",+ detail: "Full permission details",+ },+ SettingsChoice {+ key: "gallery:all",+ title: "Allow all",+ summary: "Run supported tools without asking.",+ detail: "Full permission details",+ },+ ],+ &mut state.selected,+ );+ settings_pointer_preview(ui, true, "Normal", true);+ }),+ element!("preference_theme_rail", |ui, _| {+ theme_rail(+ ui,+ |ui| {+ for label in ["Light", "Dark", "System"] {+ option_card(+ ui,+ label,+ Some("Built in"),+ label == "Light",+ true,+ PreferenceFigure::Theme { palette: Tokens::light().into(), system: label == "System" },+ );+ }+ },+ |ui| {+ theme_import_tile(ui, "Import…", "theme file");+ },+ );+ }),+ element!("preference_option_cards", |ui, _| {+ ui.horizontal_wrapped(|ui| {+ for figure in [+ PreferenceFigure::Theme { palette: Tokens::light().into(), system: true },+ PreferenceFigure::Pivot(2),+ PreferenceFigure::Quality(24),+ PreferenceFigure::Antialiasing(8),+ PreferenceFigure::ContactShading(true),+ PreferenceFigure::UpAxis(true),+ ] {+ option_card(ui, "Choice", Some("Example"), true, true, figure);+ }+ });+ }),+ element!("preference_specimens", |ui, _| {+ tab_accent_strip(ui);+ scale_specimen(ui, 1.1);+ status_palette_sample(ui, crate::theme::ColorVision::Deutan);+ colour_vision_sample(ui, &Tokens::get());+ settings_autosave_timeline(ui, 5.0);+ settings_axis_row(ui, "Push X", 0.6, [0.1, 0.2], |_| {}, |_| {}, |_| {});+ settings_mouse_mapping(ui, &[(vec!["Shift".into(), "Middle drag".into()], "Orbit".into())], |_| {});+ }),element!("assistant_entry", |ui, _| {let t = Tokens::get();egui::Frame::NONE.fill(t.app_bar).show(ui, |ui| {@@ -344,6 +433,7 @@ const ELEMENTS: &[Element] = &[ui,&mut s.selected,&[WindowPage {+ group: Some("prefs.input"),icon: "settings",label: "ui.general",handle: "gallery:page",@@ -878,6 +968,10 @@ const ELEMENTS: &[Element] = &[let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());icon_button_at(ui, rect, "close", "Close");}),+ element!("quiet_icon_button_at", |ui, _| {+ let (rect, _) = ui.allocate_exact_size(vec2(row_height(), row_height()), egui::Sense::hover());+ quiet_icon_button_at(ui, rect, "plus", "Add shortcut");+ }),element!("keyboard", |ui, _| {assert_eq!(keyboard(ui.ctx(), true), Action::None);ui.allocate_space(vec2(row_height(), row_height()));diff --git a/crates/ui-egui/src/ui_kit/layout.rs b/crates/ui-egui/src/ui_kit/layout.rsindex 6612d767ce..677bfdb24e 100644--- a/crates/ui-egui/src/ui_kit/layout.rs+++ b/crates/ui-egui/src/ui_kit/layout.rs@@ -6,6 +6,13 @@ use egui::{Response, RichText, Ui, vec2};pub(super) const FORM: &str = "sc_dense_form";pub(super) const LABEL: &str = "sc_form_label";+pub(super) const FIXED_LABEL: &str = "sc_fixed_label_width";++/// A deliberate label grid for multi-column settings, inherited by the existing shared rows.+pub(crate) fn settings_form<R>(ui: &mut Ui, label_width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {+ ui.scope_builder(egui::UiBuilder::new().ui_stack_info(egui::UiStackInfo::default().with_tag_value(FIXED_LABEL, dimension(label_width))), add)+ .inner+}/// Mark a form without global state: children inherit this tag through their UI stack./// Inherited form styling and label-column identity. Tokens: `space_4/8, form_gap_y, control_height, font_label, accent, selected_bg, dialog_rule, control_fill/border/radius, text`.@@ -86,7 +93,7 @@ pub(super) fn sized_row<R>(ui: &mut Ui, text: &str, height: f32, control: impl Fui.add(egui::Label::new(RichText::new(crate::i18n::tr_label(text)).size(t.font_label).color(t.dialog_label)).truncate()).on_hover_text(crate::i18n::tr_label(text));});- let control_rect = egui::Rect::from_min_max(egui::pos2((label_rect.right() + label_gap(width)).min(rect.right()), rect.top()), rect.max);+ let control_rect = egui::Rect::from_min_max(egui::pos2((label_rect.right() + label_gap(ui, width)).min(rect.right()), rect.top()), rect.max);let result = ui.scope_builder(egui::UiBuilder::new()@@ -115,7 +122,7 @@ pub(crate) fn caption(ui: &mut Ui, aligned_to: &str, text: &str) {let t = Tokens::get();let width = dimension(ui.available_width());let (rect, _) = ui.allocate_exact_size(vec2(width, t.form_icon_size), egui::Sense::hover());- let left = (rect.left() + label_column(ui, aligned_to, width) + label_gap(width)).min(rect.right());+ let left = (rect.left() + label_column(ui, aligned_to, width) + label_gap(ui, width)).min(rect.right());let text_rect = egui::Rect::from_min_max(egui::pos2(left, rect.top()), rect.max);paint_text(ui, text_rect, text, egui::FontId::proportional(t.font_small), t.form_dim, false);scenario::publish_rect(&format!("dialog:caption:{aligned_to}"), text_rect);@@ -154,7 +161,14 @@ pub(crate) fn section_count<R>(let badge_value = count.map(|count| count.to_string());let badge_width = badge_value.as_ref().map_or(0.0, |value| label_width(ui, value) + t.space_12);let reserved = if badge_value.is_some() { badge_width + t.space_12 } else { 0.0 };- let title_width = label_width(ui, &caption).min((text_rect.width() - reserved).max(0.0));+ let mut format = egui::TextFormat::simple(crate::fonts::semibold(t.font_caption), t.form_dim);+ format.extra_letter_spacing = t.font_caption * t.font_section_tracking;+ let title_width = ui+ .fonts_mut(|fonts| fonts.layout_job(egui::text::LayoutJob::single_section(caption.clone(), format)))+ .size()+ .x+ .ceil()+ .min((text_rect.width() - reserved).max(0.0));let title_rect = egui::Rect::from_min_max(text_rect.min, egui::pos2(text_rect.left() + title_width, text_rect.bottom()));paint_text(ui, title_rect, &caption, crate::fonts::semibold(t.font_caption), t.form_dim, true);let mut rule_left = title_rect.right() + t.space_12;diff --git a/crates/ui-egui/src/ui_kit/metrics.rs b/crates/ui-egui/src/ui_kit/metrics.rsindex 649500e648..3d2b3ab6bd 100644--- a/crates/ui-egui/src/ui_kit/metrics.rs+++ b/crates/ui-egui/src/ui_kit/metrics.rs@@ -72,6 +72,9 @@ pub(super) fn header_column(ui: &Ui, text: &str) -> f32 {/// two frames and shrinks again when the long rows go away./// Shared label width, capped at 1.6x. Tokens: `form_label_width, font_label, dialog_label, space_4`.pub(super) fn label_column(ui: &Ui, text: &str, row_width: f32) -> f32 {+ if let Some(width) = ui.stack().iter().find_map(|node| node.tags().get_downcast::<f32>(super::layout::FIXED_LABEL)) {+ return width.min(row_width * 0.6);+ }let t = Tokens::get();// Wide manager cards use the approved 104 pt label column; compact cards retain room// for their existing controls. Both sizes derive from the same form/spacing tokens.@@ -108,7 +111,13 @@ pub(crate) fn table_row_height() -> f32 {}/// Label/control gutter for the same responsive form grid as label_column.-pub(super) fn label_gap(width: f32) -> f32 {+pub(super) fn label_gap(ui: &Ui, width: f32) -> f32 {let t = Tokens::get();- if width >= t.form_card_width + t.space_24 * 2.0 { t.space_10 } else { t.space_8 }+ if ui.stack().iter().any(|node| node.tags().contains(super::layout::FIXED_LABEL)) {+ t.space_14+ } else if width >= t.form_card_width + t.space_24 * 2.0 {+ t.space_10+ } else {+ t.space_8+ }}diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rsindex c1e5eadddd..4e5a0c7223 100644--- a/crates/ui-egui/src/ui_kit/mod.rs+++ b/crates/ui-egui/src/ui_kit/mod.rs@@ -17,9 +17,15 @@ mod layout;mod menu;mod metrics;pub(crate) mod panel;+mod preferences;+mod preferences_assistant;+mod preferences_figures;+mod preferences_navigation;+mod preferences_small;mod radial;mod reports;mod search;+mod shortcuts;mod status;mod table;mod text;@@ -45,9 +51,14 @@ pub use panel::Window;pub(crate) use panel::{ComputeStatus, FeatureOptions, Panel, Part, WindowPage, panel_header_hover};#[cfg(test)]pub(crate) use panel::{collapsible_header, header};+pub(crate) use preferences::*;+pub(crate) use preferences_assistant::*;+pub(crate) use preferences_navigation::*;+pub(crate) use preferences_small::*;pub(crate) use radial::{RADIAL_RADIUS, radial_menu};pub(crate) use reports::*;pub(crate) use search::{CommandSearch, SearchBadge, SearchFieldGeometry};+pub(crate) use shortcuts::*;pub(crate) use status::*;pub(crate) use table::*;diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rsindex d349125935..f8f20e8dae 100644--- a/crates/ui-egui/src/ui_kit/panel.rs+++ b/crates/ui-egui/src/ui_kit/panel.rs@@ -381,6 +381,8 @@ pub struct Window<'a> {closeable: bool,width: f32,body_padding: bool,+ page_rows: f32,+ page_padding: egui::Vec2,left_slot: bool,}@@ -401,6 +403,8 @@ impl<'a> Window<'a> {closeable: true,width: Tokens::get().form_card_width * 1.5,body_padding: true,+ page_rows: 16.0,+ page_padding: vec2(Tokens::get().space_16, Tokens::get().space_16),left_slot: false,}}@@ -446,6 +450,22 @@ impl<'a> Window<'a> {self}+ /// Maximum page-body height in control rows, still bounded by the viewport.+ pub(crate) fn page_rows(mut self, rows: f32) -> Self {+ if rows.is_finite() {+ self.page_rows = rows.clamp(1.0, 32.0);+ }+ self+ }++ /// Content inset for a page-based window, independent of its navigation rail.+ pub(crate) fn page_padding(mut self, padding: egui::Vec2) -> Self {+ if padding.is_finite() {+ self.page_padding = padding.max(egui::Vec2::ZERO);+ }+ self+ }+/// A required choice, such as web recovery, has no dismiss action. Existing data remains/// pending until the body explicitly handles a choice.pub fn required(mut self) -> Self {@@ -524,7 +544,9 @@ impl<'a> Window<'a> {left: impl FnOnce(&mut Ui),) -> (bool, super::Action) {self.body_padding = false;- self.show_with_left(ctx, true, |ui| page_list(ui, selected, pages, state), left)+ 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), left)}/// The same bounded card frame, either movable or an input-blocking modal.@@ -573,15 +595,21 @@ impl<'a> Window<'a> {pub(crate) struct WindowPage<S> {pub icon: &'static str,pub label: &'static str,+ pub group: Option<&'static str>,pub handle: &'static str,pub scroll: bool,pub draw: fn(&mut Ui, &mut S),}+#[cfg(test)]pub(super) fn page_list<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPage<S>], state: &mut S) {+ page_list_sized(ui, selected, pages, state, 16.0, vec2(Tokens::get().space_16, Tokens::get().space_16));+}++fn page_list_sized<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPage<S>], state: &mut S, rows: f32, padding: egui::Vec2) {let t = Tokens::get();let height = (dimension(ui.ctx().content_rect().height()) - t.form_header_height - t.form_footer_height - t.space_24 * 3.0)- .clamp(0.0, t.control_height * 16.0);+ .clamp(0.0, t.control_height * rows);let (body, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), height), egui::Sense::hover());let width = (t.form_label_width * 2.0 + t.space_24 * 2.0).min(body.width());let nav = egui::Rect::from_min_size(body.min, vec2(width, body.height()));@@ -589,11 +617,17 @@ pub(super) fn page_list<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPagui.painter().vline(nav.right(), nav.y_range(), egui::Stroke::new(1.0, 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_10))), |ui| {+ ui.scope_builder(egui::UiBuilder::new().max_rect(nav.shrink2(vec2(t.space_8, t.space_6))), |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| {for (index, page) in pages.iter().enumerate() {+ if let Some(group) = page.group {+ ui.add_space(t.space_8);+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24), egui::Sense::hover());+ let rect = rect.shrink2(vec2(t.space_10, 0.0));+ paint_text(ui, rect, &crate::i18n::tr(group).to_uppercase(), crate::fonts::semibold(t.font_small), t.form_dim, true);+ }let label = crate::i18n::tr(page.label);let (rect, response) =ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.control_height + t.space_4), egui::Sense::click());@@ -627,23 +661,26 @@ pub(super) fn page_list<S>(ui: &mut Ui, selected: &mut usize, pages: &[WindowPag});});let content = egui::Rect::from_min_max(egui::pos2(nav.right(), body.top()), body.max);- let content = content.shrink2(vec2(t.space_16.min(content.width() / 2.0), t.space_16.min(content.height() / 2.0)));- ui.scope_builder(egui::UiBuilder::new().max_rect(content), |ui| {- ui.set_clip_rect(ui.clip_rect().intersect(content));- ui.spacing_mut().item_spacing.y = t.form_gap_y;- if let Some(page) = pages.get(*selected) {- if page.scroll {- let scroll = egui::ScrollArea::vertical()- .id_salt(("sc_prefs_page", *selected))- .auto_shrink([false, false])- .show(ui, |ui| (page.draw)(ui, state));- scenario::publish_rect("dialog:page_body", scroll.inner_rect);- } else {- (page.draw)(ui, state);- scenario::publish_rect("dialog:page_body", content);+ let content = content.shrink2(vec2(padding.x.min(content.width() / 2.0), padding.y.min(content.height() / 2.0)));+ ui.scope_builder(+ egui::UiBuilder::new()+ .max_rect(content)+ .ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::preferences::PAGE_SCROLL_GUTTER, padding.x)),+ |ui| {+ let clip = egui::Rect::from_min_max(content.min, egui::pos2(body.right(), content.bottom()));+ ui.set_clip_rect(ui.clip_rect().intersect(clip));+ ui.spacing_mut().item_spacing.y = t.form_gap_y;+ if let Some(page) = pages.get(*selected) {+ if page.scroll {+ let scroll = super::settings_scroll(ui, ("sc_prefs_page", *selected), |ui| (page.draw)(ui, state));+ scenario::publish_rect("dialog:page_body", scroll.inner_rect);+ } else {+ (page.draw)(ui, state);+ scenario::publish_rect("dialog:page_body", content);+ }}- }- });+ },+ );}#[cfg(test)]diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rsindex 4f899c0109..35d4a67054 100644--- a/crates/ui-egui/src/ui_kit/panel_tests.rs+++ b/crates/ui-egui/src/ui_kit/panel_tests.rs@@ -310,6 +310,7 @@ fn window_pages_have_shared_metrics_callbacks_and_a_pinned_left_footer_action()let mut drawn = 0;let pages = [WindowPage {+ group: None,icon: "settings",label: "ui.general",handle: "test:page:general",@@ -320,6 +321,7 @@ fn window_pages_have_shared_metrics_callbacks_and_a_pinned_left_footer_action()},},WindowPage {+ group: None,icon: "orbit",label: "ui.navigation",handle: "test:page:navigation",diff --git a/crates/ui-egui/src/ui_kit/preferences.rs b/crates/ui-egui/src/ui_kit/preferences.rsnew file mode 100644index 0000000000..a3f920d72c--- /dev/null+++ b/crates/ui-egui/src/ui_kit/preferences.rs@@ -0,0 +1,647 @@+//! Shared preference compositions and explanatory figures. Figures are cheap painter content,+//! never additional application viewports; every colour and control metric comes from tokens.+use super::{metrics::dimension, text::paint_text};+use crate::{+ scenario,+ theme::{ColorVision, Tokens},+};+use egui::{Color32, FontId, Pos2, Rect, Response, Sense, Stroke, Ui, pos2, vec2};++pub(super) const PAGE_SCROLL_GUTTER: &str = "sc_page_scroll_gutter";++/// Page scroller keeps content aligned while centring its bar in the window's right inset.+/// Nested pages (including Shortcuts) inherit the same gutter and height contract.+pub(crate) fn settings_scroll<R>(ui: &mut Ui, id: impl egui::AsIdSalt, add: impl FnOnce(&mut Ui) -> R) -> egui::scroll_area::ScrollAreaOutput<R> {+ let t = Tokens::get();+ let gutter = ui.stack().iter().find_map(|node| node.tags().get_downcast::<f32>(PAGE_SCROLL_GUTTER)).copied().unwrap_or(0.0);+ let width = dimension(ui.available_width());+ let height = if ui.available_height().is_finite() { dimension(ui.available_height()) } else { t.control_height * 16.0 };+ let bar = ui.spacing().scroll.floating_width;+ let extension = if gutter > 0.0 { gutter / 2.0 + bar / 2.0 } else { 0.0 };+ let host = Rect::from_min_size(ui.next_widget_position(), vec2(width + extension, height));+ ui.scope_builder(egui::UiBuilder::new().max_rect(host).layout(egui::Layout::top_down(egui::Align::Min)), |ui| {+ if gutter > 0.0 {+ let scroll = &mut ui.style_mut().spacing.scroll;+ scroll.floating = true;+ scroll.floating_allocated_width = 0.0;+ scroll.bar_outer_margin = 0.0;+ }+ egui::ScrollArea::vertical().id_salt(id).max_height(height).auto_shrink([false, false]).show(ui, |ui| {+ if gutter > 0.0 {+ ui.set_width(width);+ }+ add(ui)+ })+ })+ .inner+}++pub(crate) fn settings_heading(ui: &mut Ui, title: &str, description: &str) {+ let t = Tokens::get();+ ui.scope(|ui| {+ ui.spacing_mut().item_spacing.y = t.space_3;+ 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);+ super::text(ui, description, super::Text::Hint("settings_heading"));+ });+}++/// Settings reuse the same disclosure, uppercase typography and rule as the design system.+pub(crate) fn settings_section<R>(ui: &mut Ui, key: &str, title: &str, add: impl FnOnce(&mut Ui) -> R) -> Option<R> {+ let t = Tokens::get();+ ui.add_space(t.space_8);+ super::section(ui, key, title, true, |ui| {+ if let Some(rect) = scenario::rect_of(&format!("dialog:section:{title}")) {+ scenario::publish_rect(&format!("prefs:section:{key}"), rect);+ }+ ui.spacing_mut().item_spacing.y = t.space_8;+ add(ui)+ })+}++/// Only the four palette roles needed by a swatch, avoiding a copy of the full theme.+#[derive(Clone, Copy)]+pub(crate) struct ThemeSwatch {+ background: Color32,+ panel: Color32,+ accent: Color32,+ dim: Color32,+}+impl From<Tokens> for ThemeSwatch {+ fn from(t: Tokens) -> Self {+ Self { background: t.viewport_top, panel: t.panel, accent: t.accent, dim: t.text_dim }+ }+}++/// Controls and one explanatory specimen side by side, stacked on narrow viewports.+pub(crate) fn settings_pair<R>(ui: &mut Ui, controls: impl FnOnce(&mut Ui) -> R, preview: impl FnOnce(&mut Ui, R)) {+ let t = Tokens::get();+ let preview_width = t.form_card_width - t.space_8;+ let gap = t.space_16 + t.space_4;+ let width = dimension(ui.available_width());+ if width < preview_width * 2.0 + gap {+ let state = controls(ui);+ preview(ui, state);+ } else {+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = gap;+ let state = ui+ .allocate_ui_with_layout(vec2(width - preview_width - gap, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ ui.spacing_mut().item_spacing.x = t.space_6;+ controls(ui)+ })+ .inner;+ ui.allocate_ui_with_layout(vec2(preview_width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| preview(ui, state));+ });+ }+}++/// A horizontally scrollable, draggable tile rail with its import action pinned outside it.+/// The hidden scrollbar never reserves vertical space; a vertical wheel also moves the rail.+pub(crate) fn theme_rail(ui: &mut Ui, tiles: impl FnOnce(&mut Ui), import: impl FnOnce(&mut Ui)) {+ let t = Tokens::get();+ let action_width = t.form_label_width + t.space_24 + t.space_6;+ let rail_width = (dimension(ui.available_width()) - action_width - t.space_8).max(0.0);+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_8;+ ui.allocate_ui_with_layout(vec2(rail_width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ ui.style_mut().always_scroll_the_only_direction = true;+ egui::ScrollArea::horizontal()+ .id_salt("settings_theme_rail")+ .max_width(rail_width)+ .auto_shrink([false, true])+ .scroll_bar_visibility(egui::scroll_area::ScrollBarVisibility::AlwaysHidden)+ .scroll_source(egui::scroll_area::ScrollSource { drag: egui::scroll_area::DragScroll::Always, ..Default::default() })+ .show(ui, |ui| {+ ui.horizontal(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_8;+ tiles(ui);+ });+ });+ });+ ui.allocate_ui_with_layout(vec2(action_width, 0.0), egui::Layout::top_down(egui::Align::Min), import);+ });+}++/// Dashed import tile matches the swatch tiles, while remaining permanently visible.+pub(crate) fn theme_import_tile(ui: &mut Ui, label: &str, note: &str) -> Response {+ let t = Tokens::get();+ let width = t.form_label_width + t.space_24 + t.space_6;+ let height = t.control_height + t.space_6 * 2.0 + t.space_4 + t.space_16 * 2.0;+ let (r, response) = ui.allocate_exact_size(vec2(width.min(dimension(ui.available_width())), height), Sense::click());+ if response.hovered() {+ ui.painter().rect_filled(r, t.radius_lg, t.hover);+ }+ let mut outline = rounded_perimeter(r.shrink(t.space_2 / 2.0), f32::from(t.radius_lg));+ if let Some(first) = outline.first().copied() {+ outline.push(first);+ }+ ui.painter().extend(egui::Shape::dashed_line(&outline, Stroke::new(t.space_3 / 2.0, t.control_border), t.space_3, t.space_3));+ let icon = Rect::from_center_size(pos2(r.center().x, r.top() + t.space_16), vec2(t.space_16, t.space_16));+ crate::icons::paint_ink(ui.painter(), icon, "import_tray", t.form_dim);+ centred_text(+ ui.painter(),+ Rect::from_min_size(pos2(r.left(), r.top() + t.space_24 + t.space_4), vec2(r.width(), t.space_16)),+ label,+ FontId::proportional(t.font_label),+ t.form_dim,+ );+ centred_text(+ ui.painter(),+ Rect::from_min_size(pos2(r.left(), r.top() + t.space_24 + t.space_4 + t.space_16), vec2(r.width(), t.space_16)),+ note,+ FontId::proportional(t.font_small),+ t.form_dim,+ );+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), label));+ scenario::publish_target(&format!("dialog:{label}"), r);+ response.on_hover_cursor(egui::CursorIcon::PointingHand)+}++/// Compact informational state badge for settings; never an interactive control.+pub(crate) fn settings_badge(ui: &mut Ui, text: &str, warning: bool) {+ let t = Tokens::get();+ let ink =+ if warning { if crate::theme::contrast_ratio(t.warning, t.dialog_body) >= 4.5 { t.warning } else { t.form_ink } } else { t.form_success };+ let fill = if warning { t.warning.gamma_multiply(0.1) } else { t.form_success_fill };+ let galley = ui.painter().layout_no_wrap(text.to_owned(), crate::fonts::semibold(t.font_small), ink);+ let (r, _) = ui.allocate_exact_size(vec2(galley.size().x + t.space_16, t.space_24), Sense::hover());+ ui.painter().rect_filled(r, t.radius_xl, fill);+ ui.painter().galley(r.center() - galley.size() / 2.0, galley, ink);+}++#[derive(Clone, Copy)]+pub(crate) enum PreferenceFigure {+ Theme { palette: ThemeSwatch, system: bool },+ Pivot(usize),+ Quality(usize),+ Antialiasing(u32),+ ContactShading(bool),+ UpAxis(bool),+}++/// Reusable illustrated radio card. Width comes from the figure, and wrapping is owned by+/// the parent; labels remain accessible even when translations need an ellipsis.+pub(crate) fn option_card(ui: &mut Ui, label: &str, note: Option<&str>, selected: bool, enabled: bool, figure: PreferenceFigure) -> Response {+ let t = Tokens::get();+ let theme = matches!(figure, PreferenceFigure::Theme { .. });+ let width = match figure {+ PreferenceFigure::Theme { .. } => t.form_label_width + t.space_24 + t.space_6,+ PreferenceFigure::Antialiasing(_) => t.space_24 * 3.0 + t.space_16,+ _ => t.form_label_width + t.space_24 * 2.0 + t.space_6,+ };+ let preview_height = if theme {+ t.control_height+ } else if matches!(figure, PreferenceFigure::Antialiasing(_)) {+ t.space_24 * 3.0+ } else {+ t.space_24 * 3.0 + t.space_3+ };+ let label_height = if matches!(figure, PreferenceFigure::ContactShading(_)) { t.space_16 * 2.0 } else { t.space_16 };+ let height = preview_height + t.space_6 * 2.0 + t.space_4 + label_height + if note.is_some() { t.space_16 } else { 0.0 };+ let enabled = enabled && ui.is_enabled();+ let (rect, response) = ui.allocate_exact_size(+ vec2(if theme { width } else { width.min(dimension(ui.available_width())) }, height),+ if enabled { Sense::click() } else { Sense::hover() },+ );+ let hover = enabled && response.hovered();+ let ink = if !enabled {+ t.form_dim+ } else if selected {+ t.selected_ink+ } else {+ t.form_ink+ };+ ui.painter().rect(+ rect,+ t.radius_lg,+ if selected {+ t.selected_bg+ } else if hover {+ t.hover+ } else {+ t.control_fill+ },+ Stroke::new(if selected { 2.0 } else { 1.0 }, if selected { t.form_primary } else { t.control_border }),+ egui::StrokeKind::Inside,+ );+ let mut preview = Rect::from_min_size(rect.min + vec2(t.space_6, t.space_6), vec2((rect.width() - t.space_12).max(0.0), preview_height));+ if matches!(figure, PreferenceFigure::Antialiasing(_)) {+ preview = Rect::from_center_size(preview.center(), vec2(preview.height(), preview.height()));+ }+ paint_preference_figure(ui.painter(), preview, figure, enabled);+ let label_rect =+ Rect::from_min_size(pos2(rect.left() + t.space_4, preview.bottom() + t.space_4), vec2((rect.width() - t.space_8).max(0.0), label_height));+ centred_text_rows(+ ui.painter(),+ label_rect,+ label,+ if selected { crate::fonts::semibold(t.font_label) } else { FontId::proportional(t.font_label) },+ ink,+ if matches!(figure, PreferenceFigure::ContactShading(_)) { 2 } else { 1 },+ );+ if let Some(note) = note {+ centred_text(+ ui.painter(),+ Rect::from_min_size(pos2(label_rect.left(), label_rect.bottom()), vec2(label_rect.width(), t.space_16)),+ note,+ FontId::proportional(t.font_small),+ t.form_dim,+ );+ }+ if selected {+ let centre = pos2(rect.right() - t.space_6 - t.space_8, rect.top() + t.space_6 + t.space_8);+ ui.painter().circle_filled(centre, t.space_8, t.form_primary);+ let ink = t.on_accent;+ ui.painter().line_segment([centre + vec2(-t.space_4, 0.0), centre + vec2(-t.space_2, t.space_2)], Stroke::new(2.0, ink));+ ui.painter().line_segment([centre + vec2(-t.space_2, t.space_2), centre + vec2(t.space_4, -t.space_3)], Stroke::new(2.0, ink));+ }+ response.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::RadioButton, enabled, selected, label));+ scenario::publish_target(&format!("prefs:option:{label}"), rect);+ let response = response.on_hover_text(label);+ if enabled { response.on_hover_cursor(egui::CursorIcon::PointingHand) } else { response }+}++fn centred_text(p: &egui::Painter, rect: Rect, label: &str, font: FontId, ink: Color32) {+ centred_text_rows(p, rect, label, font, ink, 1);+}++fn centred_text_rows(p: &egui::Painter, rect: Rect, label: &str, font: FontId, ink: Color32, rows: usize) {+ let mut job = egui::text::LayoutJob::simple(label.to_owned(), font, ink, rect.width());+ job.wrap.max_rows = rows;+ job.halign = egui::Align::Center;+ let galley = p.layout_job(job);+ p.with_clip_rect(rect).galley(rect.center() - galley.rect.center().to_vec2(), galley, ink);+}++fn point(r: Rect, x: f32, y: f32) -> Pos2 {+ pos2(r.left() + r.width() * x, r.top() + r.height() * y)+}++fn paint_preference_figure(p: &egui::Painter, rect: Rect, figure: PreferenceFigure, enabled: bool) {+ if !p.clip_rect().intersects(rect) {+ return;+ }+ let t = Tokens::get();+ let p = p.with_clip_rect(rect);+ let alpha = if enabled { 1.0 } else { 0.4 };+ let accent = t.form_primary.gamma_multiply(alpha);+ if let PreferenceFigure::Theme { palette, system } = figure {+ theme_swatch(&p, rect, palette, false);+ if system {+ theme_swatch(&p, rect, Tokens::dark().into(), true);+ }+ return;+ }+ p.rect_filled(rect, t.control_radius, t.viewport_top);+ p.rect_stroke(rect, t.control_radius, Stroke::new(1.0, t.dialog_rule), egui::StrokeKind::Inside);+ match figure {+ PreferenceFigure::Theme { .. } => {}+ PreferenceFigure::Quality(sides) => {+ let n = sides.clamp(3, 96);+ let centre = rect.center();+ let radius = rect.height() * 0.34;+ let guide: Vec<_> = (0..=96)+ .map(|i| {+ let a = std::f32::consts::TAU * i as f32 / 96.0;+ centre + vec2(a.cos(), a.sin()) * radius+ })+ .collect();+ p.extend(egui::Shape::dashed_line(&guide, Stroke::new(1.0, t.control_border), t.space_2, t.space_3));+ let points = (0..n)+ .map(|i| {+ let a = std::f32::consts::TAU * i as f32 / n as f32;+ centre + vec2(a.cos(), a.sin()) * radius+ })+ .collect();+ p.add(egui::Shape::convex_polygon(points, accent.gamma_multiply(0.15), Stroke::new(1.5, accent)));+ }+ PreferenceFigure::Antialiasing(samples) => {+ let n = 10;+ let s = samples.clamp(1, 8);+ for y in 0..n {+ for x in 0..n {+ let mut covered = 0;+ for sy in 0..s {+ for sx in 0..s {+ let px = (x as f32 + (sx as f32 + 0.5) / s as f32) / n as f32;+ let py = (y as f32 + (sy as f32 + 0.5) / s as f32) / n as f32;+ if py > 0.3 + px * 0.35 {+ covered += 1;+ }+ }+ }+ let cell = Rect::from_min_max(+ point(rect, x as f32 / n as f32, y as f32 / n as f32),+ point(rect, (x + 1) as f32 / n as f32, (y + 1) as f32 / n as f32),+ );+ p.rect_filled(cell, 0, t.viewport_top.lerp_to_gamma(accent, covered as f32 / (s * s) as f32));+ }+ }+ }+ PreferenceFigure::UpAxis(y_up) => super::preferences_figures::paint_orientation(&p, rect, y_up),+ PreferenceFigure::Pivot(pivot) => super::preferences_figures::paint_orbit(&p, rect, pivot),+ PreferenceFigure::ContactShading(on) => super::preferences_figures::paint_contact_shading(&p, rect, on),+ }+}++/// Clockwise rounded boundary shared by dashed outlines and clipped palette specimens.+pub(super) fn rounded_perimeter(r: Rect, radius: f32) -> Vec<Pos2> {+ let radius = radius.min(r.width() / 2.0).min(r.height() / 2.0).max(0.0);+ let corners = [+ (pos2(r.right() - radius, r.top() + radius), -std::f32::consts::FRAC_PI_2),+ (pos2(r.right() - radius, r.bottom() - radius), 0.0),+ (pos2(r.left() + radius, r.bottom() - radius), std::f32::consts::FRAC_PI_2),+ (pos2(r.left() + radius, r.top() + radius), std::f32::consts::PI),+ ];+ corners+ .into_iter()+ .flat_map(|(centre, start)| {+ (0..=8).map(move |step| {+ let angle = start + std::f32::consts::FRAC_PI_2 * step as f32 / 8.0;+ centre + vec2(angle.cos(), angle.sin()) * radius+ })+ })+ .collect()+}++fn clip_half_plane(vertices: Vec<Pos2>, side: impl Fn(Pos2) -> f32) -> Vec<Pos2> {+ let Some(mut previous) = vertices.last().copied() else { return vertices };+ let mut clipped = Vec::with_capacity(vertices.len() + 2);+ for current in vertices {+ let a = side(previous);+ let b = side(current);+ if (a >= 0.0) != (b >= 0.0) {+ clipped.push(previous + (current - previous) * (a / (a - b)));+ }+ if b >= 0.0 {+ clipped.push(current);+ }+ previous = current;+ }+ clipped+}++fn theme_swatch(p: &egui::Painter, r: Rect, c: ThemeSwatch, diagonal: bool) {+ let boundary = rounded_perimeter(r, f32::from(Tokens::get().control_radius));+ let fill = |mut vertices: Vec<Pos2>, color: Color32| {+ if diagonal {+ vertices = clip_half_plane(vertices, |v| (v.x - r.left()) / r.width() + (v.y - r.top()) / r.height() - 1.0);+ }+ for (index, &a) in boundary.iter().enumerate() {+ let b = boundary.get(index + 1).copied().unwrap_or_else(|| boundary.first().copied().unwrap_or(a));+ vertices = clip_half_plane(vertices, |v| (b.x - a.x) * (v.y - a.y) - (b.y - a.y) * (v.x - a.x));+ if vertices.is_empty() {+ break;+ }+ }+ if vertices.len() >= 3 {+ p.add(egui::Shape::convex_polygon(vertices, color, Stroke::NONE));+ }+ };+ let rect =+ |a: (f32, f32), b: (f32, f32), color| fill(vec![point(r, a.0, a.1), point(r, b.0, a.1), point(r, b.0, b.1), point(r, a.0, b.1)], color);+ rect((0.0, 0.0), (1.0, 1.0), c.background);+ rect((0.0, 0.0), (0.34, 1.0), c.panel);+ rect((0.07, 0.29), (0.27, 0.40), c.dim);+ rect((0.07, 0.54), (0.20, 0.65), c.dim);+ let centre = point(r, 0.66, 0.5);+ let radius = r.height() * 0.25;+ fill(+ (0..48)+ .map(|i| {+ let a = std::f32::consts::TAU * i as f32 / 48.0;+ centre + vec2(a.cos(), a.sin()) * radius+ })+ .collect(),+ c.accent,+ );+ rect((0.8, 0.39), (0.94, 0.61), c.panel);+}++#[derive(Clone, Copy)]+pub(crate) struct LayoutPreview {+ pub compact: bool,+ pub labels: bool,+ pub history: usize,+ pub translucent: bool,+}++/// One live shell specimen follows all four layout choices; it is a schematic, not a second scene.+pub(crate) fn layout_preview(ui: &mut Ui, state: LayoutPreview) {+ super::preferences_figures::paint_layout(ui, state);+}++pub(crate) fn tab_accent_strip(ui: &mut Ui) {+ let t = Tokens::get();+ super::text(ui, crate::i18n::tr("prefs.tab_accent_note"), super::Text::Hint("tab_accent"));+ let names =+ [("MODEL", "Model"), ("SURFACE", "Surface"), ("MESH", "Mesh"), ("FORM", "Form"), ("SHEET METAL", "Sheet Metal"), ("RENDER", "Render")];+ let (r, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24 + t.space_8), Sense::hover());+ let width = r.width() / names.len() as f32;+ for (i, (name, display_label)) in names.iter().enumerate() {+ let rect = Rect::from_min_size(r.min + vec2(i as f32 * width, 0.0), vec2((width - t.space_6).max(0.0), t.space_6));+ let accent = crate::theme::TabAccent::for_tab(&t, name);+ ui.painter().rect_filled(rect, t.radius_sm, accent.color);+ let label = Rect::from_min_size(pos2(rect.left(), rect.bottom() + t.space_4), vec2(rect.width(), t.space_16));+ centred_text(ui.painter(), label, crate::i18n::tr_label(display_label), FontId::proportional(t.font_small), t.form_dim);+ }+}++pub(crate) fn scale_specimen(ui: &mut Ui, scale: f32) {+ let t = Tokens::get();+ let scale = if scale.is_finite() { scale.clamp(0.5, 2.5) / ui.ctx().zoom_factor().max(0.5) } else { 1.0 };+ let (r, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24 * 4.0 + t.space_16), Sense::hover());+ ui.painter().rect(r, t.radius_lg, t.control_fill, Stroke::new(1.0, t.dialog_rule), egui::StrokeKind::Inside);+ let p = ui.painter().with_clip_rect(r.shrink(t.space_8));+ let font = FontId::proportional(t.font_label * scale);+ p.text(+ r.right_top() + vec2(-t.space_8, t.space_8),+ egui::Align2::RIGHT_TOP,+ crate::i18n::tr("prefs.live_preview").to_uppercase(),+ FontId::proportional(t.font_micro),+ t.form_dim,+ );+ let origin = r.min + vec2(t.space_10, t.space_24);+ let line_h = t.control_height * scale;+ let distance = crate::i18n::tr_label("Distance");+ let label = p.layout_no_wrap(distance.to_owned(), font.clone(), t.form_dim);+ p.galley(origin + vec2(0.0, (line_h - label.size().y) / 2.0), label.clone(), t.form_dim);+ let field = Rect::from_min_size(origin + vec2(label.size().x + t.space_8 * scale, 0.0), vec2((t.form_label_width + t.space_6) * scale, line_h));+ p.rect(field, t.control_radius, t.control_fill, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ centred_text(&p, field, "12.50", FontId::monospace(t.font_body * scale), t.form_ink);+ let button = Rect::from_min_size(field.right_top() + vec2(t.space_8 * scale, 0.0), vec2(t.space_24 * 1.5 * scale, line_h));+ p.rect_filled(button, t.control_radius, t.form_primary);+ centred_text(&p, button, crate::i18n::tr_label("OK"), crate::fonts::semibold(t.font_label * scale), t.on_accent);+ let feature = Rect::from_min_size(origin + vec2(0.0, line_h + t.space_8 * scale), vec2(r.width() - t.space_10 * 2.0, line_h));+ p.rect_filled(feature, t.control_radius, t.selected_bg);+ let icon = Rect::from_center_size(pos2(feature.left() + t.space_16 * scale, feature.center().y), vec2(t.space_16, t.space_16) * scale);+ crate::icons::paint_icon(&p, icon, "extrude", 1.0);+ p.text(+ pos2(icon.right() + t.space_6 * scale, feature.center().y),+ egui::Align2::LEFT_CENTER,+ "Extrude1",+ crate::fonts::semibold(t.font_label * scale),+ t.selected_ink,+ );+ p.text(feature.right_center() - vec2(t.space_8, 0.0), egui::Align2::RIGHT_CENTER, "12.5 mm", font, t.form_dim);+}++/// Font picker and auxiliary actions share one line, with the specimen below.+pub(crate) fn settings_font_row(ui: &mut Ui, label: &str, mut add: impl FnMut(&mut Ui, usize)) {+ let t = Tokens::get();+ super::settings_form(ui, t.form_label_width, |ui| {+ super::row(ui, label, |ui| {+ let actions = t.space_24 * 8.0 + t.space_8;+ let picker = (dimension(ui.available_width()) - actions - t.space_8).max(t.space_24);+ ui.allocate_ui_with_layout(vec2(picker, t.control_height), egui::Layout::left_to_right(egui::Align::Center), |ui| add(ui, 0));+ ui.add_space(t.space_4);+ add(ui, 1);+ });+ });+}++/// Natural-width dim text, for inline suffixes and metadata without a full-width note row.+pub(crate) fn settings_inline_note(ui: &mut Ui, text: &str) {+ let t = Tokens::get();+ let galley = ui.painter().layout_no_wrap(text.to_owned(), FontId::proportional(t.font_body), t.form_dim);+ let (r, response) = ui.allocate_exact_size(galley.size(), Sense::hover());+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));+ ui.painter().galley(r.min, galley, t.form_dim);+}++/// Framed font specimen, inheriting the chosen application font and its fallback glyphs.+pub(crate) fn font_specimen(ui: &mut Ui, text: &str) {+ let t = Tokens::get();+ let (r, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.control_height + t.space_10), Sense::hover());+ ui.painter().rect(r, t.control_radius, t.control_fill, Stroke::new(1.0, t.dialog_rule), egui::StrokeKind::Inside);+ paint_text(ui, r.shrink2(vec2(t.space_12, 0.0)), text, FontId::proportional(t.font_button), t.form_ink, false);+}++/// Intrinsically sized segments, retaining the usual row label for accessibility and automation.+pub(crate) fn settings_segments(ui: &mut Ui, label: &str, selected: &mut usize, options: &[&str]) -> bool {+ let t = Tokens::get();+ let widest = options.iter().map(|s| super::ContentWidth::name(ui, s)).fold(0.0, f32::max);+ let width = ((widest + t.space_16) * options.len() as f32).min(dimension(ui.available_width()));+ ui.allocate_ui_with_layout(vec2(width, t.control_height), egui::Layout::left_to_right(egui::Align::Center), |ui| {+ ui.scope_builder(+ egui::UiBuilder::new().ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::layout::LABEL, label.to_owned())),+ |ui| super::segmented(ui, selected, options, super::Segments { compact: true, ..Default::default() }),+ )+ .inner+ })+ .inner+}++pub(crate) fn status_palette_sample(ui: &mut Ui, mode: ColorVision) {+ let t = Tokens::get();+ let colours = Tokens::themed(crate::theme::is_dark(), mode);+ ui.horizontal_wrapped(|ui| {+ for (label, icon, fill) in [+ ("prefs.status_selected", "finish", colours.form_primary),+ ("prefs.status_warning", "warning", colours.warning),+ ("prefs.status_error", "close", colours.error),+ ("prefs.status_done", "finish", colours.form_success),+ ] {+ let ink = if crate::theme::contrast_ratio(t.on_accent, fill) >= 4.5 { t.on_accent } else { t.tab_on_fill_dark };+ let label = crate::i18n::tr(label);+ let galley = ui.painter().layout_no_wrap(label.to_owned(), crate::fonts::semibold(t.font_small), ink);+ let (r, _) = ui.allocate_exact_size(vec2(galley.size().x + t.space_24 + t.space_16, t.space_24), Sense::hover());+ ui.painter().rect_filled(r, t.radius_xl, fill);+ crate::icons::paint_ink(+ ui.painter(),+ Rect::from_center_size(pos2(r.left() + t.space_12, r.center().y), vec2(t.space_12, t.space_12)),+ icon,+ ink,+ );+ ui.painter().galley(pos2(r.left() + t.space_24, r.center().y - galley.size().y / 2.0), galley, ink);+ }+ });+}++/// The names under the Colour vision sample (message ids).+#[cfg(test)]+pub(crate) const COLOUR_VISION_SAMPLE: [&str; 6] =+ ["ui.colour_vision_fixed", "ui.colour_vision_projected", "ui.axes", "Bends", "ui.draft", "ui.colour_vision_failed"];++/// The Colour vision sample (#778): fixed and projected sketch lines, the X and Y axes, bends up+/// and down, Draft Analysis and a failed feature, each drawn as it is where it appears, in the+/// colours on now. The six cells share one responsive, clipped area.+#[cfg(test)]+pub(crate) fn colour_vision_sample(ui: &mut egui::Ui, t: &Tokens) {+ let width = (dimension(ui.available_width()) / COLOUR_VISION_SAMPLE.len() as f32).min(t.space_24 * 3.0);+ let line_width = t.space_4;+ let (area, _) = ui.allocate_exact_size(egui::vec2(width * COLOUR_VISION_SAMPLE.len() as f32, t.space_24 * 2.0 + t.space_2), egui::Sense::hover());+ let p = ui.painter_at(area);+ let line = |c| egui::Stroke::new(line_width, c);+ for (i, name) in COLOUR_VISION_SAMPLE.iter().enumerate() {+ let cell = egui::Rect::from_min_size(+ area.min + egui::vec2(width * i as f32, 0.0),+ egui::vec2((width - t.space_8).max(0.0), t.control_height + t.space_4),+ );+ let (a, b) = (cell.left_center() + egui::vec2(t.space_8, 0.0), cell.right_center() - egui::vec2(t.space_8, 0.0));+ match i {+ 0 | 1 => {+ p.rect_filled(cell, t.radius_sm, t.viewport_top);+ p.line_segment([a, b], line(if i == 0 { t.sketch_locked } else { t.sketch_projected }));+ }+ 2 => {+ // X along and Y up from one corner, as the view triad draws them.+ p.rect_filled(cell, t.radius_sm, t.viewport_top);+ let o = cell.left_bottom() + egui::vec2(t.space_12, -(t.space_4 + t.space_3));+ p.line_segment([o, egui::pos2(cell.right() - t.space_10, o.y)], line(t.triad[0]));+ p.line_segment([o, egui::pos2(o.x, cell.top() + t.space_6)], line(t.triad[1]));+ }+ 3 => {+ // Dashed, as the flat pattern draws them.+ p.rect_filled(cell, t.radius_sm, t.viewport_top);+ for (dy, c) in [(-(t.space_4 + t.space_3), t.bend_up), (t.space_4 + t.space_3, t.bend_down)] {+ p.extend(egui::Shape::dashed_line(+ &[a + egui::vec2(0.0, dy), b + egui::vec2(0.0, dy)],+ line(c),+ t.space_8,+ t.space_3 + t.space_2,+ ));+ }+ }+ 4 => {+ // The three bands of Draft Analysis; in a mode the negative one is striped.+ let w = cell.width() / 3.0;+ for (k, c) in t.analysis.draft.iter().enumerate() {+ let band = egui::Rect::from_min_size(cell.min + egui::vec2(w * k as f32, 0.0), egui::vec2(w, cell.height()));+ p.rect_filled(band, 0.0, crate::theme::srgb(*c));+ if k == 2 && t.analysis.hatch {+ let stripes = p.with_clip_rect(band);+ let dark = crate::theme::srgb(c.map(|x| x * 0.6));+ let mut x = band.left() - band.height();+ while x < band.right() {+ stripes.line_segment(+ [egui::pos2(x, band.bottom()), egui::pos2(x + band.height(), band.top())],+ egui::Stroke::new(2.0, dark),+ );+ x += t.space_6 + t.space_3;+ }+ }+ }+ }+ _ => {+ // A failed feature on the timeline.+ p.rect(+ cell.shrink2(egui::vec2(t.space_10, t.space_3)),+ t.radius_sm,+ t.timeline_item_error,+ egui::Stroke::new(1.0, t.error),+ egui::StrokeKind::Inside,+ );+ }+ }+ centred_text(+ &p,+ Rect::from_min_size(cell.left_bottom() + vec2(0.0, t.space_3), vec2(cell.width(), t.space_16)),+ crate::i18n::tr(name),+ FontId::proportional(t.font_small),+ t.text_dim,+ );+ }+}diff --git a/crates/ui-egui/src/ui_kit/preferences_assistant.rs b/crates/ui-egui/src/ui_kit/preferences_assistant.rsnew file mode 100644index 0000000000..ed9e1de36d--- /dev/null+++ b/crates/ui-egui/src/ui_kit/preferences_assistant.rs@@ -0,0 +1,100 @@+//! Shared concise choice cards and the agent-pointer settings specimen.+use super::{metrics::dimension, text::paint_text};+use crate::{scenario, theme::Tokens};+use egui::{FontId, Rect, Response, Sense, Stroke, Ui, pos2, vec2};++/// One concise choice with its full meaning available to keyboard users and on hover.+pub(crate) struct SettingsChoice<'a> {+ pub key: &'a str,+ pub title: &'a str,+ pub summary: &'a str,+ pub detail: &'a str,+}++/// Equal option cards keep the choices comparable without repeating long explanations.+pub(crate) fn settings_choices(ui: &mut Ui, choices: &[SettingsChoice<'_>], selected: &mut usize) -> bool {+ let t = Tokens::get();+ let count = choices.len().max(1);+ let width = ((dimension(ui.available_width()) - t.space_8 * count.saturating_sub(1) as f32) / count as f32).max(0.0);+ let mut changed = false;+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_8;+ for (index, choice) in choices.iter().enumerate() {+ let response = choice_card(ui, width, choice, *selected == index);+ if response.clicked() {+ *selected = index;+ changed = true;+ }+ }+ });+ changed+}++fn choice_card(ui: &mut Ui, width: f32, choice: &SettingsChoice<'_>, selected: bool) -> Response {+ let t = Tokens::get();+ let height = t.space_24 * 3.0 + t.space_16;+ let (rect, response) = ui.allocate_exact_size(vec2(width, height), Sense::click());+ ui.painter().rect(+ rect,+ t.radius_lg,+ if selected {+ t.selected_bg+ } else if response.hovered() {+ t.hover+ } else {+ t.control_fill+ },+ Stroke::new(if selected { 2.0 } else { 1.0 }, if selected { t.form_primary } else { t.control_border }),+ egui::StrokeKind::Inside,+ );+ let radio = pos2(rect.left() + t.space_16, rect.top() + t.space_16);+ ui.painter().circle(radio, t.space_6, t.control_fill, Stroke::new(1.0, if selected { t.form_primary } else { t.control_border }));+ if selected {+ ui.painter().circle_filled(radio, t.space_3, t.form_primary);+ }+ let title =+ Rect::from_min_max(pos2(radio.x + t.space_12, rect.top() + t.space_4), pos2(rect.right() - t.space_8, rect.top() + t.space_24 + t.space_4));+ paint_text(ui, title, choice.title, crate::fonts::semibold(t.font_label), if selected { t.selected_ink } else { t.form_ink }, false);+ let body = Rect::from_min_max(pos2(rect.left() + t.space_12, title.bottom() + t.space_4), rect.max - vec2(t.space_12, t.space_8));+ let galley = ui.painter().layout(choice.summary.to_owned(), FontId::proportional(t.font_small), t.form_dim, body.width());+ ui.painter().with_clip_rect(ui.clip_rect().intersect(body)).galley(body.min, galley, t.form_dim);+ response.widget_info(|| {+ egui::WidgetInfo::selected(egui::WidgetType::RadioButton, ui.is_enabled(), selected, format!("{}: {}", choice.title, choice.detail))+ });+ scenario::publish_target(choice.key, rect);+ response.on_hover_text(choice.detail).on_hover_cursor(egui::CursorIcon::PointingHand)+}++/// A static preview reuses the real agent cursor artwork; it never animates or requests frames.+pub(crate) fn settings_pointer_preview(ui: &mut Ui, visible: bool, speed: &str, follows_camera: bool) {+ let t = Tokens::get();+ let width = dimension(ui.available_width());+ let (rect, response) = ui.allocate_exact_size(vec2(width, t.space_24 * 3.0 + t.space_16), Sense::hover());+ ui.painter().rect(rect, t.radius_lg, t.viewport_top, Stroke::new(1.0, t.dialog_rule), egui::StrokeKind::Inside);+ let path = [pos2(rect.left() + t.space_24, rect.center().y), rect.center(), pos2(rect.right() - t.space_24 * 2.0, rect.center().y - t.space_12)];+ ui.painter().extend(egui::Shape::dashed_line(&path, Stroke::new(1.0, t.control_border), t.space_3, t.space_4));+ for point in path {+ ui.painter().circle_filled(point, t.space_3, t.control_border);+ }+ if visible {+ crate::icons::pointer::paint(&ui.painter().with_clip_rect(rect.shrink(t.space_4)), path.get(1).copied().unwrap_or(rect.center()));+ }+ let caption = if visible {+ crate::i18n::format("ai.prefs.pointer_preview_speed", &[("speed", speed)])+ } else {+ crate::i18n::tr("ai.prefs.pointer_preview_hidden").to_owned()+ };+ let caption_rect = Rect::from_min_max(rect.min + vec2(t.space_8, t.space_4), pos2(rect.right() - t.space_8, rect.top() + t.space_24));+ paint_text(ui, caption_rect, &caption, FontId::proportional(t.font_small), t.form_dim, false);+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), &caption));+ response.on_hover_text(crate::i18n::tr(if follows_camera { "ai.prefs.follow_camera_on" } else { "ai.prefs.follow_camera_off" }));+}++/// One muted metadata line; full commands, endpoints and tool lists remain available on hover.+pub(crate) fn settings_short_note(ui: &mut Ui, text: &str) -> Response {+ let t = Tokens::get();+ let (rect, response) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_16), Sense::hover());+ paint_text(ui, rect, text, FontId::proportional(t.font_small), t.form_dim, false);+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));+ response.on_hover_text(text)+}diff --git a/crates/ui-egui/src/ui_kit/preferences_figures.rs b/crates/ui-egui/src/ui_kit/preferences_figures.rsnew file mode 100644index 0000000000..2c90f458f6--- /dev/null+++ b/crates/ui-egui/src/ui_kit/preferences_figures.rs@@ -0,0 +1,253 @@+//! Deliberately composed preference illustrations. A shared orthographic projection keeps+//! faces, ground contact, rotation cues and axes consistent at their small display size.+use crate::theme::Tokens;+use egui::{Color32, Painter, Pos2, Rect, Shape, Stroke, Vec2, vec2};++struct Canvas {+ rect: Rect,+}+impl Canvas {+ fn at(&self, x: f32, y: f32) -> Pos2 {+ self.rect.min + vec2(x * self.rect.width() / 120.0, y * self.rect.height() / 80.0)+ }+ fn width(&self, width: f32) -> f32 {+ width * (self.rect.width() / 120.0).min(self.rect.height() / 80.0)+ }+ fn project(&self, origin: (f32, f32), x: f32, y: f32, z: f32, scale: f32) -> Pos2 {+ self.at(origin.0 + (x - y) * 0.866_025_4 * scale, origin.1 + ((x + y) * 0.5 - z) * scale)+ }+}++fn face(p: &Painter, points: [Pos2; 4], fill: Color32) {+ p.add(Shape::convex_polygon(points.to_vec(), fill, Stroke::NONE));+}++/// Face order follows the actual orthographic camera: top, screen-left and screen-right.+fn solid(p: &Painter, c: &Canvas, centre: (f32, f32), size: f32, height: f32, scale: f32, t: &Tokens) -> [Pos2; 4] {+ let h = size * 0.5;+ let at = |x, y, z| c.project(centre, x, y, z, scale);+ let back = at(-h, -h, height);+ let left = at(-h, h, height);+ let front = at(h, h, height);+ let right = at(h, -h, height);+ let bottom_left = at(-h, h, 0.0);+ let bottom_front = at(h, h, 0.0);+ let bottom_right = at(h, -h, 0.0);+ face(p, [left, front, bottom_front, bottom_left], t.body.lerp_to_gamma(t.body_edge, 0.15));+ face(p, [front, right, bottom_right, bottom_front], t.body.lerp_to_gamma(t.body_edge, 0.30));+ face(p, [back, right, front, left], t.body);+ let edge = t.body_edge.lerp_to_gamma(t.form_dim, 0.35);+ let stroke = Stroke::new(c.width(1.2), edge);+ p.add(Shape::closed_line(vec![back, right, bottom_right, bottom_front, bottom_left, left], stroke));+ p.add(Shape::line(vec![left, front, right], stroke));+ p.line_segment([front, bottom_front], stroke);+ [at(-h, -h, 0.0), bottom_right, bottom_front, bottom_left]+}++fn arrow(p: &Painter, a: Pos2, b: Pos2, ink: Color32, width: f32, head: f32) {+ let tangent = (b - a).normalized();+ let normal = vec2(-tangent.y, tangent.x);+ let base = b - tangent * head;+ p.line_segment([a, base + tangent * width], Stroke::new(width, ink));+ p.add(Shape::convex_polygon(vec![b, base + normal * head * 0.44, base - normal * head * 0.44], ink, Stroke::NONE));+}++fn radial_shadow(p: &Painter, centre: Pos2, radius: Vec2, ink: Color32) {+ const SEGMENTS: u32 = 40;+ let mut mesh = egui::Mesh::default();+ mesh.colored_vertex(centre, ink);+ for i in 0..=SEGMENTS {+ let angle = std::f32::consts::TAU * i as f32 / SEGMENTS as f32;+ mesh.colored_vertex(centre + vec2(angle.cos() * radius.x, angle.sin() * radius.y), Color32::TRANSPARENT);+ }+ for i in 1..=SEGMENTS {+ mesh.add_triangle(0, i, i + 1);+ }+ p.add(Shape::mesh(mesh));+}++/// Orbit cards share a deliberately positioned model; only the pivot and its explanatory+/// cue move. The arc's arrowhead is tangent to the projected ground-plane ellipse.+pub(crate) fn paint_orbit(p: &Painter, rect: Rect, pivot: usize) {+ let t = Tokens::get();+ let c = Canvas { rect };+ let p = p.with_clip_rect(rect);+ let model_centre = (61.0, 53.0);+ radial_shadow(&p, c.at(61.0, 59.0), vec2(c.width(25.0), c.width(5.0)), t.body_edge.gamma_multiply(0.12));+ solid(&p, &c, model_centre, 24.0, 24.0, 0.9, &t);+ let (x, y) = match pivot {+ 0 => (22.0, 60.0),+ 2 => (88.0, 31.0),+ _ => (61.0, 42.0),+ };+ let centre = c.at(x, y);+ let orange = t.surface_ink;+ if pivot == 0 {+ let grey = Stroke::new(c.width(1.3), t.form_dim);+ p.line_segment([centre, c.at(x, y - 11.0)], grey);+ p.line_segment([centre, c.at(x + 11.0, y + 5.5)], grey);+ p.line_segment([centre, c.at(x - 11.0, y + 5.5)], grey);+ }+ if pivot == 1 {+ // A restrained screen-space crosshair makes "View centre" distinct from origin.+ let guide = Stroke::new(c.width(1.0), t.form_dim.gamma_multiply(0.7));+ for (a, b) in [((x - 9.0, y), (x - 5.0, y)), ((x + 5.0, y), (x + 9.0, y)), ((x, y - 9.0), (x, y - 5.0))] {+ p.line_segment([c.at(a.0, a.1), c.at(b.0, b.1)], guide);+ }+ }+ let mut arc = Vec::with_capacity(33);+ for i in 0..=32 {+ let angle = std::f32::consts::PI * (0.88 - 0.76 * i as f32 / 32.0);+ arc.push(c.at(x + 15.0 * angle.cos(), y + 5.0 + 8.5 * angle.sin()));+ }+ let end_angle = std::f32::consts::PI * 0.12;+ let end = c.at(x + 15.0 * end_angle.cos(), y + 5.0 + 8.5 * end_angle.sin());+ let direction = vec2(15.0 * end_angle.sin(), -8.5 * end_angle.cos()).normalized();+ p.add(Shape::line(arc, Stroke::new(c.width(1.8), orange)));+ arrow(&p, end - direction * c.width(5.0), end + direction * c.width(1.0), orange, c.width(1.8), c.width(5.5));+ p.circle_filled(centre, c.width(4.4), t.viewport_top);+ p.circle_filled(centre, c.width(3.0), orange);+ if pivot == 2 {+ // Seven straight vertices describe a cursor with a clean neck and substantial stem.+ let points = [(88.0, 35.0), (88.0, 49.0), (91.5, 45.8), (95.2, 53.0), (98.2, 51.5), (94.4, 44.5), (99.0, 44.5)].map(|(x, y)| c.at(x, y));+ let mut mesh = egui::Mesh::default();+ for point in points {+ mesh.colored_vertex(point, t.form_ink);+ }+ for [a, b, d] in [[0, 1, 2], [0, 2, 5], [0, 5, 6], [2, 3, 4], [2, 4, 5]] {+ mesh.add_triangle(a, b, d);+ }+ p.add(Shape::mesh(mesh));+ }+}++/// Orientation uses the same 30-degree ground plane as the model cards, with unmistakable+/// axis arrows and readable labels rather than an unrelated generic cube.+pub(crate) fn paint_orientation(p: &Painter, rect: Rect, y_up: bool) {+ let t = Tokens::get();+ let c = Canvas { rect };+ let p = p.with_clip_rect(rect);+ let centre = c.at(60.0, 48.0);+ let ground = [c.at(60.0, 32.0), c.at(97.0, 50.5), c.at(60.0, 69.0), c.at(23.0, 50.5)];+ face(&p, ground, t.form_dim.gamma_multiply(0.035));+ p.add(Shape::closed_line(ground.to_vec(), Stroke::new(c.width(0.8), t.form_dim.gamma_multiply(0.20))));+ let axes = if y_up {+ [(94.0, 65.0, 0, "X"), (60.0, 13.0, 1, "Y"), (26.0, 65.0, 2, "Z")]+ } else {+ [(94.0, 65.0, 0, "X"), (26.0, 65.0, 1, "Y"), (60.0, 13.0, 2, "Z")]+ };+ for (x, y, index, label) in axes {+ let colour = t.triad.get(index).copied().unwrap_or(t.form_ink);+ let end = c.at(x, y);+ // A halo keeps every shaft distinct from the subtle ground and the other axes.+ p.line_segment([centre, end], Stroke::new(c.width(4.2), t.viewport_top));+ arrow(&p, centre, end, colour, c.width(2.3), c.width(6.5));+ let text_pos = if y < 20.0 { c.at(x, y - 6.0) } else { c.at(x + if x < 60.0 { -7.0 } else { 7.0 }, y + 3.0) };+ let ink = if crate::theme::contrast_ratio(colour, t.viewport_top) >= 4.5 { colour } else { t.form_ink };+ p.text(text_pos, egui::Align2::CENTER_CENTER, label, crate::fonts::semibold(t.font_small), ink);+ }+ p.circle_filled(centre, c.width(2.7), t.form_ink);+ p.circle_filled(centre, c.width(1.2), t.viewport_top);+}++/// Contact shading is visible in a physically grounded model, with a broad penumbra and+/// a tight occlusion core following its footprint. The unshaded option retains a light+/// ground reference so the model never appears to float.+pub(crate) fn paint_contact_shading(p: &Painter, rect: Rect, on: bool) {+ let t = Tokens::get();+ let c = Canvas { rect };+ let p = p.with_clip_rect(rect);+ let centre = (61.0, 51.0);+ let ground = [c.at(61.0, 37.0), c.at(105.0, 59.0), c.at(61.0, 80.0), c.at(17.0, 59.0)];+ face(&p, ground, t.form_dim.gamma_multiply(0.035));+ if on {+ radial_shadow(&p, c.at(61.0, 60.0), vec2(c.width(35.0), c.width(12.5)), t.body_edge.gamma_multiply(0.24));+ radial_shadow(&p, c.at(61.0, 60.0), vec2(c.width(25.0), c.width(7.5)), t.body_edge.gamma_multiply(0.35));+ } else {+ radial_shadow(&p, c.at(61.0, 60.0), vec2(c.width(28.0), c.width(7.0)), t.body_edge.gamma_multiply(0.07));+ }+ let footprint = solid(&p, &c, centre, 28.0, 25.0, 0.9, &t);+ if on {+ // The front two contact edges align exactly with the projected solid, never an+ // arbitrary ellipse painted over the faces.+ let [_, right, front, left] = footprint;+ p.add(Shape::line(vec![left, front, right], Stroke::new(c.width(2.0), t.body_edge.gamma_multiply(0.38))));+ }+}++/// A single carefully composed shell preview demonstrates the four layout settings.+/// It is explanatory vector content: no second viewport, live scene, or nested host.+/// A restrained workspace schematic: panel placement remains primary, with a few+/// tool marks, tree rows and one simple solid providing recognisable CAD context.+pub(crate) fn paint_layout(ui: &mut egui::Ui, state: super::preferences::LayoutPreview) {+ let t = Tokens::get();+ let size = vec2(super::metrics::dimension(ui.available_width()), t.space_24 * 7.0 + t.space_6);+ let (outer, _) = ui.allocate_exact_size(size, egui::Sense::hover());+ let p = ui.painter().with_clip_rect(outer);+ p.rect(outer, t.radius_lg, t.control_fill, Stroke::new(1.0, t.dialog_rule), egui::StrokeKind::Inside);+ let r = outer.shrink(t.space_8);+ let c = Canvas { rect: r };+ p.rect(r, t.control_radius, t.viewport_top, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ let inset = if state.compact { 0.0 } else { 4.0 };+ let gap = if state.compact { 0.0 } else { 3.0 };+ let ribbon_height = if state.labels { 16.0 } else { 10.0 };+ let top = inset + ribbon_height + gap;+ let bottom = 80.0 - inset;+ let left_history = if state.history == 1 { 10.0 + gap } else { 0.0 };+ let bx = inset + left_history;+ let bw = 30.0;+ let browser_height = if state.history == 2 {+ (bottom - top - gap) * 0.5+ } else if state.history == 0 {+ bottom - top - 10.0 - gap+ } else {+ bottom - top+ };+ let panel = |x: f32, y: f32, w: f32, h: f32, label: &str, fill: Color32| {+ let rect = Rect::from_min_max(c.at(x, y), c.at(x + w, y + h));+ p.rect(rect, if state.compact { 0 } else { t.radius_sm }, fill, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ if !label.is_empty() {+ let centre = if h > 20.0 { c.at(x + w * 0.5, y + 7.0) } else { rect.center() };+ p.text(centre, egui::Align2::CENTER_CENTER, crate::i18n::tr_label(label), egui::FontId::proportional(t.font_small), t.form_dim);+ }+ rect+ };+ panel(inset, inset, 120.0 - inset * 2.0, ribbon_height, "", t.toolbar);+ panel(bx, top, bw, browser_height, "Browser", if state.translucent && !state.compact { t.panel.gamma_multiply(0.60) } else { t.panel });+ // A full row of quiet tool symbols, with label marks only when labels are enabled.+ let quiet = t.form_dim.lerp_to_gamma(t.viewport_top, 0.55);+ for index in 0..10 {+ let x = inset + 7.0 + index as f32 * (106.0 - inset * 2.0) / 9.0;+ let y = inset + if state.labels { 5.5 } else { ribbon_height * 0.5 };+ p.circle_filled(c.at(x, y), c.width(1.8), quiet);+ if state.labels {+ p.line_segment([c.at(x - 3.0, y + 4.5), c.at(x + 3.0, y + 4.5)], Stroke::new(c.width(0.65), quiet));+ }+ }+ for index in 0..3 {+ let y = top + 15.0 + index as f32 * 5.0;+ if y < top + browser_height - 3.0 {+ let indent = if index == 1 { 2.5 } else { 0.0 };+ p.line_segment([c.at(bx + 5.0 + indent, y), c.at(bx + bw - 5.0, y)], Stroke::new(c.width(0.7), t.form_dim.gamma_multiply(0.4)));+ }+ }+ let viewport_left = bx + bw + gap;+ let viewport_bottom = if state.history == 0 { bottom - 10.0 - gap } else { bottom };+ let object_centre = c.at((viewport_left + 120.0 - inset) * 0.5, (top + viewport_bottom) * 0.5);+ crate::icons::glyphs::brand_mark_silhouette(&p, object_centre, c.width(22.0), quiet);+ p.circle_filled(c.at(110.0 - inset, top + 7.0), c.width(3.5), quiet);+ let history = match state.history {+ 1 => panel(inset, top, 10.0, bottom - top, "", t.selected_bg),+ 2 => panel(bx, top + browser_height + gap, bw, bottom - top - browser_height - gap, "History", t.selected_bg),+ _ => panel(inset, bottom - 10.0, 120.0 - inset * 2.0, 10.0, "History", t.selected_bg),+ };+ if state.history == 1 {+ // A single vertical mark reads as the narrow icon-only history rail.+ p.line_segment(+ [history.center_top() + vec2(0.0, t.space_8), history.center_bottom() - vec2(0.0, t.space_8)],+ Stroke::new(2.0, t.form_primary),+ );+ }+ crate::scenario::publish_rect("prefs:layout_preview", outer);+ super::text(ui, crate::i18n::tr("prefs.preview_choices"), super::Text::Note("preview"));+}diff --git a/crates/ui-egui/src/ui_kit/preferences_navigation.rs b/crates/ui-egui/src/ui_kit/preferences_navigation.rsnew file mode 100644index 0000000000..c314002a64--- /dev/null+++ b/crates/ui-egui/src/ui_kit/preferences_navigation.rs@@ -0,0 +1,175 @@+//! Compact navigation preference compositions and explanatory figures.+use super::{metrics::dimension, text::paint_text};+use crate::theme::Tokens;+use egui::{FontId, Rect, Sense, Stroke, Ui, pos2, vec2};++/// One mouse silhouette beside the actual mapping selector and binding legend.+/// The figure is descriptive content, not an icon asset or an application viewport.+pub(crate) fn settings_mouse_mapping(ui: &mut Ui, bindings: &[(Vec<String>, String)], mapping: impl FnOnce(&mut Ui)) {+ let t = Tokens::get();+ ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_24 - t.space_2;+ let figure_size = vec2(t.form_label_width + t.space_24 + t.space_16, t.space_24 * 6.0 + t.space_16);+ let (figure, _) = ui.allocate_exact_size(figure_size, Sense::hover());+ let width = dimension(ui.available_width());+ let content = ui.allocate_ui_with_layout(vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {+ mapping(ui);+ ui.add_space(t.space_6);+ for (keys, action) in bindings.iter().take(10) {+ settings_gesture(ui, keys, action);+ }+ });+ let height = figure.height().max(content.response.rect.height());+ let figure = Rect::from_min_size(figure.min + vec2(0.0, (height - figure.height()) * 0.5), figure_size);+ let point = |x: f32, y: f32| figure.min + vec2(figure.width() * x / 110.0, figure.height() * y / 160.0);+ let mouse = Rect::from_min_max(point(12.0, 6.0), point(98.0, 154.0));+ let p = ui.painter();+ p.rect_filled(mouse, mouse.width() * 0.5, t.control_fill);+ let left = Rect::from_min_max(mouse.min, pos2(mouse.center().x, point(0.0, 68.0).y));+ p.with_clip_rect(left).rect_filled(mouse, mouse.width() * 0.5, t.selected_bg);+ let right = Rect::from_min_max(pos2(mouse.center().x, mouse.top()), pos2(mouse.right(), point(0.0, 68.0).y));+ p.with_clip_rect(right).rect_filled(mouse, mouse.width() * 0.5, t.warning.gamma_multiply(0.18));+ p.rect_stroke(mouse, mouse.width() * 0.5, Stroke::new(1.5, t.control_border), egui::StrokeKind::Inside);+ p.vline(mouse.center().x, mouse.top()..=point(0.0, 68.0).y, Stroke::new(1.2, t.control_border));+ p.hline(mouse.x_range(), point(0.0, 68.0).y, Stroke::new(1.2, t.control_border));+ p.rect_filled(Rect::from_min_max(point(48.0, 24.0), point(62.0, 54.0)), t.radius_lg, t.form_primary);+ });+}++/// Keyboard and pointer gestures use the same quiet keycap treatment as shortcuts.+fn settings_gesture(ui: &mut Ui, keys: &[String], action: &str) {+ let t = Tokens::get();+ let width = dimension(ui.available_width());+ let (rect, response) = ui.allocate_exact_size(vec2(width, t.control_height + t.space_2), Sense::hover());+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), format!("{}: {action}", keys.join(" + "))));+ ui.painter().hline(rect.x_range(), rect.bottom(), Stroke::new(1.0, t.dialog_rule));+ let key_width = (t.form_label_width * 2.0 + t.space_24 + t.space_6).min(width * 0.57);+ let key_rect = Rect::from_min_size(rect.min, vec2(key_width, rect.height()));+ let p = ui.painter().with_clip_rect(key_rect);+ let mut x = key_rect.left();+ for (index, key) in keys.iter().enumerate() {+ if index > 0 {+ let join = Rect::from_min_size(pos2(x, rect.top()), vec2(t.space_12, rect.height()));+ paint_text(ui, join, "+", FontId::proportional(t.font_small), t.form_dim, true);+ x += t.space_12;+ }+ let galley = p.layout_no_wrap(key.to_owned(), FontId::proportional(t.font_small), t.form_ink);+ let cap = Rect::from_center_size(+ pos2(x + (galley.size().x + t.space_12) / 2.0, rect.center().y),+ vec2(galley.size().x + t.space_12, t.space_24 - t.space_2),+ );+ p.rect(cap, t.radius_sm, t.control_fill, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ p.galley(pos2(cap.center().x - galley.size().x / 2.0, cap.center().y - galley.size().y / 2.0), galley, t.form_ink);+ x = cap.right() + t.space_4;+ }+ let action_rect = Rect::from_min_max(pos2(key_rect.right() + t.space_8, rect.top()), rect.max);+ paint_text(ui, action_rect, action, FontId::proportional(t.font_label), t.form_ink, false);+}++fn axis_columns(rect: Rect) -> [Rect; 5] {+ let t = Tokens::get();+ let gap = t.space_8;+ let available = (rect.width() - gap * 4.0).max(0.0);+ // The final column retains physical-motion reassignment, a real preference not shown+ // in the board. The illustration column absorbs narrow-window pressure first.+ let label = t.form_label_width + t.space_6;+ let invert = t.form_label_width;+ let speed = t.space_24 * 2.0 + t.space_16;+ let source = t.form_label_width + t.space_24 + t.space_16;+ let live = t.form_label_width * 2.0 + t.space_24 + t.space_6;+ let widths = [label, (available - label - invert - speed - source).clamp(0.0, live), invert, speed];+ let mut x = rect.left();+ std::array::from_fn(|index| {+ let width = widths.get(index).copied().unwrap_or((rect.right() - x).max(0.0));+ let column = Rect::from_min_size(pos2(x, rect.top()), vec2(width, rect.height()));+ x += width + gap;+ column+ })+}++pub(crate) fn settings_axis_header(ui: &mut Ui) {+ let t = Tokens::get();+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.space_24), Sense::hover());+ for (column, label) in axis_columns(rect).into_iter().zip(["prefs.axis", "prefs.live_input", "", "prefs.speed", "prefs.source"]) {+ paint_text(ui, column, &crate::i18n::tr(label).to_uppercase(), crate::fonts::semibold(t.font_small), t.form_dim, false);+ }+}++/// One table row combines measured input with the actual invert, gain, and motion controls.+pub(crate) fn settings_axis_row(+ ui: &mut Ui,+ name: &str,+ value: f32,+ dead_zone: [f32; 2],+ invert: impl FnOnce(&mut Ui),+ speed: impl FnOnce(&mut Ui),+ source: impl FnOnce(&mut Ui),+) {+ let t = Tokens::get();+ let (rect, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), t.control_height + t.space_4), Sense::hover());+ ui.painter().hline(rect.x_range(), rect.bottom(), Stroke::new(1.0, t.dialog_rule));+ let [label_rect, live_rect, invert_rect, speed_rect, source_rect] = axis_columns(rect);+ paint_text(ui, label_rect, name, FontId::proportional(t.font_label), t.form_ink, false);+ ui.interact(label_rect, ui.id().with("axis_name"), Sense::hover()).on_hover_text(name);+ let live_rect = Rect::from_center_size(live_rect.center(), vec2(live_rect.width(), t.space_14));+ live_axis_bar_in(ui, live_rect, value, dead_zone);+ axis_control(ui, invert_rect, "invert", name, invert);+ axis_control(ui, speed_rect, "speed", name, speed);+ axis_control(ui, source_rect, "source", name, source);+}++fn axis_control(ui: &mut Ui, rect: Rect, id: &str, label: &str, add: impl FnOnce(&mut Ui)) {+ ui.scope_builder(+ egui::UiBuilder::new()+ .id_salt(id)+ .max_rect(rect)+ .layout(egui::Layout::left_to_right(egui::Align::Center))+ .ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::layout::LABEL, label.to_owned())),+ |ui| {+ ui.set_clip_rect(ui.clip_rect().intersect(rect));+ ui.spacing_mut().text_edit_width = rect.width();+ add(ui);+ },+ );+}++/// Paint a calibrated live-input bar into an existing table cell or gallery slot.+pub(crate) fn live_axis_bar_in(ui: &Ui, live_rect: Rect, value: f32, dead_zone: [f32; 2]) {+ let t = Tokens::get();+ let p = ui.painter().with_clip_rect(live_rect.expand(t.space_2));+ p.rect_filled(live_rect, t.radius_lg, t.dialog_rule);+ let [negative, positive] = dead_zone.map(|share| if share.is_finite() { share.clamp(0.0, 1.0) } else { 0.0 });+ let zone = Rect::from_min_max(+ pos2(live_rect.center().x - live_rect.width() * 0.5 * negative, live_rect.top()),+ pos2(live_rect.center().x + live_rect.width() * 0.5 * positive, live_rect.bottom()),+ );+ let mut x = zone.left() - zone.height();+ while x < zone.right() {+ p.with_clip_rect(zone).line_segment([pos2(x, zone.bottom()), pos2(x + zone.height(), zone.top())], Stroke::new(1.0, t.control_border));+ x += t.space_4;+ }+ let value = if value.is_finite() { value.clamp(-1.0, 1.0) } else { 0.0 };+ let end = live_rect.center().x + live_rect.width() * 0.5 * value;+ p.rect_filled(+ Rect::from_x_y_ranges(+ live_rect.center().x.min(end)..=live_rect.center().x.max(end),+ live_rect.top() + t.space_2..=live_rect.bottom() - t.space_2,+ ),+ t.radius_lg,+ t.form_primary,+ );+ p.vline(live_rect.center().x, live_rect.top() - t.space_2..=live_rect.bottom() + t.space_2, Stroke::new(1.0, t.form_dim));+}++/// Compact per-axis gain uses a consistent two-decimal specimen and the real accepted range.+pub(crate) fn settings_axis_gain(ui: &mut Ui, gain: &mut f32) -> egui::Response {+ let response =+ ui.add(egui::DragValue::new(gain).range(0.0..=3.0).speed(0.05).suffix("×").fixed_decimals(2).custom_parser(crate::prefs::parse_number));+ response.widget_info(|| {+ let mut info = egui::WidgetInfo::drag_value(ui.is_enabled(), f64::from(*gain));+ info.label = Some(super::layout::label(ui).to_owned());+ info+ });+ super::layout::publish_geometry(ui, &response);+ response+}diff --git a/crates/ui-egui/src/ui_kit/preferences_small.rs b/crates/ui-egui/src/ui_kit/preferences_small.rsnew file mode 100644index 0000000000..74d12d0611--- /dev/null+++ b/crates/ui-egui/src/ui_kit/preferences_small.rs@@ -0,0 +1,126 @@+//! Shared labelled settings blocks and compact explanatory specimens.+use crate::theme::Tokens;+use egui::{Align, FontId, Layout, Rect, Sense, Stroke, Ui, pos2, vec2};++/// A labelled form block whose control column can contain several natural-height rows.+pub(crate) fn settings_block<R>(ui: &mut Ui, label: &str, label_width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {+ settings_block_content(ui, label, None, label_width, add)+}++/// A form block whose explanatory hint belongs below its label, beside the controls.+pub(crate) fn settings_block_hint<R>(ui: &mut Ui, label: &str, hint: &str, label_width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {+ settings_block_content(ui, label, Some(hint), label_width, add)+}++fn settings_block_content<R>(ui: &mut Ui, label: &str, hint: Option<&str>, label_width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {+ let t = Tokens::get();+ let width = super::metrics::dimension(ui.available_width());+ let label_width = label_width.min(width * 0.45);+ let response = ui.horizontal_top(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_14;+ ui.allocate_ui_with_layout(vec2(label_width, t.control_height), Layout::top_down(Align::Min), |ui| {+ ui.set_width(label_width);+ ui.spacing_mut().item_spacing.y = t.space_2;+ ui.add_space(t.form_gap_y);+ super::text(ui, label, super::Text::Inline);+ if let Some(hint) = hint {+ super::text(ui, hint, super::Text::Hint(label));+ }+ });+ let control_width = (width - label_width - t.space_14).max(0.0);+ ui.scope_builder(+ egui::UiBuilder::new()+ .max_rect(Rect::from_min_size(ui.next_widget_position(), vec2(control_width, 0.0)))+ .layout(Layout::top_down(Align::Min))+ .ui_stack_info(egui::UiStackInfo::default().with_tag_value(super::layout::LABEL, label.to_string())),+ |ui| {+ ui.set_width(control_width);+ ui.spacing_mut().text_edit_width = control_width;+ add(ui)+ },+ )+ .inner+ });+ crate::scenario::publish_rect(&format!("dialog:row:{label}"), response.response.rect);+ response.inner+}++/// A bounded control that keeps its intended width inside a larger form column.+pub(crate) fn settings_control_width<R>(ui: &mut Ui, width: f32, add: impl FnOnce(&mut Ui) -> R) -> R {+ let width = super::metrics::dimension(width).min(super::metrics::dimension(ui.available_width()));+ ui.allocate_ui_with_layout(vec2(width, Tokens::get().control_height), Layout::left_to_right(Align::Center), add).inner+}++/// A small numeric control, using the same number editor and geometry as every form.+pub(crate) fn settings_number<T: egui::emath::Numeric>(ui: &mut Ui, value: &mut T, range: std::ops::RangeInclusive<T>, speed: f64) -> egui::Response {+ ui.scope(|ui| {+ let t = Tokens::get();+ ui.spacing_mut().interact_size.x = t.form_label_width - t.space_6;+ super::number_field(ui, value, range, speed, "")+ })+ .inner+}++/// An illustrative half-hour of autosave marks, using the actual configured interval.+pub(crate) fn settings_autosave_timeline(ui: &mut Ui, minutes: f64) {+ let t = Tokens::get();+ let (r, _) = ui.allocate_exact_size(vec2(super::metrics::dimension(ui.available_width()), t.space_24 + t.space_12 + t.space_2), Sense::hover());+ let line = r;+ ui.painter().hline(line.x_range(), r.top() + t.space_10, Stroke::new(2.0, t.dialog_rule));+ if minutes.is_finite() && minutes > 0.0 {+ let ticks = (30.0 / minutes).floor().clamp(0.0, 60.0) as u32;+ for i in 0..=ticks {+ let x = line.right() - line.width() * (f64::from(i) * minutes / 30.0) as f32;+ ui.painter().vline(x, r.top() + t.space_4..=r.top() + t.space_16, Stroke::new(2.0, t.form_primary));+ }+ }+ for (share, key) in [(0.0, "prefs.timeline_half_hour"), (0.5, "prefs.timeline_quarter_hour"), (1.0, "prefs.timeline_now")] {+ ui.painter().text(+ pos2(line.left() + line.width() * share, r.top() + t.space_24),+ if share == 0.0 {+ egui::Align2::LEFT_TOP+ } else if share == 1.0 {+ egui::Align2::RIGHT_TOP+ } else {+ egui::Align2::CENTER_TOP+ },+ crate::i18n::tr(key),+ FontId::proportional(t.font_small),+ t.form_dim,+ );+ }+}++/// A keyboard binding table: keycaps are separate from actions and never imply fixed bindings.+pub(crate) fn settings_bindings(ui: &mut Ui, bindings: &[(&[&str], &str)]) {+ let t = Tokens::get();+ for (keys, action) in bindings {+ let width = super::metrics::dimension(ui.available_width());+ let (r, _) = ui.allocate_exact_size(vec2(width, t.control_height + t.space_2), Sense::hover());+ ui.painter().hline(r.x_range(), r.bottom(), Stroke::new(1.0, t.dialog_rule));+ let mut left = r.left();+ for key in *keys {+ let galley = ui.painter().layout_no_wrap((*key).into(), FontId::proportional(t.font_small), t.form_ink);+ let key_rect = Rect::from_center_size(+ pos2(left + (galley.size().x + t.space_12) * 0.5, r.center().y),+ vec2(galley.size().x + t.space_12, t.control_height - t.space_8),+ );+ ui.painter().rect(key_rect, t.radius_sm, t.control_fill, Stroke::new(1.0, t.control_border), egui::StrokeKind::Inside);+ ui.painter().galley(key_rect.center() - galley.size() * 0.5, galley, t.form_ink);+ left = key_rect.right() + t.space_4;+ }+ let text_rect = Rect::from_min_max(pos2(r.left() + (t.space_24 * 8.0 + t.space_8).min(width * 0.45) + t.space_10, r.top()), r.max);+ ui.scope_builder(egui::UiBuilder::new().max_rect(text_rect).layout(Layout::left_to_right(Align::Center)), |ui| {+ super::text(ui, action, super::Text::Inline);+ });+ }+}++/// Natural-width, dim monospaced numeric specimen beside a precision control.+pub(crate) fn settings_precision_sample(ui: &mut Ui, text: &str) {+ let t = Tokens::get();+ let galley = ui.painter().layout_no_wrap(text.to_owned(), FontId::monospace(t.font_body), t.form_dim);+ let (r, response) = ui.allocate_exact_size(galley.size(), Sense::hover());+ response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), text));+ ui.painter().galley(r.min, galley, t.form_dim);+}diff --git a/crates/ui-egui/src/ui_kit/reports.rs b/crates/ui-egui/src/ui_kit/reports.rsindex e5103f6b09..e52f5f4e06 100644--- a/crates/ui-egui/src/ui_kit/reports.rs+++ b/crates/ui-egui/src/ui_kit/reports.rs@@ -72,7 +72,10 @@ pub(crate) fn empty_box(ui: &mut Ui, key: &str, message: &str) {let t = Tokens::get();let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width().max(0.0), t.control_height * 3.0), egui::Sense::hover());response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), message));- let points = [rect.left_top(), rect.right_top(), rect.right_bottom(), rect.left_bottom(), rect.left_top()];+ let mut points = super::preferences::rounded_perimeter(rect.shrink(0.5), f32::from(t.radius_lg));+ if let Some(first) = points.first().copied() {+ points.push(first);+ }ui.painter().extend(egui::Shape::dashed_line(&points, egui::Stroke::new(1.0, t.control_border), t.space_4, t.space_3));ui.painter().text(rect.center(), egui::Align2::CENTER_CENTER, message, egui::FontId::proportional(t.font_label), t.form_dim);scenario::publish_rect(&format!("dialog:note:{key}"), rect);diff --git a/crates/ui-egui/src/ui_kit/shortcuts.rs b/crates/ui-egui/src/ui_kit/shortcuts.rsnew file mode 100644index 0000000000..7e2f98060b--- /dev/null+++ b/crates/ui-egui/src/ui_kit/shortcuts.rs@@ -0,0 +1,102 @@+//! Search-and-actions toolbar shared by settings tables and command lists.+use crate::{icons, theme::Tokens};+use egui::{Align, FontId, Rect, Response, Sense, Stroke, Ui, pos2, vec2};++pub(crate) struct SearchAction<'a> {+ pub label: &'a str,+ pub icon: Option<&'a str>,+ pub visible: bool,+ pub tooltip: Option<&'a str>,+}++/// One expanding search input followed by measured, untruncated action buttons.+/// Narrow hosts scroll the row horizontally rather than wrapping actions below its filter.+pub(crate) fn search_actions_row(+ ui: &mut Ui,+ id: egui::Id,+ value: &mut String,+ hint: &str,+ actions: &[SearchAction<'_>],+) -> (Response, Option<usize>) {+ let t = Tokens::get();+ let action_width: f32 = actions+ .iter()+ .filter(|a| a.visible)+ .map(|a| {+ let text = super::ContentWidth::label(ui, a.label);+ let padding = if a.icon.is_some() { t.space_10 * 2.0 + t.space_14 + t.space_6 } else { ui.spacing().button_padding.x * 2.0 };+ text + padding + t.space_8+ })+ .sum();+ let width = super::metrics::dimension(ui.available_width());+ let minimum = t.form_label_width * 2.0 + action_width;+ let shown = egui::ScrollArea::horizontal().id_salt(id.with("actions_scroll")).auto_shrink([false, true]).show(ui, |ui| {+ ui.horizontal(|ui| {+ ui.spacing_mut().item_spacing.x = t.space_8;+ let filter_width = (width.max(minimum) - action_width).max(0.0);+ let response = ui+ .allocate_ui_with_layout(vec2(filter_width, t.control_height), egui::Layout::left_to_right(Align::Center), |ui| {+ search_with_icon(ui, id, value, hint)+ })+ .inner;+ let mut action = None;+ for (index, item) in actions.iter().enumerate().filter(|(_, a)| a.visible) {+ let response = if let Some(icon) = item.icon {+ super::icon_label_button(ui, item.label, icon, true, false)+ } else {+ super::button(ui, item.label, super::Button::Normal)+ };+ let response = if let Some(tooltip) = item.tooltip { response.on_hover_text(tooltip) } else { response };+ if response.clicked() {+ action = Some(index);+ }+ }+ (response, action)+ })+ .inner+ });+ shown.inner+}++/// Native text editing with the same token frame and leading magnifier as command search.+fn search_with_icon(ui: &mut Ui, id: egui::Id, value: &mut String, hint: &str) -> Response {+ let t = Tokens::get();+ let (r, frame) = ui.allocate_exact_size(vec2(super::metrics::dimension(ui.available_width()), t.control_height), Sense::click());+ let focused = ui.memory(|m| m.has_focus(id));+ ui.painter().rect(+ r,+ t.control_radius,+ t.control_fill,+ Stroke::new(1.0, if focused { t.form_primary } else { t.control_border }),+ egui::StrokeKind::Inside,+ );+ let icon = Rect::from_center_size(pos2(r.left() + t.space_8 + t.space_16 * 0.5, r.center().y), vec2(t.space_16, t.space_16));+ icons::paint_ink(ui.painter(), icon, "zoom", t.form_dim);+ let editor = Rect::from_min_max(pos2((icon.right() + t.space_6).min(r.right()), r.top()), r.right_bottom());+ let response = ui+ .scope_builder(egui::UiBuilder::new().max_rect(editor), |ui| {+ ui.set_clip_rect(ui.clip_rect().intersect(editor));+ ui.add_sized(+ editor.size(),+ super::fields::text_input(egui::TextEdit::singleline(value))+ .id(id)+ .hint_text(crate::i18n::tr_label(hint))+ .font(FontId::proportional(t.font_label))+ .text_color(t.form_ink)+ .margin(vec2(t.space_4, 0.0))+ .clip_text(true)+ .frame(egui::Frame::NONE),+ )+ })+ .inner;+ if frame.clicked() {+ response.request_focus();+ }+ super::layout::publish(ui, &response, egui::WidgetType::TextEdit);+ response.widget_info(|| {+ let mut info = egui::WidgetInfo::labeled(egui::WidgetType::TextEdit, ui.is_enabled(), crate::i18n::tr_label(hint));+ info.current_text_value = Some(value.clone());+ info+ });+ response+}diff --git a/crates/ui-egui/src/update.rs b/crates/ui-egui/src/update.rsindex f87ec6fe64..3c0cde8451 100644--- a/crates/ui-egui/src/update.rs+++ b/crates/ui-egui/src/update.rs@@ -940,28 +940,26 @@ enum State {pub fn prefs_rows(app: &mut SolveApp, ui: &mut egui::Ui) {let can = available(app);let kind = app.updater.kind().clone();- ui_kit::row(ui, crate::i18n::tr("update.prefs_label"), |ui| {- ui.add_enabled_ui(can, |ui| ui_kit::checkbox(ui, crate::i18n::tr("update.check_automatically"), &mut app.preferences.check_updates));- });- ui.horizontal(|ui| {+ ui.add_enabled_ui(can, |ui| ui_kit::checkbox(ui, crate::i18n::tr("update.check_automatically"), &mut app.preferences.check_updates));+ ui.horizontal_wrapped(|ui| {let busy = app.updater.status == Status::Checking;+ let (status, warning) = match (&app.updater.status, offered_or_newer(app)) {+ _ if !can => (String::new(), false),+ (Status::Checking, _) => (crate::i18n::tr("update.checking").to_string(), false),+ (Status::Failed(e), _) => (crate::i18n::format("update.failed", &[("error", e)]), true),+ (_, Some(v)) => (crate::i18n::format("update.available", &[("version", &v)]), false),+ (Status::UpToDate, None) => (crate::i18n::tr("update.up_to_date").to_string(), false),+ (Status::Idle, None) => (String::new(), false),+ };+ if !status.is_empty() {+ ui_kit::settings_badge(ui, &status, warning);+ }let r = ui_kit::button(ui, crate::i18n::tr("update.check_now"), ui_kit::Button::Enabled(can && !busy));crate::scenario::publish_rect("prefs:check_now", r.rect);if r.clicked() {let ctx = ui.ctx().clone();check_now(app, &ctx);}- let status = match (&app.updater.status, offered_or_newer(app)) {- _ if !can => String::new(),- (Status::Checking, _) => crate::i18n::tr("update.checking").to_string(),- (Status::Failed(e), _) => crate::i18n::format("update.failed", &[("error", e)]),- (_, Some(v)) => crate::i18n::format("update.available", &[("version", &v)]),- (Status::UpToDate, None) => crate::i18n::tr("update.up_to_date").to_string(),- (Status::Idle, None) => String::new(),- };- if !status.is_empty() {- ui_kit::text(ui, &status, ui_kit::Text::Inline);- }});let note = if can {crate::i18n::format("update.prefs_note", &[("version", current_version()), ("kind", kind.label())])@@ -970,7 +968,7 @@ pub fn prefs_rows(app: &mut SolveApp, ui: &mut egui::Ui) {} else {crate::i18n::format("update.prefs_dev", &[("version", current_version())])};- ui_kit::text(ui, ¬e, ui_kit::Text::Note("updates"));+ ui_kit::text(ui, ¬e, ui_kit::Text::Hint("updates"));if let Some(v) = offered_or_newer(app)&& offered(app).is_none()&& ui_kit::button(ui, crate::i18n::format("update.show", &[("version", &v)]), ui_kit::Button::Normal).clicked()diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex bbbf4d2423..62aa0e1e68 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -7176,10 +7176,11 @@ mod tests {let mut h = crate::scenario::Harness::new();h.app.home.open = false;let keys = |app: &SolveApp| (scene_key(app), highlight_key(app));- h.call("ui.prefs", json!({"open": "Graphics"}));- assert!(h.widget("Colour vision").is_some() && h.widget("Mode").is_some());+ h.call("ui.prefs", json!({"open": "Interface"}));+ crate::prefs::reveal_preference(&mut h, "prefs:color_vision");+ assert!(h.widget("Colour vision").is_some() && h.widget("Off").is_some() && h.widget("Deutan").is_some());let before = keys(&h.app);- h.call("ui.prefs", json!({"color_vision": "deutan"}));+ h.step(&json!({"click":{"handle":"dialog:Mode:Deutan"}})).unwrap();h.frame();assert_eq!(crate::theme::vision(), ColorVision::Deutan);assert_eq!(Tokens::get(), Tokens::themed(crate::theme::is_dark(), ColorVision::Deutan));diff --git a/crates/ui-egui/tests/scenarios/colour_vision_setting.json b/crates/ui-egui/tests/scenarios/colour_vision_setting.jsonindex bad0d850d2..96c2429c08 100644--- a/crates/ui-egui/tests/scenarios/colour_vision_setting.json+++ b/crates/ui-egui/tests/scenarios/colour_vision_setting.json@@ -1,22 +1,26 @@[- {"note": "#778: Preferences › Graphics › Colour vision. A mode applies at once, Cancel puts it back, OK keeps it, Restore Defaults on Graphics resets it, and the window keeps its size. The accessibility controls sit above the longer rendering-quality rows, so nothing here needs scrolling."},+ {"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": "Graphics"},- {"expect": {"shown": "Colour vision", "prefs": {"dialog": "Graphics"}, "same_width": "prefs:window"}},- {"click": {"handle": "prefs:color_vision"}},+ {"widget": "Interface"},+ {"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}},+ {"call": "ui.inspect", "params": {}},+ {"expect": {"shown": "Colour vision", "prefs": {"dialog": "Interface"}, "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": "Graphics"},- {"click": {"handle": "prefs:color_vision"}},+ {"widget": "Interface"},+ {"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": "Graphics"},+ {"widget": "Interface"},+ {"call": "ui.scroll", "params": {"x": 1000, "y": 500, "delta": -5000}},+ {"call": "ui.inspect", "params": {}},{"expect": {"shown": "Tritan", "same_width": "prefs:window"}},{"widget": "Restore Defaults"},{"expect": {"prefs": {"color_vision": "off"}}},diff --git a/crates/ui-egui/tests/scenarios/prefs_theme_files.json b/crates/ui-egui/tests/scenarios/prefs_theme_files.jsonindex 58ad0edc81..8dff61bb49 100644--- a/crates/ui-egui/tests/scenarios/prefs_theme_files.json+++ b/crates/ui-egui/tests/scenarios/prefs_theme_files.json@@ -1,16 +1,14 @@[- {"note": "#2255: the Theme list offers the built-in theme files (Gruvbox, SolidCraft 95, …) after Dark, Light and System; picking one applies at once, Cancel puts the theme back."},+ {"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}}},- {"click": {"handle": "prefs:theme"}},- {"click": {"handle": "prefs:theme:gruvbox-light-soft"}},- {"expect": {"prefs": {"theme": "gruvbox-light-soft", "dark": false}, "shown_handles": ["prefs:theme"], "hidden_handles": ["prefs:theme:dark"]}},- {"click": {"handle": "prefs:theme"}},+ {"widget": "Interface"},+ {"click": {"handle": "prefs:theme:light"}},+ {"expect": {"prefs": {"theme": "light", "dark": false}, "shown_handles": ["prefs:theme"]}},{"click": {"handle": "prefs:theme:gruvbox-dark"}},{"expect": {"prefs": {"theme": "gruvbox-dark", "dark": true}}},- {"click": {"handle": "prefs:theme"}},- {"click": {"handle": "prefs:theme:solidcraft-95"}},- {"expect": {"prefs": {"theme": "solidcraft-95", "dark": false}}},+ {"click": {"handle": "prefs:theme:light"}},+ {"expect": {"prefs": {"theme": "light", "dark": false}}},{"widget": "Cancel"},{"expect": {"prefs": {"dialog": null, "theme": "dark", "dark": true}}}]diff --git a/crates/ui-egui/tests/scenarios/s45_preferences.json b/crates/ui-egui/tests/scenarios/s45_preferences.jsonindex 1c5ea2749d..7f11e0c56c 100644--- a/crates/ui-egui/tests/scenarios/s45_preferences.json+++ b/crates/ui-egui/tests/scenarios/s45_preferences.json@@ -2,6 +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"},{"click": {"handle": "prefs:theme"}},{"click": {"handle": "prefs:theme:light"}},{"expect": {"prefs": {"theme": "light", "dark": false}}},@@ -10,7 +11,7 @@{"note": "Ctrl+, opens it again; the shortcuts page is in the same dialog."},{"key": "Comma", "cmd": true},{"expect": {"prefs": {"dialog": "General"}}},- {"widget": "Keyboard Shortcuts"},+ {"widget": "Shortcuts"},{"expect": {"shown": "Reset All", "prefs": {"dialog": "Keyboard Shortcuts"}}},{"widget": "Navigation"},{"widget": "Fusion"},diff --git a/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json b/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.jsonindex 88914283e5..87a2316d13 100644--- a/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json+++ b/crates/ui-egui/tests/scenarios/s46_preferences_fixed_size.json@@ -2,21 +2,25 @@{"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": "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": "Keyboard Shortcuts"},+ {"widget": "Shortcuts"},{"expect": {"prefs": {"dialog": "Keyboard 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"},+ {"widget": "Sketch & selection"},{"expect": {"prefs": {"dialog": "Sketch"}, "same_width": "prefs:window", "right_edge": {"inner": "prefs:ok", "outer": "prefs:actions", "tol": 1}}},- {"widget": "Selection"},- {"expect": {"prefs": {"dialog": "Selection"}, "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}}},+ {"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}}},{"widget": "Cancel"},diff --git a/crates/ui-egui/tests/window_widths.rs b/crates/ui-egui/tests/window_widths.rsindex f80d87fa66..06a9375d92 100644--- a/crates/ui-egui/tests/window_widths.rs+++ b/crates/ui-egui/tests/window_widths.rs@@ -19,8 +19,11 @@ fn window_widths(h: &Harness) -> Vec<(egui::Id, f32)> {}fn kit_table_limit(id: egui::Id) -> Option<f32> {+ // The accepted Preferences board has a page list and one control/preview pair at 880 pt.+ if id == egui::Id::new("sc_prefs") {+ return Some(solidcraft_ui_egui::theme::Tokens::get().form_card_width * 10.0 / 3.0);+ }[- egui::Id::new("sc_prefs"),egui::Id::new("sc_bom"),egui::Id::new("sc_gesture_editor"),egui::Id::new("sc_params_dialog"),@@ -112,7 +115,7 @@ fn floating_windows_stay_within_limits() {// Keyboard Shortcuts is a page of Preferences (one window, #36).assert!(ws.len() >= 3, "windows on screen: {ws:?}");for (layer, w) in ws {- let limit = solidcraft_ui_egui::theme::Tokens::get().form_card_width * 3.0;+ let limit = kit_table_limit(layer).unwrap_or(solidcraft_ui_egui::theme::Tokens::get().form_card_width * 3.0);assert!(w <= limit + 4.0, "{layer:?} is {w} px wide");}}diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 1afc1e89e4..0fd84bd937 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -205,7 +205,7 @@ labels; `prefs:measure_axis_distances` identifies the checkbox.| `ui.home` | `open?`: bool; `sample?`: index | the start page: show or hide it, open a built-in sample (once built); returns `open` and the recent designs || `ui.shortcut` | `command`, `key?`, `replace?` | a command's key, or rebinds it (`""` clears; a key another command uses is refused unless `replace`) || `ui.help` | `item?`: `about`, `shortcuts` (read only), `report` (opens a report draft for review), `crashes` (the Crash Reports window) | the version, commit, build date and diagnostic text |-| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner; the view redraws every frame while it is on), `length_decimals`, `angle_decimals`, `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `check_updates` (default true; [updates](book/src/guide/updates.md)); `open` (a page: General, Navigation, Keyboard Shortcuts, Design, Graphics, Sketch, Selection, AI) opens the Preferences dialog there; `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 closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark` and `stand_up_offer` |+| `ui.prefs` | any of `default_units`, `nav` (`fusion`, `solidworks`, `inventor`, `alias`, `blender`, `tinkercad`, `openscad`, `touchpad`), `zoom_reverse`, `pan_reverse_x` (default false: horizontal scrolling pans the other way), `zoom_to_cursor`, `smooth_wheel_zoom` (default true), `trackpad_pan` (default true: two-finger scroll pans, except Touchpad always zooms; pinch zooms), `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true), `look_at_anim`, `look_at_speed`, `middle_double_click` (`home` (default), `fit`, `off`), `msaa`, `show_frame_rate` (default false: frames per second in the view's bottom-right corner; the view redraws every frame while it is on), `length_decimals`, `angle_decimals`, `theme` (`dark`, `light`, `system` or a theme file's id: a built-in one such as `gruvbox-dark`, or an imported one; the reply's `theme_ids` lists them), `theme_import` (a `solidcraft-theme/1` file's JSON or text: adds the theme and turns it on; the reply's `theme_imported` is its id), `theme_remove` (an imported theme's id), `theme_export: true` (the reply's `theme_file` is the theme on now as a complete file; see [colour themes](book/src/guide/ui-tour.md#colour-themes)), `language` (`en`, `ja`, `de`, `fr`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md)), `ui_scale`, `ui_font` (an installed font family or a font file for the interface; empty for the built-in font), `up_axis` (`z`, `y`), `offer_stand_up`, `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `check_updates` (default true; [updates](book/src/guide/updates.md)); `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; `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 closes and `offer_stand_up` stays on); the offer's buttons are the handles `stand_up:stand`, `stand_up:leave` and `stand_up:never` | sets preferences (kept between runs), returns them all plus `dialog` (the open page or null), `dark` and `stand_up_offer` || `ui.capture` | `action?`: `capture`, `revert`, `cancel` | answers the Capture Position question (asked when a command starts or the design is saved while components were moved without capturing); without `action`, what waits || `ui.window` | `action`: minimize, maximize, restore, toggle, close | what the title bar's caption buttons do (on Windows and Linux the application bar is the title bar); close asks about unsaved designs first || `ui.agent_cursor` | `show` (bool), `speed`: a number from 1 to 5 (times the normal speed) or `"instant"` (no animation: the command runs at once and the pointer jumps to where it acted), `follow_camera` (bool); all optional | the settings. While the cursor is shown, `engine.execute` first glides to the command's toolbar button and to each pick, then runs and replies; later requests wait their turn. `"animate": false` on a call skips it |diff --git a/docs/ui-container-audit.md b/docs/ui-container-audit.mdindex 2f580848b9..5a547ce213 100644--- a/docs/ui-container-audit.md+++ b/docs/ui-container-audit.md@@ -1,7 +1,7 @@# Layout-aware container auditShared container foundation (#4411) and compact composition (#2029), on top of-History #3953 and Assistant #3985. General preferences save Floating or Compact;+History #3953 and Assistant #3985. Interface preferences save Floating or Compact;`view.layout` changes the same preference without changing the design.## Ownershipdiff --git a/docs/ui-kit.md b/docs/ui-kit.mdindex 84d39bf878..9b6b2d7fcf 100644--- a/docs/ui-kit.md+++ b/docs/ui-kit.md@@ -31,9 +31,10 @@ preferences, manager cards, prompts, context menus and the sketch palette. Impor- `Window` composes the shared Panel frame with a 40 pt icon/title/close header,padded content and optional 48 pt footer. `show_with_left` pins a left action besidethe right-aligned buttons. `show_pages` accepts declarative `WindowPage` entries- (existing icon, i18n label key, stable handle, scroll policy and draw callback).+ (icon, i18n label key, optional group heading, stable handle, scroll policy and draw callback).Its 188 pt soft page list has 32 pt icon/label rows, selected tint/ink and a divider.- All nine existing Preferences pages retain their order, settings and handles.+ Preferences has nine grouped pages; legacy control-channel page names remain aliases.+ `page_rows` opts into a taller body while preserving viewport bounds.`actions`, `anchor`/`placed`, `cards`, `fields` and `keep_open_on_escape` retainexisting window behavior. Empty action labels omit the footer.- `Confirm` is an input-blocking modal using the same card frame and footer controls.@@ -56,6 +57,14 @@ preferences, manager cards, prompts, context menus and the sketch palette. Impor- Scenario handles and accessible labels are API. Consolidated options preservethe former geometry, wrapping, native metadata and publication keys.+Preference compositions use `settings_heading`, shared disclosure `settings_section` headings and+`settings_pair` for responsive controls beside one specimen. `option_card` supplies the+shared illustrated radio control. `settings_form` and `settings_block_hint` define aligned label grids; `theme_rail` keeps the import tile fixed beside a scrollbar-free scrolling row. `PreferenceFigure` owns theme swatches, orbit pivots,+quality, anti-aliasing, contact shading and up-axis figures. `layout_preview` follows the+four workspace choices without opening another viewport. Scale, palette, autosave, mouse+and live-axis specimens share tokens and the gallery; live bars show actual calibrated+input and introduce no repaint timer.+## ElementsModule names below describe implementation locations, not caller import paths.