Debian Codegraph @

doc/classes/TabBar.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="TabBar" inherits="Control" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A control that provides a horizontal bar with tabs.
5 </brief_description>
6 <description>
7 A control that provides a horizontal bar with tabs. Similar to [TabContainer] but is only in charge of drawing tabs, not interacting with children.
8 </description>
9 <tutorials>
10 </tutorials>
11 <methods>
12 <method name="add_tab">
13 <return type="void" />
14 <param index="0" name="title" type="String" default="&quot;&quot;" />
15 <param index="1" name="icon" type="Texture2D" default="null" />
16 <description>
17 Adds a new tab.
18 </description>
19 </method>
20 <method name="clear_tabs">
21 <return type="void" />
22 <description>
23 Clears all tabs.
24 </description>
25 </method>
26 <method name="ensure_tab_visible">
27 <return type="void" />
28 <param index="0" name="idx" type="int" />
29 <description>
30 Moves the scroll view to make the tab visible.
31 </description>
32 </method>
33 <method name="get_offset_buttons_visible" qualifiers="const">
34 <return type="bool" />
35 <description>
36 Returns [code]true[/code] if the offset buttons (the ones that appear when there's not enough space for all tabs) are visible.
37 </description>
38 </method>
39 <method name="get_previous_tab" qualifiers="const">
40 <return type="int" />
41 <description>
42 Returns the previously active tab index.
43 </description>
44 </method>
45 <method name="get_tab_button_icon" qualifiers="const">
46 <return type="Texture2D" />
47 <param index="0" name="tab_idx" type="int" />
48 <description>
49 Returns the icon for the right button of the tab at index [param tab_idx] or [code]null[/code] if the right button has no icon.
50 </description>
51 </method>
52 <method name="get_tab_icon" qualifiers="const">
53 <return type="Texture2D" />
54 <param index="0" name="tab_idx" type="int" />
55 <description>
56 Returns the icon for the tab at index [param tab_idx] or [code]null[/code] if the tab has no icon.
57 </description>
58 </method>
59 <method name="get_tab_icon_max_width" qualifiers="const">
60 <return type="int" />
61 <param index="0" name="tab_idx" type="int" />
62 <description>
63 Returns the maximum allowed width of the icon for the tab at index [param tab_idx].
64 </description>
65 </method>
66 <method name="get_tab_idx_at_point" qualifiers="const">
67 <return type="int" />
68 <param index="0" name="point" type="Vector2" />
69 <description>
70 Returns the index of the tab at local coordinates [param point]. Returns [code]-1[/code] if the point is outside the control boundaries or if there's no tab at the queried position.
71 </description>
72 </method>
73 <method name="get_tab_language" qualifiers="const">
74 <return type="String" />
75 <param index="0" name="tab_idx" type="int" />
76 <description>
77 Returns tab title language code.
78 </description>
79 </method>
80 <method name="get_tab_metadata" qualifiers="const">
81 <return type="Variant" />
82 <param index="0" name="tab_idx" type="int" />
83 <description>
84 Returns the metadata value set to the tab at index [param tab_idx] using [method set_tab_metadata]. If no metadata was previously set, returns [code]null[/code] by default.
85 </description>
86 </method>
87 <method name="get_tab_offset" qualifiers="const">
88 <return type="int" />
89 <description>
90 Returns the number of hidden tabs offsetted to the left.
91 </description>
92 </method>
93 <method name="get_tab_rect" qualifiers="const">
94 <return type="Rect2" />
95 <param index="0" name="tab_idx" type="int" />
96 <description>
97 Returns tab [Rect2] with local position and size.
98 </description>
99 </method>
100 <method name="get_tab_text_direction" qualifiers="const">
101 <return type="int" enum="Control.TextDirection" />
102 <param index="0" name="tab_idx" type="int" />
103 <description>
104 Returns tab title text base writing direction.
105 </description>
106 </method>
107 <method name="get_tab_title" qualifiers="const">
108 <return type="String" />
109 <param index="0" name="tab_idx" type="int" />
110 <description>
111 Returns the title of the tab at index [param tab_idx].
112 </description>
113 </method>
114 <method name="get_tab_tooltip" qualifiers="const">
115 <return type="String" />
116 <param index="0" name="tab_idx" type="int" />
117 <description>
118 Returns the tooltip text of the tab at index [param tab_idx].
119 </description>
120 </method>
121 <method name="is_tab_disabled" qualifiers="const">
122 <return type="bool" />
123 <param index="0" name="tab_idx" type="int" />
124 <description>
125 Returns [code]true[/code] if the tab at index [param tab_idx] is disabled.
126 </description>
127 </method>
128 <method name="is_tab_hidden" qualifiers="const">
129 <return type="bool" />
130 <param index="0" name="tab_idx" type="int" />
131 <description>
132 Returns [code]true[/code] if the tab at index [param tab_idx] is hidden.
133 </description>
134 </method>
135 <method name="move_tab">
136 <return type="void" />
137 <param index="0" name="from" type="int" />
138 <param index="1" name="to" type="int" />
139 <description>
140 Moves a tab from [param from] to [param to].
141 </description>
142 </method>
143 <method name="remove_tab">
144 <return type="void" />
145 <param index="0" name="tab_idx" type="int" />
146 <description>
147 Removes the tab at index [param tab_idx].
148 </description>
149 </method>
150 <method name="select_next_available">
151 <return type="bool" />
152 <description>
153 Selects the first available tab with greater index than the currently selected. Returns [code]true[/code] if tab selection changed.
154 </description>
155 </method>
156 <method name="select_previous_available">
157 <return type="bool" />
158 <description>
159 Selects the first available tab with lower index than the currently selected. Returns [code]true[/code] if tab selection changed.
160 </description>
161 </method>
162 <method name="set_tab_button_icon">
163 <return type="void" />
164 <param index="0" name="tab_idx" type="int" />
165 <param index="1" name="icon" type="Texture2D" />
166 <description>
167 Sets an [param icon] for the button of the tab at index [param tab_idx] (located to the right, before the close button), making it visible and clickable (See [signal tab_button_pressed]). Giving it a [code]null[/code] value will hide the button.
168 </description>
169 </method>
170 <method name="set_tab_disabled">
171 <return type="void" />
172 <param index="0" name="tab_idx" type="int" />
173 <param index="1" name="disabled" type="bool" />
174 <description>
175 If [param disabled] is [code]true[/code], disables the tab at index [param tab_idx], making it non-interactable.
176 </description>
177 </method>
178 <method name="set_tab_hidden">
179 <return type="void" />
180 <param index="0" name="tab_idx" type="int" />
181 <param index="1" name="hidden" type="bool" />
182 <description>
183 If [param hidden] is [code]true[/code], hides the tab at index [param tab_idx], making it disappear from the tab area.
184 </description>
185 </method>
186 <method name="set_tab_icon">
187 <return type="void" />
188 <param index="0" name="tab_idx" type="int" />
189 <param index="1" name="icon" type="Texture2D" />
190 <description>
191 Sets an [param icon] for the tab at index [param tab_idx].
192 </description>
193 </method>
194 <method name="set_tab_icon_max_width">
195 <return type="void" />
196 <param index="0" name="tab_idx" type="int" />
197 <param index="1" name="width" type="int" />
198 <description>
199 Sets the maximum allowed width of the icon for the tab at index [param tab_idx]. This limit is applied on top of the default size of the icon and on top of [theme_item icon_max_width]. The height is adjusted according to the icon's ratio.
200 </description>
201 </method>
202 <method name="set_tab_language">
203 <return type="void" />
204 <param index="0" name="tab_idx" type="int" />
205 <param index="1" name="language" type="String" />
206 <description>
207 Sets the language code of the title for the tab at index [param tab_idx] to [param language]. This is used for line-breaking and text shaping algorithms. If [param language] is empty, the current locale is used.
208 </description>
209 </method>
210 <method name="set_tab_metadata">
211 <return type="void" />
212 <param index="0" name="tab_idx" type="int" />
213 <param index="1" name="metadata" type="Variant" />
214 <description>
215 Sets the metadata value for the tab at index [param tab_idx], which can be retrieved later using [method get_tab_metadata].
216 </description>
217 </method>
218 <method name="set_tab_text_direction">
219 <return type="void" />
220 <param index="0" name="tab_idx" type="int" />
221 <param index="1" name="direction" type="int" enum="Control.TextDirection" />
222 <description>
223 Sets tab title base writing direction.
224 </description>
225 </method>
226 <method name="set_tab_title">
227 <return type="void" />
228 <param index="0" name="tab_idx" type="int" />
229 <param index="1" name="title" type="String" />
230 <description>
231 Sets a [param title] for the tab at index [param tab_idx].
232 </description>
233 </method>
234 <method name="set_tab_tooltip">
235 <return type="void" />
236 <param index="0" name="tab_idx" type="int" />
237 <param index="1" name="tooltip" type="String" />
238 <description>
239 Sets a [param tooltip] for tab at index [param tab_idx].
240 [b]Note:[/b] By default, if the [param tooltip] is empty and the tab text is truncated (not all characters fit into the tab), the title will be displayed as a tooltip. To hide the tooltip, assign [code]" "[/code] as the [param tooltip] text.
241 </description>
242 </method>
243 </methods>
244 <members>
245 <member name="clip_tabs" type="bool" setter="set_clip_tabs" getter="get_clip_tabs" default="true">
246 If [code]true[/code], tabs overflowing this node's width will be hidden, displaying two navigation buttons instead. Otherwise, this node's minimum size is updated so that all tabs are visible.
247 </member>
248 <member name="close_with_middle_mouse" type="bool" setter="set_close_with_middle_mouse" getter="get_close_with_middle_mouse" default="true">
249 If [code]true[/code], middle-clicking on a tab will emit the [signal tab_close_pressed] signal.
250 </member>
251 <member name="current_tab" type="int" setter="set_current_tab" getter="get_current_tab" default="-1">
252 The index of the current selected tab. A value of [code]-1[/code] means that no tab is selected and can only be set when [member deselect_enabled] is [code]true[/code] or if all tabs are hidden or disabled.
253 </member>
254 <member name="deselect_enabled" type="bool" setter="set_deselect_enabled" getter="get_deselect_enabled" default="false">
255 If [code]true[/code], all tabs can be deselected so that no tab is selected. Click on the current tab to deselect it.
256 </member>
257 <member name="drag_to_rearrange_enabled" type="bool" setter="set_drag_to_rearrange_enabled" getter="get_drag_to_rearrange_enabled" default="false">
258 If [code]true[/code], tabs can be rearranged with mouse drag.
259 </member>
260 <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
261 <member name="max_tab_width" type="int" setter="set_max_tab_width" getter="get_max_tab_width" default="0">
262 Sets the maximum width which all tabs should be limited to. Unlimited if set to [code]0[/code].
263 </member>
264 <member name="scroll_to_selected" type="bool" setter="set_scroll_to_selected" getter="get_scroll_to_selected" default="true">
265 If [code]true[/code], the tab offset will be changed to keep the currently selected tab visible.
266 </member>
267 <member name="scrolling_enabled" type="bool" setter="set_scrolling_enabled" getter="get_scrolling_enabled" default="true">
268 if [code]true[/code], the mouse's scroll wheel can be used to navigate the scroll view.
269 </member>
270 <member name="select_with_rmb" type="bool" setter="set_select_with_rmb" getter="get_select_with_rmb" default="false">
271 If [code]true[/code], enables selecting a tab with the right mouse button.
272 </member>
273 <member name="switch_on_drag_hover" type="bool" setter="set_switch_on_drag_hover" getter="get_switch_on_drag_hover" default="true">
274 If [code]true[/code], hovering over a tab while dragging something will switch to that tab. Does not have effect when hovering another tab to rearrange. The delay for when this happens is dictated by [theme_item hover_switch_wait_msec].
275 </member>
276 <member name="tab_alignment" type="int" setter="set_tab_alignment" getter="get_tab_alignment" enum="TabBar.AlignmentMode" default="0">
277 The horizontal alignment of the tabs.
278 </member>
279 <member name="tab_close_display_policy" type="int" setter="set_tab_close_display_policy" getter="get_tab_close_display_policy" enum="TabBar.CloseButtonDisplayPolicy" default="0">
280 When the close button will appear on the tabs.
281 </member>
282 <member name="tab_count" type="int" setter="set_tab_count" getter="get_tab_count" default="0">
283 The number of tabs currently in the bar.
284 </member>
285 <member name="tabs_rearrange_group" type="int" setter="set_tabs_rearrange_group" getter="get_tabs_rearrange_group" default="-1">
286 [TabBar]s with the same rearrange group ID will allow dragging the tabs between them. Enable drag with [member drag_to_rearrange_enabled].
287 Setting this to [code]-1[/code] will disable rearranging between [TabBar]s.
288 </member>
289 </members>
290 <signals>
291 <signal name="active_tab_rearranged">
292 <param index="0" name="idx_to" type="int" />
293 <description>
294 Emitted when the active tab is rearranged via mouse drag. See [member drag_to_rearrange_enabled].
295 </description>
296 </signal>
297 <signal name="tab_button_pressed">
298 <param index="0" name="tab" type="int" />
299 <description>
300 Emitted when a tab's right button is pressed. See [method set_tab_button_icon].
301 </description>
302 </signal>
303 <signal name="tab_changed">
304 <param index="0" name="tab" type="int" />
305 <description>
306 Emitted when switching to another tab.
307 </description>
308 </signal>
309 <signal name="tab_clicked">
310 <param index="0" name="tab" type="int" />
311 <description>
312 Emitted when a tab is clicked, even if it is the current tab.
313 </description>
314 </signal>
315 <signal name="tab_close_pressed">
316 <param index="0" name="tab" type="int" />
317 <description>
318 Emitted when a tab's close button is pressed or, if [member close_with_middle_mouse] is [code]true[/code], when middle-clicking on a tab.
319 [b]Note:[/b] Tabs are not removed automatically; this behavior needs to be coded manually. For example:
320 [codeblocks]
321 [gdscript]
322 $TabBar.tab_close_pressed.connect($TabBar.remove_tab)
323 [/gdscript]
324 [csharp]
325 GetNode&lt;TabBar&gt;("TabBar").TabClosePressed += GetNode&lt;TabBar&gt;("TabBar").RemoveTab;
326 [/csharp]
327 [/codeblocks]
328 </description>
329 </signal>
330 <signal name="tab_hovered">
331 <param index="0" name="tab" type="int" />
332 <description>
333 Emitted when a tab is hovered by the mouse.
334 </description>
335 </signal>
336 <signal name="tab_rmb_clicked">
337 <param index="0" name="tab" type="int" />
338 <description>
339 Emitted when a tab is right-clicked.
340 </description>
341 </signal>
342 <signal name="tab_selected">
343 <param index="0" name="tab" type="int" />
344 <description>
345 Emitted when a tab is selected via click, directional input, or script, even if it is the current tab.
346 </description>
347 </signal>
348 </signals>
349 <constants>
350 <constant name="ALIGNMENT_LEFT" value="0" enum="AlignmentMode">
351 Aligns tabs to the left.
352 </constant>
353 <constant name="ALIGNMENT_CENTER" value="1" enum="AlignmentMode">
354 Aligns tabs in the middle.
355 </constant>
356 <constant name="ALIGNMENT_RIGHT" value="2" enum="AlignmentMode">
357 Aligns tabs to the right.
358 </constant>
359 <constant name="ALIGNMENT_MAX" value="3" enum="AlignmentMode">
360 Represents the size of the [enum AlignmentMode] enum.
361 </constant>
362 <constant name="CLOSE_BUTTON_SHOW_NEVER" value="0" enum="CloseButtonDisplayPolicy">
363 Never show the close buttons.
364 </constant>
365 <constant name="CLOSE_BUTTON_SHOW_ACTIVE_ONLY" value="1" enum="CloseButtonDisplayPolicy">
366 Only show the close button on the currently active tab.
367 </constant>
368 <constant name="CLOSE_BUTTON_SHOW_ALWAYS" value="2" enum="CloseButtonDisplayPolicy">
369 Show the close button on all tabs.
370 </constant>
371 <constant name="CLOSE_BUTTON_MAX" value="3" enum="CloseButtonDisplayPolicy">
372 Represents the size of the [enum CloseButtonDisplayPolicy] enum.
373 </constant>
374 </constants>
375 <theme_items>
376 <theme_item name="drop_mark_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
377 Modulation color for the [theme_item drop_mark] icon.
378 </theme_item>
379 <theme_item name="font_disabled_color" data_type="color" type="Color" default="Color(0.875, 0.875, 0.875, 0.5)">
380 Font color of disabled tabs.
381 </theme_item>
382 <theme_item name="font_hovered_color" data_type="color" type="Color" default="Color(0.95, 0.95, 0.95, 1)">
383 Font color of the currently hovered tab. Does not apply to the selected tab.
384 </theme_item>
385 <theme_item name="font_outline_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
386 The tint of text outline of the tab name.
387 </theme_item>
388 <theme_item name="font_selected_color" data_type="color" type="Color" default="Color(0.95, 0.95, 0.95, 1)">
389 Font color of the currently selected tab.
390 </theme_item>
391 <theme_item name="font_unselected_color" data_type="color" type="Color" default="Color(0.7, 0.7, 0.7, 1)">
392 Font color of the other, unselected tabs.
393 </theme_item>
394 <theme_item name="icon_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
395 Icon color of disabled tabs.
396 </theme_item>
397 <theme_item name="icon_hovered_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
398 Icon color of the currently hovered tab. Does not apply to the selected tab.
399 </theme_item>
400 <theme_item name="icon_selected_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
401 Icon color of the currently selected tab.
402 </theme_item>
403 <theme_item name="icon_unselected_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
404 Icon color of the other, unselected tabs.
405 </theme_item>
406 <theme_item name="h_separation" data_type="constant" type="int" default="4">
407 The horizontal separation between the elements inside tabs.
408 </theme_item>
409 <theme_item name="hover_switch_wait_msec" data_type="constant" type="int" default="500">
410 During a drag-and-drop, this is how many milliseconds to wait before switching the tab.
411 </theme_item>
412 <theme_item name="icon_max_width" data_type="constant" type="int" default="0">
413 The maximum allowed width of the tab's icon. This limit is applied on top of the default size of the icon, but before the value set with [method set_tab_icon_max_width]. The height is adjusted according to the icon's ratio.
414 </theme_item>
415 <theme_item name="outline_size" data_type="constant" type="int" default="0">
416 The size of the tab text outline.
417 [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
418 </theme_item>
419 <theme_item name="tab_separation" data_type="constant" type="int" default="0">
420 The space between tabs in the tab bar.
421 </theme_item>
422 <theme_item name="font" data_type="font" type="Font">
423 The font used to draw tab names.
424 </theme_item>
425 <theme_item name="font_size" data_type="font_size" type="int">
426 Font size of the tab names.
427 </theme_item>
428 <theme_item name="close" data_type="icon" type="Texture2D">
429 The icon for the close button (see [member tab_close_display_policy]).
430 </theme_item>
431 <theme_item name="decrement" data_type="icon" type="Texture2D">
432 Icon for the left arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the first tab is visible), it appears semi-transparent.
433 </theme_item>
434 <theme_item name="decrement_highlight" data_type="icon" type="Texture2D">
435 Icon for the left arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.
436 </theme_item>
437 <theme_item name="drop_mark" data_type="icon" type="Texture2D">
438 Icon shown to indicate where a dragged tab is gonna be dropped (see [member drag_to_rearrange_enabled]).
439 </theme_item>
440 <theme_item name="increment" data_type="icon" type="Texture2D">
441 Icon for the right arrow button that appears when there are too many tabs to fit in the container width. When the button is disabled (i.e. the last tab is visible) it appears semi-transparent.
442 </theme_item>
443 <theme_item name="increment_highlight" data_type="icon" type="Texture2D">
444 Icon for the right arrow button that appears when there are too many tabs to fit in the container width. Used when the button is being hovered with the cursor.
445 </theme_item>
446 <theme_item name="button_highlight" data_type="style" type="StyleBox">
447 Background of the tab and close buttons when they're being hovered with the cursor.
448 </theme_item>
449 <theme_item name="button_pressed" data_type="style" type="StyleBox">
450 Background of the tab and close buttons when it's being pressed.
451 </theme_item>
452 <theme_item name="tab_disabled" data_type="style" type="StyleBox">
453 The style of disabled tabs.
454 </theme_item>
455 <theme_item name="tab_focus" data_type="style" type="StyleBox">
456 [StyleBox] used when the [TabBar] is focused. The [theme_item tab_focus] [StyleBox] is displayed [i]over[/i] the base [StyleBox] of the selected tab, so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
457 </theme_item>
458 <theme_item name="tab_hovered" data_type="style" type="StyleBox">
459 The style of the currently hovered tab. Does not apply to the selected tab.
460 [b]Note:[/b] This style will be drawn with the same width as [theme_item tab_unselected] at minimum.
461 </theme_item>
462 <theme_item name="tab_selected" data_type="style" type="StyleBox">
463 The style of the currently selected tab.
464 </theme_item>
465 <theme_item name="tab_unselected" data_type="style" type="StyleBox">
466 The style of the other, unselected tabs.
467 </theme_item>
468 </theme_items>
469 </class>