Add focus style for grid item
This commit is contained in:
parent
f0956f494a
commit
8bbd2e7f95
1 changed files with 11 additions and 6 deletions
17
src/tab.rs
17
src/tab.rs
|
|
@ -80,6 +80,7 @@ static SPECIAL_DIRS: Lazy<HashMap<PathBuf, &'static str>> = Lazy::new(|| {
|
||||||
fn button_appearance(
|
fn button_appearance(
|
||||||
theme: &theme::Theme,
|
theme: &theme::Theme,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
|
focused: bool,
|
||||||
accent: bool,
|
accent: bool,
|
||||||
) -> widget::button::Appearance {
|
) -> widget::button::Appearance {
|
||||||
let cosmic = theme.cosmic();
|
let cosmic = theme.cosmic();
|
||||||
|
|
@ -93,6 +94,12 @@ fn button_appearance(
|
||||||
appearance.background = Some(Color::from(cosmic.bg_component_color()).into());
|
appearance.background = Some(Color::from(cosmic.bg_component_color()).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if focused && accent {
|
||||||
|
appearance.outline_width = 1.0;
|
||||||
|
appearance.outline_color = Color::from(cosmic.accent_color());
|
||||||
|
appearance.border_width = 2.0;
|
||||||
|
appearance.border_color = Color::TRANSPARENT;
|
||||||
|
}
|
||||||
appearance.border_radius = cosmic.radius_s().into();
|
appearance.border_radius = cosmic.radius_s().into();
|
||||||
appearance
|
appearance
|
||||||
}
|
}
|
||||||
|
|
@ -100,15 +107,13 @@ fn button_appearance(
|
||||||
fn button_style(selected: bool, accent: bool) -> theme::Button {
|
fn button_style(selected: bool, accent: bool) -> theme::Button {
|
||||||
//TODO: move to libcosmic?
|
//TODO: move to libcosmic?
|
||||||
theme::Button::Custom {
|
theme::Button::Custom {
|
||||||
active: Box::new(move |focused, theme| {
|
active: Box::new(move |focused, theme| button_appearance(theme, selected, focused, accent)),
|
||||||
button_appearance(theme, selected || focused, accent)
|
disabled: Box::new(move |theme| button_appearance(theme, selected, false, accent)),
|
||||||
}),
|
|
||||||
disabled: Box::new(move |theme| button_appearance(theme, selected, accent)),
|
|
||||||
hovered: Box::new(move |focused, theme| {
|
hovered: Box::new(move |focused, theme| {
|
||||||
button_appearance(theme, selected || focused, accent)
|
button_appearance(theme, selected, focused, accent)
|
||||||
}),
|
}),
|
||||||
pressed: Box::new(move |focused, theme| {
|
pressed: Box::new(move |focused, theme| {
|
||||||
button_appearance(theme, selected || focused, accent)
|
button_appearance(theme, selected, focused, accent)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue