pub struct Ruler { /* private fields */ }Expand description
A horizontal or vertical ruler in the caller’s units. It picks a round step for the scale, so marks never crowd as the zoom changes. Numbers on a vertical ruler stack digit over digit, since text does not rotate.
use ravenrs_widgets::Ruler;
// 2.5 screen pixels per unit, with unit 120 at the start and the pointer at unit 180.
let top = Ruler::horizontal().scale(2.5).origin(120.0).marker(180.0);
let side = Ruler::vertical().scale(2.5).whole_units();Implementations§
Source§impl Ruler
impl Ruler
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
A ruler across its parent, with one pixel per unit and zero at the start.
Sourcepub fn vertical() -> Self
pub fn vertical() -> Self
A ruler down its parent, with one pixel per unit and zero at the top.
Sourcepub fn origin(self, units: f32) -> Self
pub fn origin(self, units: f32) -> Self
The value in units at the ruler’s start, which panning moves.
Sourcepub fn marker(self, units: f32) -> Self
pub fn marker(self, units: f32) -> Self
Marks this value in units, such as where the pointer is.
Sourcepub fn min_spacing(self, pixels: f32) -> Self
pub fn min_spacing(self, pixels: f32) -> Self
The least distance between numbered marks, in logical pixels (64 by default).
Sourcepub fn whole_units(self) -> Self
pub fn whole_units(self) -> Self
Never divides below one unit, for what comes in whole pieces, such as pixels.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ruler
impl RefUnwindSafe for Ruler
impl Send for Ruler
impl Sync for Ruler
impl Unpin for Ruler
impl UnsafeUnpin for Ruler
impl UnwindSafe for Ruler
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.