Use Style struct pattern instead of trait for all widgets

This commit is contained in:
Héctor Ramón Jiménez 2024-03-06 20:30:58 +01:00
parent 8a63774b24
commit 34e7c6593a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
25 changed files with 466 additions and 282 deletions

View file

@ -46,7 +46,7 @@ impl<'a, T, Message, Theme, Renderer> Menu<'a, T, Message, Theme, Renderer>
where
T: ToString + Clone,
Message: 'a,
Theme: container::Style + scrollable::Style + 'a,
Theme: 'a,
Renderer: text::Renderer + 'a,
{
/// Creates a new [`Menu`] with the given [`State`], a list of options, and
@ -197,7 +197,7 @@ where
impl<'a, Message, Theme, Renderer> Overlay<'a, Message, Theme, Renderer>
where
Message: 'a,
Theme: container::Style + scrollable::Style + 'a,
Theme: 'a,
Renderer: text::Renderer + 'a,
{
pub fn new<T>(
@ -223,20 +223,24 @@ where
style,
} = menu;
let container = Container::new(
Scrollable::new(List {
options,
hovered_option,
on_selected,
on_option_hovered,
font,
text_size,
text_line_height,
text_shaping,
padding,
style: style.menu,
})
.style(style.scrollable),
let container = Container::with_style(
Scrollable::with_direction_and_style(
List {
options,
hovered_option,
on_selected,
on_option_hovered,
font,
text_size,
text_line_height,
text_shaping,
padding,
style: style.menu,
},
scrollable::Direction::default(),
style.scrollable,
),
container::transparent,
);
state.tree.diff(&container as &dyn Widget<_, _, _>);