macos.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use crucible_appkit::{
  self,
  AppkitApplicationDelegate,
  AppkitWindow,
  AppkitWindowBuilder,
  AppkitWindowDelegate,
};
use std::cell::{ OnceCell };
#[derive(Debug)]
struct IdentifyApplicationDelegate {
  window: OnceCell<AppkitWindow>,
}
impl IdentifyApplicationDelegate {
  fn new() -> IdentifyApplicationDelegate {
    IdentifyApplicationDelegate {
      window: OnceCell::new(),
    }
  }
}
impl AppkitApplicationDelegate for IdentifyApplicationDelegate {
  fn did_finish_launching(&self) {
    let window = AppkitWindowBuilder::from_delegate(Box::new(IdentifyWindowDelegate::new()))
      .title("crucible_identify v0.1.0")
      .width(1280)
      .height(720)
      .build();
    self.window
      .set(window)
      .expect("Should have been able to initialize `window`");
  }
}
#[derive(Debug)]
struct IdentifyWindowDelegate {}
impl IdentifyWindowDelegate {
  fn new() -> IdentifyWindowDelegate {
    IdentifyWindowDelegate {}
  }
}
impl AppkitWindowDelegate for IdentifyWindowDelegate {
  fn will_close(&self) {
    crucible_appkit::terminate_application();
  }
}
pub fn run() {
  crucible_appkit::run_application(Box::new(IdentifyApplicationDelegate::new()));
}