diff --git a/crates/ui-shell/src/shell/title_bar/bar.rs b/crates/ui-shell/src/shell/title_bar/bar.rs index a805409b9..0b7ec42a6 100644 --- a/crates/ui-shell/src/shell/title_bar/bar.rs +++ b/crates/ui-shell/src/shell/title_bar/bar.rs @@ -57,6 +57,8 @@ impl Outcome for TitleBarOutput { /// - **Integrated.** The caption buttons of the window's layout sit at the two ends, flush with the window's edges. /// A double click maximizes or restores. /// +/// An end with no caption buttons or lights keeps the content `space.pad.regular` off the window's edge. +/// /// In full screen the bar shows no captions and reserves no room. The free area is the container's move band: /// pressing and dragging it moves the window, and a double click acts as above. /// @@ -164,7 +166,9 @@ impl<'a> TitleBar<'a> { /// Shows one end's room and buttons, and acts on a click: Minimize and Maximize go to the window the bar acts on, /// Close is reported. fn show_end(&mut self, ui: &mut Ui, cx: &BodyCx<'_>, end: &End, window: &Window) { - let height = SlotSize::TitleBar.resolve(&Env::of(ui).tokens); + let tokens = Env::of(ui).tokens.clone(); + let height = SlotSize::TitleBar.resolve(&tokens); + let pad = tokens.tokens().space.pad.regular; // The running window's captions take the glyphs of the desktop's icon theme; a frame given in place of the // window's (a story, a preview) draws the family's own. let ctx = cx.memory.ctx().clone(); @@ -184,7 +188,7 @@ impl<'a> TitleBar<'a> { Placed::new(("caption", index), button) }) .collect(); - arrange(ui, &Strip::new(end, height), &mut buttons); + arrange(ui, &Strip::padded(end, height, pad), &mut buttons); let (host, viewport) = (WindowHost::of(&ctx), pass::current_viewport(&ctx)); for (slot, placed) in end.captions.iter().zip(&buttons) { if !placed.response().is_some_and(Response::clicked) { diff --git a/crates/ui-shell/src/shell/title_bar/measure.rs b/crates/ui-shell/src/shell/title_bar/measure.rs index 06fc255e7..c23bec511 100644 --- a/crates/ui-shell/src/shell/title_bar/measure.rs +++ b/crates/ui-shell/src/shell/title_bar/measure.rs @@ -73,6 +73,16 @@ impl Strip { pub(super) fn new(end: &End, height: f32) -> Strip { Strip { inset: end.inset, widths: end.captions.iter().map(|slot| slot.rect.width()).collect(), height } } + + /// The strip of `end` that keeps the bar's content `pad` off the window's edge when the end holds no captions and + /// no traffic lights. + pub(super) fn padded(end: &End, height: f32, pad: f32) -> Strip { + let mut strip = Strip::new(end, height); + if strip.widths.is_empty() && strip.inset <= 0.0 { + strip.inset = pad; + } + strip + } } impl Arrangement for Strip {