Skip to content

refactor(raylib): Fix and standardize rounded corners #35729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

TheSecurityDev
Copy link
Contributor

@TheSecurityDev TheSecurityDev commented Jul 14, 2025

Implement a get_roundness function that takes a rect and a border_radius (pixels) amount and returns the roundness value for raylib.

This allows us to use the same border radius for different-sized panels without having to guess the roundness value. This mainly fixes the inconsistent panel roundness on the home page. I also increased the metrics rounding to match the old UI.

TODO: The experimental mode button also needs rounded, but I will do that in a separate PR once this is merged.

Home panels and metrics (before):

rounded-corners-raylib-old

Home panels and metrics (after):

rounded-corners-raylib-new

Set speed (before):

set-speed-raylib-old

Set speed (after):

set-speed-raylib-new

The ones below don't have much or any difference:

Settings panel (before):

settings-panel-raylib-old

Settings panel (after):

settings-panel-raylib-new

Network panel (before):

setup-network-raylib-old

Network panel (after):

setup-network-raylib-new

Alert (before):

alert-rounded-raylib-old

Alert (after):

alert-rounded-raylib-new

@github-actions github-actions bot added the ui label Jul 14, 2025
@@ -43,7 +45,7 @@ class PanelType(IntEnum):
@dataclass
class PanelInfo:
name: str
instance: object
instance: Widget
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did this to fix a type issue in my IDE

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg if this is true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the Pylance VSCode extension, if you're wondering. It shows quite a few type issues on a lot of the files, but I can't fix them all.

from openpilot.system.ui.lib.text_measure import measure_text_cached
from openpilot.system.ui.widgets import Widget

SIDEBAR_WIDTH = 300
METRIC_HEIGHT = 126
METRIC_WIDTH = 240
METRIC_MARGIN = 30
METRIC_BORDER_RADIUS = 20
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Increases the metrics border radius to match the current UI

@@ -143,7 +144,7 @@ def _render_instructions(self, rect: rl.Rectangle) -> None:

def _render_qr_code(self, rect: rl.Rectangle) -> None:
if not self.qr_texture:
rl.draw_rectangle_rounded(rect, 0.1, 20, rl.Color(240, 240, 240, 255))
rl.draw_rectangle_rounded(rect, get_roundness(rect, 30), 20, rl.Color(240, 240, 240, 255))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rounded corners are actually only visible when there's no QR code, which doesn't seem very useful

from openpilot.system.ui.lib.scroll_panel import GuiScrollPanel
from openpilot.system.ui.widgets import Widget
from openpilot.system.ui.widgets.button import gui_button, ButtonStyle, TextAlignment
from openpilot.system.ui.widgets.label import gui_label

# Constants
MARGIN = 50
PANEL_COLOR = rl.Color(30, 30, 30, 255)
PANEL_BORDER_RADIUS = 10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really should just make a Panel widget to avoid this stuff being done in different components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants