From 436ee9509540cd786b6f05d94aa7a6f81758622b Mon Sep 17 00:00:00 2001 From: Jesper We Date: Mon, 26 Oct 2026 19:31:55 +0000 Subject: [PATCH] Preference: return to the previous view when a sketch ends (#7038) (#7043) * claim: #7038 * Preference: where the view goes when a sketch ends (#7038) --- assets/locales/pending/sketch-exit-view.json | 23 ++++ crates/ui-egui/src/dialogs.rs | 6 +- crates/ui-egui/src/documents.rs | 3 + crates/ui-egui/src/lib.rs | 35 ++++- crates/ui-egui/src/prefs.rs | 50 +++++++ crates/ui-egui/src/prefs/sketch.rs | 18 +++ crates/ui-egui/src/sketch_edit_tests.rs | 129 +++++++++++++++++++ docs/book/src/guide/sketching.md | 2 + docs/control-protocol.md | 2 +- 9 files changed, 264 insertions(+), 4 deletions(-) create mode 100644 assets/locales/pending/sketch-exit-view.json diff --git a/assets/locales/pending/sketch-exit-view.json b/assets/locales/pending/sketch-exit-view.json new file mode 100644 index 000000000..705959c89 --- /dev/null +++ b/assets/locales/pending/sketch-exit-view.json @@ -0,0 +1,23 @@ +{ + "en": { + "prefs.sketch_exit_view": "When a sketch ends", + "prefs.sketch_exit_view_note": "Where the view goes after Finish Sketch, Cancel or a double Esc.", + "prefs.sketch_exit_view.keep": "Keep the current view", + "prefs.sketch_exit_view.previous": "Return to the previous view", + "prefs.sketch_exit_view.unless_rotated": "Return unless rotated" + }, + "ja": { + "prefs.sketch_exit_view": "スケッチ終了時のビュー", + "prefs.sketch_exit_view_note": "「スケッチを終了」、キャンセル、Esc の 2 回押しの後にビューが移る先です。", + "prefs.sketch_exit_view.keep": "現在のビューを維持", + "prefs.sketch_exit_view.previous": "前のビューに戻る", + "prefs.sketch_exit_view.unless_rotated": "回転していなければ戻る" + }, + "zh": { + "prefs.sketch_exit_view": "草图结束时的视图", + "prefs.sketch_exit_view_note": "“完成草图”、取消或连按两次 Esc 后视图的去向。", + "prefs.sketch_exit_view.keep": "保持当前视图", + "prefs.sketch_exit_view.previous": "返回之前的视图", + "prefs.sketch_exit_view.unless_rotated": "未旋转时返回" + } +} diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 4171f0bba..4bce5c97d 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -2921,9 +2921,10 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) { && let Some(mut plane) = crate::sketch_attachment_ui::face_plane(app, sel) { plane["fixed"] = json!(true); + let before = app.settled_cam(); match app.run("sketch.create", json!({"plane":plane})) { Ok(_) => { - look_at_sketch(app); + app.look_at_opened_sketch(before); cancel = true; then_start = d.then_start; } @@ -3330,8 +3331,9 @@ pub fn start_sketch(app: &mut SolveApp, sel: &Sel) -> Result<(), String> { { params["flip"] = json!(flip); } + let before = app.settled_cam(); app.run("sketch.create", params).map_err(|error| crate::friendly_error("sketch.create", &error))?; - look_at_sketch(app); + app.look_at_opened_sketch(before); // On a face: look at the picked point, not the plane's origin (a corner of the face), // which left the face filling the view off-centre like a big square. if let Sel::Face { point, .. } = sel diff --git a/crates/ui-egui/src/documents.rs b/crates/ui-egui/src/documents.rs index 4d0e3a411..01b15a703 100644 --- a/crates/ui-egui/src/documents.rs +++ b/crates/ui-egui/src/documents.rs @@ -26,6 +26,7 @@ pub struct DocSlot { cam: Camera, pre_sketch_marker: Option>, pub(crate) pending_feature_edit: Option, + pre_sketch_cam: Option, view: DocView, occurrence_move: Option, agent_chat: crate::agent_chat::AgentChat, @@ -47,6 +48,7 @@ impl DocSlot { cam: Camera::default(), pre_sketch_marker: None, pending_feature_edit: None, + pre_sketch_cam: None, view: DocView::default(), occurrence_move: None, agent_chat: Default::default(), @@ -129,6 +131,7 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot { cam: std::mem::replace(&mut app.cam, slot.cam), pre_sketch_marker: std::mem::replace(&mut app.pre_sketch_marker, slot.pre_sketch_marker), pending_feature_edit: std::mem::replace(&mut app.pending_feature_edit, slot.pending_feature_edit), + pre_sketch_cam: std::mem::replace(&mut app.pre_sketch_cam, slot.pre_sketch_cam), view: take_view(app), occurrence_move: std::mem::replace(&mut app.tree.occurrence_move, slot.occurrence_move), agent_chat: slot.agent_chat, diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index dc07d49b9..1db08855f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -401,6 +401,14 @@ pub struct Services { pub secrets: Option>, } +/// The view before a sketch opened and the view that faced the sketch then (#7038). +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct PreSketchView { + pub sketch: u64, + pub before: Camera, + pub facing: Camera, +} + pub struct SolveApp { /// Compact browser embed: retain model panels and joint controls without application chrome. pub embedded: bool, @@ -415,6 +423,9 @@ pub struct SolveApp { /// The history marker before Edit Sketch rolled the timeline to the sketch; Finish Sketch /// restores it. pub pre_sketch_marker: Option>, + /// The views around opening the open sketch. Leaving it goes back to the earlier one as the + /// "When a sketch ends" preference says (#7038). + pub pre_sketch_cam: Option, pub services: Services, file_picker: Option, /// A Save or Save As being written on a worker (see [`save_job`]). @@ -612,6 +623,7 @@ impl SolveApp { cam_anim: None, now: 0.0, pre_sketch_marker: None, + pre_sketch_cam: None, services, file_picker: None, saving: None, @@ -1470,6 +1482,7 @@ impl SolveApp { } let Some(idx) = self.session.doc.feature_index(id) else { return }; let marker = self.finish_sketch_for_edit(); + let before = self.settled_cam(); self.tool = None; self.dialog = None; let rolled = self.session.doc.marker != Some(idx + 1) && self.run("timeline.roll_to", json!({ "position": idx + 1 })).is_ok(); @@ -1480,7 +1493,19 @@ impl SolveApp { return; } self.pre_sketch_marker = (rolled || marker != self.session.doc.marker).then_some(marker); + self.look_at_opened_sketch(before); + } + + /// Turn the view to face the sketch just opened, and remember the view from `before` it and + /// the one facing it for when the sketch ends (#7038). + pub(crate) fn look_at_opened_sketch(&mut self, before: Camera) { dialogs::look_at_sketch(self); + self.pre_sketch_cam = self.session.active_sketch.map(|sketch| PreSketchView { sketch, before, facing: self.settled_cam() }); + } + + /// Where the camera is going: the end of the running camera animation, else where it is. + pub(crate) fn settled_cam(&self) -> Camera { + self.cam_anim.map_or(self.cam, |a| a.to) } /// Pass the original marker to the next editor. Restoring it between editors could finish @@ -1498,7 +1523,8 @@ impl SolveApp { } /// Finish the active sketch: stop editing and restore the history marker Edit Sketch moved. - /// The camera stays where it is, however the sketch is left. + /// The camera goes where the "When a sketch ends" preference says (#7038); by default it + /// stays where it is, however the sketch is left. pub fn finish_sketch(&mut self) { self.leave_sketch("sketch.finish"); } @@ -1516,12 +1542,19 @@ impl SolveApp { } dim_view::cancel(); self.tool = None; + let open = self.session.active_sketch; if self.run(command, json!({})).is_err() && command != "sketch.finish" { return; } if let Some(marker) = self.pre_sketch_marker.take() { self.restore_marker(marker); } + // Only the views saved when this sketch opened: one opened another way saved none. + if let Some(view) = self.pre_sketch_cam.take().filter(|v| Some(v.sketch) == open) + && let Some(to) = self.preferences.sketch_exit_view.view_after(view.before, view.facing, self.settled_cam()) + { + self.animate_to(to); + } } fn restore_marker(&mut self, marker: Option) { diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index 3af5ecf1d..3d1629bdd 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; use serde_json::json; pub use solidcraft_engine::doc::display_units::{format_length, length_number, length_precision, unit_scale}; use solidcraft_engine::geom::Vec3; +use solidcraft_engine::render::Camera; /// The key the apps keep the preferences under in eframe's storage. pub const STORAGE_KEY: &str = "solidcraft.prefs"; @@ -331,6 +332,53 @@ pub enum OrbitAround { Cursor, } +/// Where the view goes when a sketch ends (Preferences: "When a sketch ends", #7038). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum SketchExitView { + /// Back to the view from before the sketch opened. + Previous, + /// The view stays where it is (the default since #4909). + #[default] + Keep, + /// Back to the view from before the sketch, unless the sketch view was turned: a view only + /// panned or zoomed goes back, a turned one stays. + UnlessRotated, +} + +impl SketchExitView { + pub const ALL: [Self; 3] = [Self::Previous, Self::Keep, Self::UnlessRotated]; + + /// The message id of the choice's label. + pub fn label_id(self) -> &'static str { + match self { + Self::Previous => "prefs.sketch_exit_view.previous", + Self::Keep => "prefs.sketch_exit_view.keep", + Self::UnlessRotated => "prefs.sketch_exit_view.unless_rotated", + } + } + + /// The view to turn to when a sketch ends with the camera at `now`, or `None` to leave it. + /// `before` is the view from before the sketch opened and `facing` the one it turned to then. + /// Going back keeps `now`'s projection, so a perspective switch made in the sketch stays. + pub fn view_after(self, before: Camera, facing: Camera, now: Camera) -> Option { + let back = Camera { fov: now.fov, ..before }; + match self { + Self::Previous => Some(back), + Self::Keep => None, + Self::UnlessRotated => same_orientation(facing, now).then_some(back), + } + } +} + +/// Whether two cameras look the same way: pans and zooms move a camera without turning it. +/// Half a degree absorbs rounding in the animation that turned the view to face the sketch. +fn same_orientation(a: Camera, b: Camera) -> bool { + let near = 0.5_f64.to_radians().cos(); + let ((ar, au, ab), (br, bu, bb)) = (a.basis(), b.basis()); + ar.dot(br) > near && au.dot(bu) > near && ab.dot(bb) > near +} + /// Which program reads the 3D mouse on Linux when both spacenavd and the device itself (hidraw) /// are there (Preferences: "3D mouse driver"). Read by the app's reader, not by this crate. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] @@ -687,6 +735,8 @@ preference_settings! { /// A sketch tool's shortcut pressed again before the first point steps to the tool's next /// creation mode (#2459). Off (the default): the key starts the tool again, as it always has. shortcut_cycles_modes: bool = false, PAGE_SKETCH; + /// Where the view goes when a sketch ends (#7038). Keep (the default) leaves it as it is. + sketch_exit_view: SketchExitView = SketchExitView::default(), 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, PAGE_SKETCH; diff --git a/crates/ui-egui/src/prefs/sketch.rs b/crates/ui-egui/src/prefs/sketch.rs index a7fbe5ec5..b3a85e5ff 100644 --- a/crates/ui-egui/src/prefs/sketch.rs +++ b/crates/ui-egui/src/prefs/sketch.rs @@ -25,6 +25,24 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) { }); }); }); + ui_kit::settings_block_hint( + ui, + app.tr("prefs.sketch_exit_view"), + app.tr("prefs.sketch_exit_view_note"), + t.space_24 * 8.0 + t.space_8, + |ui| { + let exit = &mut app.preferences.sketch_exit_view; + ui_kit::settings_control_width(ui, t.space_24 * 7.0 + t.space_12, |ui| { + ui_kit::dropdown_menu(ui, "pref_sketch_exit_view", crate::i18n::tr(exit.label_id()), |ui| { + for choice in SketchExitView::ALL { + if ui_kit::list_picker(ui, choice.label_id(), crate::i18n::tr(choice.label_id()), *exit == choice).clicked() { + *exit = 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.", )); diff --git a/crates/ui-egui/src/sketch_edit_tests.rs b/crates/ui-egui/src/sketch_edit_tests.rs index bb5241014..8c7fe7731 100644 --- a/crates/ui-egui/src/sketch_edit_tests.rs +++ b/crates/ui-egui/src/sketch_edit_tests.rs @@ -238,3 +238,132 @@ mod view_corner { assert!(scenario::rect_of("view:confirm").is_some(), "the pair answers the sketch again"); } } + +/// The "When a sketch ends" preference (#7038): back to the view from before the sketch, or back +/// only when the sketch view was panned or zoomed and not turned. Keep, the default, is above. +mod exit_view_preference { + use crate::prefs::SketchExitView; + use crate::scenario::Harness; + use serde_json::json; + use solidcraft_engine::render::Camera; + + /// A sketch on XY started from the iso view with `choice` set, and that iso view. + fn sketching(choice: SketchExitView) -> (Harness, Camera) { + let mut h = Harness::new(); + h.app.preferences.sketch_exit_view = choice; + h.call("ui.view", json!({"view": "iso"})); + h.settle(); + let iso = h.app.cam; + h.step(&json!({"start": "sketch.create"})).unwrap(); + h.step(&json!({"click": {"plane": "XY"}})).unwrap(); + h.settle(); + crate::scenario::check(&mut h, &json!({"sketching": true, "camera": {"yaw_deg": 0, "pitch_deg": 90}})).unwrap(); + (h, iso) + } + + fn pan_and_zoom(h: &mut Harness) { + h.app.cam.pan(25.0, 15.0, 800.0); + h.app.cam.zoom_at(0.5, None); + h.app.cam_anim = None; + } + + fn finish(h: &mut Harness) { + h.app.run("sketch.line", json!({"points": [[0, 0], [30, 10]]})).unwrap(); + h.app.finish_sketch(); + h.settle(); + assert_eq!(h.app.session.active_sketch, None); + } + + #[test] + fn keep_is_the_default() { + assert_eq!(crate::prefs::Prefs::default().sketch_exit_view, SketchExitView::Keep); + } + + #[test] + fn previous_goes_back_after_a_turn() { + let (mut h, iso) = sketching(SketchExitView::Previous); + h.app.cam.orbit(60.0, -40.0); + pan_and_zoom(&mut h); + finish(&mut h); + assert_eq!(h.app.cam, iso); + } + + #[test] + fn unless_rotated_goes_back_after_only_panning_and_zooming() { + let (mut h, iso) = sketching(SketchExitView::UnlessRotated); + pan_and_zoom(&mut h); + finish(&mut h); + assert_eq!(h.app.cam, iso); + } + + #[test] + fn unless_rotated_keeps_a_turned_view() { + let (mut h, _) = sketching(SketchExitView::UnlessRotated); + h.app.cam.orbit(60.0, -40.0); + pan_and_zoom(&mut h); + let cam = h.app.cam; + finish(&mut h); + assert_eq!(h.app.cam, cam); + } + + #[test] + fn double_escape_and_cancel_go_back_too() { + let (mut h, iso) = sketching(SketchExitView::Previous); + h.app.cam.orbit(60.0, -40.0); + h.app.cam_anim = None; + h.step(&json!({"key": "Escape"})).unwrap(); + h.step(&json!({"key": "Escape"})).unwrap(); + h.settle(); + assert_eq!(h.app.session.active_sketch, None); + assert_eq!(h.app.cam, iso, "double Esc"); + + let (mut h, iso) = sketching(SketchExitView::Previous); + h.app.run("sketch.line", json!({"points": [[0, 0], [30, 10]]})).unwrap(); + h.app.cam.orbit(60.0, -40.0); + h.app.cam_anim = None; + h.app.cancel_sketch(); + h.settle(); + assert_eq!(h.app.session.active_sketch, None); + assert_eq!(h.app.cam, iso, "Cancel"); + } + + #[test] + fn editing_a_sketch_goes_back_to_the_view_before_the_edit() { + let mut app = crate::test_support::sample_app(); + app.preferences.sketch_exit_view = SketchExitView::Previous; + let id = super::first_sketch(&app); + let before = app.cam; + app.edit_sketch(id); + let facing = app.cam_anim.take().map(|a| a.to).unwrap(); + app.cam = facing; + app.finish_sketch(); + assert_eq!(app.settled_cam(), before); + } + + #[test] + fn a_sketch_opened_by_a_command_leaves_the_view_alone() { + let (mut h, _) = sketching(SketchExitView::Previous); + // Finished by the command, so the views saved for this sketch stay behind. + h.app.run("sketch.finish", json!({})).unwrap(); + assert!(h.app.pre_sketch_cam.is_some()); + h.app.run("sketch.create", json!({"plane": "XZ"})).unwrap(); + h.app.cam.orbit(60.0, -40.0); + h.app.cam_anim = None; + let cam = h.app.cam; + finish(&mut h); + assert_eq!(h.app.cam, cam, "the views saved for the earlier sketch don't apply"); + } + + #[test] + fn going_back_keeps_the_current_projection() { + let before = Camera::default(); + let facing = Camera { yaw: 0.0, pitch: std::f64::consts::FRAC_PI_2, ..before }; + let now = Camera { fov: 0.6, distance: 80.0, ..facing }; + for choice in [SketchExitView::Previous, SketchExitView::UnlessRotated] { + assert_eq!(choice.view_after(before, facing, now), Some(Camera { fov: 0.6, ..before }), "{choice:?}"); + } + assert_eq!(SketchExitView::Keep.view_after(before, facing, now), None); + let turned = Camera { yaw: 0.2, ..now }; + assert_eq!(SketchExitView::UnlessRotated.view_after(before, facing, turned), None); + } +} diff --git a/docs/book/src/guide/sketching.md b/docs/book/src/guide/sketching.md index 45a8a5867..64550f518 100644 --- a/docs/book/src/guide/sketching.md +++ b/docs/book/src/guide/sketching.md @@ -7,6 +7,8 @@ plane, in the view or on its browser row, offers **Create Sketch** on that plane keeping what changed since the sketch was created or opened for editing: a new sketch is removed, an edited one goes back to how it was, as one step that Undo brings back. +Opening a sketch turns the view to face it. When the sketch ends, the view stays where it is by default. Preferences › Sketch › **When a sketch ends** changes that: **Return to the previous view** goes back to the view from before the sketch, and **Return unless rotated** goes back only when you panned or zoomed the sketch view but didn't turn it. + In scripts, `XY`, `XZ`, `YZ` and their `Top`, `Front`, `Right` aliases name origin planes. These names are reserved: a construction plane cannot be created with or renamed to one (case-insensitive). If an older design already has a construction plane with such a name, a diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 6138e758b..bc732274a 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -303,7 +303,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, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `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), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `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`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `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`, `viewport_dark` (whether the 3D view is 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), `sketch_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned)), `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, counting the frames the view draws anyway; it reads 0 FPS once the view is idle), `window_system` (Linux: `auto` (default: XWayland whenever there is an X display, native Wayland on niri), `wayland`, `x11`; saved in `graphics.json`, applies at the next start; `SOLIDCRAFT_WAYLAND` overrides it), `graphics_adapter` (exact card name, or empty for Automatic; applies after restart; `WGPU_ADAPTER_NAME` takes precedence), `frame_rate_details` (default false: with the frame rate, a frame-time graph of the frames drawn with the triangles over it, a frame-time histogram and what the GPU drew; clicking the readout switches it), `length_decimals`, `angle_decimals`, `step_values` (default false: Up/Down and the wheel step a plain number in a focused value field), `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), `viewport_theme` (`theme` (default: the theme's own), `light`, `dark`: the 3D view in the Light or Dark theme's colours whatever the window uses, #4146), `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`, `extrude_auto_to_object` (default false: in the Extrude dialog, with a profile picked, a face, vertex or parallel plane picked off its plane switches the extent to To Object; it applies to Extrude dialogs opened afterwards), `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres), `hole_moves` (default false: a placed Single hole has a drag handle (`hole:`), and a pick on a face that has a hole moves it there), `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it), `color_vision` (`off` (default), `protan`, `deutan`, `tritan`: colour vision modes, #778), `view_confirm_corner` (default false: while a dialog or a sketch is open, a check and a cross at the view's top right, handles `view:confirm:ok` and `view:confirm:cancel`, do what the dialog's OK and Cancel do, or Finish Sketch and Cancel Sketch; the axis view or cube moves down below them, #6709), `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`, `viewport_dark` (whether the 3D view is 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. The pointer shows the command's localized name, including commands inside a closed toolbar group; an animated batch names each command it visits. It also follows the pointer input sent with `ui.move`, `ui.click`, `ui.drag` and `ui.scroll`, as each event reaches the app, and a press leaves a ripple. `"animate": false` on a call skips it |