mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
epi: merge App::load into App::setup, and provide Frame argument
This gives users more control over the order of load/setup. It also allows users to load textures in setup.
This commit is contained in:
@@ -95,9 +95,18 @@ pub trait App {
|
||||
fn update(&mut self, ctx: &egui::CtxRef, frame: &mut Frame<'_>);
|
||||
|
||||
/// Called once before the first frame.
|
||||
/// Allows you to do setup code and to call `ctx.set_fonts()`.
|
||||
/// Optional.
|
||||
fn setup(&mut self, _ctx: &egui::CtxRef) {}
|
||||
///
|
||||
/// Allows you to do setup code, e.g to call `[Context::set_fonts]`,
|
||||
/// `[Context::set_visuals]` etc.
|
||||
///
|
||||
/// Also allows you to restore state, if there is a storage.
|
||||
fn setup(
|
||||
&mut self,
|
||||
_ctx: &egui::CtxRef,
|
||||
_frame: &mut Frame<'_>,
|
||||
_storage: Option<&dyn Storage>,
|
||||
) {
|
||||
}
|
||||
|
||||
/// If `true` a warm-up call to [`Self::update`] will be issued where
|
||||
/// `ctx.memory().everything_is_visible()` will be set to `true`.
|
||||
@@ -107,9 +116,6 @@ pub trait App {
|
||||
false
|
||||
}
|
||||
|
||||
/// Called once on start. Allows you to restore state.
|
||||
fn load(&mut self, _storage: &dyn Storage) {}
|
||||
|
||||
/// Called on shutdown, and perhaps at regular intervals. Allows you to save state.
|
||||
///
|
||||
/// On web the states is stored to "Local Storage".
|
||||
|
||||
Reference in New Issue
Block a user