pub struct Scene { /* private fields */ }Expand description
Host-independent retained scene for one surface.
The scene begins in snapshot mode. After a frame is prepared, mutations are rejected until the caller accepts or discards it. This makes clearing the journal on acceptance lossless without requiring a second concurrent dirty generation.
Implementations§
Source§impl Scene
impl Scene
Sourcepub fn hit_test(
&self,
root: NodeId,
point: InputPoint,
) -> Result<Option<NodeId>, SceneError>
pub fn hit_test( &self, root: NodeId, point: InputPoint, ) -> Result<Option<NodeId>, SceneError>
Finds the visually topmost node at one surface-space point.
Sourcepub fn text_span_at(
&self,
node: NodeId,
point: InputPoint,
) -> Option<TextSpanId>
pub fn text_span_at( &self, node: NodeId, point: InputPoint, ) -> Option<TextSpanId>
Resolves a visible inline source span at a surface-space pointer position.
Source§impl Scene
impl Scene
Sourcepub fn new(surface: SurfaceId) -> Self
pub fn new(surface: SurfaceId) -> Self
Creates an empty scene that will emit a snapshot on its first frame.
Sourcepub fn with_protocol(surface: SurfaceId, protocol: ProtocolVersion) -> Self
pub fn with_protocol(surface: SurfaceId, protocol: ProtocolVersion) -> Self
Creates an empty scene using the version selected with its Host.
Sourcepub const fn scene_epoch(&self) -> u32
pub const fn scene_epoch(&self) -> u32
Returns the current scene epoch.
Sourcepub const fn accepted_revision(&self) -> u64
pub const fn accepted_revision(&self) -> u64
Returns the last renderer-accepted revision.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of live retained nodes.
Sourcepub fn node(&self, node: NodeId) -> Option<&SceneNode>
pub fn node(&self, node: NodeId) -> Option<&SceneNode>
Returns a retained node when it is live.
Sourcepub fn node_snapshot(&self, node: NodeId) -> Option<Arc<SceneNode>>
pub fn node_snapshot(&self, node: NodeId) -> Option<Arc<SceneNode>>
Retains an immutable node snapshot without copying its content or geometry.
Sourcepub fn pointer_capture_target(&self, pointer: PointerId) -> Option<NodeId>
pub fn pointer_capture_target(&self, pointer: PointerId) -> Option<NodeId>
Returns the node currently retaining one pointer capture.
Sourcepub fn has_pending_work(&self) -> bool
pub fn has_pending_work(&self) -> bool
Returns whether a snapshot, mutation, command, or retry needs a frame.
Sourcepub fn has_prepared_frame(&self) -> bool
pub fn has_prepared_frame(&self) -> bool
Returns whether a prepared frame is waiting for acceptance or discard.
Sourcepub fn create_node(
&mut self,
element_type: ElementTypeId,
) -> Result<NodeId, SceneError>
pub fn create_node( &mut self, element_type: ElementTypeId, ) -> Result<NodeId, SceneError>
Creates an unattached retained node and returns its epoch-unique ID.
Sourcepub fn delete_node(&mut self, node: NodeId) -> Result<(), SceneError>
pub fn delete_node(&mut self, node: NodeId) -> Result<(), SceneError>
Deletes a node and its complete retained subtree.
Sourcepub fn insert_child(
&mut self,
parent: NodeId,
child: NodeId,
index: u32,
) -> Result<(), SceneError>
pub fn insert_child( &mut self, parent: NodeId, child: NodeId, index: u32, ) -> Result<(), SceneError>
Attaches an unattached child at an index.
Sourcepub fn remove_child(
&mut self,
parent: NodeId,
child: NodeId,
) -> Result<(), SceneError>
pub fn remove_child( &mut self, parent: NodeId, child: NodeId, ) -> Result<(), SceneError>
Detaches a direct child without deleting it.
Sourcepub fn move_child(
&mut self,
parent: NodeId,
child: NodeId,
index: u32,
) -> Result<(), SceneError>
pub fn move_child( &mut self, parent: NodeId, child: NodeId, index: u32, ) -> Result<(), SceneError>
Moves a direct child within its current parent.
Sourcepub fn set_layout(
&mut self,
node: NodeId,
geometry: impl Into<LayoutGeometry>,
) -> Result<(), SceneError>
pub fn set_layout( &mut self, node: NodeId, geometry: impl Into<LayoutGeometry>, ) -> Result<(), SceneError>
Sets resolved layout when it differs from retained state.
Sourcepub fn set_box_paint(
&mut self,
node: NodeId,
paint: BoxPaint,
) -> Result<(), SceneError>
pub fn set_box_paint( &mut self, node: NodeId, paint: BoxPaint, ) -> Result<(), SceneError>
Sets background and border paint when it differs from retained state.
Sourcepub fn set_background_layers(
&mut self,
node: NodeId,
layers: Vec<BackgroundLayer>,
) -> Result<(), SceneError>
pub fn set_background_layers( &mut self, node: NodeId, layers: Vec<BackgroundLayer>, ) -> Result<(), SceneError>
Sets the ordered background image layers when they differ from retained state. An empty list clears every image while preserving box color.
Sourcepub fn set_visual_effects(
&mut self,
node: NodeId,
effects: VisualEffects,
) -> Result<(), SceneError>
pub fn set_visual_effects( &mut self, node: NodeId, effects: VisualEffects, ) -> Result<(), SceneError>
Sets resolved visual effects when they differ from retained state.
Sourcepub fn set_clip(
&mut self,
node: NodeId,
clip: BoxClip,
) -> Result<(), SceneError>
pub fn set_clip( &mut self, node: NodeId, clip: BoxClip, ) -> Result<(), SceneError>
Sets descendant overflow clipping when it differs from retained state.
Sourcepub fn set_transform(
&mut self,
node: NodeId,
transform: Transform,
) -> Result<(), SceneError>
pub fn set_transform( &mut self, node: NodeId, transform: Transform, ) -> Result<(), SceneError>
Sets a resolved transform when it differs from retained state.
Sourcepub fn set_opacity(
&mut self,
node: NodeId,
opacity: f32,
) -> Result<(), SceneError>
pub fn set_opacity( &mut self, node: NodeId, opacity: f32, ) -> Result<(), SceneError>
Sets resolved opacity when it differs from retained state.
Sourcepub fn set_visibility(
&mut self,
node: NodeId,
visibility: Visibility,
) -> Result<(), SceneError>
pub fn set_visibility( &mut self, node: NodeId, visibility: Visibility, ) -> Result<(), SceneError>
Sets resolved visibility when it differs from retained state.
Sourcepub fn set_z_order(
&mut self,
node: NodeId,
z_order: i32,
) -> Result<(), SceneError>
pub fn set_z_order( &mut self, node: NodeId, z_order: i32, ) -> Result<(), SceneError>
Sets resolved stacking order when it differs from retained state.
Sourcepub fn set_text(
&mut self,
node: NodeId,
content: TextContent,
) -> Result<(), SceneError>
pub fn set_text( &mut self, node: NodeId, content: TextContent, ) -> Result<(), SceneError>
Sets plain-text presentation when it differs from retained state.
Sourcepub fn set_text_style(
&mut self,
node: NodeId,
style: TextStyleSnapshot,
) -> Result<(), SceneError>
pub fn set_text_style( &mut self, node: NodeId, style: TextStyleSnapshot, ) -> Result<(), SceneError>
Sets a resolved inherited text-style snapshot when it differs from retained state.
Sourcepub fn set_property(
&mut self,
node: NodeId,
property: PropertyId,
value: WhiskerValue,
) -> Result<(), SceneError>
pub fn set_property( &mut self, node: NodeId, property: PropertyId, value: WhiskerValue, ) -> Result<(), SceneError>
Sets a typed property when it differs from retained state.
Sourcepub fn clear_property(
&mut self,
node: NodeId,
property: PropertyId,
) -> Result<(), SceneError>
pub fn clear_property( &mut self, node: NodeId, property: PropertyId, ) -> Result<(), SceneError>
Clears a typed property when it is present.
Sourcepub fn set_event_mask(
&mut self,
node: NodeId,
event_mask: u64,
) -> Result<(), SceneError>
pub fn set_event_mask( &mut self, node: NodeId, event_mask: u64, ) -> Result<(), SceneError>
Sets a node’s event subscription mask.
Sourcepub fn set_accessibility(
&mut self,
node: NodeId,
accessibility: Accessibility,
) -> Result<(), SceneError>
pub fn set_accessibility( &mut self, node: NodeId, accessibility: Accessibility, ) -> Result<(), SceneError>
Replaces a node’s common accessibility semantics.
Sourcepub fn set_hit_test(
&mut self,
node: NodeId,
behavior: HitTestBehavior,
) -> Result<(), SceneError>
pub fn set_hit_test( &mut self, node: NodeId, behavior: HitTestBehavior, ) -> Result<(), SceneError>
Sets a node’s Host hit-test participation.
Sourcepub fn update_host_scroll_offset(
&mut self,
node: NodeId,
offset: [f32; 2],
) -> Result<(), SceneError>
pub fn update_host_scroll_offset( &mut self, node: NodeId, offset: [f32; 2], ) -> Result<(), SceneError>
Updates transient Host-owned scroll state without producing a frame operation.
Native scrolling advances independently of frame delivery. Retaining its latest logical offset keeps Rust input routing aligned with the pixels the Host currently presents while leaving Rust-authored layout unchanged.
Sourcepub fn set_cursor(
&mut self,
node: NodeId,
cursor: Cursor,
) -> Result<(), SceneError>
pub fn set_cursor( &mut self, node: NodeId, cursor: Cursor, ) -> Result<(), SceneError>
Sets a node’s resolved pointing-device cursor.
Sourcepub fn set_pointer_capture(
&mut self,
node: NodeId,
pointer: PointerId,
) -> Result<(), SceneError>
pub fn set_pointer_capture( &mut self, node: NodeId, pointer: PointerId, ) -> Result<(), SceneError>
Captures a pointer when it is not already captured by this node.
Sourcepub fn release_pointer_capture(
&mut self,
node: NodeId,
pointer: PointerId,
) -> Result<(), SceneError>
pub fn release_pointer_capture( &mut self, node: NodeId, pointer: PointerId, ) -> Result<(), SceneError>
Releases a pointer when it is currently captured by this node.
Sourcepub fn release_pointer_captures(&mut self) -> Result<(), SceneError>
pub fn release_pointer_captures(&mut self) -> Result<(), SceneError>
Releases every captured pointer.
Sourcepub fn invoke_command(
&mut self,
node: NodeId,
command: CommandId,
arguments: WhiskerValue,
) -> Result<(), SceneError>
pub fn invoke_command( &mut self, node: NodeId, command: CommandId, arguments: WhiskerValue, ) -> Result<(), SceneError>
Queues an element command after preceding visual mutations.
Sourcepub fn prepare_frame(
&mut self,
viewport_epoch: u32,
) -> Result<Option<&FramePacket>, SceneError>
pub fn prepare_frame( &mut self, viewport_epoch: u32, ) -> Result<Option<&FramePacket>, SceneError>
Prepares the next snapshot or delta and keeps it pending.
Returns Ok(None) when the accepted scene is idle. Repeated calls while
a packet is pending return SceneError::FramePending; the caller must
first accept or discard that packet.
Sourcepub fn accept_pending(&mut self, revision: u64) -> Result<(), SceneError>
pub fn accept_pending(&mut self, revision: u64) -> Result<(), SceneError>
Commits the pending packet after renderer acceptance.
Sourcepub fn discard_pending(&mut self) -> Result<(), SceneError>
pub fn discard_pending(&mut self) -> Result<(), SceneError>
Discards a prepared packet after a transport or renderer failure.
Retained mutations remain dirty, so the next preparation retries the same semantic work with a new diagnostic frame ID.
Sourcepub fn require_snapshot(&mut self) -> Result<(), SceneError>
pub fn require_snapshot(&mut self) -> Result<(), SceneError>
Switches the next frame to a full snapshot with a new scene epoch.
This is called after a renderer returns NeedSnapshot. Any pending
delta is discarded, while retained state and queued commands remain.