Skip to content

Commit db5e413

Browse files
authored
Experimental button should be raylib widget (#35491)
should be widget
1 parent 2031a33 commit db5e413

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

selfdrive/ui/onroad/exp_button.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import pyray as rl
33
from cereal.messaging import SubMaster
44
from openpilot.selfdrive.ui.ui_state import ui_state
5-
from openpilot.system.ui.lib.application import gui_app
5+
from openpilot.system.ui.lib.application import gui_app, Widget
66
from openpilot.common.params import Params
77

88

9-
class ExpButton:
9+
class ExpButton(Widget):
1010
def __init__(self, button_size: int, icon_size: int):
1111
self._params = Params()
1212
self._experimental_mode: bool = False
@@ -41,8 +41,8 @@ def handle_mouse_event(self) -> bool:
4141
return True
4242
return False
4343

44-
def draw(self, x: int, y: int) -> None:
45-
self._rect.x, self._rect.y = x, y
44+
def render(self, rect: rl.Rectangle) -> None:
45+
self._rect.x, self._rect.y = rect.x, rect.y
4646
center_x = int(self._rect.x + self._rect.width // 2)
4747
center_y = int(self._rect.y + self._rect.height // 2)
4848

selfdrive/ui/onroad/hud_renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def render(self, rect: rl.Rectangle) -> None:
120120

121121
button_x = rect.x + rect.width - UI_CONFIG.border_size - UI_CONFIG.button_size
122122
button_y = rect.y + UI_CONFIG.border_size
123-
self._exp_button.draw(button_x, button_y)
123+
self._exp_button.render(rl.Rectangle(button_x, button_y, 0, 0))
124124

125125
def handle_mouse_event(self) -> bool:
126126
return bool(self._exp_button.handle_mouse_event())

0 commit comments

Comments
 (0)