testing for event handling
This commit is contained in:
+15
-11
@@ -1,17 +1,21 @@
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
collections::HashMap,
|
||||
};
|
||||
|
||||
pub mod text;
|
||||
pub mod macros;
|
||||
|
||||
use std::fmt::Debug;
|
||||
pub trait Event: Any {}
|
||||
|
||||
use downcast_rs::{impl_downcast, DowncastSync};
|
||||
pub trait Component: DowncastSync + Debug {}
|
||||
impl_downcast!(sync Component);
|
||||
pub struct Screen {
|
||||
element: Box<dyn Element>,
|
||||
event_handlers: HashMap<TypeId, Box<dyn FnMut(Box<dyn Event>)>>,
|
||||
}
|
||||
|
||||
impl Screen {
|
||||
|
||||
}
|
||||
|
||||
pub trait Element {
|
||||
fn get_component<T: Component + 'static>(&mut self) -> Option<&mut T>;
|
||||
fn add_component<T: Component + 'static>(&mut self, component: T);
|
||||
}
|
||||
|
||||
pub trait Extension {
|
||||
fn tick(&mut self);
|
||||
fn init(&mut self, screen: &mut Screen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user