raylib: scroll panel cleanup (#35599)

* no d

* we don't even use it

* use a deque

* hmm

* Revert "hmm"

This reverts commit 0203bf7214.
pull/35598/head^2
Shane Smiskol 2 days ago committed by GitHub
parent a22eecd773
commit 56fca1353f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      system/ui/lib/scroll_panel.py

@ -1,4 +1,5 @@
import pyray as rl import pyray as rl
from collections import deque
from enum import IntEnum from enum import IntEnum
# Scroll constants for smooth scrolling behavior # Scroll constants for smooth scrolling behavior
@ -31,8 +32,7 @@ class GuiScrollPanel:
self._velocity_y = 0.0 # Velocity for inertia self._velocity_y = 0.0 # Velocity for inertia
self._is_dragging: bool = False self._is_dragging: bool = False
self._bounce_offset: float = 0.0 self._bounce_offset: float = 0.0
self._last_frame_time = rl.get_time() self._velocity_history: deque[float] = deque(maxlen=VELOCITY_HISTORY_SIZE)
self._velocity_history: list[float] = []
self._last_drag_time: float = 0.0 self._last_drag_time: float = 0.0
self._content_rect: rl.Rectangle | None = None self._content_rect: rl.Rectangle | None = None
self._bounds_rect: rl.Rectangle | None = None self._bounds_rect: rl.Rectangle | None = None
@ -44,11 +44,6 @@ class GuiScrollPanel:
# Calculate time delta # Calculate time delta
current_time = rl.get_time() current_time = rl.get_time()
delta_time = current_time - self._last_frame_time
self._last_frame_time = current_time
# Prevent large jumps
delta_time = min(delta_time, 0.05)
mouse_pos = rl.get_mouse_position() mouse_pos = rl.get_mouse_position()
max_scroll_y = max(content.height - bounds.height, 0) max_scroll_y = max(content.height - bounds.height, 0)
@ -66,7 +61,7 @@ class GuiScrollPanel:
self._last_mouse_y = mouse_pos.y self._last_mouse_y = mouse_pos.y
self._start_mouse_y = mouse_pos.y self._start_mouse_y = mouse_pos.y
self._last_drag_time = current_time self._last_drag_time = current_time
self._velocity_history = [] self._velocity_history.clear()
self._velocity_y = 0.0 self._velocity_y = 0.0
self._bounce_offset = 0.0 self._bounce_offset = 0.0
self._is_dragging = False self._is_dragging = False
@ -82,9 +77,6 @@ class GuiScrollPanel:
drag_velocity = delta_y / time_since_last_drag / 60.0 drag_velocity = delta_y / time_since_last_drag / 60.0
self._velocity_history.append(drag_velocity) self._velocity_history.append(drag_velocity)
if len(self._velocity_history) > VELOCITY_HISTORY_SIZE:
self._velocity_history.pop(0)
self._last_drag_time = current_time self._last_drag_time = current_time
# Detect actual dragging # Detect actual dragging

Loading…
Cancel
Save