From 9a546ff97a429344bca7ab02b7a6dc184361c17a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 20 Feb 2021 16:28:39 +0100 Subject: [PATCH] SlidSlider will now show the value display by default. Turn off with slider.show_value(false) Closes https://github.com/emilk/egui/issues/183 --- CHANGELOG.md | 1 + egui/src/widgets/slider.rs | 54 +++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3424a5c4..2e6a1f2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Improve the positioning of tooltips. * Only show tooltips if mouse is still. +* `Slider` will now show the value display by default, unless turned off with `.show_value(false)`. ## 0.9.0 - 2021-02-07 - Light Mode and much more diff --git a/egui/src/widgets/slider.rs b/egui/src/widgets/slider.rs index 1276b902..2f83f42c 100644 --- a/egui/src/widgets/slider.rs +++ b/egui/src/widgets/slider.rs @@ -47,6 +47,15 @@ struct SliderSpec { /// 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)`. +/// +/// ``` +/// # let ui = &mut egui::Ui::__test(); +/// # let mut my_f32: f32 = 0.0; +/// ui.add(egui::Slider::f32(&mut my_f32, 0.0..=100.0).text("My value")); +/// ``` #[must_use = "You should put this widget in an ui with `ui.add(widget);`"] pub struct Slider<'a> { get_set_value: GetSetValue<'a>, @@ -54,8 +63,8 @@ pub struct Slider<'a> { spec: SliderSpec, clamp_to_range: bool, smart_aim: bool, - // TODO: label: Option