ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Slider.hpp
Go to the documentation of this file.
1#pragma once
2
11
12#include "Common.hpp"
13#include "Layout.hpp"
14
15namespace ZenitUI::UI
16{
20
28 class Slider : public TLayout<Slider>
29 {
30 public:
34 explicit Slider(float val = 0.5f);
35
37 std::function<void(float)> onValueChanged = nullptr;
38
40 float getValue() const { return value; }
41
48 void setValue(float v, bool notify = true);
49
50 static constexpr const char *PART_TRACK = "track";
51 static constexpr const char *PART_FILL = "fill";
52 static constexpr const char *PART_KNOB = "knob";
53
54 protected:
55 Vec2 computeIntrinsicSize(float availW, float availH) override;
56 void onUpdate(float dt) override;
57 void renderContent(float op, const ComputedStyle &style) override;
58
59 private:
60 float value;
61 };
62
63} // namespace ZenitUI::UI
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
TLayout(Args &&...args)
Definition Layout.hpp:1401
void onUpdate(float dt) override
Called every frame from update, after input dispatch.
Slider(float val=0.5f)
Construct with an initial value, clamped to [0, 1].
Vec2 computeIntrinsicSize(float availW, float availH) override
Compute the intrinsic size, excluding padding and border.
std::function< void(float)> onValueChanged
Fired whenever the value changes, with the new value in [0, 1].
Definition Slider.hpp:37
void setValue(float v, bool notify=true)
Set the value and optionally fire onValueChanged.
float getValue() const
Current value in [0, 1].
Definition Slider.hpp:40
void renderContent(float op, const ComputedStyle &style) override
Draw the node's content (text, images, custom geometry).
Dense style: every property has a concrete value.
Definition Style.hpp:1036
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25