pub use imgui_presentable_derive::*;
mod basic_types;
#[cfg(feature = "glam")]
mod glam_types;
mod std_types;
#[cfg(feature = "imgui_backend")]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Extent {
pub width: u16,
pub height: u16,
}
#[cfg(feature = "imgui_backend")]
pub trait ImguiPresentable {
fn render_window(&self, ui: &imgui::Ui, extent: Extent) {
ui.window(std::any::type_name::<Self>())
.resizable(true)
.collapsible(true)
.bg_alpha(0.7f32)
.position([0.0, 0.0], imgui::Condition::FirstUseEver)
.menu_bar(true)
.build(|| self.render_component(ui, extent));
}
fn render_component(&self, ui: &imgui::Ui, extent: Extent);
fn render_window_mut(&mut self, ui: &imgui::Ui, extent: Extent) {
ui.window(std::any::type_name::<Self>())
.resizable(true)
.collapsible(true)
.bg_alpha(0.7f32)
.position([0.0, 0.0], imgui::Condition::FirstUseEver)
.menu_bar(true)
.build(|| self.render_component_mut(ui, extent));
}
fn render_component_mut(&mut self, ui: &imgui::Ui, extent: Extent) {
self.render_component(ui, extent);
}
}
#[cfg(feature = "egui_backend")]
pub trait EguiPresentable {
fn render_window(&self, context: &egui::Context) {
egui::Window::new(std::any::type_name::<Self>())
.show(context, |ui| self.render_component(ui));
}
fn render_component(&self, ui: &mut egui::Ui);
fn render_window_mut(&mut self, context: &egui::Context) {
egui::Window::new(std::any::type_name::<Self>())
.show(context, |ui| self.render_component_mut(ui));
}
fn render_component_mut(&mut self, ui: &mut egui::Ui) {
self.render_component(ui);
}
}