TabBar

Inherits: Control < CanvasItem < Node < Object

Tab bar control.

Description

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

Methods

void

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

void

clear_tab_opentype_features ( int tab_idx )

void

ensure_tab_visible ( int idx )

bool

get_offset_buttons_visible ( ) const

int

get_previous_tab ( ) const

bool

get_select_with_rmb ( ) const

int

get_tab_count ( ) const

bool

get_tab_disabled ( int tab_idx ) const

Texture2D

get_tab_icon ( int tab_idx ) const

String

get_tab_language ( int tab_idx ) const

int

get_tab_offset ( ) const

int

get_tab_opentype_feature ( int tab_idx, String tag ) const

Rect2

get_tab_rect ( int tab_idx ) const

TextDirection

get_tab_text_direction ( 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_disabled ( int tab_idx, bool disabled )

void

set_tab_icon ( int tab_idx, Texture2D icon )

void

set_tab_language ( int tab_idx, String language )

void

set_tab_opentype_feature ( int tab_idx, String tag, int values )

void

set_tab_text_direction ( int tab_idx, TextDirection direction )

void

set_tab_title ( int tab_idx, String title )

void

set_tabs_rearrange_group ( int group_id )

Signals

  • active_tab_rearranged ( int idx_to )

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


  • 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_pressed ( int tab )

Emitted when a tab's close button is pressed.

Note: Tabs are not removed automatically once the close button is pressed, this behaviour needs to be programmed manually. For example:

$TabBar.tab_close_pressed.connect($TabBar.remove_tab)

  • tab_hovered ( int tab )

Emitted when a tab is hovered by the mouse.


  • tab_rmb_clicked ( int tab )

Emitted when a tab is right-clicked.

Enumerations

enum TabAlign:

  • ALIGN_LEFT = 0 --- Align the tabs to the left.

  • ALIGN_CENTER = 1 --- Align the tabs to the center.

  • ALIGN_RIGHT = 2 --- Align the tabs to the right.

  • ALIGN_MAX = 3 --- Represents the size of the TabAlign enum.


enum CloseButtonDisplayPolicy:

  • CLOSE_BUTTON_SHOW_NEVER = 0 --- Never show the close buttons.

  • CLOSE_BUTTON_SHOW_ACTIVE_ONLY = 1 --- Only show the close button on the currently active tab.

  • CLOSE_BUTTON_SHOW_ALWAYS = 2 --- Show the close button on all tabs.

  • CLOSE_BUTTON_MAX = 3 --- Represents the size of the CloseButtonDisplayPolicy enum.

Property Descriptions

Default

true

Setter

set_clip_tabs(value)

Getter

get_clip_tabs()

If true, tabs overflowing this node's width will be hidden, displaying two navigation buttons instead. Otherwise, this node's minimum size is updated so that all tabs are visible.


  • int current_tab

Default

0

Setter

set_current_tab(value)

Getter

get_current_tab()

Select tab at index tab_idx.


  • bool drag_to_rearrange_enabled

Default

false

Setter

set_drag_to_rearrange_enabled(value)

Getter

get_drag_to_rearrange_enabled()

If true, tabs can be rearranged with mouse drag.


  • bool scrolling_enabled

Default

true

Setter

set_scrolling_enabled(value)

Getter

get_scrolling_enabled()

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


Default

1

Setter

set_tab_align(value)

Getter

get_tab_align()

The alignment of all tabs. See TabAlign for details.


Default

0

Setter

set_tab_close_display_policy(value)

Getter

get_tab_close_display_policy()

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

Method Descriptions

Adds a new tab.


  • void clear_tab_opentype_features ( int tab_idx )

Removes all OpenType features from the tab title.


  • 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.


  • 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.


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


  • String get_tab_language ( int tab_idx ) const

Returns tab title language code.


  • int get_tab_offset ( ) const

Returns the number of hidden tabs offsetted to the left.


  • int get_tab_opentype_feature ( int tab_idx, String tag ) const

Returns OpenType feature tag of the tab title.


  • Rect2 get_tab_rect ( int tab_idx ) const

Returns tab Rect2 with local position and size.


Returns tab title text base writing direction.


Returns the title of the tab at index tab_idx.


  • int get_tabs_rearrange_group ( ) const

Returns the TabBar's 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_disabled ( int tab_idx, bool disabled )

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


Sets an icon for the tab at index tab_idx.


  • void set_tab_language ( int tab_idx, String language )

Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.


  • void set_tab_opentype_feature ( int tab_idx, String tag, int values )

Sets OpenType feature tag for the tab title. More info: OpenType feature tags.


Sets tab title base writing direction.


  • 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 TabBar the same value to dragging tabs between TabBar. Enable drag with drag_to_rearrange_enabled.

Theme Property Descriptions

The icon for the close button (see tab_close_display_policy).


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


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


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.


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.


The font used to draw tab names.


  • Color font_disabled_color

Default

Color(0.9, 0.9, 0.9, 0.2)

Font color of disabled tabs.


  • Color font_outline_color

Default

Color(1, 1, 1, 1)

The tint of text outline of the tab name.


  • Color font_selected_color

Default

Color(0.94, 0.94, 0.94, 1)

Font color of the currently selected tab.


  • int font_size

Font size of the tab names.


  • Color font_unselected_color

Default

Color(0.69, 0.69, 0.69, 1)

Font color of the other, unselected tabs.


  • int hseparation

Default

4

The horizontal separation between the elements inside tabs.


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.


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.


  • int outline_size

Default

0

The size of the tab text outline.


The style of disabled tabs.


The style of the currently selected tab.


The style of the other, unselected tabs.