Struct egui::widgets::Slider[][src]

#[must_use = "You should put this widget in an ui with `ui.add(widget);`"]pub struct Slider<'a> { /* fields omitted */ }

Control a number by a horizontal slider.

The slider range defines the values you get when pulling the slider to the far edges. By default, the slider can still show values outside this range, and still allows users to enter values outside the range by clicking the slider value and editing it. If you want to clamp incoming and outgoing values, use Slider::clamp_to_range.

The range can include any numbers, and go from low-to-high or from high-to-low.

The slider consists of three parts: a horizontal slider, a value display, and an optional text. The user can click the value display to edit its value. It can be turned off with .show_value(false).

ui.add(egui::Slider::f32(&mut my_f32, 0.0..=100.0).text("My value"));

Implementations

impl<'a> Slider<'a>[src]

pub fn f32(value: &'a mut f32, range: RangeInclusive<f32>) -> Self[src]

pub fn f64(value: &'a mut f64, range: RangeInclusive<f64>) -> Self[src]

pub fn i8(value: &'a mut i8, range: RangeInclusive<i8>) -> Self[src]

pub fn u8(value: &'a mut u8, range: RangeInclusive<u8>) -> Self[src]

pub fn i16(value: &'a mut i16, range: RangeInclusive<i16>) -> Self[src]

pub fn u16(value: &'a mut u16, range: RangeInclusive<u16>) -> Self[src]

pub fn i32(value: &'a mut i32, range: RangeInclusive<i32>) -> Self[src]

pub fn u32(value: &'a mut u32, range: RangeInclusive<u32>) -> Self[src]

pub fn i64(value: &'a mut i64, range: RangeInclusive<i64>) -> Self[src]

pub fn u64(value: &'a mut u64, range: RangeInclusive<u64>) -> Self[src]

pub fn isize(value: &'a mut isize, range: RangeInclusive<isize>) -> Self[src]

pub fn usize(value: &'a mut usize, range: RangeInclusive<usize>) -> Self[src]

pub fn from_get_set(
    range: RangeInclusive<f64>,
    get_set_value: impl 'a + FnMut(Option<f64>) -> f64
) -> Self
[src]

pub fn show_value(self, show_value: bool) -> Self[src]

Control wether or not the slider shows the current value. Default: true.

pub fn prefix(self, prefix: impl ToString) -> Self[src]

Show a prefix before the number, e.g. “x: “

pub fn suffix(self, suffix: impl ToString) -> Self[src]

Add a suffix to the number, this can be e.g. a unit (“°” or “ m“)

pub fn text(self, text: impl Into<String>) -> Self[src]

Show a text next to the slider (e.g. explaining what the slider controls).

pub fn text_color(self, text_color: Color32) -> Self[src]

pub fn logarithmic(self, logarithmic: bool) -> Self[src]

Make this a logarithmic slider. This is great for when the slider spans a huge range, e.g. from one to a million. The default is OFF.

pub fn smallest_positive(self, smallest_positive: f64) -> Self[src]

For logarithmic sliders that includes zero: what is the smallest positive value you want to be able to select? The default is 1 for integer sliders and 1e-6 for real sliders.

pub fn largest_finite(self, largest_finite: f64) -> Self[src]

For logarithmic sliders, the largest positive value we are interested in before the slider switches to INFINITY, if that is the higher end. Default: INFINITY.

pub fn clamp_to_range(self, clamp_to_range: bool) -> Self[src]

If set to true, all incoming and outgoing values will be clamped to the slider range. Default: false.

pub fn smart_aim(self, smart_aim: bool) -> Self[src]

Turn smart aim on/off. Default is ON. There is almost no point in turning this off.

pub fn precision(self, precision: usize) -> Self[src]

👎 Deprecated:

Use fixed_decimals instead

pub fn min_decimals(self, min_decimals: usize) -> Self[src]

Set a minimum number of decimals to display. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.

pub fn max_decimals(self, max_decimals: usize) -> Self[src]

Set a maximum number of decimals to display. Values will also be rounded to this number of decimals. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.

pub fn fixed_decimals(self, num_decimals: usize) -> Self[src]

Set an exact number of decimals to display. Values will also be rounded to this number of decimals. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.

pub fn integer(self) -> Self[src]

Helper: equivalent to self.precision(0).smallest_positive(1.0). If you use one of the integer constructors (e.g. Slider::i32) this is called for you, but if you want to have a slider for picking integer values in an Slider::f64, use this.

Trait Implementations

impl<'a> Widget for Slider<'a>[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for Slider<'a>

impl<'a> !Send for Slider<'a>

impl<'a> !Sync for Slider<'a>

impl<'a> Unpin for Slider<'a>

impl<'a> !UnwindSafe for Slider<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.