Trait rerun::external::eframe::App

pub trait App {
    // Required method
    fn update(&mut self, ctx: &Context, frame: &mut Frame);

    // Provided methods
    fn save(&mut self, _storage: &mut dyn Storage) { ... }
    fn on_exit(&mut self) { ... }
    fn auto_save_interval(&self) -> Duration { ... }
    fn clear_color(&self, _visuals: &Visuals) -> [f32; 4] { ... }
    fn persist_egui_memory(&self) -> bool { ... }
    fn raw_input_hook(&mut self, _ctx: &Context, _raw_input: &mut RawInput) { ... }
}
Expand description

Implement this trait to write apps that can be compiled for both web/wasm and desktop/native using eframe.

Required Methods§

fn update(&mut self, ctx: &Context, frame: &mut Frame)

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 egui::Context can be cloned and saved if you like.

To force a repaint, call egui::Context::request_repaint at any time (e.g. from another thread).

This is called for the root viewport (egui::ViewportId::ROOT). Use egui::Context::show_viewport_deferred to spawn additional viewports (windows). (A “viewport” in egui means an native OS window).

Provided Methods§

fn save(&mut self, _storage: &mut dyn Storage)

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

Only called when the “persistence” feature is enabled.

On web the state is stored to “Local Storage”.

On native the path is picked using crate::storage_dir. The path can be customized via NativeOptions::persistence_path.

fn on_exit(&mut self)

Called once on shutdown, after Self::save.

If you need to abort an exit use [Self::on_close_event].

fn auto_save_interval(&self) -> Duration

Time between automatic calls to Self::save

fn clear_color(&self, _visuals: &Visuals) -> [f32; 4]

Background color values 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.

ATTENTION: Since these float values go to the render as-is, any color space conversion as done e.g. by converting from egui::Color32 to egui::Rgba may cause incorrect results. egui recommends that rendering backends use a normal “gamma-space” (non-sRGB-aware) blending, which means the values you return here should also be in sRGB gamma-space in the 0-1 range. You can use egui::Color32::to_normalized_gamma_f32 for this.

fn persist_egui_memory(&self) -> bool

Controls whether or not the egui memory (window positions etc) will be persisted (only if the “persistence” feature is enabled).

fn raw_input_hook(&mut self, _ctx: &Context, _raw_input: &mut RawInput)

A hook for manipulating or filtering raw input before it is processed by Self::update.

This function provides a way to modify or filter input events before they are processed by egui.

It can be used to prevent specific keyboard shortcuts or mouse events from being processed by egui.

Additionally, it can be used to inject custom keyboard or mouse events into the input stream, which can be useful for implementing features like a virtual keyboard.

§Arguments
  • _ctx - The context of the egui, which provides access to the current state of the egui.
  • _raw_input - The raw input events that are about to be processed. This can be modified to change the input that egui processes.
§Note

This function does not return a value. Any changes to the input should be made directly to _raw_input.

Implementations on Foreign Types§

source§

impl App for App

source§

fn clear_color(&self, _visuals: &Visuals) -> [f32; 4]

source§

fn save(&mut self, storage: &mut dyn Storage)

source§

fn update(&mut self, egui_ctx: &Context, frame: &mut Frame)

Implementors§