Struct tuix::Slider[]

pub struct Slider {
    pub value: f32,
    // some fields omitted
}

Fields

value: f32

Implementations

Create a new slider widget with default values (min: 0.0, max: 1.0, val: 0.0).

Example

Slider::new().build(state, parent, |builder| builder);

Set the initial value of the slider.

Example

Slider::new()
   .with_init(0.5)
   .build(state, parent, |builder| builder)

Set the range of the slider. Min and Max values are extracted from the range.

Example

Slider::new()
    .with_range(0.0..5.0)
    .build(state, parent, |builder| builder)

Set the minimum value of the slider.

Example

Slider::new()
    .with_min(0.2)
    .build(state, parent, |builder| builder)

Set the maximum value of the slider.

Example

Slider::new()
    .with_max()
    .build(state, parent, |builder| builder)

Set the callback triggered when the slider value has changed.

Takes a closure which provides the current value and returns an event to be sent when the slider value has changed after releasing the slider. If the slider thumb is pressed but not moved, and thus the value is not changed, then the event will not be sent.

Example

Slider::new()
    .on_change(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_change: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the callback triggered when the slider value is changing (dragging).

Takes a closure which triggers when the slider value is changing, either by pressing the track or dragging the thumb along the track.

Example

Slider::new()
    .on_changing(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_changing: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the callback triggered when the slider value reaches the minimum.

Takes a closure which triggers when the slider reaches the minimum value, either by pressing the track at the start or dragging the thumb to the start of the track. The event is sent once for each time the value reaches the minimum.

Example

Slider::new()
    .on_min(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the callback triggered when the slider value reaches the maximum.

Takes a closure which triggers when the slider reaches the maximum value, either by pressing the track at the end or dragging the thumb to the end of the track. The event is sent once for each time the value reaches the maximum.

Example

Slider::new()
    .on_max(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the event sent when the slider is pressed.

The event is sent when the left mouse button is pressed on any part of the slider.

Example

Slider::new()
    .on_max(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the event sent when the slider is released.

The event is sent when the left mouse button is released after being pressed on any part of the slider.

Example

Slider::new()
    .on_max(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the event sent when the mouse cursor enters the slider.

The event is sent when the mouse cursor enters the bounding box of the slider.

Example

Slider::new()
    .on_max(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Set the event sent when the mouse cursor leaves the slider

The event is sent when the mouse cursor leaves the bounding box of the slider.

Example

Slider::new()
    .on_max(|slider, state, entity| {
        entity.emit(WindowEvent::Debug(format!("Slider on_min: {}", slider.value)));
    })
    .build(state, parent, |builder| builder);

Trait Implementations

Returns the “default value” for a type. Read more

Adds the widget into state and returns the associated type Ret - an entity id or a tuple of entity ids

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.