convenience method for creating a basic image widget
This commit is contained in:
parent
3bb12fdcee
commit
ec6d0f1b73
|
@ -43,9 +43,7 @@ impl AppState<GameContext> for DemoState {
|
|||
|
||||
if let Some(slime_type_texture_id) = context.core.slime_texture_id_map.get(&slime_type.0) {
|
||||
ui.same_line();
|
||||
ui.invisible_button("Slime Type", [16.0, 16.0]);
|
||||
let draw_list = ui.get_window_draw_list();
|
||||
draw_list.add_image(*slime_type_texture_id, ui.item_rect_min(), ui.item_rect_max()).build();
|
||||
ui.image("Slime Type", *slime_type_texture_id, [16.0, 16.0]);
|
||||
}
|
||||
|
||||
ui.same_line();
|
||||
|
|
|
@ -70,6 +70,7 @@ impl SystemEventHandler for ImGui {
|
|||
pub trait UiSupport {
|
||||
fn is_any_hovered(&self) -> bool;
|
||||
fn is_any_focused(&self) -> bool;
|
||||
fn image(&self, id: impl AsRef<str>, texture_id: imgui::TextureId, size: [f32; 2]);
|
||||
}
|
||||
|
||||
impl UiSupport for imgui::Ui {
|
||||
|
@ -80,4 +81,10 @@ impl UiSupport for imgui::Ui {
|
|||
fn is_any_focused(&self) -> bool {
|
||||
self.is_window_focused_with_flags(imgui::WindowFocusedFlags::ANY_WINDOW)
|
||||
}
|
||||
|
||||
fn image(&self, id: impl AsRef<str>, texture_id: imgui::TextureId, size: [f32; 2]) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue