workflow_egui/frame/
app.rs

1use crate::imports::*;
2
3pub struct Context<'r, T> {
4    pub runtime: Runtime,
5    pub app: &'r mut T,
6    pub ctx: &'r egui::Context,
7    pub frame: &'r mut eframe::Frame,
8    pub device: &'r mut Device,
9}
10
11pub trait App: Sized + 'static {
12    fn mobile_text_styles(&self) -> Option<BTreeMap<egui::TextStyle, egui::FontId>> {
13        None
14    }
15    fn default_text_styles(&self) -> Option<BTreeMap<egui::TextStyle, egui::FontId>> {
16        None
17    }
18
19    fn handle_event(&mut self, _ctx: &egui::Context, _event: RuntimeEvent) {}
20
21    fn handle_keyboard_events(
22        &mut self,
23        _key: egui::Key,
24        _pressed: bool,
25        _modifiers: &egui::Modifiers,
26        _repeat: bool,
27    ) {
28    }
29
30    fn device(&mut self) -> Option<&mut Device> {
31        None
32    }
33
34    fn init(&mut self, _runtime: &Runtime, _cc: &eframe::CreationContext<'_>) {}
35
36    fn render(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame);
37
38    fn save(&mut self, _storage: &mut dyn eframe::Storage) {}
39
40    fn on_exit(&mut self) {}
41
42    /// Time between automatic calls to [`Self::save`]
43    fn auto_save_interval(&self) -> std::time::Duration {
44        std::time::Duration::from_secs(30)
45    }
46
47    fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
48        egui::Color32::from_rgba_unmultiplied(12, 12, 12, 180).to_normalized_gamma_f32()
49    }
50
51    fn persist_egui_memory(&self) -> bool {
52        true
53    }
54
55    fn raw_input_hook(&mut self, _ctx: &egui::Context, _raw_input: &mut egui::RawInput) {}
56}