62 Dropdown(std::vector<std::string> options,
int selected = 0);
71 const std::vector<std::string> &
getOptions()
const {
return options; }
74 void setOptions(std::vector<std::string> newOptions,
int newSelected = 0,
bool fireChange =
false);
96 std::function<void(
int,
const std::string &)>
onChange;
108 std::vector<std::string> options;
111 std::shared_ptr<Button> button;
112 std::shared_ptr<ScrollView> listContainer;
113 std::weak_ptr<Layout> prevFocus_;
116 void closeInternal(
bool restoreFocus);
117 void applyOpenState();
119 void positionList(
float scrollX,
float scrollY);
120 void refreshButtonText();
121 void updateListStyles();
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
A read-only text node backed by UIContext::textEngine.
TLayout(Args &&...args)
Definition Layout.hpp:1401
std::function< void(bool)> onOpenChanged
Fired when the list is opened or closed.
Definition Dropdown.hpp:98
void onEnabledChanged(bool nowEnabled) override
Called from setEnabled after the state change.
void setOptions(std::vector< std::string > newOptions, int newSelected=0, bool fireChange=false)
Replace the option list at runtime and rebuild the popup items.
void setOpen(bool o)
Open or close the option list.
int getSelected() const
Currently selected index.
Definition Dropdown.hpp:65
void onBuild() override
Hook: called once after create() finishes constructing the object.
const std::string & getSelectedText() const
Currently selected option string, or empty if none.
Dropdown(std::vector< std::string > options, int selected=0)
Construct with options and an initial selection.
bool setSelectedByText(const std::string &value, bool fireChange=false)
Select the first option whose label equals value.
std::function< void(int, const std::string &)> onChange
Fired when an item is selected.
Definition Dropdown.hpp:96
void arrange(Rect space) override
Assign a screen rect to this node and lay out its children.
void setSelected(int idx, bool fireChange=true)
Select the option at idx.
bool getOpen() const
true while the option list is visible.
Definition Dropdown.hpp:86
void onUpdate(float dt) override
Called every frame from update, after input dispatch.
const std::vector< std::string > & getOptions() const
Current option list.
Definition Dropdown.hpp:71
void translateSubtree(float dx, float dy) override
Translate the subtree (children and their descendants) by (dx, dy).
Axis-aligned rectangle in screen coordinates.
Definition CoreTypes.hpp:46