diff --git a/widget/src/combo_box.rs b/widget/src/combo_box.rs index 0e4e1c17..db7121ce 100644 --- a/widget/src/combo_box.rs +++ b/widget/src/combo_box.rs @@ -152,6 +152,7 @@ pub struct ComboBox< menu_class: ::Class<'a>, padding: Padding, size: Option, + menu_height: Length, } impl<'a, T, Message, Theme, Renderer> ComboBox<'a, T, Message, Theme, Renderer> @@ -188,6 +189,7 @@ where menu_class: ::default_menu(), padding: text_input::DEFAULT_PADDING, size: None, + menu_height: Length::Shrink, } } @@ -273,6 +275,12 @@ where } } + /// Sets the height of the menu of the [`ComboBox`]. + pub fn menu_height(mut self, menu_height: impl Into) -> Self { + self.menu_height = menu_height.into(); + self + } + /// Sets the style of the input of the [`ComboBox`]. #[must_use] pub fn input_style( @@ -908,6 +916,7 @@ where layout.position() + translation, *viewport, bounds.height, + self.menu_height, )) } } else { diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs index 7092f9ba..4f7bbe50 100644 --- a/widget/src/overlay/menu.rs +++ b/widget/src/overlay/menu.rs @@ -128,12 +128,14 @@ where position: Point, viewport: Rectangle, target_height: f32, + menu_height: Length, ) -> overlay::Element<'a, Message, Theme, Renderer> { overlay::Element::new(Box::new(Overlay::new( position, viewport, self, target_height, + menu_height, ))) } } @@ -185,6 +187,7 @@ where viewport: Rectangle, menu: Menu<'a, 'b, T, Message, Theme, Renderer>, target_height: f32, + menu_height: Length, ) -> Self where T: Clone + ToString, @@ -215,7 +218,8 @@ where text_shaping, padding, class, - }); + }) + .height(menu_height); state.tree.diff(&list as &dyn Widget<_, _, _>); diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs index 5a129f9b..ba39143f 100644 --- a/widget/src/pick_list.rs +++ b/widget/src/pick_list.rs @@ -173,6 +173,7 @@ pub struct PickList< class: ::Class<'a>, menu_class: ::Class<'a>, last_status: Option, + menu_height: Length, } impl<'a, T, L, V, Message, Theme, Renderer> @@ -209,6 +210,7 @@ where class: ::default(), menu_class: ::default_menu(), last_status: None, + menu_height: Length::Shrink, } } @@ -224,6 +226,12 @@ where self } + /// Sets the height of the [`Menu`]. + pub fn menu_height(mut self, menu_height: impl Into) -> Self { + self.menu_height = menu_height.into(); + self + } + /// Sets the [`Padding`] of the [`PickList`]. pub fn padding>(mut self, padding: P) -> Self { self.padding = padding.into(); @@ -725,6 +733,7 @@ where layout.position() + translation, *viewport, bounds.height, + self.menu_height, )) } else { None