Improve context menu styling

This commit is contained in:
Jeremy Soller 2023-11-20 11:34:59 -07:00
parent 858bad0f50
commit 7782a421a3
No known key found for this signature in database
GPG key ID: DCFCA852D3906975

View file

@ -1,11 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::{
cosmic_theme,
//TODO: export in cosmic::widget
iced::{
widget::{column, horizontal_rule},
Alignment, Length,
Alignment, Background, Length,
},
theme,
widget::{
@ -50,7 +49,7 @@ pub fn context_menu<'a>(config: &Config, entity: segmented_button::Entity) -> El
.on_press(Message::TabContextAction(entity, action))
};
widget::cosmic_container::container(column!(
widget::container(column!(
menu_item(fl!("undo"), Action::Undo),
menu_item(fl!("redo"), Action::Redo),
horizontal_rule(1),
@ -59,8 +58,20 @@ pub fn context_menu<'a>(config: &Config, entity: segmented_button::Entity) -> El
menu_item(fl!("paste"), Action::Paste),
menu_item(fl!("select-all"), Action::SelectAll),
))
.layer(cosmic_theme::Layer::Background)
.style(theme::Container::Card)
.padding(1)
//TODO: move style to libcosmic
.style(theme::Container::custom(|theme| {
let cosmic = theme.cosmic();
let component = &cosmic.background.component;
widget::container::Appearance {
icon_color: Some(component.on.into()),
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border_radius: 8.0.into(),
border_width: 1.0,
border_color: component.divider.into(),
}
}))
.width(Length::Fixed(240.0))
.into()
}