pub struct SceneModel(/* private fields */);Expand description
A shared, cloneable handle to a Scene.
Implementations§
Source§impl SceneModel
impl SceneModel
Sourcepub fn with_index(index: Box<dyn SpatialIndex>) -> Self
pub fn with_index(index: Box<dyn SpatialIndex>) -> Self
A handle to a fresh scene with a custom SpatialIndex.
Sourcepub fn from_scene(scene: Scene) -> Self
pub fn from_scene(scene: Scene) -> Self
Wrap an existing Scene in a handle. Used by
SceneView::new for the single-view path.
Sourcepub fn handle_count(&self) -> usize
pub fn handle_count(&self) -> usize
Number of distinct handles to this scene (1 = unshared).
Sourcepub fn add_widget<W: Widget + 'static>(&self, widget: W, rect: Rect) -> ItemId
pub fn add_widget<W: Widget + 'static>(&self, widget: W, rect: Rect) -> ItemId
Single-view heavyweight widget (the one-shot Once path). The first
view to build drains it; a second view sharing this model produces no
child for it. For multi-view, use add_widget_item.
Sourcepub fn add_widget_item<P: 'static>(&self, payload: P, rect: Rect) -> ItemId
pub fn add_widget_item<P: 'static>(&self, payload: P, rect: Rect) -> ItemId
Multi-view heavyweight item: store a typed payload; each view builds
its own widget instance from it via its delegate. Returns the ItemId.
Sourcepub fn set_payload<P: 'static>(&self, id: ItemId, payload: P)
pub fn set_payload<P: 'static>(&self, id: ItemId, payload: P)
Replace the payload of a Delegated heavyweight item; every view
rebuilds that item’s widget on the next pass.
§Panics
Panics if id is unknown, refers to a single-view add_widget (Once)
entry, or refers to a lightweight item.
Sourcepub fn payload(&self, id: ItemId) -> Option<Rc<dyn Any>>
pub fn payload(&self, id: ItemId) -> Option<Rc<dyn Any>>
The current type-erased payload of a Delegated item, if any.
Sourcepub fn add_item<I: SceneItem + 'static>(
&self,
item: I,
local_pos: Point,
) -> ItemId
pub fn add_item<I: SceneItem + 'static>( &self, item: I, local_pos: Point, ) -> ItemId
Add a lightweight SceneItem at local_pos.
Sourcepub fn add_item_dynamic<I: SceneItem + 'static>(
&self,
item: I,
local_pos: Point,
) -> ItemId
pub fn add_item_dynamic<I: SceneItem + 'static>( &self, item: I, local_pos: Point, ) -> ItemId
Add a lightweight item with signal-driven (dynamic) bounds.
Sourcepub fn add_boxed_item(
&self,
item: Box<dyn SceneItem>,
local_pos: Point,
) -> ItemId
pub fn add_boxed_item( &self, item: Box<dyn SceneItem>, local_pos: Point, ) -> ItemId
Add an already-boxed lightweight item at local_pos. The boxed-dyn
counterpart of add_item, used by
SceneListAdapter.
Sourcepub fn set_local_pos(&self, id: ItemId, local_pos: Point)
pub fn set_local_pos(&self, id: ItemId, local_pos: Point)
Move id to local_pos in its parent’s coordinate space; notifies all views.
Sourcepub fn set_local_bounds(&self, id: ItemId, local_bounds: Rect)
pub fn set_local_bounds(&self, id: ItemId, local_bounds: Rect)
Replace the local bounding rect of id; notifies all views.
Sourcepub fn set_transform(&self, id: ItemId, transform: Transform2D)
pub fn set_transform(&self, id: ItemId, transform: Transform2D)
Set an additional local-to-parent transform (rotation, scale) on id; notifies all views.
Sourcepub fn set_flags(&self, id: ItemId, flags: ItemFlags)
pub fn set_flags(&self, id: ItemId, flags: ItemFlags)
Replace the complete ItemFlags bitset for id; notifies all views.
Sourcepub fn set_flag(&self, id: ItemId, flag: ItemFlags, on: bool)
pub fn set_flag(&self, id: ItemId, flag: ItemFlags, on: bool)
Set or clear a single ItemFlags bit on id; notifies all views.
Sourcepub fn set_visible(&self, id: ItemId, visible: bool)
pub fn set_visible(&self, id: ItemId, visible: bool)
Show or hide id (also hides its descendants); notifies all views.
Sourcepub fn set_opacity(&self, id: ItemId, opacity: f32)
pub fn set_opacity(&self, id: ItemId, opacity: f32)
Set the paint opacity of id (0.0 = transparent, 1.0 = opaque); notifies all views.
Sourcepub fn set_item_fill(&self, id: ItemId, fill: impl Into<ColorProp>)
pub fn set_item_fill(&self, id: ItemId, fill: impl Into<ColorProp>)
Replace a lightweight item’s fill colour live; every view repaints
(no relayout/rebuild). Accepts a plain Color,
a theme role, a Signal<Color>, or a Signal<Role>. See
Scene::set_item_fill for the reactive-colour contract.
Sourcepub fn clear_item_fill(&self, id: ItemId)
pub fn clear_item_fill(&self, id: ItemId)
Clear a lightweight item’s fill; every view repaints.
Sourcepub fn set_item_stroke(
&self,
id: ItemId,
color: impl Into<ColorProp>,
style: StrokeStyle,
)
pub fn set_item_stroke( &self, id: ItemId, color: impl Into<ColorProp>, style: StrokeStyle, )
Replace a lightweight item’s stroke (colour + [StrokeStyle]) live;
every view repaints (no relayout/rebuild).
Sourcepub fn clear_item_stroke(&self, id: ItemId)
pub fn clear_item_stroke(&self, id: ItemId)
Clear a lightweight item’s stroke; every view repaints.
Sourcepub fn set_z(&self, id: ItemId, z: f32)
pub fn set_z(&self, id: ItemId, z: f32)
Set the z-order of id within its layer; higher values paint on top.
Sourcepub fn bring_to_front(&self, id: ItemId)
pub fn bring_to_front(&self, id: ItemId)
Give id the highest z-value in its layer so it paints on top of all siblings.
Sourcepub fn send_to_back(&self, id: ItemId)
pub fn send_to_back(&self, id: ItemId)
Give id the lowest z-value in its layer so it paints beneath all siblings.
Sourcepub fn set_layer(&self, id: ItemId, layer: SceneLayer)
pub fn set_layer(&self, id: ItemId, layer: SceneLayer)
Move id to a different SceneLayer (background, default, foreground); notifies all views.
Sourcepub fn set_item_parent(&self, child: ItemId, parent: Option<ItemId>)
pub fn set_item_parent(&self, child: ItemId, parent: Option<ItemId>)
Re-parent child under parent (or under the scene root when None); notifies all views.
Sourcepub fn remove(&self, id: ItemId)
pub fn remove(&self, id: ItemId)
Remove an item and its descendants. Drops any Delegated payload Rc
and cleans the item’s a11y mappings; alive logical children re-root.
Sourcepub fn set_item_handlers(
&self,
id: ItemId,
handlers: Option<SceneItemHandlerSet>,
)
pub fn set_item_handlers( &self, id: ItemId, handlers: Option<SceneItemHandlerSet>, )
Replace the SceneItemHandlerSet of id, or clear it with None.
Sourcepub fn with_handlers_mut<R>(
&self,
id: ItemId,
f: impl FnOnce(&mut SceneItemHandlerSet) -> R,
) -> Option<R>
pub fn with_handlers_mut<R>( &self, id: ItemId, f: impl FnOnce(&mut SceneItemHandlerSet) -> R, ) -> Option<R>
Mutate an item’s handler set through a closure (avoids returning a
borrow guard tied to the RefMut).
Sourcepub fn add_magnet(&self, item: ItemId, magnet: Magnet) -> MagnetId
pub fn add_magnet(&self, item: ItemId, magnet: Magnet) -> MagnetId
Attach a Magnet to item; see Scene::add_magnet.
Sourcepub fn remove_magnet(&self, magnet: MagnetId)
pub fn remove_magnet(&self, magnet: MagnetId)
Remove a magnet by id; see Scene::remove_magnet.
Sourcepub fn clear_magnets(&self, item: ItemId)
pub fn clear_magnets(&self, item: ItemId)
Remove every magnet on item; see Scene::clear_magnets.
Sourcepub fn set_magnet_local_pos(&self, magnet: MagnetId, local_pos: Point)
pub fn set_magnet_local_pos(&self, magnet: MagnetId, local_pos: Point)
Move a magnet in its item’s local frame; see Scene::set_magnet_local_pos.
Sourcepub fn set_magnet_enabled(&self, magnet: MagnetId, enabled: bool)
pub fn set_magnet_enabled(&self, magnet: MagnetId, enabled: bool)
Enable or disable a magnet; see Scene::set_magnet_enabled.
Sourcepub fn magnet_ids_of(&self, item: ItemId) -> Vec<MagnetId>
pub fn magnet_ids_of(&self, item: ItemId) -> Vec<MagnetId>
Ids of every magnet on item; see Scene::magnet_ids_of.
Sourcepub fn magnet_owner(&self, magnet: MagnetId) -> Option<ItemId>
pub fn magnet_owner(&self, magnet: MagnetId) -> Option<ItemId>
The owning item of a magnet; see Scene::magnet_owner.
Sourcepub fn magnet_scene_pos(&self, magnet: MagnetId) -> Option<Point>
pub fn magnet_scene_pos(&self, magnet: MagnetId) -> Option<Point>
A magnet’s scene position; see Scene::magnet_scene_pos.
Sourcepub fn magnet(&self, magnet: MagnetId) -> Option<MagnetRef>
pub fn magnet(&self, magnet: MagnetId) -> Option<MagnetRef>
Resolve a magnet to a MagnetRef snapshot; see Scene::magnet.
Sourcepub fn compute_item_snap(
&self,
dragged: ItemId,
drag_delta: Vec2,
capture_radius: f32,
predicate: &dyn Fn(&MagnetRef, &MagnetRef) -> MagnetVerdict,
) -> Option<MagnetSnap>
pub fn compute_item_snap( &self, dragged: ItemId, drag_delta: Vec2, capture_radius: f32, predicate: &dyn Fn(&MagnetRef, &MagnetRef) -> MagnetVerdict, ) -> Option<MagnetSnap>
Best item-drag snap; see Scene::compute_item_snap. A shared
(read-only) borrow is held while the predicate runs over owned
candidate snapshots, so the predicate may read but must not mutate
the model.
Sourcepub fn compute_port_snap(
&self,
source: MagnetId,
cursor_scene: Point,
capture_radius: f32,
predicate: &dyn Fn(&MagnetRef, &MagnetRef) -> MagnetVerdict,
) -> Option<(MagnetRef, Option<Rc<dyn Any>>)>
pub fn compute_port_snap( &self, source: MagnetId, cursor_scene: Point, capture_radius: f32, predicate: &dyn Fn(&MagnetRef, &MagnetRef) -> MagnetVerdict, ) -> Option<(MagnetRef, Option<Rc<dyn Any>>)>
Best port-drag snap; see Scene::compute_port_snap.
Sourcepub fn nearest_magnet(&self, scene_pt: Point, radius: f32) -> Option<MagnetId>
pub fn nearest_magnet(&self, scene_pt: Point, radius: f32) -> Option<MagnetId>
Nearest enabled magnet within radius; see Scene::nearest_magnet.
Sourcepub fn set_scene_rect(&self, rect: Option<Rect>)
pub fn set_scene_rect(&self, rect: Option<Rect>)
Set the logical extent of the scene (used for scroll-bar sizing); None = unbounded.
Sourcepub fn pan_axes(&self, axes: PanAxes)
pub fn pan_axes(&self, axes: PanAxes)
Restrict panning to horizontal, vertical, or both axes; updates pan_axes_signal.
Sourcepub fn zoomable(&self, on: bool)
pub fn zoomable(&self, on: bool)
Enable or disable pinch/scroll zoom; updates zoomable_signal.
Sourcepub fn set_pan_bounds(&self, bounds: Option<Rect>)
pub fn set_pan_bounds(&self, bounds: Option<Rect>)
Clamp the camera pan to bounds (scene coordinates); None = no limit; updates pan_bounds_signal.
Sourcepub fn set_zoom_range(&self, range: Option<RangeInclusive<f32>>)
pub fn set_zoom_range(&self, range: Option<RangeInclusive<f32>>)
Restrict the zoom factor to range; None = no limit; updates zoom_range_signal.
Sourcepub fn add_a11y_group(&self, builder: A11yGroupBuilder) -> A11yGroupId
pub fn add_a11y_group(&self, builder: A11yGroupBuilder) -> A11yGroupId
Register a logical AT group (landmark / rotor category container); returns its stable A11yGroupId.
Sourcepub fn remove_a11y_group(&self, id: A11yGroupId)
pub fn remove_a11y_group(&self, id: A11yGroupId)
Remove a previously registered AT group; triggers an a11y_change_signal bump.
Sourcepub fn set_a11y_parent(&self, child: A11yNode, parent: Option<A11yNode>)
pub fn set_a11y_parent(&self, child: A11yNode, parent: Option<A11yNode>)
Re-parent child in the AT tree, overriding the default visual parent; None re-attaches under the scene root.
Sourcepub fn add_a11y_relation(
&self,
from: A11yNode,
kind: A11yRelation,
to: A11yNode,
)
pub fn add_a11y_relation( &self, from: A11yNode, kind: A11yRelation, to: A11yNode, )
Declare a cross-node AT relationship (controls, describes, labels) from from to to.
Sourcepub fn set_a11y_live(&self, node: A11yNode, live: Live)
pub fn set_a11y_live(&self, node: A11yNode, live: Live)
Mark node as a live region (Polite or Assertive) so assistive tech announces changes to it.
Sourcepub fn set_a11y_landmark(&self, node: A11yNode, role: Role)
pub fn set_a11y_landmark(&self, node: A11yNode, role: Role)
Assign a landmark role to node (e.g. Role::Region, Role::Main) for rotor navigation.
Sourcepub fn set_a11y_categories(&self, node: A11yNode, categories: &[A11yCategory])
pub fn set_a11y_categories(&self, node: A11yNode, categories: &[A11yCategory])
Register node under the given rotor A11yCategory slices so it appears in category-filtered navigation.
Sourcepub fn refresh_dynamic_bounds(&self) -> bool
pub fn refresh_dynamic_bounds(&self) -> bool
Re-read signal-driven bounds for add_item_dynamic entries; returns
true if any changed.
Sourcepub fn item_change_signal(&self) -> Signal<ItemChange>
pub fn item_change_signal(&self) -> Signal<ItemChange>
Reactive signal fired on every structural scene change; all views observe this to reconcile.
Sourcepub fn a11y_change_signal(&self) -> Signal<u64>
pub fn a11y_change_signal(&self) -> Signal<u64>
Reactive monotonic counter bumped on every AT-structure change; views re-walk accessibility on any increment.
Sourcepub fn mutation_version(&self) -> u64
pub fn mutation_version(&self) -> u64
Monotonic counter incremented on every mutation; useful for cache invalidation without observing a signal.
Sourcepub fn pan_axes_signal(&self) -> Signal<PanAxes>
pub fn pan_axes_signal(&self) -> Signal<PanAxes>
Sourcepub fn pan_bounds_signal(&self) -> Signal<Option<Rect>>
pub fn pan_bounds_signal(&self) -> Signal<Option<Rect>>
Reactive camera-pan clamp bounds; updated by set_pan_bounds.
Sourcepub fn zoom_range_signal(&self) -> Signal<Option<RangeInclusive<f32>>>
pub fn zoom_range_signal(&self) -> Signal<Option<RangeInclusive<f32>>>
Reactive zoom-factor clamp range; updated by set_zoom_range.
Sourcepub fn zoomable_signal(&self) -> Signal<bool>
pub fn zoomable_signal(&self) -> Signal<bool>
Reactive zoom-enabled flag; updated by zoomable.
Sourcepub fn local_pos(&self, id: ItemId) -> Option<Point>
pub fn local_pos(&self, id: ItemId) -> Option<Point>
The local position of id in its parent’s coordinate space; None if id is unknown.
Sourcepub fn local_bounds(&self, id: ItemId) -> Option<Rect>
pub fn local_bounds(&self, id: ItemId) -> Option<Rect>
The local bounding rect of id; None if id is unknown.
Sourcepub fn transform(&self, id: ItemId) -> Option<Transform2D>
pub fn transform(&self, id: ItemId) -> Option<Transform2D>
The additional local-to-parent transform of id (beyond position); None if none is set.
Sourcepub fn scene_transform(&self, id: ItemId) -> Transform2D
pub fn scene_transform(&self, id: ItemId) -> Transform2D
The full local-to-scene transform for id (parent chain composed); identity if id is unknown.
Sourcepub fn scene_pos(&self, id: ItemId) -> Option<Point>
pub fn scene_pos(&self, id: ItemId) -> Option<Point>
The origin of id mapped into scene coordinates; None if id is unknown.
Sourcepub fn scene_rect(&self, id: ItemId) -> Option<Rect>
pub fn scene_rect(&self, id: ItemId) -> Option<Rect>
The bounding rect of id in scene coordinates (local bounds transformed by the parent chain); None if unknown.
Sourcepub fn flags(&self, id: ItemId) -> Option<ItemFlags>
pub fn flags(&self, id: ItemId) -> Option<ItemFlags>
The ItemFlags bitset of id; None if id is unknown.
Sourcepub fn is_effectively_visible(&self, id: ItemId) -> bool
pub fn is_effectively_visible(&self, id: ItemId) -> bool
Returns true if id and all of its ancestors are visible.
Sourcepub fn opacity(&self, id: ItemId) -> Option<f32>
pub fn opacity(&self, id: ItemId) -> Option<f32>
The own opacity of id (ignoring ancestors); None if id is unknown.
Sourcepub fn effective_opacity(&self, id: ItemId) -> f32
pub fn effective_opacity(&self, id: ItemId) -> f32
Accumulated opacity for id (own × each ancestor’s opacity).
Sourcepub fn z(&self, id: ItemId) -> Option<f32>
pub fn z(&self, id: ItemId) -> Option<f32>
The z-order value of id within its layer; None if id is unknown.
Sourcepub fn layer(&self, id: ItemId) -> Option<SceneLayer>
pub fn layer(&self, id: ItemId) -> Option<SceneLayer>
The SceneLayer of id; None if id is unknown.
Sourcepub fn parent_of(&self, id: ItemId) -> Option<ItemId>
pub fn parent_of(&self, id: ItemId) -> Option<ItemId>
The direct parent of id, or None if it is a root item (or unknown).
Sourcepub fn is_descendant_of(&self, id: ItemId, ancestor: ItemId) -> bool
pub fn is_descendant_of(&self, id: ItemId, ancestor: ItemId) -> bool
Returns true if id is anywhere in ancestor’s subtree.
Sourcepub fn scene_rect_extent(&self) -> Option<Rect>
pub fn scene_rect_extent(&self) -> Option<Rect>
The logical extent set via set_scene_rect; None = unbounded.
Sourcepub fn current_pan_axes(&self) -> PanAxes
pub fn current_pan_axes(&self) -> PanAxes
The current pan-axis restriction without subscribing to its signal.
Sourcepub fn is_zoomable(&self) -> bool
pub fn is_zoomable(&self) -> bool
Returns true if zoom is currently enabled (snapshot; use zoomable_signal for reactivity).
Sourcepub fn current_pan_bounds(&self) -> Option<Rect>
pub fn current_pan_bounds(&self) -> Option<Rect>
Current pan-clamp bounds without subscribing to its signal.
Sourcepub fn current_zoom_range(&self) -> Option<RangeInclusive<f32>>
pub fn current_zoom_range(&self) -> Option<RangeInclusive<f32>>
Current zoom-factor clamp range without subscribing to its signal.
Sourcepub fn items_in_rect(&self, scene_rect: Rect) -> Vec<ItemId>
pub fn items_in_rect(&self, scene_rect: Rect) -> Vec<ItemId>
All items whose bounding rects overlap scene_rect (spatial-index query).
Sourcepub fn item_at(&self, scene_pt: Point) -> Option<ItemId>
pub fn item_at(&self, scene_pt: Point) -> Option<ItemId>
The topmost item under scene_pt using exact-shape hit-testing; None if no item is hit.
Sourcepub fn items_at(&self, scene_pt: Point) -> Vec<ItemId>
pub fn items_at(&self, scene_pt: Point) -> Vec<ItemId>
All items under scene_pt (exact-shape hit-test), ordered front-to-back.
Sourcepub fn colliding_items(&self, id: ItemId) -> Vec<ItemId>
pub fn colliding_items(&self, id: ItemId) -> Vec<ItemId>
All items whose bounding rects intersect id’s bounding rect.
Sourcepub fn a11y_parent_of(&self, child: A11yNode) -> Option<A11yNode>
pub fn a11y_parent_of(&self, child: A11yNode) -> Option<A11yNode>
The AT-tree parent of child as set by set_a11y_parent; None = visual default.
Trait Implementations§
Source§impl Clone for SceneModel
impl Clone for SceneModel
Source§impl Debug for SceneModel
impl Debug for SceneModel
Auto Trait Implementations§
impl !RefUnwindSafe for SceneModel
impl !Send for SceneModel
impl !Sync for SceneModel
impl !UnwindSafe for SceneModel
impl Freeze for SceneModel
impl Unpin for SceneModel
impl UnsafeUnpin for SceneModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more