TUI rendering mostly working
This commit is contained in:
1 parent
39a3db68bd
commit
71a0bdf71d
8 files changed
+20
-44
No files matched your search
@@ -160,36 +160,6 @@ pub struct NodeMask {
|
||||
}
|
||||
|
||||
impl NodeMask {
|
||||
pub fn from_node(node: &NodeType) -> Self {
|
||||
match node {
|
||||
NodeType::Text { .. } => NodeMaskBuilder::new().with_text().build(),
|
||||
NodeType::Element(ElementNode {
|
||||
tag: _,
|
||||
namespace: _,
|
||||
attributes,
|
||||
listeners,
|
||||
}) => Self {
|
||||
attritutes: AttributeMask::Some(
|
||||
attributes
|
||||
.keys()
|
||||
.map(|key| key.name.as_str().into())
|
||||
.collect(),
|
||||
),
|
||||
namespace: true,
|
||||
tag: true,
|
||||
text: false,
|
||||
listeners: !listeners.is_empty(),
|
||||
},
|
||||
NodeType::Placeholder => Self {
|
||||
attritutes: AttributeMask::default(),
|
||||
tag: true,
|
||||
namespace: true,
|
||||
text: false,
|
||||
listeners: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if two masks overlap
|
||||
pub fn overlaps(&self, other: &Self) -> bool {
|
||||
(self.tag && other.tag)
|
||||
|
||||
@@ -191,7 +191,6 @@ pub trait Pass<V: FromAnyValue + Send + Sync = ()>: Any + Send + Sync {
|
||||
debug_assert!(!Self::NodeDependencies::type_ids()
|
||||
.iter()
|
||||
.any(|id| *id == TypeId::of::<Self>()));
|
||||
println!("passing: {node_id:?}");
|
||||
// get all of the states from the tree view
|
||||
// Safety: No node has itself as a parent or child.
|
||||
let myself: SlabEntry<'static, Self> = unsafe {
|
||||
|
||||
@@ -610,6 +610,7 @@ pub trait NodeImmutable<V: FromAnyValue + Send + Sync>: Sized {
|
||||
|
||||
pub trait NodeMutable<V: FromAnyValue + Send + Sync>: Sized + NodeImmutable<V> {
|
||||
fn get_mut<T: Any + Sync + Send>(&mut self) -> Option<&mut T>;
|
||||
fn insert<T: Any + Sync + Send>(&mut self, value: T);
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -648,6 +649,10 @@ impl<'a, V: FromAnyValue + Send + Sync> NodeMutable<V> for NodeMut<'a, V> {
|
||||
fn get_mut<T: Any + Sync + Send>(&mut self) -> Option<&mut T> {
|
||||
todo!("get_mut with mark as dirty")
|
||||
}
|
||||
|
||||
fn insert<T: Any + Sync + Send>(&mut self, _: T) {
|
||||
todo!("insert with mark as dirty")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, V: FromAnyValue + Send + Sync> NodeMut<'a, V> {
|
||||
@@ -777,4 +782,8 @@ impl<'a, V: FromAnyValue + Send + Sync> NodeMutable<V> for NodeMutRaw<'a, V> {
|
||||
fn get_mut<T: Any + Sync + Send>(&mut self) -> Option<&mut T> {
|
||||
self.dom.tree.get_mut::<T>(self.id)
|
||||
}
|
||||
|
||||
fn insert<T: Any + Sync + Send>(&mut self, value: T) {
|
||||
self.dom.tree.insert(self.id, value);
|
||||
}
|
||||
}
|
||||
@@ -173,15 +173,17 @@ impl Tree {
|
||||
}
|
||||
|
||||
pub fn get<T: Any + Sync + Send>(&self, id: NodeId) -> Option<&T> {
|
||||
self.nodes.read_slab().get(id)
|
||||
self.nodes.try_read_slab().and_then(|slab| slab.get(id))
|
||||
}
|
||||
|
||||
pub fn get_mut<T: Any + Sync + Send>(&mut self, id: NodeId) -> Option<&mut T> {
|
||||
self.nodes.write_slab().get_mut(id)
|
||||
self.nodes
|
||||
.try_write_slab()
|
||||
.and_then(|slab| slab.get_mut(id))
|
||||
}
|
||||
|
||||
pub fn insert<T: Any + Sync + Send>(&mut self, id: NodeId, value: T) {
|
||||
self.nodes.write_slab().insert(id, value);
|
||||
self.nodes.get_or_insert_slab_mut().insert(id, value);
|
||||
}
|
||||
|
||||
pub fn contains(&self, id: NodeId) -> bool {
|
||||
@@ -218,11 +220,9 @@ impl<'a> DynamicallyBorrowedTree<'a> {
|
||||
let nodes_data = self.node_slab();
|
||||
let mut nodes = FxHashMap::default();
|
||||
for id in immutable {
|
||||
println!("reading {id:?}");
|
||||
nodes.insert(id, MaybeRead::Read(self.nodes.get_slab(id).unwrap()));
|
||||
}
|
||||
for id in mutable {
|
||||
println!("writing {id:?}");
|
||||
nodes.insert(id, MaybeRead::Write(self.nodes.get_slab_mut(id).unwrap()));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user