From 8e34b58bc3bf99ff7ab58dedf44a891331276784 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 11 Nov 2026 22:37:13 +0000 Subject: [PATCH] Header parts measure inside a layout-memory boundary: the faces a container measures for its header parts are no content of the body around, so no transcript keeps or checks them; DockGroup's menu button takes its side from the header slot --- crates/ui-contract/src/contract/body/hooks.rs | 2 +- crates/ui-contract/src/contract/body/regions.rs | 6 ++++-- crates/ui-panels/src/docking/group.rs | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ui-contract/src/contract/body/hooks.rs b/crates/ui-contract/src/contract/body/hooks.rs index 8d880e570..3cb538229 100644 --- a/crates/ui-contract/src/contract/body/hooks.rs +++ b/crates/ui-contract/src/contract/body/hooks.rs @@ -518,7 +518,7 @@ impl ShapeHooks for BodyHooks<'_> { ) -> Option> { let props = Arc::clone(&self.props); let header = props.header?; - let parts = comp.header_parts(cx); + let parts = layout_memory::boundary(cx.ui.ctx(), true, || comp.header_parts(cx)); if parts == crate::contract::HeaderParts::NONE { return None; } diff --git a/crates/ui-contract/src/contract/body/regions.rs b/crates/ui-contract/src/contract/body/regions.rs index 70fd00bd7..87841245e 100644 --- a/crates/ui-contract/src/contract/body/regions.rs +++ b/crates/ui-contract/src/contract/body/regions.rs @@ -250,10 +250,12 @@ impl<'b> BodyHooks<'b> { bcx.close_requested() } - /// The room the container's own header parts take this pass (`Container::header_parts`). + /// The room the container's own header parts take this pass (`Container::header_parts`). The faces it measures + /// are a question about the parts, not content of the body around: no transcript keeps or checks them. pub(super) fn header_parts(comp: &C, ui: &Ui, env: &Env, cx: &crate::contract::Cx<'_, C>) -> HeaderParts { let input = crate::contract::steps::MeasureIn { ui, env, proposal: craft_behavior::Proposal::Ideal, room: None }; - comp.header_parts(&crate::contract::steps::measure_cx::(&input, cx.style, cx.core.resolved, cx.shown.as_deref())) + let measure = crate::contract::steps::measure_cx::(&input, cx.style, cx.core.resolved, cx.shown.as_deref()); + crate::runtime::layout_memory::boundary(ui.ctx(), true, || comp.header_parts(&measure)) } /// The header's line inside its inset, less the slots of the container's own header parts at its two edges: the diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index e7e06584b..1d172d08d 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -312,9 +312,10 @@ impl Component for DockGroup<'_, P> { let sense = if self.movable { Sense::CLICK | Sense::DRAG | Sense::FOCUS } else { Sense::CLICK | Sense::FOCUS }; let _ = cx.header_part(HeaderEdge::End, GRIP, band).sense(sense).focusable(); if self.menu_button() { - let size = cx.face(Self::menu_face(words.panel_menu.clone())); - let end = rest.take_end(size.x).0; - let button = Rect::from_min_size(egui::Pos2::new(end.left(), slot.top()), Vec2::new(end.width(), size.y.min(slot.height()))); + // An icon button is square: its side is the slot's room past the band and the gap. + let side = (slot.width() - cx.tokens.size.handle.band_outer - cx.tokens.space.gap.item).max(0.0); + let end = rest.take_end(side).0; + let button = Rect::from_min_size(egui::Pos2::new(end.left(), slot.top()), Vec2::new(end.width(), side.min(slot.height()))); let _ = cx .header_part(HeaderEdge::End, MENU, button) .sense(Sense::CLICK | Sense::FOCUS)