Skip to main content

Context

Struct Context 

Source
pub struct Context { /* private fields */ }
Expand description

Ambient framework-managed UI context binding the active SceneHandle, responsive signals, and platform metadata.

Implementations§

Source§

impl Context

High-level declarative building helpers on Context.

Source

pub fn new(scene: SceneHandle, platform: PlatformKind) -> Self

Creates a new Context with reactive viewport, theme, and safe-area signals.

§Arguments
  • SceneHandle - Shared scene handle.
  • PlatformKind - Active platform kind.
§Returns
  • Self - Constructed build context.
Source

pub fn elapsed_ms(&self) -> u64

Returns the monotonic runtime elapsed clock in milliseconds.

§Arguments
  • &Self - Context reference.
§Returns
  • u64 - Elapsed runtime time in milliseconds.
Source

pub fn request_exit(&self)

Requests graceful OS-level application termination across all platforms.

§Arguments
  • &Self - Context reference.
Source

pub fn view(&mut self, style: Style) -> NodeId

Creates a View node with the given style.

§Arguments
  • &Self - Build context.
  • Style - Initial style.
§Returns
  • NodeId - Created node handle.
Source

pub fn text(&mut self, content: String, style: Style) -> NodeId

Creates a Text node with static initial text.

§Arguments
  • &Self - Build context.
  • String - Text content.
  • Style - Text style.
§Returns
  • NodeId - Created node handle.
Source

pub fn reactive_text<F>(&mut self, style: Style, producer: F) -> NodeId
where F: FnMut() -> String + 'static,

Creates a reactive Text node whose content updates surgically whenever tracked signals change.

§Arguments
  • &Self - Build context.
  • Style - Text style.
  • F - Reactive text producer.
§Returns
  • NodeId - Created reactive text node handle.
Source

pub fn scroll_view(&mut self, style: Style) -> NodeId

Creates a ScrollView node with the given style.

§Arguments
  • &Self - Build context.
  • Style - Scroll container style.
§Returns
  • NodeId - Created scroll view handle.
Source

pub fn input(&mut self, state: InputNodeState, style: Style) -> NodeId

Creates an Input node with initial state and style.

§Arguments
  • &Self - Build context.
  • InputNodeState - Initial input state.
  • Style - Input style.
§Returns
  • NodeId - Created input handle.
Source

pub fn image(&mut self, buffer: ImageBuffer, style: Style) -> NodeId

Creates an Image node with decoded RGBA8 pixel data.

§Arguments
  • &Self - Build context.
  • ImageBuffer - Image buffer.
  • Style - Image style.
§Returns
  • NodeId - Created image handle.
Source

pub fn canvas<F>(&mut self, style: Style, painter: F) -> NodeId
where F: FnMut(Rect, &mut DisplayList) + 'static,

Creates a Canvas node bound to a custom draw callback.

§Arguments
  • &Self - Build context.
  • Style - Canvas style.
  • F - Draw callback receiving node bounds and mutable DisplayList.
§Returns
  • NodeId - Created canvas handle.
Source

pub fn portal(&mut self, style: Style) -> NodeId

Creates an overlay Portal node.

§Arguments
  • &Self - Build context.
  • Style - Portal style.
§Returns
  • NodeId - Created portal handle.
Source

pub fn fragment(&mut self) -> NodeId

Creates a transparent logical Fragment grouping container for sibling nodes.

§Arguments
  • &Self - Build context.
§Returns
  • NodeId - Created fragment handle.
Source

pub fn append(&mut self, parent: NodeId, child: NodeId)

Appends child to parent.

§Arguments
  • &Self - Build context.
  • NodeId - Parent container.
  • NodeId - Child node.
Source

pub fn append_many(&mut self, parent: NodeId, children: &[NodeId])

Appends a slice of children to parent under a single scene write lock and dirty pass.

§Arguments
  • &Self - Build context.
  • NodeId - Parent container.
  • &[NodeId] - Ordered child node slice.
Source

pub fn bind_style<F>(&mut self, node_id: NodeId, producer: F)
where F: FnMut() -> Style + 'static,

