mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
raylib: more closely match Qt alert sizes (#36283)
* hmm this doesn't work * clean up * more * bad fmtr * match sidebar net texts * better
This commit is contained in:
@@ -40,13 +40,13 @@ class Colors:
|
||||
|
||||
|
||||
NETWORK_TYPES = {
|
||||
NetworkType.none: "Offline",
|
||||
NetworkType.wifi: "WiFi",
|
||||
NetworkType.none: "--",
|
||||
NetworkType.wifi: "Wi-Fi",
|
||||
NetworkType.ethernet: "ETH",
|
||||
NetworkType.cell2G: "2G",
|
||||
NetworkType.cell3G: "3G",
|
||||
NetworkType.cell4G: "LTE",
|
||||
NetworkType.cell5G: "5G",
|
||||
NetworkType.ethernet: "Ethernet",
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ class Sidebar(Widget):
|
||||
|
||||
# Microphone button
|
||||
if self._recording_audio:
|
||||
self._mic_indicator_rect = rl.Rectangle(rect.x + rect.width - 138, rect.y + 245, 75, 40)
|
||||
self._mic_indicator_rect = rl.Rectangle(rect.x + rect.width - 130, rect.y + 245, 75, 40)
|
||||
|
||||
mic_pressed = mouse_down and rl.check_collision_point_rec(mouse_pos, self._mic_indicator_rect)
|
||||
bg_color = rl.Color(Colors.DANGER.r, Colors.DANGER.g, Colors.DANGER.b, int(255 * 0.65)) if mic_pressed else Colors.DANGER
|
||||
|
||||
@@ -21,6 +21,11 @@ ALERT_FONT_SMALL = 66
|
||||
ALERT_FONT_MEDIUM = 74
|
||||
ALERT_FONT_BIG = 88
|
||||
|
||||
ALERT_HEIGHTS = {
|
||||
AlertSize.small: 271,
|
||||
AlertSize.mid: 420,
|
||||
}
|
||||
|
||||
SELFDRIVE_STATE_TIMEOUT = 5 # Seconds
|
||||
SELFDRIVE_UNRESPONSIVE_TIMEOUT = 10 # Seconds
|
||||
|
||||
@@ -119,15 +124,9 @@ class AlertRenderer(Widget):
|
||||
if size == AlertSize.full:
|
||||
return rect
|
||||
|
||||
height = (ALERT_FONT_MEDIUM + 2 * ALERT_PADDING if size == AlertSize.small else
|
||||
ALERT_FONT_BIG + ALERT_LINE_SPACING + ALERT_FONT_SMALL + 2 * ALERT_PADDING)
|
||||
|
||||
return rl.Rectangle(
|
||||
rect.x + ALERT_MARGIN,
|
||||
rect.y + rect.height - ALERT_MARGIN - height,
|
||||
rect.width - 2 * ALERT_MARGIN,
|
||||
height
|
||||
)
|
||||
h = ALERT_HEIGHTS.get(size, rect.height)
|
||||
return rl.Rectangle(rect.x + ALERT_MARGIN, rect.y + rect.height - h + ALERT_MARGIN,
|
||||
rect.width - ALERT_MARGIN * 2, h - ALERT_MARGIN * 2)
|
||||
|
||||
def _draw_background(self, rect: rl.Rectangle, alert: Alert) -> None:
|
||||
color = ALERT_COLORS.get(alert.status, ALERT_COLORS[AlertStatus.normal])
|
||||
@@ -152,7 +151,7 @@ class AlertRenderer(Widget):
|
||||
font_size1 = 132 if is_long else 177
|
||||
align_ment = rl.GuiTextAlignment.TEXT_ALIGN_CENTER
|
||||
vertical_align = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE
|
||||
text_rect = rl.Rectangle(rect.x, rect.y, rect.width, rect.height // 2)
|
||||
text_rect = rl.Rectangle(rect.x, rect.y, rect.width, rect.height)
|
||||
|
||||
gui_text_box(text_rect, alert.text1, font_size1, alignment=align_ment, alignment_vertical=vertical_align, font_weight=FontWeight.BOLD)
|
||||
text_rect.y = rect.y + rect.height // 2
|
||||
|
||||
Reference in New Issue
Block a user