From 973018fdb71a2289d80e8a5fa8e092543173af9e Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 27 Sep 2024 09:34:37 -0600 Subject: [PATCH] Fix style of menu folders --- src/theme/style/button.rs | 18 ++++++++++++++---- src/widget/menu/menu_tree.rs | 12 +++++++++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/theme/style/button.rs b/src/theme/style/button.rs index 704ef8c42b8..0d9753e69b1 100644 --- a/src/theme/style/button.rs +++ b/src/theme/style/button.rs @@ -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(); diff --git a/src/widget/menu/menu_tree.rs b/src/widget/menu/menu_tree.rs index 809703744da..65ebbd9c061 100644 --- a/src/widget/menu/menu_tree.rs +++ b/src/widget/menu/menu_tree.rs @@ -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), )); }