Skip to main content

SliderData

Struct SliderData 

Source
pub struct SliderData {
    pub sprites: Vec<Option<SpriteRef>>,
    pub range: [f32; 2],
    pub value: f32,
    pub steps: i32,
    pub inset: i32,
    pub track_y: i32,
    pub number: Option<NodeId>,
    pub over_knob: bool,
    pub drag: Option<(f32, i32)>,
}
Expand description

The state of a slider.

Fields§

§sprites: Vec<Option<SpriteRef>>

The sprites: the track’s ends and middle, the knob, and the knob under the pointer.

§range: [f32; 2]

The smallest and the largest value.

§value: f32

The value.

§steps: i32

Steps across the range (SliderDescription): a click on the track moves the value one of them.

§inset: i32

The space between the track’s ends and the knob’s travel, in pixels.

§track_y: i32

The track’s vertical position in the element, in pixels.

§number: Option<NodeId>

The number shown next to the slider, if it has one.

§over_knob: bool

The pointer is over the knob (it draws the fifth sprite).

§drag: Option<(f32, i32)>

A drag from the knob (flag 0x200000): the value and pointer x when it began.

Implementations§

Source§

impl SliderData

Source

pub fn step(&self) -> f32

One step of the range (a track click), a hundredth when the slider has none.

Source

pub fn knob(&self, rect: [i32; 4]) -> [i32; 4]

The knob’s rectangle in rect: its sprite’s size, from the inset at the minimum.

Source

pub fn dragged(&self, rect: [i32; 4], x: i32) -> Option<f32>

The value a drag from the knob gives with the pointer at x.

Trait Implementations§

Source§

impl Clone for SliderData

Source§

fn clone(&self) -> SliderData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SliderData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.