diff --git a/crates/ui-contract/src/contract/mount.rs b/crates/ui-contract/src/contract/mount.rs
index 2925ba943..bf0644279 100644
--- a/crates/ui-contract/src/contract/mount.rs
+++ b/crates/ui-contract/src/contract/mount.rs
@@ -333,7 +333,8 @@ impl Host for ViewportHost {
let open = ViewportOpen {
id,
title: title.as_str(),
- size: layout_memory::read(&ctx, id).or(placed.map(|rect| rect.size())),
+ // A placed rect is the caller's size for the window; the measured size is for a window sized by content.
+ size: placed.map(|rect| rect.size()).or_else(|| layout_memory::read(&ctx, id)),
save: self.save.as_deref(),
spec: &spec,
limits: (Some(self.overlay.size_limits.min), self.overlay.size_limits.max),
diff --git a/crates/ui-panels/src/docking/commands/dock.rs b/crates/ui-panels/src/docking/commands/dock.rs
index ccfac4dce..23f67c720 100644
--- a/crates/ui-panels/src/docking/commands/dock.rs
+++ b/crates/ui-panels/src/docking/commands/dock.rs
@@ -86,6 +86,7 @@ impl DockCommands {
pub struct DockScene<'a, P> {
layout: &'a Layout
,
space: &'a FloatSpace
,
+ source: Option,
locked: bool,
permissions: &'a dyn Fn(&P) -> Permissions,
}
@@ -94,7 +95,14 @@ impl<'a, P> DockScene<'a, P> {
/// A scene over `layout`. `locked` is `WorkspaceSet::locked`; `permissions` is what the host passes to
/// `Workspace::apply_all`.
pub fn new(layout: &'a Layout, space: &'a FloatSpace
, locked: bool, permissions: &'a dyn Fn(&P) -> Permissions) -> Self {
- DockScene { layout, space, locked, permissions }
+ DockScene { layout, space, source: None, locked, permissions }
+ }
+
+ /// The size of the group or window the command runs from, which a float of it takes.
+ #[must_use]
+ pub fn source(mut self, size: Vec2) -> Self {
+ self.source = Some(size);
+ self
}
fn policy(&self, panel: &P) -> Permissions {
@@ -291,19 +299,10 @@ fn float_actions(scene: &DockScene<'_, P>, unit: &DragUnit
vec![action]
}
-/// The rect a drag would float `unit` at, inside the float area.
+/// The rect a command floats `unit` at, inside the float area: the size [`FloatSpace::size_of`] gives it, from the
+/// size of the group the command runs from.
fn placed(scene: &DockScene<'_, P>, unit: &DragUnit) -> Rect {
- let (layout, space) = (scene.layout, scene.space);
- let panel = unit.lead();
- let docked = layout.place(panel).and_then(|place| layout.column(&place)).and_then(|column| column.width);
- let remembered = match unit {
- DragUnit::Panel(_) => space.panel(panel),
- DragUnit::Group(_) | DragUnit::Window(_) => space.group(panel),
- DragUnit::Column(_) => space.column(panel),
- };
- let width = docked.filter(|_| !matches!(unit, DragUnit::Panel(_))).unwrap_or(space.default_size.x);
- let size = remembered.unwrap_or_else(|| Vec2::new(width, space.default_size.y));
- space.place(size)
+ scene.space.place(scene.space.size_of(unit, scene.source))
}
/// The panels of the last column of the dock on `edge`.
diff --git a/crates/ui-panels/src/docking/drop.rs b/crates/ui-panels/src/docking/drop.rs
index 887fa6177..627bded35 100644
--- a/crates/ui-panels/src/docking/drop.rs
+++ b/crates/ui-panels/src/docking/drop.rs
@@ -44,18 +44,31 @@ impl
DragUnit
{
pub trait DockDrag
{
/// What the drag moves in `layout`; `None` when the dragged panel is not in it.
fn unit(&self, layout: &Layout
) -> Option>;
+ /// The size of what the drag left where it started, which a float takes; `None` floats it at its own or the
+ /// default size.
+ fn source(&self) -> Option {
+ None
+ }
}
impl DockDrag for PanelDrag {
fn unit(&self, layout: &Layout
) -> Option> {
layout.panels().into_iter().find(|panel| PanelKey::of(*panel) == self.panel).cloned().map(DragUnit::Panel)
}
+
+ fn source(&self) -> Option {
+ self.source
+ }
}
impl DockDrag for GroupDrag
{
fn unit(&self, _layout: &Layout
) -> Option> {
Some(self.unit.clone())
}
+
+ fn source(&self) -> Option {
+ self.source
+ }
}
/// What a drop does and what the ghost paints for it.
@@ -201,14 +214,11 @@ fn spot_action(
}
}
-/// The action that floats `unit` in a window under `at`, inside the area of `space`, at the size `space` recorded for
-/// it, and the outline the ghost paints for it. The pointer sits in the middle of the window's title row.
-pub fn float_drop(unit: &DragUnit, space: &FloatSpace
, at: Pos2) -> DockDropped
{
- let recorded = match unit {
- DragUnit::Panel(panel) => space.panel(panel),
- DragUnit::Group(anchor) | DragUnit::Window(anchor) | DragUnit::Column(anchor) => space.group(anchor),
- };
- let size = recorded.unwrap_or(space.default_size).min(space.area.size());
+/// The action that floats `unit` in a window under `at`, inside the area of `space`, at [`FloatSpace::size_of`] with
+/// `source` the size the unit had where the drag started, and the outline the ghost paints for it. The pointer sits in
+/// the middle of the window's title row.
+pub fn float_drop(unit: &DragUnit, space: &FloatSpace
, at: Pos2, source: Option) -> DockDropped {
+ let size = space.size_of(unit, source).min(space.area.size());
let min = (at - Vec2::new(size.x * 0.5, space.title_row * 0.5)).min(space.area.max - size).max(space.area.min);
let rect = Rect::from_min_size(min, size);
let action = match unit {
@@ -275,7 +285,7 @@ impl DockDropTarget<'_, P> {
let unit = drag.unit(self.layout)?;
let window = matches!(unit, DragUnit::Window(_));
if pointer::frame(self.ctx).mods.cmd {
- return if window { None } else { self.float(&unit, at) };
+ return if window { None } else { self.float(&unit, at, drag.source()) };
}
if window && !self.title_bar_docks {
return None;
@@ -292,12 +302,13 @@ impl DockDropTarget<'_, P> {
if window || !self.float_on_empty {
return None;
}
- self.float(&unit, at)
+ self.float(&unit, at, drag.source())
}
- /// The unit floated under `at`, when it may float and the model takes it.
- fn float(&self, unit: &DragUnit, at: Pos2) -> Option> {
- let floated = float_drop(unit, self.space?, at);
+ /// The unit floated under `at`, when it may float and the model takes it; `source` is its size where the drag
+ /// started.
+ fn float(&self, unit: &DragUnit, at: Pos2, source: Option) -> Option> {
+ let floated = float_drop(unit, self.space?, at, source);
((self.permissions)(unit.lead()).floatable && takes(self.layout, &floated.action, self.permissions)).then_some(floated)
}
}
@@ -367,9 +378,10 @@ pub(crate) fn started(env: &EnvView<'_>) -> Option {
env.get::().0
}
-/// Starts the drag of `unit`, whose shown panel is `active`. A group or a column drags a ghost frame; `ghost` gives
-/// its size and label. A window moves itself, so its drag has no ghost and `ghost` is `None`.
-pub fn start_group_drag(cx: &mut Cx<'_, C>, unit: DragUnit
, active: PanelKey, ghost: Option<(Vec2, Label)>)
+/// Starts the drag of `unit`, whose shown panel is `active` and whose size where it starts is `source`. A group or a
+/// column drags a ghost frame; `ghost` gives its size and label. A window moves itself, so its drag has no ghost and
+/// `ghost` is `None`.
+pub fn start_group_drag
(cx: &mut Cx<'_, C>, unit: DragUnit
, active: PanelKey, source: Option, ghost: Option<(Vec2, Label)>)
where
P: Clone + Send + Sync + 'static,
C: Component,
@@ -379,7 +391,7 @@ where
None => DragPreview::None,
};
let started = started(&cx.env);
- cx.start_drag(GroupDrag { unit, active, started }, preview);
+ cx.start_drag(GroupDrag { unit, active, source, started }, preview);
}
/// Ends a running tab or group drag that started on `shown`'s dock under another revision: another arrangement
diff --git a/crates/ui-panels/src/docking/event.rs b/crates/ui-panels/src/docking/event.rs
index 4ae692640..75ba22db8 100644
--- a/crates/ui-panels/src/docking/event.rs
+++ b/crates/ui-panels/src/docking/event.rs
@@ -1,6 +1,6 @@
//! `DockEvent`, `FloatSpace` and `HidePanels`: what a dock reports to the host and the host tells a dock.
-use super::{DockCommands, DockSizes};
+use super::{DockCommands, DockSizes, DragUnit};
use egui::{Rect, Vec2};
/// A request for host state outside the layout, or a report of where something ended up.
@@ -72,12 +72,10 @@ pub struct FloatSpace {
pub inset: f32,
/// The height of a floating window's title row (`DockSizes::bar`), which a drop keeps under the pointer.
pub title_row: f32,
- /// The size a command floats a panel at when the area never drew it.
+ /// The size a unit floats at when neither its panel nor where it came from gives one.
pub default_size: Vec2,
- /// What a drag floats from each drawn panel: the panel alone, its group and its dock column.
+ /// The float size of each panel that has one of its own (`PanelSpec::float_size`).
panels: Vec<(P, Vec2)>,
- groups: Vec<(P, Vec2)>,
- columns: Vec<(P, Vec2)>,
/// The height each panel's content used when it was last drawn, which fits a floated group to its content;
/// `None` for content that filled its body.
contents: Vec<(P, Option)>,
@@ -95,8 +93,6 @@ impl FloatSpace {
title_row: sizes.bar,
default_size: sizes.float_size,
panels: Vec::new(),
- groups: Vec::new(),
- columns: Vec::new(),
contents: Vec::new(),
side_edge_zones: false,
}
@@ -114,27 +110,27 @@ impl FloatSpace {
self.side_edge_zones
}
- /// Adds the size a command floats `panel` at alone when the area has not drawn it, such as a hidden panel or a
- /// headless run. A size the area recorded for the panel takes precedence.
+ /// Adds the size `panel` floats at alone, whatever size it had where it came from.
#[must_use]
pub fn with_panel_size(mut self, panel: P, size: Vec2) -> Self {
self.panels.push((panel, size));
self
}
- /// The size a command floats `panel` at alone, when recorded.
+ /// The float size of `panel` of its own, when it has one.
pub fn panel(&self, panel: &P) -> Option {
Self::find(&self.panels, panel)
}
- /// The size a command floats the group of `panel` at, when recorded.
- pub fn group(&self, panel: &P) -> Option {
- Self::find(&self.groups, panel)
- }
-
- /// The size a command floats the dock column of `panel` at, when recorded.
- pub fn column(&self, panel: &P) -> Option {
- Self::find(&self.columns, panel)
+ /// The size `unit` floats at: a panel's own float size, else the size it had where it came from (`source`, a
+ /// window's own or a group's or column's with the window's title row above it), else the default.
+ pub fn size_of(&self, unit: &DragUnit, source: Option) -> Vec2 {
+ let own = match unit {
+ DragUnit::Panel(panel) => self.panel(panel),
+ _ => None,
+ };
+ let framed = |size: Vec2| if matches!(unit, DragUnit::Window(_)) { size } else { size + Vec2::new(0.0, self.title_row) };
+ own.or(source.map(framed)).unwrap_or(self.default_size)
}
fn find(sizes: &[(P, Vec2)], panel: &P) -> Option {
diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs
index 8c8cd0595..cad016f8e 100644
--- a/crates/ui-panels/src/docking/floating.rs
+++ b/crates/ui-panels/src/docking/floating.rs
@@ -164,7 +164,8 @@ impl<'a> FloatingGroup<'a> {
#[must_use]
pub fn window_of(mut self, anchor: P) -> Self {
let active = PanelKey::of(&anchor);
- self.start_drag = Some(Box::new(move |cx| start_group_drag(cx, DragUnit::Window(anchor), active, None)));
+ let size = self.rect.size();
+ self.start_drag = Some(Box::new(move |cx| start_group_drag(cx, DragUnit::Window(anchor), active, Some(size), None)));
self
}
@@ -283,7 +284,8 @@ impl Container for FloatingGroup<'_> {
}
fn header(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) {
- let shown = TitleRow::new(cx.label()).strength(HeaderStrength::Strong).actions(self.actions.iter().copied()).show(ui);
+ // A drag bar with no title: the tabs below name the panels.
+ let shown = TitleRow::new("").strength(HeaderStrength::Strong).actions(self.actions.iter().copied()).show(ui);
self.taken = shown.action.or(self.taken);
if let Some(rows) = self.menu.as_mut() {
self.menu_opener = rows.hang(ui, &shown, cx.words::().panel_menu.clone());
diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs
index c1c28edb9..34d434c3d 100644
--- a/crates/ui-panels/src/docking/group.rs
+++ b/crates/ui-panels/src/docking/group.rs
@@ -102,7 +102,9 @@ impl Component for GroupGrip {
fn update(&mut self, cx: &mut Cx<'_, Self>) {
self.double = cx.press().double_pressed();
if self.movable && matches!(cx.press().phase, PressPhase::DragStart { .. }) {
- start_group_drag(cx, self.unit.clone(), self.active, self.ghost.clone());
+ // The ghost's extent is the group's own.
+ let source = self.ghost.as_ref().map(|(size, _)| *size);
+ start_group_drag(cx, self.unit.clone(), self.active, source, self.ghost.clone());
self.started = true;
}
}
@@ -341,7 +343,7 @@ impl Container for DockGroup<'_, P> {
.tear_off()
.natural_height(true)
.accept_from(|_| false)
- .drag_payload(move |drag: &ListDrag| Some(PanelDrag { panel: drag.grabbed, from, started }))
+ .drag_payload(move |drag: &ListDrag| Some(PanelDrag { panel: drag.grabbed, from, source: Some(size), started }))
.show_items(ui, &source, &mut |key, _| {
let panel = panels.iter().find(|panel| &panel.key == key);
let title = panel.map_or_else(Label::default, |panel| panel.title.clone());
diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs
index e698586ec..c79fb7bf4 100644
--- a/crates/ui-panels/src/docking/iconic.rs
+++ b/crates/ui-panels/src/docking/iconic.rs
@@ -320,7 +320,7 @@ impl Component for IconicColumn<'_, P> {
{
let shown = lead.active_panel().unwrap_or(anchor);
let label = Label::from((self.spec)(shown).label.as_str().to_owned());
- start_group_drag(cx, DragUnit::Group(anchor.clone()), PanelKey::of(shown), Some((extent.size(), label)));
+ start_group_drag(cx, DragUnit::Group(anchor.clone()), PanelKey::of(shown), None, Some((extent.size(), label)));
began = true;
}
}
@@ -329,7 +329,7 @@ impl Component for IconicColumn<'_, P> {
&& let Some(panel) = self.panel(*group, *panel)
{
let label = Label::from((self.spec)(panel).label.as_str().to_owned());
- start_group_drag(cx, DragUnit::Panel(panel.clone()), PanelKey::of(panel), Some((cell.size(), label)));
+ start_group_drag(cx, DragUnit::Panel(panel.clone()), PanelKey::of(panel), None, Some((cell.size(), label)));
began = true;
}
}
diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs
index f0fceee29..2190bff03 100644
--- a/crates/ui-panels/src/docking/mod.rs
+++ b/crates/ui-panels/src/docking/mod.rs
@@ -69,7 +69,7 @@ use crate::style::{ComponentStyle, StyleCx};
use craft_behavior::dock::{DockEdge, Layout, Node, SplitSize};
use craft_behavior::{Axis, EditEvents, Flow, Metrics, PartKey, Sense};
use divider::{Divider, Drag};
-use egui::{Rect, Response};
+use egui::{Rect, Response, Vec2};
use std::fmt::Debug;
use std::hash::{DefaultHasher, Hash, Hasher};
use tree::{FrameRules, SplitHandle};
@@ -121,13 +121,15 @@ impl PanelTitle {
}
/// What a dragged tab carries.
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq)]
#[non_exhaustive]
pub struct PanelDrag {
/// The dragged panel.
pub panel: PanelKey,
/// The group the tab was in, named by its anchor panel.
pub from: PanelKey,
+ /// The size of that group where the drag started: a float of the panel takes it.
+ pub source: Option,
/// The arrangement the drag started on, when it started in a dock area.
pub(crate) started: Option,
}
diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs
index 2b5b996c5..451ab69ed 100644
--- a/crates/ui-panels/src/docking/spec.rs
+++ b/crates/ui-panels/src/docking/spec.rs
@@ -63,7 +63,8 @@ pub struct PanelSpec {
/// free height with the other groups that have none when no group asks for a fill, and takes the group's
/// minimum when one does.
pub heights: Option,
- /// The size the panel floats at: its width and the most height it takes. `None`: `FloatSpace`'s default size.
+ /// The size the panel floats at: its width and the most height it takes. `None`: the size of the group it floats
+ /// out of, else `FloatSpace`'s default size.
pub float_size: Option,
/// 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.
diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs
index fee121962..c9fbb13be 100644
--- a/crates/ui-panels/src/docking/targets.rs
+++ b/crates/ui-panels/src/docking/targets.rs
@@ -369,11 +369,14 @@ impl DockTargets {
/// What a drag of a whole group, window or column carries, beside `PanelDrag` for one tab. Every such drag starts
/// through [`start_group_drag`](super::start_group_drag), so the type is `non_exhaustive` and only the crate builds it.
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct GroupDrag
{
/// What the drag moves, named by a panel of it.
pub unit: DragUnit
,
+ /// The size of the group, window or column where the drag started, which a float of it takes; `None` where
+ /// that size is not the unit's own (an iconic column's cells).
+ pub source: Option,
/// The panel the unit shows, for the drag's preview.
pub active: PanelKey,
/// The arrangement the drag started on, when it started in a dock area.
diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs
index c7ad2b7b8..8ebf66f8b 100644
--- a/crates/ui-patterns/src/patterns/dock/area.rs
+++ b/crates/ui-patterns/src/patterns/dock/area.rs
@@ -622,12 +622,16 @@ impl Pass<'_, P> {
(rows, hosted)
}
- /// Runs a panel command on `panel`: the event of a command the host carries out, else its actions.
- fn run(&mut self, panel: &P, command: DockCommands) {
+ /// Runs a panel command on `panel`: the event of a command the host carries out, else its actions. `source` is
+ /// the size of the group the command runs from, which a float of it takes.
+ fn run(&mut self, panel: &P, command: DockCommands, source: Option) {
let scene = self.scene;
let permissions = |panel: &P| scene.permissions(panel);
// The area's permissions are narrowed for a locked workspace already.
- let commands = DockScene::new(scene.layout, scene.space, false, &permissions);
+ let mut commands = DockScene::new(scene.layout, scene.space, false, &permissions);
+ if let Some(size) = source {
+ commands = commands.source(size);
+ }
let report = &mut self.report;
if let Some(event) = command.event(panel) {
report.events.push(event);
@@ -653,8 +657,8 @@ impl Pass<'_, P> {
fn pick(&mut self, panel: &P, item: GroupItem) {
match item {
GroupItem::MoveTo(at) => self.move_to(panel, at),
- GroupItem::CollapseToIcons => self.run(panel, DockCommands::CollapseToIcons),
- GroupItem::AutoCollapse => self.run(panel, DockCommands::AutoCollapse),
+ GroupItem::CollapseToIcons => self.run(panel, DockCommands::CollapseToIcons, None),
+ GroupItem::AutoCollapse => self.run(panel, DockCommands::AutoCollapse, None),
}
}
@@ -711,7 +715,7 @@ impl Pass<'_, P> {
self.pick(shown, item);
}
for command in output.commands {
- self.run(shown, command);
+ self.run(shown, command, Some(rect.size()));
}
if output.toggle_minimized {
self.report.actions.push(match look.section {
@@ -726,7 +730,7 @@ impl Pass<'_, P> {
&& scene.permissions(panel).floatable
&& (scene.config.float_on_empty_drop || !ui.ctx().content_rect().contains(torn.pointer))
{
- self.report.actions.push(float_drop(&DragUnit::Panel(panel.clone()), scene.space, torn.pointer).action);
+ self.report.actions.push(float_drop(&DragUnit::Panel(panel.clone()), scene.space, torn.pointer, Some(rect.size())).action);
}
None
}
@@ -912,8 +916,10 @@ impl Pass<'_, P> {
if let Some(item) = picked.get() {
self.pick(&active, item);
}
+ // The window's commands run from its body, below the title row.
+ let body = opening.rect.size() - Vec2::new(0.0, scene.sizes.bar);
for command in commands {
- self.run(&active, command);
+ self.run(&active, command, Some(body));
}
if output.minimized_toggled {
self.report.actions.push(Action::set_minimized(anchor.clone(), !window.minimized));
diff --git a/crates/ui-patterns/tests/it/docking/floating_area.rs b/crates/ui-patterns/tests/it/docking/floating_area.rs
index 45d8c42e3..9f2c71ed8 100644
--- a/crates/ui-patterns/tests/it/docking/floating_area.rs
+++ b/crates/ui-patterns/tests/it/docking/floating_area.rs
@@ -156,3 +156,27 @@ fn a_floating_window_leaves_the_docked_tree_its_room() {
let beside = docked_bottom(with_window(Some(Node::tabs(vec![DOCKED], 0))));
assert!((beside - alone).abs() <= SLACK, "the docked group ends at {beside} beside the window, at {alone} without it");
}
+
+/// A floating window's drag bar shows no title: its tab is the one place the panel's name shows in the window.
+#[trial]
+fn a_floating_windows_drag_bar_shows_no_title() {
+ let bed = bed(with_window(Some(Node::tabs(vec![DOCKED], 0))), |_| Permissions::ALL);
+ let named = bed.fixture.texts().iter().filter(|text| text.text == title(WINDOW) && WINDOW_AT.contains_rect(text.rect)).count();
+ assert_eq!(named, 1, "only the tab names the panel: {:?}", bed.fixture.texts());
+}
+
+/// A tab dragged out of the window floats at the width its group had where it was docked, not a default size.
+#[trial]
+fn a_tab_torn_out_of_its_group_floats_at_the_groups_width() {
+ let mut bed = bed(Layout::new(Some(Node::tabs(vec![DOCKED, SECOND], 0)), Vec::new()), |_| Permissions::ALL);
+ let group = bed.fixture.by_role(Role::TAB_PANEL).first().expect("the docked group shows").rect;
+ let tab = bed.fixture.by_role(Role::TAB).into_iter().max_by(|a, b| a.rect.min.x.total_cmp(&b.rect.min.x)).expect("the second tab shows");
+ let outside = Pos2::new(group.center().x, -40.0);
+ press_and_move(&mut bed.fixture, tab.center(), outside - tab.center());
+ bed.fixture.frame(vec![release(outside)]);
+ bed.fixture.settle();
+ let layout = bed.workspace.borrow().layout.clone();
+ let window =
+ layout.floating.iter().find(|window| window.contains(&SECOND)).unwrap_or_else(|| panic!("the tab floats: {:?}", bed.actions.borrow()));
+ assert!((window.rect.width() - group.width()).abs() <= SLACK, "floated {:?}, docked group {group:?}", window.rect);
+}
diff --git a/crates/ui-patterns/tests/it/docking/native.rs b/crates/ui-patterns/tests/it/docking/native.rs
index f0490be3a..15b63fbc3 100644
--- a/crates/ui-patterns/tests/it/docking/native.rs
+++ b/crates/ui-patterns/tests/it/docking/native.rs
@@ -111,6 +111,23 @@ fn a_native_dock_window_shows_no_os_title_bar() {
}
}
+/// A native float's OS window opens at the float's own size, not at what its content measured.
+#[trial]
+fn a_native_float_opens_at_its_own_size() {
+ let windows = Windows::new();
+ windows.root_info(info(true, ROOT_AT));
+ let mut workspace = Workspace::new(Layout::new(None, vec![float()]));
+ let mut sizes = Vec::new();
+ for _ in 0..3 {
+ let out = windows.frame(vec![], vec![], |ui| {
+ DockArea::new("Native dock", Bind::bound(&mut workspace), &mut Palettes(Permissions::ALL), DockConfig::default()).show(ui);
+ });
+ sizes.extend(out.builders.into_iter().filter(|(viewport, _)| *viewport != ViewportId::ROOT).map(|(_, builder)| builder.inner_size));
+ }
+ let size = float().rect.size();
+ assert!(!sizes.is_empty() && sizes.iter().all(|shown| *shown == Some(size)), "{size:?} asked, {sizes:?} opened");
+}
+
/// The OS close of a native float closes its window when every panel may close, and leaves it open otherwise.
#[trial]
fn the_os_close_of_a_native_float_closes_it_when_its_panels_may_close() {