maycoon_core/app/mod.rs
1use crate::app::context::AppContext;
2use crate::app::runner::MayRunner;
3use crate::config::MayConfig;
4use crate::plugin::PluginManager;
5use crate::widget::Widget;
6use maycoon_theme::theme::Theme;
7
8/// Contains diagnostics data for the application.
9pub mod diagnostics;
10
11/// Contains the font context structure.
12pub mod font_ctx;
13
14/// Contains the application handler.
15pub mod handler;
16
17/// Contains the application information structure.
18pub mod info;
19
20/// Contains the update mode bitflag.
21pub mod update;
22
23/// Contains the [AppContext] structure for access to the application lifecycle.
24pub mod context;
25
26/// Contains the [MayRunner] structure to create and run an application using `winit`.
27pub mod runner;
28
29/// The main application interface.
30///
31/// Contains basic functions for the [MayRunner] to create and run an application.
32pub trait Application: Sized {
33 /// The theme of the application and its widgets.
34 ///
35 /// See [maycoon_theme::theme] for built-in themes.
36 type Theme: Theme;
37
38 /// Renders/builds the application's widgets.
39 ///
40 /// This function will be passed to the [MayRunner] to create and run the application.
41 fn build(context: AppContext) -> impl Widget;
42
43 /// Returns the [MayConfig] for the application.
44 fn config(&self) -> MayConfig<Self::Theme>;
45
46 /// Builds and returns the [PluginManager] for the application.
47 fn plugins(&self) -> PluginManager<Self::Theme> {
48 PluginManager::new()
49 }
50
51 /// Runs the application using the [MayRunner].
52 ///
53 /// Override this method if you want to use a custom event loop.
54 fn run(self) {
55 MayRunner::<Self::Theme>::new(self.config()).run(Self::build, self.plugins());
56 }
57}