raylib: format from today's prs

pull/35503/head
Shane Smiskol 2 months ago
parent 9153f97900
commit f70592b7e9
  1. 1
      selfdrive/ui/layouts/settings/device.py
  2. 4
      selfdrive/ui/layouts/settings/software.py
  3. 4
      selfdrive/ui/widgets/exp_mode_button.py
  4. 1
      system/ui/lib/button.py
  5. 9
      system/ui/lib/list_view.py
  6. 1
      system/ui/widgets/confirm_dialog.py
  7. 2
      system/ui/widgets/option_dialog.py

@ -11,7 +11,6 @@ from openpilot.system.ui.lib.list_view import ListView, text_item, button_item
from openpilot.system.ui.widgets.option_dialog import MultiOptionDialog
from openpilot.system.ui.widgets.confirm_dialog import confirm_dialog, alert_dialog
# Description constants
DESCRIPTIONS = {
'pair_device': "Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.",

@ -30,11 +30,11 @@ class SoftwareLayout(Widget):
def _on_select_branch(self): pass
def _on_uninstall(self):
def handle_uninstall_confirmation(result):
def handle_uninstall_confirmation(result):
if result == DialogResult.CONFIRM:
self._params.put_bool("DoUninstall", True)
gui_app.set_modal_overlay(
gui_app.set_modal_overlay(
lambda: confirm_dialog("Are you sure you want to uninstall?", "Uninstall"),
callback=handle_uninstall_confirmation,
)

@ -30,7 +30,7 @@ class ExperimentalModeButton(Widget):
def _draw_gradient_background(self, rect):
start_color, end_color = self._get_gradient_colors()
rl.draw_rectangle_gradient_h(int(rect.x), int(rect.y), int(rect.width), int(rect.height),
start_color, end_color)
start_color, end_color)
def _handle_interaction(self, rect):
mouse_pos = rl.get_mouse_position()
@ -59,7 +59,7 @@ class ExperimentalModeButton(Widget):
# Draw text label (left aligned)
text = "EXPERIMENTAL MODE ON" if self.experimental_mode else "CHILL MODE ON"
text_x = rect.x + self.horizontal_padding
text_y = rect.y + rect.height / 2 - 45//2 # Center vertically
text_y = rect.y + rect.height / 2 - 45 // 2 # Center vertically
rl.draw_text_ex(gui_app.font(FontWeight.NORMAL), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.Color(0, 0, 0, 255))

@ -24,7 +24,6 @@ DEFAULT_BUTTON_FONT_SIZE = 60
BUTTON_DISABLED_TEXT_COLOR = rl.Color(228, 228, 228, 51)
ACTION_BUTTON_FONT_SIZE = 48
BUTTON_TEXT_COLOR = {
ButtonStyle.NORMAL: rl.Color(228, 228, 228, 255),
ButtonStyle.PRIMARY: rl.Color(228, 228, 228, 255),

@ -10,7 +10,6 @@ from openpilot.system.ui.lib.wrap_text import wrap_text
from openpilot.system.ui.lib.button import gui_button, ButtonStyle
from openpilot.system.ui.lib.toggle import Toggle, WIDTH as TOGGLE_WIDTH, HEIGHT as TOGGLE_HEIGHT
ITEM_BASE_HEIGHT = 170
LINE_PADDING = 40
LINE_COLOR = rl.GRAY
@ -31,6 +30,7 @@ BUTTON_FONT_WEIGHT = FontWeight.MEDIUM
TEXT_PADDING = 20
def _resolve_value(value, default=""):
return value() if callable(value) else (value or default)
@ -191,7 +191,7 @@ class ListView(Widget):
rl.begin_scissor_mode(int(rect.x), int(rect.y), int(rect.width), int(rect.height))
for i, item in enumerate(self._items):
y = int(item.rect.y + scroll_offset.y)
y = int(item.rect.y + scroll_offset.y)
if y + item.rect.height <= rect.y or y >= rect.y + rect.height:
continue
@ -245,7 +245,7 @@ class ListView(Widget):
item_height = item.get_item_height(self._font, content_width)
item.rect = rl.Rectangle(container_rect.x, container_rect.y + current_y, container_rect.width, item_height)
current_y += item_height
return current_y # total height of all items
return current_y # total height of all items
def _handle_mouse_interaction(self, rect: rl.Rectangle, scroll_offset: rl.Vector2):
mouse_pos = rl.get_mouse_position()
@ -293,16 +293,19 @@ class ListView(Widget):
def simple_item(title: str, callback: Callable | None = None) -> ListItem:
return ListItem(title=title, callback=callback)
def toggle_item(title: str, description: str | Callable[[], str] | None = None, initial_state: bool = False,
callback: Callable | None = None, icon: str = "", enabled: bool | Callable[[], bool] = True) -> ListItem:
action = ToggleAction(initial_state=initial_state, enabled=enabled)
return ListItem(title=title, description=description, action_item=action, icon=icon, callback=callback)
def button_item(title: str, button_text: str | Callable[[], str], description: str | Callable[[], str] | None = None,
callback: Callable | None = None, enabled: bool | Callable[[], bool] = True) -> ListItem:
action = ButtonAction(text=button_text, enabled=enabled)
return ListItem(title=title, description=description, action_item=action, callback=callback)
def text_item(title: str, value: str | Callable[[], str], description: str | Callable[[], str] | None = None,
callback: Callable | None = None, enabled: bool | Callable[[], bool] = True) -> ListItem:
action = TextAction(text=value, color=rl.Color(170, 170, 170, 255), enabled=enabled)

@ -3,7 +3,6 @@ from openpilot.system.ui.lib.application import gui_app, DialogResult, FontWeigh
from openpilot.system.ui.lib.button import gui_button, ButtonStyle
from openpilot.system.ui.lib.label import gui_text_box
DIALOG_WIDTH = 1520
DIALOG_HEIGHT = 600
BUTTON_HEIGHT = 160

@ -64,7 +64,7 @@ class MultiOptionDialog(Widget):
return 0
if gui_button(rl.Rectangle(content_rect.x + button_w + BUTTON_SPACING, button_y, button_w, BUTTON_HEIGHT),
"Select", is_enabled=self.selection != self.current, button_style=ButtonStyle.PRIMARY):
"Select", is_enabled=self.selection != self.current, button_style=ButtonStyle.PRIMARY):
return 1
return -1

Loading…
Cancel
Save