pub struct Minimap { /* private fields */ }Expand description
A small copy of the content with a rectangle around what is in view, linked to a
ZoomPanView by the same ZoomView. A press or a drag moves the view there, and so do
the arrow keys (with Shift, further).
use ravenrs_core::{Color, ImageData, Size};
use ravenrs_reactive::State;
use ravenrs_widgets::{Minimap, ZoomView};
let view = State::new(ZoomView::at(2.0));
if let Some(thumbnail) = ImageData::from_fn(64, 48, |_, _| Color::rgb(0.3, 0.4, 0.5)) {
let map = Minimap::image(view.binding(), thumbnail).content_size(Size::new(6400.0, 4800.0));
}Implementations§
Source§impl Minimap
impl Minimap
Sourcepub fn image(view: Binding<ZoomView>, image: ImageData) -> Self
pub fn image(view: Binding<ZoomView>, image: ImageData) -> Self
A map showing image, usually a small version of the content.
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
A map showing what draw draws, for content of this size in units of the caller.
Sourcepub fn content_size(self, content: Size) -> Self
pub fn content_size(self, content: Size) -> Self
The size of the content the view shows, when image is a smaller version of it.
Sourcepub fn max_size(self, width: f32, height: f32) -> Self
pub fn max_size(self, width: f32, height: f32) -> Self
The most width and height, in logical pixels (160 each by default). The map takes the proportions of the content inside that.
Sourcepub fn press_zoom(self, scale: f32) -> Self
pub fn press_zoom(self, scale: f32) -> Self
A press while everything is in view zooms to this scale, there. Without it, such a press does nothing, since there is nowhere to go.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Minimap
impl !Send for Minimap
impl !Sync for Minimap
impl !UnwindSafe for Minimap
impl Freeze for Minimap
impl Unpin for Minimap
impl UnsafeUnpin for Minimap
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
Mutably borrows from an owned value. Read more
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>
Adds padding inside the box, in logical pixels.
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Paints a background behind the content.
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
Fixes the width and/or height in logical pixels;
None keeps the content size.