@@ -6,9 +6,8 @@ extends RefCounted
66## distances to boundaries, and handle margin/layout management.
77
88
9- ## Calculates container size on X axis without vertical scrollbar's width.
10- ## [param container] - The scroll container
11- ## [param content_margins] - StyleBox margins (left, top, right, bottom)
9+ ## Calculates the available container size on the X axis without the vertical scrollbar's width. [br]
10+ ## Uses [param container] dimensions and [param content_margins] for calculation.
1211static func get_spare_size_x (container : Control , content_margins : Vector4 ) -> float :
1312 var v_scroll_bar : ScrollBar = container .get_v_scroll_bar ()
1413 var size_x : float = container .size .x
@@ -20,9 +19,8 @@ static func get_spare_size_x(container: Control, content_margins: Vector4) -> fl
2019 return max (size_x , 0.0 )
2120
2221
23- ## Calculates container size on Y axis without horizontal scrollbar's height.
24- ## [param container] - The scroll container
25- ## [param content_margins] - StyleBox margins (left, top, right, bottom)
22+ ## Calculates the available container size on the Y axis without the horizontal scrollbar's height. [br]
23+ ## Uses [param container] dimensions and [param content_margins] for calculation.
2624static func get_spare_size_y (container : Control , content_margins : Vector4 ) -> float :
2725 var h_scroll_bar : ScrollBar = container .get_h_scroll_bar ()
2826 var size_y : float = container .size .y
@@ -34,20 +32,17 @@ static func get_spare_size_y(container: Control, content_margins: Vector4) -> fl
3432 return max (size_y , 0.0 )
3533
3634
37- ## Calculates container size without scrollbar sizes.
38- ## [param container] - The scroll container
39- ## [param content_margins] - StyleBox margins (left, top, right, bottom)
35+ ## Calculates the available container size on both axes without scrollbar sizes. [br]
36+ ## Uses [param container] dimensions and [param content_margins] for calculation.
4037static func get_spare_size (container : Control , content_margins : Vector4 ) -> Vector2 :
4138 return Vector2 (
4239 get_spare_size_x (container , content_margins ),
4340 get_spare_size_y (container , content_margins )
4441 )
4542
4643
47- ## Calculates the size difference between container and child node on X axis.
48- ## [param child] - The child control to measure
49- ## [param spare_size_x] - Available container width
50- ## [param clamp] - Whether to clamp child size to minimum of container size
44+ ## Calculates the size difference between container and [param child] node on the X axis. [br]
45+ ## When [param clamp] is [code]true[/code], clamps child size to minimum of [param spare_size_x].
5146static func get_child_size_x_diff (child : Control , spare_size_x : float , clamp : bool ) -> float :
5247 var child_size_x : float = child .size .x * child .scale .x
5348
@@ -57,10 +52,8 @@ static func get_child_size_x_diff(child: Control, spare_size_x: float, clamp: bo
5752 return child_size_x - spare_size_x
5853
5954
60- ## Calculates the size difference between container and child node on Y axis.
61- ## [param child] - The child control to measure
62- ## [param spare_size_y] - Available container height
63- ## [param clamp] - Whether to clamp child size to minimum of container size
55+ ## Calculates the size difference between container and [param child] node on the Y axis. [br]
56+ ## When [param clamp] is [code]true[/code], clamps child size to minimum of [param spare_size_y].
6457static func get_child_size_y_diff (child : Control , spare_size_y : float , clamp : bool ) -> float :
6558 var child_size_y : float = child .size .y * child .scale .y
6659
@@ -70,11 +63,8 @@ static func get_child_size_y_diff(child: Control, spare_size_y: float, clamp: bo
7063 return child_size_y - spare_size_y
7164
7265
73- ## Calculates the size difference between container and child node on both axes.
74- ## [param child] - The child control to measure
75- ## [param spare_size] - Available container size
76- ## [param clamp_x] - Whether to clamp child X size to minimum of container size
77- ## [param clamp_y] - Whether to clamp child Y size to minimum of container size
66+ ## Calculates the size difference between container and [param child] node on both axes. [br]
67+ ## When [param clamp_x] or [param clamp_y] is [code]true[/code], clamps respective child size to minimum of [param spare_size].
7868static func get_child_size_diff (
7969 child : Control ,
8070 spare_size : Vector2 ,
@@ -87,35 +77,30 @@ static func get_child_size_diff(
8777 )
8878
8979
90- ## Calculates distance to left boundary.
91- ## [param child_pos_x] - Current X position of child
80+ ## Calculates distance from the current [param child_pos_x] to the left boundary.
9281static func get_left_dist (child_pos_x : float ) -> float :
9382 return child_pos_x
9483
9584
96- ## Calculates distance to right boundary.
97- ## [param child_pos_x] - Current X position of child
98- ## [param child_size_diff_x] - Size difference between container and child on X axis
85+ ## Calculates distance from the current [param child_pos_x] to the right boundary. [br]
86+ ## Uses [param child_size_diff_x] for the size difference calculation.
9987static func get_right_dist (child_pos_x : float , child_size_diff_x : float ) -> float :
10088 return child_pos_x + child_size_diff_x
10189
10290
103- ## Calculates distance to top boundary.
104- ## [param child_pos_y] - Current Y position of child
91+ ## Calculates distance from the current [param child_pos_y] to the top boundary.
10592static func get_top_dist (child_pos_y : float ) -> float :
10693 return child_pos_y
10794
10895
109- ## Calculates distance to bottom boundary.
110- ## [param child_pos_y] - Current Y position of child
111- ## [param child_size_diff_y] - Size difference between container and child on Y axis
96+ ## Calculates distance from the current [param child_pos_y] to the bottom boundary. [br]
97+ ## Uses [param child_size_diff_y] for the size difference calculation.
11298static func get_bottom_dist (child_pos_y : float , child_size_diff_y : float ) -> float :
11399 return child_pos_y + child_size_diff_y
114100
115101
116- ## Calculates distance to all four boundaries (left, right, top, bottom).
117- ## [param child_pos] - Current position of child
118- ## [param child_size_diff] - Size difference between container and child
102+ ## Calculates distances from the current [param child_pos] to all four boundaries. [br]
103+ ## Returns [Vector4] with distances: [code](left, right, top, bottom)[/code]. Uses [param child_size_diff] for calculations.
119104static func get_boundary_dist (child_pos : Vector2 , child_size_diff : Vector2 ) -> Vector4 :
120105 return Vector4 (
121106 get_left_dist (child_pos .x ),
@@ -125,35 +110,30 @@ static func get_boundary_dist(child_pos: Vector2, child_size_diff: Vector2) -> V
125110 )
126111
127112
128- ## Checks if content is currently beyond the top boundary.
129- ## [param pos_y] - Y position to check
113+ ## Checks whether content at [param pos_y] is currently beyond the top boundary.
130114static func is_outside_top_boundary (pos_y : float ) -> bool :
131115 return pos_y > 0.0
132116
133117
134- ## Checks if content is currently beyond the bottom boundary.
135- ## [param pos_y] - Y position to check
136- ## [param size_diff_y] - Size difference on Y axis
118+ ## Checks whether content at [param pos_y] is currently beyond the bottom boundary. [br]
119+ ## Uses [param size_diff_y] to determine the boundary position.
137120static func is_outside_bottom_boundary (pos_y : float , size_diff_y : float ) -> bool :
138121 return pos_y < - size_diff_y
139122
140123
141- ## Checks if content is currently beyond the left boundary.
142- ## [param pos_x] - X position to check
124+ ## Checks whether content at [param pos_x] is currently beyond the left boundary.
143125static func is_outside_left_boundary (pos_x : float ) -> bool :
144126 return pos_x > 0.0
145127
146128
147- ## Checks if content is currently beyond the right boundary.
148- ## [param pos_x] - X position to check
149- ## [param size_diff_x] - Size difference on X axis
129+ ## Checks whether content at [param pos_x] is currently beyond the right boundary. [br]
130+ ## Uses [param size_diff_x] to determine the boundary position.
150131static func is_outside_right_boundary (pos_x : float , size_diff_x : float ) -> bool :
151132 return pos_x < - size_diff_x
152133
153134
154- ## Updates and retrieves content margins from container's StyleBox.
155- ## [param container] - The scroll container
156- ## Returns Vector4 with margins (left, top, right, bottom)
135+ ## Retrieves content margins from the [param container]'s StyleBox. [br]
136+ ## Returns [Vector4] with margins in order: [code](left, top, right, bottom)[/code].
157137static func get_content_margins (container : Control ) -> Vector4 :
158138 var style_box : StyleBox = container .get_theme_stylebox ("panel" )
159139 if style_box :
@@ -167,19 +147,15 @@ static func get_content_margins(container: Control) -> Vector4:
167147 return Vector4 .ZERO
168148
169149
170- ## Calculates the baseline offset for content positioning.
150+ ## Calculates the baseline offset for content positioning from [param content_node] and [param current_scroll_pos]. [br]
171151## This captures the layout offset applied by StyleBox and content positioning.
172- ## [param content_node] - The content control node
173- ## [param current_scroll_pos] - Current scroll position
174- ## Returns the baseline offset as Vector2
175152static func calculate_base_offset (content_node : Control , current_scroll_pos : Vector2 ) -> Vector2 :
176153 if not content_node :
177154 return Vector2 .ZERO
178155 return content_node .position - current_scroll_pos
179156
180157
181- ## Calculates the initial base offset from margins.
182- ## [param content_margins] - StyleBox margins (left, top, right, bottom)
183- ## Returns the baseline offset as Vector2
158+ ## Calculates the initial base offset from [param content_margins]. [br]
159+ ## Returns the baseline offset as [Vector2].
184160static func calculate_initial_offset (content_margins : Vector4 ) -> Vector2 :
185161 return Vector2 (content_margins .x , content_margins .y )
0 commit comments