2
0

class_tabs.rst 21 KB

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