fix(menu_bar): root text will inherit icon color from header

This commit is contained in:
Michael Aaron Murphy 2024-05-21 04:34:35 +02:00
parent aa3f5d3401
commit f9f8eb51cb
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
8 changed files with 26 additions and 24 deletions

View file

@ -14,9 +14,7 @@ use cosmic::iced_core::{Length, Size};
use cosmic::widget::menu::action::MenuAction;
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::menu::key_bind::Modifier;
use cosmic::widget::menu::menu_tree::{menu_items, menu_root, MenuItem};
use cosmic::widget::menu::{ItemHeight, ItemWidth, MenuBar, MenuTree};
use cosmic::widget::segmented_button::Entity;
use cosmic::widget::menu::{self, ItemHeight, ItemWidth};
use cosmic::{executor, Element};
/// Runs application with these settings
@ -67,7 +65,7 @@ pub enum Action {
impl MenuAction for Action {
type Message = Message;
fn message(&self, _entity_opt: Option<Entity>) -> Self::Message {
fn message(&self) -> Self::Message {
match self {
Action::WindowClose => Message::WindowClose,
Action::ToggleHideContent => Message::ToggleHideContent,
@ -156,23 +154,23 @@ impl cosmic::Application for App {
}
pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
MenuBar::new(vec![MenuTree::with_children(
menu_root("File"),
menu_items(
menu::bar(vec![menu::Tree::with_children(
menu::root("File"),
menu::items(
key_binds,
vec![
MenuItem::Button("New window", Action::WindowNew),
MenuItem::Divider,
MenuItem::Folder(
menu::Item::Button("New window", Action::WindowNew),
menu::Item::Divider,
menu::Item::Folder(
"View",
vec![MenuItem::CheckBox(
vec![menu::Item::CheckBox(
"Hide content",
config.hide_content,
Action::ToggleHideContent,
)],
),
MenuItem::Divider,
MenuItem::Button("Quit", Action::WindowClose),
menu::Item::Divider,
menu::Item::Button("Quit", Action::WindowClose),
],
),
)])

View file

@ -168,7 +168,7 @@ impl cosmic::Application for App {
Err(why) => Message::OpenError(Arc::new(why)),
}
})
.map(cosmic::app::Message::App);
.map(Into::into);
}
// Displays an error in the application's warning bar.