feat(ScrollBar): click-drag support #54
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mupen64/ugui!54
Loading…
Reference in a new issue
No description provided.
Delete branch "relative-scrollbar"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request overview
Adds click-drag behavior to the
ScrollBarcontrol by tracking a per-drag offset so the thumb doesn’t “jump” when dragging begins.Changes:
setup()for scrollbar control state initialization (data.drag_offset).metatable.Comments suppressed due to low confidence (2)
src/ugui/controls/scrollbar.lua:27
ratiois only type-checked, but the new drag math assumes it’s within a sane range. Ifratio <= 0orratio > 1,thumb_sizebecomes invalid and the remap/division logic can misbehave. Consider validating (or clamping)ratioto something like(0, 1]invalidate, and handle theratio == 1no-scroll case explicitly.src/ugui/controls/scrollbar.lua:55
metatable is inconsistent with the common style used by other controls (e.g.,src/ugui/controls/trackbar.lua:34andsrc/ugui/controls/joystick.lua:51use{ signal_change = ... }). For consistency/readability, consider restoring the spaces inside the braces here.💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
track_lengthcan become 0 (e.g.,ratio == 1) or negative (ratio > 1), which makescurrent_pos / track_lengthproducenan/infand then propagate throughclamp. Please guard againsttrack_length <= 0(e.g., keepdata.valueunchanged and/or force it to 0) before dividing, so dragging can’t generatenanvalues.