Skip to main content

RemovedItem

Struct RemovedItem 

Source
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

Source

pub fn id(&self) -> ItemId

The id this item had, and the id Scene::restore puts it back at.

Source

pub fn local_pos(&self) -> Point

Position in the parent’s coordinate frame.

Source

pub fn local_bounds(&self) -> Rect

AABB in local coordinates.

Source

pub fn transform(&self) -> Transform2D

Local→parent transform.

Source

pub fn z(&self) -> f32

Paint z-order.

Source

pub fn layer(&self) -> SceneLayer

Lightweight paint band.

Source

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.

Source

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.

Source

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.

Source

pub fn flags(&self) -> ItemFlags

Behaviour flags.

Source

pub fn opacity(&self) -> f32

Local opacity multiplier.

Source

pub fn is_widget(&self) -> bool

Whether this was a heavyweight Widget entry rather than a lightweight SceneItem one.

Source

pub fn item(&self) -> Option<&dyn SceneItem>

The lightweight item, if this was one. None for widget entries.

Source

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

Source

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.

Source

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.

Source

pub fn a11y(&self) -> &ItemA11yDecorations

The logical-AT decorations this item carried — both directions of every edge. See ItemA11yDecorations.

Source

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§

Source§

impl Debug for RemovedItem

Source§

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

Hand-written: SceneEntry holds a Box<dyn SceneItem> or a Box<dyn Widget> plus an Option<Box<SceneItemHandlerSet>>, and Magnet is Clone only — none of the three is Debug, so this cannot be derived.

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
§

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

§

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

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more