#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.scene: &'a SceneThe 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: TransformOpWhat the gesture asks of them.
start: TransformFrameThe frame the gesture started from. Fixed for the gesture’s life, so a constraint measures total travel rather than per-sample travel.
proposed: TransformFrameThe 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: TransformSourceWhich route produced it.
magnet_snapped: boolWhether 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<'_>
impl ProposedChange<'_>
Sourcepub fn translation(&self) -> Vec2
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.
Sourcepub fn translated(&self, translation: Vec2) -> TransformFrame
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§
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> 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