Skip to main content

Slider

#include "toolkit/slider.hpp"

A draggable horizontal or vertical slider over a float range. Inherits Widget.

Slider screenshot

Example​

auto slider = std::make_unique<toolkit::Slider>();
slider->set_range(0.0f, 1.0f);
slider->on_change = [](toolkit::Slider &, float v) { /* ... */ };

Construction​

explicit Slider(Orientation orientation = Orientation::Horizontal);

Orientation is Horizontal | Vertical (types.hpp).

API​

MemberDescription
value() / set_value(float)Current value
minimum() / set_minimum(float)Range lower bound
maximum() / set_maximum(float)Range upper bound
set_range(float min, float max)Set both bounds at once

Callbacks​

CallbackDescription
on_change — std::function<void(Slider&, float)>Fired as the value changes; also settable via set_on_change(fn)