pub use egui;
#[cfg(feature = "glow-backend")]
pub use egui_glow;
pub use sdl2;
#[cfg(feature = "canvas-backend")]
pub mod canvas;
#[cfg(feature = "glow-backend")]
pub mod glow;
pub mod state;
#[cfg(feature = "wgpu-backend")]
pub mod wgpu;
#[cfg(feature = "canvas-backend")]
pub use canvas::EguiCanvas;
#[cfg(feature = "glow-backend")]
pub use glow::*;
pub use state::*;
#[cfg(feature = "wgpu-backend")]
pub use wgpu::EguiWgpu;
pub struct EguiRunOutput {
pub shapes: Vec<egui::epaint::ClippedShape>,
pub pixels_per_point: f32,
pub textures_delta: egui::TexturesDelta,
}
impl Default for EguiRunOutput {
fn default() -> Self {
Self {
shapes: Default::default(),
pixels_per_point: 1.0,
textures_delta: Default::default(),
}
}
}
impl EguiRunOutput {
#[inline]
pub fn update(
&mut self,
ctx: &egui::Context,
state: &mut State,
run_ui: impl FnMut(&egui::Context),
) {
let raw_input = state.take_egui_input();
let egui::FullOutput {
platform_output,
viewport_output: _,
textures_delta,
shapes,
pixels_per_point,
} = ctx.run(raw_input, run_ui);
state.handle_platform_output(platform_output);
self.shapes = shapes;
self.textures_delta.append(textures_delta);
self.pixels_per_point = pixels_per_point;
}
#[inline]
pub fn take(&mut self) -> (egui::TexturesDelta, Vec<egui::epaint::ClippedShape>) {
let textures_delta = std::mem::take(&mut self.textures_delta);
let shapes = std::mem::take(&mut self.shapes);
(textures_delta, shapes)
}
}