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) -> Self
pub fn image(view: Binding<ZoomView>, image: ImageData) -> Self
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,
) -> Self
pub fn custom( view: Binding<ZoomView>, content: Size, draw: impl Fn(ZoomPanPaint, &mut Scene) + 'static, ) -> Self
Shows what draw draws, for content of this size in units of the caller.
Sourcepub fn size(self, width: f32, height: f32) -> Self
pub fn size(self, width: f32, height: f32) -> Self
Fixed size in logical pixels, instead of taking the free space.
Sourcepub fn grow(self, grow: f32) -> Self
pub fn grow(self, grow: f32) -> Self
How much of the free space along the parent stack it takes (1 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§
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<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<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.