pub struct RemovedItem { /* private fields */ }Expand description
One item lifted whole out of a Scene: its entry, its
magnets and its logical-AT decorations, still owned and still carrying its
original ItemId.
Opaque on purpose. It wraps the crate-private SceneEntry whole rather
than copying its fields out, so a future field added to the entry cannot be
missed by Scene::restore — the same argument the
single-construction-site rule makes for insertion.
§Ordering
Scene::take returns a subtree deepest-first, the
order remove already announces in.
Scene::restore_all reverses it for you;
restoring by hand means roots first, or a child hits
RestoreError::MissingParent.
Implementations§
Source§impl RemovedItem
impl RemovedItem
Sourcepub fn id(&self) -> ItemId
pub fn id(&self) -> ItemId
The id this item had, and the id
Scene::restore puts it back at.
Sourcepub fn local_bounds(&self) -> Rect
pub fn local_bounds(&self) -> Rect
AABB in local coordinates.
Sourcepub fn layer(&self) -> SceneLayer
pub fn layer(&self) -> SceneLayer
Lightweight paint band.
Sourcepub fn parent(&self) -> Option<ItemId>
pub fn parent(&self) -> Option<ItemId>
Logical parent at the moment of removal. A restore needs this item
present, or it fails with RestoreError::MissingParent.
Sourcepub fn detach(&mut self)
pub fn detach(&mut self)
Forget the recorded parent, so this salvage restores at root level.
The door RestoreError::MissingParent points at, and the one a
move between scenes needs: the parent a salvage names is still in the
scene it came from, so restoring a parented item into a second scene is
refused unless its parent went first — or unless the caller says, here,
that it should arrive unparented.
Nothing else changes: geometry is untouched, so an item that was placed
in its parent’s frame keeps those numbers and now reads them as scene
coordinates. Use
Scene::reparent_keeping_scene_pos
after the restore when the item should not visibly move.
Sourcepub fn children(&self) -> &[ItemId]
pub fn children(&self) -> &[ItemId]
Direct children at the moment of removal — all of them removed with it,
and all of them present in the same Scene::take
result.
Sourcepub fn is_widget(&self) -> bool
pub fn is_widget(&self) -> bool
Whether this was a heavyweight Widget entry rather than a lightweight
SceneItem one.
Sourcepub fn item(&self) -> Option<&dyn SceneItem>
pub fn item(&self) -> Option<&dyn SceneItem>
The lightweight item, if this was one. None for widget entries.
Sourcepub fn into_item(self) -> Option<Box<dyn SceneItem>>
pub fn into_item(self) -> Option<Box<dyn SceneItem>>
Consume the salvage for its lightweight item box — cut-to-clipboard.
None for widget entries (and the salvage is dropped either way).
Sourcepub fn payload(&self) -> Option<Rc<dyn Any>>
pub fn payload(&self) -> Option<Rc<dyn Any>>
The type-erased payload of a multi-view (Delegated) heavyweight
entry, which is what lets a restored card be rebuilt by every view’s
delegate. None for a lightweight item and for a single-view
(Scene::add_widget) entry.
Sourcepub fn widget_instance_present(&self) -> bool
pub fn widget_instance_present(&self) -> bool
Whether a single-view (Scene::add_widget) entry still carries its
one Box<dyn Widget>.
true for every lightweight item and for every multi-view
(add_widget_item) entry, because neither depends on a one-shot box.
This is a fact about the salvage, not a verdict on restorability,
and the distinction matters: a Once widget already drained by a
mounted view restores perfectly well when the take and the restore
happen inside one build cycle (the view’s orphan reap keys on the
scene’s live heavyweight set, which the restore has already put the id
back into, so the arena instance is never destroyed). Refusing such a
restore would refuse one that works — and would refuse the whole entry,
geometry and accessibility included, over a widget instance.
So Scene::restore always accepts, and this
reports what an app needs to decide for itself. When false and the
view has already reaped the instance, the restored entry is a
heavyweight slot with nothing to materialise — visible to no view. The
rule that avoids it entirely is the same one multi-view content already
follows: content that must survive an undo goes in through
SceneModel::add_widget_item,
whose payload every view can rebuild from.
Sourcepub fn a11y(&self) -> &ItemA11yDecorations
pub fn a11y(&self) -> &ItemA11yDecorations
The logical-AT decorations this item carried — both directions of every
edge. See ItemA11yDecorations.
Sourcepub fn magnet_count(&self) -> usize
pub fn magnet_count(&self) -> usize
How many magnets were attached to this item. Their ids are preserved by
a restore, so a consumer keying connections on
MagnetId keeps them.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RemovedItem
impl !Send for RemovedItem
impl !Sync for RemovedItem
impl !UnwindSafe for RemovedItem
impl Freeze for RemovedItem
impl Unpin for RemovedItem
impl UnsafeUnpin for RemovedItem
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
§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> ⓘ
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