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>,
|
||||
padding: Padding,
|
||||
size: Option<f32>,
|
||||
menu_height: Length,
|
||||
}
|
||||
|
||||
impl<'a, T, Message, Theme, Renderer> ComboBox<'a, T, Message, Theme, Renderer>
|
||||
|
|
@ -188,6 +189,7 @@ where
|
|||
menu_class: <Theme as Catalog>::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<Length>) -> 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 {
|
||||
|
|
|
|||
|
|
@ -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<_, _, _>);
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ pub struct PickList<
|
|||
class: <Theme as Catalog>::Class<'a>,
|
||||
menu_class: <Theme as menu::Catalog>::Class<'a>,
|
||||
last_status: Option<Status>,
|
||||
menu_height: Length,
|
||||
}
|
||||
|
||||
impl<'a, T, L, V, Message, Theme, Renderer>
|
||||
|
|
@ -209,6 +210,7 @@ where
|
|||
class: <Theme as Catalog>::default(),
|
||||
menu_class: <Theme as Catalog>::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<Length>) -> Self {
|
||||
self.menu_height = menu_height.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the [`Padding`] of the [`PickList`].
|
||||
pub fn padding<P: Into<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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue