From 950b9644e8f357a04bd6ed3797c605fa84518c47 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 25 Oct 2026 05:29:44 +0000 Subject: [PATCH] docking: a drop beside a frame too narrow to halve takes the room from beyond its divider --- crates/ui/src/docking/dock_model.rs | 41 ++++++++++ crates/ui/src/docking/drop_tests.rs | 22 ++++++ crates/ui/src/docking/model.rs | 16 +++- crates/ui/src/docking/model_tests.rs | 20 +++++ crates/ui/src/docking/render/preview.rs | 101 ++++++++++++++++++++++-- crates/ui/src/docking/render/sizes.rs | 14 +++- crates/ui/src/docking/split_tests.rs | 55 ++++++++++++- crates/ui/src/docking/workspace.rs | 7 ++ docs/ui-docking.md | 11 ++- 9 files changed, 271 insertions(+), 16 deletions(-) diff --git a/crates/ui/src/docking/dock_model.rs b/crates/ui/src/docking/dock_model.rs index 27390e092..37c6fa074 100644 --- a/crates/ui/src/docking/dock_model.rs +++ b/crates/ui/src/docking/dock_model.rs @@ -326,6 +326,35 @@ pub(super) fn split_frame

(root: &mut Node

, path: &[bool], new: Node

, zo true } +/// [`split_frame`] with the sizes of [`Placement::SplitSized`]: the new split takes `size`, and +/// the nearest enclosing split whose divider runs along the frame's `zone` side takes `outer`. +/// False when there is no such split, or a dock is beyond it. +pub(super) fn split_frame_sized

