mici setup: new start button (#37501)
* pressable * slow * fast and looks great * 0.075 * clean up * fix missing * clean up
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
selfdrive/assets/icons_mici/setup/start_button.png
LFS
Normal file
BIN
selfdrive/assets/icons_mici/setup/start_button.png
LFS
Normal file
Binary file not shown.
BIN
selfdrive/assets/icons_mici/setup/start_button_pressed.png
LFS
Normal file
BIN
selfdrive/assets/icons_mici/setup/start_button_pressed.png
LFS
Normal file
Binary file not shown.
@@ -14,6 +14,7 @@ from collections.abc import Callable
|
||||
import pyray as rl
|
||||
|
||||
from cereal import log
|
||||
from openpilot.common.filter_simple import FirstOrderFilter
|
||||
from openpilot.common.realtime import config_realtime_process, set_core_affinity
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.common.utils import run_cmd
|
||||
@@ -109,16 +110,21 @@ class StartPage(Widget):
|
||||
font_weight=FontWeight.DISPLAY, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
||||
|
||||
self._start_bg_txt = gui_app.texture("icons_mici/setup/green_button.png", 520, 224)
|
||||
self._start_bg_pressed_txt = gui_app.texture("icons_mici/setup/green_button_pressed.png", 520, 224)
|
||||
self._start_bg_txt = gui_app.texture("icons_mici/setup/start_button.png", 500, 224, keep_aspect_ratio=False)
|
||||
self._start_bg_pressed_txt = gui_app.texture("icons_mici/setup/start_button_pressed.png", 500, 224, keep_aspect_ratio=False)
|
||||
self._scale_filter = FirstOrderFilter(1.0, 0.1, 1 / gui_app.target_fps)
|
||||
self._click_delay = 0.075
|
||||
|
||||
def _render(self, rect: rl.Rectangle):
|
||||
draw_x = rect.x + (rect.width - self._start_bg_txt.width) / 2
|
||||
draw_y = rect.y + (rect.height - self._start_bg_txt.height) / 2
|
||||
scale = self._scale_filter.update(1.07 if self.is_pressed else 1.0)
|
||||
base_draw_x = rect.x + (rect.width - self._start_bg_txt.width) / 2
|
||||
base_draw_y = rect.y + (rect.height - self._start_bg_txt.height) / 2
|
||||
draw_x = base_draw_x + (self._start_bg_txt.width * (1 - scale)) / 2
|
||||
draw_y = base_draw_y + (self._start_bg_txt.height * (1 - scale)) / 2
|
||||
texture = self._start_bg_pressed_txt if self.is_pressed else self._start_bg_txt
|
||||
rl.draw_texture(texture, int(draw_x), int(draw_y), rl.WHITE)
|
||||
rl.draw_texture_ex(texture, (draw_x, draw_y), 0, scale, rl.WHITE)
|
||||
|
||||
self._title.render(rect)
|
||||
self._title.render(rl.Rectangle(rect.x, rect.y + (draw_y - base_draw_y), rect.width, rect.height))
|
||||
|
||||
|
||||
class SoftwareSelectionPage(Widget):
|
||||
|
||||
Reference in New Issue
Block a user