diff options
| author | pml68 <contact@pml68.dev> | 2025-04-08 19:40:45 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.dev> | 2025-04-15 23:49:01 +0200 |
| commit | 53dc5464c2f595d1a32174598e280428d3265f15 (patch) | |
| tree | eacb4abf0bbad81abd78e9b2617255c147ea345c /material_theme/src/menu.rs | |
| parent | feat(material_theme): impl `scrollable::Catalog` (diff) | |
| download | iced-builder-53dc5464c2f595d1a32174598e280428d3265f15.tar.gz | |
feat(material_theme): impl `menu::Catalog`, change `dialog::Catalog` impl
Diffstat (limited to '')
| -rw-r--r-- | material_theme/src/menu.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/material_theme/src/menu.rs b/material_theme/src/menu.rs new file mode 100644 index 0000000..d1bebec --- /dev/null +++ b/material_theme/src/menu.rs @@ -0,0 +1,29 @@ +use iced_widget::core::{Background, border}; +use iced_widget::overlay::menu::{Catalog, Style, StyleFn}; + +use super::Theme; + +impl Catalog for Theme { + type Class<'a> = StyleFn<'a, Self>; + + fn default<'a>() -> <Self as Catalog>::Class<'a> { + Box::new(default) + } + + fn style(&self, class: &<Self as Catalog>::Class<'_>) -> Style { + class(self) + } +} + +pub fn default(theme: &Theme) -> Style { + let surface = theme.colorscheme.surface; + let secondary = theme.colorscheme.secondary; + + Style { + border: border::rounded(4), + background: Background::Color(surface.surface_container.base), + text_color: surface.on_surface, + selected_background: Background::Color(secondary.secondary_container), + selected_text_color: secondary.on_secondary_container, + } +} |
