ui: Use PopoverMenu::new
for constructing PopoverMenu
s (#13178)
This PR replaces the `popover_menu` function for constructing `PopoverMenu`s with a `PopoverMenu::new` associated function. This brings `PopoverMenu` in line with our other UI components. Release Notes: - N/A
This commit is contained in:
parent
59104a08fd
commit
78e0f71a28
9 changed files with 53 additions and 50 deletions
|
@ -77,6 +77,19 @@ pub struct PopoverMenu<M: ManagedView> {
|
|||
}
|
||||
|
||||
impl<M: ManagedView> PopoverMenu<M> {
|
||||
/// Returns a new [`PopoverMenu`].
|
||||
pub fn new(id: impl Into<ElementId>) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
child_builder: None,
|
||||
menu_builder: None,
|
||||
anchor: AnchorCorner::TopLeft,
|
||||
attach: None,
|
||||
offset: None,
|
||||
trigger_handle: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn menu(mut self, f: impl Fn(&mut WindowContext) -> Option<View<M>> + 'static) -> Self {
|
||||
self.menu_builder = Some(Rc::new(f));
|
||||
self
|
||||
|
@ -165,19 +178,6 @@ fn show_menu<M: ManagedView>(
|
|||
cx.refresh();
|
||||
}
|
||||
|
||||
/// Creates a [`PopoverMenu`]
|
||||
pub fn popover_menu<M: ManagedView>(id: impl Into<ElementId>) -> PopoverMenu<M> {
|
||||
PopoverMenu {
|
||||
id: id.into(),
|
||||
child_builder: None,
|
||||
menu_builder: None,
|
||||
anchor: AnchorCorner::TopLeft,
|
||||
attach: None,
|
||||
offset: None,
|
||||
trigger_handle: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PopoverMenuElementState<M> {
|
||||
menu: Rc<RefCell<Option<View<M>>>>,
|
||||
child_bounds: Option<Bounds<Pixels>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue