hUI/hui/src/event.rs

38 lines
719 B
Rust
Raw Normal View History

2024-02-27 13:31:12 -06:00
//! input, window events and event handling
2024-02-17 14:43:46 -06:00
use glam::Vec2;
2024-02-28 18:15:29 -06:00
use crate::input::{MouseButton, ButtonState, KeyboardKey};
2024-02-19 18:00:57 -06:00
#[derive(Clone, Copy, Debug)]
2024-02-17 14:43:46 -06:00
pub enum UiEvent {
MouseMove(Vec2),
2024-02-19 18:00:57 -06:00
MouseButton {
button: MouseButton,
state: ButtonState,
},
KeyboardButton {
key: KeyboardKey,
state: ButtonState,
},
2024-02-17 14:43:46 -06:00
TextInput(char),
}
2024-02-29 10:57:06 -06:00
#[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(..)
}
}