class_tabbar.rst 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/TabBar.xml.
  6. .. _class_TabBar:
  7. TabBar
  8. ======
  9. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Tab bar control.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Simple tabs control, similar to :ref:`TabContainer<class_TabContainer>` but is only in charge of drawing tabs, not interacting with children.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  21. | :ref:`bool<class_bool>` | :ref:`clip_tabs<class_TabBar_property_clip_tabs>` | ``true`` |
  22. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  23. | :ref:`int<class_int>` | :ref:`current_tab<class_TabBar_property_current_tab>` | ``0`` |
  24. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  25. | :ref:`bool<class_bool>` | :ref:`drag_to_rearrange_enabled<class_TabBar_property_drag_to_rearrange_enabled>` | ``false`` |
  26. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  27. | :ref:`int<class_int>` | :ref:`max_tab_width<class_TabBar_property_max_tab_width>` | ``0`` |
  28. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`scroll_to_selected<class_TabBar_property_scroll_to_selected>` | ``true`` |
  30. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  31. | :ref:`bool<class_bool>` | :ref:`scrolling_enabled<class_TabBar_property_scrolling_enabled>` | ``true`` |
  32. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  33. | :ref:`bool<class_bool>` | :ref:`select_with_rmb<class_TabBar_property_select_with_rmb>` | ``false`` |
  34. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  35. | :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` | :ref:`tab_alignment<class_TabBar_property_tab_alignment>` | ``0`` |
  36. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  37. | :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` | :ref:`tab_close_display_policy<class_TabBar_property_tab_close_display_policy>` | ``0`` |
  38. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  39. | :ref:`int<class_int>` | :ref:`tab_count<class_TabBar_property_tab_count>` | ``0`` |
  40. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  41. | :ref:`int<class_int>` | :ref:`tabs_rearrange_group<class_TabBar_property_tabs_rearrange_group>` | ``-1`` |
  42. +-----------------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------+
  43. .. rst-class:: classref-reftable-group
  44. Methods
  45. -------
  46. .. table::
  47. :widths: auto
  48. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`add_tab<class_TabBar_method_add_tab>` **(** :ref:`String<class_String>` title="", :ref:`Texture2D<class_Texture2D>` icon=null **)** |
  50. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`ensure_tab_visible<class_TabBar_method_ensure_tab_visible>` **(** :ref:`int<class_int>` idx **)** |
  52. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`get_offset_buttons_visible<class_TabBar_method_get_offset_buttons_visible>` **(** **)** |const| |
  54. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_previous_tab<class_TabBar_method_get_previous_tab>` **(** **)** |const| |
  56. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_tab_button_icon<class_TabBar_method_get_tab_button_icon>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  58. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Texture2D<class_Texture2D>` | :ref:`get_tab_icon<class_TabBar_method_get_tab_icon>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  60. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_tab_idx_at_point<class_TabBar_method_get_tab_idx_at_point>` **(** :ref:`Vector2<class_Vector2>` point **)** |const| |
  62. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`String<class_String>` | :ref:`get_tab_language<class_TabBar_method_get_tab_language>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  64. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`get_tab_offset<class_TabBar_method_get_tab_offset>` **(** **)** |const| |
  66. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Rect2<class_Rect2>` | :ref:`get_tab_rect<class_TabBar_method_get_tab_rect>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  68. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`TextDirection<enum_Control_TextDirection>` | :ref:`get_tab_text_direction<class_TabBar_method_get_tab_text_direction>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  70. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`String<class_String>` | :ref:`get_tab_title<class_TabBar_method_get_tab_title>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  72. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`bool<class_bool>` | :ref:`is_tab_disabled<class_TabBar_method_is_tab_disabled>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  74. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`is_tab_hidden<class_TabBar_method_is_tab_hidden>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  76. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`move_tab<class_TabBar_method_move_tab>` **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)** |
  78. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`remove_tab<class_TabBar_method_remove_tab>` **(** :ref:`int<class_int>` tab_idx **)** |
  80. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`set_tab_button_icon<class_TabBar_method_set_tab_button_icon>` **(** :ref:`int<class_int>` tab_idx, :ref:`Texture2D<class_Texture2D>` icon **)** |
  82. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`set_tab_disabled<class_TabBar_method_set_tab_disabled>` **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)** |
  84. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`set_tab_hidden<class_TabBar_method_set_tab_hidden>` **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` hidden **)** |
  86. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`set_tab_icon<class_TabBar_method_set_tab_icon>` **(** :ref:`int<class_int>` tab_idx, :ref:`Texture2D<class_Texture2D>` icon **)** |
  88. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`set_tab_language<class_TabBar_method_set_tab_language>` **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` language **)** |
  90. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`set_tab_text_direction<class_TabBar_method_set_tab_text_direction>` **(** :ref:`int<class_int>` tab_idx, :ref:`TextDirection<enum_Control_TextDirection>` direction **)** |
  92. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`set_tab_title<class_TabBar_method_set_tab_title>` **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)** |
  94. +--------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. .. rst-class:: classref-reftable-group
  96. Theme Properties
  97. ----------------
  98. .. table::
  99. :widths: auto
  100. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  101. | :ref:`Color<class_Color>` | :ref:`drop_mark_color<class_TabBar_theme_color_drop_mark_color>` | ``Color(1, 1, 1, 1)`` |
  102. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  103. | :ref:`Color<class_Color>` | :ref:`font_disabled_color<class_TabBar_theme_color_font_disabled_color>` | ``Color(0.875, 0.875, 0.875, 0.5)`` |
  104. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  105. | :ref:`Color<class_Color>` | :ref:`font_outline_color<class_TabBar_theme_color_font_outline_color>` | ``Color(1, 1, 1, 1)`` |
  106. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  107. | :ref:`Color<class_Color>` | :ref:`font_selected_color<class_TabBar_theme_color_font_selected_color>` | ``Color(0.95, 0.95, 0.95, 1)`` |
  108. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  109. | :ref:`Color<class_Color>` | :ref:`font_unselected_color<class_TabBar_theme_color_font_unselected_color>` | ``Color(0.7, 0.7, 0.7, 1)`` |
  110. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  111. | :ref:`int<class_int>` | :ref:`h_separation<class_TabBar_theme_constant_h_separation>` | ``4`` |
  112. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  113. | :ref:`int<class_int>` | :ref:`outline_size<class_TabBar_theme_constant_outline_size>` | ``0`` |
  114. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  115. | :ref:`Font<class_Font>` | :ref:`font<class_TabBar_theme_font_font>` | |
  116. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  117. | :ref:`int<class_int>` | :ref:`font_size<class_TabBar_theme_font_size_font_size>` | |
  118. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  119. | :ref:`Texture2D<class_Texture2D>` | :ref:`close<class_TabBar_theme_icon_close>` | |
  120. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  121. | :ref:`Texture2D<class_Texture2D>` | :ref:`decrement<class_TabBar_theme_icon_decrement>` | |
  122. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  123. | :ref:`Texture2D<class_Texture2D>` | :ref:`decrement_highlight<class_TabBar_theme_icon_decrement_highlight>` | |
  124. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  125. | :ref:`Texture2D<class_Texture2D>` | :ref:`drop_mark<class_TabBar_theme_icon_drop_mark>` | |
  126. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  127. | :ref:`Texture2D<class_Texture2D>` | :ref:`increment<class_TabBar_theme_icon_increment>` | |
  128. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  129. | :ref:`Texture2D<class_Texture2D>` | :ref:`increment_highlight<class_TabBar_theme_icon_increment_highlight>` | |
  130. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  131. | :ref:`StyleBox<class_StyleBox>` | :ref:`button_highlight<class_TabBar_theme_style_button_highlight>` | |
  132. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  133. | :ref:`StyleBox<class_StyleBox>` | :ref:`button_pressed<class_TabBar_theme_style_button_pressed>` | |
  134. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  135. | :ref:`StyleBox<class_StyleBox>` | :ref:`tab_disabled<class_TabBar_theme_style_tab_disabled>` | |
  136. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  137. | :ref:`StyleBox<class_StyleBox>` | :ref:`tab_selected<class_TabBar_theme_style_tab_selected>` | |
  138. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  139. | :ref:`StyleBox<class_StyleBox>` | :ref:`tab_unselected<class_TabBar_theme_style_tab_unselected>` | |
  140. +-----------------------------------+------------------------------------------------------------------------------+-------------------------------------+
  141. .. rst-class:: classref-section-separator
  142. ----
  143. .. rst-class:: classref-descriptions-group
  144. Signals
  145. -------
  146. .. _class_TabBar_signal_active_tab_rearranged:
  147. .. rst-class:: classref-signal
  148. **active_tab_rearranged** **(** :ref:`int<class_int>` idx_to **)**
  149. Emitted when the active tab is rearranged via mouse drag. See :ref:`drag_to_rearrange_enabled<class_TabBar_property_drag_to_rearrange_enabled>`.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_TabBar_signal_tab_button_pressed:
  153. .. rst-class:: classref-signal
  154. **tab_button_pressed** **(** :ref:`int<class_int>` tab **)**
  155. Emitted when a tab's right button is pressed. See :ref:`set_tab_button_icon<class_TabBar_method_set_tab_button_icon>`.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_TabBar_signal_tab_changed:
  159. .. rst-class:: classref-signal
  160. **tab_changed** **(** :ref:`int<class_int>` tab **)**
  161. Emitted when switching to another tab.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_TabBar_signal_tab_clicked:
  165. .. rst-class:: classref-signal
  166. **tab_clicked** **(** :ref:`int<class_int>` tab **)**
  167. Emitted when a tab is clicked, even if it is the current tab.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_TabBar_signal_tab_close_pressed:
  171. .. rst-class:: classref-signal
  172. **tab_close_pressed** **(** :ref:`int<class_int>` tab **)**
  173. Emitted when a tab's close button is pressed.
  174. \ **Note:** Tabs are not removed automatically once the close button is pressed, this behavior needs to be programmed manually. For example:
  175. .. tabs::
  176. .. code-tab:: gdscript
  177. $TabBar.tab_close_pressed.connect($TabBar.remove_tab)
  178. .. code-tab:: csharp
  179. GetNode<TabBar>("TabBar").TabClosePressed += GetNode<TabBar>("TabBar").RemoveTab;
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_TabBar_signal_tab_hovered:
  183. .. rst-class:: classref-signal
  184. **tab_hovered** **(** :ref:`int<class_int>` tab **)**
  185. Emitted when a tab is hovered by the mouse.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_TabBar_signal_tab_rmb_clicked:
  189. .. rst-class:: classref-signal
  190. **tab_rmb_clicked** **(** :ref:`int<class_int>` tab **)**
  191. Emitted when a tab is right-clicked. :ref:`select_with_rmb<class_TabBar_property_select_with_rmb>` must be enabled.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_TabBar_signal_tab_selected:
  195. .. rst-class:: classref-signal
  196. **tab_selected** **(** :ref:`int<class_int>` tab **)**
  197. Emitted when a tab is selected via click or script, even if it is the current tab.
  198. .. rst-class:: classref-section-separator
  199. ----
  200. .. rst-class:: classref-descriptions-group
  201. Enumerations
  202. ------------
  203. .. _enum_TabBar_AlignmentMode:
  204. .. rst-class:: classref-enumeration
  205. enum **AlignmentMode**:
  206. .. _class_TabBar_constant_ALIGNMENT_LEFT:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **ALIGNMENT_LEFT** = ``0``
  209. Places tabs to the left.
  210. .. _class_TabBar_constant_ALIGNMENT_CENTER:
  211. .. rst-class:: classref-enumeration-constant
  212. :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **ALIGNMENT_CENTER** = ``1``
  213. Places tabs in the middle.
  214. .. _class_TabBar_constant_ALIGNMENT_RIGHT:
  215. .. rst-class:: classref-enumeration-constant
  216. :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **ALIGNMENT_RIGHT** = ``2``
  217. Places tabs to the right.
  218. .. _class_TabBar_constant_ALIGNMENT_MAX:
  219. .. rst-class:: classref-enumeration-constant
  220. :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **ALIGNMENT_MAX** = ``3``
  221. Represents the size of the :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` enum.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _enum_TabBar_CloseButtonDisplayPolicy:
  225. .. rst-class:: classref-enumeration
  226. enum **CloseButtonDisplayPolicy**:
  227. .. _class_TabBar_constant_CLOSE_BUTTON_SHOW_NEVER:
  228. .. rst-class:: classref-enumeration-constant
  229. :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **CLOSE_BUTTON_SHOW_NEVER** = ``0``
  230. Never show the close buttons.
  231. .. _class_TabBar_constant_CLOSE_BUTTON_SHOW_ACTIVE_ONLY:
  232. .. rst-class:: classref-enumeration-constant
  233. :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **CLOSE_BUTTON_SHOW_ACTIVE_ONLY** = ``1``
  234. Only show the close button on the currently active tab.
  235. .. _class_TabBar_constant_CLOSE_BUTTON_SHOW_ALWAYS:
  236. .. rst-class:: classref-enumeration-constant
  237. :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **CLOSE_BUTTON_SHOW_ALWAYS** = ``2``
  238. Show the close button on all tabs.
  239. .. _class_TabBar_constant_CLOSE_BUTTON_MAX:
  240. .. rst-class:: classref-enumeration-constant
  241. :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **CLOSE_BUTTON_MAX** = ``3``
  242. Represents the size of the :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` enum.
  243. .. rst-class:: classref-section-separator
  244. ----
  245. .. rst-class:: classref-descriptions-group
  246. Property Descriptions
  247. ---------------------
  248. .. _class_TabBar_property_clip_tabs:
  249. .. rst-class:: classref-property
  250. :ref:`bool<class_bool>` **clip_tabs** = ``true``
  251. .. rst-class:: classref-property-setget
  252. - void **set_clip_tabs** **(** :ref:`bool<class_bool>` value **)**
  253. - :ref:`bool<class_bool>` **get_clip_tabs** **(** **)**
  254. 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.
  255. .. rst-class:: classref-item-separator
  256. ----
  257. .. _class_TabBar_property_current_tab:
  258. .. rst-class:: classref-property
  259. :ref:`int<class_int>` **current_tab** = ``0``
  260. .. rst-class:: classref-property-setget
  261. - void **set_current_tab** **(** :ref:`int<class_int>` value **)**
  262. - :ref:`int<class_int>` **get_current_tab** **(** **)**
  263. Select tab at index ``tab_idx``.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_TabBar_property_drag_to_rearrange_enabled:
  267. .. rst-class:: classref-property
  268. :ref:`bool<class_bool>` **drag_to_rearrange_enabled** = ``false``
  269. .. rst-class:: classref-property-setget
  270. - void **set_drag_to_rearrange_enabled** **(** :ref:`bool<class_bool>` value **)**
  271. - :ref:`bool<class_bool>` **get_drag_to_rearrange_enabled** **(** **)**
  272. If ``true``, tabs can be rearranged with mouse drag.
  273. .. rst-class:: classref-item-separator
  274. ----
  275. .. _class_TabBar_property_max_tab_width:
  276. .. rst-class:: classref-property
  277. :ref:`int<class_int>` **max_tab_width** = ``0``
  278. .. rst-class:: classref-property-setget
  279. - void **set_max_tab_width** **(** :ref:`int<class_int>` value **)**
  280. - :ref:`int<class_int>` **get_max_tab_width** **(** **)**
  281. Sets the maximum width which all tabs should be limited to. Unlimited if set to ``0``.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_TabBar_property_scroll_to_selected:
  285. .. rst-class:: classref-property
  286. :ref:`bool<class_bool>` **scroll_to_selected** = ``true``
  287. .. rst-class:: classref-property-setget
  288. - void **set_scroll_to_selected** **(** :ref:`bool<class_bool>` value **)**
  289. - :ref:`bool<class_bool>` **get_scroll_to_selected** **(** **)**
  290. If ``true``, the tab offset will be changed to keep the the currently selected tab visible.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_TabBar_property_scrolling_enabled:
  294. .. rst-class:: classref-property
  295. :ref:`bool<class_bool>` **scrolling_enabled** = ``true``
  296. .. rst-class:: classref-property-setget
  297. - void **set_scrolling_enabled** **(** :ref:`bool<class_bool>` value **)**
  298. - :ref:`bool<class_bool>` **get_scrolling_enabled** **(** **)**
  299. if ``true``, the mouse's scroll wheel can be used to navigate the scroll view.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_TabBar_property_select_with_rmb:
  303. .. rst-class:: classref-property
  304. :ref:`bool<class_bool>` **select_with_rmb** = ``false``
  305. .. rst-class:: classref-property-setget
  306. - void **set_select_with_rmb** **(** :ref:`bool<class_bool>` value **)**
  307. - :ref:`bool<class_bool>` **get_select_with_rmb** **(** **)**
  308. If ``true``, enables selecting a tab with the right mouse button.
  309. .. rst-class:: classref-item-separator
  310. ----
  311. .. _class_TabBar_property_tab_alignment:
  312. .. rst-class:: classref-property
  313. :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **tab_alignment** = ``0``
  314. .. rst-class:: classref-property-setget
  315. - void **set_tab_alignment** **(** :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` value **)**
  316. - :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` **get_tab_alignment** **(** **)**
  317. Sets the position at which tabs will be placed. See :ref:`AlignmentMode<enum_TabBar_AlignmentMode>` for details.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_TabBar_property_tab_close_display_policy:
  321. .. rst-class:: classref-property
  322. :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **tab_close_display_policy** = ``0``
  323. .. rst-class:: classref-property-setget
  324. - void **set_tab_close_display_policy** **(** :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` value **)**
  325. - :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` **get_tab_close_display_policy** **(** **)**
  326. Sets when the close button will appear on the tabs. See :ref:`CloseButtonDisplayPolicy<enum_TabBar_CloseButtonDisplayPolicy>` for details.
  327. .. rst-class:: classref-item-separator
  328. ----
  329. .. _class_TabBar_property_tab_count:
  330. .. rst-class:: classref-property
  331. :ref:`int<class_int>` **tab_count** = ``0``
  332. .. rst-class:: classref-property-setget
  333. - void **set_tab_count** **(** :ref:`int<class_int>` value **)**
  334. - :ref:`int<class_int>` **get_tab_count** **(** **)**
  335. The number of tabs currently in the bar.
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_TabBar_property_tabs_rearrange_group:
  339. .. rst-class:: classref-property
  340. :ref:`int<class_int>` **tabs_rearrange_group** = ``-1``
  341. .. rst-class:: classref-property-setget
  342. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` value **)**
  343. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)**
  344. **TabBar**\ s with the same rearrange group ID will allow dragging the tabs between them. Enable drag with :ref:`drag_to_rearrange_enabled<class_TabBar_property_drag_to_rearrange_enabled>`.
  345. Setting this to ``-1`` will disable rearranging between **TabBar**\ s.
  346. .. rst-class:: classref-section-separator
  347. ----
  348. .. rst-class:: classref-descriptions-group
  349. Method Descriptions
  350. -------------------
  351. .. _class_TabBar_method_add_tab:
  352. .. rst-class:: classref-method
  353. void **add_tab** **(** :ref:`String<class_String>` title="", :ref:`Texture2D<class_Texture2D>` icon=null **)**
  354. Adds a new tab.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_TabBar_method_ensure_tab_visible:
  358. .. rst-class:: classref-method
  359. void **ensure_tab_visible** **(** :ref:`int<class_int>` idx **)**
  360. Moves the scroll view to make the tab visible.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_TabBar_method_get_offset_buttons_visible:
  364. .. rst-class:: classref-method
  365. :ref:`bool<class_bool>` **get_offset_buttons_visible** **(** **)** |const|
  366. Returns ``true`` if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
  367. .. rst-class:: classref-item-separator
  368. ----
  369. .. _class_TabBar_method_get_previous_tab:
  370. .. rst-class:: classref-method
  371. :ref:`int<class_int>` **get_previous_tab** **(** **)** |const|
  372. Returns the previously active tab index.
  373. .. rst-class:: classref-item-separator
  374. ----
  375. .. _class_TabBar_method_get_tab_button_icon:
  376. .. rst-class:: classref-method
  377. :ref:`Texture2D<class_Texture2D>` **get_tab_button_icon** **(** :ref:`int<class_int>` tab_idx **)** |const|
  378. Returns the :ref:`Texture2D<class_Texture2D>` for the right button of the tab at index ``tab_idx`` or ``null`` if the button has no :ref:`Texture2D<class_Texture2D>`.
  379. .. rst-class:: classref-item-separator
  380. ----
  381. .. _class_TabBar_method_get_tab_icon:
  382. .. rst-class:: classref-method
  383. :ref:`Texture2D<class_Texture2D>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** |const|
  384. Returns the :ref:`Texture2D<class_Texture2D>` for the tab at index ``tab_idx`` or ``null`` if the tab has no :ref:`Texture2D<class_Texture2D>`.
  385. .. rst-class:: classref-item-separator
  386. ----
  387. .. _class_TabBar_method_get_tab_idx_at_point:
  388. .. rst-class:: classref-method
  389. :ref:`int<class_int>` **get_tab_idx_at_point** **(** :ref:`Vector2<class_Vector2>` point **)** |const|
  390. Returns the index of the tab at local coordinates ``point``. Returns ``-1`` if the point is outside the control boundaries or if there's no tab at the queried position.
  391. .. rst-class:: classref-item-separator
  392. ----
  393. .. _class_TabBar_method_get_tab_language:
  394. .. rst-class:: classref-method
  395. :ref:`String<class_String>` **get_tab_language** **(** :ref:`int<class_int>` tab_idx **)** |const|
  396. Returns tab title language code.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_TabBar_method_get_tab_offset:
  400. .. rst-class:: classref-method
  401. :ref:`int<class_int>` **get_tab_offset** **(** **)** |const|
  402. Returns the number of hidden tabs offsetted to the left.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_TabBar_method_get_tab_rect:
  406. .. rst-class:: classref-method
  407. :ref:`Rect2<class_Rect2>` **get_tab_rect** **(** :ref:`int<class_int>` tab_idx **)** |const|
  408. Returns tab :ref:`Rect2<class_Rect2>` with local position and size.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_TabBar_method_get_tab_text_direction:
  412. .. rst-class:: classref-method
  413. :ref:`TextDirection<enum_Control_TextDirection>` **get_tab_text_direction** **(** :ref:`int<class_int>` tab_idx **)** |const|
  414. Returns tab title text base writing direction.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_TabBar_method_get_tab_title:
  418. .. rst-class:: classref-method
  419. :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** |const|
  420. Returns the title of the tab at index ``tab_idx``.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_TabBar_method_is_tab_disabled:
  424. .. rst-class:: classref-method
  425. :ref:`bool<class_bool>` **is_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** |const|
  426. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_TabBar_method_is_tab_hidden:
  430. .. rst-class:: classref-method
  431. :ref:`bool<class_bool>` **is_tab_hidden** **(** :ref:`int<class_int>` tab_idx **)** |const|
  432. Returns ``true`` if the tab at index ``tab_idx`` is hidden.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_TabBar_method_move_tab:
  436. .. rst-class:: classref-method
  437. void **move_tab** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  438. Moves a tab from ``from`` to ``to``.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_TabBar_method_remove_tab:
  442. .. rst-class:: classref-method
  443. void **remove_tab** **(** :ref:`int<class_int>` tab_idx **)**
  444. Removes the tab at index ``tab_idx``.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_TabBar_method_set_tab_button_icon:
  448. .. rst-class:: classref-method
  449. void **set_tab_button_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture2D<class_Texture2D>` icon **)**
  450. Sets an ``icon`` for the button of the tab at index ``tab_idx`` (located to the right, before the close button), making it visible and clickable (See :ref:`tab_button_pressed<class_TabBar_signal_tab_button_pressed>`). Giving it a ``null`` value will hide the button.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_TabBar_method_set_tab_disabled:
  454. .. rst-class:: classref-method
  455. void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  456. If ``disabled`` is ``true``, disables the tab at index ``tab_idx``, making it non-interactable.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_TabBar_method_set_tab_hidden:
  460. .. rst-class:: classref-method
  461. void **set_tab_hidden** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` hidden **)**
  462. If ``hidden`` is ``true``, hides the tab at index ``tab_idx``, making it disappear from the tab area.
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_TabBar_method_set_tab_icon:
  466. .. rst-class:: classref-method
  467. void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture2D<class_Texture2D>` icon **)**
  468. Sets an ``icon`` for the tab at index ``tab_idx``.
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_TabBar_method_set_tab_language:
  472. .. rst-class:: classref-method
  473. void **set_tab_language** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` language **)**
  474. Sets language code of tab title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_TabBar_method_set_tab_text_direction:
  478. .. rst-class:: classref-method
  479. void **set_tab_text_direction** **(** :ref:`int<class_int>` tab_idx, :ref:`TextDirection<enum_Control_TextDirection>` direction **)**
  480. Sets tab title base writing direction.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_TabBar_method_set_tab_title:
  484. .. rst-class:: classref-method
  485. void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  486. Sets a ``title`` for the tab at index ``tab_idx``.
  487. .. rst-class:: classref-section-separator
  488. ----
  489. .. rst-class:: classref-descriptions-group
  490. Theme Property Descriptions
  491. ---------------------------
  492. .. _class_TabBar_theme_color_drop_mark_color:
  493. .. rst-class:: classref-themeproperty
  494. :ref:`Color<class_Color>` **drop_mark_color** = ``Color(1, 1, 1, 1)``
  495. Modulation color for the :ref:`drop_mark<class_TabBar_theme_icon_drop_mark>` icon.
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_TabBar_theme_color_font_disabled_color:
  499. .. rst-class:: classref-themeproperty
  500. :ref:`Color<class_Color>` **font_disabled_color** = ``Color(0.875, 0.875, 0.875, 0.5)``
  501. Font color of disabled tabs.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_TabBar_theme_color_font_outline_color:
  505. .. rst-class:: classref-themeproperty
  506. :ref:`Color<class_Color>` **font_outline_color** = ``Color(1, 1, 1, 1)``
  507. The tint of text outline of the tab name.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_TabBar_theme_color_font_selected_color:
  511. .. rst-class:: classref-themeproperty
  512. :ref:`Color<class_Color>` **font_selected_color** = ``Color(0.95, 0.95, 0.95, 1)``
  513. Font color of the currently selected tab.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_TabBar_theme_color_font_unselected_color:
  517. .. rst-class:: classref-themeproperty
  518. :ref:`Color<class_Color>` **font_unselected_color** = ``Color(0.7, 0.7, 0.7, 1)``
  519. Font color of the other, unselected tabs.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_TabBar_theme_constant_h_separation:
  523. .. rst-class:: classref-themeproperty
  524. :ref:`int<class_int>` **h_separation** = ``4``
  525. The horizontal separation between the elements inside tabs.
  526. .. rst-class:: classref-item-separator
  527. ----
  528. .. _class_TabBar_theme_constant_outline_size:
  529. .. rst-class:: classref-themeproperty
  530. :ref:`int<class_int>` **outline_size** = ``0``
  531. The size of the tab text outline.
  532. \ **Note:** If using a font with :ref:`FontFile.multichannel_signed_distance_field<class_FontFile_property_multichannel_signed_distance_field>` enabled, its :ref:`FontFile.msdf_pixel_range<class_FontFile_property_msdf_pixel_range>` must be set to at least *twice* the value of :ref:`outline_size<class_TabBar_theme_constant_outline_size>` for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
  533. .. rst-class:: classref-item-separator
  534. ----
  535. .. _class_TabBar_theme_font_font:
  536. .. rst-class:: classref-themeproperty
  537. :ref:`Font<class_Font>` **font**
  538. The font used to draw tab names.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_TabBar_theme_font_size_font_size:
  542. .. rst-class:: classref-themeproperty
  543. :ref:`int<class_int>` **font_size**
  544. Font size of the tab names.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_TabBar_theme_icon_close:
  548. .. rst-class:: classref-themeproperty
  549. :ref:`Texture2D<class_Texture2D>` **close**
  550. The icon for the close button (see :ref:`tab_close_display_policy<class_TabBar_property_tab_close_display_policy>`).
  551. .. rst-class:: classref-item-separator
  552. ----
  553. .. _class_TabBar_theme_icon_decrement:
  554. .. rst-class:: classref-themeproperty
  555. :ref:`Texture2D<class_Texture2D>` **decrement**
  556. 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.
  557. .. rst-class:: classref-item-separator
  558. ----
  559. .. _class_TabBar_theme_icon_decrement_highlight:
  560. .. rst-class:: classref-themeproperty
  561. :ref:`Texture2D<class_Texture2D>` **decrement_highlight**
  562. 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.
  563. .. rst-class:: classref-item-separator
  564. ----
  565. .. _class_TabBar_theme_icon_drop_mark:
  566. .. rst-class:: classref-themeproperty
  567. :ref:`Texture2D<class_Texture2D>` **drop_mark**
  568. Icon shown to indicate where a dragged tab is gonna be dropped (see :ref:`drag_to_rearrange_enabled<class_TabBar_property_drag_to_rearrange_enabled>`).
  569. .. rst-class:: classref-item-separator
  570. ----
  571. .. _class_TabBar_theme_icon_increment:
  572. .. rst-class:: classref-themeproperty
  573. :ref:`Texture2D<class_Texture2D>` **increment**
  574. 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.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_TabBar_theme_icon_increment_highlight:
  578. .. rst-class:: classref-themeproperty
  579. :ref:`Texture2D<class_Texture2D>` **increment_highlight**
  580. 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.
  581. .. rst-class:: classref-item-separator
  582. ----
  583. .. _class_TabBar_theme_style_button_highlight:
  584. .. rst-class:: classref-themeproperty
  585. :ref:`StyleBox<class_StyleBox>` **button_highlight**
  586. Background of the tab and close buttons when they're being hovered with the cursor.
  587. .. rst-class:: classref-item-separator
  588. ----
  589. .. _class_TabBar_theme_style_button_pressed:
  590. .. rst-class:: classref-themeproperty
  591. :ref:`StyleBox<class_StyleBox>` **button_pressed**
  592. Background of the tab and close buttons when it's being pressed.
  593. .. rst-class:: classref-item-separator
  594. ----
  595. .. _class_TabBar_theme_style_tab_disabled:
  596. .. rst-class:: classref-themeproperty
  597. :ref:`StyleBox<class_StyleBox>` **tab_disabled**
  598. The style of disabled tabs.
  599. .. rst-class:: classref-item-separator
  600. ----
  601. .. _class_TabBar_theme_style_tab_selected:
  602. .. rst-class:: classref-themeproperty
  603. :ref:`StyleBox<class_StyleBox>` **tab_selected**
  604. The style of the currently selected tab.
  605. .. rst-class:: classref-item-separator
  606. ----
  607. .. _class_TabBar_theme_style_tab_unselected:
  608. .. rst-class:: classref-themeproperty
  609. :ref:`StyleBox<class_StyleBox>` **tab_unselected**
  610. The style of the other, unselected tabs.
  611. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  612. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  613. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  614. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  615. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  616. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`