pub struct RangeSlider<'a> { /* private fields */ }Expand description
Select a range of numbers with a two-handled slider.
The handles may meet but never cross.
Looks and behaves like crate::Slider, but with two handles.
ui.add(egui::RangeSlider::new(&mut low, &mut high, 0.0..=100.0).text("Range"));The default size is set by crate::style::Spacing::slider_width.
Implementations§
Source§impl<'a> RangeSlider<'a>
impl<'a> RangeSlider<'a>
Sourcepub fn new<Num>(
low: &'a mut Num,
high: &'a mut Num,
range: impl Into<RangeInclusive<Num>>,
) -> RangeSlider<'a>where
Num: Numeric,
pub fn new<Num>(
low: &'a mut Num,
high: &'a mut Num,
range: impl Into<RangeInclusive<Num>>,
) -> RangeSlider<'a>where
Num: Numeric,
Creates a new horizontal range slider.
The values are clamped to range, and low is clamped to high.
Sourcepub fn from_get_set(
range: RangeInclusive<f64>,
get_set_low: impl FnMut(Option<f64>) -> f64 + 'a,
get_set_high: impl FnMut(Option<f64>) -> f64 + 'a,
) -> RangeSlider<'a>
pub fn from_get_set( range: RangeInclusive<f64>, get_set_low: impl FnMut(Option<f64>) -> f64 + 'a, get_set_high: impl FnMut(Option<f64>) -> f64 + 'a, ) -> RangeSlider<'a>
Creates a range slider over values that cannot be borrowed directly.
Sourcepub fn integer(self) -> RangeSlider<'a>
pub fn integer(self) -> RangeSlider<'a>
Helper: equivalent to self.fixed_decimals(0).smallest_positive(1.0).step_by(1.0).
Sourcepub fn text(self, text: impl Into<WidgetText>) -> RangeSlider<'a>
pub fn text(self, text: impl Into<WidgetText>) -> RangeSlider<'a>
Show a text label next to the widget.
Sourcepub fn text_color(self, text_color: Color32) -> RangeSlider<'a>
pub fn text_color(self, text_color: Color32) -> RangeSlider<'a>
Set the color of the text shown next to the widget.
Sourcepub fn min_separation<Num>(self, min_separation: Num) -> RangeSlider<'a>where
Num: Numeric,
pub fn min_separation<Num>(self, min_separation: Num) -> RangeSlider<'a>where
Num: Numeric,
The closest the handles may come, in values rather than points.
Default: 0.0, which lets the range collapse to nothing.
Sourcepub fn orientation(self, orientation: SliderOrientation) -> RangeSlider<'a>
pub fn orientation(self, orientation: SliderOrientation) -> RangeSlider<'a>
Which way the rail runs. Default: SliderOrientation::Horizontal.
Sourcepub fn vertical(self) -> RangeSlider<'a>
pub fn vertical(self) -> RangeSlider<'a>
Make this a vertical range slider.
Sourcepub fn clamping(self, clamping: SliderClamping) -> RangeSlider<'a>
pub fn clamping(self, clamping: SliderClamping) -> RangeSlider<'a>
Controls when the values are clamped to the range. Default: SliderClamping::Always.
Sourcepub fn smart_aim(self, smart_aim: bool) -> RangeSlider<'a>
pub fn smart_aim(self, smart_aim: bool) -> RangeSlider<'a>
Guide the values towards round numbers while dragging. Default: true.
Sourcepub fn step_by(self, step: f64) -> RangeSlider<'a>
pub fn step_by(self, step: f64) -> RangeSlider<'a>
Set the minimal change of the values.
Value 0.0 effectively disables the feature. Default: 0.0.
Sourcepub fn handle_shape(self, handle_shape: HandleShape) -> RangeSlider<'a>
pub fn handle_shape(self, handle_shape: HandleShape) -> RangeSlider<'a>
Change the shape of both handles. Default: crate::style::Visuals::handle_shape.
Sourcepub fn spec(self, spec: SliderSpec) -> RangeSlider<'a>
pub fn spec(self, spec: SliderSpec) -> RangeSlider<'a>
Replace how values are spread along the rail.
Sourcepub fn logarithmic(self, logarithmic: bool) -> RangeSlider<'a>
pub fn logarithmic(self, logarithmic: bool) -> RangeSlider<'a>
Give the small values as much of the rail as the large ones. Default: false.
Sourcepub fn smallest_positive(self, smallest_positive: f64) -> RangeSlider<'a>
pub fn smallest_positive(self, smallest_positive: f64) -> RangeSlider<'a>
For logarithmic sliders that includes zero:
what is the smallest positive value you want to be able to select?
Default: 1e-6.
Sourcepub fn largest_finite(self, largest_finite: f64) -> RangeSlider<'a>
pub fn largest_finite(self, largest_finite: f64) -> RangeSlider<'a>
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.
Sourcepub fn drag_value(self, drag_value: DragValueSettings<'a>) -> RangeSlider<'a>
pub fn drag_value(self, drag_value: DragValueSettings<'a>) -> RangeSlider<'a>
Replace every setting for the numbers beside the rail.
Sourcepub fn show_value(self, show_value: bool) -> RangeSlider<'a>
pub fn show_value(self, show_value: bool) -> RangeSlider<'a>
Show an editable value beside each end of the rail: low before it, high after it.
Default: true.
Sourcepub fn drag_value_speed(self, drag_value_speed: f64) -> RangeSlider<'a>
pub fn drag_value_speed(self, drag_value_speed: f64) -> RangeSlider<'a>
How much the numbers beside the rail change per point of drag.
Default: the rate the handles move at.
Sourcepub fn format(self, format: ValueFormat<'a>) -> RangeSlider<'a>
pub fn format(self, format: ValueFormat<'a>) -> RangeSlider<'a>
Replace how the numbers beside the rail are written and read back.
Sourcepub fn prefix(self, prefix: impl IntoAtoms<'a>) -> RangeSlider<'a>
pub fn prefix(self, prefix: impl IntoAtoms<'a>) -> RangeSlider<'a>
Show a prefix before both numbers, e.g. “x: “.
Goes in front of any prefix already set, so .prefix("b").prefix("a") shows ab.
Sourcepub fn suffix(self, suffix: impl IntoAtoms<'a>) -> RangeSlider<'a>
pub fn suffix(self, suffix: impl IntoAtoms<'a>) -> RangeSlider<'a>
Add a suffix to both numbers, e.g. a unit (“°” or “ m“).
Goes after any suffix already set, so .suffix("a").suffix("b") shows ab.
Sourcepub fn min_decimals(self, min_decimals: usize) -> RangeSlider<'a>
pub fn min_decimals(self, min_decimals: usize) -> RangeSlider<'a>
Set the minimum number of decimals to display. Default: 0.
Sourcepub fn max_decimals(self, max_decimals: usize) -> RangeSlider<'a>
pub fn max_decimals(self, max_decimals: usize) -> RangeSlider<'a>
Set the maximum number of decimals to display.
Sourcepub fn max_decimals_opt(self, max_decimals: Option<usize>) -> RangeSlider<'a>
pub fn max_decimals_opt(self, max_decimals: Option<usize>) -> RangeSlider<'a>
Set the maximum number of decimals to display, or None to let the widget pick.
Values will also be rounded to this number of decimals when it is set.
Sourcepub fn fixed_decimals(self, num_decimals: usize) -> RangeSlider<'a>
pub fn fixed_decimals(self, num_decimals: usize) -> RangeSlider<'a>
Show exactly this many decimals.
Sourcepub fn custom_formatter(
self,
formatter: impl Fn(f64, RangeInclusive<usize>) -> String + 'a,
) -> RangeSlider<'a>
pub fn custom_formatter( self, formatter: impl Fn(f64, RangeInclusive<usize>) -> String + 'a, ) -> RangeSlider<'a>
Set a formatter for both numbers.
Sourcepub fn custom_parser(
self,
parser: impl Fn(&str) -> Option<f64> + 'a,
) -> RangeSlider<'a>
pub fn custom_parser( self, parser: impl Fn(&str) -> Option<f64> + 'a, ) -> RangeSlider<'a>
Set a parser for both numbers, accepting what Self::custom_formatter writes.
Sourcepub fn binary(self, min_width: usize, twos_complement: bool) -> RangeSlider<'a>
pub fn binary(self, min_width: usize, twos_complement: bool) -> RangeSlider<'a>
Display and parse both numbers as binary integers. See ValueFormat::binary.
ui.add(egui::RangeSlider::new(&mut low, &mut high, -100..=100).binary(64, false));Sourcepub fn octal(self, min_width: usize, twos_complement: bool) -> RangeSlider<'a>
pub fn octal(self, min_width: usize, twos_complement: bool) -> RangeSlider<'a>
Display and parse both numbers as octal integers. See ValueFormat::octal.
ui.add(egui::RangeSlider::new(&mut low, &mut high, -100..=100).octal(22, false));Sourcepub fn hexadecimal(
self,
min_width: usize,
twos_complement: bool,
upper: bool,
) -> RangeSlider<'a>
pub fn hexadecimal( self, min_width: usize, twos_complement: bool, upper: bool, ) -> RangeSlider<'a>
Display and parse both numbers as hexadecimal integers. See ValueFormat::hexadecimal.
ui.add(egui::RangeSlider::new(&mut low, &mut high, -100..=100).hexadecimal(16, false, true));Sourcepub fn update_while_editing(self, update: bool) -> RangeSlider<'a>
pub fn update_while_editing(self, update: bool) -> RangeSlider<'a>
Update the values on each key press while a number is being typed. Default: true.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for RangeSlider<'a>
impl<'a> !Send for RangeSlider<'a>
impl<'a> !Sync for RangeSlider<'a>
impl<'a> !UnwindSafe for RangeSlider<'a>
impl<'a> Forget for RangeSlider<'a>
impl<'a> Freeze for RangeSlider<'a>
impl<'a> Move for RangeSlider<'a>
impl<'a> Unpin for RangeSlider<'a>
impl<'a> UnsafeUnpin for RangeSlider<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more