Skip to main content

egui_baseview/
lib.rs

1mod renderer;
2mod translate;
3mod window;
4
5pub use baseview;
6use baseview::WindowSize;
7pub use keyboard_types::Key;
8pub use renderer::GraphicsConfig;
9pub use window::{EguiWindow, EguiWindowSettings, Frame, KeyCapture, RepaintNotifier};
10
11/// Implement this trait to run an app with egui-baseview.
12pub trait App: Send + 'static {
13    /// Called once before the first frame. Setup code such as `egui_ctx.set_fonts()`
14    /// can be done here.
15    ///
16    /// If an error is returned, then the window will be closed.
17    fn build(
18        &mut self,
19        egui_ctx: egui::Context,
20        frame: &mut Frame,
21    ) -> Result<(), baseview::HandlerError> {
22        let _ = egui_ctx;
23        let _ = frame;
24        Ok(())
25    }
26
27    /// Called each time the UI needs repainting, which may be many times per second.
28    fn ui(&mut self, ui: &mut egui::Ui, frame: &mut Frame);
29
30    /// Called when the window has been resized.
31    ///
32    /// The given size takes the zoom factor into account.
33    fn resized(&mut self, size: WindowSize) {
34        let _ = size;
35    }
36
37    /// Called when the zoom factor has changed.
38    fn zoom_factor_changed(&mut self, zoom_factor: f32) {
39        let _ = zoom_factor;
40    }
41}