document state trait

This commit is contained in:
Evan Almloff committed 2023-02-11 17:43:08 -06:00
1 parent d8da8e4275
commit fe3ad8ebe9
11 files changed
+58 -55

No files matched your search

+4 -4
View File
@@ -4,7 +4,7 @@ use dioxus_native_core::{
node_ref::{AttributeMaskBuilder, NodeMaskBuilder},
real_dom::NodeImmutable,
utils::{ElementProduced, PersistantElementIter},
Dependancy, NodeId, Pass, RealDom, SendAnyMap,
Dependancy, NodeId, RealDom, SendAnyMap, State,
};
use std::{cmp::Ordering, num::NonZeroU16};
@@ -63,7 +63,7 @@ pub(crate) struct Focus {
pub level: FocusLevel,
}
impl Pass for Focus {
impl State for Focus {
const NODE_MASK: NodeMaskBuilder<'static> = NodeMaskBuilder::new()
.with_attrs(AttributeMaskBuilder::Some(FOCUS_ATTRIBUTES))
.with_listeners();
@@ -72,7 +72,7 @@ impl Pass for Focus {
type ChildDependencies = ();
type NodeDependencies = ();
fn pass<'a>(
fn update<'a>(
&mut self,
node_view: NodeView,
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -130,7 +130,7 @@ impl Pass for Focus {
context: &SendAnyMap,
) -> Self {
let mut myself = Self::default();
myself.pass(node_view, node, parent, children, context);
myself.update(node_view, node, parent, children, context);
myself
}
}
+4 -4
View File
@@ -5,7 +5,7 @@ use dioxus_native_core::layout_attributes::{
};
use dioxus_native_core::node::OwnedAttributeView;
use dioxus_native_core::node_ref::{AttributeMaskBuilder, NodeMaskBuilder, NodeView};
use dioxus_native_core::{Dependancy, Pass, SendAnyMap};
use dioxus_native_core::{Dependancy, SendAnyMap, State};
use taffy::prelude::*;
use crate::{screen_to_layout_space, unit_to_layout_space};
@@ -42,7 +42,7 @@ pub(crate) struct TaffyLayout {
pub node: PossiblyUninitalized<Node>,
}
impl Pass for TaffyLayout {
impl State for TaffyLayout {
type ChildDependencies = (Self,);
type ParentDependencies = ();
type NodeDependencies = ();
@@ -51,7 +51,7 @@ impl Pass for TaffyLayout {
.with_attrs(AttributeMaskBuilder::Some(SORTED_LAYOUT_ATTRS))
.with_text();
fn pass<'a>(
fn update<'a>(
&mut self,
node_view: NodeView,
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -198,7 +198,7 @@ impl Pass for TaffyLayout {
context: &SendAnyMap,
) -> Self {
let mut myself = Self::default();
myself.pass(node_view, node, parent, children, context);
myself.update(node_view, node, parent, children, context);
myself
}
}
+1 -1
View File
@@ -7,7 +7,7 @@ use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use dioxus_html::EventData;
use dioxus_native_core::{node_ref::NodeMaskBuilder, real_dom::NodeImmutable, Pass};
use dioxus_native_core::{node_ref::NodeMaskBuilder, real_dom::NodeImmutable, State};
use dioxus_native_core::{real_dom::RealDom, FxDashSet, NodeId, SendAnyMap};
use focus::FocusState;
use futures::{channel::mpsc::UnboundedSender, pin_mut, Future, StreamExt};
+4 -4
View File
@@ -1,4 +1,4 @@
use dioxus_native_core::{node_ref::NodeView, Dependancy, Pass, SendAnyMap};
use dioxus_native_core::{node_ref::NodeView, Dependancy, SendAnyMap, State};
#[derive(PartialEq, Debug, Clone, Copy)]
pub(crate) enum PreventDefault {
@@ -25,7 +25,7 @@ impl Default for PreventDefault {
}
}
impl Pass for PreventDefault {
impl State for PreventDefault {
type ParentDependencies = ();
type ChildDependencies = ();
type NodeDependencies = ();
@@ -37,7 +37,7 @@ impl Pass for PreventDefault {
]))
.with_listeners();
fn pass<'a>(
fn update<'a>(
&mut self,
node_view: NodeView,
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -82,7 +82,7 @@ impl Pass for PreventDefault {
context: &SendAnyMap,
) -> Self {
let mut myself = Self::default();
myself.pass(node_view, node, parent, children, context);
myself.update(node_view, node, parent, children, context);
myself
}
}
+4 -4
View File
@@ -33,7 +33,7 @@ use dioxus_native_core::{
layout_attributes::parse_value,
node::OwnedAttributeView,
node_ref::{AttributeMaskBuilder, NodeMaskBuilder, NodeView},
Dependancy, Pass, SendAnyMap,
Dependancy, SendAnyMap, State,
};
use taffy::prelude::*;
@@ -45,7 +45,7 @@ pub struct StyleModifier {
pub modifier: TuiModifier,
}
impl Pass for StyleModifier {
impl State for StyleModifier {
type ParentDependencies = (Self,);
type ChildDependencies = ();
type NodeDependencies = ();
@@ -55,7 +55,7 @@ impl Pass for StyleModifier {
.with_attrs(AttributeMaskBuilder::Some(SORTED_STYLE_ATTRS))
.with_element();
fn pass<'a>(
fn update<'a>(
&mut self,
node_view: NodeView,
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
@@ -121,7 +121,7 @@ impl Pass for StyleModifier {
context: &SendAnyMap,
) -> Self {
let mut myself = Self::default();
myself.pass(node_view, node, parent, children, context);
myself.update(node_view, node, parent, children, context);
myself
}
}