Tabs

Inherits: Control < CanvasItem < Node < Object

Tabs control.

Description

Simple tabs control, similar to TabContainer but is only in charge of drawing tabs, not interacting with children.

Properties

int

current_tab

0

bool

drag_to_rearrange_enabled

false

bool

scrolling_enabled

true

TabAlign

tab_align

1

CloseButtonDisplayPolicy

tab_close_display_policy

0

Methods

void

add_tab ( String title="", Texture icon=null )

void

ensure_tab_visible ( int idx )

bool

get_offset_buttons_visible ( ) const

int

get_previous_tab ( ) const

bool

get_select_with_rmb ( ) const

Texture

get_tab_button_icon ( int tab_idx ) const

int

get_tab_count ( ) const

bool

get_tab_disabled ( int tab_idx ) const

Texture

get_tab_icon ( int tab_idx ) const

int

get_tab_offset ( ) const

Rect2

get_tab_rect ( int tab_idx ) const

String

get_tab_title ( int tab_idx ) const

int

get_tabs_rearrange_group ( ) const

void

move_tab ( int from, int to )

void

remove_tab ( int tab_idx )

void

set_select_with_rmb ( bool enabled )

void

set_tab_button_icon ( int tab_idx, Texture icon )

void

set_tab_disabled ( int tab_idx, bool disabled )

void

set_tab_icon ( int tab_idx, Texture icon )

void

set_tab_title ( int tab_idx, String title )

void

set_tabs_rearrange_group ( int group_id )

Theme Properties

Color

font_color_bg

Color( 0.69, 0.69, 0.69, 1 )

Color

font_color_disabled

Color( 0.9, 0.9, 0.9, 0.2 )

Color

font_color_fg

Color( 0.94, 0.94, 0.94, 1 )

int

hseparation

4

int

label_valign_bg

2

int

label_valign_fg

0

int

top_margin

24

Font

font

Texture

close

Texture

decrement

Texture

decrement_highlight

Texture

increment

Texture

increment_highlight

StyleBox

button

StyleBox

button_pressed

StyleBox

tab_bg

StyleBox

tab_disabled

StyleBox

tab_fg


Signals

reposition_active_tab_request ( int idx_to )

Emitted when the active tab is rearranged via mouse drag. See drag_to_rearrange_enabled.


right_button_pressed ( int tab )

Emitted when a tab's right button is pressed. See set_tab_button_icon.


tab_changed ( int tab )

Emitted when switching to another tab.


tab_clicked ( int tab )

Emitted when a tab is clicked, even if it is the current tab.


tab_close ( int tab )

Emitted when a tab is closed.


tab_hover ( int tab )

Emitted when a tab is hovered by the mouse.


Enumerations

enum TabAlign:

TabAlign ALIGN_LEFT = 0

Align the tabs to the left.

TabAlign ALIGN_CENTER = 1

Align the tabs to the center.

TabAlign ALIGN_RIGHT = 2

Align the tabs to the right.

TabAlign ALIGN_MAX = 3

Represents the size of the TabAlign enum.


enum CloseButtonDisplayPolicy:

CloseButtonDisplayPolicy CLOSE_BUTTON_SHOW_NEVER = 0

Never show the close buttons.

CloseButtonDisplayPolicy CLOSE_BUTTON_SHOW_ACTIVE_ONLY = 1

Only show the close button on the currently active tab.

CloseButtonDisplayPolicy CLOSE_BUTTON_SHOW_ALWAYS = 2

Show the close button on all tabs.

CloseButtonDisplayPolicy CLOSE_BUTTON_MAX = 3

Represents the size of the CloseButtonDisplayPolicy enum.


Property Descriptions

int current_tab = 0

  • void set_current_tab ( int value )

  • int get_current_tab ( )

Select tab at index tab_idx.


bool drag_to_rearrange_enabled = false

  • void set_drag_to_rearrange_enabled ( bool value )

  • bool get_drag_to_rearrange_enabled ( )

If true, tabs can be rearranged with mouse drag.


bool scrolling_enabled = true

  • void set_scrolling_enabled ( bool value )

  • bool get_scrolling_enabled ( )

if true, the mouse's scroll wheel can be used to navigate the scroll view.


TabAlign tab_align = 1

The alignment of all tabs. See TabAlign for details.


CloseButtonDisplayPolicy tab_close_display_policy = 0

Sets when the close button will appear on the tabs. See CloseButtonDisplayPolicy for details.


Method Descriptions

void add_tab ( String title="", Texture icon=null )

Adds a new tab.


void ensure_tab_visible ( int idx )

Moves the scroll view to make the tab visible.


bool get_offset_buttons_visible ( ) const

Returns true if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.


int get_previous_tab ( ) const

Returns the previously active tab index.


bool get_select_with_rmb ( ) const

Returns true if select with right mouse button is enabled.


Texture get_tab_button_icon ( int tab_idx ) const

Returns the button icon from the tab at index tab_idx.


int get_tab_count ( ) const

Returns the number of tabs.


bool get_tab_disabled ( int tab_idx ) const

Returns true if the tab at index tab_idx is disabled.


Texture get_tab_icon ( int tab_idx ) const

Returns the Texture for the tab at index tab_idx or null if the tab has no Texture.


int get_tab_offset ( ) const

Returns the number of hidden tabs offsetted to the left.


Rect2 get_tab_rect ( int tab_idx ) const

Returns tab Rect2 with local position and size.


String get_tab_title ( int tab_idx ) const

Returns the title of the tab at index tab_idx.


int get_tabs_rearrange_group ( ) const

Returns the Tabs' rearrange group ID.


void move_tab ( int from, int to )

Moves a tab from from to to.


void remove_tab ( int tab_idx )

Removes the tab at index tab_idx.


void set_select_with_rmb ( bool enabled )

If true, enables selecting a tab with the right mouse button.


void set_tab_button_icon ( int tab_idx, Texture icon )

Sets the button icon from the tab at index tab_idx.


void set_tab_disabled ( int tab_idx, bool disabled )

If disabled is true, disables the tab at index tab_idx, making it non-interactable.


void set_tab_icon ( int tab_idx, Texture icon )

Sets an icon for the tab at index tab_idx.


void set_tab_title ( int tab_idx, String title )

Sets a title for the tab at index tab_idx.


void set_tabs_rearrange_group ( int group_id )

Defines the rearrange group ID. Choose for each Tabs the same value to dragging tabs between Tabs. Enable drag with drag_to_rearrange_enabled.


Theme Property Descriptions

Color font_color_bg = Color( 0.69, 0.69, 0.69, 1 )

Font color of inactive tabs.


Color font_color_disabled = Color( 0.9, 0.9, 0.9, 0.2 )

Font color of disabled tabs.


Color font_color_fg = Color( 0.94, 0.94, 0.94, 1 )

Font color of the currently selected tab.


int hseparation = 4

The horizontal separation between the tabs.


int label_valign_bg = 2

There is currently no description for this theme property. Please help us by contributing one!


int label_valign_fg = 0

There is currently no description for this theme property. Please help us by contributing one!


int top_margin = 24

There is currently no description for this theme property. Please help us by contributing one!


Font font

The font used to draw tab names.


Texture close

The icon for the close button (see tab_close_display_policy).


Texture decrement

Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent.


Texture decrement_highlight

Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.


Texture increment

Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent.


Texture increment_highlight

Icon for the right arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.


StyleBox button

Background of the close button when it's being hovered with the cursor.


StyleBox button_pressed

Background of the close button when it's being pressed.


StyleBox tab_bg

The style of an inactive tab.


StyleBox tab_disabled

The style of a disabled tab


StyleBox tab_fg

The style of the currently selected tab.