@@ -198,6 +206,7 @@ export const ONROAD_LAYOUT_TEMPLATE = `
@@ -384,6 +393,14 @@ export const ONROAD_LAYOUT_TEMPLATE = `
This widget uses its original status colors.
+
Lead Indicator
Object.assign(state.backdrop, update) })
const artFeed = new LayoutPreviewFeed({ art: true, unauthorized: props.unauthorized, queue,
publish: update => Object.assign(state.art, update) })
- watch(() => [state.draft && JSON.stringify(state.draft), state.profile, state.scene, !!state.drag,
+ const widgetArtDraft = () => {
+ if (!state.draft || props.projection) return state.draft
+ const { borderWidth, ...document } = state.draft
+ return document
+ }
+ watch(() => [state.draft && JSON.stringify(widgetArtDraft()), state.profile, state.scene, !!state.drag,
!!state.layerDrag, state.data?.revision, state.data?.editable], () => {
if (props.mode !== "local" || !state.data?.editable || !state.draft) {
artFeed.stop()
return
}
if (!artFeed.active) artFeed.start()
- const document = props.projection ? projectionPayload({document: state.draft}, state.data.metadata).document : layoutDocument(state.draft)
+ const document = props.projection ? projectionPayload({document: state.draft}, state.data.metadata).document : layoutDocument(widgetArtDraft())
artFeed.update(document, props.projection ? "projection" : state.profile, state.scene, !!state.drag || !!state.layerDrag)
}, {flush: "sync"})
// The real screen behind the arrangement: status border, road, alerts and sidebar, without the movable widgets.
@@ -605,6 +610,9 @@ export const OnroadLayoutPage = {
["Speed limit", scene => scene.id.startsWith("slc_")]].map(([label, test]) => ({ label, scenes: this.availableScenes.filter(test) }))
},
sceneBorder() { return previewScene(this.state.scene).border },
+ borderWidth() { return this.projection ? 100 : this.state.draft?.borderWidth ?? 100 },
+ borderStroke() { return Math.round((this.state.profile === "compact" ? 8 : 30) * this.borderWidth / 100) },
+ borderInset() { return this.state.profile === "compact" ? this.borderStroke / 2 : this.borderStroke },
expandedRoad() { return !this.projection && this.state.profile === "large" && this.displayValue("DeveloperSidebar") !== "On" },
roadBounds() { return this.expandedRoad ? { ...this.profile.bounds, width: this.profile.bounds.width + 300 } : this.profile.bounds },
favoriteZones() {
@@ -905,13 +913,19 @@ export const OnroadLayoutPage = {
this.state.inspectorPanel = "lead"
this.revealEditPanel()
},
+ openBorderEditor() {
+ if (this.projection || this.state.drag || this.state.layerDrag) return
+ this.deselectWidget()
+ this.state.inspectorPanel = "border"
+ this.revealEditPanel()
+ },
// On narrow screens the edit controls always open with their top just under the pinned tabs.
revealEditPanel() {
if (typeof window === "undefined") return
const align = () => {
const section = this.state.inspectorPanel
- if (!["edit", "lead"].includes(section)) return
- const tabs = this.$refs.sections, panel = section === "lead" ? this.$refs.leadPanel : this.$refs.editPanel
+ if (!["edit", "lead", "border"].includes(section)) return
+ const tabs = this.$refs.sections, panel = this.$refs[section + "Panel"]
if (!tabs || !panel || getComputedStyle(tabs).position !== "sticky") return
const gap = panel.getBoundingClientRect().top - tabs.getBoundingClientRect().bottom - 8
if (Math.abs(gap) >= 1) window.scrollBy(0, gap)
@@ -1243,6 +1257,16 @@ export const OnroadLayoutPage = {
this.state.notice = ""
showDraftChange()
},
+ setBorderWidth(value) {
+ if (!this.editable || this.projection || this.state.drag || this.state.layerDrag ||
+ !Number.isInteger(value) || value < 50 || value > 100 || value % 5) return
+ const before = clone(this.state.draft)
+ if (value === 100) delete this.state.draft.borderWidth
+ else this.state.draft.borderWidth = value
+ this.recordChange(before, "borderWidth")
+ this.state.notice = ""
+ showDraftChange()
+ },
setReduceMotion(value) {
if (this.state.profile !== 'large' || !this.editable || this.projection || this.state.drag || this.state.layerDrag || typeof value !== 'boolean') return
const before = clone(this.state.draft)
diff --git a/openpilot/starpilot/ui/onroad.py b/openpilot/starpilot/ui/onroad.py
index 6cb0e25825..8882df68e9 100644
--- a/openpilot/starpilot/ui/onroad.py
+++ b/openpilot/starpilot/ui/onroad.py
@@ -23,7 +23,7 @@ from openpilot.starpilot.ui.onroad_customization import (CLOCK_WIDGET, MODE_WIDG
from openpilot.starpilot.ui.appearance_preferences import CameraViewChoice
from openpilot.starpilot.ui.onroad_alerts import AlertRenderer
-from openpilot.starpilot.ui.onroad_border import render_compact_half_borders, render_large_half_borders
+from openpilot.starpilot.ui.onroad_border import compact_border, render_compact_half_borders, render_large_half_borders
from openpilot.starpilot.ui.onroad_compact_widgets import CompactHudRenderer, MiciSidebarWidgets, compact_wheel_warning
from openpilot.starpilot.ui.onroad_personality import PersonalityWidget
from openpilot.starpilot.ui.onroad_curve import GlowPhase, controlling as curve_controlling, glow_color, intensity, render_glow, status_label
@@ -388,16 +388,18 @@ class OnroadView:
right_shift = width - 1860
frame = rl.Rectangle(0, 0, width, height)
content = rl.Rectangle(30, 30, width - 60, height - 60)
+ stroke = 30 if self.projection_viewport else (30 * state.customization.get("borderWidth", 100) + 50) // 100
+ road = content if stroke == 30 else rl.Rectangle(stroke, stroke, width - 2 * stroke, height - 2 * stroke)
# Current CameraView's no-frame placeholder stays at the disengaged blue.
color = rl.Color(18, 40, 57, 255)
edge = axis_status_color(state)
- rl.draw_rectangle_rec(content, color)
- clip.begin_scissor_mode(30, 30, int(content.width), int(content.height))
+ rl.draw_rectangle_rec(road, color)
+ clip.begin_scissor_mode(stroke, stroke, int(road.width), int(road.height))
try:
if self.camera_layer is not None and state.camera_available:
- self.camera_layer(content, state)
+ self.camera_layer(road, state)
elif self.background_layer is not None:
- self.background_layer(content, state)
+ self.background_layer(road, state)
draw_top_scrim(content)
ordered = bool(state.customization.get("widgetOrder", {}).get("large"))
if ordered:
@@ -479,11 +481,11 @@ class OnroadView:
self.fonts.draw(label, FontRole.SEMI_BOLD, 29, 1390 + right_shift, 56,
curve_color)
self._traffic_badge(state, 56 + 45 * int(label is not None))
- render_glow(content, state, border_width=30, time_s=state.observed_ns / 1e9 if state.observed_ns else rl.get_time(),
+ render_glow(road, state, border_width=stroke, time_s=state.observed_ns / 1e9 if state.observed_ns else rl.get_time(),
phase=getattr(self, "_curve_glow_phase", None))
- rl.draw_rectangle_lines_ex(frame, 30, rl.BLACK)
- rl.draw_rectangle_rounded_lines_ex(content, 0.12, 10, 30, edge)
- render_large_half_borders(state, state.observed_ns / 1e9 if state.observed_ns else rl.get_time(), content, int(height))
+ rl.draw_rectangle_lines_ex(frame, stroke, rl.BLACK)
+ rl.draw_rectangle_rounded_lines_ex(road, 0.12, 10, stroke, edge)
+ render_large_half_borders(state, state.observed_ns / 1e9 if state.observed_ns else rl.get_time(), road, int(height), stroke)
self._preview_badge(state)
def _compact(self, state: OnroadState) -> None:
@@ -569,7 +571,8 @@ class OnroadView:
self.compact_sidebar.render(rail, state)
clip.begin_scissor_mode(0, 0, 476, 240)
try:
- rl.draw_rectangle_rounded_lines_ex(rl.Rectangle(4, 4, 468, 232), 0.12, 16, 8, color)
+ border, stroke = compact_border(state.customization)
+ rl.draw_rectangle_rounded_lines_ex(border, 0.12, 16, stroke, color)
finally:
clip.end_scissor_mode()
render_compact_half_borders(state, state.observed_ns / 1e9 if state.observed_ns else rl.get_time())
diff --git a/openpilot/starpilot/ui/onroad_border.py b/openpilot/starpilot/ui/onroad_border.py
index 82e447e673..57526de2a1 100644
--- a/openpilot/starpilot/ui/onroad_border.py
+++ b/openpilot/starpilot/ui/onroad_border.py
@@ -35,20 +35,26 @@ def half_colors(state: OnroadState, time_s: float) -> tuple[rl.Color | None, rl.
return color(signals.left_blindspot, signals.left_blinker), color(signals.right_blindspot, signals.right_blinker)
+def compact_border(document) -> tuple[rl.Rectangle, int]:
+ width = round(8 * document.get("borderWidth", 100) / 100)
+ inset = width / 2
+ return rl.Rectangle(inset, inset, 476 - width, 240 - width), width
+
+
def render_compact_half_borders(state: OnroadState, time_s: float) -> None:
left, right = half_colors(state, time_s)
- border = rl.Rectangle(4, 4, 468, 232)
+ border, stroke = compact_border(state.customization)
for x, width, color in ((0, 238, left), (238, 238, right)):
if color is None:
continue
clip.begin_scissor_mode(x, 0, width, 240)
try:
- rl.draw_rectangle_rounded_lines_ex(border, 0.12, 16, 8, color)
+ rl.draw_rectangle_rounded_lines_ex(border, 0.12, 16, stroke, color)
finally:
clip.end_scissor_mode()
-def render_large_half_borders(state: OnroadState, time_s: float, content: rl.Rectangle, frame_height: int) -> None:
+def render_large_half_borders(state: OnroadState, time_s: float, content: rl.Rectangle, frame_height: int, stroke: int = 30) -> None:
"""Android Auto: tint each half of the large status edge, matching the C4 half borders."""
left, right = half_colors(state, time_s)
middle = int(content.x + content.width / 2)
@@ -57,7 +63,7 @@ def render_large_half_borders(state: OnroadState, time_s: float, content: rl.Rec
continue
clip.begin_scissor_mode(x, 0, width, frame_height)
try:
- rl.draw_rectangle_rounded_lines_ex(content, 0.12, 10, 30, color)
+ rl.draw_rectangle_rounded_lines_ex(content, 0.12, 10, stroke, color)
finally:
clip.end_scissor_mode()
diff --git a/openpilot/starpilot/ui/onroad_customization.py b/openpilot/starpilot/ui/onroad_customization.py
index 15c3fe9cd4..8740d0cbc5 100644
--- a/openpilot/starpilot/ui/onroad_customization.py
+++ b/openpilot/starpilot/ui/onroad_customization.py
@@ -565,6 +565,11 @@ def validate_document(value):
fields.add('clock24Hour')
if type(value['clock24Hour']) is not bool:
raise ValueError('Invalid clock format preference')
+ if 'borderWidth' in value:
+ fields.add('borderWidth')
+ width = value['borderWidth']
+ if type(width) is not int or not 50 <= width <= 100 or width % 5:
+ raise ValueError('Invalid border width')
if 'reduceMotion' in value:
fields.add('reduceMotion')
if type(value['reduceMotion']) is not bool:
@@ -799,6 +804,8 @@ def validate_document(value):
if 'speedAlign' in value:
result['speedAlign'] = value['speedAlign']
result['reduceMotion'] = value.get('reduceMotion', False)
+ if value.get('borderWidth', 100) != 100:
+ result['borderWidth'] = value['borderWidth']
if 'clock24Hour' in value:
result['clock24Hour'] = value['clock24Hour']
if 'showMaxSpeed' in value:
diff --git a/openpilot/starpilot/ui/tests/test_onroad_axes.py b/openpilot/starpilot/ui/tests/test_onroad_axes.py
index 544bb3a255..efde140379 100644
--- a/openpilot/starpilot/ui/tests/test_onroad_axes.py
+++ b/openpilot/starpilot/ui/tests/test_onroad_axes.py
@@ -515,6 +515,10 @@ class TestOnroadAxes(unittest.TestCase):
patch.object(onroad, "render_corner_hint"), \
patch.object(view, "_slc_actions"):
view.render(state)
+ stock_width = 30 if profile == Profile.LARGE else 8
+ self.assertEqual(border.call_args.args[-2], stock_width)
+ view.render(replace(state, customization={**state.customization, "borderWidth": 50}))
+ self.assertEqual(border.call_args.args[-2], stock_width // 2)
expected = compact_color if profile == Profile.COMPACT else rgba(axis_status_color(state))
self.assertEqual(rgba(border.call_args.args[-1]), expected)
if alert.size == AlertSize.NONE:
diff --git a/prebuilt.json b/prebuilt.json
index dab52fa6d9..12d75d915f 100644
--- a/prebuilt.json
+++ b/prebuilt.json
@@ -1 +1 @@
-{"protected_inventory_sha256": "8c755579abb61f67aeb8571e8d1e017cdbf9f8bf8f1727f528a4e041001a4b79", "schema_version": 1}
+{"protected_inventory_sha256": "cc4f511ec71ca7100e9c3f4831582d2ae306d7ea8cbedc654ce2fc259b9b37b5", "schema_version": 1}