Skip to content

Commit 59235ff

Browse files
v-katIvy
and
Ivy
authored
Changing menu_image_button to use ImageButton builder (#3288)
Co-authored-by: Ivy <fake@email.com>
1 parent 5f742b9 commit 59235ff

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

crates/egui/src/menu.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ pub fn menu_button<R>(
111111
/// Returns `None` if the menu is not open.
112112
pub fn menu_image_button<R>(
113113
ui: &mut Ui,
114-
texture_id: TextureId,
115-
image_size: impl Into<Vec2>,
114+
image_button: ImageButton,
116115
add_contents: impl FnOnce(&mut Ui) -> R,
117116
) -> InnerResponse<Option<R>> {
118-
stationary_menu_image_impl(ui, texture_id, image_size, Box::new(add_contents))
117+
stationary_menu_image_impl(ui, image_button, Box::new(add_contents))
119118
}
120119

121120
/// Construct a nested sub menu in another menu.
@@ -202,14 +201,13 @@ fn stationary_menu_impl<'c, R>(
202201
/// Responds to primary clicks.
203202
fn stationary_menu_image_impl<'c, R>(
204203
ui: &mut Ui,
205-
texture_id: TextureId,
206-
image_size: impl Into<Vec2>,
204+
image_button: ImageButton,
207205
add_contents: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
208206
) -> InnerResponse<Option<R>> {
209207
let bar_id = ui.id();
210208

211209
let mut bar_state = BarState::load(ui.ctx(), bar_id);
212-
let button_response = ui.add(ImageButton::new(texture_id, image_size));
210+
let button_response = ui.add(image_button);
213211
let inner = bar_state.bar_menu(&button_response, add_contents);
214212

215213
bar_state.store(ui.ctx(), bar_id);

crates/egui/src/ui.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,7 @@ impl Ui {
22222222
if let Some(menu_state) = self.menu_state.clone() {
22232223
menu::submenu_button(self, menu_state, String::new(), add_contents)
22242224
} else {
2225-
menu::menu_image_button(self, texture_id, image_size, add_contents)
2225+
menu::menu_image_button(self, ImageButton::new(texture_id, image_size), add_contents)
22262226
}
22272227
}
22282228
}

0 commit comments

Comments
 (0)