-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
base: master
Are you sure you want to change the base?
refactor(raylib): Fix and standardize rounded corners #35729
Conversation
@@ -43,7 +45,7 @@ class PanelType(IntEnum): | |||
@dataclass | |||
class PanelInfo: | |||
name: str | |||
instance: object | |||
instance: Widget |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
Implement a
get_roundness
function that takes a rect and aborder_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):
Home panels and metrics (after):
Set speed (before):
Set speed (after):
The ones below don't have much or any difference:
Settings panel (before):
Settings panel (after):
Network panel (before):
Network panel (after):
Alert (before):
Alert (after):