2021-01-01 21:31:22 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2020-04-19 19:13:04 +00:00
|
|
|
use super::{WindowDescriptor, WindowId};
|
2021-01-25 04:06:06 +00:00
|
|
|
use bevy_math::{IVec2, Vec2};
|
2020-04-19 19:13:04 +00:00
|
|
|
|
2021-09-10 18:46:16 +00:00
|
|
|
/// A window event that is sent whenever a windows logical size has changed
|
2020-04-19 19:13:04 +00:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowResized {
|
|
|
|
pub id: WindowId,
|
2021-09-10 18:46:16 +00:00
|
|
|
/// The new logical width of the window
|
2020-12-07 21:32:57 +00:00
|
|
|
pub width: f32,
|
2021-09-10 18:46:16 +00:00
|
|
|
/// The new logical height of the window
|
2020-12-07 21:32:57 +00:00
|
|
|
pub height: f32,
|
2020-04-19 19:13:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// An event that indicates that a new window should be created.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct CreateWindow {
|
2020-06-25 23:02:21 +00:00
|
|
|
pub id: WindowId,
|
2020-04-19 19:13:04 +00:00
|
|
|
pub descriptor: WindowDescriptor,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An event that indicates a window should be closed.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct CloseWindow {
|
|
|
|
pub id: WindowId,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An event that is sent whenever a new window is created.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowCreated {
|
|
|
|
pub id: WindowId,
|
|
|
|
}
|
|
|
|
|
2021-03-11 00:27:30 +00:00
|
|
|
/// An event that is sent whenever a close was requested for a window. For example: when the "close"
|
|
|
|
/// button is pressed on a window.
|
2020-04-19 19:13:04 +00:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowCloseRequested {
|
|
|
|
pub id: WindowId,
|
2020-04-25 01:55:15 +00:00
|
|
|
}
|
2020-06-04 06:22:32 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct CursorMoved {
|
2020-06-15 19:47:35 +00:00
|
|
|
pub id: WindowId,
|
2020-06-04 06:22:32 +00:00
|
|
|
pub position: Vec2,
|
2020-06-15 19:47:35 +00:00
|
|
|
}
|
2020-11-07 01:15:56 +00:00
|
|
|
|
2020-12-03 19:30:27 +00:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct CursorEntered {
|
|
|
|
pub id: WindowId,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct CursorLeft {
|
|
|
|
pub id: WindowId,
|
|
|
|
}
|
|
|
|
|
2020-11-07 01:15:56 +00:00
|
|
|
/// An event that is sent whenever a window receives a character from the OS or underlying system.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct ReceivedCharacter {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub char: char,
|
|
|
|
}
|
2020-12-07 21:24:25 +00:00
|
|
|
|
|
|
|
/// An event that indicates a window has received or lost focus.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowFocused {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub focused: bool,
|
|
|
|
}
|
2020-12-28 20:26:50 +00:00
|
|
|
|
|
|
|
/// An event that indicates a window's scale factor has changed.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowScaleFactorChanged {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub scale_factor: f64,
|
|
|
|
}
|
|
|
|
/// An event that indicates a window's OS-reported scale factor has changed.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowBackendScaleFactorChanged {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub scale_factor: f64,
|
|
|
|
}
|
2021-01-01 21:31:22 +00:00
|
|
|
|
|
|
|
/// Events related to files being dragged and dropped on a window.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub enum FileDragAndDrop {
|
|
|
|
DroppedFile { id: WindowId, path_buf: PathBuf },
|
|
|
|
|
|
|
|
HoveredFile { id: WindowId, path_buf: PathBuf },
|
|
|
|
|
|
|
|
HoveredFileCancelled { id: WindowId },
|
|
|
|
}
|
2021-01-25 04:06:06 +00:00
|
|
|
|
|
|
|
/// An event that is sent when a window is repositioned in physical pixels.
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct WindowMoved {
|
|
|
|
pub id: WindowId,
|
|
|
|
pub position: IVec2,
|
|
|
|
}
|