1 #ifndef TERMOX_WIDGET_WIDGETS_DETAIL_SLIDER_LOGIC_HPP
2 #define TERMOX_WIDGET_WIDGETS_DETAIL_SLIDER_LOGIC_HPP
3 #include <signals_light/signal.hpp>
11 using Ratio_t = double;
33 [[nodiscard]]
auto minimum() const -> Value_t;
36 [[nodiscard]] auto
maximum() const -> Value_t;
48 [[nodiscard]] auto
ratio() const ->
double;
54 [[nodiscard]] auto
value() const -> Value_t;
57 [[nodiscard]] auto
length() const -> Value_t;
Holds the ratio of a slider like Widget and calculates current value.
Definition: slider_logic.hpp:8
void decrement(Value_t amount=1)
Decrement the current value by amount.
Definition: slider_logic.cpp:45
auto minimum() const -> Value_t
Return the smallest possible value for the slider.
Definition: slider_logic.cpp:36
void set_maximum(Value_t max)
Set the maximum value the slider can take on.
Definition: slider_logic.cpp:27
sl::Signal< void(Value_t)> value_changed
Signal emitted every time the value is changed.
Definition: slider_logic.hpp:14
Slider_logic(Value_t minimum, Value_t maximum)
Initialize with range of acceptable values and minimum current value.
Definition: slider_logic.cpp:11
void set_ratio(Ratio_t ratio)
Directly set the ratio as a value from [0.0, 1.0].
Definition: slider_logic.cpp:50
auto value() const -> Value_t
Return the current value.
Definition: slider_logic.cpp:76
auto maximum() const -> Value_t
Return the largest possible value for the slider.
Definition: slider_logic.cpp:38
void set_value(Value_t value)
Set the current value of the slider and emit signal.
Definition: slider_logic.cpp:66
void set_minimum(Value_t min)
Set the minimum value the slider can take on.
Definition: slider_logic.cpp:18
auto length() const -> Value_t
Return the distance between the maximum and minimum.
Definition: slider_logic.cpp:82
auto ratio() const -> double
Return the position of the current value in the slider as a ratio.
Definition: slider_logic.cpp:64
void increment(Value_t amount=1)
Increment the current value by amount.
Definition: slider_logic.cpp:40
sl::Signal< void(Ratio_t)> ratio_changed
Signal emitted every time the ratio is changed.
Definition: slider_logic.hpp:17