40 setKeyboardActivates(
true);
44 defs.width = Px(44.0f);
45 defs.height = Px(24.0f);
46 defs.radius = Px(12.0f);
47 defs.background = state ?
Color{37, 99, 235, 255} :
Color{55, 62, 78, 255};
61 const bool next = !getChecked();
78 knob->getInlineDefaults().left = nowChecked ? Px(23.0f) : Px(3.0f);
84 knob->cls(
"toggle-knob");
85 knob->setInteractive(
false);
86 knob->setBlocksRaycast(
false);
87 auto &kdefs = knob->getInlineDefaults();
88 kdefs.position = Position::Absolute;
89 kdefs.width = Px(18.0f);
90 kdefs.height = Px(18.0f);
91 kdefs.radius = Px(9.0f);
93 kdefs.left = getChecked() ? Px(23.0f) : Px(3.0f);
94 kdefs.background = Colors::White;
99 std::shared_ptr<Layout> knob;
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
void setStyleTag(const std::string &t)
Set the node's style tag.
Style & getInlineDefaults()
Direct mutable access to the inline defaults (lowest-priority inline).
Definition Layout.hpp:735
void setChecked(bool c)
Set the :checked pseudo-class state.
Definition Layout.hpp:447
void addChild(std::shared_ptr< Layout > child)
Append child to this node's child list.
Definition Layout.hpp:302
TLayout(Args &&...args)
Definition Layout.hpp:1401
bool isChecked
Legacy mirror of getChecked().
Definition Toggle.hpp:70
void onBuild() override
Hook: called once after create() finishes constructing the object.
Definition Toggle.hpp:81
std::function< void(bool)> onToggle
Fired after the checked state changes via user interaction or toggle(true).
Definition Toggle.hpp:68
void toggle(bool notify=true)
Flip the checked state and optionally fire onToggle.
Definition Toggle.hpp:59
void onCheckedChanged(bool nowChecked) override
Called from setChecked after the checked state changes.
Definition Toggle.hpp:73
Toggle(bool state=false)
Construct with an initial state.
Definition Toggle.hpp:35
LayoutType
Positioning strategy applied to a Layout node's direct children.
Definition UIEnums.hpp:29
@ Stack
Children overlap each other; Z-order controls paint order.
Definition UIEnums.hpp:30
@ Pointer
Pointing hand (buttons, links, interactive controls).
Definition UIEnums.hpp:64
8-bit-per-channel RGBA color, non-premultiplied.
Definition CoreTypes.hpp:78