41 explicit Tab(std::string title =
"");
43 const std::string &getTitle()
const noexcept {
return title_; }
44 void setTitle(std::string title);
79 std::shared_ptr<Tab>
addTab(std::string title, std::shared_ptr<Layout> content =
nullptr);
116 TabBarPosition getTabBarPosition() const noexcept {
return barPosition_; }
119 std::shared_ptr<Layout>
tabBar()
const {
return tabBar_; }
122 std::shared_ptr<Layout>
contentHost()
const {
return contentHost_; }
140 std::weak_ptr<Layout> pane;
141 std::shared_ptr<Button> button;
144 std::vector<std::shared_ptr<Layout>> collectPanes()
const;
145 std::string resolvePaneTitle(
const Layout &pane,
int index)
const;
147 void applyActiveVisuals();
148 int findNextEnabled(
int from,
int dir)
const;
149 int findEdgeEnabled(
bool first)
const;
151 std::shared_ptr<Layout> tabBar_;
152 std::shared_ptr<Layout> contentHost_;
153 std::vector<TabEntry> entries_;
156 int requestedInitialIndex_{0};
157 int activeIndex_{-1};
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.
The base node type: tree, style, layout, input, scroll, render.
Definition Layout.hpp:154
Layout(LayoutType type=LayoutType::Stack)
Construct a node with the given layout strategy.
Definition Layout.hpp:163
TLayout(Args &&...args)
Definition Layout.hpp:1401
void setTabTitle(int index, std::string title)
Update the title of the tab at index.
int tabCount() const
Number of tab pages currently inside this TabView.
static bool parseTabBarPosition(std::string_view s, TabBarPosition &out) noexcept
Parse "top" or "bottom".
int getActiveTab() const
Index of the active tab, or -1 if empty.
std::string getTabTitle(int index) const
Return the title of the tab at index, or "" if out of range.
std::shared_ptr< Layout > getTabPage(int index) const
Return the page node at index, or nullptr if out of range.
std::function< void(int)> onTabChanged
Fired whenever the active tab changes via user interaction or setActiveTab(i, true).
Definition TabView.hpp:128
std::shared_ptr< Layout > tabBar() const
Access the internal TabBar container.
Definition TabView.hpp:119
Vec2 measure(float parent_w, float parent_h) override
Compute the intrinsic size given available space.
bool removeTab(int index)
Remove the tab at index.
std::shared_ptr< Layout > contentHost() const
Access the internal TabContent container.
Definition TabView.hpp:122
std::shared_ptr< Button > tabButton(int index)
Return the Button corresponding to tab index, or nullptr if out of range.
void setActiveTab(int index, bool notify=false)
Activate the tab at index.
std::shared_ptr< Tab > addTab(std::string title, std::shared_ptr< Layout > content=nullptr)
Append a tab page and return its Tab wrapper node.
void setTabEnabled(int index, bool enabled)
Enable or disable the tab at index.
TabView(int initialSelected=0, TabBarPosition position=TabBarPosition::Top)
Construct a TabView.
void clearTabs()
Remove every tab page and tab button.
void onUpdate(float dt) override
Called every frame from update, after input dispatch.
Layout * contentTarget() override
Return the node that receives children when built from markup.
Definition TabView.hpp:130
void onBuild() override
Hook: called once after create() finishes constructing the object.
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25