maycoon_core/app/
info.rs

1use nalgebra::Vector2;
2use winit::event::{DeviceId, ElementState, KeyEvent, MouseButton};
3
4use crate::app::diagnostics::Diagnostics;
5use crate::app::font_ctx::FontContext;
6
7/// The application information container.
8pub struct AppInfo {
9    /// The position of the cursor. If [None], the cursor left the window.
10    pub cursor_pos: Option<Vector2<f64>>,
11    /// The fired key events.
12    pub keys: Vec<(DeviceId, KeyEvent)>,
13    /// The fired mouse button events.
14    pub buttons: Vec<(DeviceId, MouseButton, ElementState)>,
15    /// App Diagnostics.
16    pub diagnostics: Diagnostics,
17    /// The current font context.
18    pub font_context: FontContext,
19    /// The size of the window.
20    pub size: Vector2<f64>,
21}
22
23impl AppInfo {
24    /// Reset the application information for a new frame.
25    pub fn reset(&mut self) {
26        self.buttons.clear();
27        self.keys.clear();
28    }
29}
30
31impl Default for AppInfo {
32    fn default() -> Self {
33        Self {
34            cursor_pos: None,
35            keys: Vec::with_capacity(4),
36            buttons: Vec::with_capacity(2),
37            diagnostics: Diagnostics::default(),
38            font_context: FontContext::default(),
39            size: Vector2::new(0.0, 0.0),
40        }
41    }
42}