|
ZenitUI
Retained-mode C++20 UI framework
|
Container displaying a strip of selectable tabs and one active page at a time. More...
#include <TabView.hpp>
Public Member Functions | |
| TabView (int initialSelected=0, TabBarPosition position=TabBarPosition::Top) | |
| Construct a TabView. | |
| std::shared_ptr< Tab > | addTab (std::string title, std::shared_ptr< Layout > content=nullptr) |
| Append a tab page and return its Tab wrapper node. | |
| bool | removeTab (int index) |
Remove the tab at index. | |
| void | clearTabs () |
| Remove every tab page and tab button. | |
| int | tabCount () const |
| Number of tab pages currently inside this TabView. | |
| int | getActiveTab () const |
| Index of the active tab, or -1 if empty. | |
| void | setActiveTab (int index, bool notify=false) |
Activate the tab at index. | |
| void | setTabTitle (int index, std::string title) |
Update the title of the tab at index. | |
| std::string | getTabTitle (int index) const |
Return the title of the tab at index, or "" if out of range. | |
| void | setTabEnabled (int index, bool enabled) |
Enable or disable the tab at index. | |
| std::shared_ptr< Layout > | getTabPage (int index) const |
Return the page node at index, or nullptr if out of range. | |
| std::shared_ptr< Button > | tabButton (int index) |
Return the Button corresponding to tab index, or nullptr if out of range. | |
| void | setTabBarPosition (TabBarPosition pos) |
| TabBarPosition | getTabBarPosition () const noexcept |
| std::shared_ptr< Layout > | tabBar () const |
| Access the internal TabBar container. | |
| std::shared_ptr< Layout > | contentHost () const |
| Access the internal TabContent container. | |
| Layout * | contentTarget () override |
| Return the node that receives children when built from markup. | |
| Vec2 | measure (float parent_w, float parent_h) override |
| Compute the intrinsic size given available space. | |
| Public Member Functions inherited from ZenitUI::TLayout< TabView > | |
| TLayout (Args &&...args) | |
Forward constructor arguments to Base. | |
| std::shared_ptr< TabView > | cls (const std::string &name) |
| Fluent addClass; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | id (const std::string &node_id) |
| Fluent setId; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | withRef (const std::string &r) |
| Fluent setRef; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | size (Value w, Value h) |
| Fluent setSize; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | passThrough (bool p=true) |
| Fluent setPassThrough; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | with (std::shared_ptr< Layout > c) |
| Fluent addChild; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< TabView > | self () |
| Return shared_from_this() statically cast to Derived. | |
| Public Member Functions inherited from ZenitUI::Layout | |
| Layout (LayoutType type=LayoutType::Stack) | |
| Construct a node with the given layout strategy. | |
| virtual | ~Layout () |
| Destroy the node and clean up framework-side references. | |
| template<typename T = Layout> | |
| std::shared_ptr< T > | as () |
| static_pointer_cast helper returning shared_ptr<T>. | |
| void | addClass (const std::string &className) |
| Add a class name to the node's style class list. | |
| void | removeClass (const std::string &className) |
| Remove a class name; no-op if absent. | |
| void | clearStyleClasses () |
| Remove every class name. | |
| void | setStyleTag (const std::string &t) |
| Set the node's style tag. | |
| bool | hasClass (const std::string &className) const |
| true if the node has the given class. | |
| bool | hasId (const std::string &targetId) const |
true if the node's nodeId equals targetId. | |
| void | setId (const std::string &node_id) |
| Set the node's #id (used in selectors and by UINode::find). | |
| void | setRef (const std::string &r) |
| Set the node's @ref (used by UINode::ref / refAll). | |
| const std::string & | getStyleTag () const |
| const std::vector< std::string > & | getStyleClasses () const |
| void | setSize (Value w, Value h) |
| Convenience: set explicit width and height. | |
| std::shared_ptr< Layout > | cls (const std::string &className) |
| Fluent addClass; returns shared_from_this(). | |
| std::shared_ptr< Layout > | id (const std::string &node_id) |
| Fluent setId; returns shared_from_this(). | |
| std::shared_ptr< Layout > | size (Value w, Value h) |
| Fluent setSize; returns shared_from_this(). | |
| std::shared_ptr< Layout > | with (std::shared_ptr< Layout > child) |
| Fluent addChild; returns shared_from_this(). | |
| void | addChild (std::shared_ptr< Layout > child) |
Append child to this node's child list. | |
| void | insertChildBefore (const Layout *anchor, std::shared_ptr< Layout > child) |
Insert child immediately before anchor (or append if anchor is not found). | |
| bool | moveChildBefore (const Layout *anchor, const Layout *child) |
Reposition an existing direct child immediately before anchor (or at the end if anchor is not found) without detaching its UIContext. | |
| bool | removeChild (const Layout *child) |
| Synchronously detach a single direct child, clearing its parent pointer. | |
| void | removeFromParent () |
| Request removal at the next culling pass. | |
| virtual void | removeAllChildren () |
| Detach every child immediately, clearing their parent pointers. | |
| void | retainObject (std::shared_ptr< void > obj) |
| Retain an arbitrary type-erased object for the lifetime of this node. | |
| std::shared_ptr< Layout > | getParent () const |
| bool | hasParent () const |
| bool | isAncestorOf (const Layout *other) const |
true if this node is an ancestor of other. | |
| void | setInteractive (bool interactive) |
| void | setBlocksRaycast (bool blocks) |
| void | setEnabled (bool e) |
| Enable or disable the node. | |
| bool | getEnabled () const |
| void | setVisible (bool v) |
| Show or hide the node (display: none semantics). | |
| bool | isVisible () const |
| void | setChecked (bool c) |
| Set the :checked pseudo-class state. | |
| bool | getChecked () const |
| bool | isHoveredState () const |
| bool | isPressedState () const |
| bool | isFocusedState () const |
| bool | isDisabledState () const |
| bool | isCheckedState () const |
| void | setUpdateWhenDisabled (bool v) |
| bool | getUpdateWhenDisabled () const |
| void | beginTransition () |
| Restart the current style transition from the current value. | |
| void | setFocusable (bool f) |
| bool | isFocusable () const |
| bool | getFocused () const |
| void | setFocusScope (bool s) |
| bool | isFocusScope () const |
| void | notifyDescendantFocused (Layout *descendant) |
| Notify the node that one of its descendants gained focus. | |
| bool | isStackingContext () const |
| true if the node has a non-static position and a non-auto zIndex. | |
| int | getZIndex () const |
| Effective zIndex; returns 0 for the "auto" case. | |
| bool | isScrollContainer () const |
| true if either overflow axis is non-visible. | |
| void | scrollTo (float x, float y) |
| Set the scroll offset, clamped to the valid range. | |
| void | scrollToX (float x) |
| void | scrollToY (float y) |
| void | scrollToTop () |
| void | scrollToBottom () |
| void | scrollToLeft () |
| void | scrollToRight () |
| bool | scrollIntoView (float margin=0.0f) |
Scroll the nearest scrolling ancestor so that this node's rect becomes visible, respecting margin. | |
| bool | scrollIntoView (const Rect &subRect, float margin=0.0f) |
Scroll the nearest scrolling ancestor so that subRect becomes visible, respecting margin. | |
| float | getScrollX () const |
| float | getScrollY () const |
| float | getMaxScrollX () const |
| float | getMaxScrollY () const |
| void | setPortal (bool p) |
| Enable or disable portal rendering for this node. | |
| bool | isPortal () const |
| void | setPassThrough (bool p) |
| bool | getPassThrough () const |
| void | setDraggable (bool d) |
| bool | isDraggable () const |
| void | setDroppable (bool d) |
| bool | isDroppable () const |
| DragHandlers & | drag () |
| Access Drag & Drop callbacks for this node, allocating storage lazily on first call. | |
| const DragHandlers * | dragHandlers () const noexcept |
| Non-allocating read access to Drag & Drop callbacks, or nullptr if none were set. | |
| void | capturePointer () |
| Capture the pointer: all subsequent input events go to this node. | |
| void | releasePointer () |
| Release the pointer capture if this node owns it. | |
| bool | hasPointerCapture () const |
| true if this node currently holds the pointer capture. | |
| void | setKeyboardActivates (bool v) |
| bool | getKeyboardActivates () const |
| LayoutType | getLayoutType () const |
| LayoutType | getEffectiveLayoutType () const |
| FontHandle | resolveFont (const ComputedStyle &style, FontHandle fallback={}) const |
| Resolve a FontHandle from the node's style font stack. | |
| ResolvedBgTexture | resolveBgTexture (const ComputedStyle &style, TextureHandle fallbackTex={}, NineSlice fallbackSlice={0, 0, 0, 0}) |
| Resolve the background texture from the style, falling back to explicit parameters if the style has no background-texture. | |
| void | setInlineBase (const Style &s) |
Overlay s onto the node's inline style (highest priority). | |
| Style & | getInlineBase () |
| Direct mutable access to the inline style. | |
| Style & | getInlineDefaults () |
| Direct mutable access to the inline defaults (lowest-priority inline). | |
| void | addAnimation (const std::string &name, std::shared_ptr< UIAnimation > anim) |
Register an imperative animation under name. | |
| void | playAnimation (const std::string &name, bool playReverse=false) |
Start (or restart) the imperative animation named name. | |
| bool | hasActiveAnimations () const |
| true if this node or any descendant is currently animating. | |
| void | addCssAnimation (const std::string &name) |
| Manually start a CSS animation by name. | |
| void | stopCssAnimation (const std::string &name) |
| Mark the named CSS animation as finished. | |
| virtual void | arrange (Rect space) |
| Assign a screen rect to this node and lay out its children. | |
| virtual void | update (float dt, bool ancestorBlocked=false, bool scrolling=false) |
| Per-frame update: input, style, animation, then recurse into children. | |
| virtual void | draw (float parentOpacity=1.0f) |
| Draw the node and its children. | |
| Layout * | hitTest (Vec2 p, bool ancestorBlocked=false, const Rect *clipLocal=nullptr) |
| Hit-test a point against this subtree. | |
| Layout * | hitTestDroppable (Vec2 p, const DragPayload &payload, const Layout *excludeSource, const Layout *excludeGhost, const Rect *clipLocal=nullptr) |
| Hit-test a point against droppable nodes during an active drag (ยง5.22b). | |
| void | updateTree (float dt) |
| Root-of-tree update: refresh pointer state and recurse. | |
| void | runFrame (float dt) |
| Run one full frame: update, measure, arrange. | |
| void | renderFrame () |
| Render the current state: beginFrame, draw, endFrame. | |
| Rect | getRect () const |
| Vec2 | getMeasuredSize () const |
| const ComputedStyle & | getStyle () const |
| std::vector< const ThemeRule * > | getMatchingRules () const |
| Return the stylesheet theme of the active UIContext. | |
| UIContext * | contextPtr () const |
| Return the UIContext this node is attached to, or nullptr if unmounted. | |
| UIContext * | context () const |
| Return the UIContext this node is attached to, or nullptr if unmounted. | |
| void | attachContext (UIContext *newCtx) |
Attach this node and its subtree to newCtx. | |
| void | detachContext () |
| Detach this node and its subtree from its current UIContext. | |
| Vec2 | viewportSize () const |
| Return the logical viewport size of this node's UIContext (or {0, 0} if unmounted). | |
| const Theme & | theme () const |
| Return the stylesheet theme of this node's UIContext (or an empty theme if unmounted). | |
| void | setBackgroundTexture (TextureHandle tex, NineSlice np={0, 0, 0, 0}) |
| Override the background texture with a direct handle. | |
| void | setShader (EffectHandle shader) |
| Set a custom shader effect applied to the node's content. | |
| void | invalidateLayerCache () |
| Mark any cached off-screen filter layer on this node and its ancestors as dirty so it is re-baked on the next draw pass. | |
| void | resetInteractionState () |
| Reset transient interaction state (hovered, pressed, focused, capture, and current UIState) across this subtree, firing onHoverExit if currently hovered. | |
| void | snapStyleImmediate () |
| Immediately resolve style rules and clear pending transitions across this subtree so recycled nodes position and style on the same frame. | |
Static Public Member Functions | |
| static bool | parseTabBarPosition (std::string_view s, TabBarPosition &out) noexcept |
| Parse "top" or "bottom". | |
| Static Public Member Functions inherited from ZenitUI::TLayout< TabView > | |
| static std::shared_ptr< TabView > | create (Args &&...args) |
| Construct a shared_ptr<Derived> and call onBuild(). | |
Public Attributes | |
| std::function< void(int)> | onTabChanged |
| Fired whenever the active tab changes via user interaction or setActiveTab(i, true). | |
| Public Attributes inherited from ZenitUI::Layout | |
| std::function< void()> | onHoverEnter |
| std::function< void()> | onHoverExit |
| std::function< void()> | onPress |
| std::function< void()> | onRelease |
| std::function< void()> | onClick |
| std::function< void()> | onRightClick |
| Right-click hook; fires on right-button press over the node. | |
| std::function< void(MouseButton)> | onButtonPress |
| std::function< void(MouseButton)> | onButtonRelease |
| std::function< void(MouseButton)> | onButtonClick |
| std::function< void()> | onAnimationsFinished |
| Called when the node had active local animations and now has none. | |
| std::vector< std::shared_ptr< Layout > > | children |
| Children of this node. | |
| std::string | nodeId |
| #id for selector matching and UINode::find. | |
| std::string | ref |
| @ref for UINode::ref / refAll lookup. | |
Protected Member Functions | |
| void | onBuild () override |
| Hook: called once after create() finishes constructing the object. | |
| void | onUpdate (float dt) override |
| Called every frame from update, after input dispatch. | |
| Protected Member Functions inherited from ZenitUI::Layout | |
| void | invalidateIfRelevant (SimpleSelector::Kind kind, std::string_view name) |
| Propagate a class/tag change to descendants that may match it. | |
| void | invalidateStyleCacheRecursive () |
| Mark the whole subtree as needing style re-resolution. | |
| void | invalidateFollowingSiblings (SimpleSelector::Kind kind, std::string_view name) |
| void | invalidateFollowingSiblingsCache () |
| void | invalidateChildrenForSiblingRules () |
| Style | partStyle (const std::string &partName) |
Resolve the style for pseudo-element partName. | |
| virtual Vec2 | computeIntrinsicSize (float, float) |
| Compute the intrinsic size, excluding padding and border. | |
| virtual void | onLayout () |
| Called after arrange assigns the node's rect. | |
| virtual void | onEnabledChanged (bool) |
| Called from setEnabled after the state change. | |
| virtual void | onCheckedChanged (bool) |
| Called from setChecked after the checked state changes. | |
| virtual void | onDetachContext (UIContext *) |
| Called from detachContext() right before clearing ctx_. | |
| EffectHandle | resolveActiveEffect () |
| Resolve the currently active effect handle. | |
| virtual void | renderContent (float, const ComputedStyle &) |
| Draw the node's content (text, images, custom geometry). | |
| virtual void | renderChrome (float op, const ComputedStyle &style) |
| Draw the node's background, border, and shadow. | |
| virtual void | onDescendantFocused (Layout *) |
| Called on ancestors when a descendant gains focus. | |
| void | arrangeInto (Rect space) |
| Dispatch to the layout-type-specific arrange helper. | |
| Transform2D | currentTransform (const ComputedStyle &style) const |
| Compute the current transform from the style's translateX/translateY/rotation/scale. | |
| virtual void | translateSubtree (float dx, float dy) |
| Translate the subtree (children and their descendants) by (dx, dy). | |
Container displaying a strip of selectable tabs and one active page at a time.
Style tag: "TabView". Child sub-nodes use tags/classes:
Supports mouse clicks and keyboard navigation (Left/Right/Home/End) while a tab button has focus, automatically skipping disabled tabs.
|
explicit |
|
inlineoverridevirtual |
Return the node that receives children when built from markup.
Components that wrap their content in a sub-layout (e.g. Modal keeps its children inside content) override this to point at the wrapper. Default: this.
Reimplemented from ZenitUI::Layout.
|
overridevirtual |
Compute the intrinsic size given available space.
Called bottom-up during measure. Subclasses override computeIntrinsicSize (which receives the available space after padding / border) rather than this method directly.
| parent_w | Available width from the parent, in pixels. |
| parent_h | Available height from the parent, in pixels. |
Reimplemented from ZenitUI::Layout.
|
overrideprotectedvirtual |
Hook: called once after create() finishes constructing the object.
Reimplemented from ZenitUI::TLayout< TabView >.
|
overrideprotectedvirtual |
Called every frame from update, after input dispatch.
Reimplemented from ZenitUI::Layout.
| bool ZenitUI::UI::TabView::removeTab | ( | int | index | ) |
Remove the tab at index.
Returns false if out of range.
| void ZenitUI::UI::TabView::setActiveTab | ( | int | index, |
| bool | notify = false ) |
Activate the tab at index.
| index | 0-based tab index (clamped when tabs exist). |
| notify | Fire onTabChanged if the active index changed. |