feat: inactive window header icon/text colors

This commit is contained in:
Michael Aaron Murphy 2024-05-17 19:42:02 +02:00 • committed by Michael Murphy
parent 1355588723
commit 9292ea647b
2 changed files with 36 additions and 18 deletions

View file

@ -373,7 +373,9 @@ pub enum Container {
Custom(Box<dyn Fn(&Theme) -> container::Appearance>), Custom(Box<dyn Fn(&Theme) -> container::Appearance>),
Dialog, Dialog,
Dropdown, Dropdown,
HeaderBar, HeaderBar {
focused: bool,
},
List, List,
Primary, Primary,
Secondary, Secondary,
@ -473,9 +475,22 @@ impl container::StyleSheet for Theme {
} }
} }
Container::HeaderBar => container::Appearance { Container::HeaderBar { focused } => {
icon_color: Some(Color::from(cosmic.accent.base)), let (icon_color, text_color) = if *focused {
text_color: Some(Color::from(cosmic.background.on)), (
Color::from(cosmic.accent.base),
Color::from(cosmic.background.on),
)
} else {
use crate::ext::ColorExt;
let unfocused_color = Color::from(cosmic.background.component.on)
.blend_alpha(cosmic.background.base.into(), 0.75);
(unfocused_color, unfocused_color)
};
container::Appearance {
icon_color: Some(icon_color),
text_color: Some(text_color),
background: Some(iced::Background::Color(cosmic.background.base.into())), background: Some(iced::Background::Color(cosmic.background.base.into())),
border: Border { border: Border {
radius: [ radius: [
@ -488,7 +503,8 @@ impl container::StyleSheet for Theme {
..Default::default() ..Default::default()
}, },
shadow: Shadow::default(), shadow: Shadow::default(),
}, }
}
Container::ContextDrawer => { Container::ContextDrawer => {
let mut appearance = crate::style::Container::primary(cosmic); let mut appearance = crate::style::Container::primary(cosmic);

View file

@ -299,7 +299,9 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
.padding(8) .padding(8)
.spacing(8) .spacing(8)
.apply(widget::container) .apply(widget::container)
.style(crate::theme::Container::HeaderBar) .style(crate::theme::Container::HeaderBar {
focused: self.focused,
})
.center_y() .center_y()
.apply(widget::mouse_area); .apply(widget::mouse_area);