summaryrefslogtreecommitdiffstats
path: root/widget/src/combo_box.rs
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src/combo_box.rs')
-rw-r--r--widget/src/combo_box.rs30
1 files changed, 18 insertions, 12 deletions
diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs
index 62c19137..44830d8a 100644
--- a/widget/src/combo_box.rs
+++ b/widget/src/combo_box.rs
@@ -62,9 +62,9 @@ where
on_selected: impl Fn(T) -> Message + 'static,
) -> Self
where
- Style<Theme>: Default,
+ Theme: DefaultStyle,
{
- let style = Style::<Theme>::default();
+ let style = Theme::default_style();
let text_input = TextInput::with_style(
placeholder,
@@ -762,7 +762,7 @@ where
.collect()
}
-/// The appearance of a [`ComboBox`].
+/// The style of a [`ComboBox`].
#[derive(Debug, PartialEq, Eq)]
pub struct Style<Theme> {
/// The style of the [`TextInput`] of the [`ComboBox`].
@@ -772,6 +772,14 @@ pub struct Style<Theme> {
menu: menu::Style<Theme>,
}
+impl Style<Theme> {
+ /// The default style of a [`ComboBox`].
+ pub const DEFAULT: Self = Self {
+ text_input: text_input::default,
+ menu: menu::Style::<Theme>::DEFAULT,
+ };
+}
+
impl<Theme> Clone for Style<Theme> {
fn clone(&self) -> Self {
*self
@@ -780,16 +788,14 @@ impl<Theme> Clone for Style<Theme> {
impl<Theme> Copy for Style<Theme> {}
-impl Default for Style<Theme> {
- fn default() -> Self {
- default()
- }
+/// The default style of a [`ComboBox`].
+pub trait DefaultStyle: Sized {
+ /// Returns the default style of a [`ComboBox`].
+ fn default_style() -> Style<Self>;
}
-/// The default style of a [`ComboBox`].
-pub fn default() -> Style<Theme> {
- Style {
- text_input: text_input::default,
- menu: menu::Style::default(),
+impl DefaultStyle for Theme {
+ fn default_style() -> Style<Self> {
+ Style::<Self>::DEFAULT
}
}