cacao/examples/todos_list/app.rs
Ryan McGrath c713194262
v0.3.
- Changes internal target_os flags to be feature flags; macOS is now
  appkit, and iOS/tvOS are now uikit. This enables platforms that are
  not Apple-specific platforms that use frameworks to be compiled for.

- Updates the examples to handle closing/quitting better.
2021-08-07 22:31:48 -07:00

38 lines
1 KiB
Rust

//! Implements the start of the App lifecycle. Handles creating the required menu and window
//! components and message dispatching.
use cacao::appkit::{App, AppDelegate};
use cacao::notification_center::Dispatcher;
use crate::menu::menu;
use crate::storage::{Defaults, Message};
use crate::windows::WindowManager;
/// This handles routing lifecycle events, and maintains our `WindowManager`.
#[derive(Default)]
pub struct TodosApp {
pub window_manager: WindowManager
}
impl AppDelegate for TodosApp {
/// Sets the menu, activates the app, opens the main window and requests notification
/// permissions.
fn did_finish_launching(&self) {
Defaults::register();
App::set_menu(menu());
App::activate();
self.window_manager.open_main();
}
}
impl Dispatcher for TodosApp {
type Message = Message;
/// Handles a message that came over on the main (UI) thread.
fn on_ui_message(&self, message: Self::Message) {
self.window_manager.on_ui_message(message);
}
}