Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Dialogs: OK and Cancel at the top (#6708) (#6713)

Lars Jansen2d629069c6bb
diff --git a/assets/locales/pending/dialog-buttons-top.json b/assets/locales/pending/dialog-buttons-top.json
new file mode 100644
index 0000000000..d311acd339
--- /dev/null
+++ b/assets/locales/pending/dialog-buttons-top.json
@@ -0,0 +1,18 @@
+{
+ "en": {
+ "prefs.dialog_buttons": "Dialog buttons",
+ "prefs.top": "Top"
+ },
+ "ja": {
+ "prefs.dialog_buttons": "ダイアログのボタン",
+ "prefs.top": "上"
+ },
+ "ko": {
+ "prefs.dialog_buttons": "대화 상자 버튼",
+ "prefs.top": "위쪽"
+ },
+ "zh": {
+ "prefs.dialog_buttons": "对话框按钮",
+ "prefs.top": "顶部"
+ }
+}
diff --git a/crates/ui-egui/src/dialogs_all_tests.rs b/crates/ui-egui/src/dialogs_all_tests.rs
index 8bcb85968b..bf25da5030 100644
--- a/crates/ui-egui/src/dialogs_all_tests.rs
+++ b/crates/ui-egui/src/dialogs_all_tests.rs
@@ -481,6 +481,85 @@ fn remaining_dialogs_keep_kit_chrome_and_cancel_restores_preview() {
}
}
+/// Interface › Dialog buttons › Top (#6708): every card made by the shared panel moves its
+/// actions into the header row, with the footer's enabled states, handles and close behaviour.
+#[test]
+fn top_dialog_buttons_keep_every_cards_states_handles_and_close() {
+ for command in [
+ "solid.revolve",
+ "solid.shell",
+ "solid.box",
+ "joint.create",
+ "solid.thread",
+ "inspect.measure",
+ "contact.create",
+ "motion.study",
+ "explode.create",
+ "parts.insert",
+ "joint.drive",
+ "inspect.interference",
+ "file.save_mesh",
+ "file.export_view_dxf",
+ "sheet.flat_pattern",
+ ] {
+ let mut seen = Vec::new();
+ for placement in ["bottom", "top"] {
+ let mut h = fixture();
+ h.call("ui.resize", json!({"width":1600,"height":1200}));
+ h.call("ui.prefs", json!({"dialog_buttons": placement}));
+ let design = h.app.session.doc.to_json();
+ h.app.start(command);
+ h.frames(4);
+ let header = scenario::rect_of("dialog:header").unwrap_or_else(|| panic!("{command} {placement}: no header"));
+ let cancel = scenario::handle_at("dialog:cancel").unwrap_or_else(|| panic!("{command} {placement}: no cancel"));
+ seen.push((
+ scenario::count_of("dialog:ok:enabled"),
+ scenario::rect_of("dialog:ok").is_some(),
+ scenario::rect_of("dialog:apply").is_some(),
+ ));
+ if placement == "top" {
+ assert!(scenario::rect_of("dialog:footer").is_none(), "{command}: no footer row");
+ assert!(header.contains(cancel), "{command}: cancel in the header {header:?}");
+ assert!(scenario::rect_of("dialog:ok").is_none_or(|ok| header.contains_rect(ok)), "{command}: OK in the header");
+ assert_eq!(scenario::handle_at("dialog:close"), Some(cancel), "{command}: Cancel is the close");
+ } else {
+ assert!(scenario::rect_of("dialog:footer").unwrap().contains(cancel), "{command}: cancel in the footer");
+ }
+ h.step(&json!({"click":{"handle":"dialog:close"}})).unwrap();
+ assert!(h.app.dialog.is_none(), "{command} {placement}: closed");
+ assert_eq!(h.app.session.doc.to_json(), design, "{command} {placement}: closing keeps the design");
+ }
+ assert_eq!(seen.first(), seen.get(1), "{command}: OK and Apply as at the bottom");
+ }
+}
+
+/// With the buttons at the top, OK, Enter and Esc do what they do with them at the bottom.
+#[test]
+fn top_dialog_buttons_apply_and_cancel_like_the_footer() {
+ for how in ["click", "enter", "escape"] {
+ let mut h = fixture();
+ h.call("ui.resize", json!({"width":1600,"height":1200}));
+ h.call("ui.prefs", json!({"dialog_buttons": "top"}));
+ h.app.dialog = Some(representative(&h, "solid.revolve"));
+ h.settle();
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(1.0));
+ let (design, bodies) = (h.app.session.doc.to_json(), h.app.session.world_state().bodies.len());
+ let step = match how {
+ "click" => json!({"click":{"handle":"dialog:OK"}}),
+ "enter" => json!({"key":"Enter"}),
+ _ => json!({"key":"Escape"}),
+ };
+ h.step(&step).unwrap();
+ h.settle();
+ assert!(h.app.dialog.is_none(), "{how}: the dialog closes");
+ if how == "escape" {
+ assert_eq!(h.app.session.doc.to_json(), design, "Esc leaves the design as it was");
+ } else {
+ assert_eq!(h.app.session.world_state().bodies.len(), bodies + 1, "{how}: the revolve is made");
+ }
+ }
+}
+
/// OK and Cancel in the view's corner (#6709) do what the dialog's own do: the check applies and
/// closes, the cross cancels without a change, and the check is grey (and does nothing) whenever
/// the dialog's OK is.
@@ -528,6 +607,41 @@ fn view_corner_ok_and_cancel_answer_the_dialog_like_its_own_buttons() {
assert!(h.app.dialog.is_none(), "the cross closes Measure");
}
+/// Both options at once (#6708 with #6709): the check in the view's corner greys out with the OK
+/// in the title row, the pair keeps clear of the dialog, and either OK applies it.
+#[test]
+fn top_dialog_buttons_and_the_view_corner_agree() {
+ let open = |command: &str| {
+ let mut h = fixture();
+ h.call("ui.resize", json!({"width":1600,"height":1200}));
+ h.call("ui.prefs", json!({"dialog_buttons": "top", "view_confirm_corner": true}));
+ if command == "solid.revolve" {
+ h.app.dialog = Some(representative(&h, command));
+ } else {
+ h.app.start(command);
+ }
+ h.settle();
+ h
+ };
+ for (command, enabled) in [("solid.revolve", 1.0), ("solid.shell", 0.0)] {
+ let _h = open(command);
+ let header = scenario::rect_of("dialog:header").unwrap();
+ assert!(scenario::rect_of("dialog:footer").is_none(), "{command}");
+ assert!(header.contains_rect(scenario::rect_of("dialog:ok").unwrap()), "{command}: OK in the title row");
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(enabled), "{command}");
+ assert_eq!(scenario::count_of("view:confirm:ok:enabled"), Some(enabled), "{command}: the check follows the title row's OK");
+ assert!(!scenario::rect_of("view:confirm").unwrap().intersects(header), "{command}: the pair keeps clear of the dialog");
+ }
+ for handle in ["dialog:ok", "view:confirm:ok"] {
+ let mut h = open("solid.revolve");
+ let bodies = h.app.session.world_state().bodies.len();
+ h.step(&json!({"click":{"handle":handle}})).unwrap();
+ h.settle();
+ assert!(h.app.dialog.is_none(), "{handle}: the dialog closes");
+ assert_eq!(h.app.session.world_state().bodies.len(), bodies + 1, "{handle}: the revolve is made");
+ }
+}
+
fn resized_box_editor(command: &str, params: Value) -> (Harness, u64) {
let mut h = Harness::new();
for (id, params) in [
diff --git a/crates/ui-egui/src/dialogs_sketch_tests.rs b/crates/ui-egui/src/dialogs_sketch_tests.rs
index 844fe82210..0123a5d1c6 100644
--- a/crates/ui-egui/src/dialogs_sketch_tests.rs
+++ b/crates/ui-egui/src/dialogs_sketch_tests.rs
@@ -128,6 +128,28 @@ fn apply_commits_once_keeps_values_and_waits_for_new_selection_ok_closes() {
}
}
+/// Interface › Dialog buttons › Top (#6708): Apply sits between Cancel and OK in the header row
+/// and still commits once, keeping the dialog open.
+#[test]
+fn apply_in_the_header_row_commits_once_and_keeps_the_dialog() {
+ let mut h = fixture();
+ h.call("ui.prefs", json!({"dialog_buttons":"top"}));
+ h.app.dialog = Some(picked(&h, "sketch.offset"));
+ h.settle();
+ let header = scenario::rect_of("dialog:header").unwrap();
+ assert!(scenario::rect_of("dialog:footer").is_none());
+ let (cancel, apply, ok) =
+ (scenario::rect_of("dialog:cancel").unwrap(), scenario::rect_of("dialog:apply").unwrap(), scenario::rect_of("dialog:ok").unwrap());
+ assert!(header.contains_rect(cancel) && header.contains_rect(apply) && header.contains_rect(ok));
+ assert!(cancel.right() < apply.left() && apply.right() < ok.left());
+ let undo = h.app.session.undo.len();
+ h.step(&json!({"click":{"handle":"dialog:apply"}})).unwrap();
+ h.settle();
+ assert_eq!(h.app.session.undo.len(), undo + 1, "one Apply, one undo");
+ assert!(h.app.dialog.is_some(), "Apply keeps the dialog");
+ assert_eq!(scenario::rect_of("dialog:apply"), Some(apply), "the buttons stay where they were");
+}
+
#[test]
fn picked_list_removes_one_item_and_field_still_activates_input() {
let mut h = fixture();
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index d29a7815ef..b9fad80b36 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -2124,6 +2124,7 @@ impl SolveApp {
self.ui.show_timeline = true;
}
self.ui.layout.publish(ui.ctx());
+ self.preferences.dialog_buttons.publish(ui.ctx());
scenario::clear_handles();
self.poll_feature_edit(ui.ctx());
self.poll_deferred(ui.ctx());
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index 3f39e1a3b1..0f619039a6 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -628,6 +628,8 @@ preference_settings! {
layout: crate::shell::LayoutMode = Default::default(), PAGE_INTERFACE;
/// Show command names beneath ribbon icons, independently of workspace layout.
ribbon_labels: bool = true, PAGE_INTERFACE;
+ /// Where a dialog's OK and Cancel sit: under its inputs (the default) or in its title row (#6708).
+ dialog_buttons: crate::ui_kit::DialogButtons = Default::default(), PAGE_INTERFACE;
/// Interface scale (1 = 100 %).
ui_scale: f32 = 1.0, PAGE_INTERFACE, accept(0.5..=2.5);
/// Interface font: an installed font family (or a font file), or empty for the built-in one
@@ -3397,6 +3399,7 @@ mod tests {
("ui_font", json!("test font"), PAGE_INTERFACE),
("layout", json!("compact"), PAGE_INTERFACE),
("ribbon_labels", json!(false), PAGE_INTERFACE),
+ ("dialog_buttons", json!("top"), PAGE_INTERFACE),
("timeline_left", json!(true), PAGE_INTERFACE),
("timeline_under_browser", json!(true), PAGE_INTERFACE),
("history_sketches", json!("under_feature"), PAGE_INTERFACE),
@@ -4027,6 +4030,35 @@ mod tests {
assert_eq!(h.app.preferences.history_sketches, HistorySketches::UnderFeature);
}
+ #[test]
+ fn dialog_buttons_default_bottom_and_follow_preferences_transactions() {
+ use crate::ui_kit::DialogButtons;
+ let old: Prefs = serde_json::from_value(json!({"ribbon_labels": false})).unwrap();
+ assert_eq!(old.dialog_buttons, DialogButtons::Bottom, "settings from before keep the footer");
+ assert_eq!(lenient(&json!({"dialog_buttons": "sideways"})).dialog_buttons, DialogButtons::Bottom);
+ let mut h = crate::scenario::Harness::new();
+ h.call("ui.prefs", json!({"open": "Interface"}));
+ super::reveal_preference(&mut h, "prefs:dialog_buttons:top");
+ h.step(&json!({"click": {"handle": "prefs:dialog_buttons:top"}})).unwrap();
+ assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Top);
+ h.call("ui.prefs", json!({"button": "cancel"}));
+ assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Bottom);
+
+ let reply = h.call("ui.prefs", json!({"dialog_buttons": "top"}));
+ assert_eq!(reply["result"]["dialog_buttons"], "top");
+ let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+ restored.load_prefs(&h.app.prefs());
+ assert_eq!(restored.preferences.dialog_buttons, DialogButtons::Top);
+ let before = h.app.preferences.clone();
+ assert!(control(&mut h.app, &json!({"dialog_buttons": "sideways"})).is_err());
+ assert_eq!(h.app.preferences, before, "an unknown value changes nothing");
+ h.call("ui.prefs", json!({"open": "Interface"}));
+ h.call("ui.prefs", json!({"button": "defaults"}));
+ assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Bottom);
+ h.call("ui.prefs", json!({"button": "cancel"}));
+ assert_eq!(h.app.preferences.dialog_buttons, DialogButtons::Top);
+ }
+
#[test]
fn free_orbit_defaults_off_and_follows_preferences_transactions() {
let old: Prefs = serde_json::from_value(json!({"nav":"solidworks"})).unwrap();
diff --git a/crates/ui-egui/src/prefs/interface.rs b/crates/ui-egui/src/prefs/interface.rs
index 579bb4ff84..6d02ce0828 100644
--- a/crates/ui-egui/src/prefs/interface.rs
+++ b/crates/ui-egui/src/prefs/interface.rs
@@ -42,6 +42,23 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
app.preferences.ribbon_labels = selected == 0;
}
});
+ // Where every feature dialog puts its OK and Cancel (#6708).
+ ui_kit::row(ui, app.tr("prefs.dialog_buttons"), |ui| {
+ let placements = [crate::ui_kit::DialogButtons::Bottom, crate::ui_kit::DialogButtons::Top];
+ let mut selected = placements.iter().position(|p| *p == app.preferences.dialog_buttons).unwrap_or(0);
+ if ui_kit::segmented(ui, &mut selected, &[app.tr("prefs.bottom"), app.tr("prefs.top")], Default::default())
+ && let Some(placement) = placements.get(selected)
+ {
+ app.preferences.dialog_buttons = *placement;
+ }
+ });
+ // Handles that don't depend on the language, by the saved value.
+ let row = app.tr("prefs.dialog_buttons");
+ for (label, key) in [("prefs.bottom", "bottom"), ("prefs.top", "top")] {
+ if let Some(at) = crate::scenario::handle_at(&format!("dialog:{row}:{}", app.tr(label))) {
+ crate::scenario::publish_handle(&format!("prefs:dialog_buttons:{key}"), at);
+ }
+ }
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(
diff --git a/crates/ui-egui/src/ui_kit/actions.rs b/crates/ui-egui/src/ui_kit/actions.rs
index fe290d1b80..823ca7e67d 100644
--- a/crates/ui-egui/src/ui_kit/actions.rs
+++ b/crates/ui-egui/src/ui_kit/actions.rs
@@ -121,20 +121,7 @@ pub(super) fn footer_with_left(
let inner = band.shrink2(vec2(t.space_12, t.space_10));
scenario::publish_rect("dialog:footer:actions", inner);
let mut action = if ui.is_enabled() { keyboard(ui.ctx(), ok_enabled) } else { Action::None };
- let primary_fill = if t.borders.bevel.is_some() && !danger {
- t.control_fill
- } else if danger {
- t.form_error
- } else {
- t.form_primary
- };
- let primary_ink = if t.borders.bevel.is_some() && !danger {
- t.form_ink
- } else if danger && crate::theme::contrast_ratio(t.on_accent, primary_fill) < 4.5 {
- t.tab_on_fill_dark
- } else {
- t.on_accent
- };
+ let look = ActionLook::new(ok_enabled, selected, danger);
let mut actions_left = inner.right();
let row = ui.scope_builder(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
@@ -143,49 +130,16 @@ pub(super) fn footer_with_left(
if (kind == Action::Apply && (apply_label.is_none() || confirm)) || (kind == Action::Ok && ok_label.is_empty()) || label.is_empty() {
continue;
}
- let marked = selected == Some(kind);
- let primary = kind == Action::Ok && selected.is_none_or(|s| s == Action::Ok);
- let live = kind == Action::Cancel || ok_enabled;
- ui.spacing_mut().button_padding = vec2(if primary { t.space_16 } else { t.space_12 }, 0.0);
- let text = RichText::new(crate::i18n::tr_label(label)).size(t.font_label).color(if primary && ok_enabled {
- primary_ink
- } else if primary {
- t.form_dim
- } else {
- t.form_ink
- });
- let response = ui.add_enabled(
- live,
- egui::Button::new(if primary && ok_enabled { text.bold_face() } else { text })
- .selected(marked && !primary)
- .fill(if primary && ok_enabled {
- primary_fill
- } else if marked {
- t.selected_bg
- } else {
- t.control_fill
- })
- .stroke(if primary && ok_enabled {
- egui::Stroke::NONE
- } else if marked && !primary {
- egui::Stroke::new(1.0, t.form_primary)
- } else {
- t.control_border_stroke(t.control_border)
- })
- .wrap_mode(egui::TextWrapMode::Extend)
- .corner_radius(t.control_radius)
- .min_size(vec2(if primary { t.space_24 * 3.0 } else { 0.0 }, t.form_button_height)),
+ let primary = look.primary(kind);
+ let response = action_button(
+ ui,
+ label,
+ kind,
+ &look,
+ if primary { t.space_16 } else { t.space_12 },
+ if primary { t.space_24 * 3.0 } else { 0.0 },
);
- t.button_bevel(ui, &response, false);
- pointer_on_hover(ui, &response);
actions_left = actions_left.min(response.rect.left());
- let key = match kind {
- Action::Ok => "dialog:ok",
- Action::Apply => "dialog:apply",
- _ => "dialog:cancel",
- };
- scenario::publish_target(key, response.rect);
- scenario::publish_handle(&format!("dialog:{label}"), response.rect.center());
if response.clicked() {
action = kind;
}
@@ -225,6 +179,154 @@ pub(super) fn footer_with_left(
action
}
+/// What every OK, Apply and Cancel button shares, wherever the row of them sits.
+struct ActionLook {
+ ok_enabled: bool,
+ selected: Option<Action>,
+ primary_fill: egui::Color32,
+ primary_ink: egui::Color32,
+}
+
+impl ActionLook {
+ fn new(ok_enabled: bool, selected: Option<Action>, danger: bool) -> Self {
+ let t = Tokens::get();
+ let primary_fill = if t.borders.bevel.is_some() && !danger {
+ t.control_fill
+ } else if danger {
+ t.form_error
+ } else {
+ t.form_primary
+ };
+ let primary_ink = if t.borders.bevel.is_some() && !danger {
+ t.form_ink
+ } else if danger && crate::theme::contrast_ratio(t.on_accent, primary_fill) < 4.5 {
+ t.tab_on_fill_dark
+ } else {
+ t.on_accent
+ };
+ Self { ok_enabled, selected, primary_fill, primary_ink }
+ }
+
+ /// OK carries the accent unless the keyboard marks another action.
+ fn primary(&self, kind: Action) -> bool {
+ kind == Action::Ok && self.selected.is_none_or(|s| s == Action::Ok)
+ }
+}
+
+/// One OK, Apply or Cancel button, `padding` at its sides and at least `min_width` wide, with its
+/// scenario handles (`dialog:ok`, `dialog:apply`, `dialog:cancel` and `dialog:<label>`).
+fn action_button(ui: &mut Ui, label: &str, kind: Action, look: &ActionLook, padding: f32, min_width: f32) -> Response {
+ let t = Tokens::get();
+ let ok_enabled = look.ok_enabled;
+ let marked = look.selected == Some(kind);
+ let primary = look.primary(kind);
+ let live = kind == Action::Cancel || ok_enabled;
+ ui.spacing_mut().button_padding = vec2(padding, 0.0);
+ let text = RichText::new(crate::i18n::tr_label(label)).size(t.font_label).color(if primary && ok_enabled {
+ look.primary_ink
+ } else if primary {
+ t.form_dim
+ } else {
+ t.form_ink
+ });
+ let response = ui.add_enabled(
+ live,
+ egui::Button::new(if primary && ok_enabled { text.bold_face() } else { text })
+ .selected(marked && !primary)
+ .fill(if primary && ok_enabled {
+ look.primary_fill
+ } else if marked {
+ t.selected_bg
+ } else {
+ t.control_fill
+ })
+ .stroke(if primary && ok_enabled {
+ egui::Stroke::NONE
+ } else if marked && !primary {
+ egui::Stroke::new(1.0, t.form_primary)
+ } else {
+ t.control_border_stroke(t.control_border)
+ })
+ .wrap_mode(egui::TextWrapMode::Extend)
+ .corner_radius(t.control_radius)
+ .min_size(vec2(min_width, t.form_button_height)),
+ );
+ t.button_bevel(ui, &response, false);
+ pointer_on_hover(ui, &response);
+ let key = match kind {
+ Action::Ok => "dialog:ok",
+ Action::Apply => "dialog:apply",
+ _ => "dialog:cancel",
+ };
+ scenario::publish_target(key, response.rect);
+ scenario::publish_handle(&format!("dialog:{label}"), response.rect.center());
+ response
+}
+
+/// A panel's OK, Apply and Cancel in its header row (`DialogButtons::Top`): the footer's buttons,
+/// in the footer's order, with its enabled states, keyboard and scenario handles. Each is as wide
+/// as its label in the bold face, so the row keeps its place whatever the panel's inputs do.
+/// Tokens: `form_button_height`, `font_label`, `space_4/8`, and the footer's button tokens.
+pub(crate) struct HeaderActions<'a> {
+ /// Right to left: OK, Apply, Cancel (those with a label).
+ slots: Vec<(Action, &'a str, egui::Rect)>,
+}
+
+impl<'a> HeaderActions<'a> {
+ /// Lays the buttons out right to left from `right`, centred on `band`, never past its left.
+ pub(crate) fn new(ui: &Ui, band: egui::Rect, right: f32, ok: &'a str, apply: Option<&'a str>, cancel: &'a str) -> Self {
+ let t = Tokens::get();
+ let mut slots = Vec::new();
+ let mut x = right;
+ for (label, kind) in [(ok, Action::Ok), (apply.unwrap_or(""), Action::Apply), (cancel, Action::Cancel)] {
+ if label.is_empty() {
+ continue;
+ }
+ let text = ui.painter().layout_no_wrap(crate::i18n::tr_label(label).to_owned(), crate::fonts::bold(t.font_label), t.form_ink);
+ let width = (text.size().x.ceil() + t.space_8 * 2.0).min((x - band.left()).max(0.0));
+ let rect = egui::Rect::from_min_max(
+ egui::pos2(x - width, band.center().y - t.form_button_height / 2.0),
+ egui::pos2(x, band.center().y + t.form_button_height / 2.0),
+ );
+ slots.push((kind, label, rect));
+ x = (rect.left() - t.space_4).max(band.left());
+ }
+ Self { slots }
+ }
+
+ /// Where the buttons start; `right` when there are none.
+ pub(crate) fn left(&self, right: f32) -> f32 {
+ self.slots.iter().map(|(_, _, rect)| rect.left()).fold(right, f32::min)
+ }
+
+ pub(crate) fn rect(&self, kind: Action) -> Option<egui::Rect> {
+ self.slots.iter().find(|(k, _, _)| *k == kind).map(|(_, _, rect)| *rect)
+ }
+
+ /// Draws the buttons; returns what was clicked, or what Enter and Esc ask for.
+ pub(crate) fn show(&self, ui: &mut Ui, ok_enabled: bool) -> Action {
+ let ok_enabled = ok_enabled && self.rect(Action::Ok).is_some();
+ scenario::publish_count("dialog:ok:enabled", f64::from(ok_enabled && ui.is_enabled()));
+ let mut action = if ui.is_enabled() { keyboard(ui.ctx(), ok_enabled) } else { Action::None };
+ let look = ActionLook::new(ok_enabled, None, false);
+ let padding = Tokens::get().space_8;
+ for (kind, label, rect) in &self.slots {
+ let builder = egui::UiBuilder::new()
+ .id_salt(("header_action", *kind as u8))
+ .max_rect(*rect)
+ .layout(egui::Layout::centered_and_justified(egui::Direction::LeftToRight));
+ let response = ui.scope_builder(builder, |ui| action_button(ui, label, *kind, &look, padding, 0.0)).inner;
+ if response.clicked() {
+ action = *kind;
+ }
+ }
+ if let Some(all) = self.slots.iter().map(|(_, _, rect)| *rect).reduce(|a, b| a.union(b)) {
+ scenario::publish_rect("dialog:header:actions", all);
+ }
+ action
+ }
+}
+
/// One equal-width secondary action, with optional existing icon master.
pub(crate) struct PairButton<'a> {
pub key: &'a str,
diff --git a/crates/ui-egui/src/ui_kit/mod.rs b/crates/ui-egui/src/ui_kit/mod.rs
index 808fb015cf..1ec0fa67ea 100644
--- a/crates/ui-egui/src/ui_kit/mod.rs
+++ b/crates/ui-egui/src/ui_kit/mod.rs
@@ -48,8 +48,8 @@ pub(crate) use history::*;
pub(crate) use layout::*;
pub(crate) use menu::{Menu, MenuItem, rename_menu, workspace_menu};
pub(crate) use metrics::{ContentWidth, header_height, row_height, table_row_height};
-pub use panel::Window;
pub(crate) use panel::{ComputeStatus, FeatureOptions, Panel, Part, WindowPage, panel_header_hover};
+pub use panel::{DialogButtons, Window};
#[cfg(test)]
pub(crate) use panel::{collapsible_header, header};
pub(crate) use preferences::*;
diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rs
index c2c5e71efe..ba0830c620 100644
--- a/crates/ui-egui/src/ui_kit/panel.rs
+++ b/crates/ui-egui/src/ui_kit/panel.rs
@@ -62,6 +62,124 @@ fn header_impl(ui: &mut Ui, icon: &str, title: &str, collapsed: Option<&mut bool
t.secondary_hline(ui.painter(), rect.x_range(), rect.bottom(), t.dialog_rule);
}
+/// Where a feature panel's OK, Cancel and Apply sit (Preferences › Interface › Dialog buttons,
+/// #6708). The app publishes the preference each frame, so every `Panel::feature` follows it.
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum DialogButtons {
+ /// In a footer row under the inputs (how it always was). Also what a value this version
+ /// doesn't know reads as (`prefs::lenient`).
+ #[default]
+ Bottom,
+ /// In the header row, right of the title, where they stay while sections open and close.
+ Top,
+}
+
+impl DialogButtons {
+ pub(crate) fn publish(self, ctx: &egui::Context) {
+ ctx.data_mut(|data| data.insert_temp(egui::Id::new("sc_dialog_buttons"), self));
+ }
+
+ pub(crate) fn current(ctx: &egui::Context) -> Self {
+ ctx.data(|data| data.get_temp(egui::Id::new("sc_dialog_buttons"))).unwrap_or_default()
+ }
+}
+
+/// The header row of a feature panel whose actions sit at the top. It is laid out before the
+/// body, and its icon, title and buttons are drawn after it, once the compute status and whether
+/// OK is enabled are known. Same tokens as `header`, plus `HeaderActions`'.
+struct TopHeader<'a> {
+ icon: egui::Rect,
+ title: egui::Rect,
+ actions: super::HeaderActions<'a>,
+}
+
+impl<'a> TopHeader<'a> {
+ fn new(ui: &mut Ui, ok: &'a str, apply: Option<&'a str>, cancel: &'a str, collapsed: Option<&mut bool>, close: &mut bool) -> Self {
+ let t = Tokens::get();
+ let (band, _) = ui.allocate_exact_size(vec2(dimension(ui.available_width()), header_height()), egui::Sense::hover());
+ let icon = egui::Rect::from_center_size(
+ egui::pos2(band.left() + t.space_12 + t.form_icon_size / 2.0, band.center().y),
+ vec2(t.form_icon_size, t.form_icon_size),
+ );
+ // The buttons end where the fields below do.
+ let end = (band.right() - t.space_12).max(band.left());
+ let actions = super::HeaderActions::new(ui, band, end, ok, apply, cancel);
+ let buttons = actions.left(end);
+ // Nothing placed yet beside the buttons: the next control keeps clear of them.
+ let beside_buttons = |right: f32| buttons < end && right >= buttons;
+ // An icon target to the left of what is already placed, `space_4` clear of the buttons.
+ let target = |right: f32| {
+ let right = if beside_buttons(right) { right - t.space_4 } else { right };
+ egui::Rect::from_center_size(
+ egui::pos2((right - t.form_close_size / 2.0).max(band.left()), band.center().y),
+ vec2(t.form_close_size, t.form_close_size),
+ )
+ };
+ let mut right = buttons;
+ // The header's close does what Cancel does in every panel, so with Cancel up here it is
+ // left out: one control for one action, and its width goes to the title. Its handle
+ // moves to Cancel, so automation that closes a panel keeps working.
+ if let Some(cancel_rect) = actions.rect(super::Action::Cancel) {
+ scenario::publish_handle("dialog:close", cancel_rect.center());
+ } else {
+ let close_rect = target(right);
+ let response = icon_button_at(ui, close_rect, "close", "Close");
+ scenario::publish_handle("dialog:close", response.rect.center());
+ if response.clicked() {
+ *close = true;
+ }
+ right = close_rect.left();
+ }
+ if let Some(collapsed) = collapsed {
+ let fold = target(right);
+ let response = super::disclosure_button_at(ui, fold, !*collapsed, crate::i18n::tr_label(if *collapsed { "Expand" } else { "Collapse" }));
+ scenario::publish_handle("dialog:collapse", response.rect.center());
+ if response.clicked() {
+ *collapsed = !*collapsed;
+ }
+ right = fold.left();
+ }
+ // Text next to a text button keeps a gap; an icon target carries its own padding.
+ if beside_buttons(right) {
+ right = (right - t.space_6).max(band.left());
+ }
+ let left = (icon.right() + t.space_8).min(right);
+ let title = egui::Rect::from_min_max(egui::pos2(left, band.top()), egui::pos2(right.max(left), band.bottom()));
+ // Dragging the panel by its title must not start on a button.
+ scenario::publish_handle("dialog:title", title.center());
+ scenario::publish_rect("dialog:header", band);
+ t.secondary_hline(ui.painter(), band.x_range(), band.bottom(), t.dialog_rule);
+ Self { icon, title, actions }
+ }
+
+ /// The icon (the compute spinner while busy), the title (the compute status while there is
+ /// one: the footer that showed it is gone) and the buttons. Returns the action asked for.
+ fn finish(&self, ui: &mut Ui, icon: &str, title: &str, state: &ComputeStatus, ok_enabled: bool) -> super::Action {
+ let t = Tokens::get();
+ if state.busy {
+ egui::Spinner::new().size(t.space_14).paint_at(ui, self.icon);
+ let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));
+ ui.interact(self.icon, ui.id().with("compute_status"), egui::Sense::hover()).on_hover_text(status);
+ ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));
+ } else {
+ crate::icons::paint_icon(ui.painter(), self.icon, icon, 1.0);
+ }
+ let heading = crate::fonts::semibold(t.font_heading);
+ match state.text.as_deref() {
+ Some(status) => paint_text(ui, self.title, status, crate::fonts::medium(t.font_label), t.form_dim, false),
+ None => paint_text(ui, self.title, title, heading.clone(), t.form_ink, false),
+ }
+ let title_response = ui.interact(self.title, ui.make_persistent_id("title_text"), egui::Sense::hover());
+ title_response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, ui.is_enabled(), title));
+ // The buttons take the row's width first; a title that no longer fits says itself on hover.
+ if ui.painter().layout_no_wrap(title.to_owned(), heading, t.form_ink).size().x > self.title.width() {
+ title_response.on_hover_text(title);
+ }
+ self.actions.show(ui, ok_enabled)
+ }
+}
+
/// A bounded docked or floating card. Uses form_card_width and the caller's tokenised frame.
/// Window IDs and content scopes are retained so moving a card does not reset field focus.
pub(crate) struct Panel<'a> {
@@ -287,16 +405,21 @@ impl<'a> Panel<'a> {
let band = egui::Rect::from_min_size(min, vec2(ui.available_width(), super::header_height()));
crate::frame::drag_dock(ui, band, heading.drag_key, heading.moved, self.bounded_anchor(ui.ctx()) - heading.docked);
let mut close = false;
- if let Some(collapsed) = collapsed.as_deref_mut() {
- collapsible_header(ui, heading.icon, heading.title, collapsed, || close = true);
+ let top = if DialogButtons::current(ui.ctx()) == DialogButtons::Top {
+ Some(TopHeader::new(ui, self.ok, heading.apply_label, self.cancel, collapsed.as_deref_mut(), &mut close))
} else {
- header(ui, heading.icon, heading.title, || close = true);
- }
+ if let Some(collapsed) = collapsed.as_deref_mut() {
+ collapsible_header(ui, heading.icon, heading.title, collapsed, || close = true);
+ } else {
+ header(ui, heading.icon, heading.title, || close = true);
+ }
+ None
+ };
let bottom = self.viewport.bottom()
- super::Container::new(ui.ctx(), super::Surface::Feature).gap()
- self.frame.inner_margin.bottomf()
- self.frame.stroke.width;
- let footer_height = t.form_footer_height;
+ let footer_height = if top.is_some() { 0.0 } else { t.form_footer_height };
let fields_height = (bottom - ui.cursor().top() - footer_height - ui.spacing().item_spacing.y).max(0.0);
let fields_height = self.body_rows.map_or(fields_height, |rows| fields_height.min(rows * t.control_height + t.space_12 * 2.0));
let fields_rect = egui::Rect::from_min_size(ui.cursor().min, vec2(ui.available_width(), fields_height));
@@ -331,6 +454,11 @@ impl<'a> Panel<'a> {
})
.inner
};
+ if let Some(top) = &top {
+ let action = top.finish(ui, heading.icon, heading.title, &state, valid && !state.applying);
+ super::Container::finish_content(ui, self.positioned_frame(ui.ctx()));
+ return (close, action);
+ }
let corners = self.positioned_frame(ui.ctx()).corner_radius;
let action = super::footer(
ui,
diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rs
index 36e974f174..96569d7111 100644
--- a/crates/ui-egui/src/ui_kit/panel_tests.rs
+++ b/crates/ui-egui/src/ui_kit/panel_tests.rs
@@ -128,6 +128,161 @@ fn panel_keeps_actions_and_body_geometry_in_both_layouts() {
}
}
+/// One frame of a feature panel with `rows` body rows, the given `placement` published.
+fn feature_frame_with(
+ ctx: &egui::Context,
+ placement: DialogButtons,
+ rows: usize,
+ valid: bool,
+ collapsed: Option<&mut bool>,
+ events: Vec<egui::Event>,
+) -> (bool, Action) {
+ let vp = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(640.0, 480.0));
+ scenario::clear_handles();
+ let mut result = (false, Action::None);
+ let mut collapsed = collapsed;
+ crate::test_support::frame(ctx, egui::RawInput { screen_rect: Some(vp), events, focused: true, ..Default::default() }, |_| {
+ placement.publish(ctx);
+ let side = crate::frame::Side::Right;
+ let frame = Panel::feature_frame(ctx, crate::shell::LayoutMode::Floating, side);
+ let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
+ let panel = Panel::new("Fillet", egui::Id::new("top_actions"), anchor, vp, side, frame);
+ panel.window(ctx).show(ctx, |ui| {
+ let heading = FeatureOptions {
+ icon: "fillet",
+ title: "Fillet",
+ drag_key: "top_actions",
+ moved: egui::Vec2::ZERO,
+ docked: anchor,
+ apply_label: Some("Apply"),
+ };
+ let body = |ui: &mut Ui| {
+ for row_index in 0..rows {
+ text(ui, &format!("Input {row_index}"), Text::Note("row"));
+ }
+ ComputeStatus { text: None, busy: false, applying: false }
+ };
+ result = match collapsed.as_deref_mut() {
+ Some(collapsed) => panel.feature_collapsible(ui, heading, false, valid, collapsed, body),
+ None => panel.feature(ui, heading, false, valid, body),
+ };
+ });
+ });
+ result
+}
+
+#[test]
+fn top_placement_puts_the_actions_in_the_header_row_where_they_stay() {
+ let ctx = crate::fonts::test_context();
+ for _ in 0..3 {
+ feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, Vec::new());
+ }
+ let header = scenario::rect_of("dialog:header").unwrap();
+ assert_eq!(header.height(), Tokens::get().form_header_height);
+ assert!(scenario::rect_of("dialog:footer").is_none(), "the footer row is gone");
+ let (ok, apply, cancel) =
+ (scenario::rect_of("dialog:ok").unwrap(), scenario::rect_of("dialog:apply").unwrap(), scenario::rect_of("dialog:cancel").unwrap());
+ for (name, rect) in [("ok", ok), ("apply", apply), ("cancel", cancel)] {
+ assert!(header.contains_rect(rect), "{name} {rect:?} sits in the header {header:?}");
+ assert_eq!(rect.height(), Tokens::get().form_button_height, "{name}");
+ }
+ assert!(cancel.right() < apply.left() && apply.right() < ok.left(), "the footer's order: Cancel, Apply, then OK at the right");
+ assert_eq!(scenario::handle_at("dialog:close"), Some(cancel.center()), "Cancel stands in for the close button");
+ assert!(scenario::handle_at("dialog:OK").is_some() && scenario::handle_at("dialog:Cancel").is_some());
+ assert!(scenario::handle_at("dialog:title").is_some_and(|at| at.x < cancel.left()), "the title drags clear of the buttons");
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(1.0));
+
+ // More inputs, a longer card: the buttons stay where they were.
+ for _ in 0..2 {
+ feature_frame_with(&ctx, DialogButtons::Top, 24, true, None, Vec::new());
+ }
+ assert_eq!(scenario::rect_of("dialog:ok"), Some(ok));
+ assert_eq!(scenario::rect_of("dialog:cancel"), Some(cancel));
+
+ // OK greys out exactly as it does in the footer, and a click on it then does nothing.
+ feature_frame_with(&ctx, DialogButtons::Top, 2, false, None, Vec::new());
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0));
+ let at = ok.center();
+ feature_frame_with(&ctx, DialogButtons::Top, 2, false, None, crate::test_support::pointer(at, true));
+ assert_eq!(feature_frame_with(&ctx, DialogButtons::Top, 2, false, None, crate::test_support::pointer(at, false)).1, Action::None);
+ feature_frame_with(&ctx, DialogButtons::Bottom, 2, false, None, Vec::new());
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0), "the same state at the bottom");
+
+ // The buttons and the keys answer as the footer's do.
+ for (target, expected) in [(ok, Action::Ok), (apply, Action::Apply), (cancel, Action::Cancel)] {
+ feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, Vec::new());
+ feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, crate::test_support::pointer(target.center(), true));
+ let clicked = feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, crate::test_support::pointer(target.center(), false));
+ assert_eq!(clicked, (false, expected));
+ }
+ for (key, expected) in [(egui::Key::Escape, Action::Cancel), (egui::Key::Enter, Action::Ok)] {
+ feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, Vec::new());
+ assert_eq!(feature_frame_with(&ctx, DialogButtons::Top, 2, true, None, crate::test_support::key(key)).1, expected, "{key:?}");
+ }
+}
+
+/// With no footer to show it, the compute status takes the title's place and the spinner the
+/// icon's, until the feature is in; OK stays grey meanwhile, as in the footer.
+#[test]
+fn top_placement_shows_the_compute_status_in_the_title_row() {
+ let ctx = crate::fonts::test_context();
+ let vp = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(640.0, 480.0));
+ let mut output = None;
+ for _ in 0..3 {
+ scenario::clear_handles();
+ output = Some(crate::test_support::frame(&ctx, egui::RawInput { screen_rect: Some(vp), ..Default::default() }, |_| {
+ DialogButtons::Top.publish(&ctx);
+ let side = crate::frame::Side::Right;
+ let anchor = egui::pos2(vp.right() - crate::shell::SHELL_GAP, vp.top());
+ let panel = Panel::new(
+ "Fillet",
+ egui::Id::new("top_status"),
+ anchor,
+ vp,
+ side,
+ Panel::feature_frame(&ctx, crate::shell::LayoutMode::Floating, side),
+ );
+ panel.window(&ctx).show(&ctx, |ui| {
+ let heading = FeatureOptions {
+ icon: "fillet",
+ title: "Fillet",
+ drag_key: "top_status",
+ moved: egui::Vec2::ZERO,
+ docked: anchor,
+ apply_label: None,
+ };
+ panel.feature(ui, heading, true, true, |ui| {
+ text(ui, "Input", Text::Note("row"));
+ ComputeStatus { text: Some("Computing… 3 s".into()), busy: true, applying: true }
+ });
+ });
+ }));
+ }
+ let texts: Vec<String> = output.iter().flat_map(crate::test_support::text_shapes).map(|shape| shape.galley.job.text.clone()).collect();
+ assert!(texts.iter().any(|text| text == "Computing… 3 s"), "{texts:?}");
+ assert!(!texts.iter().any(|text| text == "Fillet"), "the status stands in for the title: {texts:?}");
+ assert_eq!(scenario::count_of("dialog:ok:enabled"), Some(0.0), "OK waits for the feature");
+ assert!(scenario::rect_of("dialog:header").unwrap().contains_rect(scenario::rect_of("dialog:cancel").unwrap()));
+}
+
+#[test]
+fn top_placement_keeps_a_managers_fold_beside_the_actions() {
+ let ctx = crate::fonts::test_context();
+ let mut collapsed = false;
+ for _ in 0..3 {
+ feature_frame_with(&ctx, DialogButtons::Top, 4, true, Some(&mut collapsed), Vec::new());
+ }
+ let header = scenario::rect_of("dialog:header").unwrap();
+ let fold = scenario::handle_at("dialog:collapse").unwrap();
+ let cancel = scenario::rect_of("dialog:cancel").unwrap();
+ assert!(header.contains(fold) && fold.x < cancel.left(), "{fold:?} left of {cancel:?}");
+ assert!(scenario::handle_at("dialog:title").is_some_and(|at| at.x < fold.x));
+ feature_frame_with(&ctx, DialogButtons::Top, 4, true, Some(&mut collapsed), crate::test_support::pointer(fold, true));
+ feature_frame_with(&ctx, DialogButtons::Top, 4, true, Some(&mut collapsed), crate::test_support::pointer(fold, false));
+ assert!(collapsed);
+ assert_eq!(scenario::rect_of("dialog:cancel"), Some(cancel), "folding leaves the buttons in place");
+}
+
#[test]
fn palette_scrolls_short_views_and_retains_its_status_and_action_handles() {
for layout in [crate::shell::LayoutMode::Docked, crate::shell::LayoutMode::Floating] {
diff --git a/crates/ui-egui/tests/scenarios/dialog_buttons_top.json b/crates/ui-egui/tests/scenarios/dialog_buttons_top.json
new file mode 100644
index 0000000000..9ef1f2faf9
--- /dev/null
+++ b/crates/ui-egui/tests/scenarios/dialog_buttons_top.json
@@ -0,0 +1,27 @@
+[
+ {"note": "Interface › Dialog buttons › Top (#6708): a dialog's OK and Cancel sit in its title row, right of the title. The buttons keep their handles, Cancel takes the close button's, and Enter and Esc work as before."},
+ {"call": "engine.execute", "params": {"command": "sketch.create", "params": {"plane": "XY", "name": "Sketch1"}}},
+ {"call": "engine.execute", "params": {"command": "sketch.rectangle.two_point", "params": {"p0": [0, 0], "p1": [40, 30]}}},
+ {"call": "engine.execute", "params": {"command": "sketch.finish", "params": {}}},
+ {"call": "ui.prefs", "params": {"open": "Interface"}},
+ {"click": {"handle": "prefs:dialog_buttons:top"}},
+ {"widget": "OK"},
+ {"expect": {"prefs": {"dialog": null, "dialog_buttons": "top"}}},
+ {"note": "Extrude picks the sketch's one profile; its buttons are in the title row."},
+ {"start": "solid.extrude"},
+ {"frames": 4},
+ {"expect": {"dialog": "Extrude", "handle_order": ["dialog:title", "dialog:Cancel", "dialog:OK"], "bodies": 0}},
+ {"note": "Esc cancels, and so does the close handle, now on Cancel."},
+ {"key": "Escape"},
+ {"expect": {"dialog": null, "bodies": 0}},
+ {"start": "solid.extrude"},
+ {"frames": 4},
+ {"click": {"handle": "dialog:close"}},
+ {"expect": {"dialog": null, "bodies": 0}},
+ {"note": "OK in the title row makes the feature."},
+ {"start": "solid.extrude"},
+ {"frames": 4},
+ {"click": {"handle": "dialog:OK"}},
+ {"until": {"dialog": null}},
+ {"expect": {"bodies": 1, "errors": 0}}
+]
diff --git a/docs/book/src/guide/ui-tour.md b/docs/book/src/guide/ui-tour.md
index d46117e3fd..f2d8daf771 100644
--- a/docs/book/src/guide/ui-tour.md
+++ b/docs/book/src/guide/ui-tour.md
@@ -80,7 +80,9 @@
identity or change the exported solid. Unsupported or uncertain wall geometry
keeps its existing edge presentation.
- **Dialogs** dock on the right with a live preview. Most features also show drag handles and a
- value box in the viewport.
+ value box in the viewport. Interface › **Dialog buttons** › **Top** puts OK, Cancel and Apply in
+ the dialog's title row, right of the title, where they stay while sections open and close;
+ Cancel then also takes the place of the close button. Enter and Esc work as before.
- **Timeline** (bottom). Every feature in order. Double-click to edit, drag the marker to roll
back, and drag features to reorder them. Preferences can put the timeline vertically at the
far left of the viewport, beside the browser. Its seam handle switches between icon
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index cdef95e625..f82a2a92df 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), `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:<n>`), 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), `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `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:<n>`), 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), `history_sketches` (`in_order` (default), `under_feature`: the History at the left lists a sketch under the first feature built from it, #6489; the timeline at the bottom keeps the creation order), `dialog_buttons` (`bottom` (default), `top`: a feature dialog's OK, Cancel and Apply sit in its title row instead of under its inputs, #6708; the buttons keep their handles, and `dialog:close` is then Cancel's), `check_updates` (default true; [updates](book/src/guide/updates.md)), `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge)); `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 |
diff --git a/docs/ui-kit.md b/docs/ui-kit.md
index c54b4a1857..bc290b2558 100644
--- a/docs/ui-kit.md
+++ b/docs/ui-kit.md
@@ -29,6 +29,10 @@ preferences, manager cards, prompts, context menus and the sketch palette. Impor
pinned actions, compute status and keyboard routing. `wide()` uses three card
widths. `feature_frame` and `palette_frame` retain docked/floating surfaces.
`FeatureOptions::apply_label` adds Apply; `Panel::actions` supplies custom labels.
+ With `DialogButtons::Top` published (Preferences › Interface › Dialog buttons), `feature`
+ puts the actions in the header row through `HeaderActions` instead of a footer: the same
+ buttons, enabled states, keyboard and handles, each as wide as its bold label, with Cancel
+ standing in for the close button and the compute status in the title's place.
`body_rows` caps a manager's scrolling body independently of its position; short
viewports still keep the header and actions visible.
- `Window` composes the shared Panel frame with a 40 pt icon/title/close header,
@@ -122,7 +126,7 @@ table. Panel/Window/Confirm compositions also have dedicated geometry and intera
| `primary_button` | Accent action outside a footer | `accent`, `on_accent`, form tokens |
| `icon_button_at` | Icon action inside a supplied rectangle | `form_icon_inset`, `text/dim`, icon palette |
| `button_pair`, `PairButton` | Equal secondary actions, optional icons and selected state | `form_button_height`, control/selection/icon tokens |
-| `footer`, `Footer`, `Action` | OK/Cancel with optional Apply, compute status or selected action | `form_footer/button_height`, `dialog_footer/rule`, `control_*`, `accent`, spacing |
+| `footer`, `Footer`, `Action`, `HeaderActions` | OK/Cancel with optional Apply, compute status or selected action; `HeaderActions` puts the same buttons in a header row | `form_footer/button_height`, `dialog_footer/rule`, `control_*`, `accent`, spacing |
| `keyboard` | Esc cancels, unowned Enter submits when valid | none |
| `action_menu`, `command_menu_button` | Nested dense action menu or ribbon overflow action retaining its icon, shortcut and enabled state | form control/font tokens, `space_16`, icon palette |
| table: `table`, `table_custom`, `Column`, `Table::headers`, `Table::row`, `TableRow::cell`, `Table::add_prompt` | Left-aligned headers/cells, horizontal overflow, selected/hover rows and empty state. `table_custom` supplies header actions through `headers`. `Column::flex` shares remaining width by weight, freezing columns at their control minimums before redistributing the remaining space; `Column::icon_only` hides the heading while retaining its automation identity. `add_prompt` is the final slim dashed line and requests a regular draft row from its owner; `Column::new(label, width)` uses label-column multiples, `min_content_width(points)` reserves measured control content; `ContentWidth::name` measures strong configuration names | label-column tokens, `control_height`, `dialog_rule/footer`, `selected_bg`, spacing |