fix: selected images should have a border
This commit is contained in:
parent
01d7e46fea
commit
d02a4fefff
1 changed files with 6 additions and 4 deletions
|
|
@ -39,6 +39,7 @@ pub enum Button {
|
||||||
pub fn appearance(
|
pub fn appearance(
|
||||||
theme: &crate::Theme,
|
theme: &crate::Theme,
|
||||||
focused: bool,
|
focused: bool,
|
||||||
|
selected: bool,
|
||||||
style: &Button,
|
style: &Button,
|
||||||
color: impl Fn(&Component) -> (Color, Option<Color>, Option<Color>),
|
color: impl Fn(&Component) -> (Color, Option<Color>, Option<Color>),
|
||||||
) -> Appearance {
|
) -> Appearance {
|
||||||
|
|
@ -86,7 +87,7 @@ pub fn appearance(
|
||||||
corner_radii = &cosmic.corner_radii.radius_s;
|
corner_radii = &cosmic.corner_radii.radius_s;
|
||||||
appearance.border_radius = (*corner_radii).into();
|
appearance.border_radius = (*corner_radii).into();
|
||||||
|
|
||||||
if focused {
|
if focused || selected {
|
||||||
appearance.border_width = 2.0;
|
appearance.border_width = 2.0;
|
||||||
appearance.border_color = cosmic.accent.base.into();
|
appearance.border_color = cosmic.accent.base.into();
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +154,7 @@ impl StyleSheet for crate::Theme {
|
||||||
}
|
}
|
||||||
let accent = self.cosmic().accent_color();
|
let accent = self.cosmic().accent_color();
|
||||||
|
|
||||||
appearance(self, focused, style, |component| {
|
appearance(self, focused, selected, style, |component| {
|
||||||
let text_color = if matches!(
|
let text_color = if matches!(
|
||||||
style,
|
style,
|
||||||
Button::Icon | Button::IconVertical | Button::HeaderBar
|
Button::Icon | Button::IconVertical | Button::HeaderBar
|
||||||
|
|
@ -177,7 +178,7 @@ impl StyleSheet for crate::Theme {
|
||||||
return disabled(self);
|
return disabled(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
appearance(self, false, style, |component| {
|
appearance(self, false, false, style, |component| {
|
||||||
let mut background = Color::from(component.base);
|
let mut background = Color::from(component.base);
|
||||||
background.a *= 0.5;
|
background.a *= 0.5;
|
||||||
(
|
(
|
||||||
|
|
@ -201,6 +202,7 @@ impl StyleSheet for crate::Theme {
|
||||||
appearance(
|
appearance(
|
||||||
self,
|
self,
|
||||||
focused || matches!(style, Button::Image),
|
focused || matches!(style, Button::Image),
|
||||||
|
selected,
|
||||||
style,
|
style,
|
||||||
|component| {
|
|component| {
|
||||||
let text_color = if matches!(
|
let text_color = if matches!(
|
||||||
|
|
@ -228,7 +230,7 @@ impl StyleSheet for crate::Theme {
|
||||||
}
|
}
|
||||||
let accent = self.cosmic().accent_button.pressed;
|
let accent = self.cosmic().accent_button.pressed;
|
||||||
|
|
||||||
appearance(self, focused, style, |component| {
|
appearance(self, focused, selected, style, |component| {
|
||||||
let text_color = if matches!(
|
let text_color = if matches!(
|
||||||
style,
|
style,
|
||||||
Button::Icon | Button::IconVertical | Button::HeaderBar
|
Button::Icon | Button::IconVertical | Button::HeaderBar
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue