[−][src]Struct cursive::views::SliderView
A horizontal or vertical slider.
Examples
use cursive::views::{Dialog, SliderView}; let slider_view = SliderView::horizontal(10) .on_change(|s, n| if n == 5 { s.add_layer(Dialog::info("5! Pick 5!")); }) .on_enter(|s, n| match n { 5 => s.add_layer(Dialog::info("You did it!")), n => s.add_layer(Dialog::info(format!("Why {}? Why not 5?", n))), });
Methods
impl SliderView
[src]
pub fn new(orientation: Orientation, max_value: usize) -> Self
[src]
Creates a new SliderView
in the given orientation.
The view will have a fixed length of max_value
,
with one tick per block.
The actual range of values for this slider is [0, max_value - 1]
.
pub fn vertical(max_value: usize) -> Self
[src]
Creates a new vertical SliderView
.
pub fn horizontal(max_value: usize) -> Self
[src]
Creates a new horizontal SliderView
.
pub fn set_value(&mut self, value: usize) -> EventResult
[src]
Sets the current value.
Returns an event result with a possible callback,
if on_change
was set..
pub fn value(self, value: usize) -> Self
[src]
Sets the current value.
Chainable variant.
pub fn get_value(&self) -> usize
[src]
Gets the current value.
pub fn get_max_value(&self) -> usize
[src]
Gets the max value.
pub fn on_change<F>(self, callback: F) -> Self where
F: Fn(&mut Cursive, usize) + 'static,
[src]
F: Fn(&mut Cursive, usize) + 'static,
Sets a callback to be called when the slider is moved.
pub fn on_enter<F>(self, callback: F) -> Self where
F: Fn(&mut Cursive, usize) + 'static,
[src]
F: Fn(&mut Cursive, usize) + 'static,
Sets a callback to be called when the
Trait Implementations
impl View for SliderView
[src]
fn draw(&self, printer: &Printer)
[src]
fn required_size(&mut self, _: Vec2) -> Vec2
[src]
fn on_event(&mut self, event: Event) -> EventResult
[src]
fn take_focus(&mut self, _: Direction) -> bool
[src]
fn layout(&mut self, _: Vec2)
[src]
fn needs_relayout(&self) -> bool
[src]
fn call_on_any<'a>(&mut self, _: &Selector, _: AnyCb<'a>)
[src]
fn focus_view(&mut self, _: &Selector) -> Result<(), ()>
[src]
fn important_area(&self, view_size: Vec2) -> Rect
[src]
Auto Trait Implementations
impl !RefUnwindSafe for SliderView
impl !Send for SliderView
impl !Sync for SliderView
impl Unpin for SliderView
impl !UnwindSafe for SliderView
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,