2023-01-12 06:24:44 +01:00
|
|
|
use crate::time::Instant;
|
|
|
|
|
|
2020-01-16 07:12:59 +01:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
2020-01-10 01:28:45 +01:00
|
|
|
/// A window-related event.
|
2022-08-17 16:09:25 +02:00
|
|
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
2020-01-10 01:28:45 +01:00
|
|
|
pub enum Event {
|
2021-07-26 12:36:13 -07:00
|
|
|
/// A window was moved.
|
|
|
|
|
Moved {
|
|
|
|
|
/// The new logical x location of the window
|
|
|
|
|
x: i32,
|
|
|
|
|
/// The new logical y location of the window
|
|
|
|
|
y: i32,
|
|
|
|
|
},
|
|
|
|
|
|
2021-01-15 18:21:44 +01:00
|
|
|
/// A window was resized.
|
2020-01-10 01:28:45 +01:00
|
|
|
Resized {
|
2021-09-01 19:21:49 +07:00
|
|
|
/// The new logical width of the window
|
2020-01-10 01:28:45 +01:00
|
|
|
width: u32,
|
2021-09-01 19:21:49 +07:00
|
|
|
/// The new logical height of the window
|
2020-01-10 01:28:45 +01:00
|
|
|
height: u32,
|
|
|
|
|
},
|
2020-01-16 07:12:59 +01:00
|
|
|
|
2023-01-12 02:59:08 +01:00
|
|
|
/// A window redraw was requested.
|
|
|
|
|
///
|
|
|
|
|
/// The [`Instant`] contains the current time.
|
|
|
|
|
RedrawRequested(Instant),
|
|
|
|
|
|
2021-03-30 21:33:57 +02:00
|
|
|
/// The user has requested for the window to close.
|
|
|
|
|
///
|
|
|
|
|
/// Usually, you will want to terminate the execution whenever this event
|
|
|
|
|
/// occurs.
|
|
|
|
|
CloseRequested,
|
|
|
|
|
|
2021-01-15 18:21:44 +01:00
|
|
|
/// A window was focused.
|
|
|
|
|
Focused,
|
|
|
|
|
|
|
|
|
|
/// A window was unfocused.
|
|
|
|
|
Unfocused,
|
|
|
|
|
|
2020-01-16 07:12:59 +01:00
|
|
|
/// A file is being hovered over the window.
|
|
|
|
|
///
|
|
|
|
|
/// When the user hovers multiple files at once, this event will be emitted
|
|
|
|
|
/// for each file separately.
|
|
|
|
|
FileHovered(PathBuf),
|
|
|
|
|
|
|
|
|
|
/// A file has beend dropped into the window.
|
|
|
|
|
///
|
|
|
|
|
/// When the user drops multiple files at once, this event will be emitted
|
|
|
|
|
/// for each file separately.
|
|
|
|
|
FileDropped(PathBuf),
|
|
|
|
|
|
|
|
|
|
/// A file was hovered, but has exited the window.
|
|
|
|
|
///
|
2020-01-16 07:18:17 +01:00
|
|
|
/// There will be a single `FilesHoveredLeft` event triggered even if
|
|
|
|
|
/// multiple files were hovered.
|
|
|
|
|
FilesHoveredLeft,
|
2020-01-10 01:28:45 +01:00
|
|
|
}
|