From b721fd935c6b689b1365e21dfc864e43bf3a5895 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 12 Mar 2024 16:40:56 +0100 Subject: Use closures for `PickList::style` --- widget/src/combo_box.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'widget/src/combo_box.rs') diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index 95667882..ee24d742 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -42,7 +42,7 @@ pub struct ComboBox< on_option_hovered: Option Message>>, on_close: Option, on_input: Option Message>>, - menu_style: menu::Style, + menu_style: menu::Style<'a, Theme>, padding: Padding, size: Option, } @@ -125,7 +125,7 @@ where } /// Sets the style of the [`ComboBox`]. - pub fn style(mut self, style: impl Into>) -> Self + pub fn style(mut self, style: impl Into>) -> Self where Theme: 'a, { @@ -672,7 +672,7 @@ where self.state.sync_filtered_options(filtered_options); - let mut menu = menu::Menu::with_style( + let mut menu = menu::Menu::new( menu, &filtered_options.options, hovered_option, @@ -686,7 +686,7 @@ where (self.on_selected)(x) }, self.on_option_hovered.as_deref(), - self.menu_style, + &self.menu_style, ) .width(bounds.width) .padding(self.padding); @@ -765,27 +765,27 @@ where /// The style of a [`ComboBox`]. #[allow(missing_debug_implementations)] -pub struct Style { +pub struct Style<'a, Theme> { /// The style of the [`TextInput`] of the [`ComboBox`]. - pub text_input: text_input::Style<'static, Theme>, + pub text_input: text_input::Style<'a, Theme>, /// The style of the [`Menu`] of the [`ComboBox`]. /// /// [`Menu`]: menu::Menu - pub menu: menu::Style, + pub menu: menu::Style<'a, Theme>, } /// The default style of a [`ComboBox`]. pub trait DefaultStyle: Sized { /// Returns the default style of a [`ComboBox`]. - fn default_style() -> Style; + fn default_style() -> Style<'static, Self>; } impl DefaultStyle for Theme { - fn default_style() -> Style { + fn default_style() -> Style<'static, Self> { Style { text_input: Box::new(text_input::default), - menu: menu::Style::DEFAULT, + menu: menu::DefaultStyle::default_style(), } } } -- cgit