TermOx
Public Types | Public Member Functions | Public Attributes | List of all members
ox::detail::Slider_logic Class Reference

Holds the ratio of a slider like Widget and calculates current value. More...

#include <slider_logic.hpp>

Public Types

using Value_t = int
 
using Ratio_t = double
 

Public Member Functions

 Slider_logic (Value_t minimum, Value_t maximum)
 Initialize with range of acceptable values and minimum current value.
 
void set_minimum (Value_t min)
 Set the minimum value the slider can take on. More...
 
void set_maximum (Value_t max)
 Set the maximum value the slider can take on. More...
 
auto minimum () const -> Value_t
 Return the smallest possible value for the slider.
 
auto maximum () const -> Value_t
 Return the largest possible value for the slider.
 
void increment (Value_t amount=1)
 Increment the current value by amount.
 
void decrement (Value_t amount=1)
 Decrement the current value by amount.
 
void set_ratio (Ratio_t ratio)
 Directly set the ratio as a value from [0.0, 1.0].
 
auto ratio () const -> double
 Return the position of the current value in the slider as a ratio.
 
void set_value (Value_t value)
 Set the current value of the slider and emit signal.
 
auto value () const -> Value_t
 Return the current value.
 
auto length () const -> Value_t
 Return the distance between the maximum and minimum.
 

Public Attributes

sl::Signal< void(Value_t)> value_changed
 Signal emitted every time the value is changed.
 
sl::Signal< void(Ratio_t)> ratio_changed
 Signal emitted every time the ratio is changed.
 

Detailed Description

Holds the ratio of a slider like Widget and calculates current value.

Member Function Documentation

◆ set_maximum()

void ox::detail::Slider_logic::set_maximum ( Value_t  max)

Set the maximum value the slider can take on.

Modifies minimum to be max - 1 if min >= max.

◆ set_minimum()

void ox::detail::Slider_logic::set_minimum ( Value_t  min)

Set the minimum value the slider can take on.

Modifies maximum to be min + 1 if max <= min.


The documentation for this class was generated from the following files: