Skip to content
0.2.0-dev Download ZIP
195 lines ·12.7 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="ScrollContainer" inherits="Container" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A container used to provide scrollbars to a child control when needed.
5 </brief_description>
6 <description>
7 A container used to provide a child control with scrollbars when needed. Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer. Scrollbars will also automatically resize the grabber based on the [member Control.custom_minimum_size] of the Control relative to the ScrollContainer.
8 </description>
9 <tutorials>
10 <link title="Using Containers">$DOCS_URL/tutorials/ui/gui_containers.html</link>
11 </tutorials>
12 <methods>
13 <method name="ensure_control_visible">
14 <return type="void" />
15 <param index="0" name="control" type="Control" />
16 <description>
17 Ensures the given [param control] is visible (must be a direct or indirect child of the ScrollContainer). Used by [member follow_focus].
18 [b]Note:[/b] This will not work on a node that was just added during the same frame. If you want to scroll to a newly added child, you must wait until the next frame using [signal SceneTree.process_frame]:
19 [codeblock]
20 add_child(child_node)
21 await get_tree().process_frame
22 ensure_control_visible(child_node)
23 [/codeblock]
24 </description>
25 </method>
26 <method name="get_h_scroll_bar">
27 <return type="HScrollBar" />
28 <description>
29 Returns the horizontal scrollbar [HScrollBar] of this [ScrollContainer].
30 [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use [member horizontal_scroll_mode].
31 </description>
32 </method>
33 <method name="get_v_scroll_bar">
34 <return type="VScrollBar" />
35 <description>
36 Returns the vertical scrollbar [VScrollBar] of this [ScrollContainer].
37 [b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to disable or hide a scrollbar, you can use [member vertical_scroll_mode].
38 </description>
39 </method>
40 </methods>
41 <members>
42 <member name="clip_contents" type="bool" setter="set_clip_contents" getter="is_clipping_contents" overrides="Control" default="true" />
43 <member name="draw_focus_border" type="bool" setter="set_draw_focus_border" getter="get_draw_focus_border" default="false">
44 If [code]true[/code], [theme_item focus] is drawn when the ScrollContainer or one of its descendant nodes is focused.
45 </member>
46 <member name="follow_focus" type="bool" setter="set_follow_focus" getter="is_following_focus" default="false">
47 If [code]true[/code], the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible.
48 </member>
49 <member name="horizontal_scroll_mode" type="int" setter="set_horizontal_scroll_mode" getter="get_horizontal_scroll_mode" enum="ScrollContainer.ScrollMode" default="1">
50 Controls whether horizontal scrollbar can be used and when it should be visible.
51 </member>
52 <member name="propagate_maximum_size" type="bool" setter="set_propagate_maximum_size" getter="is_propagating_maximum_size" overrides="Control" default="false" />
53 <member name="scroll_deadzone" type="int" setter="set_deadzone" getter="get_deadzone" default="0">
54 Deadzone for touch scrolling. Lower deadzone makes the scrolling more sensitive.
55 </member>
56 <member name="scroll_hint_mode" type="int" setter="set_scroll_hint_mode" getter="get_scroll_hint_mode" enum="ScrollContainer.ScrollHintMode" default="0">
57 The way which scroll hints (indicators that show that the content can still be scrolled in a certain direction) will be shown.
58 [b]Note:[/b] Modes with perpendicular hints won't be shown if the content can be scrolled both vertically and horizontally.
59 </member>
60 <member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0">
61 The current horizontal scroll value.
62 [b]Note:[/b] If you are setting this value in the [method Node._ready] function or earlier, it needs to be wrapped with [method Object.set_deferred], since scroll bar's [member Range.max_value] is not initialized yet.
63 [codeblock]
64 func _ready():
65 set_deferred("scroll_horizontal", 600)
66 [/codeblock]
67 </member>
68 <member name="scroll_horizontal_by_default" type="bool" setter="set_scroll_horizontal_by_default" getter="is_scroll_horizontal_by_default" default="false">
69 If [code]true[/code], the mouse wheel scrolls the view horizontally, and holding [kbd]Shift[/kbd] scrolls vertically.
70 If [code]false[/code] (default), the mouse wheel scrolls the view vertically, and holding [kbd]Shift[/kbd] scrolls horizontally.
71 </member>
72 <member name="scroll_horizontal_custom_step" type="float" setter="set_horizontal_custom_step" getter="get_horizontal_custom_step" default="-1.0">
73 Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's horizontal increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
74 </member>
75 <member name="scroll_vertical" type="int" setter="set_v_scroll" getter="get_v_scroll" default="0">
76 The current vertical scroll value.
77 [b]Note:[/b] Setting it early needs to be deferred, just like in [member scroll_horizontal].
78 [codeblock]
79 func _ready():
80 set_deferred("scroll_vertical", 600)
81 [/codeblock]
82 </member>
83 <member name="scroll_vertical_custom_step" type="float" setter="set_vertical_custom_step" getter="get_vertical_custom_step" default="-1.0">
84 Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's vertical increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused.
85 </member>
86 <member name="tile_scroll_hint" type="bool" setter="set_tile_scroll_hint" getter="is_scroll_hint_tiled" default="false">
87 If [code]true[/code], the scroll hint texture will be tiled instead of stretched. See [member scroll_hint_mode].
88 </member>
89 <member name="vertical_scroll_mode" type="int" setter="set_vertical_scroll_mode" getter="get_vertical_scroll_mode" enum="ScrollContainer.ScrollMode" default="1">
90 Controls whether vertical scrollbar can be used and when it should be visible.
91 </member>
92 </members>
93 <signals>
94 <signal name="scroll_ended">
95 <description>
96 Emitted when scrolling stops when dragging the scrollable area [i]with a touch event[/i]. This signal is [i]not[/i] emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
97 [b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
98 </description>
99 </signal>
100 <signal name="scroll_started">
101 <description>
102 Emitted when scrolling starts when dragging the scrollable area [i]with a touch event[/i]. This signal is [i]not[/i] emitted when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
103 [b]Note:[/b] This signal is only emitted on Android or iOS, or on desktop/web platforms when [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse] is enabled.
104 </description>
105 </signal>
106 </signals>
107 <constants>
108 <constant name="SCROLL_MODE_DISABLED" value="0" enum="ScrollMode">
109 Scrolling disabled, scrollbar will be invisible.
110 </constant>
111 <constant name="SCROLL_MODE_AUTO" value="1" enum="ScrollMode">
112 Scrolling enabled, scrollbar will be visible only if necessary, i.e. container's content is bigger than the container.
113 </constant>
114 <constant name="SCROLL_MODE_SHOW_ALWAYS" value="2" enum="ScrollMode">
115 Scrolling enabled, scrollbar will be always visible.
116 </constant>
117 <constant name="SCROLL_MODE_SHOW_NEVER" value="3" enum="ScrollMode">
118 Scrolling enabled, scrollbar will be hidden.
119 </constant>
120 <constant name="SCROLL_MODE_RESERVE" value="4" enum="ScrollMode">
121 Combines [constant SCROLL_MODE_AUTO] and [constant SCROLL_MODE_SHOW_ALWAYS]. The scrollbar is only visible if necessary, but the content size is adjusted as if it was always visible. It's useful for ensuring that content size stays the same regardless if the scrollbar is visible.
122 </constant>
123 <constant name="SCROLL_MODE_MAXIMIZE_FIRST" value="5" enum="ScrollMode">
124 Behaves like [constant SCROLL_MODE_AUTO], but makes the [ScrollContainer] report a minimum size based on its content (limited by [member Control.custom_maximum_size] when set on the corresponding axis). This allows it to grow first and only start scrolling once constrained.
125 </constant>
126 <constant name="SCROLL_HINT_MODE_DISABLED" value="0" enum="ScrollHintMode">
127 Scroll hints will never be shown.
128 </constant>
129 <constant name="SCROLL_HINT_MODE_ALL" value="1" enum="ScrollHintMode">
130 Scroll hints will be shown at the top and bottom (if vertical), or left and right (if horizontal).
131 </constant>
132 <constant name="SCROLL_HINT_MODE_TOP_AND_LEFT" value="2" enum="ScrollHintMode">
133 Scroll hints will be shown at the top (if vertical), or the left (if horizontal).
134 </constant>
135 <constant name="SCROLL_HINT_MODE_BOTTOM_AND_RIGHT" value="3" enum="ScrollHintMode">
136 Scroll hints will be shown at the bottom (if horizontal), or the right (if horizontal).
137 </constant>
138 <constant name="SCROLL_HINT_MODE_TOP_AND_BOTTOM" value="4" enum="ScrollHintMode">
139 Scroll hints will be shown at the top and bottom.
140 </constant>
141 <constant name="SCROLL_HINT_MODE_LEFT_AND_RIGHT" value="5" enum="ScrollHintMode">
142 Scroll hints will be shown on the left and right.
143 </constant>
144 <constant name="SCROLL_HINT_MODE_TOP" value="6" enum="ScrollHintMode">
145 Scroll hint will be shown at the top.
146 </constant>
147 <constant name="SCROLL_HINT_MODE_BOTTOM" value="7" enum="ScrollHintMode">
148 Scroll hint will be shown at the bottom.
149 </constant>
150 <constant name="SCROLL_HINT_MODE_LEFT" value="8" enum="ScrollHintMode">
151 Scroll hint will be shown on the left.
152 </constant>
153 <constant name="SCROLL_HINT_MODE_RIGHT" value="9" enum="ScrollHintMode">
154 Scroll hint will be shown on the right.
155 </constant>
156 </constants>
157 <theme_items>
158 <theme_item name="scroll_hint_horizontal_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
159 [Color] used to modulate the [theme_item scroll_hint_horizontal] texture.
160 </theme_item>
161 <theme_item name="scroll_hint_vertical_color" data_type="color" type="Color" default="Color(0, 0, 0, 1)">
162 [Color] used to modulate the [theme_item scroll_hint_vertical] texture.
163 </theme_item>
164 <theme_item name="scrollbar_h_separation" data_type="constant" type="int" default="0">
165 The space between the ScrollContainer's vertical scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size.
166 </theme_item>
167 <theme_item name="scrollbar_margin_bottom" data_type="constant" type="int" default="-1">
168 The bottom margin of the horizontal scrollbar. When negative, uses [theme_item panel]'s bottom margin.
169 </theme_item>
170 <theme_item name="scrollbar_margin_left" data_type="constant" type="int" default="-1">
171 The left margin of the horizontal scrollbar. When negative, uses [theme_item panel]'s left margin.
172 </theme_item>
173 <theme_item name="scrollbar_margin_right" data_type="constant" type="int" default="-1">
174 The right margin of the horizontal scrollbar. When negative, uses [theme_item panel]'s right margin.
175 </theme_item>
176 <theme_item name="scrollbar_margin_top" data_type="constant" type="int" default="-1">
177 The top margin of the horizontal scrollbar. When negative, uses [theme_item panel]'s top margin.
178 </theme_item>
179 <theme_item name="scrollbar_v_separation" data_type="constant" type="int" default="0">
180 The space between the ScrollContainer's horizontal scroll bar and its content, in pixels. No space will be added when the content's minimum size is larger than the ScrollContainer's size.
181 </theme_item>
182 <theme_item name="scroll_hint_horizontal" data_type="icon" type="Texture2D">
183 The indicator that will be shown when the content can still be scrolled horizontally. See [member scroll_hint_mode].
184 </theme_item>
185 <theme_item name="scroll_hint_vertical" data_type="icon" type="Texture2D">
186 The indicator that will be shown when the content can still be scrolled vertically. See [member scroll_hint_mode].
187 </theme_item>
188 <theme_item name="focus" data_type="style" type="StyleBox">
189 The focus border [StyleBox] of the [ScrollContainer]. Only used if [member draw_focus_border] is [code]true[/code].
190 </theme_item>
191 <theme_item name="panel" data_type="style" type="StyleBox">
192 The background [StyleBox] of the [ScrollContainer].
193 </theme_item>
194 </theme_items>
195</class>