#[non_exhaustive]pub struct Placement {
pub parent: Option<ItemId>,
pub z: f32,
pub local_pos: Point,
pub transform: Transform2D,
}Expand description
Where an item sits, as one property: logical parent, paint z, position in the parent frame, and local to parent transform.
§Why these four together
Scene::set_item_parent deliberately does not rebase local_pos — a
child’s position is stated in its parent’s frame, so adopting a new parent
moves the item unless the caller compensates. A visually-stable reparent is
therefore set_item_parent + set_local_pos + set_transform: three
events, three things for a history to undo separately, and two intermediate
states in which the item is visibly somewhere it never was.
Writing all four at once removes all three, and it is the half of Figma’s
“parent + fractional index as one property” that Teksilo was missing. The
other half — O(1) reorder with no sibling rewrite — is already here: z
is an f32 and Scene::set_z writes one field, so
Scene::z_between is a fractional insert.
#[non_exhaustive]: the crate hands this to consumer code and takes it
back — and it is the one place a caller states a whole placement, so a fifth
property joining the set is exactly the growth this guards. Build one with
new.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.parent: Option<ItemId>Logical parent, or None for scene-rooted.
z: f32Paint z-order within the band.
local_pos: PointOrigin of the item’s local frame, in the parent’s coordinates.
transform: Transform2DRotation / scale applied around the local origin.
Implementations§
Trait Implementations§
impl Copy for Placement
impl StructuralPartialEq for Placement
Auto Trait Implementations§
impl Freeze for Placement
impl RefUnwindSafe for Placement
impl Send for Placement
impl Sync for Placement
impl Unpin for Placement
impl UnsafeUnpin for Placement
impl UnwindSafe for Placement
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> DowncastSync for T
impl<T> DowncastSync for T
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