pub struct TransformConfig { /* private fields */ }Expand description
Per-view transform-controller configuration, installed via
SceneView::transform_controller.
Built the way MagnetismConfig is: Rc’d
closures so the view can clone it into every handler, Prop-accepting
reactive knobs, one enabled signal.
Implementations§
Source§impl TransformConfig
impl TransformConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
A controller with every handle, no ratio lock, corner-anchored scaling,
6 px padding, 9 px handles, a 4 × 4 minimum, body drag on, live preview,
t for the keyboard route and edge auto-pan on.
Sourcepub fn handles(self, set: TransformHandleSet) -> Self
pub fn handles(self, set: TransformHandleSet) -> Self
Which handles the frame offers. Konva’s enabledAnchors.
A handle in the set is still hidden when the selection cannot honour
it — see
SceneView::transform_controller
for the rule. What is drawn is exactly what will happen.
Sourcepub fn keep_ratio(self, on: impl Into<Prop<bool>>) -> Self
pub fn keep_ratio(self, on: impl Into<Prop<bool>>) -> Self
Keep the selection’s aspect ratio through a resize. Konva’s keepRatio.
Sourcepub fn centered_scaling(self, on: impl Into<Prop<bool>>) -> Self
pub fn centered_scaling(self, on: impl Into<Prop<bool>>) -> Self
Scale about the frame’s centre rather than the opposite anchor.
Konva’s centeredScaling.
Sourcepub fn rotation_snaps(self, radians: impl IntoIterator<Item = f32>) -> Self
pub fn rotation_snaps(self, radians: impl IntoIterator<Item = f32>) -> Self
Absolute angles, in radians, a rotation snaps to when it comes within
rotation_snap_tolerance.
Sourcepub fn rotation_snap_tolerance(self, radians: f32) -> Self
pub fn rotation_snap_tolerance(self, radians: f32) -> Self
How close a rotation has to get to a snap before it takes it. Default 5°.
Sourcepub fn padding(self, screen_px: f32) -> Self
pub fn padding(self, screen_px: f32) -> Self
How far outside the selection the frame is drawn, in screen pixels.
Konva’s padding.
This is load-bearing, not decoration: it is what puts the frame band and
the handles on pixels a heavyweight card does not own, and therefore
what makes them grabbable over one. Setting it below
handle_px / 2 lets a handle overlap a card, and a card that claims its
own press will then take the grab.
Sourcepub fn min_size(self, w: f32, h: f32) -> Self
pub fn min_size(self, w: f32, h: f32) -> Self
The smallest frame a resize will produce, in scene units.
Sourcepub fn body_drag(self, on: bool) -> Self
pub fn body_drag(self, on: bool) -> Self
Whether a press on the body of a selected, movable item starts a group move. Default on.
Best-effort over the heavyweight tier by construction: a card that
claims its own press — one carrying capture_pointer or its own
on_drag — wins it, and this view never sees the gesture. The frame
band is the route that always works.
Sourcepub fn live_preview(self, mode: LivePreview) -> Self
pub fn live_preview(self, mode: LivePreview) -> Self
Whether the items follow the gesture or only the frame does.
Sourcepub fn transform_key(self, key: Key) -> Self
pub fn transform_key(self, key: Key) -> Self
The key that enters the keyboard transform mode while the view is
focused. Default t, mirroring magnetism’s m.
Sourcepub fn edge_pan_px(self, px: f32) -> Self
pub fn edge_pan_px(self, px: f32) -> Self
How close to the viewport edge a pointer gesture has to get before the view starts panning, in screen pixels. Zero turns auto-pan off.
Sourcepub fn edge_pan_speed(self, px_per_second: f32) -> Self
pub fn edge_pan_speed(self, px_per_second: f32) -> Self
Auto-pan speed, in screen pixels per second.
Sourcepub fn labels(self, labels: TransformLabels) -> Self
pub fn labels(self, labels: TransformLabels) -> Self
The names the frame and its handles publish to assistive technology.
Sourcepub fn enabled(self, on: impl Into<Prop<bool>>) -> Self
pub fn enabled(self, on: impl Into<Prop<bool>>) -> Self
Set the enabled state, statically or reactively.
Sourcepub fn enabled_signal(&self) -> Signal<bool>
pub fn enabled_signal(&self) -> Signal<bool>
The reactive enabled signal, for a toolbar to read or bind.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether the controller is currently enabled.
Sourcepub fn on_start(
self,
f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_start( self, f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static, ) -> Self
Fired once when a gesture begins.
Sourcepub fn on_change(
self,
f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_change( self, f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static, ) -> Self
Fired on every pointer sample and every keyboard step.
Sourcepub fn on_end(
self,
f: impl Fn(&TransformSession, TransformOutcome, &mut EventContext<'_>) + 'static,
) -> Self
pub fn on_end( self, f: impl Fn(&TransformSession, TransformOutcome, &mut EventContext<'_>) + 'static, ) -> Self
Fired once when a gesture finishes, committed or cancelled.
The scene has already been written when the outcome is
TransformOutcome::Committed, so this is the hook an app records the
delta from — a reversible-edit layer lives above this crate, never
inside it.
Sourcepub fn chrome(
self,
f: impl Fn(&mut Canvas, &PaintContext<'_>, &TransformChrome) + 'static,
) -> Self
pub fn chrome( self, f: impl Fn(&mut Canvas, &PaintContext<'_>, &TransformChrome) + 'static, ) -> Self
Replace the built-in chrome painter. Paints in scene coordinates.
Trait Implementations§
Source§impl Clone for TransformConfig
impl Clone for TransformConfig
Source§fn clone(&self) -> TransformConfig
fn clone(&self) -> TransformConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TransformConfig
impl Debug for TransformConfig
Auto Trait Implementations§
impl !RefUnwindSafe for TransformConfig
impl !Send for TransformConfig
impl !Sync for TransformConfig
impl !UnwindSafe for TransformConfig
impl Freeze for TransformConfig
impl Unpin for TransformConfig
impl UnsafeUnpin for TransformConfig
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
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> 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