diff --git a/crates/ui-egui/src/panels/panel_docking.rs b/crates/ui-egui/src/panels/panel_docking.rs index c05bd2d065..6e962cc553 100644 --- a/crates/ui-egui/src/panels/panel_docking.rs +++ b/crates/ui-egui/src/panels/panel_docking.rs @@ -154,6 +154,10 @@ fn display_width(column: &Column) -> f32 { /// The canvas panel's least width in points, for the docking layout and the dock-edge layout. pub(crate) const CANVAS_MIN_WIDTH: f32 = 200.0; +/// The narrowest column, in points, that still draws a panel's body; a narrower one shows only +/// its chrome. Deliberately independent of [`CANVAS_MIN_WIDTH`], although both are 200. +const PANEL_BODY_MIN_WIDTH: f32 = 200.0; + /// The least displayed width of a column: the app's 220-point panel minimum, unless the column is /// iconic (its icons fit in the narrow width) or has no panels. const MIN_COLUMN_WIDTH: f32 = 220.0; @@ -1578,7 +1582,7 @@ impl craft_ui::docking::DockContent for PanelContent<'_> { } // A window too small for the dock squeezes its column below the panels' minimum width, // which their layouts do not take. - if !self.collapsed.contains(id) && ui.available_width() >= 200.0 { + if !self.collapsed.contains(id) && ui.available_width() >= PANEL_BODY_MIN_WIDTH { let pro = crate::theme::Tokens::get(ui.ctx()).pro; ui.spacing_mut().item_spacing.y = if pro { 0.0 } else { 6.0 }; egui::Frame::NONE.inner_margin(crate::widgets::body_margin(pro)).show(ui, |ui| body(self.app, ui, id)); diff --git a/crates/ui-egui/src/panels/panel_docking/tests.rs b/crates/ui-egui/src/panels/panel_docking/tests.rs index 9c6f6ecf98..f4664fa890 100644 --- a/crates/ui-egui/src/panels/panel_docking/tests.rs +++ b/crates/ui-egui/src/panels/panel_docking/tests.rs @@ -1917,6 +1917,22 @@ fn a_narrow_window_draws_a_stored_dock_width_narrower_without_losing_it() { assert!(dock.width() - 36.0 <= 364.5, "the drawn dock column fits beside the toolbox and canvas, got {dock:?}"); assert!(canvas.width() >= 199.5, "the canvas keeps its 200-point minimum, got {canvas:?} beside {dock:?}"); assert!(!canvas.intersect(dock).is_positive(), "the dock never overlaps the canvas: {canvas:?}, {dock:?}"); + // `hit_rects` reports each control's full widget rect (`Response::rect`), not its clipped + // `interact_rect`, so a squeezed column may report chrome past the panel edge; what is drawn + // is that rect inside the panel's clip. No visible part may reach the toolbox, which sits + // between the canvas and the dock, or the canvas. + let toolbox = egui::Rect::from_x_y_ranges(canvas.right()..=dock.left(), dock.y_range()); + let hits = craft_ui::docking::DockArea::::hit_rects(&h.ctx, area_id()); + assert!(hits.iter().any(|(_, rect)| rect.intersect(dock).is_positive()), "the dock drew visible controls: {hits:?}"); + for (hit, rect) in &hits { + let visible = rect.intersect(dock); + if !visible.is_positive() { + continue; + } + assert!(dock.contains_rect(visible), "{hit:?}: {visible:?} outside {dock:?}"); + assert!(!visible.intersect(canvas).is_positive(), "{hit:?}: {visible:?} reaches the canvas {canvas:?}"); + assert!(!visible.intersect(toolbox).is_positive(), "{hit:?}: {visible:?} reaches the toolbox {toolbox:?}"); + } h.set_size(vec2(1280.0, 600.0)); h.run_steps(3); assert!((dock_width(h.state()) - 520.0).abs() < 0.5, "growing the window keeps the stored width");