41 onClick = std::move(cb);
44 setKeyboardActivates(
true);
45 setStyleTag(
"Button");
53 auto t = labelChild();
54 return t ? t->getText() : std::string{};
62 if (
auto t = labelChild())
67 auto lbl =
Label(s)->cls(
"btn-text");
69 addChild(std::move(lbl));
73 std::shared_ptr<Text> labelChild()
const
75 if (
auto cached = label_.lock())
77 if (cached->getParent().get() ==
this)
81 for (
const auto &c : children)
83 if (
auto t = std::dynamic_pointer_cast<Text>(c))
92 mutable std::weak_ptr<Text> label_;
98 inline std::shared_ptr<Button>
Btn(std::string text, std::function<
void()> cb =
nullptr)
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
Basic layout containers: VStack, HStack, Panel.
A read-only text node backed by UIContext::textEngine.
TLayout(Args &&...args)
Definition Layout.hpp:1401
static std::shared_ptr< Button > create(Args &&...args)
Definition Layout.hpp:1410
@ Center
Center within the available space.
Definition CoreTypes.hpp:455
@ Pointer
Pointing hand (buttons, links, interactive controls).
Definition UIEnums.hpp:64