class_tabs.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` | :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:`Texture2D<class_Texture2D>` 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:`Texture2D<class_Texture2D>` | close | |
  73. +-----------------------------------+---------------------+------------------------------+
  74. | :ref:`Texture2D<class_Texture2D>` | decrement | |
  75. +-----------------------------------+---------------------+------------------------------+
  76. | :ref:`Texture2D<class_Texture2D>` | 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:`Texture2D<class_Texture2D>` | increment | |
  89. +-----------------------------------+---------------------+------------------------------+
  90. | :ref:`Texture2D<class_Texture2D>` | increment_highlight | |
  91. +-----------------------------------+---------------------+------------------------------+
  92. | :ref:`StyleBox<class_StyleBox>` | panel | |
  93. +-----------------------------------+---------------------+------------------------------+
  94. | :ref:`StyleBox<class_StyleBox>` | tab_bg | |
  95. +-----------------------------------+---------------------+------------------------------+
  96. | :ref:`StyleBox<class_StyleBox>` | tab_disabled | |
  97. +-----------------------------------+---------------------+------------------------------+
  98. | :ref:`StyleBox<class_StyleBox>` | tab_fg | |
  99. +-----------------------------------+---------------------+------------------------------+
  100. Signals
  101. -------
  102. .. _class_Tabs_signal_reposition_active_tab_request:
  103. - **reposition_active_tab_request** **(** :ref:`int<class_int>` idx_to **)**
  104. Emitted when the active tab is rearranged via mouse drag. See :ref:`drag_to_rearrange_enabled<class_Tabs_property_drag_to_rearrange_enabled>`.
  105. ----
  106. .. _class_Tabs_signal_right_button_pressed:
  107. - **right_button_pressed** **(** :ref:`int<class_int>` tab **)**
  108. Emitted when a tab is right-clicked.
  109. ----
  110. .. _class_Tabs_signal_tab_changed:
  111. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  112. Emitted when switching to another tab.
  113. ----
  114. .. _class_Tabs_signal_tab_clicked:
  115. - **tab_clicked** **(** :ref:`int<class_int>` tab **)**
  116. Emitted when a tab is clicked, even if it is the current tab.
  117. ----
  118. .. _class_Tabs_signal_tab_close:
  119. - **tab_close** **(** :ref:`int<class_int>` tab **)**
  120. Emitted when a tab is closed.
  121. ----
  122. .. _class_Tabs_signal_tab_hover:
  123. - **tab_hover** **(** :ref:`int<class_int>` tab **)**
  124. Emitted when a tab is hovered by the mouse.
  125. Enumerations
  126. ------------
  127. .. _enum_Tabs_TabAlign:
  128. .. _class_Tabs_constant_ALIGN_LEFT:
  129. .. _class_Tabs_constant_ALIGN_CENTER:
  130. .. _class_Tabs_constant_ALIGN_RIGHT:
  131. .. _class_Tabs_constant_ALIGN_MAX:
  132. enum **TabAlign**:
  133. - **ALIGN_LEFT** = **0** --- Align the tabs to the left.
  134. - **ALIGN_CENTER** = **1** --- Align the tabs to the center.
  135. - **ALIGN_RIGHT** = **2** --- Align the tabs to the right.
  136. - **ALIGN_MAX** = **3** --- Represents the size of the :ref:`TabAlign<enum_Tabs_TabAlign>` enum.
  137. ----
  138. .. _enum_Tabs_CloseButtonDisplayPolicy:
  139. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_NEVER:
  140. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ACTIVE_ONLY:
  141. .. _class_Tabs_constant_CLOSE_BUTTON_SHOW_ALWAYS:
  142. .. _class_Tabs_constant_CLOSE_BUTTON_MAX:
  143. enum **CloseButtonDisplayPolicy**:
  144. - **CLOSE_BUTTON_SHOW_NEVER** = **0** --- Never show the close buttons.
  145. - **CLOSE_BUTTON_SHOW_ACTIVE_ONLY** = **1** --- Only show the close button on the currently active tab.
  146. - **CLOSE_BUTTON_SHOW_ALWAYS** = **2** --- Show the close button on all tabs.
  147. - **CLOSE_BUTTON_MAX** = **3** --- Represents the size of the :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` enum.
  148. Property Descriptions
  149. ---------------------
  150. .. _class_Tabs_property_current_tab:
  151. - :ref:`int<class_int>` **current_tab**
  152. +-----------+------------------------+
  153. | *Default* | ``0`` |
  154. +-----------+------------------------+
  155. | *Setter* | set_current_tab(value) |
  156. +-----------+------------------------+
  157. | *Getter* | get_current_tab() |
  158. +-----------+------------------------+
  159. Select tab at index ``tab_idx``.
  160. ----
  161. .. _class_Tabs_property_drag_to_rearrange_enabled:
  162. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  163. +-----------+--------------------------------------+
  164. | *Default* | ``false`` |
  165. +-----------+--------------------------------------+
  166. | *Setter* | set_drag_to_rearrange_enabled(value) |
  167. +-----------+--------------------------------------+
  168. | *Getter* | get_drag_to_rearrange_enabled() |
  169. +-----------+--------------------------------------+
  170. If ``true``, tabs can be rearranged with mouse drag.
  171. ----
  172. .. _class_Tabs_property_scrolling_enabled:
  173. - :ref:`bool<class_bool>` **scrolling_enabled**
  174. +-----------+------------------------------+
  175. | *Default* | ``true`` |
  176. +-----------+------------------------------+
  177. | *Setter* | set_scrolling_enabled(value) |
  178. +-----------+------------------------------+
  179. | *Getter* | get_scrolling_enabled() |
  180. +-----------+------------------------------+
  181. if ``true``, the mouse's scroll wheel cab be used to navigate the scroll view.
  182. ----
  183. .. _class_Tabs_property_tab_align:
  184. - :ref:`TabAlign<enum_Tabs_TabAlign>` **tab_align**
  185. +-----------+----------------------+
  186. | *Default* | ``1`` |
  187. +-----------+----------------------+
  188. | *Setter* | set_tab_align(value) |
  189. +-----------+----------------------+
  190. | *Getter* | get_tab_align() |
  191. +-----------+----------------------+
  192. The alignment of all tabs. See :ref:`TabAlign<enum_Tabs_TabAlign>` for details.
  193. ----
  194. .. _class_Tabs_property_tab_close_display_policy:
  195. - :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` **tab_close_display_policy**
  196. +-----------+-------------------------------------+
  197. | *Default* | ``0`` |
  198. +-----------+-------------------------------------+
  199. | *Setter* | set_tab_close_display_policy(value) |
  200. +-----------+-------------------------------------+
  201. | *Getter* | get_tab_close_display_policy() |
  202. +-----------+-------------------------------------+
  203. Sets when the close button will appear on the tabs. See :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` for details.
  204. Method Descriptions
  205. -------------------
  206. .. _class_Tabs_method_add_tab:
  207. - void **add_tab** **(** :ref:`String<class_String>` title="", :ref:`Texture2D<class_Texture2D>` icon=null **)**
  208. Adds a new tab.
  209. ----
  210. .. _class_Tabs_method_ensure_tab_visible:
  211. - void **ensure_tab_visible** **(** :ref:`int<class_int>` idx **)**
  212. Moves the scroll view to make the tab visible.
  213. ----
  214. .. _class_Tabs_method_get_offset_buttons_visible:
  215. - :ref:`bool<class_bool>` **get_offset_buttons_visible** **(** **)** const
  216. Returns ``true`` if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
  217. ----
  218. .. _class_Tabs_method_get_select_with_rmb:
  219. - :ref:`bool<class_bool>` **get_select_with_rmb** **(** **)** const
  220. Returns ``true`` if select with right mouse button is enabled.
  221. ----
  222. .. _class_Tabs_method_get_tab_count:
  223. - :ref:`int<class_int>` **get_tab_count** **(** **)** const
  224. Returns the number of tabs.
  225. ----
  226. .. _class_Tabs_method_get_tab_disabled:
  227. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** const
  228. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  229. ----
  230. .. _class_Tabs_method_get_tab_icon:
  231. - :ref:`Texture2D<class_Texture2D>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** const
  232. Returns the :ref:`Texture2D<class_Texture2D>` for the tab at index ``tab_idx`` or ``null`` if the tab has no :ref:`Texture2D<class_Texture2D>`.
  233. ----
  234. .. _class_Tabs_method_get_tab_offset:
  235. - :ref:`int<class_int>` **get_tab_offset** **(** **)** const
  236. Returns the number of hidden tabs offsetted to the left.
  237. ----
  238. .. _class_Tabs_method_get_tab_rect:
  239. - :ref:`Rect2<class_Rect2>` **get_tab_rect** **(** :ref:`int<class_int>` tab_idx **)** const
  240. Returns tab :ref:`Rect2<class_Rect2>` with local position and size.
  241. ----
  242. .. _class_Tabs_method_get_tab_title:
  243. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** const
  244. 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>`.
  245. ----
  246. .. _class_Tabs_method_get_tabs_rearrange_group:
  247. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** const
  248. Returns the ``Tabs``' rearrange group ID.
  249. ----
  250. .. _class_Tabs_method_move_tab:
  251. - void **move_tab** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  252. Moves a tab from ``from`` to ``to``.
  253. ----
  254. .. _class_Tabs_method_remove_tab:
  255. - void **remove_tab** **(** :ref:`int<class_int>` tab_idx **)**
  256. Removes the tab at index ``tab_idx``.
  257. ----
  258. .. _class_Tabs_method_set_select_with_rmb:
  259. - void **set_select_with_rmb** **(** :ref:`bool<class_bool>` enabled **)**
  260. If ``true``, enables selecting a tab with the right mouse button.
  261. ----
  262. .. _class_Tabs_method_set_tab_disabled:
  263. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  264. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``.
  265. **Note:** Its title text will remain unless it is also removed with :ref:`set_tab_title<class_Tabs_method_set_tab_title>`.
  266. ----
  267. .. _class_Tabs_method_set_tab_icon:
  268. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture2D<class_Texture2D>` icon **)**
  269. Sets an ``icon`` for the tab at index ``tab_idx``.
  270. ----
  271. .. _class_Tabs_method_set_tab_title:
  272. - void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  273. Sets a ``title`` for the tab at index ``tab_idx``.
  274. ----
  275. .. _class_Tabs_method_set_tabs_rearrange_group:
  276. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  277. 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)``.