TabsLayout

Implements: tracker.Observable

A horizontal tab layout component for organizing content into multiple pages.

TabsLayout provides a tab-based interface with clickable tab headers that can switch between different content views. It supports visual feedback for hover and selection states, individual tab themes, and disabled tabs. The layout automatically manages tab positioning, borders, and background rendering.

Key features:

  • Clickable tab headers with hover effects
  • Individual tab theming and state management
  • Disabled tab support
  • Automatic border and background management
  • Integration with window systems
  • Configurable margins and spacing
  • Depth-based tab ordering for visual layering

Usage example:

var tabsLayout = new TabsLayout();
tabsLayout.tabs = ['Tab 1', 'Tab 2', 'Tab 3'];
tabsLayout.selectedIndex = 0;
tabsLayout.marginX = 5;
tabsLayout.marginY = 2;

tabsLayout.onSelectedIndexChange(this, (index, prev) -> {
    trace('Selected tab: ' + index);
    // Switch content based on selected tab
});

add(tabsLayout);

Instance Members

elements
observedDirty: Bool

Default is false, automatically set to true when any of this instance's observable variables has changed.


elements
theme: Theme

Custom theme override for this tabs layout. If null, uses the global context theme


elements
marginX: Float

Horizontal margin extending beyond the tabs layout bounds.

This margin affects border and background rendering, extending the visual elements beyond the actual tab bounds for seamless integration with surrounding content.


elements
marginY: Float

Vertical margin extending beyond the tabs layout bounds.

This margin affects border and background rendering, extending the visual elements beyond the actual tab bounds for seamless integration with surrounding content.


elements
windowItem: WindowItem

Reference to the WindowItem managing this tabs layout, if applicable.

When the tabs layout is managed by a WindowItem, this property provides access to the window context for coordination and event handling.


elements
selectedIndex: Int

Index of the currently selected tab. -1 means no tab is selected


Array of tab labels to display in the tab headers


elements
tabStates: ceramic.ReadOnlyArray<TabState>

Array of states for each tab (NORMAL, DISABLED, etc.)


elements
tabThemes: ceramic.ReadOnlyArray<Theme>

Array of custom themes for individual tabs. Uses default theme if null for a tab


elements
invalidateTheme(): Void

elements
invalidateSelectedIndex(): Void

elements
invalidateTabs(): Void

elements
invalidateTabStates(): Void

elements
invalidateTabThemes(): Void

elements
invalidateTabViews(): Void

elements
invalidateHoverIndex(): Void

elements
new(): Void

Creates a new TabsLayout.

Sets up the basic layout properties, creates border elements, and initializes automatic updates for tab management and styling. Configures the layout for overlapping tabs with custom depth management.

Private Members

elements
unobservedTheme: Theme

elements
unobservedSelectedIndex: Int

elements
unobservedTabs: ceramic.ReadOnlyArray<String>

elements
unobservedTabStates: ceramic.ReadOnlyArray<TabState>

elements
unobservedTabThemes: ceramic.ReadOnlyArray<Theme>

elements
tabViews: Array<ceramic.TextView>

Internal array of TextView components representing the tab headers


elements
unobservedTabViews: Array<ceramic.TextView>

elements
hoverIndex: Int

Index of the tab currently being hovered by the mouse. -1 means no hover


elements
unobservedHoverIndex: Int

elements
appliedTabs: Array<String>

Cache of previously applied tab labels for change detection


elements
beforeBorder: ceramic.Quad

Border element rendered before the selected tab


elements
afterBorder: ceramic.Quad

Border element rendered after the selected tab


elements
beforeSelectedBackground: ceramic.Quad

Background element rendered before the selected tab area


elements
afterSelectedBackground: ceramic.Quad

Background element rendered after the selected tab area


elements
topBackground: ceramic.Quad

Background element rendered above the tabs


elements
bottomBackground: ceramic.Quad

Background element rendered below the tabs


elements
emitObservedDirty(instance: TabsLayout, fromSerializedField: Bool): Void

Event when any observable value as changed on this instance.

Name Type
instance TabsLayout
fromSerializedField Bool

elements
emitThemeChange(current: Theme, previous: Theme): Void

Event when theme field changes.

Name Type
current Theme
previous Theme

elements
emitSelectedIndexChange(current: Int, previous: Int): Void

Event when selectedIndex field changes.

Name Type
current Int
previous Int

elements
emitTabsChange(current: ceramic.ReadOnlyArray<String>, previous: ceramic.ReadOnlyArray<String>): Void

Event when tabs field changes.

Name Type
current ceramic.ReadOnlyArray<String>
previous ceramic.ReadOnlyArray<String>

elements
emitTabStatesChange(current: ceramic.ReadOnlyArray<TabState>, previous: ceramic.ReadOnlyArray<TabState>): Void

Event when tabStates field changes.

Name Type
current ceramic.ReadOnlyArray<TabState>
previous ceramic.ReadOnlyArray<TabState>

elements
emitTabThemesChange(current: ceramic.ReadOnlyArray<Theme>, previous: ceramic.ReadOnlyArray<Theme>): Void

Event when tabThemes field changes.

Name Type
current ceramic.ReadOnlyArray<Theme>
previous ceramic.ReadOnlyArray<Theme>

elements
emitTabViewsChange(current: Array<ceramic.TextView>, previous: Array<ceramic.TextView>): Void

Event when tabViews field changes.

Name Type
current Array<ceramic.TextView>
previous Array<ceramic.TextView>

elements
emitHoverIndexChange(current: Int, previous: Int): Void

Event when hoverIndex field changes.

Name Type
current Int
previous Int

elements
updateTabs(): Void

Updates the tab views based on the current tabs array.

Creates new TextView components for new tabs, removes unused tab views, and updates the visual hierarchy. This method is called automatically when the tabs array changes.


elements
renderWindowBackground(): Bool

Indicates whether this tabs layout should render window background.

This method is used by the window system to determine background rendering behavior. Always returns true for tabs layouts.

Returns Description
Bool true to enable window background rendering

elements
initTabView(index: Int, tabView: ceramic.TextView): Void

Initializes event handlers and behavior for a tab view.

Sets up hover tracking, click/touch handling for tab selection, and automatic touchable state management based on tab state.

Name Type Description
index Int The index of this tab
tabView ceramic.TextView The TextView component for this tab

elements
layout(): Void

Performs layout of tab views and manages visual depth ordering.

Updates tab depth values to create proper visual layering with the selected tab on top, positions border elements around the selected tab, and manages background element positioning based on margins and selection state.


elements
updateStyle(): Void

Updates the visual style of all tabs and background elements.

Applies theme-based styling to tab views based on their state (selected, hovered, disabled, normal). Manages border colors, background colors, text colors, and transparency. Also handles creation and destruction of background elements based on theme settings.

Metadata

Name Parameters
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()