Merge branch 'design-port/fw-dock-flyout-height' into design-port/pr-docking-windows

# Conflicts:
#	crates/ui-panels/src/docking/iconic.rs
#	crates/ui-panels/src/docking/mod.rs
#	docs/ui-docking.md
This commit is contained in:
skylartaylor committed 2026-11-25 03:10:11 +01:00
commit e010b91cb1
5 files changed
+119 -13

No files matched your search

+14 -7
View File
@@ -6,7 +6,9 @@ use super::dock_column::{
register_edges, show_bar,
};
use super::group::GripMarks;
use super::{CardInset, DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag};
use super::{
CardInset, DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, FlyoutHeight, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag,
};
use crate::buttons::IconButton;
use crate::contract::overlay::{Anchor, PopupLayer};
use crate::contract::{
@@ -181,10 +183,12 @@ pub struct IconicColumnStyle {
/// column registers its drop spots with the dock `dock` as an expanded column does: its edges, the seams between its
/// icon groups, the top and bottom of the stack and each icon group's cells, which join its tabs. The flyout shows
/// its group through the `view` of [`show_flyouts`](IconicColumn::show_flyouts), with the opened panel active, as tall as the view measures the
/// group within the room and at least the height of its panels' default heights; a group the user sized keeps that
/// size. The flyout's top is level with its group's icons, shifted by the group's `flyout_offset`, inside `within`.
/// The user resizes it by its top and bottom edges and the edge away from the column; each step comes back in
/// [`IconicColumnOutput::flyout`], which the host keeps in the group (`flyout_width`, `height`, `flyout_offset`).
/// group within the room and at least the default height ([`DockHeights`](super::DockHeights)) of each of its panels
/// whose [`FlyoutHeight`] is `Docked`, the default: a panel whose flyout is `Content` tall leaves its docked heights to
/// its group docked in a column. A group the user sized keeps that size. The flyout's top is level with its group's
/// icons, shifted by the group's `flyout_offset`, inside `within`. The user resizes it by its top and bottom edges and
/// the edge away from the column; each step comes back in [`IconicColumnOutput::flyout`], which the host keeps in the
/// group (`flyout_width`, `height`, `flyout_offset`).
/// The flyouts stand above the floating windows as popups do, or below them with `flyout_layer` set to
/// `PopupLayer::BelowWindows`, which a dock area sets for its docked columns from `DockConfig::flyout_layer`.
///
@@ -425,12 +429,15 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> {
Plan { bar, cells, names, grips, groups, body }
}
/// The height of the flyout of `group`: the group's own height, else what its panels ask for, else the least.
/// The height of the flyout of `group`: the group's own height, else the docked default heights of its panels
/// whose flyout takes them ([`FlyoutHeight::Docked`]), else the least.
fn flyout_height(&self, group: &Group<P>, sizes: &DockSizes) -> f32 {
let content = group
.panels
.iter()
.filter_map(|panel| (self.spec)(panel).heights.filter(|heights| heights.valid()))
.map(|panel| (self.spec)(panel))
.filter(|spec| spec.flyout_height == FlyoutHeight::Docked)
.filter_map(|spec| spec.heights.filter(|heights| heights.valid()))
.map(|heights| heights.default + sizes.strip)
.fold(sizes.strip + sizes.least, f32::max);
group.height.filter(|height| height.is_finite() && *height > 0.0).unwrap_or(content).max(sizes.strip + sizes.least)
+76 -2
View File
@@ -1,5 +1,5 @@
//! Trials of `IconicColumn`: the letter of a panel without an icon, the names a wide column shows, the grips of its
//! groups, the resizes of its flyouts, and a flyout that a command leaves open.
//! groups, the heights and resizes of its flyouts, and a flyout that a command leaves open.
#![allow(clippy::panic, clippy::expect_used, reason = "trials assert by panicking")]
use super::GRIP;
@@ -8,7 +8,8 @@ use crate::contract::overlay::{self, OpenFilter};
use crate::contract::{Bind, Show as _, ShowContainer as _};
use crate::docking::group::GRIP_ABOVE;
use crate::docking::{
DockHeights, DockSizes, DockSpot, DockTargets, DragUnit, FlyoutResize, GroupAt, GroupDrag, GroupGrip, IconicColumn, PanelKey, PanelSpec,
DockColumn, DockHeights, DockSizes, DockSpot, DockTargets, DragUnit, FlyoutHeight, FlyoutResize, GroupAt, GroupDrag, GroupGrip, IconicColumn,
PanelKey, PanelSpec,
};
use crate::runtime::commands::{AppCatalog, Binding, CommandDef, CommandInput, Scope};
use crate::runtime::drag;
@@ -420,6 +421,79 @@ fn a_flyout_with_an_offset_in_a_short_viewport_stays_inside_and_resizes_its_widt
}
}
/// The body height a panel asks for docked in a column, well above what its one-line body measures.
const DOCKED: f32 = 260.0;
/// A panel with a one-line body that asks for [`DOCKED`] in a dock column, its flyout `height` tall; the other panel
/// asks for no height.
fn docked_tall(height: FlyoutHeight) -> impl Fn(&u8) -> PanelSpec {
move |panel| match panel {
0 => PanelSpec::new("Swatches").heights(DockHeights::new(DOCKED)).flyout_height(height),
_ => PanelSpec::new("Brushes"),
}
}
/// What a group with a one-line body measures in the trials: its strip, the body's padding and a line, four strips.
fn one_line(sizes: &DockSizes) -> f32 {
sizes.strip * 4.0
}
/// The height of the flyout of the [`docked_tall`] panel at `height`, whose group measures [`one_line`], and the dock
/// sizes it showed in.
fn flyout_height_of(height: FlyoutHeight) -> (f32, DockSizes) {
let shown = Rc::new(Cell::new(None));
let (seen, open) = (Rc::clone(&shown), Cell::new(None));
let spec = docked_tall(height);
let place = Rect::from_min_size(Pos2::ZERO, Vec2::new(RAIL, SCREEN.y));
let mut fixture = Fixture::new(move |ui| {
let column = Column::new(vec![Group::new(vec![0], 0)]);
let measured = one_line(&StyleCx::with_root(ui.ctx(), DockSizes::style));
let mut now = open.get();
IconicColumn::new("Panels", global("iconic column", "flyout height"), &column, Bind::bound(&mut now), &spec)
.within(screen())
.show_flyouts_at(ui, place, |_, at, _, _| match at {
GroupAt::Measure(_) => Some(measured),
GroupAt::Show(rect) => {
seen.set(Some(rect));
None
}
});
open.set(now);
});
fixture.room(SCREEN).settle();
let icon = fixture.by_label("Swatches").expect("the Swatches icon").rect.center();
fixture.click_at(icon).settle();
(shown.get().expect("the flyout is open").height(), StyleCx::with_root(fixture.ctx(), DockSizes::style))
}
/// A panel that asks for a tall docked height opens a flyout at least that tall by default; with
/// `FlyoutHeight::Content` its flyout is as tall as its one-line body measures, while docked in a column its group
/// keeps the docked height.
#[trial]
fn a_content_tall_flyout_ignores_the_docked_height_that_its_docked_group_keeps() {
let (by_default, sizes) = flyout_height_of(FlyoutHeight::Docked);
let (docked, measured) = (DOCKED + sizes.strip, one_line(&sizes));
assert!(measured < docked && measured > sizes.strip + sizes.least, "the body measures between the least and the docked height");
assert!(near(by_default, docked), "by default the flyout takes the docked height: {by_default} for {docked}");
let (content, _) = flyout_height_of(FlyoutHeight::Content);
assert!(near(content, measured), "a content-tall flyout is as tall as its body measures: {content} for {measured}");
let rects = Rc::new(RefCell::new(Vec::new()));
let seen = Rc::clone(&rects);
let spec = docked_tall(FlyoutHeight::Content);
let mut fixture = Fixture::new(move |ui| {
let column = Column::new(vec![Group::new(vec![0], 0), Group::new(vec![1], 0)]);
let mut shown = Vec::new();
DockColumn::new("Panels", global("dock column", "flyout height"), &column, &spec).show_groups(ui, |group, rect, _, _| {
shown.push((group.panels.first().copied(), rect));
});
*seen.borrow_mut() = shown;
});
fixture.room(SCREEN).settle();
let group = rects.borrow().iter().find(|(panel, _)| *panel == Some(0)).map(|(_, rect)| *rect).expect("the docked group shows");
assert!(near(group.height(), docked), "docked in a column the group keeps its docked height: {group:?} for {docked}");
}
/// Each icon group's grip strip has its own room at the group's top: across the group, below the bar or the group
/// before it and above the group's first icon, overlapping no icon. A drag that starts on a grip moves its whole
/// group, as a drag on an icon moves its panel.
+1 -1
View File
@@ -45,7 +45,7 @@ pub use panels::{close_requests, open_requests};
pub use placed::{Placing, placed_rect, with_area_rules};
pub use root::{DockRoot, DockRootOutput, DockRootStyle};
pub use sources::{DividerKind, DockSource, SourceKind};
pub use spec::{DockGrid, DockHeights, PanelSpec};
pub use spec::{DockGrid, DockHeights, FlyoutHeight, PanelSpec};
pub use splitter::{Splitter, SplitterStyle};
pub use targets::{CardInset, DockSizes, DockSpot, DockTargets, GroupDrag, ZoneRule};
pub use words::DockWords;
+26 -2
View File
@@ -51,6 +51,19 @@ impl DockHeights {
}
}
/// How tall the flyout of a panel in a column collapsed to icons opens while the user has not resized its group. Either
/// way the flyout is at least as tall as its body measures, within the room below its top.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum FlyoutHeight {
/// At least the panel's [`DockHeights::default`], the height its group takes docked in a column.
#[default]
Docked,
/// As tall as the body measures, at least the dock's least group height: the panel's [`DockHeights`] size its
/// group docked in a column only.
Content,
}
/// How a panel that lays its content in a grid of equal columns (a toolbar) sizes its dock column. The column is a
/// whole number of content columns wide, its steps ([`Column::steps`](craft_behavior::dock::Column::steps)), and as
/// tall as the content measures at that width: docked from the top of the dock, floating under the title row. A drag
@@ -162,9 +175,12 @@ pub struct PanelSpec {
pub icon: Option<IconSpec<'static>>,
/// Body size limits.
pub limits: SizeLimits,
/// How the panel's group sizes itself in a dock column until the user resizes it. `None` shares the column's
/// free height with the column's last open group, which fills it, and with the other groups that have none.
/// How the panel's group sizes itself in a dock column until the user resizes it, and under
/// [`FlyoutHeight::Docked`] the least height of its flyout. `None` shares the column's free height with the
/// column's last open group, which fills it, and with the other groups that have none.
pub heights: Option<DockHeights>,
/// How tall the panel's flyout opens: at least its docked default height, or as tall as its body measures.
pub flyout_height: FlyoutHeight,
/// 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<Vec2>,
@@ -208,6 +224,7 @@ impl PanelSpec {
icon: None,
limits: SizeLimits::default(),
heights: None,
flyout_height: FlyoutHeight::Docked,
float_size: None,
allow_native: true,
window_kind: WindowKind::Tool,
@@ -270,6 +287,13 @@ impl PanelSpec {
self
}
/// How tall the panel's flyout opens.
#[must_use]
pub fn flyout_height(mut self, height: FlyoutHeight) -> Self {
self.flyout_height = height;
self
}
/// The size the panel floats at.
#[must_use]
pub fn float_size(mut self, size: Vec2) -> Self {
+2 -1
View File
@@ -56,7 +56,7 @@ The host keeps its panels' specs in a plain-data model that implements `PanelSpe
| Method | Does |
| --- | --- |
| `spec` | The panel's `PanelSpec`: label, icon, `SizeLimits`, `DockHeights`, float size, `allow_native`, `window_kind`, `canvas`, `grid`, `host_body`. |
| `spec` | The panel's `PanelSpec`: label, icon, `SizeLimits`, `DockHeights`, `FlyoutHeight`, float size, `allow_native`, `window_kind`, `canvas`, `grid`, `host_body`. |
| `permissions` | The panel's `Permissions` (default `ALL`). |
The area reads them only when the model's revision, the workspace's revision or the lock changes (`runtime::derived`), and keeps what it read otherwise, so an idle pass reads no spec. A host changes a label or a limit by editing the model. A spec reads no style: a tool rail's grid is `DockGrid::rail(cells)`, which the dock sizes from its own tokens.
@@ -124,6 +124,7 @@ The theme's docking sizes (`DockSizes`) set the drop bands and zones. `DockWords
- A drag ends without a change when another arrangement replaces the workspace it started on: it records the workspace's generation, which `Workspace::replace` and the `WorkspaceSet` switch and reset change. The dock's own edits keep the generation, so they keep the drag. Every write moves the workspace's revision (`Workspace::revision`), which keys what the area derives.
- A floating window's id comes from a counter its layout owns (`Layout::fresh_window_id`). It starts above every id the layout is built or loaded with and only grows while the layout lives; `Workspace::replace` gives the incoming windows ids the replaced layout never gave out, and a dock area keeps the windows its actions add above every id it has shown, so a workspace an undo brings back draws no id twice (`Workspace::raise_window_floor`). An OS window never passes to another window.
- A dock column's last open group fills the column: it takes the height the other groups leave and asks for its `DockHeights::fill`. The other groups keep the height the user gave them, or take their `DockHeights::default`, which shrinks towards `compact` before the filling group gets less than its fill. Groups that ask for no heights share the free height with the filling group.
- A flyout is as tall as its group measures, within the room below its top, and at least the `DockHeights::default` of each of its panels whose `PanelSpec::flyout_height` is `FlyoutHeight::Docked`, the default. A panel with `FlyoutHeight::Content` opens a flyout as tall as its body measures, while its `DockHeights` still size its group docked in a column. A group the user sized keeps that height.
- Split handles are Tab stops, and the arrow keys move them. A divider drag is one gesture in `DockAreaOutput::edit`.
- A pointer press on a panel tab (a click, a drag's press, the tab menu's secondary press) leaves key focus where it was, so the document's keys keep working; Tab still reaches the tab row.
- Floating windows stack with the app's own egui windows in egui's area order: the one shown, pressed or raised last (`FloatingGroup::raise`, which the host's `DockArea::focus` request sets on the window holding the panel) is on top, so a dialog the app opens over a floating panel shows above it. A docked flyout with `DockConfig::flyout_layer(PopupLayer::BelowWindows)` stands below all of them.