cacao/examples/window.rs

55 lines
1.4 KiB
Rust
Raw Normal View History

//! This example showcases setting up a basic application and window.
use cacao::appkit::menu::{Menu, MenuItem};
use cacao::appkit::window::Window;
2022-07-16 00:14:02 +10:00
use cacao::appkit::{App, AppDelegate};
#[derive(Default)]
struct BasicApp {
2022-08-18 09:11:45 +10:00
window: Window,
}
impl AppDelegate for BasicApp {
fn did_finish_launching(&self) {
App::set_menu(vec![
2022-08-18 09:11:45 +10:00
Menu::new(
"",
vec![
MenuItem::Services,
MenuItem::Separator,
MenuItem::Hide,
MenuItem::HideOthers,
MenuItem::ShowAll,
MenuItem::Separator,
MenuItem::Quit,
],
),
2022-07-16 00:14:02 +10:00
Menu::new("File", vec![MenuItem::CloseWindow]),
Menu::new("View", vec![MenuItem::EnterFullScreen]),
2022-08-18 09:11:45 +10:00
Menu::new(
"Window",
vec![
MenuItem::Minimize,
MenuItem::Zoom,
MenuItem::Separator,
MenuItem::new("Bring All to Front"),
],
),
]);
2021-02-08 15:51:40 +11:00
App::activate();
self.window.set_minimum_content_size(400., 400.);
self.window.set_title("A Basic Window");
self.window.show();
}
fn should_terminate_after_last_window_closed(&self) -> bool {
true
}
}
fn main() {
App::new("com.test.window", BasicApp::default()).run();
}