ori_core/event/window.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
use crate::{layout::Size, window::WindowId};
/// Event emitted when a window wants to close.
///
/// After this event is emitted, if it wasn't handled, the window will be closed.
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
pub struct WindowCloseRequested {
/// The window that wants to close.
pub window: WindowId,
}
/// Event emitted when a window is resized.
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
pub struct WindowResized {
/// The window that was resized.
pub window: WindowId,
/// The new width of the window.
pub width: u32,
/// The new height of the window.
pub height: u32,
}
impl WindowResized {
/// Get the new size of the window.
pub fn size(&self) -> Size {
Size::new(self.width as f32, self.height as f32)
}
}
/// Event emitted when a window is scaled.
#[derive(Clone, Debug, Copy, PartialEq)]
pub struct WindowScaled {
/// The window that was scaled.
pub window: WindowId,
/// The new scale factor of the window.
pub scale_factor: f32,
}
/// Event emitted when a window is maximized.
#[derive(Clone, Debug, Copy, PartialEq, Eq, Hash)]
pub struct WindowMaximized {
/// The window that was maximized.
pub window: WindowId,
/// Whether the window is maximized or not.
pub maximized: bool,
}