fix(headerbar): center-align title even if start region is empty

This commit is contained in:
Michael Aaron Murphy 2023-11-01 16:29:45 +01:00 committed by Michael Murphy
parent 43c78fa0df
commit 9ccd34b5ab

View file

@ -101,13 +101,13 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
// Creates the headerbar widget. // Creates the headerbar widget.
let mut widget = widget::row::with_capacity(4) let mut widget = widget::row::with_capacity(4)
// If elements exist in the start region, append them here. // If elements exist in the start region, append them here.
.push_maybe((!start.is_empty()).then(|| { .push(
widget::row::with_children(start) widget::row::with_children(start)
.align_items(iced::Alignment::Center) .align_items(iced::Alignment::Center)
.apply(widget::container) .apply(widget::container)
.align_x(iced::alignment::Horizontal::Left) .align_x(iced::alignment::Horizontal::Left)
.width(Length::Fill) .width(Length::Fill),
})) )
// If elements exist in the center region, use them here. // If elements exist in the center region, use them here.
// This will otherwise use the title as a widget if a title was defined. // This will otherwise use the title as a widget if a title was defined.
.push(if !center.is_empty() { .push(if !center.is_empty() {