Skip to main content

App

Trait App 

Source
pub trait App: Send + 'static {
    // Required method
    fn ui(&mut self, ui: &mut Ui, frame: &mut Frame);

    // Provided methods
    fn build(
        &mut self,
        egui_ctx: Context,
        frame: &mut Frame,
    ) -> Result<(), HandlerError> { ... }
    fn resized(&mut self, size: WindowSize) { ... }
    fn zoom_factor_changed(&mut self, zoom_factor: f32) { ... }
}
Expand description

Implement this trait to run an app with egui-baseview.

Required Methods§

Source

fn ui(&mut self, ui: &mut Ui, frame: &mut Frame)

Called each time the UI needs repainting, which may be many times per second.

Provided Methods§

Source

fn build( &mut self, egui_ctx: Context, frame: &mut Frame, ) -> Result<(), HandlerError>

Called once before the first frame. Setup code such as egui_ctx.set_fonts() can be done here.

If an error is returned, then the window will be closed.

Source

fn resized(&mut self, size: WindowSize)

Called when the window has been resized.

The given size takes the zoom factor into account.

Source

fn zoom_factor_changed(&mut self, zoom_factor: f32)

Called when the zoom factor has changed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§