mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-14 06:58:35 +00:00
Merge pull request #491 from dbr/sliderdoc
Add example to Slider.range() doc
This commit is contained in:
commit
8b899381f3
@ -48,6 +48,28 @@ impl<'a, T: DataTypeKind> Slider<'a, T> {
|
||||
}
|
||||
}
|
||||
/// Sets the range (inclusive)
|
||||
///
|
||||
/// The argument uses the standard Rust [`std::ops::Range`] syntax.
|
||||
///
|
||||
/// For example, to set both the min and max values:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use imgui::im_str;
|
||||
/// imgui::Slider::new(im_str!("Example"))
|
||||
/// .range(1 ..= 10)
|
||||
/// // Remember to call .build(&ui)
|
||||
/// ;
|
||||
/// ```
|
||||
///
|
||||
/// To set only the max value, using the default minimum value:
|
||||
///
|
||||
/// ```rust
|
||||
/// # use imgui::im_str;
|
||||
/// imgui::Slider::new(im_str!("Example"))
|
||||
/// .range(..= 10)
|
||||
/// // Remember to call .build(&ui)
|
||||
/// ;
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn range<R: InclusiveRangeBounds<T>>(mut self, range: R) -> Self {
|
||||
self.min = range.start_bound().copied().unwrap_or(T::SLIDER_MIN);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user