class_tabs.rst 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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>` |
  17. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`drag_to_rearrange_enabled<class_Tabs_property_drag_to_rearrange_enabled>` |
  19. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`scrolling_enabled<class_Tabs_property_scrolling_enabled>` |
  21. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+
  22. | :ref:`TabAlign<enum_Tabs_TabAlign>` | :ref:`tab_align<class_Tabs_property_tab_align>` |
  23. +---------------------------------------------------------------------+---------------------------------------------------------------------------------+
  24. | :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` | :ref:`tab_close_display_policy<class_Tabs_property_tab_close_display_policy>` |
  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 |
  81. +---------------------------------+---------------------+
  82. | :ref:`Color<class_Color>` | font_color_disabled |
  83. +---------------------------------+---------------------+
  84. | :ref:`Color<class_Color>` | font_color_fg |
  85. +---------------------------------+---------------------+
  86. | :ref:`int<class_int>` | hseparation |
  87. +---------------------------------+---------------------+
  88. | :ref:`Texture<class_Texture>` | increment |
  89. +---------------------------------+---------------------+
  90. | :ref:`Texture<class_Texture>` | increment_highlight |
  91. +---------------------------------+---------------------+
  92. | :ref:`int<class_int>` | label_valign_bg |
  93. +---------------------------------+---------------------+
  94. | :ref:`int<class_int>` | label_valign_fg |
  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 |
  105. +---------------------------------+---------------------+
  106. Signals
  107. -------
  108. .. _class_Tabs_signal_reposition_active_tab_request:
  109. - **reposition_active_tab_request** **(** :ref:`int<class_int>` idx_to **)**
  110. ----
  111. .. _class_Tabs_signal_right_button_pressed:
  112. - **right_button_pressed** **(** :ref:`int<class_int>` tab **)**
  113. ----
  114. .. _class_Tabs_signal_tab_changed:
  115. - **tab_changed** **(** :ref:`int<class_int>` tab **)**
  116. ----
  117. .. _class_Tabs_signal_tab_clicked:
  118. - **tab_clicked** **(** :ref:`int<class_int>` tab **)**
  119. ----
  120. .. _class_Tabs_signal_tab_close:
  121. - **tab_close** **(** :ref:`int<class_int>` tab **)**
  122. ----
  123. .. _class_Tabs_signal_tab_hover:
  124. - **tab_hover** **(** :ref:`int<class_int>` tab **)**
  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**
  145. - **CLOSE_BUTTON_SHOW_ACTIVE_ONLY** = **1**
  146. - **CLOSE_BUTTON_SHOW_ALWAYS** = **2**
  147. - **CLOSE_BUTTON_MAX** = **3** --- Represents the size of the :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` enum.
  148. Description
  149. -----------
  150. Simple tabs control, similar to :ref:`TabContainer<class_TabContainer>` but is only in charge of drawing tabs, not interact with children.
  151. Property Descriptions
  152. ---------------------
  153. .. _class_Tabs_property_current_tab:
  154. - :ref:`int<class_int>` **current_tab**
  155. +----------+------------------------+
  156. | *Setter* | set_current_tab(value) |
  157. +----------+------------------------+
  158. | *Getter* | get_current_tab() |
  159. +----------+------------------------+
  160. Select tab at index ``tab_idx``.
  161. ----
  162. .. _class_Tabs_property_drag_to_rearrange_enabled:
  163. - :ref:`bool<class_bool>` **drag_to_rearrange_enabled**
  164. +----------+--------------------------------------+
  165. | *Setter* | set_drag_to_rearrange_enabled(value) |
  166. +----------+--------------------------------------+
  167. | *Getter* | get_drag_to_rearrange_enabled() |
  168. +----------+--------------------------------------+
  169. If ``true``, tabs can be rearranged with mouse drag.
  170. ----
  171. .. _class_Tabs_property_scrolling_enabled:
  172. - :ref:`bool<class_bool>` **scrolling_enabled**
  173. +----------+------------------------------+
  174. | *Setter* | set_scrolling_enabled(value) |
  175. +----------+------------------------------+
  176. | *Getter* | get_scrolling_enabled() |
  177. +----------+------------------------------+
  178. ----
  179. .. _class_Tabs_property_tab_align:
  180. - :ref:`TabAlign<enum_Tabs_TabAlign>` **tab_align**
  181. +----------+----------------------+
  182. | *Setter* | set_tab_align(value) |
  183. +----------+----------------------+
  184. | *Getter* | get_tab_align() |
  185. +----------+----------------------+
  186. The alignment of all tabs. See enum ``TabAlign`` constants for details.
  187. ----
  188. .. _class_Tabs_property_tab_close_display_policy:
  189. - :ref:`CloseButtonDisplayPolicy<enum_Tabs_CloseButtonDisplayPolicy>` **tab_close_display_policy**
  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. ----
  201. .. _class_Tabs_method_ensure_tab_visible:
  202. - void **ensure_tab_visible** **(** :ref:`int<class_int>` idx **)**
  203. Moves the Scroll view to make the tab visible.
  204. ----
  205. .. _class_Tabs_method_get_offset_buttons_visible:
  206. - :ref:`bool<class_bool>` **get_offset_buttons_visible** **(** **)** const
  207. ----
  208. .. _class_Tabs_method_get_select_with_rmb:
  209. - :ref:`bool<class_bool>` **get_select_with_rmb** **(** **)** const
  210. Returns ``true`` if select with right mouse button is enabled.
  211. ----
  212. .. _class_Tabs_method_get_tab_count:
  213. - :ref:`int<class_int>` **get_tab_count** **(** **)** const
  214. Returns the number of tabs.
  215. ----
  216. .. _class_Tabs_method_get_tab_disabled:
  217. - :ref:`bool<class_bool>` **get_tab_disabled** **(** :ref:`int<class_int>` tab_idx **)** const
  218. Returns ``true`` if the tab at index ``tab_idx`` is disabled.
  219. ----
  220. .. _class_Tabs_method_get_tab_icon:
  221. - :ref:`Texture<class_Texture>` **get_tab_icon** **(** :ref:`int<class_int>` tab_idx **)** const
  222. Returns the :ref:`Texture<class_Texture>` for the tab at index ``tab_idx`` or null if the tab has no :ref:`Texture<class_Texture>`.
  223. ----
  224. .. _class_Tabs_method_get_tab_offset:
  225. - :ref:`int<class_int>` **get_tab_offset** **(** **)** const
  226. ----
  227. .. _class_Tabs_method_get_tab_rect:
  228. - :ref:`Rect2<class_Rect2>` **get_tab_rect** **(** :ref:`int<class_int>` tab_idx **)** const
  229. Returns tab :ref:`Rect2<class_Rect2>` with local position and size.
  230. ----
  231. .. _class_Tabs_method_get_tab_title:
  232. - :ref:`String<class_String>` **get_tab_title** **(** :ref:`int<class_int>` tab_idx **)** const
  233. 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>`.
  234. ----
  235. .. _class_Tabs_method_get_tabs_rearrange_group:
  236. - :ref:`int<class_int>` **get_tabs_rearrange_group** **(** **)** const
  237. Returns the ``Tabs`` rearrange group id.
  238. ----
  239. .. _class_Tabs_method_move_tab:
  240. - void **move_tab** **(** :ref:`int<class_int>` from, :ref:`int<class_int>` to **)**
  241. Rearrange tab.
  242. ----
  243. .. _class_Tabs_method_remove_tab:
  244. - void **remove_tab** **(** :ref:`int<class_int>` tab_idx **)**
  245. Removes tab at index ``tab_idx``
  246. ----
  247. .. _class_Tabs_method_set_select_with_rmb:
  248. - void **set_select_with_rmb** **(** :ref:`bool<class_bool>` enabled **)**
  249. If ``true``, enables selecting a tab with right mouse button.
  250. ----
  251. .. _class_Tabs_method_set_tab_disabled:
  252. - void **set_tab_disabled** **(** :ref:`int<class_int>` tab_idx, :ref:`bool<class_bool>` disabled **)**
  253. If ``disabled`` is ``false``, hides the tab at index ``tab_idx``. Note that its title text will remain, unless also removed with :ref:`set_tab_title<class_Tabs_method_set_tab_title>`.
  254. ----
  255. .. _class_Tabs_method_set_tab_icon:
  256. - void **set_tab_icon** **(** :ref:`int<class_int>` tab_idx, :ref:`Texture<class_Texture>` icon **)**
  257. Sets an icon for the tab at index ``tab_idx``.
  258. ----
  259. .. _class_Tabs_method_set_tab_title:
  260. - void **set_tab_title** **(** :ref:`int<class_int>` tab_idx, :ref:`String<class_String>` title **)**
  261. Sets a title for the tab at index ``tab_idx``.
  262. ----
  263. .. _class_Tabs_method_set_tabs_rearrange_group:
  264. - void **set_tabs_rearrange_group** **(** :ref:`int<class_int>` group_id **)**
  265. Defines rearrange group id, choose for each ``Tabs`` the same value to enable tab drag between ``Tabs``. Enable drag with ``set_drag_to_rearrange_enabled(true)``.