Skip to main content

TransformConfig

Struct TransformConfig 

Source
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

Source

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.

Source

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.

Source

pub fn keep_ratio(self, on: impl Into<Prop<bool>>) -> Self

Keep the selection’s aspect ratio through a resize. Konva’s keepRatio.

Source

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.

Source

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.

Source

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

Source

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.

Source

pub fn handle_px(self, px: f32) -> Self

The on-screen size of a handle, in pixels. Default 9.

Source

pub fn min_size(self, w: f32, h: f32) -> Self

The smallest frame a resize will produce, in scene units.

Source

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.

Source

pub fn live_preview(self, mode: LivePreview) -> Self

Whether the items follow the gesture or only the frame does.

Source

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.

Source

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.

Source

pub fn edge_pan_speed(self, px_per_second: f32) -> Self

Auto-pan speed, in screen pixels per second.

Source

pub fn labels(self, labels: TransformLabels) -> Self

The names the frame and its handles publish to assistive technology.

Source

pub fn enabled(self, on: impl Into<Prop<bool>>) -> Self

Set the enabled state, statically or reactively.

Source

pub fn enabled_signal(&self) -> Signal<bool>

The reactive enabled signal, for a toolbar to read or bind.

Source

pub fn is_enabled(&self) -> bool

Whether the controller is currently enabled.

Source

pub fn on_start( self, f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static, ) -> Self

Fired once when a gesture begins.

Source

pub fn on_change( self, f: impl Fn(&TransformSession, &mut EventContext<'_>) + 'static, ) -> Self

Fired on every pointer sample and every keyboard step.

Source

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.

Source

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

Source§

fn clone(&self) -> TransformConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TransformConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for TransformConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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