Dialogs: open in the left column in place of the browser and History (#6707) (#6712)

* claim: #6707

* feat(dialogs): open in the left column in place of the browser and History (#6707)

* fix(i18n): Vietnamese messages for the dialog placement option (#6707)
This commit is contained in:
Lars Jansen
2026-10-27 17:59:00 +00:00
committed by GitHub
parent 236b5c9ebf
commit 5a477b7774
17 changed files with 569 additions and 35 deletions
@@ -0,0 +1,56 @@
{
"en": {
"prefs.dialogs": "Dialogs",
"prefs.dialogs_edge": "At the view's edge",
"prefs.dialogs_left_column": "In the left column",
"prefs.dialogs_note": "Where command dialogs open: docked at the view's edge, or in the left column in place of the browser and the History, which come back as they were when the dialog closes."
},
"de": {
"prefs.dialogs": "Dialoge",
"prefs.dialogs_edge": "Am Rand der Ansicht",
"prefs.dialogs_left_column": "In der linken Spalte",
"prefs.dialogs_note": "Wo Befehlsdialoge öffnen: am Rand der Ansicht angedockt oder in der linken Spalte anstelle von Browser und Verlauf, die beim Schließen des Dialogs wie zuvor zurückkehren."
},
"ja": {
"prefs.dialogs": "ダイアログ",
"prefs.dialogs_edge": "ビューの端",
"prefs.dialogs_left_column": "左の列",
"prefs.dialogs_note": "コマンドダイアログを開く場所:ビューの端にドッキングするか、左の列でブラウザーと履歴の代わりに表示します。ダイアログを閉じるとブラウザーと履歴は元どおりに戻ります。"
},
"ko": {
"prefs.dialogs": "대화 상자",
"prefs.dialogs_edge": "뷰 가장자리",
"prefs.dialogs_left_column": "왼쪽 열",
"prefs.dialogs_note": "명령 대화 상자가 열리는 위치: 뷰 가장자리에 고정하거나, 왼쪽 열에서 브라우저와 이력 대신 표시합니다. 대화 상자를 닫으면 브라우저와 이력이 그대로 돌아옵니다."
},
"nl": {
"prefs.dialogs": "Dialogen",
"prefs.dialogs_edge": "Aan de rand van de weergave",
"prefs.dialogs_left_column": "In de linkerkolom",
"prefs.dialogs_note": "Waar opdrachtdialogen openen: vastgezet aan de rand van de weergave, of in de linkerkolom in plaats van de browser en de geschiedenis, die terugkomen zoals ze waren wanneer de dialoog sluit."
},
"zh": {
"prefs.dialogs": "对话框",
"prefs.dialogs_edge": "视图边缘",
"prefs.dialogs_left_column": "左侧栏",
"prefs.dialogs_note": "命令对话框的打开位置:停靠在视图边缘,或在左侧栏中替代浏览器和历史;关闭对话框后,浏览器和历史恢复原样。"
},
"ar": {
"prefs.dialogs": "الحوارات",
"prefs.dialogs_edge": "عند حافة العرض",
"prefs.dialogs_left_column": "في العمود الأيسر",
"prefs.dialogs_note": "مكان فتح حوارات الأوامر: مثبتة عند حافة العرض، أو في العمود الأيسر مكان المستعرض والسجل، اللذين يعودان كما كانا عند إغلاق الحوار."
},
"he": {
"prefs.dialogs": "תיבות דו־שיח",
"prefs.dialogs_edge": "בקצה התצוגה",
"prefs.dialogs_left_column": "בעמודה השמאלית",
"prefs.dialogs_note": "היכן נפתחות תיבות הדו־שיח של הפקודות: מעוגנות בקצה התצוגה, או בעמודה השמאלית במקום הדפדפן וההיסטוריה, שחוזרים כפי שהיו כשהתיבה נסגרת."
},
"vi": {
"prefs.dialogs": "Hộp thoại",
"prefs.dialogs_edge": "Ở cạnh khung nhìn",
"prefs.dialogs_left_column": "Trong cột bên trái",
"prefs.dialogs_note": "Nơi hộp thoại lệnh mở ra: gắn ở cạnh khung nhìn, hoặc trong cột bên trái thay cho trình duyệt và Lịch sử, hai phần này trở lại như cũ khi hộp thoại đóng."
}
}
+9 -2
View File
@@ -957,6 +957,12 @@ pub(crate) fn resize_column(app: &mut SolveApp, ui: &egui::Ui, rect: Rect, width
crate::scenario::publish_handle(handle, pos2(rect.right() - BROWSER_RAIL / 2.0, rect.center().y));
}
/// The width of the browser folded to its rail beside a left History.
pub(crate) fn collapsed_width() -> f32 {
let t = Tokens::get();
t.space_24 + t.space_10
}
/// One content-hugging browser; the shared container supplies floating or flush compact chrome.
pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {
let available = ui.available_rect_before_wrap();
@@ -986,11 +992,12 @@ pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {
let bounds = if stacked {
crate::timeline_left::stacked_rects(app, available).0
} else {
panel_bounds(available, if vertical { None } else { app.shell.history }, if collapsed { t.space_24 + t.space_10 } else { width }, gap)
panel_bounds(available, if vertical { None } else { app.shell.history }, if collapsed { collapsed_width() } else { width }, gap)
};
app.shell.browser = None;
let min_height = HEADER_H + 2.0 * (CARD_INSET + 1.0);
if bounds.is_positive() && bounds.height() >= min_height {
// A dialog in the left column holds the browser's place (`dialog_column`).
if !crate::dialog_column::holds(app) && bounds.is_positive() && bounds.height() >= min_height {
let fill = if container.floating() && app.preferences.browser_float { t.panel.gamma_multiply(BROWSER_FLOAT_ALPHA) } else { t.panel };
let frame = container.frame(ui.ctx(), fill, crate::frame::Side::Left).inner_margin(CARD_INSET as i8);
let inner_width = (bounds.width() - frame.total_margin().sum().x).max(0.0);
+104
View File
@@ -0,0 +1,104 @@
//! Command dialogs in the left column (#6707). With Preferences › Interface › Dialogs set to
//! *In the left column* (`dialog_place: "left_column"`), an open command dialog takes the place
//! of the browser and of the History at the left, whichever of them the column shows, at the
//! column's width and never narrower than the dialog's own card. The column is only not drawn
//! while the dialog holds it: no width, fold or collapsed state changes, so OK, Cancel or Esc
//! bring it back exactly as it was.
//!
//! - History at the bottom: the dialog takes the browser's place and the strip stays.
//! - No column at the left (the browser hidden, or translucent over the view, and the History
//! not at the left): the dialog docks at the left edge in a column of its own width.
//! - The Assistant docked on the left keeps the outside edge: the column starts beside it, as
//! the browser does.
//! - Compact layout with the History at the left: the History's edge panel stays allocated
//! (empty) under the dialog, so the view keeps its size and the model doesn't move.
//! - The Sketch Palette keeps the right edge; Delete confirmations stay where they are.
use egui::{Rect, pos2};
use serde::{Deserialize, Serialize};
use crate::SolveApp;
use crate::theme::Tokens;
use crate::ui_kit::{Container, Surface};
/// Where command dialogs open (Preferences › Interface › Dialogs).
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DialogPlace {
/// Docked at the view's edge: the right, or the left while the Sketch Palette holds the right.
#[default]
Edge,
/// In the left column, in place of the browser and the History there.
LeftColumn,
}
/// Does the open dialog hold the left column this frame?
pub(crate) fn holds(app: &SolveApp) -> bool {
app.preferences.dialog_place == DialogPlace::LeftColumn && app.dialog.as_ref().is_some_and(crate::dialogs::docks)
}
/// The History is drawn at the left this frame (beside or under the browser).
fn left_history(app: &SolveApp) -> bool {
app.ui.show_timeline && app.preferences.timeline_left && !crate::render_workspace::active(app)
}
/// The column a dialog of `width` holds, laid out in `available` (the space the browser and a
/// left History are laid out in this frame): from the left edge, beside the Assistant, to the
/// right of what the column shows, at least `width` wide, and from the top down to a bottom
/// History card. It mirrors where `timeline_left::left_panel` and `browser::browser` put
/// their cards.
pub(crate) fn rect(app: &SolveApp, available: Rect, width: f32) -> Rect {
let t = Tokens::get();
let panel = Container::for_layout(app.ui.layout, Surface::Panel);
let gap = panel.gap();
let left = (available.left() + crate::agent_chat::left_inset(app, available) + gap).min(available.right());
let history = left_history(app);
let stacked = history && app.preferences.timeline_under_browser;
let browser_width = crate::browser::browser_width(app.preferences.browser_width);
let mut right = left;
if stacked {
// Browser and History share one column of the browser's width.
right = left + browser_width;
} else if history {
right = left + crate::timeline_left::strip_width(app);
}
let translucent = panel.floating() && app.preferences.browser_float;
if app.ui.show_browser && !stacked && !translucent {
let from = if history { right + gap } else { left };
let collapsed = history && app.preferences.timeline_left_browser_collapsed;
right = from + if collapsed { crate::browser::collapsed_width() } else { browser_width };
}
let bottom = app.shell.history.filter(|_| app.ui.show_timeline && !app.preferences.timeline_left).map_or(available.bottom(), |h| h.top()) - gap;
let width = if width.is_finite() { width.max(t.space_24) } else { t.form_card_width };
let right = right.max(left + width).min(available.right() - gap).max(left);
Rect::from_min_max(pos2(left, available.top()), pos2(right, bottom.max(available.top())))
}
/// The column the dialog `d` holds, or `None` when it docks at the view's edge. The column
/// laid out with the browser this frame, or (a dialog opened after that, from a key in the view)
/// the same column worked out now from the space the browser had; the next frame then leaves
/// the browser out.
pub(crate) fn place(app: &SolveApp, ctx: &egui::Context, d: &crate::dialogs::Dialog) -> Option<Rect> {
if app.preferences.dialog_place != DialogPlace::LeftColumn || !crate::dialogs::docks(d) {
return None;
}
let column = app.shell.dialog_column.or_else(|| {
ctx.request_repaint();
app.shell.left_space.map(|available| rect(app, available, crate::dialogs::card_width(d)))
});
column.filter(|r| r.is_finite() && r.is_positive())
}
/// Lay out this frame's column before the browser and the History are drawn: they skip
/// themselves while a dialog holds it, and the view's content area starts beside it.
pub(crate) fn layout(app: &mut SolveApp, available: Rect) {
app.shell.left_space = Some(available);
app.shell.dialog_column = app.dialog.as_ref().filter(|_| holds(app)).map(|d| rect(app, available, crate::dialogs::card_width(d)));
}
/// The bounds the dialog's card is placed in: the column's left and top, the space's right edge,
/// and the column's bottom plus the gap the card keeps to it.
pub(crate) fn bounds(app: &SolveApp, column: Rect, viewport: Rect) -> Rect {
let gap = Container::for_layout(app.ui.layout, Surface::Feature).gap();
Rect::from_min_max(column.min, pos2(viewport.right().max(column.right()), column.bottom() + gap))
}
+38 -18
View File
@@ -2743,6 +2743,24 @@ pub(crate) fn sync_feature_edit_sketch(app: &mut SolveApp) {
});
}
/// Does this dialog dock as a card (at the view's edge or in the left column)? A delete
/// confirmation is a centred prompt instead.
pub(crate) fn docks(d: &Dialog) -> bool {
!matches!(d.kind, Kind::ConfirmDelete { .. })
}
/// The width a dialog's card asks for: the managers' wider form, a study's table, or a card.
pub(crate) fn card_width(d: &Dialog) -> f32 {
let t = Tokens::get();
if matches!(d.kind, Kind::Appearance(_) | Kind::Material { .. }) {
t.form_card_width + t.form_label_width + t.space_6
} else if matches!(&d.kind, Kind::Motion(k) if k.wide()) {
t.form_card_width * 3.0
} else {
t.form_card_width
}
}
/// A dialog's primary and closing actions. Measure only closes; a deletion's primary action
/// says what it does.
pub(crate) fn action_labels(kind: &Kind) -> (&'static str, &'static str) {
@@ -2764,6 +2782,7 @@ pub(crate) fn corner_confirms(d: &Dialog) -> bool {
/// Show the active dialog (if any), docked flush to an edge of the viewport just below the axis
/// view, sized to its content. The right edge is its place, except while a sketch is open: the
/// Sketch Palette keeps the right there, and the dialog takes the left so both stay on screen.
/// With Dialogs › In the left column it holds the left column instead (`dialog_column`).
pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
// A click in the view's corner is for the dialog open this frame, or for none.
let corner = app.viewport.corner.take();
@@ -2814,7 +2833,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let vp = crate::agent_chat::tool_space(app, crate::shell::content_rect(app, app.viewport.rect.unwrap_or_else(|| ctx.content_rect())));
// The Sketch Palette owns the right edge for as long as a sketch is being edited. A dialog
// started there docks at the left instead, so neither panel hides the other.
let side = if crate::sketch_palette::editing(app) && crate::sketch_palette::fits_beside_a_dialog(app, ctx) {
let column = crate::dialog_column::place(app, ctx, &d);
let side = if column.is_some() || (crate::sketch_palette::editing(app) && crate::sketch_palette::fits_beside_a_dialog(app, ctx)) {
crate::frame::Side::Left
} else {
crate::frame::Side::Right
@@ -2826,12 +2846,17 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
// Command dialogs share the last dragged offset on this side until the application
// exits, kept inside the viewport.
let drag_key = side.dialog_offset_key();
let moved = crate::frame::dock_offset(ctx, drag_key);
let docked = egui::pos2(side.anchor_x(vp), top);
let drag_bounds = crate::shell::tool_drag_rect(app, vp);
let anchor = crate::frame::offset_anchor(docked, moved, drag_bounds, side);
// exits, kept inside the viewport. In the left column a dialog stays in its place.
let (drag_key, moved, docked, drag_bounds, anchor) = if let Some(column) = column {
crate::scenario::publish_rect("dialog:column", column);
("", egui::Vec2::ZERO, column.min, crate::dialog_column::bounds(app, column, vp), column.min)
} else {
let drag_key = side.dialog_offset_key();
let moved = crate::frame::dock_offset(ctx, drag_key);
let docked = egui::pos2(side.anchor_x(vp), top);
let drag_bounds = crate::shell::tool_drag_rect(app, vp);
(drag_key, moved, docked, drag_bounds, crate::frame::offset_anchor(docked, moved, drag_bounds, side))
};
let mut keep = true;
let mut ok = false;
let mut applied = false;
@@ -2865,18 +2890,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
let ok_enabled = valid && !ok_label.is_empty() && app.applying.is_none();
let panel = crate::ui_kit::Panel::new(&heading, egui::Id::new(("sc_dialog", title(&d.kind))), anchor, drag_bounds, side, frame)
.actions(ok_label, close_label);
let panel = if matches!(d.kind, Kind::Appearance(_) | Kind::Material { .. }) {
panel.width(t.form_card_width + t.form_label_width + t.space_6)
} else if wide {
let panel = panel.wide();
if side == crate::frame::Side::Left {
let available = app.viewport.palette_rect.map_or(vp.width(), |r| (r.left() - vp.left() - t.space_8).max(0.0));
panel.width((t.form_card_width * 3.0).min(available))
} else {
panel
}
let panel = if let Some(column) = column {
panel.width(column.width()).joined(crate::ui_kit::DockEdges { left: true, top: true, ..Default::default() })
} else if wide && side == crate::frame::Side::Left {
let available = app.viewport.palette_rect.map_or(vp.width(), |r| (r.left() - vp.left() - t.space_8).max(0.0));
panel.width(card_width(&d).min(available))
} else {
panel
panel.width(card_width(&d))
};
let reset_scroll = d.reset_scroll;
let panel =
+4 -1
View File
@@ -32,6 +32,7 @@ pub mod crash_ui;
pub mod deferred;
pub mod delete;
pub mod design_properties;
pub mod dialog_column;
mod dialog_descriptor;
pub mod dialogs;
pub mod dialogs_appearance;
@@ -2209,7 +2210,8 @@ impl SolveApp {
self.shell.cards = vec![cards.workspace, cards.ribbon];
self.shell.history = if left_timeline {
let below_ribbon = egui::Rect::from_min_max(egui::pos2(full.left(), cards.bottom), full.max);
Some(timeline_left::floating_rect(self, below_ribbon))
// A dialog in the left column holds the History's place.
(!dialog_column::holds(self)).then(|| timeline_left::floating_rect(self, below_ribbon))
} else {
show_timeline.then(|| timeline::floating_rect(full))
};
@@ -2238,6 +2240,7 @@ impl SolveApp {
if floating && show_timeline && !left_timeline {
timeline::timeline(self, ui);
}
dialog_column::layout(self, ui.available_rect_before_wrap());
if left_timeline {
timeline_left::left_panel(self, ui);
}
+4
View File
@@ -663,6 +663,9 @@ preference_settings! {
/// Draw the parts browser on a translucent card over the 3D view instead of a column of its
/// own, so the workspace keeps the whole window width.
browser_float: bool = false, PAGE_INTERFACE;
/// Where command dialogs open: at the view's edge, or in the left column in place of the
/// browser and the History there (#6707).
dialog_place: crate::dialog_column::DialogPlace = Default::default(), PAGE_INTERFACE;
/// The wheel zooms toward the point under the cursor (else toward the view's centre).
zoom_to_cursor: bool = true, PAGE_NAVIGATION => check("Zoom to the cursor", "The wheel zooms toward the point under the cursor (off: toward the view's centre)");
/// Spread discrete wheel input across frames (off: apply each event immediately).
@@ -3422,6 +3425,7 @@ mod tests {
("timeline_under_browser", json!(true), PAGE_INTERFACE),
("history_sketches", json!("under_feature"), PAGE_INTERFACE),
("browser_float", json!(true), PAGE_INTERFACE),
("dialog_place", json!("left_column"), PAGE_INTERFACE),
("color_vision", json!("protan"), PAGE_INTERFACE),
("viewport_theme", json!("light"), PAGE_INTERFACE),
("view_confirm_corner", json!(true), PAGE_INTERFACE),
+11
View File
@@ -112,6 +112,17 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
}
});
});
// Where command dialogs open (#6707).
ui_kit::row(ui, app.tr("prefs.dialogs"), |ui| {
use crate::dialog_column::DialogPlace;
let mut selected = usize::from(app.preferences.dialog_place == DialogPlace::LeftColumn);
let options = [app.tr("prefs.dialogs_edge"), app.tr("prefs.dialogs_left_column")];
let segments = ui.scope(|ui| ui_kit::segmented(ui, &mut selected, &options, Default::default()));
segments.response.on_hover_text(app.tr("prefs.dialogs_note"));
if segments.inner {
app.preferences.dialog_place = if selected == 1 { DialogPlace::LeftColumn } else { DialogPlace::Edge };
}
});
// Where a dialog's and a sketch's OK and Cancel also sit (#6709).
ui_kit::row(ui, "", |ui| {
let check = setting::view_confirm_corner(app, ui).on_hover_text(app.tr("prefs.view_confirm_corner_note"));
+7
View File
@@ -103,6 +103,10 @@ pub(crate) struct State {
pub history_folding: Option<[f32; 2]>,
pub history_fold_motion: Option<[crate::timeline_left::FoldMotion; 2]>,
pub content: Option<Rect>,
/// The space the browser and a left History are laid out in this frame.
pub left_space: Option<Rect>,
/// The left column an open dialog holds this frame (`dialog_column`).
pub dialog_column: Option<Rect>,
}
/// One source of occlusion for navigation, picking, overlays and fit.
@@ -170,6 +174,9 @@ pub(crate) fn workspace_content(app: &SolveApp, mut content: Rect) -> Rect {
if let Some(browser) = app.shell.browser {
content.min.x = (browser.right() + gap).clamp(content.left(), content.right());
}
if let Some(column) = app.shell.dialog_column {
content.min.x = (column.right() + gap).clamp(content.left(), content.right());
}
content
}
+227
View File
@@ -680,3 +680,230 @@ fn embed_keeps_model_panels_without_application_chrome() {
assert!(rect_of("browser:card").is_some());
assert!(h.app.viewport.rect.is_some());
}
/// A design with a finished sketch nothing uses yet, so Extrude opens ready for OK.
fn sketched(h: &mut Harness) {
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[40,30]})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
}
/// Dialogs › In the left column (#6707): Extrude takes the place of the browser and the History
/// at the left, at the column's width and never narrower than its card, in both layouts and
/// every History dock. The view keeps its size, the dialog is covered, the content area starts
/// beside it, and OK, Cancel or Esc bring the column back exactly as it was.
#[test]
fn a_dialog_in_the_left_column_takes_the_place_of_browser_and_history() {
let card = crate::theme::Tokens::get().form_card_width;
for mode in [LayoutMode::Floating, LayoutMode::Docked] {
for (dock, close) in [("bottom", "Cancel"), ("left", "Escape"), ("under_browser", "OK")] {
let what = format!("{mode:?}, History {dock}, {close}");
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1400,"height":900}));
h.call("ui.set", json!({"layout":mode}));
h.call("ui.prefs", json!({"dialog_place":"left_column"}));
h.app.run("view.history_layout", json!({"dock":dock})).unwrap();
sketched(&mut h);
h.settle();
let browser = h.app.shell.browser.expect("browser");
let history = h.app.shell.history.expect("history");
let viewport = h.app.viewport.rect.unwrap();
let prefs = serde_json::to_value(&h.app.preferences).unwrap();
let column = if dock == "bottom" { browser } else { browser.union(history) };
h.step(&json!({"start":"solid.extrude"})).unwrap();
h.settle();
let dialog = h.app.viewport.dialog_rect.expect("dialog");
assert_eq!(rect_of("dialog:outer"), Some(dialog), "{what}");
let place = rect_of("dialog:column").expect("the column is published");
assert!((dialog.left() - column.left()).abs() <= 1.0 && (place.left() - column.left()).abs() <= 1.0, "{what}: {dialog:?} {column:?}");
assert!((dialog.top() - column.top()).abs() <= 1.0, "{what}: {dialog:?} {column:?}");
// The card's outline lies outside its response rect, one stroke at each side.
assert!((dialog.width() - column.width().max(card)).abs() <= 2.5, "{what}: {dialog:?} {column:?}");
assert!(dialog.bottom() <= place.bottom() + 1.0, "{what}: {dialog:?} {place:?}");
assert!(rect_of("browser:card").is_none() && h.app.shell.browser.is_none(), "{what}: the browser is not drawn");
if dock == "bottom" {
assert_eq!(h.app.shell.history, Some(history), "{what}: the bottom strip stays");
assert!(dialog.bottom() < history.top(), "{what}");
} else {
assert!(rect_of("history:vertical").is_none(), "{what}: the History is not drawn");
}
assert_eq!(h.app.viewport.rect, Some(viewport), "{what}: the view keeps its size");
assert!(covered(&h.app, dialog.center()), "{what}");
assert!(content_rect(&h.app, viewport).left() >= dialog.right(), "{what}");
assert!(h.widget("Distance").is_some(), "{what}: the inputs are there");
match close {
"Escape" => h.step(&json!({"key":"Escape"})).unwrap(),
other => h.step(&json!({"widget":other})).unwrap(),
}
h.settle();
assert!(h.app.dialog.is_none(), "{what}");
assert_eq!(h.app.session.doc.features.len(), if close == "OK" { 2 } else { 1 }, "{what}: OK adds the extrude");
let back = h.app.shell.browser.expect("the browser is back");
assert_eq!((back.x_range(), back.top()), (browser.x_range(), browser.top()), "{what}");
assert_eq!(h.app.shell.history, Some(history), "{what}: the History is back as it was");
assert_eq!(serde_json::to_value(&h.app.preferences).unwrap(), prefs, "{what}: no width or fold changed");
assert!(rect_of("dialog:column").is_none(), "{what}");
}
}
}
/// With no column at the left (the browser hidden, or translucent over the view) a dialog in
/// the left column docks at the left edge at its own width, above the bottom History strip.
#[test]
fn without_a_left_column_a_dialog_docks_at_the_left_edge_at_its_own_width() {
let card = crate::theme::Tokens::get().form_card_width;
for (mode, browser) in [(LayoutMode::Floating, "hidden"), (LayoutMode::Docked, "hidden"), (LayoutMode::Floating, "translucent")] {
let what = format!("{mode:?}, browser {browser}");
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1400,"height":900}));
h.call("ui.set", json!({"layout":mode}));
h.call("ui.prefs", json!({"dialog_place":"left_column","browser_float":browser == "translucent"}));
h.app.ui.show_browser = browser != "hidden";
sketched(&mut h);
h.settle();
let history = h.app.shell.history.expect("history");
let viewport = h.app.viewport.rect.unwrap();
h.step(&json!({"start":"solid.extrude"})).unwrap();
h.settle();
let dialog = h.app.viewport.dialog_rect.expect("dialog");
let gap = Container::for_layout(mode, Surface::Panel).gap();
assert!((dialog.left() - (viewport.left() + gap)).abs() <= 1.0, "{what}: {dialog:?} {viewport:?}");
assert!((dialog.width() - card).abs() <= 2.5, "{what}: {dialog:?}");
assert!(dialog.bottom() < history.top(), "{what}");
assert!(rect_of("browser:card").is_none(), "{what}");
h.step(&json!({"widget":"Cancel"})).unwrap();
h.settle();
assert_eq!(rect_of("browser:card").is_some(), browser == "translucent", "{what}");
}
}
/// The Assistant docked on the left keeps the outside edge: the column starts beside it, where
/// the browser was.
#[test]
fn a_dialog_in_the_left_column_starts_beside_the_assistant() {
let mut h = Harness::new();
h.app.home.open = false;
h.call("ui.resize", json!({"width":1800,"height":1000}));
h.call("ui.set", json!({"layout":"floating"}));
h.call("ui.prefs", json!({"dialog_place":"left_column"}));
h.call("ui.agent_chat", json!({"open":true,"side":"left","width":380,"picker":false}));
h.frames(5);
let browser = h.app.shell.browser.unwrap();
h.app.start("sketch.create");
h.frames(5);
let chat = h.app.agent_chat.panel_rect.unwrap();
let dialog = h.app.viewport.dialog_rect.unwrap();
assert!((dialog.left() - browser.left()).abs() <= 1.0, "{dialog:?} {browser:?}");
assert!(!dialog.intersect(chat).is_positive(), "{dialog:?} {chat:?}");
let title = crate::scenario::handle_at("dialog:title").unwrap();
h.call("ui.drag", json!({"x0":title.x,"y0":title.y,"x1":title.x + 300.0,"y1":title.y + 200.0,"steps":10}));
h.frames(4);
assert_eq!(h.app.viewport.dialog_rect, Some(dialog), "a dialog in the column stays in its place");
}
/// The Sketch Palette keeps the right edge while a sketch dialog holds the left column, also on
/// a view too narrow for both side by side; editing a feature reopens its dialog in the column
/// and Cancel rolls the marker back.
#[test]
fn the_sketch_palette_stays_and_editing_a_feature_opens_in_the_left_column() {
for width in [1400.0, 900.0] {
let mut h = Harness::new();
h.call("ui.resize", json!({"width":width,"height":900}));
h.call("ui.prefs", json!({"dialog_place":"left_column"}));
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[40,30]})).unwrap();
h.settle();
let palette = rect_of("sketch_palette:outer").expect("palette");
let browser = h.app.shell.browser.unwrap();
h.step(&json!({"start":"inspect.measure"})).unwrap();
h.settle();
let dialog = h.app.viewport.dialog_rect.expect("measure");
let kept = rect_of("sketch_palette:outer").expect("the palette stays on screen");
assert!((kept.right() - palette.right()).abs() <= 1.0 && (kept.top() - palette.top()).abs() <= 1.0, "width {width}: {kept:?} {palette:?}");
assert!((dialog.left() - browser.left()).abs() <= 1.0 && !dialog.intersect(palette).is_positive(), "width {width}: {dialog:?}");
h.step(&json!({"widget":"Close"})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
h.app.run("solid.extrude", json!({"distance":10})).unwrap();
h.settle();
let extrude = h.app.session.doc.features.last().unwrap().id;
let marker = h.app.session.doc.marker;
h.app.edit_feature(extrude);
h.settle();
assert!(h.app.dialog.as_ref().is_some_and(|d| d.editing.is_some()));
assert_ne!(h.app.session.doc.marker, marker, "editing rolls the marker to the feature");
let edit = h.app.viewport.dialog_rect.expect("edit dialog");
assert!((edit.left() - browser.left()).abs() <= 1.0, "width {width}: {edit:?}");
assert!(h.app.shell.browser.is_none());
h.step(&json!({"widget":"Cancel"})).unwrap();
h.settle();
assert_eq!(h.app.session.doc.marker, marker);
assert!(h.app.shell.browser.is_some());
}
}
/// OK and Cancel in the view's corner (#6709) with a dialog in the left column: the pair keeps
/// the view's top right, beside the column's content area and clear of the dialog; its check
/// applies the dialog and its cross cancels, and either way the column comes back.
#[test]
fn the_view_corner_answers_a_dialog_in_the_left_column() {
for how in ["ok", "cancel"] {
let mut h = Harness::new();
h.call("ui.resize", json!({"width":1400,"height":900}));
h.call("ui.prefs", json!({"dialog_place":"left_column","view_confirm_corner":true}));
sketched(&mut h);
h.settle();
let browser = h.app.shell.browser.expect("browser");
h.step(&json!({"start":"solid.extrude"})).unwrap();
h.settle();
let dialog = h.app.viewport.dialog_rect.expect("dialog");
let pair = rect_of("view:confirm").expect("the pair in the view's corner");
let content = content_rect(&h.app, h.app.viewport.rect.unwrap());
assert!((dialog.left() - browser.left()).abs() <= 1.0, "{how}: the dialog holds the column: {dialog:?}");
assert!(content.contains_rect(pair) && pair.left() > content.center().x, "{how}: {pair:?} in the top right of {content:?}");
assert!(!pair.intersects(dialog), "{how}: {pair:?} {dialog:?}");
assert!(covered(&h.app, pair.center()), "{how}");
assert_eq!(crate::scenario::count_of("view:confirm:ok:enabled"), Some(1.0), "{how}");
h.step(&json!({"click":{"handle":format!("view:confirm:{how}")}})).unwrap();
h.settle();
assert!(h.app.dialog.is_none(), "{how}: the dialog closes");
assert_eq!(h.app.session.doc.features.len(), if how == "ok" { 2 } else { 1 }, "{how}: the check makes the extrude");
assert!(h.app.shell.browser.is_some_and(|b| b.x_range() == browser.x_range()), "{how}: the column comes back");
}
}
/// Dialogs is an Interface preference: set from the page or the control channel, saved,
/// refused when unknown, and Cancel and Restore Defaults put it back. A dialog already open
/// moves with it.
#[test]
fn dialog_place_is_saved_and_survives_cancel_defaults_and_bad_input() {
use crate::dialog_column::DialogPlace;
let mut h = Harness::new();
sketched(&mut h);
h.step(&json!({"start":"solid.extrude"})).unwrap();
h.settle();
let right = h.app.viewport.dialog_rect.unwrap();
assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge);
h.call("ui.prefs", json!({"open":"Interface"}));
crate::prefs::reveal_preference(&mut h, "dialog:Dialogs:In the left column");
h.step(&json!({"click":{"handle":"dialog:Dialogs:In the left column"}})).unwrap();
assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn);
h.call("ui.prefs", json!({"button":"ok"}));
h.settle();
let left = h.app.viewport.dialog_rect.unwrap();
assert!(left.left() < right.left() && h.app.shell.browser.is_none(), "the open dialog moves to the column: {left:?}");
let mut restored = crate::SolveApp::new(Default::default(), Default::default());
restored.load_prefs(&h.app.prefs());
assert_eq!(restored.preferences.dialog_place, DialogPlace::LeftColumn);
h.call("ui.prefs", json!({"open":"Interface","dialog_place":"edge"}));
h.call("ui.prefs", json!({"button":"cancel"}));
assert_eq!(h.app.preferences.dialog_place, DialogPlace::LeftColumn);
h.call("ui.prefs", json!({"open":"Interface"}));
h.call("ui.prefs", json!({"button":"defaults"}));
assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge);
h.call("ui.prefs", json!({"button":"ok"}));
assert!(crate::prefs::set(&mut h.app, &json!({"dialog_place":"top"})).is_err());
assert_eq!(h.app.preferences.dialog_place, DialogPlace::Edge);
restored.load_prefs(r#"{"preferences":{"dialog_place":"top","default_units":"in"}}"#);
assert_eq!(restored.preferences.dialog_place, DialogPlace::Edge);
assert_eq!(restored.preferences.default_units, "in");
}
+3 -2
View File
@@ -253,9 +253,10 @@ pub fn fits_beside_a_dialog(app: &SolveApp, ctx: &egui::Context) -> bool {
}
/// Is the palette on screen? It stays for as long as a sketch is being edited, a command dialog
/// open or not: the dialog takes the left edge of the viewport and the palette keeps the right.
/// open or not: the dialog takes the left edge of the viewport (or the left column) and the
/// palette keeps the right.
pub fn visible(app: &SolveApp, ctx: &egui::Context) -> bool {
editing(app) && ((app.dialog.is_none() && app.tree.redefine.is_none()) || fits_beside_a_dialog(app, ctx))
editing(app) && ((app.dialog.is_none() && app.tree.redefine.is_none()) || fits_beside_a_dialog(app, ctx) || crate::dialog_column::holds(app))
}
/// The creation family of the tool that is running, and the exact variant it is running, when
+17 -4
View File
@@ -181,10 +181,16 @@ pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let available = ui.available_rect_before_wrap();
app.shell.history_dock_space = Some(available);
// A dialog in the left column holds the History's place (`dialog_column`).
let held = crate::dialog_column::holds(app);
if held {
// No row is under the pointer: the view lights no feature for the History.
app.viewport.hover_feature = None;
}
if Container::for_layout(app.ui.layout, Surface::Panel).floating() || stacked(app) {
let bounds = floating_rect(app, available);
app.shell.history = None;
if !bounds.is_finite() || bounds.width() < crate::ui_kit::history_width(false) || bounds.height() < t.control_height {
if held || !bounds.is_finite() || bounds.width() < crate::ui_kit::history_width(false) || bounds.height() < t.control_height {
return;
}
let container = Container::new(ui.ctx(), Surface::Panel).joined(crate::ui_kit::DockEdges { left: true, top: true, ..Default::default() });
@@ -217,15 +223,22 @@ pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {
if width < crate::ui_kit::history_width(false) {
return;
}
// Held by a dialog, the docked panel stays allocated but empty, so the view keeps its size.
let response = Container::new(ui.ctx(), Surface::Panel)
.edge("sc_timeline_left", Edge::Left)
.exact_size(width)
.resizable(false)
.frame(Container::new(ui.ctx(), Surface::Panel).edge_frame(t.panel).inner_margin(t.space_4))
.show(ui, |ui| left_timeline(app, ui));
crate::scenario::publish_rect("history:vertical", response.response.rect);
.show(ui, |ui| {
if !held {
left_timeline(app, ui);
}
});
app.shell.history = Some(response.response.rect);
seam_handle(app, ui, response.response.rect);
if !held {
crate::scenario::publish_rect("history:vertical", response.response.rect);
seam_handle(app, ui, response.response.rect);
}
}
}
+3 -2
View File
@@ -111,10 +111,11 @@ impl Container {
}
}
/// Movable tool sheets round all exposed corners, joining only their right dock edge.
/// Movable tool sheets round all exposed corners, joining only their right dock edge (or the
/// edges they were declared `joined` at).
pub(crate) fn tool_frame(self, mut frame: Frame, right_docked: bool) -> Frame {
if self.surface == Surface::Feature && !self.floating() {
frame.corner_radius = Self::compact_rounding(DockEdges { right: right_docked, ..Default::default() });
frame.corner_radius = Self::compact_rounding(self.joined.unwrap_or(DockEdges { right: right_docked, ..Default::default() }));
}
frame
}
+17 -2
View File
@@ -194,11 +194,13 @@ pub(crate) struct Panel<'a> {
ok: &'a str,
cancel: &'a str,
reset_scroll: bool,
joined: Option<super::DockEdges>,
}
pub(crate) struct FeatureOptions<'a> {
pub icon: &'a str,
pub title: &'a str,
/// The dock offset the title band drags; empty for a card that stays in its place.
pub drag_key: &'a str,
pub moved: egui::Vec2,
pub docked: egui::Pos2,
@@ -265,9 +267,17 @@ impl<'a> Panel<'a> {
ok: "OK",
cancel: "Cancel",
reset_scroll: false,
joined: None,
}
}
/// The edges the card meets the window or a docked surface at (a dialog in the left column):
/// in Compact, only its other corners round.
pub(crate) fn joined(mut self, edges: super::DockEdges) -> Self {
self.joined = Some(edges);
self
}
/// A newly opened manager starts at its first section. Later frames retain user scrolling.
pub(crate) fn reset_scroll(mut self, reset: bool) -> Self {
self.reset_scroll = reset;
@@ -324,7 +334,8 @@ impl<'a> Panel<'a> {
crate::frame::Side::Right => anchor.x,
crate::frame::Side::Left => anchor.x + self.width.min(self.viewport.width().max(0.0)),
};
super::Container::new(ctx, super::Surface::Feature).tool_frame(self.frame, right >= self.viewport.right() - 0.5)
let container = super::Container::new(ctx, super::Surface::Feature);
self.joined.map_or(container, |edges| container.joined(edges)).tool_frame(self.frame, right >= self.viewport.right() - 0.5)
}
pub(crate) fn window(&self, ctx: &egui::Context) -> egui::Window<'a> {
@@ -403,7 +414,11 @@ impl<'a> Panel<'a> {
let t = Tokens::get();
let min = ui.cursor().min;
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);
if heading.drag_key.is_empty() {
scenario::publish_handle("dialog:title", band.center());
} else {
crate::frame::drag_dock(ui, band, heading.drag_key, heading.moved, self.bounded_anchor(ui.ctx()) - heading.docked);
}
let mut close = false;
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))
@@ -0,0 +1,24 @@
[
{"note": "Dialogs: In the left column (#6707). Extrude takes the browser's place at its width (never narrower than the card), the bottom History strip stays, and Cancel (or Enter, which applies it) brings the browser back as it was."},
{"call": "ui.prefs", "params": {"dialog_place": "left_column"}},
{"start": "sketch.create"},
{"click": {"plane": "XY"}},
{"start": "sketch.rectangle.two_point"},
{"click": {"sketch": [0, 0]}},
{"click": {"sketch": [40, 30]}},
{"key": "Escape"},
{"start": "sketch.finish"},
{"expect": {"sketching": false, "same_width": "browser:card"}},
{"start": "solid.extrude"},
{"frames": 4},
{"expect": {"dialog": "Extrude", "spans": {"inner": "dialog:outer", "outer": "dialog:column", "axis": "x", "tol": 3}}},
{"expect": {"shown_handles": ["dialog:OK"]}},
{"widget": "Cancel"},
{"frames": 4},
{"expect": {"dialog": null, "same_width": "browser:card"}},
{"start": "solid.extrude"},
{"text": "10"},
{"key": "Enter"},
{"frames": 4},
{"expect": {"dialog": null, "bodies": 1, "same_width": "browser:card"}}
]
+40 -2
View File
@@ -1,6 +1,6 @@
//! Layout checks over every toolbar command, headless (see `solidcraft_ui_egui::scenario`):
//! each command's dialog opens docked at the viewport's right within its width limits, and
//! every window it opens fits on screen.
//! each command's dialog opens docked at the viewport's right within its width limits (or in
//! the left column, when the preferences put it there), and every window it opens fits on screen.
use serde_json::{Value, json};
use solidcraft_ui_egui::scenario::{Harness, check, rect_of};
@@ -55,6 +55,44 @@ fn every_dialog_opens_docked_within_its_width_limits() {
assert!(bad.is_empty(), "{} problems:\n{}", bad.len(), bad.join("\n"));
}
/// Dialogs › In the left column (#6707): every command's dialog opens in the browser's place, at
/// least as wide as the browser and its own card, and fits on screen.
#[test]
fn every_dialog_opens_in_the_left_column_when_asked() {
let mut bad = Vec::new();
let mut seen = 0;
for spec in solidcraft_engine::command_specs() {
if spec.tab.is_empty() || spec.tab == "SKETCH" {
continue;
}
let mut h = harness();
h.call("ui.prefs", json!({"dialog_place": "left_column"}));
h.frames(2);
let Some(browser) = rect_of("browser:card") else {
bad.push(format!("{}: no browser before the dialog", spec.id));
continue;
};
h.call("ui.start", json!({"command": spec.id}));
h.frames(4);
let (Some(dialog), Some(column)) = (rect_of("dialog:outer").filter(|_| h.app.dialog.is_some()), rect_of("dialog:column")) else {
continue;
};
seen += 1;
let screen = h.ctx.content_rect();
if (dialog.left() - browser.left()).abs() > 1.0 || (dialog.top() - browser.top()).abs() > 1.0 {
bad.push(format!("{}: dialog {dialog:?} is not in the browser's place {browser:?}", spec.id));
}
if dialog.width() < browser.width().max(260.0) - 2.5 || (dialog.width() - column.width()).abs() > 2.5 {
bad.push(format!("{}: dialog width {:.0}, column {:.0}, browser {:.0}", spec.id, dialog.width(), column.width(), browser.width()));
}
if !screen.expand(1.0).contains_rect(dialog) || rect_of("browser:card").is_some() {
bad.push(format!("{}: dialog {dialog:?} off screen or beside a browser", spec.id));
}
}
assert!(seen > 20, "only {seen} commands opened a dialog in the column");
assert!(bad.is_empty(), "{} problems:\n{}", bad.len(), bad.join("\n"));
}
/// Windows that are not command dialogs: each fits on screen.
#[test]
fn other_windows_fit_on_screen() {
+4 -1
View File
@@ -82,7 +82,10 @@
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. Interface › **Dialog buttons** › **Top** puts OK, Cancel and Apply in
value box in the viewport. Preferences › Interface › **Dialogs** › *In the left column* opens
them in the browser's place instead (and the History's, when it is at the left), at least as
wide as that column; the column comes back as it was when the dialog closes.
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
File diff suppressed because one or more lines are too long