2021-02-08 18:37:25 +11:00
|
|
|
//! The main Todos window.
|
|
|
|
|
2021-08-08 15:31:48 +10:00
|
|
|
use cacao::appkit::toolbar::Toolbar;
|
2022-07-16 00:14:02 +10:00
|
|
|
use cacao::appkit::window::{Window, WindowDelegate};
|
2021-02-08 18:37:25 +11:00
|
|
|
use cacao::view::ViewController;
|
|
|
|
|
|
|
|
use crate::storage::Message;
|
|
|
|
|
|
|
|
mod toolbar;
|
|
|
|
use toolbar::TodosToolbar;
|
|
|
|
|
|
|
|
mod content_view;
|
|
|
|
use content_view::TodosContentView;
|
|
|
|
|
|
|
|
mod list;
|
|
|
|
|
|
|
|
pub struct TodosWindow {
|
|
|
|
pub content: ViewController<TodosContentView>,
|
2022-08-19 07:45:19 +10:00
|
|
|
pub toolbar: Toolbar<TodosToolbar>
|
2021-02-08 18:37:25 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TodosWindow {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
TodosWindow {
|
|
|
|
content: ViewController::new(TodosContentView::default()),
|
2022-08-19 07:45:19 +10:00
|
|
|
toolbar: Toolbar::new("TodosToolbar", TodosToolbar::default())
|
2021-02-08 18:37:25 +11:00
|
|
|
}
|
|
|
|
}
|
2022-07-11 01:15:29 +10:00
|
|
|
|
2021-02-08 18:37:25 +11:00
|
|
|
pub fn on_message(&self, message: Message) {
|
|
|
|
if let Some(delegate) = &self.content.view.delegate {
|
|
|
|
delegate.on_message(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WindowDelegate for TodosWindow {
|
|
|
|
const NAME: &'static str = "TodosWindow";
|
2022-07-11 01:15:29 +10:00
|
|
|
|
|
|
|
fn did_load(&mut self, window: Window) {
|
2021-02-08 18:37:25 +11:00
|
|
|
window.set_autosave_name("TodosWindow");
|
|
|
|
window.set_minimum_content_size(400, 400);
|
|
|
|
window.set_movable_by_background(true);
|
|
|
|
window.set_title("Tasks");
|
|
|
|
|
|
|
|
window.set_toolbar(&self.toolbar);
|
|
|
|
window.set_content_view_controller(&self.content);
|
|
|
|
}
|
|
|
|
}
|