class_tabs.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. **Category:** Core
  10. Brief Description
  11. -----------------
  12. Tabs control.
  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. .. _class_Tabs_signal_right_button_pressed:
  111. - **right_button_pressed** **(** :ref:`int<class_int>` tab **)**
  112. .. _class_Tabs_signal_tab_changed:
  113. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  114. .. _class_Tabs_signal_tab_clicked:
  115. - **tab_clicked** **(** :ref:`int<class_int>` tab **)**
  116. .. _class_Tabs_signal_tab_close:
  117. - **tab_close** **(** :ref:`int<class_int>` tab **)**
  118. .. _class_Tabs_signal_tab_hover:
  119. - **tab_hover** **(** :ref:`int<class_int>` tab **)**
  120. Enumerations
  121. ------------
  122. .. _enum_Tabs_TabAlign:
  123. .. _class_Tabs_constant_ALIGN_LEFT:
  124. .. _class_Tabs_constant_ALIGN_CENTER:
  125. .. _class_Tabs_constant_ALIGN_RIGHT:
  126. .. _class_Tabs_constant_ALIGN_MAX:
  127. enum **TabAlign**:
  128. - **ALIGN_LEFT** = **0** --- Align the tabs to the left.
  129. - **ALIGN_CENTER** = **1** --- Align the tabs to the center.
  130. - **ALIGN_RIGHT** = **2** --- Align the tabs to the right.
  131. - **ALIGN_MAX** = **3** --- Represents the size of the :ref:`TabAlign<enum_Tabs_TabAlign>` enum.
  132. .. _enum_Tabs_CloseButtonDisplayPolicy:
  133. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_NEVER:
  134. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ACTIVE_ONLY:
  135. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ALWAYS:
  136. .. _class_Tabs_constant_CLOSE_BUTTON_MAX:
  137. enum **CloseButtonDisplayPolicy**:
  138. - **CLOSE_BUTTON_SHOW_NEVER** = **0**
  139. - **CLOSE_BUTTON_SHOW_ACTIVE_ONLY** = **1**
  140. - **CLOSE_BUTTON_SHOW_ALWAYS** = **2**
  141. - **CLOSE_BUTTON_MAX** = **3** --- Represents the size of the :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` enum.
  142. Description
  143. -----------
  144. Simple tabs control, similar to :ref:`TabContainer<class_TabContainer>` but is only in charge of drawing tabs, not interact with children.
  145. Property Descriptions
  146. ---------------------
  147. .. _class_Tabs_property_current_tab:
  148. - :ref:`int<class_int>` **current_tab**
  149. +-----------+------------------------+
  150. | *Default* | 0 |
  151. +-----------+------------------------+
  152. | *Setter* | set_current_tab(value) |
  153. +-----------+------------------------+
  154. | *Getter* | get_current_tab() |
  155. +-----------+------------------------+
  156. Select tab at index ``tab_idx``.
  157. .. _class_Tabs_property_drag_to_rearrange_enabled:
  158. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  159. +-----------+--------------------------------------+
  160. | *Default* | false |
  161. +-----------+--------------------------------------+
  162. | *Setter* | set_drag_to_rearrange_enabled(value) |
  163. +-----------+--------------------------------------+
  164. | *Getter* | get_drag_to_rearrange_enabled() |
  165. +-----------+--------------------------------------+
  166. If ``true``, tabs can be rearranged with mouse drag.
  167. .. _class_Tabs_property_scrolling_enabled:
  168. - :ref:`bool<class_bool>` **scrolling_enabled**
  169. +-----------+------------------------------+
  170. | *Default* | true |
  171. +-----------+------------------------------+
  172. | *Setter* | set_scrolling_enabled(value) |
  173. +-----------+------------------------------+
  174. | *Getter* | get_scrolling_enabled() |
  175. +-----------+------------------------------+
  176. .. _class_Tabs_property_tab_align:
  177. - :ref:`TabAlign<enum_Tabs_TabAlign>` **tab_align**
  178. +-----------+----------------------+
  179. | *Default* | 1 |
  180. +-----------+----------------------+
  181. | *Setter* | set_tab_align(value) |
  182. +-----------+----------------------+
  183. | *Getter* | get_tab_align() |
  184. +-----------+----------------------+
  185. The alignment of all tabs. See enum ``TabAlign`` constants for details.
  186. .. _class_Tabs_property_tab_close_display_policy:
  187. - :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` **tab_close_display_policy**
  188. +-----------+-------------------------------------+
  189. | *Default* | 0 |
  190. +-----------+-------------------------------------+
  191. | *Setter* | set_tab_close_display_policy(value) |
  192. +-----------+-------------------------------------+
  193. | *Getter* | get_tab_close_display_policy() |
  194. +-----------+-------------------------------------+
  195. Method Descriptions
  196. -------------------
  197. .. _class_Tabs_method_add_tab:
  198. - void **add_tab** **(** :ref:`String<class_String>` title="", :ref:`Texture<class_Texture>` icon=null **)**
  199. Adds a new tab.
  200. .. _class_Tabs_method_ensure_tab_visible:
  201. - void **ensure_tab_visible** **(** :ref:`int<class_int>` idx **)**
  202. Moves the scroll view to make the tab visible.
  203. .. _class_Tabs_method_get_offset_buttons_visible:
  204. - :ref:`bool<class_bool>` **get_offset_buttons_visible** **(** **)** const
  205. .. _class_Tabs_method_get_select_with_rmb:
  206. - :ref:`bool<class_bool>` **get_select_with_rmb** **(** **)** const
  207. Returns ``true`` if select with right mouse button is enabled.
  208. .. _class_Tabs_method_get_tab_count:
  209. - :ref:`int<class_int>` **get_tab_count** **(** **)** const
  210. Returns the number of tabs.
  211. .. _class_Tabs_method_get_tab_disabled:
  212. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** const
  213. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  214. .. _class_Tabs_method_get_tab_icon:
  215. - :ref:`Texture<class_Texture>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** const
  216. Returns the :ref:`Texture<class_Texture>` for the tab at index ``tab_idx`` or ``null`` if the tab has no :ref:`Texture<class_Texture>`.
  217. .. _class_Tabs_method_get_tab_offset:
  218. - :ref:`int<class_int>` **get_tab_offset** **(** **)** const
  219. .. _class_Tabs_method_get_tab_rect:
  220. - :ref:`Rect2<class_Rect2>` **get_tab_rect** **(** :ref:`int<class_int>` tab_idx **)** const
  221. Returns tab :ref:`Rect2<class_Rect2>` with local position and size.
  222. .. _class_Tabs_method_get_tab_title:
  223. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** const
  224. 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>`.
  225. .. _class_Tabs_method_get_tabs_rearrange_group:
  226. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** const
  227. Returns the ``Tabs``' rearrange group ID.
  228. .. _class_Tabs_method_move_tab:
  229. - void **move_tab** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  230. Moves a tab from ``from`` to ``to``.
  231. .. _class_Tabs_method_remove_tab:
  232. - void **remove_tab** **(** :ref:`int<class_int>` tab_idx **)**
  233. Removes the tab at index ``tab_idx``.
  234. .. _class_Tabs_method_set_select_with_rmb:
  235. - void **set_select_with_rmb** **(** :ref:`bool<class_bool>` enabled **)**
  236. If ``true``, enables selecting a tab with the right mouse button.
  237. .. _class_Tabs_method_set_tab_disabled:
  238. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  239. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``.
  240. **Note:** Its title text will remain unless it is also removed with :ref:`set_tab_title<class_Tabs_method_set_tab_title>`.
  241. .. _class_Tabs_method_set_tab_icon:
  242. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)**
  243. Sets an ``icon`` for the tab at index ``tab_idx``.
  244. .. _class_Tabs_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``.
  247. .. _class_Tabs_method_set_tabs_rearrange_group:
  248. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  249. 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)``.