Add menu_height method to pick_list and combo_box
This commit is contained in:
parent
9ef65db8c9
commit
71a4dff703
3 changed files with 23 additions and 1 deletions
|
|
@ -152,6 +152,7 @@ pub struct ComboBox<
|
||||||
menu_class: <Theme as menu::Catalog>::Class<'a>,
|
menu_class: <Theme as menu::Catalog>::Class<'a>,
|
||||||
padding: Padding,
|
padding: Padding,
|
||||||
size: Option<f32>,
|
size: Option<f32>,
|
||||||
|
menu_height: Length,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, Message, Theme, Renderer> ComboBox<'a, T, Message, Theme, Renderer>
|
impl<'a, T, Message, Theme, Renderer> ComboBox<'a, T, Message, Theme, Renderer>
|
||||||
|
|
@ -188,6 +189,7 @@ where
|
||||||
menu_class: <Theme as Catalog>::default_menu(),
|
menu_class: <Theme as Catalog>::default_menu(),
|
||||||
padding: text_input::DEFAULT_PADDING,
|
padding: text_input::DEFAULT_PADDING,
|
||||||
size: None,
|
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<Length>) -> Self {
|
||||||
|
self.menu_height = menu_height.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the style of the input of the [`ComboBox`].
|
/// Sets the style of the input of the [`ComboBox`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn input_style(
|
pub fn input_style(
|
||||||
|
|
@ -908,6 +916,7 @@ where
|
||||||
layout.position() + translation,
|
layout.position() + translation,
|
||||||
*viewport,
|
*viewport,
|
||||||
bounds.height,
|
bounds.height,
|
||||||
|
self.menu_height,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -128,12 +128,14 @@ where
|
||||||
position: Point,
|
position: Point,
|
||||||
viewport: Rectangle,
|
viewport: Rectangle,
|
||||||
target_height: f32,
|
target_height: f32,
|
||||||
|
menu_height: Length,
|
||||||
) -> overlay::Element<'a, Message, Theme, Renderer> {
|
) -> overlay::Element<'a, Message, Theme, Renderer> {
|
||||||
overlay::Element::new(Box::new(Overlay::new(
|
overlay::Element::new(Box::new(Overlay::new(
|
||||||
position,
|
position,
|
||||||
viewport,
|
viewport,
|
||||||
self,
|
self,
|
||||||
target_height,
|
target_height,
|
||||||
|
menu_height,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -185,6 +187,7 @@ where
|
||||||
viewport: Rectangle,
|
viewport: Rectangle,
|
||||||
menu: Menu<'a, 'b, T, Message, Theme, Renderer>,
|
menu: Menu<'a, 'b, T, Message, Theme, Renderer>,
|
||||||
target_height: f32,
|
target_height: f32,
|
||||||
|
menu_height: Length,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
T: Clone + ToString,
|
T: Clone + ToString,
|
||||||
|
|
@ -215,7 +218,8 @@ where
|
||||||
text_shaping,
|
text_shaping,
|
||||||
padding,
|
padding,
|
||||||
class,
|
class,
|
||||||
});
|
})
|
||||||
|
.height(menu_height);
|
||||||
|
|
||||||
state.tree.diff(&list as &dyn Widget<_, _, _>);
|
state.tree.diff(&list as &dyn Widget<_, _, _>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,7 @@ pub struct PickList<
|
||||||
class: <Theme as Catalog>::Class<'a>,
|
class: <Theme as Catalog>::Class<'a>,
|
||||||
menu_class: <Theme as menu::Catalog>::Class<'a>,
|
menu_class: <Theme as menu::Catalog>::Class<'a>,
|
||||||
last_status: Option<Status>,
|
last_status: Option<Status>,
|
||||||
|
menu_height: Length,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, L, V, Message, Theme, Renderer>
|
impl<'a, T, L, V, Message, Theme, Renderer>
|
||||||
|
|
@ -209,6 +210,7 @@ where
|
||||||
class: <Theme as Catalog>::default(),
|
class: <Theme as Catalog>::default(),
|
||||||
menu_class: <Theme as Catalog>::default_menu(),
|
menu_class: <Theme as Catalog>::default_menu(),
|
||||||
last_status: None,
|
last_status: None,
|
||||||
|
menu_height: Length::Shrink,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,6 +226,12 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the height of the [`Menu`].
|
||||||
|
pub fn menu_height(mut self, menu_height: impl Into<Length>) -> Self {
|
||||||
|
self.menu_height = menu_height.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the [`Padding`] of the [`PickList`].
|
/// Sets the [`Padding`] of the [`PickList`].
|
||||||
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
|
pub fn padding<P: Into<Padding>>(mut self, padding: P) -> Self {
|
||||||
self.padding = padding.into();
|
self.padding = padding.into();
|
||||||
|
|
@ -725,6 +733,7 @@ where
|
||||||
layout.position() + translation,
|
layout.position() + translation,
|
||||||
*viewport,
|
*viewport,
|
||||||
bounds.height,
|
bounds.height,
|
||||||
|
self.menu_height,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue