How-To: Tabs
Goal: a tab bar (settings screen, inventory categories) with design-time tabs, runtime-registered tabs, and per-tab content widgets.
UCrimsonButtonBase subclass to use as the tab button (see How-To: Buttons & Action Glyphs).1. Make the tab button
Create a Blueprint from Crimson Tab Button Base (UCrimsonTabButtonBase). It already implements ICrimsonTabButtonInterface; override the Set Tab Label Info event to receive an FCrimsonTabDescriptor (TabId, TabText, IconBrush) and populate your label/icon.
Images/CrimsonUI/howto-tab-button.png2. Make the tab list and preregister tabs
Create a Blueprint from Crimson Tab List Widget Base (UCrimsonTabListWidgetBase, a UCommonTabListWidgetBase). Fill PreregisteredTabInfoArray in Class Defaults - one FCrimsonTabDescriptor per design-time tab: TabId (unique FName), TabText, IconBrush, TabButtonType (your WBP_TabButton), and TabContentType (the UCommonUserWidget page shown while the tab is active). Then, as with any CommonUI tab list, call Set Linked Switcher (pointing at a UCommonActivatableWidgetSwitcher in your screen) before tabs are created - content widgets are instantiated into it.
Images/CrimsonUI/howto-tab-list.png3. Register tabs at runtime
Images/CrimsonUI/howto-tab-dynamic-bp.pngRuntime helpers (all BlueprintCallable): SetTabHiddenState(TabId, bHidden), IsTabVisible(TabId), GetVisibleTabCount(), GetTabContentForId(TabId), IsFirstTabActive() / IsLastTabActive() (for prev/next bumper logic), GetPreregisteredTabInfo(TabId). Bind OnTabContentCreated to touch each content widget as it is instantiated.
See also
- How-To: Buttons & Action Glyphs - the tab button's base class.
- How-To: Push & Pop Screens - hosting the tabbed screen on a layer.