Binds a reactive Style closure to node_id and attaches its disposal Scope automatically.

§Arguments
  • &Self - Build context.
  • NodeId - Target scene node.
  • F - Reactive Style producer closure.
Source

pub fn on_pointer_enter<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a pointer-enter handler on node_id.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Pointer-enter callback closure.
Source

pub fn on_pointer_leave<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a pointer-leave handler on node_id.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Pointer-leave callback closure.
Source

pub fn on_focus<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a focus-gained handler on node_id and marks it focusable.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Focus callback closure receiving UiEventKind::Focus.
Source

pub fn on_blur<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a focus-lost handler on node_id.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Blur callback closure receiving UiEventKind::Blur.
Source

pub fn set_focusable(&mut self, node_id: NodeId, focusable: bool)

Configures whether node_id participates in keyboard focus navigation.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • bool - Whether keyboard focus is enabled.
Source

pub fn on_click<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a click handler on node_id and sets pointer cursor automatically.

§Arguments
  • &Self - Build context.
  • NodeId - Target node.
  • F - Click callback closure.
Source

pub fn on_change<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a change handler on an Input node.

§Arguments
  • &Self - Build context.
  • NodeId - Target input node.
  • F - Change callback closure.
Source

pub fn set_a11y(&mut self, node_id: NodeId, props: A11yProps)

Attaches semantic accessibility properties to node_id.

§Arguments
  • &Self - Build context.
  • NodeId - Target scene node.
  • A11yProps - Semantic role, label, hint, and state metadata.
Source

pub fn on_scroll<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a scroll handler on a scrollable container node.

§Arguments
  • &Self - Build context.
  • NodeId - Target scroll container node.
  • F - Scroll callback closure receiving UiEventKind::Scroll(delta).
Source

pub fn on_pointer_down<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a pointer-down handler on node_id for draggable interactive controls.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Pointer-down callback closure.
Source

pub fn on_pointer_move<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a pointer-move handler on node_id receiving captured drag coordinates while pressed.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Pointer-move callback closure.
Source

pub fn on_pointer_up<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a pointer-up handler on node_id invoked when drag capture releases.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Pointer-up callback closure.
Source

pub fn on_hover<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a hover handler on node_id invoked on both PointerEnter and PointerLeave.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Hover callback closure receiving UiEventKind::PointerEnter or PointerLeave.
Source

pub fn on_key<F>(&mut self, node_id: NodeId, callback: F)
where F: FnMut(&UiEvent) + 'static,

Registers a keyboard key-down handler on node_id and marks it focusable.

§Arguments
  • &Self - Build context.
  • NodeId - Target node handle.
  • F - Key-down callback closure receiving UiEventKind::KeyDown.
Source

pub fn set_virtual_scroll( &mut self, node_id: NodeId, scroll_y: f32, content_height: f32, )

Records virtualized scroll progress on node_id so the overlay scrollbar tracks accurately.

§Arguments
  • &Self - Build context.
  • NodeId - Target virtualized scroll container.
  • f32 - Active virtual vertical scroll offset in logical pixels.
  • f32 - Full virtualized content height in logical pixels.
Source

pub fn set_scroll_offset(&mut self, node_id: NodeId, offset: Point)

Sets the concrete inner pixel scroll offset on node_id (used by virtualized lists for sub-pixel alignment).

§Arguments
  • &Self - Build context.
  • NodeId - Target scroll container.
  • Point - Scroll offset (x, y) in logical pixels.
Source

pub fn start_transition(&mut self, transition: NodeTransition)

Starts a smooth paint/transform transition on transition.get_node().

§Arguments
  • &Self - Build context.
  • NodeTransition - Transition specification.
Source

pub fn bind_children<F>(&mut self, host: NodeId, builder: F)
where F: FnMut() -> Vec<NodeId> + 'static,

Mounts a reactive dynamic subtree whose children rebuild cleanly inside an isolated Scope.

§Arguments
  • &Self - Build context.
  • NodeId - Host container node.
  • F - Reactive zero-ctx builder returning child NodeId values.
Source§

impl Context

Source

pub fn get_scene(&self) -> &SceneHandle

Source

pub fn get_mut_scene(&mut self) -> &mut SceneHandle

Source

pub fn set_scene(&mut self, val: SceneHandle) -> &mut Self

Source

pub fn get_breakpoint(&self) -> Signal<Breakpoint>

Source

pub fn get_mut_breakpoint(&mut self) -> &mut Signal<Breakpoint>

Source

pub fn set_breakpoint(&mut self, val: Signal<Breakpoint>) -> &mut Self

Source

pub fn get_viewport_size(&self) -> Signal<Size>

Source

pub fn get_mut_viewport_size(&mut self) -> &mut Signal<Size>

Source

pub fn set_viewport_size(&mut self, val: Signal<Size>) -> &mut Self

Source

pub fn get_theme_mode(&self) -> Signal<ThemeMode>

Source

pub fn get_mut_theme_mode(&mut self) -> &mut Signal<ThemeMode>

Source

pub fn set_theme_mode(&mut self, val: Signal<ThemeMode>) -> &mut Self

Source

pub fn get_platform(&self) -> PlatformKind

Source

pub fn get_mut_platform(&mut self) -> &mut PlatformKind

Source

pub fn set_platform(&mut self, val: PlatformKind) -> &mut Self

Source

pub fn get_safe_area(&self) -> Signal<SafeAreaInsets>

Source

pub fn get_mut_safe_area(&mut self) -> &mut Signal<SafeAreaInsets>

Source

pub fn set_safe_area(&mut self, val: Signal<SafeAreaInsets>) -> &mut Self

Source

pub fn get_gesture(&self) -> Signal<Option<GestureEvent>>

Source

pub fn get_mut_gesture(&mut self) -> &mut Signal<Option<GestureEvent>>

Source

pub fn set_gesture(&mut self, val: Signal<Option<GestureEvent>>) -> &mut Self

Source

pub fn get_system_back(&self) -> Signal<u64>

Source

pub fn get_mut_system_back(&mut self) -> &mut Signal<u64>

Source

pub fn set_system_back(&mut self, val: Signal<u64>) -> &mut Self

Source

pub fn get_dynamic_hub(&self) -> &DynamicUpdateHub

Source

pub fn get_mut_dynamic_hub(&mut self) -> &mut DynamicUpdateHub

Source

pub fn set_dynamic_hub(&mut self, val: DynamicUpdateHub) -> &mut Self

Source

pub fn get_fps_limit(&self) -> Signal<Option<u32>>

Source

pub fn get_mut_fps_limit(&mut self) -> &mut Signal<Option<u32>>

Source

pub fn set_fps_limit(&mut self, val: Signal<Option<u32>>) -> &mut Self

Source

pub fn get_live_fps(&self) -> Signal<f32>

Source

pub fn get_mut_live_fps(&mut self) -> &mut Signal<f32>

Source

pub fn set_live_fps(&mut self, val: Signal<f32>) -> &mut Self

Source

pub fn get_active_touches(&self) -> Signal<Vec<(u64, Point)>>

Source

pub fn get_mut_active_touches(&mut self) -> &mut Signal<Vec<(u64, Point)>>

Source

pub fn set_active_touches( &mut self, val: Signal<Vec<(u64, Point)>>, ) -> &mut Self

Source

pub fn get_exit_requested(&self) -> Signal<bool>

Source

pub fn get_mut_exit_requested(&mut self) -> &mut Signal<bool>

Source

pub fn set_exit_requested(&mut self, val: Signal<bool>) -> &mut Self

Source

pub fn get_mut_clock_ms(&mut self) -> &mut Rc<Cell<u64>>

Source

pub fn set_clock_ms(&mut self, val: Rc<Cell<u64>>) -> &mut Self

Trait Implementations§

Source§

impl Clone for Context

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
Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the struct fields as a debug struct, skipping excluded fields.

§Arguments
  • &mut ::std::fmt::Formatter<'_> - The formatter to write the representation into.
§Returns
  • ::std::fmt::Result - Success or failure of the formatting operation.

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<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> 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> 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.