Fix style of menu folders
This commit is contained in:
parent
cf6a35474e
commit
973018fdb7
2 changed files with 25 additions and 5 deletions
|
|
@ -27,6 +27,7 @@ pub enum Button {
|
|||
IconVertical,
|
||||
Image,
|
||||
Link,
|
||||
MenuFolder,
|
||||
MenuItem,
|
||||
MenuRoot,
|
||||
#[default]
|
||||
|
|
@ -125,10 +126,14 @@ pub fn appearance(
|
|||
appearance.icon_color = Some(cosmic.background.on.into());
|
||||
appearance.text_color = Some(cosmic.background.on.into());
|
||||
}
|
||||
Button::MenuRoot => {
|
||||
appearance.background = None;
|
||||
appearance.icon_color = None;
|
||||
appearance.text_color = None;
|
||||
Button::MenuFolder => {
|
||||
// Menu folders cannot be disabled, ignore customized icon and text color
|
||||
let component = &cosmic.background.component;
|
||||
let (background, _, _) = color(component);
|
||||
appearance.background = Some(Background::Color(background));
|
||||
appearance.icon_color = Some(component.on.into());
|
||||
appearance.text_color = Some(component.on.into());
|
||||
corner_radii = &cosmic.corner_radii.radius_s;
|
||||
}
|
||||
Button::MenuItem => {
|
||||
let (background, text, icon) = color(&cosmic.background.component);
|
||||
|
|
@ -137,6 +142,11 @@ pub fn appearance(
|
|||
appearance.text_color = text;
|
||||
corner_radii = &cosmic.corner_radii.radius_s;
|
||||
}
|
||||
Button::MenuRoot => {
|
||||
appearance.background = None;
|
||||
appearance.icon_color = None;
|
||||
appearance.text_color = None;
|
||||
}
|
||||
}
|
||||
|
||||
appearance.border_radius = (*corner_radii).into();
|
||||
|
|
|
|||
|
|
@ -299,7 +299,17 @@ where
|
|||
.size(16)
|
||||
.icon()
|
||||
.into(),
|
||||
]),
|
||||
])
|
||||
.style(
|
||||
// Menu folders have no on_press so they take on the disabled style by default
|
||||
if children.is_empty() {
|
||||
// This will make the folder use the disabled style if it has no children
|
||||
theme::Button::MenuItem
|
||||
} else {
|
||||
// This will make the folder use the enabled style if it has children
|
||||
theme::Button::MenuFolder
|
||||
},
|
||||
),
|
||||
menu_items(key_binds, children),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue