more progress updating tui
This commit is contained in:
1 parent
8c07b4059f
commit
11b37ee141
11 files changed
+44
-64
No files matched your search
@@ -3,6 +3,7 @@ use dioxus_core::ElementId;
|
||||
use crate::{
|
||||
node::{NodeData, NodeType, OwnedAttributeView},
|
||||
state::union_ordered_iter,
|
||||
RealNodeId,
|
||||
};
|
||||
|
||||
/// A view into a [VNode] with limited access.
|
||||
@@ -26,6 +27,11 @@ impl<'a> NodeView<'a> {
|
||||
self.inner.element_id
|
||||
}
|
||||
|
||||
/// Get the node id of the node
|
||||
pub fn node_id(&self) -> RealNodeId {
|
||||
self.inner.node_id
|
||||
}
|
||||
|
||||
/// Get the tag of the node if the tag is enabled in the mask
|
||||
pub fn tag(&self) -> Option<&'a str> {
|
||||
self.mask
|
||||
|
||||
@@ -334,7 +334,7 @@ pub fn resolve_passes<T, Tr: TreeView<T>>(
|
||||
if pass
|
||||
.dependancies()
|
||||
.iter()
|
||||
.all(|d| resolved_passes.contains(d))
|
||||
.all(|d| resolved_passes.contains(d) || *d == pass_id)
|
||||
&& !pass_mask.overlaps(currently_borrowed)
|
||||
{
|
||||
let pass = passes.remove(i);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use dioxus_core::{ElementId, Mutations, TemplateNode};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::ops::{Deref, DerefMut, Index, IndexMut};
|
||||
|
||||
use crate::node::{Node, NodeType, OwnedAttributeDiscription, OwnedAttributeValue};
|
||||
@@ -32,6 +33,7 @@ pub struct RealDom<S: State> {
|
||||
nodes_listening: FxHashMap<String, FxHashSet<RealNodeId>>,
|
||||
stack: Vec<RealNodeId>,
|
||||
templates: FxHashMap<String, Vec<RealNodeId>>,
|
||||
root_initialized: bool,
|
||||
}
|
||||
|
||||
impl<S: State> Default for RealDom<S> {
|
||||
@@ -55,10 +57,11 @@ impl<S: State> RealDom<S> {
|
||||
|
||||
RealDom {
|
||||
tree,
|
||||
node_id_mapping: Vec::new(),
|
||||
node_id_mapping: vec![Some(root_id)],
|
||||
nodes_listening: FxHashMap::default(),
|
||||
stack: vec![root_id],
|
||||
templates: FxHashMap::default(),
|
||||
root_initialized: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +102,7 @@ impl<S: State> RealDom<S> {
|
||||
&mut self,
|
||||
node: &TemplateNode,
|
||||
mutations_vec: &mut FxHashMap<RealNodeId, NodeMask>,
|
||||
) -> Option<RealNodeId> {
|
||||
) -> RealNodeId {
|
||||
match node {
|
||||
TemplateNode::Element {
|
||||
tag,
|
||||
@@ -132,21 +135,31 @@ impl<S: State> RealDom<S> {
|
||||
});
|
||||
let node_id = self.create_node(node);
|
||||
for child in *children {
|
||||
if let Some(child_id) = self.create_template_node(child, mutations_vec) {
|
||||
self.add_child(node_id, child_id);
|
||||
}
|
||||
let child_id = self.create_template_node(child, mutations_vec);
|
||||
self.add_child(node_id, child_id);
|
||||
}
|
||||
self.stack.push(node_id);
|
||||
Some(node_id)
|
||||
node_id
|
||||
}
|
||||
TemplateNode::Text(txt) => {
|
||||
let node_id = self.create_node(Node::new(NodeType::Text {
|
||||
text: txt.to_string(),
|
||||
}));
|
||||
self.stack.push(node_id);
|
||||
Some(node_id)
|
||||
node_id
|
||||
}
|
||||
TemplateNode::Dynamic(_) => {
|
||||
let node_id = self.create_node(Node::new(NodeType::Placeholder));
|
||||
self.stack.push(node_id);
|
||||
node_id
|
||||
}
|
||||
TemplateNode::DynamicText(_) => {
|
||||
let node_id = self.create_node(Node::new(NodeType::Text {
|
||||
text: String::new(),
|
||||
}));
|
||||
self.stack.push(node_id);
|
||||
node_id
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,13 +169,17 @@ impl<S: State> RealDom<S> {
|
||||
for template in mutations.templates {
|
||||
let mut template_root_ids = Vec::new();
|
||||
for root in template.roots {
|
||||
if let Some(id) = self.create_template_node(root, &mut nodes_updated) {
|
||||
template_root_ids.push(id);
|
||||
}
|
||||
let id = self.create_template_node(root, &mut nodes_updated);
|
||||
template_root_ids.push(id);
|
||||
}
|
||||
self.templates
|
||||
.insert(template.name.to_string(), template_root_ids);
|
||||
}
|
||||
if !self.root_initialized {
|
||||
self.root_initialized = true;
|
||||
let root_id = self.tree.root();
|
||||
nodes_updated.insert(root_id, NodeMask::ALL);
|
||||
}
|
||||
for e in mutations.edits {
|
||||
use dioxus_core::Mutation::*;
|
||||
match e {
|
||||
@@ -171,7 +188,7 @@ impl<S: State> RealDom<S> {
|
||||
let parent = self.element_to_node_id(id);
|
||||
for child in children {
|
||||
self.add_child(parent, child);
|
||||
mark_dirty(parent, NodeMask::ALL, &mut nodes_updated);
|
||||
mark_dirty(child, NodeMask::ALL, &mut nodes_updated);
|
||||
}
|
||||
}
|
||||
AssignId { path, id } => {
|
||||
@@ -207,6 +224,7 @@ impl<S: State> RealDom<S> {
|
||||
let template_id = self.templates[name][index];
|
||||
let clone_id = self.clone_node(template_id, &mut nodes_updated);
|
||||
self.set_element_id(clone_id, id);
|
||||
self.stack.push(clone_id);
|
||||
}
|
||||
ReplaceWith { id, m } => {
|
||||
let new_nodes = self.stack.split_off(m);
|
||||
@@ -218,7 +236,7 @@ impl<S: State> RealDom<S> {
|
||||
self.tree.remove(old_node_id);
|
||||
}
|
||||
ReplacePlaceholder { path, m } => {
|
||||
let new_nodes = self.stack.split_off(m);
|
||||
let new_nodes = self.stack.split_off(self.stack.len() - m);
|
||||
let old_node_id = self.load_child(path);
|
||||
for new in new_nodes {
|
||||
self.tree.insert_after(old_node_id, new);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::{node::NodeType, real_dom::RealDom, state::State, tree::TreeView, NodeId, RealNodeId};
|
||||
use dioxus_core::{Mutation, Mutations};
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub enum ElementProduced {
|
||||
/// The iterator produced an element by progressing to the next node in a depth first order.
|
||||
|
||||
Reference in new issue
Block a user