ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Checkbox.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 Checkbox : public TLayout<Checkbox>
29 {
30 public:
35 explicit Checkbox(bool state = false);
36
38 void toggle(bool notify = true);
39
41 std::function<void(bool)> onToggle = nullptr;
44
45 static constexpr const char *PART_BOX = "box";
46 static constexpr const char *PART_MARK = "mark";
47
48 protected:
49 void onCheckedChanged(bool nowChecked) override;
50 Vec2 computeIntrinsicSize(float availW, float availH) override;
51 void renderContent(float op, const ComputedStyle &style) override;
52 };
53
54} // 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
Checkbox(bool state=false)
Construct with an initial state.
std::function< void(bool)> onToggle
Fired after the checked state changes via user interaction or toggle(true).
Definition Checkbox.hpp:41
void renderContent(float op, const ComputedStyle &style) override
Draw the node's content (text, images, custom geometry).
void toggle(bool notify=true)
Flip the checked state and optionally fire onToggle.
bool isChecked
Legacy mirror of getChecked().
Definition Checkbox.hpp:43
Vec2 computeIntrinsicSize(float availW, float availH) override
Compute the intrinsic size, excluding padding and border.
void onCheckedChanged(bool nowChecked) override
Called from setChecked after the checked state changes.
Dense style: every property has a concrete value.
Definition Style.hpp:1036
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25