class_tabcontainer.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 TabContainer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TabContainer:
  6. TabContainer
  7. ============
  8. **Inherits:** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Tabbed container.
  10. Description
  11. -----------
  12. Sets the active tab's ``visible`` property to the value ``true``. Sets all other children's to ``false``.
  13. Ignores non-:ref:`Control<class_Control>` children.
  14. Individual tabs are always visible unless you use :ref:`set_tab_disabled<class_TabContainer_method_set_tab_disabled>` and :ref:`set_tab_title<class_TabContainer_method_set_tab_title>` to hide it.
  15. To hide only a tab's content, nest the content inside a child :ref:`Control<class_Control>`, so it receives the ``TabContainer``'s visibility setting instead.
  16. Properties
  17. ----------
  18. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  19. | :ref:`bool<class_bool>` | :ref:`all_tabs_in_front<class_TabContainer_property_all_tabs_in_front>` | ``false`` |
  20. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  21. | :ref:`int<class_int>` | :ref:`current_tab<class_TabContainer_property_current_tab>` | ``0`` |
  22. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  23. | :ref:`bool<class_bool>` | :ref:`drag_to_rearrange_enabled<class_TabContainer_property_drag_to_rearrange_enabled>` | ``false`` |
  24. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  25. | :ref:`TabAlign<enum_TabContainer_TabAlign>` | :ref:`tab_align<class_TabContainer_property_tab_align>` | ``1`` |
  26. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`tabs_visible<class_TabContainer_property_tabs_visible>` | ``true`` |
  28. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`use_hidden_tabs_for_min_size<class_TabContainer_property_use_hidden_tabs_for_min_size>` | ``false`` |
  30. +---------------------------------------------+-----------------------------------------------------------------------------------------------+-----------+
  31. Methods
  32. -------
  33. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Control<class_Control>` | :ref:`get_current_tab_control<class_TabContainer_method_get_current_tab_control>` **(** **)** |const| |
  35. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Popup<class_Popup>` | :ref:`get_popup<class_TabContainer_method_get_popup>` **(** **)** |const| |
  37. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`get_previous_tab<class_TabContainer_method_get_previous_tab>` **(** **)** |const| |
  39. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`Control<class_Control>` | :ref:`get_tab_control<class_TabContainer_method_get_tab_control>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  41. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_tab_count<class_TabContainer_method_get_tab_count>` **(** **)** |const| |
  43. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`get_tab_disabled<class_TabContainer_method_get_tab_disabled>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  45. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Texture<class_Texture>` | :ref:`get_tab_icon<class_TabContainer_method_get_tab_icon>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  47. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`String<class_String>` | :ref:`get_tab_title<class_TabContainer_method_get_tab_title>` **(** :ref:`int<class_int>` tab_idx **)** |const| |
  49. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`get_tabs_rearrange_group<class_TabContainer_method_get_tabs_rearrange_group>` **(** **)** |const| |
  51. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_popup<class_TabContainer_method_set_popup>` **(** :ref:`Node<class_Node>` popup **)** |
  53. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_tab_disabled<class_TabContainer_method_set_tab_disabled>` **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)** |
  55. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_tab_icon<class_TabContainer_method_set_tab_icon>` **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)** |
  57. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_tab_title<class_TabContainer_method_set_tab_title>` **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)** |
  59. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`set_tabs_rearrange_group<class_TabContainer_method_set_tabs_rearrange_group>` **(** :ref:`int<class_int>` group_id **)** |
  61. +-------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------+
  62. Theme Properties
  63. ----------------
  64. +---------------------------------+---------------------+------------------------------+
  65. | :ref:`Texture<class_Texture>` | decrement | |
  66. +---------------------------------+---------------------+------------------------------+
  67. | :ref:`Texture<class_Texture>` | decrement_highlight | |
  68. +---------------------------------+---------------------+------------------------------+
  69. | :ref:`Font<class_Font>` | font | |
  70. +---------------------------------+---------------------+------------------------------+
  71. | :ref:`Color<class_Color>` | font_color_bg | Color( 0.69, 0.69, 0.69, 1 ) |
  72. +---------------------------------+---------------------+------------------------------+
  73. | :ref:`Color<class_Color>` | font_color_disabled | Color( 0.9, 0.9, 0.9, 0.2 ) |
  74. +---------------------------------+---------------------+------------------------------+
  75. | :ref:`Color<class_Color>` | font_color_fg | Color( 0.94, 0.94, 0.94, 1 ) |
  76. +---------------------------------+---------------------+------------------------------+
  77. | :ref:`int<class_int>` | hseparation | 4 |
  78. +---------------------------------+---------------------+------------------------------+
  79. | :ref:`Texture<class_Texture>` | increment | |
  80. +---------------------------------+---------------------+------------------------------+
  81. | :ref:`Texture<class_Texture>` | increment_highlight | |
  82. +---------------------------------+---------------------+------------------------------+
  83. | :ref:`int<class_int>` | label_valign_bg | 2 |
  84. +---------------------------------+---------------------+------------------------------+
  85. | :ref:`int<class_int>` | label_valign_fg | 0 |
  86. +---------------------------------+---------------------+------------------------------+
  87. | :ref:`Texture<class_Texture>` | menu | |
  88. +---------------------------------+---------------------+------------------------------+
  89. | :ref:`Texture<class_Texture>` | menu_highlight | |
  90. +---------------------------------+---------------------+------------------------------+
  91. | :ref:`StyleBox<class_StyleBox>` | panel | |
  92. +---------------------------------+---------------------+------------------------------+
  93. | :ref:`int<class_int>` | side_margin | 8 |
  94. +---------------------------------+---------------------+------------------------------+
  95. | :ref:`StyleBox<class_StyleBox>` | tab_bg | |
  96. +---------------------------------+---------------------+------------------------------+
  97. | :ref:`StyleBox<class_StyleBox>` | tab_disabled | |
  98. +---------------------------------+---------------------+------------------------------+
  99. | :ref:`StyleBox<class_StyleBox>` | tab_fg | |
  100. +---------------------------------+---------------------+------------------------------+
  101. | :ref:`int<class_int>` | top_margin | 24 |
  102. +---------------------------------+---------------------+------------------------------+
  103. Signals
  104. -------
  105. .. _class_TabContainer_signal_pre_popup_pressed:
  106. - **pre_popup_pressed** **(** **)**
  107. Emitted when the ``TabContainer``'s :ref:`Popup<class_Popup>` button is clicked. See :ref:`set_popup<class_TabContainer_method_set_popup>` for details.
  108. ----
  109. .. _class_TabContainer_signal_tab_changed:
  110. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  111. Emitted when switching to another tab.
  112. ----
  113. .. _class_TabContainer_signal_tab_selected:
  114. - **tab_selected** **(** :ref:`int<class_int>` tab **)**
  115. Emitted when a tab is selected, even if it is the current tab.
  116. Enumerations
  117. ------------
  118. .. _enum_TabContainer_TabAlign:
  119. .. _class_TabContainer_constant_ALIGN_LEFT:
  120. .. _class_TabContainer_constant_ALIGN_CENTER:
  121. .. _class_TabContainer_constant_ALIGN_RIGHT:
  122. enum **TabAlign**:
  123. - **ALIGN_LEFT** = **0** --- Align the tabs to the left.
  124. - **ALIGN_CENTER** = **1** --- Align the tabs to the center.
  125. - **ALIGN_RIGHT** = **2** --- Align the tabs to the right.
  126. Property Descriptions
  127. ---------------------
  128. .. _class_TabContainer_property_all_tabs_in_front:
  129. - :ref:`bool<class_bool>` **all_tabs_in_front**
  130. +-----------+------------------------------+
  131. | *Default* | ``false`` |
  132. +-----------+------------------------------+
  133. | *Setter* | set_all_tabs_in_front(value) |
  134. +-----------+------------------------------+
  135. | *Getter* | is_all_tabs_in_front() |
  136. +-----------+------------------------------+
  137. If ``true``, all tabs are drawn in front of the panel. If ``false``, inactive tabs are drawn behind the panel.
  138. ----
  139. .. _class_TabContainer_property_current_tab:
  140. - :ref:`int<class_int>` **current_tab**
  141. +-----------+------------------------+
  142. | *Default* | ``0`` |
  143. +-----------+------------------------+
  144. | *Setter* | set_current_tab(value) |
  145. +-----------+------------------------+
  146. | *Getter* | get_current_tab() |
  147. +-----------+------------------------+
  148. The current tab index. When set, this index's :ref:`Control<class_Control>` node's ``visible`` property is set to ``true`` and all others are set to ``false``.
  149. ----
  150. .. _class_TabContainer_property_drag_to_rearrange_enabled:
  151. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  152. +-----------+--------------------------------------+
  153. | *Default* | ``false`` |
  154. +-----------+--------------------------------------+
  155. | *Setter* | set_drag_to_rearrange_enabled(value) |
  156. +-----------+--------------------------------------+
  157. | *Getter* | get_drag_to_rearrange_enabled() |
  158. +-----------+--------------------------------------+
  159. If ``true``, tabs can be rearranged with mouse drag.
  160. ----
  161. .. _class_TabContainer_property_tab_align:
  162. - :ref:`TabAlign<enum_TabContainer_TabAlign>` **tab_align**
  163. +-----------+----------------------+
  164. | *Default* | ``1`` |
  165. +-----------+----------------------+
  166. | *Setter* | set_tab_align(value) |
  167. +-----------+----------------------+
  168. | *Getter* | get_tab_align() |
  169. +-----------+----------------------+
  170. The alignment of all tabs in the tab container. See the :ref:`TabAlign<enum_TabContainer_TabAlign>` constants for details.
  171. ----
  172. .. _class_TabContainer_property_tabs_visible:
  173. - :ref:`bool<class_bool>` **tabs_visible**
  174. +-----------+-------------------------+
  175. | *Default* | ``true`` |
  176. +-----------+-------------------------+
  177. | *Setter* | set_tabs_visible(value) |
  178. +-----------+-------------------------+
  179. | *Getter* | are_tabs_visible() |
  180. +-----------+-------------------------+
  181. If ``true``, tabs are visible. If ``false``, tabs' content and titles are hidden.
  182. ----
  183. .. _class_TabContainer_property_use_hidden_tabs_for_min_size:
  184. - :ref:`bool<class_bool>` **use_hidden_tabs_for_min_size**
  185. +-----------+-----------------------------------------+
  186. | *Default* | ``false`` |
  187. +-----------+-----------------------------------------+
  188. | *Setter* | set_use_hidden_tabs_for_min_size(value) |
  189. +-----------+-----------------------------------------+
  190. | *Getter* | get_use_hidden_tabs_for_min_size() |
  191. +-----------+-----------------------------------------+
  192. If ``true``, children :ref:`Control<class_Control>` nodes that are hidden have their minimum size take into account in the total, instead of only the currently visible one.
  193. Method Descriptions
  194. -------------------
  195. .. _class_TabContainer_method_get_current_tab_control:
  196. - :ref:`Control<class_Control>` **get_current_tab_control** **(** **)** |const|
  197. Returns the child :ref:`Control<class_Control>` node located at the active tab index.
  198. ----
  199. .. _class_TabContainer_method_get_popup:
  200. - :ref:`Popup<class_Popup>` **get_popup** **(** **)** |const|
  201. Returns the :ref:`Popup<class_Popup>` node instance if one has been set already with :ref:`set_popup<class_TabContainer_method_set_popup>`.
  202. ----
  203. .. _class_TabContainer_method_get_previous_tab:
  204. - :ref:`int<class_int>` **get_previous_tab** **(** **)** |const|
  205. Returns the previously active tab index.
  206. ----
  207. .. _class_TabContainer_method_get_tab_control:
  208. - :ref:`Control<class_Control>` **get_tab_control** **(** :ref:`int<class_int>` tab_idx **)** |const|
  209. Returns the :ref:`Control<class_Control>` node from the tab at index ``tab_idx``.
  210. ----
  211. .. _class_TabContainer_method_get_tab_count:
  212. - :ref:`int<class_int>` **get_tab_count** **(** **)** |const|
  213. Returns the number of tabs.
  214. ----
  215. .. _class_TabContainer_method_get_tab_disabled:
  216. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** |const|
  217. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  218. ----
  219. .. _class_TabContainer_method_get_tab_icon:
  220. - :ref:`Texture<class_Texture>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** |const|
  221. Returns the :ref:`Texture<class_Texture>` for the tab at index ``tab_idx`` or ``null`` if the tab has no :ref:`Texture<class_Texture>`.
  222. ----
  223. .. _class_TabContainer_method_get_tab_title:
  224. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** |const|
  225. 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_TabContainer_method_set_tab_title>`.
  226. ----
  227. .. _class_TabContainer_method_get_tabs_rearrange_group:
  228. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** |const|
  229. Returns the ``TabContainer`` rearrange group id.
  230. ----
  231. .. _class_TabContainer_method_set_popup:
  232. - void **set_popup** **(** :ref:`Node<class_Node>` popup **)**
  233. If set on a :ref:`Popup<class_Popup>` node instance, a popup menu icon appears in the top-right corner of the ``TabContainer``. Clicking it will expand the :ref:`Popup<class_Popup>` node.
  234. ----
  235. .. _class_TabContainer_method_set_tab_disabled:
  236. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  237. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``.
  238. **Note:** Its title text will remain, unless also removed with :ref:`set_tab_title<class_TabContainer_method_set_tab_title>`.
  239. ----
  240. .. _class_TabContainer_method_set_tab_icon:
  241. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)**
  242. Sets an icon for the tab at index ``tab_idx``.
  243. ----
  244. .. _class_TabContainer_method_set_tab_title:
  245. - void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  246. Sets a title for 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_TabContainer_method_set_tab_title>`.
  247. ----
  248. .. _class_TabContainer_method_set_tabs_rearrange_group:
  249. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  250. Defines rearrange group id, choose for each ``TabContainer`` the same value to enable tab drag between ``TabContainer``. Enable drag with ``set_drag_to_rearrange_enabled(true)``.
  251. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  252. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  253. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`