1use crate::config::Config;
9use anyhow::Result;
10use std::sync::Arc;
11use tokio::runtime::Runtime;
12use winit::event_loop::{ControlFlow, EventLoop};
13
14pub mod bell;
15pub mod debug_state;
16pub mod handler;
17pub mod input_events;
18pub mod mouse;
19pub mod mouse_events;
20pub mod render_cache;
21pub mod window_manager;
22pub mod window_state;
23
24pub use window_manager::WindowManager;
25
26pub struct App {
28 config: Config,
29 runtime: Arc<Runtime>,
30}
31
32impl App {
33 pub fn new(runtime: Arc<Runtime>) -> Result<Self> {
35 let config = Config::load()?;
36 Ok(Self { config, runtime })
37 }
38
39 pub fn run(self) -> Result<()> {
41 let event_loop = EventLoop::new()?;
42 event_loop.set_control_flow(ControlFlow::Wait);
45
46 let mut window_manager = WindowManager::new(self.config, self.runtime);
47
48 event_loop.run_app(&mut window_manager)?;
49
50 Ok(())
51 }
52}