pub struct PanZoomController { /* private fields */ }Expand description
A cloneable handle onto a PanZoomView: drive it with
jump_to/fit_to_bounds/
fit_rect and read where it stands with
transform. Every clone shares one state, so the handle
an app keeps in its state and the one attached to the view are the same.
Commands are recorded, not applied: the widget applies the latest one at its next layout or paint (a later command replaces an unapplied earlier one), clamping the scale to the view’s bounds. One controller drives one view; attaching it to two makes them race for its commands.
Implementations§
Source§impl PanZoomController
impl PanZoomController
Sourcepub fn new() -> Self
pub fn new() -> Self
A controller attached to nothing yet, reading PanZoomTransform::IDENTITY.
Sourcepub fn transform(&self) -> PanZoomTransform
pub fn transform(&self) -> PanZoomTransform
The transform the attached widget last published (identity until one attaches and lays out).
Sourcepub fn viewport_size(&self) -> Size
pub fn viewport_size(&self) -> Size
The attached widget’s last laid-out size (zero until it lays out).
Sourcepub fn content_size(&self) -> Size
pub fn content_size(&self) -> Size
The child’s last laid-out natural size (zero until it lays out).
Sourcepub fn jump_to(&self, scale: f64, offset: Vec2)
pub fn jump_to(&self, scale: f64, offset: Vec2)
Move to scale (clamped to the view’s bounds) with the child’s origin
at view-local offset.
Sourcepub fn fit_to_bounds(&self)
pub fn fit_to_bounds(&self)
Fit the child’s whole laid-out bounds into the view, centred, at the largest scale that shows all of it (clamped to the view’s bounds).