mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-08 23:22:04 +08:00
BigUI WIP: Drop starpilot_icon
This commit is contained in:
@@ -10,7 +10,7 @@ from openpilot.system.ui.lib.scroll_panel2 import GuiScrollPanel2
|
||||
from openpilot.system.ui.lib.text_measure import measure_text_cached
|
||||
from openpilot.system.ui.widgets import Widget, DialogResult
|
||||
from openpilot.system.ui.widgets.label import gui_label
|
||||
from openpilot.selfdrive.ui.layouts.settings.starpilot.asset_loader import starpilot_texture
|
||||
|
||||
from openpilot.selfdrive.ui.layouts.settings.starpilot.scribble import draw_custom_icon
|
||||
|
||||
|
||||
@@ -2442,9 +2442,8 @@ class HubTile(AetherTile):
|
||||
self,
|
||||
title: str | Callable[[], str],
|
||||
desc: str | Callable[[], str],
|
||||
icon_path: str,
|
||||
icon_key: str | None = None,
|
||||
on_click: Callable | None = None,
|
||||
starpilot_icon: bool = False,
|
||||
bg_color: rl.Color | str | None = None,
|
||||
get_status: Callable[[], str] | None = None,
|
||||
):
|
||||
@@ -2455,17 +2454,8 @@ class HubTile(AetherTile):
|
||||
self.get_status = get_status
|
||||
self.title = title
|
||||
self.desc = desc
|
||||
self.custom_icon_key = None
|
||||
if icon_path:
|
||||
if icon_path in ["sound", "steering", "navigate", "system", "display", "vehicle"]:
|
||||
self.custom_icon_key = icon_path
|
||||
self._icon = None
|
||||
elif starpilot_icon:
|
||||
self._icon = starpilot_texture(icon_path, 100, 100)
|
||||
else:
|
||||
self._icon = gui_app.texture(icon_path, 100, 100)
|
||||
else:
|
||||
self._icon = None
|
||||
self.custom_icon_key = icon_key if icon_key in ("sound", "steering", "navigate", "system", "display", "vehicle") else None
|
||||
self._icon = None
|
||||
self._font_title = gui_app.font(FontWeight.BOLD)
|
||||
self._font_desc = gui_app.font(FontWeight.NORMAL)
|
||||
|
||||
|
||||
@@ -197,9 +197,8 @@ class StarPilotLayout(Widget):
|
||||
tile = HubTile(
|
||||
title=tr(cat["title"]),
|
||||
desc=tr(cat.get("desc", "")),
|
||||
icon_path=cat["icon"],
|
||||
icon_key=cat["icon"],
|
||||
on_click=on_click,
|
||||
starpilot_icon=True,
|
||||
bg_color=cat.get("color")
|
||||
)
|
||||
self._main_grid.add_tile(tile)
|
||||
@@ -216,9 +215,8 @@ class StarPilotLayout(Widget):
|
||||
tile = HubTile(
|
||||
title=tr(label),
|
||||
desc="",
|
||||
icon_path=cat["icon"],
|
||||
icon_key=cat["icon"],
|
||||
on_click=on_btn_click,
|
||||
starpilot_icon=True,
|
||||
bg_color=cat.get("color")
|
||||
)
|
||||
self._main_grid.add_tile(tile)
|
||||
|
||||
@@ -126,9 +126,8 @@ class StarPilotPanel(Widget):
|
||||
return HubTile(
|
||||
title=tr(cat["title"]),
|
||||
desc=tr(cat.get("desc", "")),
|
||||
icon_path=cat.get("icon"),
|
||||
icon_key=cat.get("icon"),
|
||||
on_click=on_click,
|
||||
starpilot_icon=cat.get("starpilot_icon", True),
|
||||
bg_color=cat.get("color"),
|
||||
get_status=cat.get("get_status"),
|
||||
)
|
||||
|
||||
@@ -262,7 +262,7 @@ class TestAethergridContracts(unittest.TestCase):
|
||||
|
||||
def test_hub_tile_preserves_status_progress_api(self):
|
||||
mod = _import_aethergrid()
|
||||
tile = mod.HubTile("Driving Controls", "Desc", "", bg_color="#3B82F6", get_status=lambda: "Download 50%")
|
||||
tile = mod.HubTile("Driving Controls", "Desc", bg_color="#3B82F6", get_status=lambda: "Download 50%")
|
||||
|
||||
self.assertEqual(tile.get_status(), "Download 50%")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user