mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-04-08 02:43:58 +08:00
* split nav widget out * clean up * clean up * fix * work * small enough to not be function * nah we want intflag * clean up * always runs * more clean up * prep for scroller * opacity for settings * clean up layout * set enabled * rm
17 lines
639 B
Python
17 lines
639 B
Python
import pyray as rl
|
|
from openpilot.system.ui.lib.application import gui_app
|
|
from openpilot.system.ui.widgets import Widget
|
|
|
|
|
|
class IconWidget(Widget):
|
|
def __init__(self, image_path: str, size: tuple[int, int], opacity: float = 1.0):
|
|
super().__init__()
|
|
self._texture = gui_app.texture(image_path, size[0], size[1])
|
|
self._opacity = opacity
|
|
self.set_rect(rl.Rectangle(0, 0, float(size[0]), float(size[1])))
|
|
self.set_enabled(False)
|
|
|
|
def _render(self, _) -> None:
|
|
color = rl.Color(255, 255, 255, int(self._opacity * 255))
|
|
rl.draw_texture_ex(self._texture, rl.Vector2(self._rect.x, self._rect.y), 0.0, 1.0, color)
|