Dock trial: a tab dropped at the window edge beside a start dock makes a new outer column

This commit is contained in:
aiongg
2026-11-24 18:35:21 +00:00
parent ea3b99e892
commit 24d491397d
@@ -2,7 +2,7 @@
use super::Numbered;
use craft_behavior::Axis;
use craft_behavior::dock::{Layout, Node, SplitSize, Workspace};
use craft_behavior::dock::{Column, DockEdge, Group, Layout, Node, SplitSize, Workspace};
use craft_ui::contract::{Bind, BodyCx, Role, Tracked};
use craft_ui::docking::{DockConfig, DockPanels, DragUnit, FloatSpace, GroupAt, float_drop};
use craft_ui::patterns::dock::DockArea;
@@ -206,6 +206,24 @@ fn a_tab_dropped_on_a_strip_at_the_layouts_top_edge_joins_its_group_and_the_edge
assert!(group_rect(&bed, 1).width() >= area.width() - SLACK, "the panel went to a full-width row on top");
}
/// A tab dropped at the window edge beside a start dock makes a new outer column there: the band centred on the
/// outermost column's start edge reaches the window edge, so the drop does not need room the dock lacks.
#[trial]
fn a_tab_dropped_at_the_window_edge_beside_a_start_dock_makes_a_new_outer_column() {
let start = Node::dock(DockEdge::Start, vec![Column::new(vec![Group::new(vec![1], 0)]).with_width(150.0)]);
let end = Node::dock(DockEdge::End, vec![Column::new(vec![Group::new(vec![3, 4], 0)]).with_width(150.0)]);
let rest = Node::split(Axis::X, SplitSize::Ratio(0.7), Node::tabs(vec![2], 0), end);
let mut bed = bed_on(Node::split(Axis::X, SplitSize::FixedFirst(150.0), start, rest));
// The dock area fills the room from its origin, so x = 3 is 3 pt from the window edge.
drop_tab(&mut bed, 4, Pos2::new(3.0, ROOM.y * 0.5));
let layout = bed.workspace.borrow().layout().clone();
let path = layout.dock_path(DockEdge::Start).expect("the start dock stays");
let Some(Node::Dock { columns, .. }) = craft_behavior::dock::node_at(layout.root.as_ref().unwrap(), &path) else { panic!("a start dock") };
let panels: Vec<Vec<usize>> = columns.iter().map(|column| column.groups.iter().flat_map(|group| group.panels.clone()).collect()).collect();
assert_eq!(panels, vec![vec![4], vec![1]], "the dropped panel is a new column on the window-edge side of the docked one");
assert!(tab(&bed, 4).right() <= tab(&bed, 1).left() + SLACK, "the new column shows outside the old one");
}
/// A drop that floats a panel in open room marks the region the window takes, as a docked drop marks its group's: one
/// outline with a light fill around the pointer, where the window lands.
#[trial]