egui/egui_demo_lib/src/apps/demo/app.rs

28 lines
805 B
Rust
Raw Normal View History

/// Demonstrates how to make an app using Egui.
///
2020-12-29 13:15:46 +00:00
/// Implements `epi::App` so it can be used with
/// [`egui_glium`](https://crates.io/crates/egui_glium) and [`egui_web`](https://crates.io/crates/egui_web).
2021-01-01 16:11:05 +00:00
#[derive(Default, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct DemoApp {
2021-01-01 16:11:05 +00:00
demo_windows: super::DemoWindows,
2020-07-23 16:54:16 +00:00
}
2020-12-29 13:15:46 +00:00
impl epi::App for DemoApp {
fn name(&self) -> &str {
2021-01-01 23:13:34 +00:00
"✨ Egui Demo"
}
2020-12-29 13:15:46 +00:00
fn load(&mut self, storage: &dyn epi::Storage) {
*self = epi::get_value(storage, epi::APP_KEY).unwrap_or_default()
}
2020-12-29 13:15:46 +00:00
fn save(&mut self, storage: &mut dyn epi::Storage) {
epi::set_value(storage, epi::APP_KEY, self);
}
fn update(&mut self, ctx: &egui::CtxRef, _frame: &mut epi::Frame<'_>) {
self.demo_windows.ui(ctx);
2020-07-23 16:54:16 +00:00
}
2020-05-10 17:04:10 +00:00
}