From 8ef85cc4a80eeff5f8df0973c354b1179c6e02ef Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 22 Nov 2026 00:07:47 +0000 Subject: [PATCH] Dock group header: a raw egui layout again; its side-by-side items take none of the header column's flow facts, the tab row takes the rest of the line and a settled header runs no Row --- crates/ui-panels/src/docking/group.rs | 49 +++++++++++-------- .../exceptions/craft-ui-panels/docking.toml | 8 +++ 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index 85eb040a6..5bdc7e57d 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -9,11 +9,10 @@ use super::{PanelDrag, PanelKey, PanelTitle, Titles}; use crate::buttons::IconButton; use crate::contract::overlay::Anchor; use crate::contract::{ - Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, Gap, HeaderEdge, HeaderParts, HeaderRegion, + Access, Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, ContextMenuRequest, Cx, HeaderEdge, HeaderParts, HeaderRegion, ListDrag, MeasureCx, MemoProps, MemoView, Name, Outbox, Outcome, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, PopupKind, Props as _, Role, ShowCollection as _, ShowContainer as _, Sizing, WordSetCx as _, }; -use crate::layout_components::Row; use crate::menu::{GroupItem, Menu, PanelMenu, PanelRow}; use crate::runtime::commands::{CommandSet as _, CommandState, Commands as _}; use crate::runtime::env::Label; @@ -505,27 +504,35 @@ impl Container for let started = drop::started(&cx.env); let mut extra = self.extra.take(); let env = crate::runtime::env::Env::of(ui); - ui.set_min_height(env.tokens.size.panel_header); + let rtl = env.direction.is_rtl(); + let (line, gap) = (env.tokens.size.panel_header, env.tokens.space.gap.item); + ui.set_min_height(line); let surface_pressed = cx.surface_pressed(); + // A raw egui layout: the host's items and the tab row sit side by side, and the header column's flow facts are + // not theirs. The tab row takes the rest of the line, so the strip's empty room is its own, and nothing but the + // memoized tab row runs in it, so a settled header replays. + let layout = if rtl { egui::Layout::right_to_left(egui::Align::Min) } else { egui::Layout::left_to_right(egui::Align::Min) }; let mut sent = Vec::new(); - let mut strip = None; - let _ = Row::new().fill_width().gap(Gap::Item).show(ui, |ui, _| { - if let Some(hook) = extra.as_mut() { - hook.run(ui, cx); - } - let row = TabRow { - anchor: self.anchor.clone(), - panels: self.panels.clone(), - active: self.active, - closable: self.closable, - wheel_selects: self.wheel_selects_tabs, - dock: self.dock, - sent: Outbox::new(&mut sent), - }; - // The env around the tab row holds only values its key follows (the shell, the dock's arrangement, a - // floating window's layer), no handle or context rebuilt each pass, so it replays at rest. - strip = MemoView::new(("tabs", cx.id), row, tab_row::

).show(ui); - }); + let strip = ui + .with_layout(layout, |ui| { + ui.spacing_mut().item_spacing.x = gap; // design: allow[style-mutation](the header lays its title cells with an egui layout and sets that layout's gap) + if let Some(hook) = extra.as_mut() { + hook.run(ui, cx); + } + let row = TabRow { + anchor: self.anchor.clone(), + panels: self.panels.clone(), + active: self.active, + closable: self.closable, + wheel_selects: self.wheel_selects_tabs, + dock: self.dock, + sent: Outbox::new(&mut sent), + }; + // The env around the tab row holds only values its key follows (the shell, the dock's arrangement, a + // floating window's layer), no handle or context rebuilt each pass, so it replays at rest. + MemoView::new(("tabs", cx.id), row, tab_row::

).show(ui) + }) + .inner; self.extra = extra; // A press on the group's empty body focuses its panel, as in Photoshop. if surface_pressed && let Some(strip) = strip { diff --git a/design/exceptions/craft-ui-panels/docking.toml b/design/exceptions/craft-ui-panels/docking.toml index c7dc26bf5..1bfc5dd49 100644 --- a/design/exceptions/craft-ui-panels/docking.toml +++ b/design/exceptions/craft-ui-panels/docking.toml @@ -1,5 +1,13 @@ config_version = 1 +[[exception]] +name = "dock-header-gap" +kind = "marker" +rule = "style-mutation" +path = "crates/ui-panels/src/docking/group.rs" +reason = "The header lays its title cells with an egui layout and sets that layout gap." +count = 1 + [[exception]] name = "iconic-story-stage" kind = "marker"