SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Feature dialog: draw the busy spinner in the footer row (#8362)
Daniela1a801fb31f5
diff --git a/crates/ui-egui/src/ui_kit/panel.rs b/crates/ui-egui/src/ui_kit/panel.rsindex f5bb2f580b..a011ab0b06 100644--- a/crates/ui-egui/src/ui_kit/panel.rs+++ b/crates/ui-egui/src/ui_kit/panel.rs@@ -807,23 +807,25 @@ impl<'a> Panel<'a> {return (close, action);}let corners = self.positioned_frame(ui.ctx()).corner_radius;- let action = super::footer(+ // The spinner sits in the footer's own row, at its side inset and on the buttons' centre+ // line, in the slot the status text leaves for it.+ let action = super::actions::footer_with_left(ui,self.ok,self.cancel,valid && !state.applying,super::Footer { apply: heading.apply_label, status: state.text.as_deref(), corners: Some(corners), ..Default::default() },+ |ui| {+ if state.busy {+ let (rect, _) = ui.allocate_exact_size(vec2(t.space_16, ui.available_height()), egui::Sense::hover());+ egui::Spinner::new().size(t.space_14).paint_at(ui, rect);+ scenario::publish_rect("dialog:footer:spinner", rect);+ let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));+ ui.interact(rect, ui.id().with("compute_status"), egui::Sense::hover()).on_hover_text(status);+ ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));+ }+ },);- if state.busy {- let rect = egui::Rect::from_min_size(- egui::pos2(ui.min_rect().left(), ui.min_rect().bottom() - super::row_height()),- vec2(t.space_16, super::row_height()),- );- egui::Spinner::new().size(t.space_14).paint_at(ui, rect);- let status = state.text.as_deref().unwrap_or_else(|| crate::i18n::tr_label("Updating the preview"));- ui.interact(rect, ui.id().with("compute_status"), egui::Sense::hover()).on_hover_text(status);- ui.ctx().request_repaint_after(std::time::Duration::from_millis(100));- }super::Container::finish_content(ui, self.positioned_frame(ui.ctx()));(close, action)})diff --git a/crates/ui-egui/src/ui_kit/panel_tests.rs b/crates/ui-egui/src/ui_kit/panel_tests.rsindex 96569d7111..49f74eed5c 100644--- a/crates/ui-egui/src/ui_kit/panel_tests.rs+++ b/crates/ui-egui/src/ui_kit/panel_tests.rs@@ -265,6 +265,50 @@ fn top_placement_shows_the_compute_status_in_the_title_row() {assert!(scenario::rect_of("dialog:header").unwrap().contains_rect(scenario::rect_of("dialog:cancel").unwrap()));}+/// With the buttons in the footer, the busy spinner sits in the footer's row: at its side inset+/// and on the buttons' centre line, not against the card's edge (it used to hang there).+#[test]+fn bottom_placement_puts_the_busy_spinner_in_the_footer_row() {+ let ctx = crate::fonts::test_context();+ let vp = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(640.0, 480.0));+ for _ in 0..3 {+ scenario::clear_handles();+ crate::test_support::frame(&ctx, egui::RawInput { screen_rect: Some(vp), ..Default::default() }, |_| {+ DialogButtons::Bottom.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("bottom_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: "bottom_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 spinner = scenario::rect_of("dialog:footer:spinner").expect("the spinner shows while busy");+ let actions = scenario::rect_of("dialog:footer:actions").unwrap();+ let ok = scenario::rect_of("dialog:ok").unwrap();+ assert!(actions.contains_rect(spinner), "{spinner:?} inside the footer row {actions:?}");+ assert!((spinner.left() - actions.left()).abs() < 0.5, "at the footer's inset: {spinner:?} {actions:?}");+ assert!((spinner.center().y - ok.center().y).abs() < 0.5, "on the buttons' line: {spinner:?} {ok:?}");+}+#[test]fn top_placement_keeps_a_managers_fold_beside_the_actions() {let ctx = crate::fonts::test_context();