Skip to content

Commit

Permalink
Added with_range method to slider #21
Browse files Browse the repository at this point in the history
  • Loading branch information
geom3trik committed Apr 12, 2021
1 parent 91ff9a9 commit ed62b3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/widgets/inputs/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ impl Slider {
self
}

pub fn with_range(mut self, range: std::ops::Range<f32>) -> Self {
self.min = range.start;
self.max = range.end;

self
}

pub fn with_min(mut self, val: f32) -> Self {
self.min = val;
self
Expand Down
1 change: 1 addition & 0 deletions examples/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ fn main() {
let row = HBox::new().build(state, panel, |builder| builder);
Label::new("Slider").build(state, row, |builder| builder);
Slider::new()
.with_range(0.0..20.0)
.on_hover(Event::new(WindowEvent::WindowClose))
.build(state, row, |builder| builder.set_flex_grow(1.0));

Expand Down

0 comments on commit ed62b3b

Please sign in to comment.