9#ifndef ASW_MODULES_UI_SLIDER_H
10#define ASW_MODULES_UI_SLIDER_H
77 std::optional<SliderStyle>
style;
120 void draw(
Context& ctx)
override;
Shared state for the UI system.
Theme theme
The current UI theme.
A horizontal slider for a value between min and max, e.g. volume.
const SliderStyle & get_style(const Context &ctx) const
Get the style this slider draws with.
std::function< void(float)> on_change
Callback invoked with the new value when the user changes it.
bool on_event(Context &ctx, const UIEvent &e) override
Handle dragging and left and right while focused.
bool adjusts_left_right() const
Whether left and right change the value right now, without editing.
float step
Change per left or right press. Dragging snaps to it when snap is set.
std::optional< bool > adjust_on_left_right
Whether left and right change the value without editing first. Empty to decide from the layout: off i...
bool snap
Snap dragged values to step.
void set_from_pointer(float x)
void on_focus_changed(Context &ctx, bool focused) override
Leave edit mode when focus moves away.
float value
Current value.
Slider()
Default constructor.
bool is_editing() const
Whether the slider is in edit mode.
std::optional< SliderStyle > style
Style for this slider only. Uses the theme slider style when empty.
void set_value(float v)
Set the value without calling on_change.
void activate(Context &ctx) override
Enter or leave edit mode when left and right move focus.
UI context and focus management for the ASW UI module.
How a slider looks. Set on Theme::slider for every slider, or on Slider::style for one slider.
SliderStyle slider
Default slider style.
Event structure for UI interactions.