Trait epi::App [−][src]
pub trait App {
fn update(&mut self, ctx: &CtxRef, frame: &mut Frame<'_>);
fn name(&self) -> &str;
fn setup(
&mut self,
_ctx: &CtxRef,
_frame: &mut Frame<'_>,
_storage: Option<&dyn Storage>
) { ... }
fn warm_up_enabled(&self) -> bool { ... }
fn save(&mut self, _storage: &mut dyn Storage) { ... }
fn on_exit(&mut self) { ... }
fn auto_save_interval(&self) -> Duration { ... }
fn max_size_points(&self) -> Vec2 { ... }
fn clear_color(&self) -> Rgba { ... }
fn persist_native_window(&self) -> bool { ... }
fn persist_egui_memory(&self) -> bool { ... }
}
Expand description
Implement this trait to write apps that can be compiled both natively using the egui_glium
crate,
and deployed as a web site using the egui_web
crate.
Required methods
Called each time the UI needs repainting, which may be many times per second.
Put your widgets into a egui::SidePanel
, egui::TopBottomPanel
, egui::CentralPanel
, egui::Window
or egui::Area
.
To force a repaint, call either egui::Context::request_repaint
or use Frame::repaint_signal
.
The name of your App, used for the title bar of native windows
and the save location of persistence (see Self::save
).
Provided methods
Called once before the first frame.
Allows you to do setup code, e.g to call egui::Context::set_fonts
,
egui::Context::set_visuals
etc.
Also allows you to restore state, if there is a storage (required the “persistence” feature).
fn warm_up_enabled(&self) -> bool
fn warm_up_enabled(&self) -> bool
If true
a warm-up call to Self::update
will be issued where
ctx.memory().everything_is_visible()
will be set to true
.
This will help pre-caching all text, preventing stutter when opening a window containing new glyphs.
In this warm-up call, all painted shapes will be ignored.
Called on shutdown, and perhaps at regular intervals. Allows you to save state.
Only called when the “persistence” feature is enabled.
On web the states is stored to “Local Storage”.
On native the path is picked using directories_next::ProjectDirs::data_dir
which is:
- Linux:
/home/UserName/.local/share/APPNAME
- macOS:
/Users/UserName/Library/Application Support/APPNAME
- Windows:
C:\Users\UserName\AppData\Roaming\APPNAME
where APPNAME
is what is returned by Self::name()
.
Called once on shutdown (before or after Self::save
)
fn auto_save_interval(&self) -> Duration
fn auto_save_interval(&self) -> Duration
Time between automatic calls to Self::save
fn max_size_points(&self) -> Vec2
fn max_size_points(&self) -> Vec2
The size limit of the web app canvas.
fn clear_color(&self) -> Rgba
fn clear_color(&self) -> Rgba
Background color for the app, e.g. what is sent to gl.clearColor
.
This is the background of your windows if you don’t set a central panel.
fn persist_native_window(&self) -> bool
fn persist_native_window(&self) -> bool
Controls wether or not the native window position and size will be persisted (only if the “persistence” feature is enabled).
fn persist_egui_memory(&self) -> bool
fn persist_egui_memory(&self) -> bool
Controls wether or not the egui memory (window positions etc) will be persisted (only if the “persistence” feature is enabled).