Experimental button should be raylib widget (#35491)

should be widget
pull/35489/head
Shane Smiskol 3 weeks ago committed by GitHub
parent 2031a33188
commit db5e413049
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      selfdrive/ui/onroad/exp_button.py
  2. 2
      selfdrive/ui/onroad/hud_renderer.py

@ -2,11 +2,11 @@ import time
import pyray as rl import pyray as rl
from cereal.messaging import SubMaster from cereal.messaging import SubMaster
from openpilot.selfdrive.ui.ui_state import ui_state from openpilot.selfdrive.ui.ui_state import ui_state
from openpilot.system.ui.lib.application import gui_app from openpilot.system.ui.lib.application import gui_app, Widget
from openpilot.common.params import Params from openpilot.common.params import Params
class ExpButton: class ExpButton(Widget):
def __init__(self, button_size: int, icon_size: int): def __init__(self, button_size: int, icon_size: int):
self._params = Params() self._params = Params()
self._experimental_mode: bool = False self._experimental_mode: bool = False
@ -41,8 +41,8 @@ class ExpButton:
return True return True
return False return False
def draw(self, x: int, y: int) -> None: def render(self, rect: rl.Rectangle) -> None:
self._rect.x, self._rect.y = x, y self._rect.x, self._rect.y = rect.x, rect.y
center_x = int(self._rect.x + self._rect.width // 2) center_x = int(self._rect.x + self._rect.width // 2)
center_y = int(self._rect.y + self._rect.height // 2) center_y = int(self._rect.y + self._rect.height // 2)

@ -120,7 +120,7 @@ class HudRenderer(Widget):
button_x = rect.x + rect.width - UI_CONFIG.border_size - UI_CONFIG.button_size button_x = rect.x + rect.width - UI_CONFIG.border_size - UI_CONFIG.button_size
button_y = rect.y + UI_CONFIG.border_size button_y = rect.y + UI_CONFIG.border_size
self._exp_button.draw(button_x, button_y) self._exp_button.render(rl.Rectangle(button_x, button_y, 0, 0))
def handle_mouse_event(self) -> bool: def handle_mouse_event(self) -> bool:
return bool(self._exp_button.handle_mouse_event()) return bool(self._exp_button.handle_mouse_event())

Loading…
Cancel
Save