1use std::sync::{Arc, Mutex};
3
4use crate::{audio::Audio, events::{KeyboardEvent, MouseClickEvent, MouseMotionEvent, MouseWheelEvent, WindowEventHandler}, graphics::{Graphics, HasWindow}, resources::ResourceManager};
5
6pub mod audio;
8pub mod events;
10pub mod graphics;
12pub mod resources;
14mod tests;
16
17unsafe impl Send for Window {}
18unsafe impl Sync for Window {}
19
20pub struct Window {
25 pub graphics: Graphics,
27 pub audio: Audio,
29 pub resource_manager: Arc<Mutex<ResourceManager>>,
31}
32
33impl Window {
34 pub fn new(graphics: Graphics, resource_manager: Arc<Mutex<ResourceManager>>) -> Window {
43 Window {
44 graphics,
45 audio: Audio::new(),
46 resource_manager,
47 }
48 }
49}
50
51impl HasWindow for Window {
52 fn window_mut(&mut self) -> &mut Self {
53 self
54 }
55}
56
57pub struct CoreHandler;
58#[async_trait::async_trait]
59impl WindowEventHandler for CoreHandler {
60 fn update(&self, _window: &mut Window) -> anyhow::Result<()> {
61 Ok(())
62 }
63
64 fn draw(&mut self, _window: &mut Window) -> anyhow::Result<()> {
65 Ok(())
66 }
67
68 fn key_down_event(&self, _window: &mut Window, _event: KeyboardEvent) -> anyhow::Result<()> {
69 Ok(())
70 }
71
72 fn key_up_event(&self, _window: &mut Window, _event: KeyboardEvent) -> anyhow::Result<()> {
73 Ok(())
74 }
75
76 fn mouse_motion_event(
77 &self,
78 _window: &mut Window,
79 _event: MouseMotionEvent,
80 ) -> anyhow::Result<()> {
81 Ok(())
82 }
83
84 fn mouse_button_down_event(
85 &self,
86 _window: &mut Window,
87 _event: MouseClickEvent,
88 ) -> anyhow::Result<()> {
89 Ok(())
90 }
91
92 fn mouse_button_up_event(
93 &self,
94 _window: &mut Window,
95 _event: MouseClickEvent,
96 ) -> anyhow::Result<()> {
97 Ok(())
98 }
99
100 fn mouse_wheel_event(
101 &self,
102 _window: &mut Window,
103 _event: MouseWheelEvent,
104 ) -> anyhow::Result<()> {
105 Ok(())
106 }
107}