fix(header_bar): match spacing to designs
This commit is contained in:
parent
af7157b45a
commit
8e823f622f
2 changed files with 44 additions and 10 deletions
|
|
@ -882,7 +882,30 @@ impl<App: Application> ApplicationExt for App {
|
||||||
header = header.end(element.map(Message::App));
|
header = header.end(element.map(Message::App));
|
||||||
}
|
}
|
||||||
|
|
||||||
header.apply(|w| id_container(w, iced_core::id::Id::new("COSMIC_header")))
|
header
|
||||||
|
// Needed for apps without a content container, but with a header bar
|
||||||
|
.apply(container)
|
||||||
|
.style(move |theme| container::Style {
|
||||||
|
background: if content_container {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(iced::Background::Color(
|
||||||
|
theme.cosmic().background.base.into(),
|
||||||
|
))
|
||||||
|
},
|
||||||
|
border: iced::Border {
|
||||||
|
radius: [
|
||||||
|
theme.cosmic().radius_s()[0] - 1.0,
|
||||||
|
theme.cosmic().radius_s()[1] - 1.0,
|
||||||
|
theme.cosmic().radius_0()[2],
|
||||||
|
theme.cosmic().radius_0()[3],
|
||||||
|
]
|
||||||
|
.into(),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.apply(|w| id_container(w, iced_core::id::Id::new("COSMIC_header")))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
@ -892,17 +915,19 @@ impl<App: Application> ApplicationExt for App {
|
||||||
.apply(container)
|
.apply(container)
|
||||||
.padding(if sharp_corners { 0 } else { 1 })
|
.padding(if sharp_corners { 0 } else { 1 })
|
||||||
.style(move |theme| container::Style {
|
.style(move |theme| container::Style {
|
||||||
icon_color: Some(iced::Color::from(theme.cosmic().background.on)),
|
background: if content_container {
|
||||||
text_color: Some(iced::Color::from(theme.cosmic().background.on)),
|
Some(iced::Background::Color(
|
||||||
background: Some(iced::Background::Color(
|
theme.cosmic().background.base.into(),
|
||||||
theme.cosmic().background.base.into(),
|
))
|
||||||
)),
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
border: iced::Border {
|
border: iced::Border {
|
||||||
color: theme.cosmic().bg_divider().into(),
|
color: theme.cosmic().bg_divider().into(),
|
||||||
width: if sharp_corners { 0.0 } else { 1.0 },
|
width: if sharp_corners { 0.0 } else { 1.0 },
|
||||||
radius: theme.cosmic().radius_s().into(),
|
radius: theme.cosmic().radius_s().into(),
|
||||||
},
|
},
|
||||||
shadow: iced::Shadow::default(),
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Show any current dialog on top and centered over the view content
|
// Show any current dialog on top and centered over the view content
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2022 System76 <info@system76.com>
|
// Copyright 2022 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use crate::cosmic_theme::Density;
|
use crate::cosmic_theme::{Density, Spacing};
|
||||||
use crate::{ext::CollectionWidget, widget, Element};
|
use crate::{theme, widget, Element};
|
||||||
use apply::Apply;
|
use apply::Apply;
|
||||||
use derive_setters::Setters;
|
use derive_setters::Setters;
|
||||||
use iced::Length;
|
use iced::Length;
|
||||||
|
|
@ -287,6 +287,12 @@ impl<'a, Message: Clone + 'static> Widget<Message, crate::Theme, crate::Renderer
|
||||||
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
/// Converts the headerbar builder into an Iced element.
|
/// Converts the headerbar builder into an Iced element.
|
||||||
pub fn view(mut self) -> Element<'a, Message> {
|
pub fn view(mut self) -> Element<'a, Message> {
|
||||||
|
let Spacing {
|
||||||
|
space_xxxs,
|
||||||
|
space_xxs,
|
||||||
|
..
|
||||||
|
} = theme::active().cosmic().spacing;
|
||||||
|
|
||||||
// Take ownership of the regions to be packed.
|
// Take ownership of the regions to be packed.
|
||||||
let start = std::mem::take(&mut self.start);
|
let start = std::mem::take(&mut self.start);
|
||||||
let center = std::mem::take(&mut self.center);
|
let center = std::mem::take(&mut self.center);
|
||||||
|
|
@ -307,6 +313,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
// If elements exist in the start region, append them here.
|
// If elements exist in the start region, append them here.
|
||||||
.push(
|
.push(
|
||||||
widget::row::with_children(start)
|
widget::row::with_children(start)
|
||||||
|
.spacing(space_xxxs)
|
||||||
.align_y(iced::Alignment::Center)
|
.align_y(iced::Alignment::Center)
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.align_x(iced::Alignment::Start)
|
.align_x(iced::Alignment::Start)
|
||||||
|
|
@ -316,6 +323,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
// 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() {
|
||||||
widget::row::with_children(center)
|
widget::row::with_children(center)
|
||||||
|
.spacing(space_xxxs)
|
||||||
.align_y(iced::Alignment::Center)
|
.align_y(iced::Alignment::Center)
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.center_x(Length::Fill)
|
.center_x(Length::Fill)
|
||||||
|
|
@ -327,6 +335,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
})
|
})
|
||||||
.push(
|
.push(
|
||||||
widget::row::with_children(end)
|
widget::row::with_children(end)
|
||||||
|
.spacing(space_xxs)
|
||||||
.align_y(iced::Alignment::Center)
|
.align_y(iced::Alignment::Center)
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.align_x(iced::Alignment::End)
|
.align_x(iced::Alignment::End)
|
||||||
|
|
@ -418,7 +427,7 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
||||||
.take()
|
.take()
|
||||||
.map(|m| icon!("window-close-symbolic", 16, m)),
|
.map(|m| icon!("window-close-symbolic", 16, m)),
|
||||||
)
|
)
|
||||||
.spacing(8)
|
.spacing(theme::active().cosmic().space_xxs())
|
||||||
.apply(widget::container)
|
.apply(widget::container)
|
||||||
.center_y(Length::Fill)
|
.center_y(Length::Fill)
|
||||||
.into()
|
.into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue