mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Add trailing_fill() toggle to Slider (#2660)
* slider: add trailing_color toggle * slider/visuals: add global option in visuals with override toggle * slider: add to demos * use `.unwrap_or_else()` instead of match
This commit is contained in:
@@ -16,6 +16,7 @@ pub struct Sliders {
|
||||
pub integer: bool,
|
||||
pub vertical: bool,
|
||||
pub value: f64,
|
||||
pub trailing_fill: bool,
|
||||
}
|
||||
|
||||
impl Default for Sliders {
|
||||
@@ -31,6 +32,7 @@ impl Default for Sliders {
|
||||
integer: false,
|
||||
vertical: false,
|
||||
value: 10.0,
|
||||
trailing_fill: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +66,7 @@ impl super::View for Sliders {
|
||||
integer,
|
||||
vertical,
|
||||
value,
|
||||
trailing_fill,
|
||||
} = self;
|
||||
|
||||
ui.label("You can click a slider value to edit it with the keyboard.");
|
||||
@@ -95,7 +98,8 @@ impl super::View for Sliders {
|
||||
.smart_aim(*smart_aim)
|
||||
.orientation(orientation)
|
||||
.text("i32 demo slider")
|
||||
.step_by(istep),
|
||||
.step_by(istep)
|
||||
.trailing_fill(*trailing_fill),
|
||||
);
|
||||
*value = value_i32 as f64;
|
||||
} else {
|
||||
@@ -106,7 +110,8 @@ impl super::View for Sliders {
|
||||
.smart_aim(*smart_aim)
|
||||
.orientation(orientation)
|
||||
.text("f64 demo slider")
|
||||
.step_by(istep),
|
||||
.step_by(istep)
|
||||
.trailing_fill(*trailing_fill),
|
||||
);
|
||||
|
||||
ui.label(
|
||||
@@ -126,17 +131,24 @@ impl super::View for Sliders {
|
||||
Slider::new(min, type_min..=type_max)
|
||||
.logarithmic(true)
|
||||
.smart_aim(*smart_aim)
|
||||
.text("left"),
|
||||
.text("left")
|
||||
.trailing_fill(*trailing_fill),
|
||||
);
|
||||
ui.add(
|
||||
Slider::new(max, type_min..=type_max)
|
||||
.logarithmic(true)
|
||||
.smart_aim(*smart_aim)
|
||||
.text("right"),
|
||||
.text("right")
|
||||
.trailing_fill(*trailing_fill),
|
||||
);
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.checkbox(trailing_fill, "Toggle trailing color");
|
||||
ui.label("When enabled, trailing color will be painted up until the circle.");
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.checkbox(use_steps, "Use steps");
|
||||
ui.label("When enabled, the minimal value change would be restricted to a given step.");
|
||||
if *use_steps {
|
||||
|
||||
Reference in New Issue
Block a user