(root: &mut Node

, path: &[bool], new: Node

, zone: Zone, size: SplitSize, outer: SplitSize) -> bool { + let axis = if matches!(zone, Zone::Top | Zone::Bottom) { SplitAxis::Vertical } else { SplitAxis::Horizontal }; + // A divider on the frame's start side (left or top) belongs to a split holding the frame + // in its second child. + let start = matches!(zone, Zone::Left | Zone::Top); + let enclosing = (0..path.len()).rev().find(|&depth| { + path.get(depth) == Some(&start) && matches!(node_at(root, &path[..depth]), Some(Node::Split { axis: own, .. }) if *own == axis) + }); + let Some(depth) = enclosing else { return false }; + let Some(Node::Split { size: own, first, second, .. }) = node_at_mut(root, &path[..depth]) else { return false }; + if zone == Zone::Center || matches!(**first, Node::Dock { .. }) || matches!(**second, Node::Dock { .. }) { + return false; + } + *own = outer; + if !split_frame(root, path, new, zone) { + return false; + } + match node_at_mut(root, path) { + Some(Node::Split { size: own, .. }) => { + *own = size; + true + } + _ => false, + } +} + /// Insert `new` at `index` and select the member at `index + selected`. fn splice

(panels: &mut Vec

, active: &mut usize, index: usize, new: Vec

, selected: usize) { let index = index.min(panels.len()); @@ -799,6 +828,18 @@ impl Layout

{ let root = self.tree_mut(window).ok_or(DockError::MissingTarget)?; if split_frame(root, path, new, zone) { Ok(()) } else { Err(DockError::MissingTarget) } } + Placement::SplitSized { zone, size, outer } => { + let (window, path) = place.tree_path().ok_or(DockError::InvalidPlacement)?; + let new = match moving.node { + Some(node) => node, + None => { + let (panels, active) = flatten(moving.groups); + Node::Tabs { panels, active } + } + }; + let root = self.tree_mut(window).ok_or(DockError::MissingTarget)?; + if split_frame_sized(root, path, new, zone, size, outer) { Ok(()) } else { Err(DockError::InvalidPlacement) } + } // A floating window is a tree: a group above or below splits the anchor's group. Placement::Group { below, .. } if matches!(place, Place::Floating { .. }) => { let zone = if below { Zone::Bottom } else { Zone::Top }; diff --git a/crates/ui/src/docking/drop_tests.rs b/crates/ui/src/docking/drop_tests.rs index 0098aeb58..87de29b3c 100644 --- a/crates/ui/src/docking/drop_tests.rs +++ b/crates/ui/src/docking/drop_tests.rs @@ -432,3 +432,25 @@ fn a_header_drag_in_a_window_of_two_groups_still_offers_the_other_group() { out.actions ); } + +#[test] +fn a_drop_beside_a_frame_too_narrow_to_halve_takes_room_from_its_neighbour() { + // Frame 2 is 60 pt wide beside frame 1; group 4 floats over frame 1. + let root = + Node::Split { axis: SplitAxis::Horizontal, size: SplitSize::FixedSecond(60.0), first: Box::new(tabs(&[1])), second: Box::new(tabs(&[2])) }; + let layout = Layout { root: Some(root), floating: vec![Floating::single(vec![4], 0, [100.0, 100.0, 200.0, 200.0])] }; + let mut d = DockDriver::new(layout, Bodies::default()); + let (body, rect) = group(&d, 2); + let at = pos2(body.left() + 8.0, body.center().y); + d.hold(tab(&d, 4), at); + assert!(d.filled(line(rect, Zone::Left)), "a line along frame 2's left edge"); + let out = d.release(at); + assert!( + matches!(&out.actions[..], [Action::Move { panel: 4, anchor: 2, placement: Placement::SplitSized { zone: Zone::Left, .. } }]), + "{:?}", + out.actions + ); + d.settle(); + assert!((group(&d, 2).1.width() - rect.width()).abs() < 1.0, "frame 2 keeps its width"); + assert!(group(&d, 4).1.width() >= 40.0); +} diff --git a/crates/ui/src/docking/model.rs b/crates/ui/src/docking/model.rs index 6bbf15ad2..31dcfcfa0 100644 --- a/crates/ui/src/docking/model.rs +++ b/crates/ui/src/docking/model.rs @@ -1,7 +1,8 @@ use std::{collections::HashSet, fmt, hash::Hash}; use super::dock_model::{ - Column, ColumnLocation, Group, GroupLocation, Moving, PanelState, Place, Side, Target, Unit, node_at, split_frame, tree_panels, valid_column, + Column, ColumnLocation, Group, GroupLocation, Moving, PanelState, Place, Side, Target, Unit, node_at, split_frame, split_frame_sized, + tree_panels, valid_column, }; use crate::layout::{SplitAxis, SplitSize}; @@ -305,6 +306,13 @@ pub enum Placement

{ /// Center inserts after the anchor; sides split the anchor's frame into two halves, and /// every other frame keeps its size. Sides apply to `Tabs` and `Stack` nodes only. Split(Zone), + /// A side [`Placement::Split`] that gives the new frame its own room instead of half the + /// anchor's frame: the new split takes `size`, and `outer` replaces the size of the nearest + /// enclosing split whose divider runs along the anchor frame's `zone` side, so the frames + /// beyond that divider give the room. The renderer offers it beside a frame too small to + /// halve. `Center`, and an anchor without such a divider or with a dock beyond it, are + /// invalid. + SplitSized { zone: Zone, size: SplitSize, outer: SplitSize }, /// A new group above or below the anchor's group in a dock column. On an anchor in a /// floating window, a split of the anchor's group above or below. /// `height` is the inserted group's preferred height ([`super::Group::height`]); `None` @@ -1309,6 +1317,10 @@ impl Layout

{ let new = Node::Tabs { panels: vec![entry.panel], active: 0 }; return if split_frame(root, &path, new, zone) { Ok(()) } else { Err(DockError::MissingTarget) }; } + if let Placement::SplitSized { zone, size, outer } = placement { + let new = Node::Tabs { panels: vec![entry.panel], active: 0 }; + return if split_frame_sized(root, &path, new, zone, size, outer) { Ok(()) } else { Err(DockError::InvalidPlacement) }; + } if insert_node(root, &entry, anchor, &placement) { Ok(()) } else { Err(DockError::MissingTarget) } } } @@ -1318,7 +1330,7 @@ impl Layout

{ fn placement_allowed

(placement: &Placement

, anchor: Permissions) -> bool { match placement { Placement::Tab { .. } | Placement::Split(Zone::Center) => anchor.accepts_tabs, - Placement::Split(_) => anchor.accepts_splits, + Placement::Split(_) | Placement::SplitSized { .. } => anchor.accepts_splits, _ => true, } } diff --git a/crates/ui/src/docking/model_tests.rs b/crates/ui/src/docking/model_tests.rs index 9327fd4d3..d510939bd 100644 --- a/crates/ui/src/docking/model_tests.rs +++ b/crates/ui/src/docking/model_tests.rs @@ -754,3 +754,23 @@ fn edge_placement_splits_the_part_between_the_docks_or_the_root() { assert_eq!(frames.apply(Action::Move { panel: 2, anchor: 1, placement: Placement::Edge(Zone::Center) }), Err(DockError::InvalidPlacement)); assert_eq!(frames, before); } + +#[test] +fn a_sized_split_sets_the_new_split_and_the_enclosing_one_beside_the_anchor() { + // 1 | (2 | 3): 4 goes left of 3, and the split between 2 and 3 gives the room. + let layout = Layout { + root: Some(hsplit(SplitSize::Ratio(0.5), tabs(&[1], 0), hsplit(SplitSize::FixedSecond(60.0), tabs(&[2], 0), tabs(&[3], 0)))), + floating: vec![Floating::single(vec![4], 0, [0.0, 0.0, 100.0, 100.0])], + }; + let sized = |zone| Placement::SplitSized { zone, size: SplitSize::FixedFirst(100.0), outer: SplitSize::FixedSecond(164.0) }; + let mut moved = layout.clone(); + moved.apply(Action::Move { panel: 4, anchor: 3, placement: sized(Zone::Left) }).unwrap(); + let inner = hsplit(SplitSize::FixedSecond(164.0), tabs(&[2], 0), hsplit(SplitSize::FixedFirst(100.0), tabs(&[4], 0), tabs(&[3], 0))); + assert_eq!(moved.root, Some(hsplit(SplitSize::Ratio(0.5), tabs(&[1], 0), inner))); + // 1 has no divider on its left, and a center is no side. + for (anchor, zone) in [(1, Zone::Left), (3, Zone::Center)] { + let mut moved = layout.clone(); + assert_eq!(moved.apply(Action::Move { panel: 4, anchor, placement: sized(zone) }), Err(DockError::InvalidPlacement), "{anchor} {zone:?}"); + assert_eq!(moved, layout); + } +} diff --git a/crates/ui/src/docking/render/preview.rs b/crates/ui/src/docking/render/preview.rs index 75b9365f2..740665c21 100644 --- a/crates/ui/src/docking/render/preview.rs +++ b/crates/ui/src/docking/render/preview.rs @@ -10,7 +10,7 @@ use crate::docking::{ surface::TAB_PADDING, targets::{SIDE_EDGE_ZONE_DEPTH, resolve_drop_on}, }; -use crate::layout::SplitAxis; +use crate::layout::{SplitAxis, SplitSize}; /// Ctrl (Windows, Linux) or Cmd (macOS) held: the drop floats and no target is offered. fn float_only(ctx: &Context) -> bool { @@ -182,7 +182,7 @@ impl Renderer<'_, P> { let (edges, joins) = (false, false); let split = match proposal.placement { Placement::Split(Zone::Center) => !joins, - Placement::Split(_) => !edges, + Placement::Split(_) | Placement::SplitSized { .. } => !edges, _ => false, }; if window && !into_window && split { @@ -209,6 +209,11 @@ impl Renderer<'_, P> { if self.leaves_room(action(Target::At { anchor: proposal.anchor.clone(), placement: proposal.placement.clone() })) { return Some(self.settled(proposal, action)); } + if let Some(placement) = self.sized_split(panel, &proposal, &action) + && self.leaves_room(action(Target::At { anchor: proposal.anchor.clone(), placement: placement.clone() })) + { + return Some(self.settled(DropProposal { placement, ..proposal }, action)); + } let target = targets.iter().rev().find(|t| crate::docking::targets::usable(t.rect) && t.rect.contains(pointer))?; let proposal = resolve_drop_on( panel, @@ -220,6 +225,83 @@ impl Renderer<'_, P> { Some(self.settled(proposal, action)) } + /// The side split of `proposal`'s frame when halving it leaves no room + /// ([`Placement::SplitSized`]): the frame keeps its size, the new frame takes the size the + /// moved panels have now (at least its minimum and [`DROP_MARGIN`]), and the frames beyond + /// the divider on that side give the room. `None` without such a divider, or when those + /// frames cannot give the new frame its minimum. + fn sized_split(&self, panel: &P, proposal: &DropProposal

, action: &impl Fn(Target

) -> Action

) -> Option> { + let Placement::Split(zone) = proposal.placement else { return None }; + let axis = if matches!(zone, Zone::Top | Zone::Bottom) { SplitAxis::Vertical } else { SplitAxis::Horizontal }; + let along = |v: Vec2| if axis == SplitAxis::Horizontal { v.x } else { v.y }; + // The divider on the frame's start side (left or top) belongs to a split holding the + // frame in its second child, as `split_frame_sized` finds it. + let start = matches!(zone, Zone::Left | Zone::Top); + let anchor = &proposal.anchor; + let now = self.drawn_groups(self.layout); + let frame = along(now.iter().find(|(node, _)| holds(node, anchor))?.1.size()); + let mut candidate = self.layout.clone(); + let halves = action(Target::At { anchor: anchor.clone(), placement: proposal.placement.clone() }); + candidate.apply_with_permissions(halves, |p| self.permissions(p)).ok()?; + let (root, area, path) = match candidate.place(anchor)? { + Place::Node(path) => (candidate.root.as_ref()?, self.workspace, path), + Place::Floating { window, path } => { + let window = candidate.floating.get(window)?; + (&window.root, self.window_body(window), path) + } + Place::Dock { .. } => return None, + }; + // The splits from the root down to the new one, as drawn with halves. + let sizer = self.sizer(); + let (_, split_path) = path.split_last()?; + let mut chain = vec![(root, area)]; + for &second in split_path { + let &(node, rect) = chain.last()?; + let [a, b] = sizer.children(node, rect)?; + chain.push(if second { b } else { a }); + } + let &(Node::Split { first, second, .. }, halved) = chain.last()? else { return None }; + let new = if start { first } else { second }; + let depth = (0..split_path.len()).rev().find(|&d| { + split_path.get(d) == Some(&start) && chain.get(d).is_some_and(|(n, _)| matches!(n, Node::Split { axis: own, .. } if *own == axis)) + })?; + let &(outer, outer_rect) = chain.get(depth)?; + let Node::Split { size: outer_size, first: a, second: b, .. } = outer else { return None }; + if matches!(**a, Node::Dock { .. }) || matches!(**b, Node::Dock { .. }) { + return None; + } + let [a, b] = sizer.children(outer, outer_rect)?; + let far = if start { a } else { b }; + // The far side's edge at the divider is its end edge when the divider is on the start + // side of the frame. + let room = sizer.travel(far.0, far.1, axis, start).0 - DROP_MARGIN; + let least = along(super::node_limits(new, self.style, &*self.content).min) + DROP_MARGIN; + let gap = self.style.gap; + let wanted = now.iter().find(|(node, _)| holds(node, panel)).map_or(least, |(_, rect)| along(rect.size())); + let size = wanted.max(least).min(along(halved.size()) + room - frame - gap); + if size < least { + return None; + } + // The anchor's side of the outer split grows by what the halves did not take already. + let grow = frame + gap + size - along(halved.size()); + let first = along(a.1.size()) + if start { -grow } else { grow }; + let outer = super::sizes::resized(*outer_size, first, along(a.1.size()) + along(b.1.size()))?; + let size = super::sizes::resized(SplitSize::Ratio(0.5), if start { size } else { frame }, frame + size)?; + Some(Placement::SplitSized { zone, size, outer }) + } + + /// Every group of `layout`'s trees as drawn, with its rect. + fn drawn_groups<'l>(&self, layout: &'l Layout

) -> Vec<(&'l Node

, Rect)> { + let sizer = self.sizer(); + let mut out = Vec::new(); + for (root, area) in self.trees(layout) { + let mut drawn = Vec::new(); + sizer.groups(root, area, &mut drawn); + out.extend(drawn.into_iter().map(|d| (d.node, d.rect))); + } + out + } + /// `proposal`, marked a no-op when `action` at it would leave every panel where it is, /// changing only sizes ([`Layout::same_arrangement`]): a lone group dropped beside the /// group it already borders, or a tab on the edge its frame already holds. Such a drop @@ -345,7 +427,7 @@ impl Renderer<'_, P> { if zones { self.paint_marker(&painter, &proposal); } else { - let split = matches!(proposal.placement, Placement::Split(zone) | Placement::Edge(zone) if zone != Zone::Center); + let split = matches!(proposal.placement, Placement::Split(zone) | Placement::SplitSized { zone, .. } | Placement::Edge(zone) if zone != Zone::Center); self.paint_preview(ctx, &painter, &proposal, split); } if drag.gesture != GroupGesture::Window { @@ -485,7 +567,7 @@ impl Renderer<'_, P> { /// region the drop takes, filled for a tab drag (`filled`) or a split. fn paint_preview(&self, ctx: &Context, painter: &egui::Painter, proposal: &DropProposal

, filled: bool) { if crate::docking::targets::usable(proposal.preview) { - let beside = matches!(proposal.placement, Placement::Split(zone) | Placement::Edge(zone) if zone != Zone::Center); + let beside = matches!(proposal.placement, Placement::Split(zone) | Placement::SplitSized { zone, .. } | Placement::Edge(zone) if zone != Zone::Center); if self.style.side_edge_zones { drop_preview(painter, proposal.preview.shrink(1.0), self.style.accent, filled); } else if beside { @@ -551,7 +633,7 @@ impl Renderer<'_, P> { use crate::docking::targets::{header_height, usable, zone_shape}; let zone_of = |proposal: &DropProposal

| match proposal.placement { _ if proposal.noop => None, - Placement::Split(zone) => Some(zone), + Placement::Split(zone) | Placement::SplitSized { zone, .. } => Some(zone), Placement::Tab { .. } => Some(Zone::Center), _ => None, }; @@ -715,6 +797,15 @@ impl Renderer<'_, P> { } } +/// Whether the drawn group `node` holds `panel`. +fn holds(node: &Node

, panel: &P) -> bool { + match node { + Node::Tabs { panels, .. } => panels.contains(panel), + Node::Stack { entries } => entries.iter().any(|e| &e.panel == panel), + Node::Split { .. } | Node::Dock { .. } => false, + } +} + /// The panel that names a drawn group: its first panel; none for a dock or a split. fn lead

(node: &Node

) -> Option<&P> { match node { diff --git a/crates/ui/src/docking/render/sizes.rs b/crates/ui/src/docking/render/sizes.rs index b1c9fd493..415ecf8dc 100644 --- a/crates/ui/src/docking/render/sizes.rs +++ b/crates/ui/src/docking/render/sizes.rs @@ -312,16 +312,22 @@ impl

Sizer<'_, P> { /// The size of a split at `path` whose first child is `first` of `available` points, in the /// split's own mode `size`: a fixed side keeps its points, a ratio stays a ratio. fn push_size(path: &[bool], size: SplitSize, first: f32, available: f32, out: &mut Vec<(Vec, SplitSize)>) { + if let Some(size) = resized(size, first, available) { + out.push((path.to_vec(), size)); + } +} + +/// `size` in its own mode for a first child of `first` out of `available` points. +pub(in crate::docking) fn resized(size: SplitSize, first: f32, available: f32) -> Option { if available <= 0.0 || !available.is_finite() || !first.is_finite() { - return; + return None; } let first = first.clamp(0.0, available); - let size = match size { + Some(match size { SplitSize::Ratio(_) => SplitSize::Ratio((first / available).clamp(0.0, 1.0)), SplitSize::FixedFirst(_) => SplitSize::FixedFirst(first), SplitSize::FixedSecond(_) => SplitSize::FixedSecond(available - first), - }; - out.push((path.to_vec(), size)); + }) } /// One group of a flat row, such as the panels of a stack or the groups of a dock column: diff --git a/crates/ui/src/docking/split_tests.rs b/crates/ui/src/docking/split_tests.rs index 8a07c80fa..232ed9d80 100644 --- a/crates/ui/src/docking/split_tests.rs +++ b/crates/ui/src/docking/split_tests.rs @@ -194,10 +194,10 @@ fn groups_have_one_small_minimum_and_no_maximum() { assert_eq!(group(&d, TOOLS).width(), 40.0, "and shrinks to the minimum, no further"); // At its minimum, with Project left of it at its own, it has no room for two halves and - // takes a drop on its edge as a tab. + // takes a drop on its left edge as a tab. let tools = group(&d, TOOLS); assert_eq!(group(&d, PROJECT[0]).width(), 40.0); - let out = d.drag(tab(&d, INFO), pos2(tools.right() - 4.0, tools.center().y + 30.0)); + let out = d.drag(tab(&d, INFO), pos2(tools.left() + 4.0, tools.center().y + 30.0)); assert!( matches!(&out.actions[..], [Action::Move { panel: INFO, anchor: TOOLS, placement: Placement::Split(Zone::Center) | Placement::Tab { .. } }]), "{:?}", @@ -359,6 +359,57 @@ fn a_drop_beside_a_narrow_group_splits_that_group_only() { assert_eq!((group(&d, PROJECT[0]), group(&d, TIMELINE), group(&d, METERS)), (project, timeline, meters)); } +/// Properties and a narrow Tools frame side by side, Tools `tools` wide in an area `width` +/// wide, with Info floating at the left. +fn beside_tools(width: f32, tools: f32) -> Driver { + let root = Node::Split { + axis: SplitAxis::Horizontal, + size: SplitSize::FixedSecond(tools), + first: Box::new(tabs(&PROPERTIES)), + second: Box::new(tabs(&[TOOLS])), + }; + let layout = Layout { root: Some(root), floating: vec![Floating::single(vec![INFO], 0, [width + 100.0, 100.0, 280.0, 200.0])] }; + let mut d = driver(layout, Film::default()); + d.area = Rect::from_min_size(Pos2::ZERO, vec2(width, SCREEN.y)); + d.settle(); + d +} + +#[test] +fn a_drop_beside_a_frame_too_narrow_to_halve_takes_room_from_its_neighbour() { + let mut d = beside_tools(1000.0, 60.0); + let (tools, properties, info) = (group(&d, TOOLS), group(&d, PROPERTIES[0]), group(&d, INFO)); + let left = zone_shape(tools, 26.0, 40.0, Zone::Left).unwrap(); + let at = pos2(tools.left() + 4.0, tools.center().y + 13.0); + d.hold(tab(&d, INFO), at); + assert!(d.filled_polygon(&left), "Tools' left zone is a target"); + let out = d.release(at); + assert!( + matches!(&out.actions[..], [Action::Move { panel: INFO, anchor: TOOLS, placement: Placement::SplitSized { zone: Zone::Left, .. } }]), + "{:?}", + out.actions + ); + d.settle(); + let (new_tools, new_info, new_properties) = (group(&d, TOOLS), group(&d, INFO), group(&d, PROPERTIES[0])); + assert!((new_tools.width() - tools.width()).abs() < 1.0, "Tools keeps its width: {new_tools:?}"); + assert!((new_info.width() - info.width()).abs() < 1.0, "Info keeps its floating width: {new_info:?}"); + assert!(new_info.right() < new_tools.left() && new_properties.right() < new_info.left()); + assert!(new_properties.width() < properties.width() - 200.0, "Properties gave the room"); +} + +#[test] +fn a_drop_beside_a_narrow_frame_joins_it_when_no_neighbour_has_room() { + let mut d = beside_tools(130.0, 60.0); + let tools = group(&d, TOOLS); + let at = pos2(tools.left() + 4.0, tools.center().y + 13.0); + let out = d.drag(tab(&d, INFO), at); + assert!( + matches!(&out.actions[..], [Action::Move { panel: INFO, anchor: TOOLS, placement: Placement::Tab { .. } | Placement::Split(Zone::Center) }]), + "{:?}", + out.actions + ); +} + #[test] fn every_divider_travels_after_drops() { let mut d = film(); diff --git a/crates/ui/src/docking/workspace.rs b/crates/ui/src/docking/workspace.rs index 183af38d3..c3711a50c 100644 --- a/crates/ui/src/docking/workspace.rs +++ b/crates/ui/src/docking/workspace.rs @@ -312,6 +312,13 @@ fn reversed(hidden: &Location

, location: &Location

, panel: Placement::Split(Zone::Bottom) => (Placement::Split(Zone::Top), location.size), Placement::Group { below, .. } => (Placement::Group { below: !below, height: None }, None), Placement::Column { after } => (Placement::Column { after: !after }, None), + Placement::SplitSized { zone, .. } => match zone { + Zone::Left => (Placement::Split(Zone::Right), location.size), + Zone::Right => (Placement::Split(Zone::Left), location.size), + Zone::Top => (Placement::Split(Zone::Bottom), location.size), + Zone::Bottom => (Placement::Split(Zone::Top), location.size), + Zone::Center => return None, + }, Placement::Edge(_) => return None, }; Some(Location { floating: None, anchor: Some(panel.clone()), placement, size, sibling: Vec::new(), ..hidden.clone() }) diff --git a/docs/ui-docking.md b/docs/ui-docking.md index 4ad822a4b..79415dd61 100644 --- a/docs/ui-docking.md +++ b/docs/ui-docking.md @@ -85,7 +85,9 @@ layout.apply(Action::Move { that side or a new group above or below in a dock. A floating window takes splits as the docked layout does; `Placement::Group` on a floating anchor splits its group above or below. - A side split zone puts what moves in a new half-size split of the anchor's frame, and no - other frame changes size. The new split has its own divider. + other frame changes size. The new split has its own divider. `Placement::SplitSized` sizes + that split instead (`size`) and resizes the enclosing split whose divider runs along the + anchor frame's side (`outer`), so the frames beyond that divider give the new frame its room. - Other actions select, minimize, collapse to icons, resize splits (`ResizeSplit` in the docked layout, `ResizeWindowSplit` in the floating window holding a panel), columns and groups, and move a floating window to its own OS window (`SetNative`, and `SetMonitor` for the monitor it @@ -242,8 +244,11 @@ A flyout fits its content the same way, without the title bar. - Beside a frame is a split of that frame. Beside a group in a dock column, the top and bottom stack a new group above or below it, and the left and right make a new column on that side. - A frame too narrow or short for two halves of `DockStyle::min_pane` still splits when the - frames beyond it can give the room, as they do for a dragged divider. When they cannot, that - side joins the frame's tabs instead, or takes nothing when the frame takes no tabs. The gap + frames beyond it can give the room, as they do for a dragged divider. When they cannot, the + frame keeps its size and the new frame takes the width (or height) the moved panels have now, + at least its minimum, from the frames beyond the frame's divider on that side + (`Placement::SplitSized`). When those have no room either, that side joins the frame's tabs + instead, or takes nothing when the frame takes no tabs. The gap between two frames is no target. - Bands along borders come before the group zones. Each is centred on its border where the pointer can reach both sides: