Skip to content

Commit d24deb7

Browse files
committed
Documentation fixes
1 parent 873d7f2 commit d24deb7

11 files changed

Lines changed: 159 additions & 272 deletions

addons/SmoothScroll/helpers/scroll_debugger.gd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ extends RefCounted
99
static var debug_gradient: Gradient = null
1010

1111

12-
## Sets up the gradient for debug visualization
12+
## Sets up the gradient for debug visualization.
1313
static func setup_debug_drawing() -> void:
1414
if debug_gradient == null:
1515
debug_gradient = Gradient.new()
1616
debug_gradient.set_color(0.0, Color.GREEN)
1717
debug_gradient.set_color(1.0, Color.RED)
1818

1919

20-
## Draws debug visualization showing overdrag distances and velocity.
21-
## [param container] - The SmoothScrollContainer to draw debug info for
20+
## Draws debug visualization for the specified [param container]. [br]
21+
## Shows overdrag distances and velocity indicators using colored lines.
2222
static func draw_debug(container: SmoothScrollContainer) -> void:
2323
if not container.content_node: return
2424

addons/SmoothScroll/helpers/scroll_input_handler.gd

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ var drag_temp_data: Array = []
3333
#endregion
3434

3535

36-
## Initializes the input handler with a container reference.
37-
## [param container] - The SmoothScrollContainer to handle input for
36+
## Initializes the input handler with a reference to the [param container].
3837
func _init(container: SmoothScrollContainer) -> void:
3938
_container = container
4039

4140

42-
## Processes GUI input events for scrolling.
43-
## [param event] - The input event to process
41+
## Processes GUI input events for scrolling. [br]
42+
## Handles mouse wheel, dragging, pan gestures, and touch events from [param event].
4443
func process_gui_input(event: InputEvent) -> void:
4544
# Show scrollbars on mouse motion
4645
if _container.hide_scrollbar_over_time and event is InputEventMouseMotion:
@@ -68,9 +67,8 @@ func process_gui_input(event: InputEvent) -> void:
6867
_container.get_tree().get_root().set_input_as_handled()
6968

7069

71-
## Processes scrollbar input events.
72-
## [param event] - The input event to process
73-
## [param vertical] - True for vertical scrollbar, false for horizontal
70+
## Processes scrollbar input events from [param event]. [br]
71+
## Handles both [param vertical] and horizontal scrollbar interactions.
7472
func process_scrollbar_input(event: InputEvent, vertical: bool) -> void:
7573
if event is InputEventMouseButton:
7674
# Forward wheel events to main input handler
@@ -90,8 +88,7 @@ func process_scrollbar_input(event: InputEvent, vertical: bool) -> void:
9088
_handle_scrollbar_touch(event, vertical)
9189

9290

93-
## Called when mouse enters/exits scrollbar area.
94-
## [param entered] - True if mouse entered, false if exited
91+
## Called when mouse enters or exits scrollbar area based on [param entered].
9592
func on_mouse_scrollbar(entered: bool) -> void:
9693
mouse_on_scrollbar = entered
9794

@@ -101,7 +98,7 @@ func any_scrollbar_dragging() -> bool:
10198
return h_scrollbar_dragging or v_scrollbar_dragging
10299

103100

104-
## Initializes drag temporary data with current position and boundaries.
101+
## Initializes drag temporary data with current position and boundary distances.
105102
func init_drag_temp_data() -> void:
106103
var spare_size: Vector2 = ScrollLayout.get_spare_size(_container, _container.content_margins)
107104
var content_node_size_diff: Vector2 = ScrollLayout.get_child_size_diff(
@@ -126,8 +123,7 @@ func init_drag_temp_data() -> void:
126123
]
127124

128125

129-
## Processes mouse button events (wheel scrolling and drag).
130-
## [param event] - The mouse button event
126+
## Processes mouse button events for wheel scrolling and dragging from [param event].
131127
func _process_mouse_button(event: InputEventMouseButton) -> void:
132128
match event.button_index:
133129
MOUSE_BUTTON_WHEEL_DOWN:
@@ -149,10 +145,8 @@ func _process_mouse_button(event: InputEventMouseButton) -> void:
149145
_end_content_drag()
150146

151147

152-
## Handles mouse wheel scrolling.
153-
## [param event] - The mouse button event
154-
## [param positive] - True for positive direction (up/left), false for negative (down/right)
155-
## [param is_vertical] - True for vertical wheel, false for horizontal wheel
148+
## Handles mouse wheel scrolling from [param event]. [br]
149+
## Scrolls in [param positive] direction (up/left or down/right) for the specified axis ([param is_vertical]).
156150
func _handle_wheel_scroll(event: InputEventMouseButton, positive: bool, is_vertical: bool) -> void:
157151
_container.last_scroll_type = SmoothScrollContainer.SCROLL_TYPE.WHEEL
158152
_container.scroll_damper = _container.wheel_scroll_damper
@@ -195,8 +189,7 @@ func _end_content_drag() -> void:
195189
is_in_deadzone = false
196190

197191

198-
## Processes drag motion events.
199-
## [param event] - The motion event with relative movement
192+
## Processes drag motion events with relative movement from [param event].
200193
func _process_drag_motion(event) -> void:
201194
if not content_dragging: return
202195

@@ -209,8 +202,7 @@ func _process_drag_motion(event) -> void:
209202
_container.handle_content_dragging()
210203

211204

212-
## Processes pan gesture events.
213-
## [param event] - The pan gesture event
205+
## Processes pan gesture events from [param event].
214206
func _process_pan_gesture(event: InputEventPanGesture) -> void:
215207
if _container.should_scroll_horizontal():
216208
_container.velocity.x = -event.delta.x * speed
@@ -220,8 +212,7 @@ func _process_pan_gesture(event: InputEventPanGesture) -> void:
220212
_container.scrollbar_animator.kill_scroll_tweens()
221213

222214

223-
## Processes screen touch events.
224-
## [param event] - The touch event
215+
## Processes screen touch events from [param event].
225216
func _process_screen_touch(event: InputEventScreenTouch) -> void:
226217
if event.pressed:
227218
if not drag_with_touch:
@@ -238,9 +229,8 @@ func _process_screen_touch(event: InputEventScreenTouch) -> void:
238229
is_in_deadzone = false
239230

240231

241-
## Handles scrollbar dragging with mouse button.
242-
## [param event] - The mouse button event
243-
## [param vertical] - True for vertical scrollbar, false for horizontal
232+
## Handles scrollbar dragging with mouse button from [param event]. [br]
233+
## Processes [param vertical] or horizontal scrollbar interactions.
244234
func _handle_scrollbar_drag_button(event: InputEventMouseButton, vertical: bool) -> void:
245235
if event.pressed:
246236
if vertical:
@@ -256,9 +246,8 @@ func _handle_scrollbar_drag_button(event: InputEventMouseButton, vertical: bool)
256246
h_scrollbar_dragging = false
257247

258248

259-
## Handles scrollbar dragging with touch.
260-
## [param event] - The touch event
261-
## [param vertical] - True for vertical scrollbar, false for horizontal
249+
## Handles scrollbar dragging with touch from [param event]. [br]
250+
## Processes [param vertical] or horizontal scrollbar interactions.
262251
func _handle_scrollbar_touch(event: InputEventScreenTouch, vertical: bool) -> void:
263252
if event.pressed:
264253
if vertical:
@@ -274,8 +263,7 @@ func _handle_scrollbar_touch(event: InputEventScreenTouch, vertical: bool) -> vo
274263
h_scrollbar_dragging = false
275264

276265

277-
## Recursively removes focus from a node and all its children.
278-
## [param node] - The node to remove focus from
266+
## Recursively removes focus from the specified [param node] and all its children.
279267
func _remove_all_children_focus(node: Node) -> void:
280268
if node is Control:
281269
var control := node as Control

addons/SmoothScroll/helpers/scroll_layout.gd

Lines changed: 31 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
1211
static 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.
2624
static 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.
4037
static 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].
5146
static 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].
6457
static 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].
7868
static 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.
9281
static 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.
9987
static 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.
10592
static 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.
11298
static 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.
119104
static 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.
130114
static 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.
137120
static 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.
143125
static 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.
150131
static 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].
157137
static 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
175152
static 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].
184160
static func calculate_initial_offset(content_margins: Vector4) -> Vector2:
185161
return Vector2(content_margins.x, content_margins.y)

0 commit comments

Comments
 (0)