pub struct RubberBand { /* private fields */ }Expand description
A rectangle drawn with a drag, in the units of the content. The selection follows the drag
through its binding, and on_select gets it on release; a press and
release without moving clears it. Escape cancels a drag.
Keyboard: the arrows move it, with Alt they resize it (and with Shift, further), Enter selects it, Delete or Escape clears it. With nothing selected, an arrow starts from the middle quarter of the content.
While dragging it paints without a build, so it costs no rebuilds if nothing else reads the selection.
use ravenrs_core::Rect;
use ravenrs_reactive::State;
use ravenrs_widgets::RubberBand;
let selection = State::new(None::<Rect>);
let band = RubberBand::new(selection.binding())
.keep(false)
.on_select(|rect| println!("zoom to {rect:?}"))
.size(320.0, 200.0);Implementations§
Source§impl RubberBand
impl RubberBand
Sourcepub fn new(selection: Binding<Option<Rect>>) -> RubberBand
pub fn new(selection: Binding<Option<Rect>>) -> RubberBand
A band bound to selection, in the units of its space.
Sourcepub fn on_select(self, handler: impl Fn(Rect) + 'static) -> RubberBand
pub fn on_select(self, handler: impl Fn(Rect) + 'static) -> RubberBand
Runs handler with the rectangle when a drag ends, or on Enter.
Sourcepub fn keep(self, keep: bool) -> RubberBand
pub fn keep(self, keep: bool) -> RubberBand
Whether the rectangle stays after the release (it does by default). A box for zooming, say, goes away as soon as it is used.
Sourcepub fn disabled(self, disabled: bool) -> RubberBand
pub fn disabled(self, disabled: bool) -> RubberBand
Takes no input while disabled, which leaves the pointer to what is underneath: for a band that only works in one mode or with a key held.
Source§impl RubberBand
impl RubberBand
Sourcepub fn size(self, width: f32, height: f32) -> RubberBand
pub fn size(self, width: f32, height: f32) -> RubberBand
Fixed size in logical pixels, instead of taking the free space.
Sourcepub fn grow(self, grow: f32) -> RubberBand
pub fn grow(self, grow: f32) -> RubberBand
How much of the free space along the parent stack it takes: 1 by default, or 0 over a stage, which then decides the size.
Sourcepub fn stage(self, stage: impl View + 'static) -> RubberBand
pub fn stage(self, stage: impl View + 'static) -> RubberBand
The view it goes over, such as an Image or a
ZoomPanView, which gives it its size. Without one, put it in
a ZStack with a fixed size.
Sourcepub fn space(self, space: ContentSpace) -> RubberBand
pub fn space(self, space: ContentSpace) -> RubberBand
Where the content is, and so the units of its coordinates: by default, its own box.
Trait Implementations§
Source§impl Debug for RubberBand
impl Debug for RubberBand
Auto Trait Implementations§
impl !RefUnwindSafe for RubberBand
impl !Send for RubberBand
impl !Sync for RubberBand
impl !UnwindSafe for RubberBand
impl Freeze for RubberBand
impl Unpin for RubberBand
impl UnsafeUnpin for RubberBand
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.