class_tabs.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Tabs.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Tabs:
  6. Tabs
  7. ====
  8. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Tabs control.
  10. Description
  11. -----------
  12. Simple tabs control, similar to :ref:`TabContainer<class_TabContainer>` but is only in charge of drawing tabs, not interact with children.
  13. Properties
  14. ----------
  15. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  16. | :ref:`int<class_int>` | :ref:`current_tab<class_Tabs_property_current_tab>` | ``0`` |
  17. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  18. | :ref:`bool<class_bool>` | :ref:`drag_to_rearrange_enabled<class_Tabs_property_drag_to_rearrange_enabled>` | ``false`` |
  19. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  20. | :ref:`bool<class_bool>` | :ref:`scrolling_enabled<class_Tabs_property_scrolling_enabled>` | ``true`` |
  21. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  22. | :ref:`TabAlign<enum_Tabs_TabAlign>` | :ref:`tab_align<class_Tabs_property_tab_align>` | ``1`` |
  23. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  24. | :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` | :ref:`tab_close_display_policy<class_Tabs_property_tab_close_display_policy>` | ``0`` |
  25. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+-----------+
  26. Methods
  27. -------
  28. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  29. | void | :ref:`add_tab<class_Tabs_method_add_tab>` **(** :ref:`String<class_String>` title="", :ref:`Texture<class_Texture>` icon=null **)** |
  30. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`ensure_tab_visible<class_Tabs_method_ensure_tab_visible>` **(** :ref:`int<class_int>` idx **)** |
  32. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`get_offset_buttons_visible<class_Tabs_method_get_offset_buttons_visible>` **(** **)** |const| |
  34. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`get_select_with_rmb<class_Tabs_method_get_select_with_rmb>` **(** **)** |const| |
  36. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`int<class_int>` | :ref:`get_tab_count<class_Tabs_method_get_tab_count>` **(** **)** |const| |
  38. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`get_tab_disabled<class_Tabs_method_get_tab_disabled>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  40. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Texture<class_Texture>` | :ref:`get_tab_icon<class_Tabs_method_get_tab_icon>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  42. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`int<class_int>` | :ref:`get_tab_offset<class_Tabs_method_get_tab_offset>` **(** **)** |const| |
  44. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Rect2<class_Rect2>` | :ref:`get_tab_rect<class_Tabs_method_get_tab_rect>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  46. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`String<class_String>` | :ref:`get_tab_title<class_Tabs_method_get_tab_title>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  48. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_tabs_rearrange_group<class_Tabs_method_get_tabs_rearrange_group>` **(** **)** |const| |
  50. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`move_tab<class_Tabs_method_move_tab>` **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)** |
  52. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`remove_tab<class_Tabs_method_remove_tab>` **(** :ref:`int<class_int>` tab_idx **)** |
  54. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_select_with_rmb<class_Tabs_method_set_select_with_rmb>` **(** :ref:`bool<class_bool>` enabled **)** |
  56. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_tab_disabled<class_Tabs_method_set_tab_disabled>` **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)** |
  58. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_tab_icon<class_Tabs_method_set_tab_icon>` **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)** |
  60. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_tab_title<class_Tabs_method_set_tab_title>` **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)** |
  62. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_tabs_rearrange_group<class_Tabs_method_set_tabs_rearrange_group>` **(** :ref:`int<class_int>` group_id **)** |
  64. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------+
  65. Theme Properties
  66. ----------------
  67. +---------------------------------+---------------------+------------------------------+
  68. | :ref:`StyleBox<class_StyleBox>` | button | |
  69. +---------------------------------+---------------------+------------------------------+
  70. | :ref:`StyleBox<class_StyleBox>` | button_pressed | |
  71. +---------------------------------+---------------------+------------------------------+
  72. | :ref:`Texture<class_Texture>` | close | |
  73. +---------------------------------+---------------------+------------------------------+
  74. | :ref:`Texture<class_Texture>` | decrement | |
  75. +---------------------------------+---------------------+------------------------------+
  76. | :ref:`Texture<class_Texture>` | decrement_highlight | |
  77. +---------------------------------+---------------------+------------------------------+
  78. | :ref:`Font<class_Font>` | font | |
  79. +---------------------------------+---------------------+------------------------------+
  80. | :ref:`Color<class_Color>` | font_color_bg | Color( 0.69, 0.69, 0.69, 1 ) |
  81. +---------------------------------+---------------------+------------------------------+
  82. | :ref:`Color<class_Color>` | font_color_disabled | Color( 0.9, 0.9, 0.9, 0.2 ) |
  83. +---------------------------------+---------------------+------------------------------+
  84. | :ref:`Color<class_Color>` | font_color_fg | Color( 0.94, 0.94, 0.94, 1 ) |
  85. +---------------------------------+---------------------+------------------------------+
  86. | :ref:`int<class_int>` | hseparation | 4 |
  87. +---------------------------------+---------------------+------------------------------+
  88. | :ref:`Texture<class_Texture>` | increment | |
  89. +---------------------------------+---------------------+------------------------------+
  90. | :ref:`Texture<class_Texture>` | increment_highlight | |
  91. +---------------------------------+---------------------+------------------------------+
  92. | :ref:`int<class_int>` | label_valign_bg | 2 |
  93. +---------------------------------+---------------------+------------------------------+
  94. | :ref:`int<class_int>` | label_valign_fg | 0 |
  95. +---------------------------------+---------------------+------------------------------+
  96. | :ref:`StyleBox<class_StyleBox>` | panel | |
  97. +---------------------------------+---------------------+------------------------------+
  98. | :ref:`StyleBox<class_StyleBox>` | tab_bg | |
  99. +---------------------------------+---------------------+------------------------------+
  100. | :ref:`StyleBox<class_StyleBox>` | tab_disabled | |
  101. +---------------------------------+---------------------+------------------------------+
  102. | :ref:`StyleBox<class_StyleBox>` | tab_fg | |
  103. +---------------------------------+---------------------+------------------------------+
  104. | :ref:`int<class_int>` | top_margin | 24 |
  105. +---------------------------------+---------------------+------------------------------+
  106. Signals
  107. -------
  108. .. _class_Tabs_signal_reposition_active_tab_request:
  109. - **reposition_active_tab_request** **(** :ref:`int<class_int>` idx_to **)**
  110. Emitted when the active tab is rearranged via mouse drag. See :ref:`drag_to_rearrange_enabled<class_Tabs_property_drag_to_rearrange_enabled>`.
  111. ----
  112. .. _class_Tabs_signal_right_button_pressed:
  113. - **right_button_pressed** **(** :ref:`int<class_int>` tab **)**
  114. Emitted when a tab is right-clicked.
  115. ----
  116. .. _class_Tabs_signal_tab_changed:
  117. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  118. Emitted when switching to another tab.
  119. ----
  120. .. _class_Tabs_signal_tab_clicked:
  121. - **tab_clicked** **(** :ref:`int<class_int>` tab **)**
  122. Emitted when a tab is clicked, even if it is the current tab.
  123. ----
  124. .. _class_Tabs_signal_tab_close:
  125. - **tab_close** **(** :ref:`int<class_int>` tab **)**
  126. Emitted when a tab is closed.
  127. ----
  128. .. _class_Tabs_signal_tab_hover:
  129. - **tab_hover** **(** :ref:`int<class_int>` tab **)**
  130. Emitted when a tab is hovered by the mouse.
  131. Enumerations
  132. ------------
  133. .. _enum_Tabs_TabAlign:
  134. .. _class_Tabs_constant_ALIGN_LEFT:
  135. .. _class_Tabs_constant_ALIGN_CENTER:
  136. .. _class_Tabs_constant_ALIGN_RIGHT:
  137. .. _class_Tabs_constant_ALIGN_MAX:
  138. enum **TabAlign**:
  139. - **ALIGN_LEFT** = **0** --- Align the tabs to the left.
  140. - **ALIGN_CENTER** = **1** --- Align the tabs to the center.
  141. - **ALIGN_RIGHT** = **2** --- Align the tabs to the right.
  142. - **ALIGN_MAX** = **3** --- Represents the size of the :ref:`TabAlign<enum_Tabs_TabAlign>` enum.
  143. ----
  144. .. _enum_Tabs_CloseButtonDisplayPolicy:
  145. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_NEVER:
  146. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ACTIVE_ONLY:
  147. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ALWAYS:
  148. .. _class_Tabs_constant_CLOSE_BUTTON_MAX:
  149. enum **CloseButtonDisplayPolicy**:
  150. - **CLOSE_BUTTON_SHOW_NEVER** = **0** --- Never show the close buttons.
  151. - **CLOSE_BUTTON_SHOW_ACTIVE_ONLY** = **1** --- Only show the close button on the currently active tab.
  152. - **CLOSE_BUTTON_SHOW_ALWAYS** = **2** --- Show the close button on all tabs.
  153. - **CLOSE_BUTTON_MAX** = **3** --- Represents the size of the :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` enum.
  154. Property Descriptions
  155. ---------------------
  156. .. _class_Tabs_property_current_tab:
  157. - :ref:`int<class_int>` **current_tab**
  158. +-----------+------------------------+
  159. | *Default* | ``0`` |
  160. +-----------+------------------------+
  161. | *Setter* | set_current_tab(value) |
  162. +-----------+------------------------+
  163. | *Getter* | get_current_tab() |
  164. +-----------+------------------------+
  165. Select tab at index ``tab_idx``.
  166. ----
  167. .. _class_Tabs_property_drag_to_rearrange_enabled:
  168. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  169. +-----------+--------------------------------------+
  170. | *Default* | ``false`` |
  171. +-----------+--------------------------------------+
  172. | *Setter* | set_drag_to_rearrange_enabled(value) |
  173. +-----------+--------------------------------------+
  174. | *Getter* | get_drag_to_rearrange_enabled() |
  175. +-----------+--------------------------------------+
  176. If ``true``, tabs can be rearranged with mouse drag.
  177. ----
  178. .. _class_Tabs_property_scrolling_enabled:
  179. - :ref:`bool<class_bool>` **scrolling_enabled**
  180. +-----------+------------------------------+
  181. | *Default* | ``true`` |
  182. +-----------+------------------------------+
  183. | *Setter* | set_scrolling_enabled(value) |
  184. +-----------+------------------------------+
  185. | *Getter* | get_scrolling_enabled() |
  186. +-----------+------------------------------+
  187. if ``true``, the mouse's scroll wheel cab be used to navigate the scroll view.
  188. ----
  189. .. _class_Tabs_property_tab_align:
  190. - :ref:`TabAlign<enum_Tabs_TabAlign>` **tab_align**
  191. +-----------+----------------------+
  192. | *Default* | ``1`` |
  193. +-----------+----------------------+
  194. | *Setter* | set_tab_align(value) |
  195. +-----------+----------------------+
  196. | *Getter* | get_tab_align() |
  197. +-----------+----------------------+
  198. The alignment of all tabs. See :ref:`TabAlign<enum_Tabs_TabAlign>` for details.
  199. ----
  200. .. _class_Tabs_property_tab_close_display_policy:
  201. - :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` **tab_close_display_policy**
  202. +-----------+-------------------------------------+
  203. | *Default* | ``0`` |
  204. +-----------+-------------------------------------+
  205. | *Setter* | set_tab_close_display_policy(value) |
  206. +-----------+-------------------------------------+
  207. | *Getter* | get_tab_close_display_policy() |
  208. +-----------+-------------------------------------+
  209. Sets when the close button will appear on the tabs. See :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` for details.
  210. Method Descriptions
  211. -------------------
  212. .. _class_Tabs_method_add_tab:
  213. - void **add_tab** **(** :ref:`String<class_String>` title="", :ref:`Texture<class_Texture>` icon=null **)**
  214. Adds a new tab.
  215. ----
  216. .. _class_Tabs_method_ensure_tab_visible:
  217. - void **ensure_tab_visible** **(** :ref:`int<class_int>` idx **)**
  218. Moves the scroll view to make the tab visible.
  219. ----
  220. .. _class_Tabs_method_get_offset_buttons_visible:
  221. - :ref:`bool<class_bool>` **get_offset_buttons_visible** **(** **)** |const|
  222. Returns ``true`` if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
  223. ----
  224. .. _class_Tabs_method_get_select_with_rmb:
  225. - :ref:`bool<class_bool>` **get_select_with_rmb** **(** **)** |const|
  226. Returns ``true`` if select with right mouse button is enabled.
  227. ----
  228. .. _class_Tabs_method_get_tab_count:
  229. - :ref:`int<class_int>` **get_tab_count** **(** **)** |const|
  230. Returns the number of tabs.
  231. ----
  232. .. _class_Tabs_method_get_tab_disabled:
  233. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** |const|
  234. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  235. ----
  236. .. _class_Tabs_method_get_tab_icon:
  237. - :ref:`Texture<class_Texture>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** |const|
  238. Returns the :ref:`Texture<class_Texture>` for the tab at index ``tab_idx`` or ``null`` if the tab has no :ref:`Texture<class_Texture>`.
  239. ----
  240. .. _class_Tabs_method_get_tab_offset:
  241. - :ref:`int<class_int>` **get_tab_offset** **(** **)** |const|
  242. Returns the number of hidden tabs offsetted to the left.
  243. ----
  244. .. _class_Tabs_method_get_tab_rect:
  245. - :ref:`Rect2<class_Rect2>` **get_tab_rect** **(** :ref:`int<class_int>` tab_idx **)** |const|
  246. Returns tab :ref:`Rect2<class_Rect2>` with local position and size.
  247. ----
  248. .. _class_Tabs_method_get_tab_title:
  249. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** |const|
  250. Returns the title of the tab at index ``tab_idx``. Tab titles default to the name of the indexed child node, but this can be overridden with :ref:`set_tab_title<class_Tabs_method_set_tab_title>`.
  251. ----
  252. .. _class_Tabs_method_get_tabs_rearrange_group:
  253. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** |const|
  254. Returns the ``Tabs``' rearrange group ID.
  255. ----
  256. .. _class_Tabs_method_move_tab:
  257. - void **move_tab** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  258. Moves a tab from ``from`` to ``to``.
  259. ----
  260. .. _class_Tabs_method_remove_tab:
  261. - void **remove_tab** **(** :ref:`int<class_int>` tab_idx **)**
  262. Removes the tab at index ``tab_idx``.
  263. ----
  264. .. _class_Tabs_method_set_select_with_rmb:
  265. - void **set_select_with_rmb** **(** :ref:`bool<class_bool>` enabled **)**
  266. If ``true``, enables selecting a tab with the right mouse button.
  267. ----
  268. .. _class_Tabs_method_set_tab_disabled:
  269. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  270. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``.
  271. **Note:** Its title text will remain unless it is also removed with :ref:`set_tab_title<class_Tabs_method_set_tab_title>`.
  272. ----
  273. .. _class_Tabs_method_set_tab_icon:
  274. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)**
  275. Sets an ``icon`` for the tab at index ``tab_idx``.
  276. ----
  277. .. _class_Tabs_method_set_tab_title:
  278. - void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  279. Sets a ``title`` for the tab at index ``tab_idx``.
  280. ----
  281. .. _class_Tabs_method_set_tabs_rearrange_group:
  282. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  283. Defines the rearrange group ID. Choose for each ``Tabs`` the same value to dragging tabs between ``Tabs``. Enable drag with ``set_drag_to_rearrange_enabled(true)``.
  284. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  285. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  286. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`