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 { ... } }
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.

The name of your App.

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.

If true a warm-up call to Self::update will be issued where ctx.memory().everything_is_visible() will be set to true.

In this warm-up call, all painted shapes will be ignored.

Called on shutdown, and perhaps at regular intervals. Allows you to save state.

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)

Time between automatic calls to Self::save

The size limit of the web app canvas.

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.

Implementors