pub struct ZoomPanView { /* private fields */ }Expand description
Zoom and pan over content: pinch or Cmd/Ctrl with the wheel to zoom, a drag or the wheel to
move, a double click between fit and 100%, and the keys +, -, 0, 1 and the arrows
(with Shift, further). A thrown drag coasts to a stop, which asks for frames only meanwhile
and never happens with reduced motion. The content cannot leave the view.
Content is an image or a closure that draws from where the view puts it, not a laid out
view: the runtime has no transform for a subtree, and scaling one by
Motion::effect would neither move what can be clicked nor
paint children whose unscaled place is off screen. A closure can still reuse any drawing
through Scene::apply_effect.
While a gesture runs it paints without a build. If nothing else in the UI reads the
ZoomView, it costs no rebuilds at all, however big the screen around it.
use ravenrs_core::ImageData;
use ravenrs_reactive::State;
use ravenrs_widgets::{Minimap, ZoomControl, ZoomPanView, ZoomView};
let view = State::new(ZoomView::fit());
let stage = ZoomPanView::image(view.binding(), photo());
let controls = ZoomControl::new(view.binding());
let map = Minimap::image(view.binding(), photo());Implementations§
Source§impl ZoomPanView
impl ZoomPanView
Sourcepub fn image(view: Binding<ZoomView>, image: ImageData) -> ZoomPanView
pub fn image(view: Binding<ZoomView>, image: ImageData) -> ZoomPanView
Shows an image, with one unit of content per pixel of it.
Sourcepub fn custom(
view: Binding<ZoomView>,
content: Size,
draw: impl Fn(ZoomPanPaint, &mut Scene) + 'static,
) -> ZoomPanView
pub fn custom( view: Binding<ZoomView>, content: Size, draw: impl Fn(ZoomPanPaint, &mut Scene) + 'static, ) -> ZoomPanView
Shows what draw draws, for content of this size in units of the caller.
Sourcepub fn size(self, width: f32, height: f32) -> ZoomPanView
pub fn size(self, width: f32, height: f32) -> ZoomPanView
Fixed size in logical pixels, instead of taking the free space.
Sourcepub fn grow(self, grow: f32) -> ZoomPanView
pub fn grow(self, grow: f32) -> ZoomPanView
How much of the free space along the parent stack it takes (1 by default).
Sourcepub fn range(self, least: f32, most: f32) -> ZoomPanView
pub fn range(self, least: f32, most: f32) -> ZoomPanView
The least and the most scale, where 1 is 100%. By default, it goes down to what shows the whole content and up to 1600%. What shows the whole content is always in range.
Sourcepub fn inertia(self, inertia: bool) -> ZoomPanView
pub fn inertia(self, inertia: bool) -> ZoomPanView
Lets a thrown drag coast (on by default).
Trait Implementations§
Source§impl Debug for ZoomPanView
impl Debug for ZoomPanView
Auto Trait Implementations§
impl !RefUnwindSafe for ZoomPanView
impl !Send for ZoomPanView
impl !Sync for ZoomPanView
impl !UnwindSafe for ZoomPanView
impl Freeze for ZoomPanView
impl Unpin for ZoomPanView
impl UnsafeUnpin for ZoomPanView
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.