Skip to main content

ProposedChange

Struct ProposedChange 

Source
#[non_exhaustive]
pub struct ProposedChange<'a> { pub scene: &'a Scene, pub items: &'a [ItemId], pub op: TransformOp, pub start: TransformFrame, pub proposed: TransformFrame, pub source: TransformSource, pub magnet_snapped: bool, }
Expand description

A change a gesture is about to make, offered to the geometry constraint.

Every field is a question, never a channel: the answer is the returned ChangeVerdict.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§scene: &'a Scene

The scene, read-only. Query siblings, guides, parents, magnets, flags — anything a constraint needs to decide.

This is the whole read surface, and the reason a constraint never needs to capture a SceneModel: one that does closes a reference cycle through the closure the scene owns and leaks the scene. A closure that must reach the model holds a WeakSceneModel. Writes panic; see the module header.

§items: &'a [ItemId]

The roots this gesture will change, pruned of any item whose ancestor is also in the set — a descendant moves because its root does, so it is deliberately not listed.

The transform controller narrows this further to the roots carrying the operation’s own flag (TransformOp::required_flag); the lightweight item drag lists the whole drag group, which is what it moves.

There is no “primary”: the subject of the decision is the frame, which is what makes the constraint grab-offset invariant. Per-item policy is still expressible — a one-item gesture is items.len() == 1.

§op: TransformOp

What the gesture asks of them.

§start: TransformFrame

The frame the gesture started from. Fixed for the gesture’s life, so a constraint measures total travel rather than per-sample travel.

§proposed: TransformFrame

The frame about to be applied, after magnetism.

Both frames’ rects are stated in the frame’s own basis. For a single rotated item that is the item’s basis, so a grid snap written against rect.x snaps along the item’s axes; a multi-item frame is axis-aligned, so the same rule snaps along the scene’s.

§source: TransformSource

Which route produced it.

§magnet_snapped: bool

Whether magnetism moved proposed onto a magnet.

The seam where the two snapping systems compose: returning ChangeVerdict::Accept when this is true lets an explicit magnet win over a standing rule. Overriding it is also allowed — and then the magnet’s connection does not fire, because a magnet whose alignment was overruled did not connect anything.

Only the lightweight item drag runs magnetism today, so this is false on the transform-controller, keyboard-nudge and app-driven routes.

Implementations§

Source§

impl ProposedChange<'_>

Source

pub fn translation(&self) -> Vec2

The scene-space translation from start to proposed.

The quantity an axis lock or a grid snap works in. Exact for a TransformOp::Move; for a resize or a rotate it is the movement of the frame’s origin, and the extent change is in the two frames themselves.

Source

pub fn translated(&self, translation: Vec2) -> TransformFrame

start moved by a scene-space translation — the frame to hand back from ChangeVerdict::Adjust once a move has been rewritten.

The exact inverse of translation, so c.translated(c.translation()) is c.proposed for a move.

Trait Implementations§

Source§

impl<'a> Debug for ProposedChange<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ProposedChange<'a>

§

impl<'a> !Send for ProposedChange<'a>

§

impl<'a> !Sync for ProposedChange<'a>

§

impl<'a> !UnwindSafe for ProposedChange<'a>

§

impl<'a> Freeze for ProposedChange<'a>

§

impl<'a> Unpin for ProposedChange<'a>

§

impl<'a> UnsafeUnpin for ProposedChange<'a>

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