From 18e5188fb32122375c0888496bebb6bdd48bf8cb Mon Sep 17 00:00:00 2001 From: KotovGGG Date: Fri, 20 Nov 2026 13:31:40 +0300 Subject: [PATCH 1/3] Let floating panels opt out of edge resizing --- crates/ui-panels/src/docking/floating.rs | 11 +++++++-- crates/ui-panels/src/docking/spec.rs | 10 ++++++++ crates/ui-patterns/src/patterns/dock/area.rs | 1 + .../tests/it/docking/floating_area.rs | 23 ++++++++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index 8e8d95d08d..af7c894fe6 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -213,6 +213,9 @@ pub struct FloatingGroup<'a> { /// Whether only the title row shows. #[prop] minimized: bool, + /// Whether the edges can be dragged to resize the window. + #[prop] + resizable: bool, /// The column the window holds, whose bar the title row is. #[prop] column: Option, @@ -268,6 +271,7 @@ impl<'a> FloatingGroup<'a> { limits: SizeLimits::default(), opacity: 1.0, minimized: false, + resizable: true, column: None, sized: Sizing::Content, native: None, @@ -345,8 +349,11 @@ impl<'a> FloatingGroup<'a> { // The frame's limits are the body's with the title row on top. let frame = self.limits.around(Vec2::new(0.0, header)); let collapsed = self.collapsed_rect(); - let mut overlay = - Overlay::floating().movable(true).resizable(!self.minimized && collapsed.is_none()).opacity(self.opacity).body_scroll(false); + let mut overlay = Overlay::floating() + .movable(true) + .resizable(self.resizable && !self.minimized && collapsed.is_none()) + .opacity(self.opacity) + .body_scroll(false); overlay = if let Some(shown) = collapsed { overlay.placed(shown).size_limits(SizeLimits::new(shown.size(), shown.size())) } else if let Some(size) = self.column.and_then(|column| column.fitted) { diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs index b395cd6f0b..f208e360dd 100644 --- a/crates/ui-panels/src/docking/spec.rs +++ b/crates/ui-panels/src/docking/spec.rs @@ -121,6 +121,8 @@ pub struct PanelSpec { /// Whether the panel's floating window may be an OS window of its own. A panel that disallows it keeps its /// window in the main window. pub allow_native: bool, + /// Whether a floating window holding this panel can be resized by dragging its edges. + pub allow_float_resize: bool, /// What an OS window holding the panel is for. A window holding any `WindowKind::Document` panel is a document /// window; the rest are tool windows. pub window_kind: WindowKind, @@ -142,6 +144,7 @@ impl PanelSpec { heights: None, float_size: None, allow_native: true, + allow_float_resize: true, window_kind: WindowKind::Tool, canvas: false, grid: None, @@ -155,6 +158,13 @@ impl PanelSpec { self } + /// Allows or disables edge resizing for a floating window holding this panel. + #[must_use] + pub fn allow_float_resize(mut self, allow: bool) -> Self { + self.allow_float_resize = allow; + self + } + /// Body size limits. #[must_use] pub fn limits(mut self, limits: SizeLimits) -> Self { diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 902dda70ed..706b4670e6 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -1340,6 +1340,7 @@ impl Pass<'_, P> { .limits(scene.spec(&anchor).limits) .sized(Sizing::Fill) .column(shape) + .resizable(specs.iter().all(|spec| spec.allow_float_resize)) .actions(actions) .window_of(anchor.clone()) .takes_drops(target, &dropped) diff --git a/crates/ui-patterns/tests/it/docking/floating_area.rs b/crates/ui-patterns/tests/it/docking/floating_area.rs index 4ea3299d47..045edcff23 100644 --- a/crates/ui-patterns/tests/it/docking/floating_area.rs +++ b/crates/ui-patterns/tests/it/docking/floating_area.rs @@ -21,6 +21,8 @@ const SECOND: usize = 3; const SHORT: usize = 4; /// A panel whose content fills its body. const FILL: usize = 5; +/// A panel whose floating window stays the size its host gives it. +const FIXED: usize = 6; /// Inside the fixture's room, so the area's bounds clamp neither the window nor the moves and resizes made of it. const WINDOW_AT: Rect = Rect { min: Pos2::new(130.0, 90.0), max: Pos2::new(330.0, 210.0) }; const SLACK: f32 = 1.5; @@ -35,7 +37,7 @@ struct Panels { impl DockPanels for Panels { fn spec(&self, panel: &usize) -> PanelSpec { - PanelSpec::new(title(*panel)) + PanelSpec::new(title(*panel)).allow_float_resize(*panel != FIXED) } fn permissions(&self, panel: &usize) -> Permissions { @@ -119,6 +121,25 @@ fn press_and_move(fixture: &mut Fixture, from: Pos2, by: Vec2) { } } +#[trial] +fn a_fixed_floating_window_ignores_edge_drags_and_still_moves_by_its_title() { + let layout = Layout::new(Some(Node::tabs(vec![DOCKED], 0)), vec![Floating::single(vec![FIXED], 0, WINDOW_AT)]); + let mut bed = bed(layout, |_| Permissions::ALL); + let right = Pos2::new(WINDOW_AT.right() - 1.0, WINDOW_AT.center().y); + let bottom = Pos2::new(WINDOW_AT.center().x, WINDOW_AT.bottom() - 1.0); + for (from, by) in [(right, Vec2::new(40.0, 0.0)), (bottom, Vec2::new(0.0, 40.0))] { + press_and_move(&mut bed.fixture, from, by); + bed.fixture.frame(vec![release(from + by)]); + bed.fixture.settle(); + assert_eq!(bed.workspace.borrow().layout.floating[0].rect, WINDOW_AT); + } + + let by = Vec2::new(-35.0, 20.0); + press_and_move(&mut bed.fixture, window_title(), by); + assert!(dragging(&bed)); + assert_ne!(bed.workspace.borrow().layout.floating[0].rect.min, WINDOW_AT.min); +} + #[trial] fn a_tab_dragged_over_a_floating_window_marks_and_joins_the_window() { let mut bed = bed(with_window(Some(Node::tabs(vec![DOCKED, SECOND], 0))), |_| Permissions::ALL); From b631ecb83954ccea162bad6d1af23d7705b2123c Mon Sep 17 00:00:00 2001 From: KotovGGG Date: Mon, 23 Nov 2026 08:14:42 +0300 Subject: [PATCH 2/3] Assert floating window movement after the drag is committed --- crates/ui-patterns/tests/it/docking/floating_area.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/tests/it/docking/floating_area.rs b/crates/ui-patterns/tests/it/docking/floating_area.rs index d5805e9235..524aefc211 100644 --- a/crates/ui-patterns/tests/it/docking/floating_area.rs +++ b/crates/ui-patterns/tests/it/docking/floating_area.rs @@ -143,8 +143,10 @@ fn a_fixed_floating_window_ignores_edge_drags_and_still_moves_by_its_title() { } let by = Vec2::new(-35.0, 20.0); - press_and_move(&mut bed.fixture, window_title(), by); + let from = window_title(); + press_and_move(&mut bed.fixture, from, by); assert!(dragging(&bed)); + bed.fixture.frame(vec![release(from + by)]).settle(); let rect = bed.workspace.borrow().layout().floating[0].rect; assert_ne!(rect.min, WINDOW_AT.min, "title drag moves the fixed window"); assert_eq!(rect.size(), WINDOW_AT.size(), "title drag keeps the fixed window's size"); From 437e5157634b984000ce578e46cac7e6f8177df9 Mon Sep 17 00:00:00 2001 From: KotovGGG Date: Mon, 23 Nov 2026 08:28:18 +0300 Subject: [PATCH 3/3] Keep the fixed-window move trial outside docking behavior --- crates/ui-patterns/tests/it/docking/floating_area.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-patterns/tests/it/docking/floating_area.rs b/crates/ui-patterns/tests/it/docking/floating_area.rs index 524aefc211..d5d0738f7d 100644 --- a/crates/ui-patterns/tests/it/docking/floating_area.rs +++ b/crates/ui-patterns/tests/it/docking/floating_area.rs @@ -133,7 +133,7 @@ fn press_and_move(fixture: &mut Fixture, from: Pos2, by: Vec2) { fn a_fixed_floating_window_ignores_edge_drags_and_still_moves_by_its_title() { let window = Floating::single(100, vec![FIXED], 0, WINDOW_AT); let layout = Layout::new(Some(Node::tabs(vec![DOCKED], 0)), vec![window]); - let mut bed = bed(layout); + let mut bed = bed_with(layout, DockConfig::default().title_bar_docks(false)); let right = Pos2::new(WINDOW_AT.right() - 1.0, WINDOW_AT.center().y); let bottom = Pos2::new(WINDOW_AT.center().x, WINDOW_AT.bottom() - 1.0); for (from, by) in [(right, Vec2::new(40.0, 0.0)), (bottom, Vec2::new(0.0, 40.0))] { @@ -147,7 +147,7 @@ fn a_fixed_floating_window_ignores_edge_drags_and_still_moves_by_its_title() { press_and_move(&mut bed.fixture, from, by); assert!(dragging(&bed)); bed.fixture.frame(vec![release(from + by)]).settle(); - let rect = bed.workspace.borrow().layout().floating[0].rect; + let rect = bed.workspace.borrow().layout().floating.first().expect("the window stays floating").rect; assert_ne!(rect.min, WINDOW_AT.min, "title drag moves the fixed window"); assert_eq!(rect.size(), WINDOW_AT.size(), "title drag keeps the fixed window's size"); }