add window::Id to Event and Action

This commit is contained in:
Richard 2022-09-19 20:59:37 -03:00 committed by bungoboingo
parent 974cc6b6f5
commit 0ad53a3d5c
11 changed files with 99 additions and 78 deletions

View file

@ -20,7 +20,7 @@ pub enum Action<T> {
Clipboard(clipboard::Action<T>),
/// Run a window action.
Window(window::Action<T>),
Window(window::Id, window::Action<T>),
/// Run a system action.
System(system::Action<T>),
@ -46,7 +46,7 @@ impl<T> Action<T> {
match self {
Self::Future(future) => Action::Future(Box::pin(future.map(f))),
Self::Clipboard(action) => Action::Clipboard(action.map(f)),
Self::Window(window) => Action::Window(window.map(f)),
Self::Window(id, window) => Action::Window(id, window.map(f)),
Self::System(system) => Action::System(system.map(f)),
Self::Widget(widget) => Action::Widget(widget.map(f)),
}
@ -60,7 +60,9 @@ impl<T> fmt::Debug for Action<T> {
Self::Clipboard(action) => {
write!(f, "Action::Clipboard({:?})", action)
}
Self::Window(action) => write!(f, "Action::Window({:?})", action),
Self::Window(id, action) => {
write!(f, "Action::Window({:?}, {:?})", id, action)
}
Self::System(action) => write!(f, "Action::System({:?})", action),
Self::Widget(_action) => write!(f, "Action::Widget"),
}

View file

@ -19,7 +19,7 @@ pub enum Event {
Mouse(mouse::Event),
/// A window event
Window(window::Event),
Window(window::Id, window::Event),
/// A touch event
Touch(touch::Event),

View file

@ -6,6 +6,9 @@ use std::hash::{Hash, Hasher};
pub struct Id(u64);
impl Id {
/// TODO(derezzedex): maybe change `u64` to an enum `Type::{Single, Multi(u64)}`
pub const MAIN: Self = Id(0);
/// TODO(derezzedex)
pub fn new(id: impl Hash) -> Id {
let mut hasher = DefaultHasher::new();