feat: event handling on desktop
This commit is contained in:
1 parent
073fea9ed3
commit
30ef225812
29 files changed
+424
-205
No files matched your search
@@ -4,28 +4,31 @@ use crate::{nodes::VNode, virtual_dom::VirtualDom};
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
||||
pub struct ElementId(pub usize);
|
||||
|
||||
pub struct ElementPath {
|
||||
pub struct ElementRef {
|
||||
// the pathway of the real element inside the template
|
||||
pub path: &'static [u8],
|
||||
|
||||
// The actual template
|
||||
pub template: *mut VNode<'static>,
|
||||
pub element: usize,
|
||||
}
|
||||
|
||||
impl ElementPath {
|
||||
impl ElementRef {
|
||||
pub fn null() -> Self {
|
||||
Self {
|
||||
template: std::ptr::null_mut(),
|
||||
element: 0,
|
||||
path: &[],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualDom {
|
||||
pub fn next_element(&mut self, template: &VNode) -> ElementId {
|
||||
pub fn next_element(&mut self, template: &VNode, path: &'static [u8]) -> ElementId {
|
||||
let entry = self.elements.vacant_entry();
|
||||
let id = entry.key();
|
||||
|
||||
entry.insert(ElementPath {
|
||||
entry.insert(ElementRef {
|
||||
template: template as *const _ as *mut _,
|
||||
element: id,
|
||||
path,
|
||||
});
|
||||
|
||||
ElementId(id)
|
||||
@@ -35,3 +38,10 @@ impl VirtualDom {
|
||||
self.elements.remove(id.0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
now......
|
||||
|
||||
an ID is mostly a pointer to a node in the real dom.
|
||||
We need to
|
||||
*/
|
||||
Reference in new issue
Block a user