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,
|
IconVertical,
|
||||||
Image,
|
Image,
|
||||||
Link,
|
Link,
|
||||||
|
MenuFolder,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
MenuRoot,
|
MenuRoot,
|
||||||
#[default]
|
#[default]
|
||||||
|
|
@ -125,10 +126,14 @@ pub fn appearance(
|
||||||
appearance.icon_color = Some(cosmic.background.on.into());
|
appearance.icon_color = Some(cosmic.background.on.into());
|
||||||
appearance.text_color = Some(cosmic.background.on.into());
|
appearance.text_color = Some(cosmic.background.on.into());
|
||||||
}
|
}
|
||||||
Button::MenuRoot => {
|
Button::MenuFolder => {
|
||||||
appearance.background = None;
|
// Menu folders cannot be disabled, ignore customized icon and text color
|
||||||
appearance.icon_color = None;
|
let component = &cosmic.background.component;
|
||||||
appearance.text_color = None;
|
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 => {
|
Button::MenuItem => {
|
||||||
let (background, text, icon) = color(&cosmic.background.component);
|
let (background, text, icon) = color(&cosmic.background.component);
|
||||||
|
|
@ -137,6 +142,11 @@ pub fn appearance(
|
||||||
appearance.text_color = text;
|
appearance.text_color = text;
|
||||||
corner_radii = &cosmic.corner_radii.radius_s;
|
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();
|
appearance.border_radius = (*corner_radii).into();
|
||||||
|
|
|
||||||
|
|
@ -299,7 +299,17 @@ where
|
||||||
.size(16)
|
.size(16)
|
||||||
.icon()
|
.icon()
|
||||||
.into(),
|
.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),
|
menu_items(key_binds, children),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue