diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 0364cf468b1..6c8d8f9b83f 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -111,11 +111,10 @@ pub fn menu_button( /// Returns `None` if the menu is not open. pub fn menu_image_button( ui: &mut Ui, - texture_id: TextureId, - image_size: impl Into, + image_button: ImageButton, add_contents: impl FnOnce(&mut Ui) -> R, ) -> InnerResponse> { - stationary_menu_image_impl(ui, texture_id, image_size, Box::new(add_contents)) + stationary_menu_image_impl(ui, image_button, Box::new(add_contents)) } /// Construct a nested sub menu in another menu. @@ -202,14 +201,13 @@ fn stationary_menu_impl<'c, R>( /// Responds to primary clicks. fn stationary_menu_image_impl<'c, R>( ui: &mut Ui, - texture_id: TextureId, - image_size: impl Into, + image_button: ImageButton, add_contents: Box R + 'c>, ) -> InnerResponse> { let bar_id = ui.id(); let mut bar_state = BarState::load(ui.ctx(), bar_id); - let button_response = ui.add(ImageButton::new(texture_id, image_size)); + let button_response = ui.add(image_button); let inner = bar_state.bar_menu(&button_response, add_contents); bar_state.store(ui.ctx(), bar_id); diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 9f413502528..686d7a66eb3 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -2222,7 +2222,7 @@ impl Ui { if let Some(menu_state) = self.menu_state.clone() { menu::submenu_button(self, menu_state, String::new(), add_contents) } else { - menu::menu_image_button(self, texture_id, image_size, add_contents) + menu::menu_image_button(self, ImageButton::new(texture_id, image_size), add_contents) } } }