mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-22 15:18:43 -06:00
38 lines
719 B
Rust
38 lines
719 B
Rust
//! input, window events and event handling
|
|
|
|
use glam::Vec2;
|
|
use crate::input::{MouseButton, ButtonState, KeyboardKey};
|
|
|
|
#[derive(Clone, Copy, Debug)]
|
|
pub enum UiEvent {
|
|
MouseMove(Vec2),
|
|
MouseButton {
|
|
button: MouseButton,
|
|
state: ButtonState,
|
|
},
|
|
KeyboardButton {
|
|
key: KeyboardKey,
|
|
state: ButtonState,
|
|
},
|
|
TextInput(char),
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub(crate) struct EventQueue {
|
|
events: Vec<UiEvent>,
|
|
}
|
|
|
|
impl EventQueue {
|
|
pub(crate) fn new() -> Self {
|
|
Self::default()
|
|
}
|
|
|
|
pub(crate) fn push(&mut self, event: UiEvent) {
|
|
self.events.push(event);
|
|
}
|
|
|
|
pub(crate) fn drain(&mut self) -> std::vec::Drain<UiEvent> {
|
|
self.events.drain(..)
|
|
}
|
|
}
|