feat(ui): 将字体权重统一调整为 CHINA 以支持中文字体渲染
将多个 UI 组件中的字体权重从原有的 `MEDIUM`、`NORMAL`、`BOLD` 等值统一修改为 `CHINA`, 以确保界面文本能够正确使用中文字体进行显示。同时调整了部分字号和标签样式,提升中文环境下的展示效果。
This commit is contained in:
parent
2270c6d7f1
commit
6f2bd6efa3
@ -141,7 +141,7 @@ class HomeLayout(Widget):
|
|||||||
self._set_state(HomeLayoutState.ALERTS)
|
self._set_state(HomeLayoutState.ALERTS)
|
||||||
|
|
||||||
def _render_header(self):
|
def _render_header(self):
|
||||||
font = gui_app.font(FontWeight.MEDIUM)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
version_text_width = self.header_rect.width
|
version_text_width = self.header_rect.width
|
||||||
|
|
||||||
|
|||||||
@ -108,9 +108,9 @@ class TermsPage(Widget):
|
|||||||
self._on_accept = on_accept
|
self._on_accept = on_accept
|
||||||
self._on_decline = on_decline
|
self._on_decline = on_decline
|
||||||
|
|
||||||
self._title = Label(tr("Welcome to openpilot"), font_size=90, font_weight=FontWeight.BOLD, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
self._title = Label(tr("Welcome to openpilot"), font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
||||||
self._desc = Label(tr("You must accept the Terms and Conditions to use openpilot. Read the latest terms at https://comma.ai/terms before continuing."),
|
self._desc = Label(tr("You must accept the Terms and Conditions to use openpilot. Read the latest terms at https://comma.ai/terms before continuing."),
|
||||||
font_size=90, font_weight=FontWeight.MEDIUM, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
||||||
|
|
||||||
self._decline_btn = Button(tr("Decline"), click_callback=on_decline)
|
self._decline_btn = Button(tr("Decline"), click_callback=on_decline)
|
||||||
self._accept_btn = Button(tr("Agree"), button_style=ButtonStyle.PRIMARY, click_callback=on_accept)
|
self._accept_btn = Button(tr("Agree"), button_style=ButtonStyle.PRIMARY, click_callback=on_accept)
|
||||||
@ -143,7 +143,7 @@ class DeclinePage(Widget):
|
|||||||
def __init__(self, back_callback=None):
|
def __init__(self, back_callback=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._text = Label(tr("You must accept the Terms and Conditions in order to use openpilot."),
|
self._text = Label(tr("You must accept the Terms and Conditions in order to use openpilot."),
|
||||||
font_size=90, font_weight=FontWeight.MEDIUM, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT)
|
||||||
self._back_btn = Button(tr("Back"), click_callback=back_callback)
|
self._back_btn = Button(tr("Back"), click_callback=back_callback)
|
||||||
self._uninstall_btn = Button(tr("Decline, uninstall openpilot"), button_style=ButtonStyle.DANGER,
|
self._uninstall_btn = Button(tr("Decline, uninstall openpilot"), button_style=ButtonStyle.DANGER,
|
||||||
click_callback=self._on_uninstall_clicked)
|
click_callback=self._on_uninstall_clicked)
|
||||||
|
|||||||
@ -87,14 +87,14 @@ class FirehoseLayout(Widget):
|
|||||||
|
|
||||||
# Title (centered)
|
# Title (centered)
|
||||||
title_text = tr(TITLE) # live translate
|
title_text = tr(TITLE) # live translate
|
||||||
title_font = gui_app.font(FontWeight.MEDIUM)
|
title_font = gui_app.font(FontWeight.CHINA)
|
||||||
text_width = measure_text_cached(title_font, title_text, 100).x
|
text_width = measure_text_cached(title_font, title_text, 100).x
|
||||||
title_x = rect.x + (rect.width - text_width) / 2
|
title_x = rect.x + (rect.width - text_width) / 2
|
||||||
rl.draw_text_ex(title_font, title_text, rl.Vector2(title_x, y), 100, 0, rl.WHITE)
|
rl.draw_text_ex(title_font, title_text, rl.Vector2(title_x, y), 100, 0, rl.WHITE)
|
||||||
y += 200
|
y += 200
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
y = self._draw_wrapped_text(x, y, w, tr(DESCRIPTION), gui_app.font(FontWeight.NORMAL), 45, rl.WHITE)
|
y = self._draw_wrapped_text(x, y, w, tr(DESCRIPTION), gui_app.font(FontWeight.CHINA), 45, rl.WHITE)
|
||||||
y += 40 + 20
|
y += 40 + 20
|
||||||
|
|
||||||
# Separator
|
# Separator
|
||||||
@ -103,14 +103,14 @@ class FirehoseLayout(Widget):
|
|||||||
|
|
||||||
# Status
|
# Status
|
||||||
status_text, status_color = self._get_status()
|
status_text, status_color = self._get_status()
|
||||||
y = self._draw_wrapped_text(x, y, w, status_text, gui_app.font(FontWeight.BOLD), 60, status_color)
|
y = self._draw_wrapped_text(x, y, w, status_text, gui_app.font(FontWeight.CHINA), 60, status_color)
|
||||||
y += 20 + 20
|
y += 20 + 20
|
||||||
|
|
||||||
# Contribution count (if available)
|
# Contribution count (if available)
|
||||||
if self.segment_count > 0:
|
if self.segment_count > 0:
|
||||||
contrib_text = trn("{} segment of your driving is in the training dataset so far.",
|
contrib_text = trn("{} segment of your driving is in the training dataset so far.",
|
||||||
"{} segments of your driving is in the training dataset so far.", self.segment_count).format(self.segment_count)
|
"{} segments of your driving is in the training dataset so far.", self.segment_count).format(self.segment_count)
|
||||||
y = self._draw_wrapped_text(x, y, w, contrib_text, gui_app.font(FontWeight.BOLD), 52, rl.WHITE)
|
y = self._draw_wrapped_text(x, y, w, contrib_text, gui_app.font(FontWeight.CHINA), 52, rl.WHITE)
|
||||||
y += 20 + 20
|
y += 20 + 20
|
||||||
|
|
||||||
# Separator
|
# Separator
|
||||||
@ -118,7 +118,7 @@ class FirehoseLayout(Widget):
|
|||||||
y += 30 + 20
|
y += 30 + 20
|
||||||
|
|
||||||
# Instructions
|
# Instructions
|
||||||
y = self._draw_wrapped_text(x, y, w, tr(INSTRUCTIONS), gui_app.font(FontWeight.NORMAL), 40, self.LIGHT_GRAY)
|
y = self._draw_wrapped_text(x, y, w, tr(INSTRUCTIONS), gui_app.font(FontWeight.CHINA), 40, self.LIGHT_GRAY)
|
||||||
|
|
||||||
# bottom margin + remove effect of scroll offset
|
# bottom margin + remove effect of scroll offset
|
||||||
return int(round(y - self.scroll_panel.offset + 40))
|
return int(round(y - self.scroll_panel.offset + 40))
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class SettingsLayout(Widget):
|
|||||||
PanelType.DRAGONPILOT: PanelInfo(tr_noop("Dp"), DragonpilotLayout()),
|
PanelType.DRAGONPILOT: PanelInfo(tr_noop("Dp"), DragonpilotLayout()),
|
||||||
}
|
}
|
||||||
|
|
||||||
self._font_medium = gui_app.font(FontWeight.MEDIUM)
|
self._font_medium = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self._close_callback: Callable | None = None
|
self._close_callback: Callable | None = None
|
||||||
|
|||||||
@ -78,8 +78,8 @@ class Sidebar(Widget):
|
|||||||
self._settings_img = gui_app.texture("images/button_settings.png", SETTINGS_BTN.width, SETTINGS_BTN.height)
|
self._settings_img = gui_app.texture("images/button_settings.png", SETTINGS_BTN.width, SETTINGS_BTN.height)
|
||||||
self._mic_img = gui_app.texture("icons/microphone.png", 30, 30)
|
self._mic_img = gui_app.texture("icons/microphone.png", 30, 30)
|
||||||
self._mic_indicator_rect = rl.Rectangle(0, 0, 0, 0)
|
self._mic_indicator_rect = rl.Rectangle(0, 0, 0, 0)
|
||||||
self._font_regular = gui_app.font(FontWeight.NORMAL)
|
self._font_regular = gui_app.font(FontWeight.CHINA)
|
||||||
self._font_bold = gui_app.font(FontWeight.SEMI_BOLD)
|
self._font_bold = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self._on_settings_click: Callable | None = None
|
self._on_settings_click: Callable | None = None
|
||||||
|
|||||||
@ -72,11 +72,11 @@ ALERT_CRITICAL_REBOOT = Alert(
|
|||||||
class AlertRenderer(Widget):
|
class AlertRenderer(Widget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.font_regular: rl.Font = gui_app.font(FontWeight.NORMAL)
|
self.font_regular: rl.Font = gui_app.font(FontWeight.CHINA)
|
||||||
self.font_bold: rl.Font = gui_app.font(FontWeight.BOLD)
|
self.font_bold: rl.Font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
# font size is set dynamically
|
# font size is set dynamically
|
||||||
self._full_text1_label = Label("", font_size=0, font_weight=FontWeight.BOLD, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
self._full_text1_label = Label("", font_size=0, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP)
|
text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP)
|
||||||
self._full_text2_label = Label("", font_size=ALERT_FONT_BIG, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
self._full_text2_label = Label("", font_size=ALERT_FONT_BIG, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP)
|
text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP)
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class DriverCameraDialog(CameraView):
|
|||||||
rect,
|
rect,
|
||||||
tr("camera starting"),
|
tr("camera starting"),
|
||||||
font_size=100,
|
font_size=100,
|
||||||
font_weight=FontWeight.BOLD,
|
font_weight=FontWeight.CHINA,
|
||||||
alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
)
|
)
|
||||||
return -1
|
return -1
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class UIConfig:
|
|||||||
class FontSizes:
|
class FontSizes:
|
||||||
current_speed: int = 176
|
current_speed: int = 176
|
||||||
speed_unit: int = 66
|
speed_unit: int = 66
|
||||||
max_speed: int = 40
|
max_speed: int = 30
|
||||||
set_speed: int = 90
|
set_speed: int = 90
|
||||||
|
|
||||||
|
|
||||||
@ -66,9 +66,9 @@ class HudRenderer(Widget):
|
|||||||
self.speed: float = 0.0
|
self.speed: float = 0.0
|
||||||
self.v_ego_cluster_seen: bool = False
|
self.v_ego_cluster_seen: bool = False
|
||||||
|
|
||||||
self._font_semi_bold: rl.Font = gui_app.font(FontWeight.SEMI_BOLD)
|
self._font_semi_bold: rl.Font = gui_app.font(FontWeight.CHINA)
|
||||||
self._font_bold: rl.Font = gui_app.font(FontWeight.BOLD)
|
self._font_bold: rl.Font = gui_app.font(FontWeight.CHINA)
|
||||||
self._font_medium: rl.Font = gui_app.font(FontWeight.MEDIUM)
|
self._font_medium: rl.Font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
self._exp_button: ExpButton = ExpButton(UI_CONFIG.button_size, UI_CONFIG.wheel_icon_size)
|
self._exp_button: ExpButton = ExpButton(UI_CONFIG.button_size, UI_CONFIG.wheel_icon_size)
|
||||||
|
|
||||||
|
|||||||
@ -538,13 +538,13 @@ class ModelRenderer(Widget):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _dp_paint_centered_lead_text(self, text, size, x, y):
|
def _dp_paint_centered_lead_text(self, text, size, x, y):
|
||||||
font = gui_app.font(FontWeight.NORMAL)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
text_width = measure_text_cached(font, text, size).x
|
text_width = measure_text_cached(font, text, size).x
|
||||||
text_x = x - text_width / 2
|
text_x = x - text_width / 2
|
||||||
rl.draw_text_ex(font, text, rl.Vector2(text_x, y), size, 0, rl.WHITE)
|
rl.draw_text_ex(font, text, rl.Vector2(text_x, y), size, 0, rl.WHITE)
|
||||||
|
|
||||||
def _draw_live_tracks(self, sm):
|
def _draw_live_tracks(self, sm):
|
||||||
font = gui_app.font(FontWeight.NORMAL)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
live_tracks = sm['liveTracks']
|
live_tracks = sm['liveTracks']
|
||||||
font_size = 40
|
font_size = 40
|
||||||
line_height = 40
|
line_height = 40
|
||||||
|
|||||||
@ -51,7 +51,7 @@ class ExperimentalModeButton(Widget):
|
|||||||
text_x = rect.x + self.horizontal_padding
|
text_x = rect.x + self.horizontal_padding
|
||||||
text_y = rect.y + rect.height / 2 - 45 * FONT_SCALE // 2 # Center vertically
|
text_y = rect.y + rect.height / 2 - 45 * FONT_SCALE // 2 # Center vertically
|
||||||
|
|
||||||
rl.draw_text_ex(gui_app.font(FontWeight.NORMAL), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.BLACK)
|
rl.draw_text_ex(gui_app.font(FontWeight.CHINA), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.BLACK)
|
||||||
|
|
||||||
# Draw icon (right aligned)
|
# Draw icon (right aligned)
|
||||||
icon_x = rect.x + rect.width - self.horizontal_padding - self.img_width
|
icon_x = rect.x + rect.width - self.horizontal_padding - self.img_width
|
||||||
|
|||||||
@ -59,14 +59,14 @@ class ActionButton(Widget):
|
|||||||
self._text = text
|
self._text = text
|
||||||
self._style = style
|
self._style = style
|
||||||
self._min_width = min_width
|
self._min_width = min_width
|
||||||
self._font = gui_app.font(FontWeight.MEDIUM)
|
self._font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def text(self) -> str:
|
def text(self) -> str:
|
||||||
return self._text() if callable(self._text) else self._text
|
return self._text() if callable(self._text) else self._text
|
||||||
|
|
||||||
def _render(self, _):
|
def _render(self, _):
|
||||||
text_size = measure_text_cached(gui_app.font(FontWeight.MEDIUM), self.text, AlertConstants.FONT_SIZE)
|
text_size = measure_text_cached(gui_app.font(FontWeight.CHINA), self.text, AlertConstants.FONT_SIZE)
|
||||||
self._rect.width = max(text_size.x + 60 * 2, self._min_width)
|
self._rect.width = max(text_size.x + 60 * 2, self._min_width)
|
||||||
self._rect.height = AlertConstants.BUTTON_HEIGHT
|
self._rect.height = AlertConstants.BUTTON_HEIGHT
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ class OffroadAlert(AbstractAlert):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
total_height = 20
|
total_height = 20
|
||||||
font = gui_app.font(FontWeight.NORMAL)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
for alert_data in self.sorted_alerts:
|
for alert_data in self.sorted_alerts:
|
||||||
if not alert_data.visible:
|
if not alert_data.visible:
|
||||||
@ -268,7 +268,7 @@ class OffroadAlert(AbstractAlert):
|
|||||||
|
|
||||||
def _render_content(self, content_rect: rl.Rectangle):
|
def _render_content(self, content_rect: rl.Rectangle):
|
||||||
y_offset = AlertConstants.ALERT_SPACING
|
y_offset = AlertConstants.ALERT_SPACING
|
||||||
font = gui_app.font(FontWeight.NORMAL)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
for alert_data in self.sorted_alerts:
|
for alert_data in self.sorted_alerts:
|
||||||
if not alert_data.visible:
|
if not alert_data.visible:
|
||||||
@ -334,7 +334,7 @@ class UpdateAlert(AbstractAlert):
|
|||||||
|
|
||||||
if self._cached_content_height == 0:
|
if self._cached_content_height == 0:
|
||||||
self._wrapped_release_notes = self.release_notes
|
self._wrapped_release_notes = self.release_notes
|
||||||
size = measure_text_cached(gui_app.font(FontWeight.NORMAL), self._wrapped_release_notes, AlertConstants.FONT_SIZE)
|
size = measure_text_cached(gui_app.font(FontWeight.CHINA), self._wrapped_release_notes, AlertConstants.FONT_SIZE)
|
||||||
self._cached_content_height = max(size.y + 60, 100)
|
self._cached_content_height = max(size.y + 60, 100)
|
||||||
|
|
||||||
return self._cached_content_height
|
return self._cached_content_height
|
||||||
|
|||||||
@ -101,7 +101,7 @@ class PairingDialog(Widget):
|
|||||||
|
|
||||||
# Title
|
# Title
|
||||||
title = tr("Pair your device to your comma account")
|
title = tr("Pair your device to your comma account")
|
||||||
title_font = gui_app.font(FontWeight.NORMAL)
|
title_font = gui_app.font(FontWeight.CHINA)
|
||||||
left_width = int(content_rect.width * 0.5 - 15)
|
left_width = int(content_rect.width * 0.5 - 15)
|
||||||
|
|
||||||
title_wrapped = wrap_text(title_font, title, 75, left_width)
|
title_wrapped = wrap_text(title_font, title, 75, left_width)
|
||||||
@ -130,7 +130,7 @@ class PairingDialog(Widget):
|
|||||||
tr("Bookmark connect.comma.ai to your home screen to use it like an app"),
|
tr("Bookmark connect.comma.ai to your home screen to use it like an app"),
|
||||||
]
|
]
|
||||||
|
|
||||||
font = gui_app.font(FontWeight.BOLD)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
y = rect.y
|
y = rect.y
|
||||||
|
|
||||||
for i, text in enumerate(instructions):
|
for i, text in enumerate(instructions):
|
||||||
@ -156,7 +156,7 @@ class PairingDialog(Widget):
|
|||||||
def _render_qr_code(self, rect: rl.Rectangle) -> None:
|
def _render_qr_code(self, rect: rl.Rectangle) -> None:
|
||||||
if not self.qr_texture:
|
if not self.qr_texture:
|
||||||
rl.draw_rectangle_rounded(rect, 0.1, 20, rl.Color(240, 240, 240, 255))
|
rl.draw_rectangle_rounded(rect, 0.1, 20, rl.Color(240, 240, 240, 255))
|
||||||
error_font = gui_app.font(FontWeight.BOLD)
|
error_font = gui_app.font(FontWeight.CHINA)
|
||||||
rl.draw_text_ex(
|
rl.draw_text_ex(
|
||||||
error_font, tr("QR Code Error"), rl.Vector2(rect.x + 20, rect.y + rect.height // 2 - 15), 30, 0.0, rl.RED
|
error_font, tr("QR Code Error"), rl.Vector2(rect.x + 20, rect.y + rect.height // 2 - 15), 30, 0.0, rl.RED
|
||||||
)
|
)
|
||||||
|
|||||||
@ -30,18 +30,18 @@ class PrimeWidget(Widget):
|
|||||||
w = rect.width - 160
|
w = rect.width - 160
|
||||||
|
|
||||||
# Title
|
# Title
|
||||||
gui_label(rl.Rectangle(x, y, w, 90), tr("Upgrade Now"), 75, font_weight=FontWeight.BOLD)
|
gui_label(rl.Rectangle(x, y, w, 90), tr("Upgrade Now"), 75, font_weight=FontWeight.CHINA)
|
||||||
|
|
||||||
# Description with wrapping
|
# Description with wrapping
|
||||||
desc_y = y + 140
|
desc_y = y + 140
|
||||||
font = gui_app.font(FontWeight.LIGHT)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
wrapped_text = "\n".join(wrap_text(font, tr("Become a comma prime member at connect.comma.ai"), 56, int(w)))
|
wrapped_text = "\n".join(wrap_text(font, tr("Become a comma prime member at connect.comma.ai"), 56, int(w)))
|
||||||
text_size = measure_text_cached(font, wrapped_text, 56)
|
text_size = measure_text_cached(font, wrapped_text, 56)
|
||||||
rl.draw_text_ex(font, wrapped_text, rl.Vector2(x, desc_y), 56, 0, rl.WHITE)
|
rl.draw_text_ex(font, wrapped_text, rl.Vector2(x, desc_y), 56, 0, rl.WHITE)
|
||||||
|
|
||||||
# Features section
|
# Features section
|
||||||
features_y = desc_y + text_size.y + 50
|
features_y = desc_y + text_size.y + 50
|
||||||
gui_label(rl.Rectangle(x, features_y, w, 50), tr("PRIME FEATURES:"), 41, font_weight=FontWeight.BOLD)
|
gui_label(rl.Rectangle(x, features_y, w, 50), tr("PRIME FEATURES:"), 41, font_weight=FontWeight.CHINA)
|
||||||
|
|
||||||
# Feature list
|
# Feature list
|
||||||
features = [tr("Remote access"), tr("24/7 LTE connectivity"), tr("1 year of drive storage"), tr("Remote snapshots")]
|
features = [tr("Remote access"), tr("24/7 LTE connectivity"), tr("1 year of drive storage"), tr("Remote snapshots")]
|
||||||
@ -58,6 +58,6 @@ class PrimeWidget(Widget):
|
|||||||
x = rect.x + 56
|
x = rect.x + 56
|
||||||
y = rect.y + 40
|
y = rect.y + 40
|
||||||
|
|
||||||
font = gui_app.font(FontWeight.BOLD)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
rl.draw_text_ex(font, tr("✓ SUBSCRIBED"), rl.Vector2(x, y), 41, 0, rl.Color(134, 255, 78, 255))
|
rl.draw_text_ex(font, tr("✓ SUBSCRIBED"), rl.Vector2(x, y), 41, 0, rl.Color(134, 255, 78, 255))
|
||||||
rl.draw_text_ex(font, tr("comma prime"), rl.Vector2(x, y + 61), 75, 0, rl.WHITE)
|
rl.draw_text_ex(font, tr("comma prime"), rl.Vector2(x, y + 61), 75, 0, rl.WHITE)
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class SetupWidget(Widget):
|
|||||||
self._pair_device_btn = Button(lambda: tr("Pair device"), self._show_pairing, button_style=ButtonStyle.PRIMARY)
|
self._pair_device_btn = Button(lambda: tr("Pair device"), self._show_pairing, button_style=ButtonStyle.PRIMARY)
|
||||||
self._open_settings_btn = Button(lambda: tr("Open"), lambda: self._open_settings_callback() if self._open_settings_callback else None,
|
self._open_settings_btn = Button(lambda: tr("Open"), lambda: self._open_settings_callback() if self._open_settings_callback else None,
|
||||||
button_style=ButtonStyle.PRIMARY)
|
button_style=ButtonStyle.PRIMARY)
|
||||||
self._firehose_label = Label(lambda: tr("🔥 Firehose Mode 🔥"), font_weight=FontWeight.MEDIUM, font_size=64)
|
self._firehose_label = Label(lambda: tr("🔥 Firehose Mode 🔥"), font_weight=FontWeight.CHINA, font_size=64)
|
||||||
|
|
||||||
def set_open_settings_callback(self, callback):
|
def set_open_settings_callback(self, callback):
|
||||||
self._open_settings_callback = callback
|
self._open_settings_callback = callback
|
||||||
@ -40,13 +40,13 @@ class SetupWidget(Widget):
|
|||||||
w = rect.width - 128
|
w = rect.width - 128
|
||||||
|
|
||||||
# Title
|
# Title
|
||||||
font = gui_app.font(FontWeight.BOLD)
|
font = gui_app.font(FontWeight.CHINA)
|
||||||
rl.draw_text_ex(font, tr("Finish Setup"), rl.Vector2(x, y), 75, 0, rl.WHITE)
|
rl.draw_text_ex(font, tr("Finish Setup"), rl.Vector2(x, y), 75, 0, rl.WHITE)
|
||||||
y += 113 # 75 + 38 spacing
|
y += 113 # 75 + 38 spacing
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
desc = tr("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.")
|
desc = tr("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.")
|
||||||
light_font = gui_app.font(FontWeight.LIGHT)
|
light_font = gui_app.font(FontWeight.CHINA)
|
||||||
wrapped = wrap_text(light_font, desc, 50, int(w))
|
wrapped = wrap_text(light_font, desc, 50, int(w))
|
||||||
for line in wrapped:
|
for line in wrapped:
|
||||||
rl.draw_text_ex(light_font, line, rl.Vector2(x, y), 50, 0, rl.WHITE)
|
rl.draw_text_ex(light_font, line, rl.Vector2(x, y), 50, 0, rl.WHITE)
|
||||||
@ -71,7 +71,7 @@ class SetupWidget(Widget):
|
|||||||
y += 64 + spacing
|
y += 64 + spacing
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
desc_font = gui_app.font(FontWeight.NORMAL)
|
desc_font = gui_app.font(FontWeight.CHINA)
|
||||||
desc_text = tr("Maximize your training data uploads to improve openpilot's driving models.")
|
desc_text = tr("Maximize your training data uploads to improve openpilot's driving models.")
|
||||||
wrapped_desc = wrap_text(desc_font, desc_text, 40, int(w))
|
wrapped_desc = wrap_text(desc_font, desc_text, 40, int(w))
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,7 @@ class SshKeyAction(ItemAction):
|
|||||||
self._keyboard = Keyboard(min_text_size=1)
|
self._keyboard = Keyboard(min_text_size=1)
|
||||||
self._params = Params()
|
self._params = Params()
|
||||||
self._error_message: str = ""
|
self._error_message: str = ""
|
||||||
self._text_font = gui_app.font(FontWeight.NORMAL)
|
self._text_font = gui_app.font(FontWeight.CHINA)
|
||||||
self._button = Button("", click_callback=self._handle_button_click, button_style=ButtonStyle.LIST_ACTION,
|
self._button = Button("", click_callback=self._handle_button_click, button_style=ButtonStyle.LIST_ACTION,
|
||||||
border_radius=BUTTON_BORDER_RADIUS, font_size=BUTTON_FONT_SIZE)
|
border_radius=BUTTON_BORDER_RADIUS, font_size=BUTTON_FONT_SIZE)
|
||||||
|
|
||||||
|
|||||||
@ -351,7 +351,7 @@ class GuiApplication:
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def font(self, font_weight: FontWeight = FontWeight.NORMAL) -> rl.Font:
|
def font(self, font_weight: FontWeight = FontWeight.CHINA) -> rl.Font:
|
||||||
return self._fonts[font_weight]
|
return self._fonts[font_weight]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -393,7 +393,7 @@ class GuiApplication:
|
|||||||
self._fonts[font_weight_file] = font
|
self._fonts[font_weight_file] = font
|
||||||
|
|
||||||
rl.unload_codepoints(codepoints)
|
rl.unload_codepoints(codepoints)
|
||||||
rl.gui_set_font(self._fonts[FontWeight.NORMAL])
|
rl.gui_set_font(self._fonts[FontWeight.CHINA])
|
||||||
|
|
||||||
def _set_styles(self):
|
def _set_styles(self):
|
||||||
rl.gui_set_style(rl.GuiControl.DEFAULT, rl.GuiControlProperty.BORDER_WIDTH, 0)
|
rl.gui_set_style(rl.GuiControl.DEFAULT, rl.GuiControlProperty.BORDER_WIDTH, 0)
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class Reset(Widget):
|
|||||||
|
|
||||||
def _render(self, rect: rl.Rectangle):
|
def _render(self, rect: rl.Rectangle):
|
||||||
label_rect = rl.Rectangle(rect.x + 140, rect.y, rect.width - 280, 100 * FONT_SCALE)
|
label_rect = rl.Rectangle(rect.x + 140, rect.y, rect.width - 280, 100 * FONT_SCALE)
|
||||||
gui_label(label_rect, "System Reset", 100, font_weight=FontWeight.BOLD)
|
gui_label(label_rect, "System Reset", 100, font_weight=FontWeight.CHINA)
|
||||||
|
|
||||||
text_rect = rl.Rectangle(rect.x + 140, rect.y + 140, rect.width - 280, rect.height - 90 - 100 * FONT_SCALE)
|
text_rect = rl.Rectangle(rect.x + 140, rect.y + 140, rect.width - 280, rect.height - 90 - 100 * FONT_SCALE)
|
||||||
gui_text_box(text_rect, self._get_body_text(), 90)
|
gui_text_box(text_rect, self._get_body_text(), 90)
|
||||||
|
|||||||
@ -25,7 +25,7 @@ NetworkType = log.DeviceState.NetworkType
|
|||||||
|
|
||||||
MARGIN = 50
|
MARGIN = 50
|
||||||
TITLE_FONT_SIZE = 90
|
TITLE_FONT_SIZE = 90
|
||||||
TITLE_FONT_WEIGHT = FontWeight.MEDIUM
|
TITLE_FONT_WEIGHT = FontWeight.CHINA
|
||||||
NEXT_BUTTON_WIDTH = 310
|
NEXT_BUTTON_WIDTH = 310
|
||||||
BODY_FONT_SIZE = 80
|
BODY_FONT_SIZE = 80
|
||||||
BUTTON_HEIGHT = 160
|
BUTTON_HEIGHT = 160
|
||||||
@ -79,7 +79,7 @@ class Setup(Widget):
|
|||||||
self.warning = gui_app.texture("icons/warning.png", 150, 150)
|
self.warning = gui_app.texture("icons/warning.png", 150, 150)
|
||||||
self.checkmark = gui_app.texture("icons/circled_check.png", 100, 100)
|
self.checkmark = gui_app.texture("icons/circled_check.png", 100, 100)
|
||||||
|
|
||||||
self._low_voltage_title_label = Label("WARNING: Low Voltage", TITLE_FONT_SIZE, FontWeight.MEDIUM, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
self._low_voltage_title_label = Label("WARNING: Low Voltage", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
text_color=rl.Color(255, 89, 79, 255), text_padding=20)
|
text_color=rl.Color(255, 89, 79, 255), text_padding=20)
|
||||||
self._low_voltage_body_label = Label("Power your device in a car with a harness or proceed at your own risk.", BODY_FONT_SIZE,
|
self._low_voltage_body_label = Label("Power your device in a car with a harness or proceed at your own risk.", BODY_FONT_SIZE,
|
||||||
text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
@ -87,7 +87,7 @@ class Setup(Widget):
|
|||||||
self._low_voltage_poweroff_button = Button("Power Off", HARDWARE.shutdown)
|
self._low_voltage_poweroff_button = Button("Power Off", HARDWARE.shutdown)
|
||||||
|
|
||||||
self._getting_started_button = Button("", self._getting_started_button_callback, button_style=ButtonStyle.PRIMARY, border_radius=0)
|
self._getting_started_button = Button("", self._getting_started_button_callback, button_style=ButtonStyle.PRIMARY, border_radius=0)
|
||||||
self._getting_started_title_label = Label("Getting Started", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._getting_started_title_label = Label("Getting Started", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
self._getting_started_body_label = Label("Before we get on the road, let's finish installation and cover some details.",
|
self._getting_started_body_label = Label("Before we get on the road, let's finish installation and cover some details.",
|
||||||
BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
|
|
||||||
@ -97,26 +97,26 @@ class Setup(Widget):
|
|||||||
button_style=ButtonStyle.PRIMARY)
|
button_style=ButtonStyle.PRIMARY)
|
||||||
self._software_selection_continue_button.set_enabled(False)
|
self._software_selection_continue_button.set_enabled(False)
|
||||||
self._software_selection_back_button = Button("Back", self._software_selection_back_button_callback)
|
self._software_selection_back_button = Button("Back", self._software_selection_back_button_callback)
|
||||||
self._software_selection_title_label = Label("Choose Software to Use", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
self._software_selection_title_label = Label("Choose Software to Use", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
text_padding=20)
|
text_padding=20)
|
||||||
|
|
||||||
self._download_failed_reboot_button = Button("Reboot device", HARDWARE.reboot)
|
self._download_failed_reboot_button = Button("Reboot device", HARDWARE.reboot)
|
||||||
self._download_failed_startover_button = Button("Start over", self._download_failed_startover_button_callback, button_style=ButtonStyle.PRIMARY)
|
self._download_failed_startover_button = Button("Start over", self._download_failed_startover_button_callback, button_style=ButtonStyle.PRIMARY)
|
||||||
self._download_failed_title_label = Label("Download Failed", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._download_failed_title_label = Label("Download Failed", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
self._download_failed_url_label = Label("", 52, FontWeight.NORMAL, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._download_failed_url_label = Label("", 52, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
self._download_failed_body_label = Label("", BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._download_failed_body_label = Label("", BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
|
|
||||||
self._network_setup_back_button = Button("Back", self._network_setup_back_button_callback)
|
self._network_setup_back_button = Button("Back", self._network_setup_back_button_callback)
|
||||||
self._network_setup_continue_button = Button("Waiting for internet", self._network_setup_continue_button_callback,
|
self._network_setup_continue_button = Button("Waiting for internet", self._network_setup_continue_button_callback,
|
||||||
button_style=ButtonStyle.PRIMARY)
|
button_style=ButtonStyle.PRIMARY)
|
||||||
self._network_setup_continue_button.set_enabled(False)
|
self._network_setup_continue_button.set_enabled(False)
|
||||||
self._network_setup_title_label = Label("Connect to Wi-Fi", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._network_setup_title_label = Label("Connect to Wi-Fi", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
|
|
||||||
self._custom_software_warning_continue_button = Button("Scroll to continue", self._custom_software_warning_continue_button_callback,
|
self._custom_software_warning_continue_button = Button("Scroll to continue", self._custom_software_warning_continue_button_callback,
|
||||||
button_style=ButtonStyle.PRIMARY)
|
button_style=ButtonStyle.PRIMARY)
|
||||||
self._custom_software_warning_continue_button.set_enabled(False)
|
self._custom_software_warning_continue_button.set_enabled(False)
|
||||||
self._custom_software_warning_back_button = Button("Back", self._custom_software_warning_back_button_callback)
|
self._custom_software_warning_back_button = Button("Back", self._custom_software_warning_back_button_callback)
|
||||||
self._custom_software_warning_title_label = Label("WARNING: Custom Software", 81, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
self._custom_software_warning_title_label = Label("WARNING: Custom Software", 81, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
text_color=rl.Color(255, 89, 79, 255),
|
text_color=rl.Color(255, 89, 79, 255),
|
||||||
text_padding=60)
|
text_padding=60)
|
||||||
self._custom_software_warning_body_label = Label("Use caution when installing third-party software.\n\n"
|
self._custom_software_warning_body_label = Label("Use caution when installing third-party software.\n\n"
|
||||||
@ -128,7 +128,7 @@ class Setup(Widget):
|
|||||||
68, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=60)
|
68, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=60)
|
||||||
self._custom_software_warning_body_scroll_panel = GuiScrollPanel()
|
self._custom_software_warning_body_scroll_panel = GuiScrollPanel()
|
||||||
|
|
||||||
self._downloading_body_label = Label("Downloading...", TITLE_FONT_SIZE, FontWeight.MEDIUM, text_padding=20)
|
self._downloading_body_label = Label("Downloading...", TITLE_FONT_SIZE, FontWeight.CHINA, text_padding=20)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open("/sys/class/hwmon/hwmon1/in1_input") as f:
|
with open("/sys/class/hwmon/hwmon1/in1_input") as f:
|
||||||
|
|||||||
@ -90,7 +90,7 @@ class Updater(Widget):
|
|||||||
def render_prompt_screen(self, rect: rl.Rectangle):
|
def render_prompt_screen(self, rect: rl.Rectangle):
|
||||||
# Title
|
# Title
|
||||||
title_rect = rl.Rectangle(MARGIN + 50, 250, rect.width - MARGIN * 2 - 100, TITLE_FONT_SIZE * FONT_SCALE)
|
title_rect = rl.Rectangle(MARGIN + 50, 250, rect.width - MARGIN * 2 - 100, TITLE_FONT_SIZE * FONT_SCALE)
|
||||||
gui_label(title_rect, "Update Required", TITLE_FONT_SIZE, font_weight=FontWeight.BOLD)
|
gui_label(title_rect, "Update Required", TITLE_FONT_SIZE, font_weight=FontWeight.CHINA)
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
desc_text = ("An operating system update is required. Connect your device to Wi-Fi for the fastest update experience. " +
|
desc_text = ("An operating system update is required. Connect your device to Wi-Fi for the fastest update experience. " +
|
||||||
|
|||||||
@ -82,7 +82,7 @@ class Button(Widget):
|
|||||||
text: str | Callable[[], str],
|
text: str | Callable[[], str],
|
||||||
click_callback: Callable[[], None] | None = None,
|
click_callback: Callable[[], None] | None = None,
|
||||||
font_size: int = DEFAULT_BUTTON_FONT_SIZE,
|
font_size: int = DEFAULT_BUTTON_FONT_SIZE,
|
||||||
font_weight: FontWeight = FontWeight.MEDIUM,
|
font_weight: FontWeight = FontWeight.CHINA,
|
||||||
button_style: ButtonStyle = ButtonStyle.NORMAL,
|
button_style: ButtonStyle = ButtonStyle.NORMAL,
|
||||||
border_radius: int = 10,
|
border_radius: int = 10,
|
||||||
text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class ConfirmDialog(Widget):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
if cancel_text is None:
|
if cancel_text is None:
|
||||||
cancel_text = tr("Cancel")
|
cancel_text = tr("Cancel")
|
||||||
self._label = Label(text, 70, FontWeight.BOLD, text_color=rl.Color(201, 201, 201, 255))
|
self._label = Label(text, 70, FontWeight.CHINA, text_color=rl.Color(201, 201, 201, 255))
|
||||||
self._html_renderer = HtmlRenderer(text=text, text_size={ElementType.P: 50}, center_text=True)
|
self._html_renderer = HtmlRenderer(text=text, text_size={ElementType.P: 50}, center_text=True)
|
||||||
self._cancel_button = Button(cancel_text, self._cancel_button_callback)
|
self._cancel_button = Button(cancel_text, self._cancel_button_callback)
|
||||||
self._confirm_button = Button(confirm_text, self._confirm_button_callback, button_style=ButtonStyle.PRIMARY)
|
self._confirm_button = Button(confirm_text, self._confirm_button_callback, button_style=ButtonStyle.PRIMARY)
|
||||||
|
|||||||
@ -62,8 +62,8 @@ class HtmlRenderer(Widget):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self._text_color = text_color
|
self._text_color = text_color
|
||||||
self._center_text = center_text
|
self._center_text = center_text
|
||||||
self._normal_font = gui_app.font(FontWeight.NORMAL)
|
self._normal_font = gui_app.font(FontWeight.CHINA)
|
||||||
self._bold_font = gui_app.font(FontWeight.BOLD)
|
self._bold_font = gui_app.font(FontWeight.CHINA)
|
||||||
self._indent_level = 0
|
self._indent_level = 0
|
||||||
|
|
||||||
if text_size is None:
|
if text_size is None:
|
||||||
@ -77,16 +77,16 @@ class HtmlRenderer(Widget):
|
|||||||
|
|
||||||
# Untagged text defaults to <p>
|
# Untagged text defaults to <p>
|
||||||
self.styles: dict[ElementType, dict[str, Any]] = {
|
self.styles: dict[ElementType, dict[str, Any]] = {
|
||||||
ElementType.H1: {"size": round(base_p_size * 2), "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 16},
|
ElementType.H1: {"size": round(base_p_size * 2), "weight": FontWeight.CHINA, "margin_top": 20, "margin_bottom": 16},
|
||||||
ElementType.H2: {"size": round(base_p_size * 1.50), "weight": FontWeight.BOLD, "margin_top": 24, "margin_bottom": 12},
|
ElementType.H2: {"size": round(base_p_size * 1.50), "weight": FontWeight.CHINA, "margin_top": 24, "margin_bottom": 12},
|
||||||
ElementType.H3: {"size": round(base_p_size * 1.17), "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 10},
|
ElementType.H3: {"size": round(base_p_size * 1.17), "weight": FontWeight.CHINA, "margin_top": 20, "margin_bottom": 10},
|
||||||
ElementType.H4: {"size": round(base_p_size * 1.00), "weight": FontWeight.BOLD, "margin_top": 16, "margin_bottom": 8},
|
ElementType.H4: {"size": round(base_p_size * 1.00), "weight": FontWeight.CHINA, "margin_top": 16, "margin_bottom": 8},
|
||||||
ElementType.H5: {"size": round(base_p_size * 0.83), "weight": FontWeight.BOLD, "margin_top": 12, "margin_bottom": 6},
|
ElementType.H5: {"size": round(base_p_size * 0.83), "weight": FontWeight.CHINA, "margin_top": 12, "margin_bottom": 6},
|
||||||
ElementType.H6: {"size": round(base_p_size * 0.67), "weight": FontWeight.BOLD, "margin_top": 10, "margin_bottom": 4},
|
ElementType.H6: {"size": round(base_p_size * 0.67), "weight": FontWeight.CHINA, "margin_top": 10, "margin_bottom": 4},
|
||||||
ElementType.P: {"size": base_p_size, "weight": FontWeight.NORMAL, "margin_top": 8, "margin_bottom": 12},
|
ElementType.P: {"size": base_p_size, "weight": FontWeight.CHINA, "margin_top": 8, "margin_bottom": 12},
|
||||||
ElementType.B: {"size": base_p_size, "weight": FontWeight.BOLD, "margin_top": 8, "margin_bottom": 12},
|
ElementType.B: {"size": base_p_size, "weight": FontWeight.CHINA, "margin_top": 8, "margin_bottom": 12},
|
||||||
ElementType.LI: {"size": base_p_size, "weight": FontWeight.NORMAL, "color": rl.Color(40, 40, 40, 255), "margin_top": 6, "margin_bottom": 6},
|
ElementType.LI: {"size": base_p_size, "weight": FontWeight.CHINA, "color": rl.Color(40, 40, 40, 255), "margin_top": 6, "margin_bottom": 6},
|
||||||
ElementType.BR: {"size": 0, "weight": FontWeight.NORMAL, "margin_top": 0, "margin_bottom": 12},
|
ElementType.BR: {"size": 0, "weight": FontWeight.CHINA, "margin_top": 0, "margin_bottom": 12},
|
||||||
}
|
}
|
||||||
|
|
||||||
self.elements: list[HtmlElement] = []
|
self.elements: list[HtmlElement] = []
|
||||||
@ -250,7 +250,7 @@ class HtmlRenderer(Widget):
|
|||||||
return total_height
|
return total_height
|
||||||
|
|
||||||
def _get_font(self, weight: FontWeight):
|
def _get_font(self, weight: FontWeight):
|
||||||
if weight == FontWeight.BOLD:
|
if weight == FontWeight.CHINA:
|
||||||
return self._bold_font
|
return self._bold_font
|
||||||
return self._normal_font
|
return self._normal_font
|
||||||
|
|
||||||
|
|||||||
@ -63,8 +63,8 @@ class Keyboard(Widget):
|
|||||||
self._layout_name: Literal["lowercase", "uppercase", "numbers", "specials"] = "lowercase"
|
self._layout_name: Literal["lowercase", "uppercase", "numbers", "specials"] = "lowercase"
|
||||||
self._caps_lock = False
|
self._caps_lock = False
|
||||||
self._last_shift_press_time = 0
|
self._last_shift_press_time = 0
|
||||||
self._title = Label("", 90, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._title = Label("", 90, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
self._sub_title = Label("", 55, FontWeight.NORMAL, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
self._sub_title = Label("", 55, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20)
|
||||||
|
|
||||||
self._max_text_size = max_text_size
|
self._max_text_size = max_text_size
|
||||||
self._min_text_size = min_text_size
|
self._min_text_size = min_text_size
|
||||||
|
|||||||
@ -26,7 +26,7 @@ def gui_label(
|
|||||||
text: str,
|
text: str,
|
||||||
font_size: int = DEFAULT_TEXT_SIZE,
|
font_size: int = DEFAULT_TEXT_SIZE,
|
||||||
color: rl.Color = DEFAULT_TEXT_COLOR,
|
color: rl.Color = DEFAULT_TEXT_COLOR,
|
||||||
font_weight: FontWeight = FontWeight.NORMAL,
|
font_weight: FontWeight = FontWeight.CHINA,
|
||||||
alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
|
alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
|
||||||
elide_right: bool = True
|
elide_right: bool = True
|
||||||
@ -75,7 +75,7 @@ def gui_text_box(
|
|||||||
color: rl.Color = DEFAULT_TEXT_COLOR,
|
color: rl.Color = DEFAULT_TEXT_COLOR,
|
||||||
alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP,
|
alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP,
|
||||||
font_weight: FontWeight = FontWeight.NORMAL,
|
font_weight: FontWeight = FontWeight.CHINA,
|
||||||
):
|
):
|
||||||
styles = [
|
styles = [
|
||||||
(rl.GuiControl.DEFAULT, rl.GuiControlProperty.TEXT_COLOR_NORMAL, rl.color_to_int(color)),
|
(rl.GuiControl.DEFAULT, rl.GuiControlProperty.TEXT_COLOR_NORMAL, rl.color_to_int(color)),
|
||||||
@ -85,14 +85,14 @@ def gui_text_box(
|
|||||||
(rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_ALIGNMENT_VERTICAL, alignment_vertical),
|
(rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_ALIGNMENT_VERTICAL, alignment_vertical),
|
||||||
(rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_WRAP_MODE, rl.GuiTextWrapMode.TEXT_WRAP_WORD)
|
(rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_WRAP_MODE, rl.GuiTextWrapMode.TEXT_WRAP_WORD)
|
||||||
]
|
]
|
||||||
if font_weight != FontWeight.NORMAL:
|
if font_weight != FontWeight.CHINA:
|
||||||
rl.gui_set_font(gui_app.font(font_weight))
|
rl.gui_set_font(gui_app.font(font_weight))
|
||||||
|
|
||||||
with GuiStyleContext(styles):
|
with GuiStyleContext(styles):
|
||||||
rl.gui_label(rect, text)
|
rl.gui_label(rect, text)
|
||||||
|
|
||||||
if font_weight != FontWeight.NORMAL:
|
if font_weight != FontWeight.CHINA:
|
||||||
rl.gui_set_font(gui_app.font(FontWeight.NORMAL))
|
rl.gui_set_font(gui_app.font(FontWeight.CHINA))
|
||||||
|
|
||||||
|
|
||||||
# Non-interactive text area. Can render emojis and an optional specified icon.
|
# Non-interactive text area. Can render emojis and an optional specified icon.
|
||||||
@ -100,7 +100,7 @@ class Label(Widget):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
text: str | Callable[[], str],
|
text: str | Callable[[], str],
|
||||||
font_size: int = DEFAULT_TEXT_SIZE,
|
font_size: int = DEFAULT_TEXT_SIZE,
|
||||||
font_weight: FontWeight = FontWeight.NORMAL,
|
font_weight: FontWeight = FontWeight.CHINA,
|
||||||
text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
text_alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
|
text_alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE,
|
||||||
text_padding: int = 0,
|
text_padding: int = 0,
|
||||||
|
|||||||
@ -26,7 +26,7 @@ BUTTON_WIDTH = 250
|
|||||||
BUTTON_HEIGHT = 100
|
BUTTON_HEIGHT = 100
|
||||||
BUTTON_BORDER_RADIUS = 50
|
BUTTON_BORDER_RADIUS = 50
|
||||||
BUTTON_FONT_SIZE = 35
|
BUTTON_FONT_SIZE = 35
|
||||||
BUTTON_FONT_WEIGHT = FontWeight.MEDIUM
|
BUTTON_FONT_WEIGHT = FontWeight.CHINA
|
||||||
|
|
||||||
TEXT_PADDING = 20
|
TEXT_PADDING = 20
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class ButtonAction(ItemAction):
|
|||||||
self._text_source = text
|
self._text_source = text
|
||||||
self._value_source: str | Callable[[], str] | None = None
|
self._value_source: str | Callable[[], str] | None = None
|
||||||
self._pressed = False
|
self._pressed = False
|
||||||
self._font = gui_app.font(FontWeight.NORMAL)
|
self._font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
def pressed():
|
def pressed():
|
||||||
self._pressed = True
|
self._pressed = True
|
||||||
@ -136,7 +136,7 @@ class ButtonAction(ItemAction):
|
|||||||
if value_text:
|
if value_text:
|
||||||
value_rect = rl.Rectangle(rect.x, rect.y, rect.width - BUTTON_WIDTH - TEXT_PADDING, rect.height)
|
value_rect = rl.Rectangle(rect.x, rect.y, rect.width - BUTTON_WIDTH - TEXT_PADDING, rect.height)
|
||||||
gui_label(value_rect, value_text, font_size=ITEM_TEXT_FONT_SIZE, color=ITEM_TEXT_VALUE_COLOR,
|
gui_label(value_rect, value_text, font_size=ITEM_TEXT_FONT_SIZE, color=ITEM_TEXT_VALUE_COLOR,
|
||||||
font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT,
|
||||||
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
||||||
|
|
||||||
# TODO: just use the generic Widget click callbacks everywhere, no returning from render
|
# TODO: just use the generic Widget click callbacks everywhere, no returning from render
|
||||||
@ -150,7 +150,7 @@ class TextAction(ItemAction):
|
|||||||
self._text_source = text
|
self._text_source = text
|
||||||
self.color = color
|
self.color = color
|
||||||
|
|
||||||
self._font = gui_app.font(FontWeight.NORMAL)
|
self._font = gui_app.font(FontWeight.CHINA)
|
||||||
initial_text = _resolve_value(text, "")
|
initial_text = _resolve_value(text, "")
|
||||||
text_width = measure_text_cached(self._font, initial_text, ITEM_TEXT_FONT_SIZE).x
|
text_width = measure_text_cached(self._font, initial_text, ITEM_TEXT_FONT_SIZE).x
|
||||||
super().__init__(int(text_width + TEXT_PADDING), enabled)
|
super().__init__(int(text_width + TEXT_PADDING), enabled)
|
||||||
@ -165,7 +165,7 @@ class TextAction(ItemAction):
|
|||||||
|
|
||||||
def _render(self, rect: rl.Rectangle) -> bool:
|
def _render(self, rect: rl.Rectangle) -> bool:
|
||||||
gui_label(self._rect, self.text, font_size=ITEM_TEXT_FONT_SIZE, color=self.color,
|
gui_label(self._rect, self.text, font_size=ITEM_TEXT_FONT_SIZE, color=self.color,
|
||||||
font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_RIGHT,
|
font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_RIGHT,
|
||||||
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class MultipleButtonAction(ItemAction):
|
|||||||
self.button_width = button_width
|
self.button_width = button_width
|
||||||
self.selected_button = selected_index
|
self.selected_button = selected_index
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self._font = gui_app.font(FontWeight.MEDIUM)
|
self._font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
def set_selected_button(self, index: int):
|
def set_selected_button(self, index: int):
|
||||||
if 0 <= index < len(self.buttons):
|
if 0 <= index < len(self.buttons):
|
||||||
@ -287,7 +287,7 @@ class ListItem(Widget):
|
|||||||
self.action_item = action_item
|
self.action_item = action_item
|
||||||
|
|
||||||
self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT))
|
self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT))
|
||||||
self._font = gui_app.font(FontWeight.NORMAL)
|
self._font = gui_app.font(FontWeight.CHINA)
|
||||||
|
|
||||||
self._html_renderer = HtmlRenderer(text="", text_size={ElementType.P: ITEM_DESC_FONT_SIZE},
|
self._html_renderer = HtmlRenderer(text="", text_size={ElementType.P: ITEM_DESC_FONT_SIZE},
|
||||||
text_color=ITEM_DESC_TEXT_COLOR)
|
text_color=ITEM_DESC_TEXT_COLOR)
|
||||||
@ -539,7 +539,7 @@ class BaseSpinBoxAction(ItemAction, ABC):
|
|||||||
display_text = self._get_display_text()
|
display_text = self._get_display_text()
|
||||||
color = ITEM_TEXT_VALUE_COLOR if is_enabled else ITEM_DESC_TEXT_COLOR
|
color = ITEM_TEXT_VALUE_COLOR if is_enabled else ITEM_DESC_TEXT_COLOR
|
||||||
gui_label(label_rect, display_text, font_size=ITEM_TEXT_FONT_SIZE, color=color,
|
gui_label(label_rect, display_text, font_size=ITEM_TEXT_FONT_SIZE, color=color,
|
||||||
font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER,
|
||||||
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -17,7 +17,7 @@ LIST_ITEM_SPACING = 25
|
|||||||
|
|
||||||
|
|
||||||
class MultiOptionDialog(Widget):
|
class MultiOptionDialog(Widget):
|
||||||
def __init__(self, title, options, current="", option_font_weight=FontWeight.MEDIUM):
|
def __init__(self, title, options, current="", option_font_weight=FontWeight.CHINA):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.title = title
|
self.title = title
|
||||||
self.options = options
|
self.options = options
|
||||||
@ -48,7 +48,7 @@ class MultiOptionDialog(Widget):
|
|||||||
content_rect = rl.Rectangle(dialog_rect.x + MARGIN, dialog_rect.y + MARGIN,
|
content_rect = rl.Rectangle(dialog_rect.x + MARGIN, dialog_rect.y + MARGIN,
|
||||||
dialog_rect.width - 2 * MARGIN, dialog_rect.height - 2 * MARGIN)
|
dialog_rect.width - 2 * MARGIN, dialog_rect.height - 2 * MARGIN)
|
||||||
|
|
||||||
gui_label(rl.Rectangle(content_rect.x, content_rect.y, content_rect.width, TITLE_FONT_SIZE), self.title, 70, font_weight=FontWeight.BOLD)
|
gui_label(rl.Rectangle(content_rect.x, content_rect.y, content_rect.width, TITLE_FONT_SIZE), self.title, 70, font_weight=FontWeight.CHINA)
|
||||||
|
|
||||||
# Options area
|
# Options area
|
||||||
options_y = content_rect.y + TITLE_FONT_SIZE + ITEM_SPACING
|
options_y = content_rect.y + TITLE_FONT_SIZE + ITEM_SPACING
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user