pub struct ZoomState { /* private fields */ }Expand description
Shared zoom/pan transform state for Modifier::zoomable.
Cloning shares the same underlying state (like ScrollState).
Implementations§
Source§impl ZoomState
impl ZoomState
Sourcepub fn with_scale_range(min_scale: f32, max_scale: f32) -> ZoomState
pub fn with_scale_range(min_scale: f32, max_scale: f32) -> ZoomState
Creates a state at scale 1.0 clamping zoom to min_scale..=max_scale.
Sourcepub fn scale_non_reactive(&self) -> f32
pub fn scale_non_reactive(&self) -> f32
Current scale without snapshot subscription.
Sourcepub fn offset_non_reactive(&self) -> Point
pub fn offset_non_reactive(&self) -> Point
Current pan offset without snapshot subscription.
pub fn min_scale(&self) -> f32
pub fn max_scale(&self) -> f32
Sourcepub fn is_transformed(&self) -> bool
pub fn is_transformed(&self) -> bool
Whether the content is currently transformed away from identity.
Sourcepub fn is_zoomed_in(&self) -> bool
pub fn is_zoomed_in(&self) -> bool
Whether the content is currently zoomed in beyond identity.
Pan gestures only apply while this is true: an image at (or below)
its natural size has nothing to pan, and drags over it belong to
enclosing scrollables.
Sourcepub fn set_offset(&self, offset: Point)
pub fn set_offset(&self, offset: Point)
Sets the pan offset directly.
Sourcepub fn apply_transform(&self, centroid: Point, pan: Point, zoom: f32)
pub fn apply_transform(&self, centroid: Point, pan: Point, zoom: f32)
Applies one gesture step: zoom by zoom about centroid, then pan.
centroid and pan are in the element’s display frame; for finger
gestures the anchor must be the centroid of the pointers BEFORE the
step (as reported by TransformGestureEvent::Transform). With the
top-left-origin layer produced by ZoomState::layer, a content
point c renders at p = c * scale + offset; this update applies
p' = zoom * (p - centroid) + centroid + pan, which keeps the
content glued to the fingers.
Pan is inert while not zoomed in: whenever the resulting scale is at
(or below) identity the offset is clamped back to zero, so a pinch
that zooms out to scale <= 1 — or a pure centroid pan at identity —
never leaves the content stranded at a stray offset.
Sourcepub fn layer(&self) -> GraphicsLayer
pub fn layer(&self) -> GraphicsLayer
Builds the GraphicsLayer rendering this transform.
Reads the state reactively, so it is meant for the lazy
Modifier::graphics_layer(move || state.layer()) form.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZoomState
impl RefUnwindSafe for ZoomState
impl Send for ZoomState
impl Sync for ZoomState
impl Unpin for ZoomState
impl UnsafeUnpin for ZoomState
impl UnwindSafe for ZoomState
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.