Skip to main content

NodeContext

Struct NodeContext 

Source
pub struct NodeContext {
Show 25 fields pub expanded_node: Weak<ExpandedNode>, pub slot_index: Property<Option<usize>>, pub local_stack_frame: Rc<RuntimePropertiesStackFrame>, pub containing_component: Weak<ExpandedNode>, pub elapsed_frames: Property<u64>, pub elapsed_millis: Property<u64>, pub gyro: Property<Gyro>, pub accel: Property<Accel>, pub bounds_parent: Property<(f64, f64)>, pub bounds_self: Property<(f64, f64)>, pub measured_size: Property<Option<(f64, f64)>>, pub subtree_layout_hull: Property<LayoutHull>, pub platform: Platform, pub os: OS, pub target: Property<TargetInfo>, pub viewport: Property<Viewport>, pub projected_children_count: Property<usize>, pub node_transform_and_bounds: TransformAndBounds<NodeLocal, Window>, pub projected_children: Property<Vec<Rc<ExpandedNode>>>, pub projected_children_changed: Property<()>, pub received_children: Property<Vec<Rc<ExpandedNode>>>, pub received_children_count: Property<usize>, pub received_children_changed: Property<()>, pub retained_received_children: Property<Vec<Rc<ExpandedNode>>>, pub retained_received_children_changed: Property<()>, /* private fields */
}
Expand description

Runtime context passed into user component lifecycle methods and event handlers.

Child-related fields intentionally separate semantic payload from engine transport:

  • projected_children is the raw transport family used by Slot
  • received_children is the normalized semantic payload that this node should treat as content from its caller
  • retained_received_children are former received children kept alive only so @out transitions can finish

A node’s own private template or primitive-assembled structure is intentionally not surfaced here as a first-class “child family” for container consumers.

Fields§

§expanded_node: Weak<ExpandedNode>§slot_index: Property<Option<usize>>

slot index of this node in its container

§local_stack_frame: Rc<RuntimePropertiesStackFrame>

Stack frame of this component, used to look up stores

§containing_component: Weak<ExpandedNode>

Reference to the ExpandedNode of the component containing this node

§elapsed_frames: Property<u64>

The current global engine frame count.

§elapsed_millis: Property<u64>

The current global engine wall-clock time in milliseconds.

§gyro: Property<Gyro>

Current device orientation sensor reading.

§accel: Property<Accel>

Current device accelerometer reading.

§bounds_parent: Property<(f64, f64)>

The bounds of this element’s immediate container (parent) in px

§bounds_self: Property<(f64, f64)>

The bounds of this element in px

§measured_size: Property<Option<(f64, f64)>>

Measured bounds resolved by the chassis or container layout for this node.

§subtree_layout_hull: Property<LayoutHull>

Node-local subtree layout hull published by the engine for container measurement.

§platform: Platform

Current platform (Web/Native) this app is running on

§os: OS

Current os (Android/Windows/Mac/Linux) this app is running on

§target: Property<TargetInfo>

Derived target facts for platform/OS checks.

§viewport: Property<Viewport>

Derived viewport facts for size and orientation checks.

§projected_children_count: Property<usize>

The number of projected children available to this node.

This is the raw transport count used by slot-driven implementations. Container-style consumers usually want received_children_count instead.

§node_transform_and_bounds: TransformAndBounds<NodeLocal, Window>

The transform of this node in the global coordinate space

§projected_children: Property<Vec<Rc<ExpandedNode>>>

Children projected into this node from the containing component.

Projection is an engine transport mechanism. Consumers that want the semantic payload owned by this node should prefer received_children.

§projected_children_changed: Property<()>

A structural invalidation signal for projected children.

§received_children: Property<Vec<Rc<ExpandedNode>>>

Semantic payload children received by this node from its caller.

This is the canonical “content” view for container-style logic. It excludes private encapsulated implementation children and also excludes exit-retained payload nodes, which instead appear in retained_received_children.

§received_children_count: Property<usize>

Convenience count derived from received_children.

§received_children_changed: Property<()>

A structural invalidation signal for received_children.

Prefer this or received_children itself for structural subscriptions that must react to reorders as well as insertions and removals.

§retained_received_children: Property<Vec<Rc<ExpandedNode>>>

Received children retained only so exit transitions can finish.

These are no longer part of the active semantic payload, but some containers still need to place them as ghosts or overlays while their @out transitions run.

§retained_received_children_changed: Property<()>

A structural invalidation signal for retained_received_children.

Implementations§

Source§

impl NodeContext

Source

pub fn push_local_store<T: Store>(&self, store: T)

Push component-local state onto the runtime stack for descendants to find.

Source

pub fn peek_local_store<T: Store, V>( &self, f: impl FnOnce(&mut T) -> V, ) -> Result<V, String>

Borrow the nearest stack-local store of type T.

Source

pub fn local_point(&self, p: Point2<Window>) -> Point2<NodeLocal>

Convert a window-space point into this node’s local coordinate space, including any presentation offsets inherited from ancestor scrollers.

Source

pub fn get_node_interface(&self) -> Option<NodeInterface>

Return the interface for this node’s containing component, when present.

Source

pub fn elapsed_time_millis(&self) -> u128

Milliseconds elapsed according to the chassis-provided clock.

Source

pub fn subscribe( &self, dependencies: &[UntypedProperty], f: impl Fn() + 'static, )

Attach a dependency subscription whose callback runs when any dependency dirties.

Source

pub fn clear_subscriptions(&self)

Remove all subscriptions registered on this node.

Source

pub fn navigate_to(&self, url: &str, target: NavigationTarget)

Ask the chassis to navigate to a URL.

On web targets, same-origin navigation in the current tab can be handled through the browser History API and routed back into Pax without a full page reload. Other targets use the active chassis navigation behavior.

Source

pub fn dispatch_event(&self, identifier: &'static str) -> Result<(), String>

Queue a named custom event from this component for dispatch at the end of the tick.

Source

pub fn set_cursor(&self, cursor: CursorStyle)

Ask the chassis to display the requested cursor over the app surface.

Source

pub fn screenshot(&self, id: u32)

Request a screenshot capture from the chassis, keyed by caller-provided id.

Source

pub fn get_screenshot_map(&self) -> Rc<RefCell<HashMap<u32, ScreenshotData>>>

Shared map where completed screenshot captures are published by id.

Trait Implementations§

Source§

impl Clone for NodeContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> RoundFrom<T> for T

Source§

fn round_from(x: T) -> T

Performs the conversion.
Source§

impl<T, U> RoundInto<U> for T
where U: RoundFrom<T>,

Source§

fn round_into(self) -> U

Performs the conversion.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>