From 1f5d92d5d734dc0f9c0e6afa7a09bcadccf278b2 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Sun, 13 Mar 2022 11:28:56 +0200 Subject: [PATCH] Add a funtion to get image id (#80) * Add a funtion to get image id * Add missing dot Co-authored-by: Vladyslav Batyrenko Co-authored-by: Vladyslav Batyrenko --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3f810cff5..99256526b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -346,6 +346,14 @@ impl EguiContext { log::debug!("Remove image (id: {:?}, handle: {:?})", id, image); id } + + /// Returns associated Egui texture id. + #[must_use] + pub fn image_id(&self, image: &Handle) -> Option { + self.user_textures + .get(&image.id) + .map(|&id| egui::TextureId::User(id)) + } } #[doc(hidden)]