mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-13 21:32:14 +08:00
Scroll panel 2: use float for offset (#36705)
* use float internally * use it everywhere -- this fixes all the problemS?! * round it everywhere * this looks so much better than before * rm
This commit is contained in:
@@ -39,7 +39,7 @@ class MiciFccModal(NavWidget):
|
||||
content_height += self._fcc_logo.height + 20
|
||||
|
||||
scroll_content_rect = rl.Rectangle(rect.x, rect.y, rect.width, content_height)
|
||||
scroll_offset = self._scroll_panel.update(rect, scroll_content_rect.height)
|
||||
scroll_offset = round(self._scroll_panel.update(rect, scroll_content_rect.height))
|
||||
|
||||
fcc_pos = rl.Vector2(rect.x + 20, rect.y + 20 + scroll_offset)
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class FirehoseLayoutBase(Widget):
|
||||
def _render(self, rect: rl.Rectangle):
|
||||
# compute total content height for scrolling
|
||||
content_height = self._measure_content_height(rect)
|
||||
scroll_offset = self._scroll_panel.update(rect, content_height)
|
||||
scroll_offset = round(self._scroll_panel.update(rect, content_height))
|
||||
|
||||
# start drawing with offset
|
||||
x = int(rect.x + 40)
|
||||
|
||||
@@ -8,7 +8,7 @@ from openpilot.system.ui.lib.application import gui_app, MouseEvent
|
||||
from openpilot.system.hardware import TICI
|
||||
from collections import deque
|
||||
|
||||
MIN_VELOCITY = 2 # px/s, changes from auto scroll to steady state
|
||||
MIN_VELOCITY = 10 # px/s, changes from auto scroll to steady state
|
||||
MIN_VELOCITY_FOR_CLICKING = 2 * 60 # px/s, accepts clicks while auto scrolling below this velocity
|
||||
MIN_DRAG_PIXELS = 12
|
||||
AUTO_SCROLL_TC_SNAP = 0.025
|
||||
@@ -202,8 +202,8 @@ class GuiScrollPanel2:
|
||||
def _get_mouse_pos(self, mouse_event: MouseEvent) -> float:
|
||||
return mouse_event.pos.x if self._horizontal else mouse_event.pos.y
|
||||
|
||||
def get_offset(self) -> int:
|
||||
return round(self._offset.x if self._horizontal else self._offset.y)
|
||||
def get_offset(self) -> float:
|
||||
return self._offset.x if self._horizontal else self._offset.y
|
||||
|
||||
def set_offset(self, value: float) -> None:
|
||||
if self._horizontal:
|
||||
|
||||
@@ -244,7 +244,7 @@ class TermsPage(Widget):
|
||||
pass
|
||||
|
||||
def _render(self, _):
|
||||
scroll_offset = self._scroll_panel.update(self._rect, self._content_height + self._continue_button.rect.height + 16)
|
||||
scroll_offset = round(self._scroll_panel.update(self._rect, self._content_height + self._continue_button.rect.height + 16))
|
||||
|
||||
if scroll_offset <= self._scrolled_down_offset:
|
||||
# don't show back if not enabled
|
||||
|
||||
@@ -124,7 +124,7 @@ class Scroller(Widget):
|
||||
self.scroll_panel.set_enabled(scroll_enabled and self.enabled)
|
||||
self.scroll_panel.update(self._rect, content_size)
|
||||
if not self._snap_items:
|
||||
return self.scroll_panel.get_offset()
|
||||
return round(self.scroll_panel.get_offset())
|
||||
|
||||
# Snap closest item to center
|
||||
center_pos = self._rect.x + self._rect.width / 2 if self._horizontal else self._rect.y + self._rect.height / 2
|
||||
|
||||
Reference in New Issue
Block a user