mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 01:44:25 +00:00
A title bar end with no captions keeps its content the regular pad off the window's edge
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user