From d80720f772d48be610a990fc8ce6b01e0f7ee255 Mon Sep 17 00:00:00 2001 From: gered Date: Tue, 30 May 2023 18:50:20 -0400 Subject: [PATCH] update image ui widget to return a bool with its clicked state --- ggdt_imgui/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ggdt_imgui/src/lib.rs b/ggdt_imgui/src/lib.rs index 16d4f9a..72fac32 100644 --- a/ggdt_imgui/src/lib.rs +++ b/ggdt_imgui/src/lib.rs @@ -72,7 +72,7 @@ pub trait UiSupport { fn display_height(&self) -> f32; fn is_any_hovered(&self) -> bool; fn is_any_focused(&self) -> bool; - fn image(&self, id: impl AsRef, texture_id: imgui::TextureId, size: [f32; 2]); + fn image(&self, id: impl AsRef, texture_id: imgui::TextureId, size: [f32; 2]) -> bool; } impl UiSupport for imgui::Ui { @@ -92,9 +92,10 @@ impl UiSupport for imgui::Ui { self.is_window_focused_with_flags(imgui::WindowFocusedFlags::ANY_WINDOW) } - fn image(&self, id: impl AsRef, texture_id: imgui::TextureId, size: [f32; 2]) { - self.invisible_button(id, size); + fn image(&self, id: impl AsRef, texture_id: imgui::TextureId, size: [f32; 2]) -> bool { + let clicked = self.invisible_button(id, size); let draw_list = self.get_window_draw_list(); draw_list.add_image(texture_id, self.item_rect_min(), self.item_rect_max()).build(); + clicked } }