SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Keep command dialogs above Browser and History (#8174) (#8203)
Colin Faulkingham27772ddba16f
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rsindex 474db59303..899d8369e6 100644--- a/crates/ui-egui/src/browser.rs+++ b/crates/ui-egui/src/browser.rs@@ -841,29 +841,25 @@ pub fn browser(app: &mut SolveApp, ui: &mut egui::Ui) {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);let inner_height = (bounds.height() - frame.total_margin().sum().y).max(0.0);- let card = Container::new(ui.ctx(), Surface::Panel)- .area(egui::Id::new("sc_browser_card"))- .fixed_pos(bounds.min)- .order(egui::Order::Middle)- .show(ui.ctx(), |ui| {- let limits = Rect::from_min_max(available.min, pos2(available.right(), bounds.bottom()));- let response = container.show_frame(ui, frame, limits, |ui| {- ui.set_width(inner_width);- ui.set_max_height(inner_height);- if stacked {- ui.set_min_height(inner_height);- ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, vec2(inner_width, inner_height))));- }- if collapsed {- browser_collapsed_rail(app, ui);- } else {- browser_contents(app, ui, &mut acts, true);- }- });- if !collapsed {- resize_column(app, ui, response.response.rect, width, "left-browser-rail");+ let card = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_browser_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {+ let limits = Rect::from_min_max(available.min, pos2(available.right(), bounds.bottom()));+ let response = container.show_frame(ui, frame, limits, |ui| {+ ui.set_width(inner_width);+ ui.set_max_height(inner_height);+ if stacked {+ ui.set_min_height(inner_height);+ ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, vec2(inner_width, inner_height))));+ }+ if collapsed {+ browser_collapsed_rail(app, ui);+ } else {+ browser_contents(app, ui, &mut acts, true);}});+ if !collapsed {+ resize_column(app, ui, response.response.rect, width, "left-browser-rail");+ }+ });let rect = card.response.rect;app.shell.browser = Some(rect);crate::scenario::publish_rect("browser:card", rect);diff --git a/crates/ui-egui/src/shell_tests.rs b/crates/ui-egui/src/shell_tests.rsindex 7d8bba3fa1..d3aeec4353 100644--- a/crates/ui-egui/src/shell_tests.rs+++ b/crates/ui-egui/src/shell_tests.rs@@ -525,6 +525,64 @@ fn tool_sheets_drag_over_browser_and_history_but_clear_protected_panels() {}}+#[test]+fn tool_sheets_stay_above_browser_and_history_after_panel_clicks() {+ for dock in ["bottom", "left", "under_browser"] {+ 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.app.run("view.history_layout", json!({"dock":dock})).unwrap();+ h.app.start("solid.extrude");+ h.settle();+ for panel in [h.app.shell.browser.unwrap(), h.app.shell.history.unwrap()] {+ let title = crate::scenario::handle_at("dialog:title").unwrap();+ let target = panel.center();+ h.call("ui.drag", json!({"x0":title.x,"y0":title.y,"x1":target.x,"y1":target.y,"steps":10}));+ let sheet = h.app.viewport.dialog_rect.unwrap();+ let overlap = sheet.intersect(panel);+ assert!(overlap.is_positive(), "{dock}: the dialog overlaps the panel");+ let exposed = panel.left_top() + egui::vec2(10.0, 10.0);+ assert!(!sheet.contains(exposed), "the panel click is outside the dialog");+ h.call("ui.click", json!({"x":exposed.x,"y":exposed.y}));+ let layer = h.ctx.layer_id_at(overlap.center()).unwrap();+ assert_eq!(layer.id, egui::Id::new(("sc_dialog", "EXTRUDE")), "{dock}: clicking a panel must not cover the dialog");+ let panel_layer = h.ctx.layer_id_at(exposed).unwrap();+ h.call("ui.click", json!({"x":1700,"y":500}));+ assert_eq!(h.ctx.layer_id_at(exposed), Some(panel_layer), "clicking the model view must not cover the panel");+ }+ h.step(&json!({"widget":"Cancel"})).unwrap();+ assert!(h.app.dialog.is_none(), "{dock}: the overlapping dialog remains clickable");+ }+}++#[test]+fn tool_sheet_dropdowns_and_preferences_still_open_above_the_sheet() {+ for layout in ["floating", "compact"] {+ let mut h = Harness::new();+ h.app.home.open = false;+ h.call("ui.resize", json!({"width":1400,"height":900}));+ h.call("ui.set", json!({"layout":layout}));+ h.app.start("solid.extrude");+ h.settle();+ let title = crate::scenario::handle_at("dialog:title").unwrap();+ h.call("ui.drag", json!({"x0":title.x,"y0":title.y,"x1":700,"y1":350,"steps":10}));+ h.step(&json!({"widget":"One Side"})).unwrap();+ h.step(&json!({"widget":"Symmetric"})).unwrap();+ assert!(matches!(h.app.dialog.as_ref().unwrap().kind, crate::dialogs::Kind::Extrude { direction: 2, .. }));+ let sheet = h.app.viewport.dialog_rect.unwrap();+ h.call("ui.prefs", json!({"open":"General"}));+ let preferences = rect_of("dialog:window").unwrap();+ let overlap = sheet.intersect(preferences);+ assert!(overlap.is_positive(), "Preferences overlaps the feature dialog");+ assert_eq!(h.ctx.layer_id_at(overlap.center()).unwrap().id, egui::Id::new("sc_prefs"), "Preferences receives input above the sheet");+ h.step(&json!({"widget":"Cancel"})).unwrap();+ assert!(!h.app.prefs_window.open && h.app.dialog.is_some(), "Cancel closes Preferences, leaving the feature dialog open");+ h.step(&json!({"widget":"Cancel"})).unwrap();+ assert!(h.app.dialog.is_none());+ }+}+#[test]fn compact_layout_is_saved_and_survives_cancel_apply_defaults_and_bad_input() {let mut h = Harness::new();diff --git a/crates/ui-egui/src/timeline_left.rs b/crates/ui-egui/src/timeline_left.rsindex d62c35febd..85bff8c55f 100644--- a/crates/ui-egui/src/timeline_left.rs+++ b/crates/ui-egui/src/timeline_left.rs@@ -184,20 +184,19 @@ fn split_handle(app: &mut SolveApp, ui: &egui::Ui, available: Rect) {return;}let rail = Rect::from_x_y_ranges(browser.x_range(), browser.bottom() - SPLIT_RAIL / 2.0..=history.top() + SPLIT_RAIL / 2.0);- Container::new(ui.ctx(), Surface::Canvas).area(egui::Id::new("sc_column_split")).order(egui::Order::Foreground).fixed_pos(rail.min).show(- ui.ctx(),- |ui| {- ui.set_min_size(rail.size());- let response = ui.interact(rail, egui::Id::new("sc_column_split_rail"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeVertical);- if response.dragged() {- let delta = ui.input(|input| input.pointer.delta().y);- if delta.is_finite() {- let header = header_outer_height().min(budget / 2.0);- app.preferences.browser_share = browser_split((browser.height() + delta) / budget, budget, header) / budget;- }+ let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_column_split")).fixed_pos(rail.min);+ ui.ctx().set_sublayer(ui.layer_id(), overlay.layer());+ overlay.show(ui.ctx(), |ui| {+ ui.set_min_size(rail.size());+ let response = ui.interact(rail, egui::Id::new("sc_column_split_rail"), Sense::drag()).on_hover_cursor(egui::CursorIcon::ResizeVertical);+ if response.dragged() {+ let delta = ui.input(|input| input.pointer.delta().y);+ if delta.is_finite() {+ let header = header_outer_height().min(budget / 2.0);+ app.preferences.browser_share = browser_split((browser.height() + delta) / budget, budget, header) / budget;}- },- );+ }+ });crate::scenario::publish_handle("left-column-split", rail.center());}@@ -241,27 +240,23 @@ pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {let fill = card_fill(app, container.floating());let frame = container.frame(ui.ctx(), fill, crate::frame::Side::Left).inner_margin(t.space_4);let inner = (bounds.size() - frame.total_margin().sum()).max(egui::Vec2::ZERO);- let card = Container::new(ui.ctx(), Surface::Panel)- .area(egui::Id::new("sc_timeline_left_card"))- .fixed_pos(bounds.min)- .order(egui::Order::Middle)- .show(ui.ctx(), |ui| {- let response = container.show_frame(ui, frame, available, |ui| {- ui.set_min_size(inner);- ui.set_max_size(inner);- ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, inner)));- left_timeline(app, ui);- });- if stacked(app) {- let width = crate::browser::browser_width(app.preferences.browser_width);- crate::browser::resize_column(app, ui, response.response.rect, width, "left-history-rail");- split_handle(app, ui, available);- }+ let card = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("sc_timeline_left_card")).fixed_pos(bounds.min).show(ui.ctx(), |ui| {+ let response = container.show_frame(ui, frame, available, |ui| {+ ui.set_min_size(inner);+ ui.set_max_size(inner);+ ui.set_clip_rect(ui.clip_rect().intersect(Rect::from_min_size(ui.max_rect().min, inner)));+ left_timeline(app, ui);});+ if stacked(app) {+ let width = crate::browser::browser_width(app.preferences.browser_width);+ crate::browser::resize_column(app, ui, response.response.rect, width, "left-history-rail");+ split_handle(app, ui, available);+ }+ });app.shell.history = Some(card.response.rect);crate::scenario::publish_rect("history:vertical", card.response.rect);if !stacked(app) {- seam_handle(app, ui, card.response.rect);+ seam_handle(app, ui, card.response.rect, card.response.layer_id);}} else {let width = strip_width(app).min(ui.available_width().max(0.0));@@ -282,7 +277,7 @@ pub fn left_panel(app: &mut SolveApp, ui: &mut egui::Ui) {app.shell.history = Some(response.response.rect);if !held {crate::scenario::publish_rect("history:vertical", response.response.rect);- seam_handle(app, ui, response.response.rect);+ seam_handle(app, ui, response.response.rect, response.response.layer_id);}}}@@ -292,29 +287,29 @@ fn names_fit(width: f32) -> bool {width >= crate::ui_kit::history_width(true) - (t.space_8 + t.space_2)}-fn seam_handle(app: &mut SolveApp, ui: &mut egui::Ui, card: Rect) {+fn seam_handle(app: &mut SolveApp, ui: &mut egui::Ui, card: Rect, parent: egui::LayerId) {let seam = crate::ui_kit::HistorySeam::new(card);let bounds = seam.edge.union(seam.pill);- Container::new(ui.ctx(), Surface::Canvas).area(egui::Id::new("history_seam_overlay")).order(egui::Order::Foreground).fixed_pos(bounds.min).show(- ui.ctx(),- |ui| {- ui.set_min_size(bounds.size());- ui.set_clip_rect(ui.ctx().content_rect());- let result = crate::ui_kit::history_seam(ui, card, card.width() >= crate::ui_kit::history_width(true));- if let Some(width) = result.width {- app.shell.history_drag_width = Some(width);- ui.ctx().request_repaint();- if result.released {- let _ = app.run("view.history_layout", json!({"width": width}));- app.shell.history_drag_width = None;- }- } else if result.toggle {- let width = crate::ui_kit::history_width(card.width() < crate::ui_kit::history_width(true));- let _ = app.run("view.history_layout", json!({"width":width}));- ui.ctx().request_repaint();+ let overlay = Container::new(ui.ctx(), Surface::Panel).area(egui::Id::new("history_seam_overlay")).fixed_pos(bounds.min);+ // The grip follows its panel when clicked, while remaining below movable dialogs.+ ui.ctx().set_sublayer(parent, overlay.layer());+ overlay.show(ui.ctx(), |ui| {+ ui.set_min_size(bounds.size());+ ui.set_clip_rect(ui.ctx().content_rect());+ let result = crate::ui_kit::history_seam(ui, card, card.width() >= crate::ui_kit::history_width(true));+ if let Some(width) = result.width {+ app.shell.history_drag_width = Some(width);+ ui.ctx().request_repaint();+ if result.released {+ let _ = app.run("view.history_layout", json!({"width": width}));+ app.shell.history_drag_width = None;}- },- );+ } else if result.toggle {+ let width = crate::ui_kit::history_width(card.width() < crate::ui_kit::history_width(true));+ let _ = app.run("view.history_layout", json!({"width":width}));+ ui.ctx().request_repaint();+ }+ });}/// Width alone chooses icons, names, horizontal transport and the optional title.diff --git a/crates/ui-egui/src/ui_kit/container.rs b/crates/ui-egui/src/ui_kit/container.rsindex e2346b238f..7a3adb0654 100644--- a/crates/ui-egui/src/ui_kit/container.rs+++ b/crates/ui-egui/src/ui_kit/container.rs@@ -250,7 +250,10 @@ impl Container {}pub fn area(self, id: Id) -> egui::Area {- egui::Area::new(id).enabled(self.input_enabled())+ // Persistent workspace cards stay below tool/system windows even when clicked.+ // Other areas keep egui's normal window layer; popups choose their own order.+ let order = if self.surface == Surface::Panel { egui::Order::Background } else { egui::Order::Middle };+ egui::Area::new(id).enabled(self.input_enabled()).order(order)}pub fn edge(self, id: impl Into<Id>, edge: Edge) -> egui::Panel {diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rsindex ced2da074a..37d95ef090 100644--- a/crates/ui-egui/src/ui_kit/panel.rs+++ b/crates/ui-egui/src/ui_kit/panel.rs@@ -312,7 +312,7 @@ impl<'a> Panel<'a> {return None;}let ctx = ui.ctx().clone();- Some(container.area(egui::Id::new(id)).fixed_pos(rect.min).movable(false).order(egui::Order::Middle).show(&ctx, |ui| {+ Some(container.area(egui::Id::new(id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {let frame = container.frame(&ctx, Tokens::get().panel, crate::frame::Side::Left).inner_margin(Tokens::get().space_4);container.show_frame(ui, frame, rect, |ui| {@@ -384,7 +384,7 @@ impl<'a> Panel<'a> {);let ctx = ui.ctx().clone();let mut move_side = None;- let response = container.area(egui::Id::new(options.id)).fixed_pos(rect.min).movable(false).order(egui::Order::Middle).show(&ctx, |ui| {+ let response = container.area(egui::Id::new(options.id)).fixed_pos(rect.min).movable(false).show(&ctx, |ui| {let frame = container.frame(&ctx, t.panel, if left { crate::frame::Side::Left } else { crate::frame::Side::Right }).inner_margin(0.0);let content = container.show_frame(ui, frame, bounds, |ui| {let size = (rect.size() - frame.total_margin().sum()).max(egui::Vec2::ZERO);