mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-03 20:53:41 +08:00
Add adjustable onroad border width
This commit is contained in:
@@ -67,6 +67,17 @@ for (const name of ["layoutDocument", "previewDocument", "withDisplay", "ordered
|
||||
assert.equal(layoutModule[name], documentHelpers[name], name)
|
||||
|
||||
const data = snapshot()
|
||||
for (const width of [50, 65, 100])
|
||||
assert.equal(validDocument({ ...data.document, borderWidth: width }, data.metadata), true)
|
||||
for (const width of [0, 49, 51, 102, null, "60"])
|
||||
assert.equal(validDocument({ ...data.document, borderWidth: width }, data.metadata), false)
|
||||
const borderEditor = { state: { draft: copy(data.document), notice: "" }, editable: true, projection: false,
|
||||
recordChange: (before, group) => assert.equal(group, "borderWidth") }
|
||||
OnroadLayoutPage.methods.setBorderWidth.call(borderEditor, 55)
|
||||
assert.equal(previewDocument(borderEditor.state.draft).borderWidth, 55)
|
||||
OnroadLayoutPage.methods.setBorderWidth.call(borderEditor, 100)
|
||||
assert.deepEqual(borderEditor.state.draft, data.document)
|
||||
assert.ok(ONROAD_LAYOUT_TEMPLATE.includes('aria-label="Edit Screen Border"'))
|
||||
const restoredCompact = copy(data)
|
||||
for (const [id, width, height, x, y] of [["max_speed", 162, 162, 0, 0], ["speed_limit", 118, 132, 330, 20]]) {
|
||||
Object.assign(restoredCompact.metadata.profiles.compact.widgets[id], { width, height, default: {x, y, enabled:true} })
|
||||
|
||||
@@ -308,6 +308,24 @@ class TestOnroadLayoutHttp(unittest.TestCase):
|
||||
self.assertEqual(self.request('/api/ui/layout', {'revision': saved['revision'], 'document': saved['document']}, cookie)[0], 409)
|
||||
self.assertEqual(self.params.get(PARAM_KEY), default_document())
|
||||
|
||||
def test_border_width_persists_without_moving_widgets(self):
|
||||
cookie = self.login()
|
||||
_, snapshot, _ = self.request('/api/ui/layout', cookie=cookie)
|
||||
request = {key: snapshot[key] for key in ('revision', 'document')}
|
||||
initial = copy.deepcopy(request["document"])
|
||||
request["document"]["borderWidth"] = 0
|
||||
self.assertEqual(self.request('/api/ui/layout', request, cookie)[0], 400)
|
||||
request["document"]["borderWidth"] = 60
|
||||
code, saved, _ = self.request('/api/ui/layout', request, cookie)
|
||||
self.assertEqual(saved["document"]["borderWidth"], 60)
|
||||
self.assertEqual(saved["document"]["layouts"], initial["layouts"])
|
||||
_, reread, _ = self.request('/api/ui/layout', cookie=cookie)
|
||||
self.assertEqual(reread["document"]["borderWidth"], 60)
|
||||
reset = {'revision': reread['revision'], 'document': {**reread['document'], 'borderWidth': 100}}
|
||||
reset_code, reset_saved, _ = self.request('/api/ui/layout', reset, cookie)
|
||||
self.assertEqual(reset_code, 200)
|
||||
self.assertEqual(reset_saved['document'], initial)
|
||||
|
||||
def test_mutation_requires_origin_session_and_unique_fields(self):
|
||||
cookie = self.login()
|
||||
_, snapshot, _ = self.request('/api/ui/layout', cookie=cookie)
|
||||
|
||||
@@ -145,11 +145,13 @@ export const PROJECTION_DISPLAY_SWITCHES = ["blindSpotBorder", "signalBorder", "
|
||||
export function validDocument(document, metadata) {
|
||||
if (!object(document)) return false
|
||||
const profiles = metadata?.projection === true ? ["large"] : PROFILES
|
||||
if (!keysEqual(document, ["version", "palette", "layouts", "widgetColors", "roadColors", ...(Object.hasOwn(document, "widgetOrder") ? ["widgetOrder"] : []), ...(Object.hasOwn(document, "speedSources") ? ["speedSources"] : []), ...(Object.hasOwn(document, "speedSourcesCard") ? ["speedSourcesCard"] : []), ...(Object.hasOwn(document, "speedAlign") ? ["speedAlign"] : []), ...(Object.hasOwn(document, "clock24Hour") ? ["clock24Hour"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "reduceMotion") ? ["reduceMotion"] : []), ...(Object.hasOwn(document, "showMaxSpeed") ? ["showMaxSpeed"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "speedDisplayOffset") ? ["speedDisplayOffset"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "display") ? ["display"] : []), ...(metadata?.projection === true && Object.hasOwn(document, "largeUiGammaTrial") ? ["largeUiGammaTrial"] : []), ...(metadata?.projection === true ? PROJECTION_DISPLAY_SWITCHES.filter(key => Object.hasOwn(document, key)) : []), ...(metadata?.projection === true && Object.hasOwn(document, "leadInfo") ? ["leadInfo"] : [])]) || (metadata?.projection === true ? document.version !== 8 : document.version !== 17) ||
|
||||
if (!keysEqual(document, ["version", "palette", "layouts", "widgetColors", "roadColors", ...(Object.hasOwn(document, "widgetOrder") ? ["widgetOrder"] : []), ...(Object.hasOwn(document, "speedSources") ? ["speedSources"] : []), ...(Object.hasOwn(document, "speedSourcesCard") ? ["speedSourcesCard"] : []), ...(Object.hasOwn(document, "speedAlign") ? ["speedAlign"] : []), ...(Object.hasOwn(document, "clock24Hour") ? ["clock24Hour"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "reduceMotion") ? ["reduceMotion"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "borderWidth") ? ["borderWidth"] : []), ...(Object.hasOwn(document, "showMaxSpeed") ? ["showMaxSpeed"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "speedDisplayOffset") ? ["speedDisplayOffset"] : []), ...(metadata?.projection !== true && Object.hasOwn(document, "display") ? ["display"] : []), ...(metadata?.projection === true && Object.hasOwn(document, "largeUiGammaTrial") ? ["largeUiGammaTrial"] : []), ...(metadata?.projection === true ? PROJECTION_DISPLAY_SWITCHES.filter(key => Object.hasOwn(document, key)) : []), ...(metadata?.projection === true && Object.hasOwn(document, "leadInfo") ? ["leadInfo"] : [])]) || (metadata?.projection === true ? document.version !== 8 : document.version !== 17) ||
|
||||
(Object.hasOwn(document, "speedSources") && typeof document.speedSources !== "boolean") ||
|
||||
(Object.hasOwn(document, "speedSourcesCard") && typeof document.speedSourcesCard !== "boolean") ||
|
||||
(Object.hasOwn(document, "speedAlign") && !SPEED_ALIGNMENTS.includes(document.speedAlign)) ||
|
||||
(Object.hasOwn(document, "clock24Hour") && typeof document.clock24Hour !== "boolean") ||
|
||||
(Object.hasOwn(document, "borderWidth") && (!Number.isInteger(document.borderWidth) || document.borderWidth < 50 ||
|
||||
document.borderWidth > 100 || document.borderWidth % 5 !== 0)) ||
|
||||
(Object.hasOwn(document, "reduceMotion") && typeof document.reduceMotion !== "boolean") ||
|
||||
(Object.hasOwn(document, "showMaxSpeed") && typeof document.showMaxSpeed !== "boolean") ||
|
||||
(Object.hasOwn(document, "speedDisplayOffset") && (!Number.isFinite(document.speedDisplayOffset) || document.speedDisplayOffset < -5 || document.speedDisplayOffset > 5)) ||
|
||||
|
||||
@@ -104,9 +104,17 @@ export const ONROAD_LAYOUT_TEMPLATE = `
|
||||
</g>
|
||||
</template>
|
||||
<rect v-if="!nativeBackdropReady" data-preview-source="scene-border"
|
||||
:x="state.profile === 'compact' ? 4 : profile.bounds.x" :y="state.profile === 'compact' ? 4 : profile.bounds.y"
|
||||
:width="state.profile === 'compact' ? 468 : roadBounds.width" :height="state.profile === 'compact' ? 232 : profile.bounds.height"
|
||||
:rx="state.profile === 'compact' ? 14 : 61" fill="none" :stroke="sceneBorder" :stroke-width="state.profile === 'compact' ? 8 : 30" />
|
||||
:x="projection ? profile.bounds.x : borderInset" :y="projection ? profile.bounds.y : borderInset"
|
||||
:width="state.profile === 'compact' ? 476 - borderStroke : roadBounds.width + (projection ? 0 : 60 - 2 * borderInset)"
|
||||
:height="projection ? profile.bounds.height : profile.height - 2 * borderInset"
|
||||
:rx="state.profile === 'compact' ? 14 : 61" fill="none" :stroke="sceneBorder" :stroke-width="borderStroke" />
|
||||
<rect v-if="!projection" class="gx-layout__widget" role="button" tabindex="0" style="cursor: pointer"
|
||||
:class="{'is-editing': state.inspectorPanel === 'border'}" aria-label="Edit Screen Border"
|
||||
:aria-pressed="state.inspectorPanel === 'border'" :x="borderInset" :y="borderInset"
|
||||
:width="state.profile === 'compact' ? 476 - borderStroke : roadBounds.width + 60 - 2 * borderInset"
|
||||
:height="profile.height - 2 * borderInset" :rx="state.profile === 'compact' ? 14 : 61"
|
||||
fill="none" stroke="transparent" :stroke-width="state.profile === 'compact' ? 16 : 48"
|
||||
@pointerdown.stop @click="openBorderEditor" @keydown.enter.prevent="openBorderEditor" @keydown.space.prevent="openBorderEditor" />
|
||||
<rect v-if="state.showEditingAids" :x="roadBounds.x" :y="roadBounds.y" :width="roadBounds.width" :height="roadBounds.height" fill="none" stroke="#8495a855" stroke-width="2" stroke-dasharray="8 8" />
|
||||
<g v-if="!projection && state.showFavoriteZones && state.showEditingAids" aria-hidden="true" pointer-events="none">
|
||||
<g v-if="state.profile === 'large'">
|
||||
@@ -198,6 +206,7 @@ export const ONROAD_LAYOUT_TEMPLATE = `
|
||||
<nav ref="sections" class="gx-layout__switcher gx-layout__sections gx-settings-tabs" :class="{'is-stuck': state.stuck.sections}" aria-label="Editor sections">
|
||||
<button class="gx-btn gx-btn--tonal" :aria-pressed="state.inspectorPanel === 'widgets'" :disabled="!!state.drag || !!state.layerDrag" @click="state.inspectorPanel = 'widgets'">Widgets</button>
|
||||
<button class="gx-btn gx-btn--tonal" :aria-pressed="['edit', 'lead'].includes(state.inspectorPanel)" :disabled="!!state.drag || !!state.layerDrag" @click="state.inspectorPanel === 'lead' ? revealEditPanel() : openEditPanel()"><span>Edit<span class="gx-layout__long"> widget</span></span></button>
|
||||
<button v-if="!projection" class="gx-btn gx-btn--tonal" :aria-pressed="state.inspectorPanel === 'border'" :disabled="!!state.drag || !!state.layerDrag" @click="openBorderEditor">Border</button>
|
||||
<button v-if="!projection" class="gx-btn gx-btn--tonal" :aria-pressed="state.inspectorPanel === 'road'" :disabled="!!state.drag || !!state.layerDrag" @click="state.inspectorPanel = 'road'"><span>Road<span class="gx-layout__long"> colors</span></span></button>
|
||||
<button v-if="projection || displayGroups.length" class="gx-btn gx-btn--tonal" :aria-pressed="state.inspectorPanel === 'display'" :disabled="!!state.drag || !!state.layerDrag" @click="state.inspectorPanel = 'display'">Options</button>
|
||||
</nav>
|
||||
@@ -384,6 +393,14 @@ export const ONROAD_LAYOUT_TEMPLATE = `
|
||||
<p v-if="!projection && !colorFields.length" class="gx-note">This widget uses its original status colors.</p>
|
||||
</div>
|
||||
</div>
|
||||
<section v-if="!projection && state.inspectorPanel === 'border'" ref="borderPanel" class="gx-layout__panel gx-layout__edit" aria-label="Edit Screen Border">
|
||||
<div class="gx-layout__subhead"><h4>Screen Border</h4></div>
|
||||
<label for="layout-border-width">Width · {{ borderWidth }}%</label>
|
||||
<input id="layout-border-width" class="gx-slider" type="range" min="50" max="100" step="5" :value="borderWidth"
|
||||
:disabled="!editAvailable || !!state.drag || !!state.layerDrag"
|
||||
@input="setBorderWidth($event.target.valueAsNumber)" @change="finishColorEdit" @blur="finishColorEdit">
|
||||
<p class="gx-note">Applies to both comma layouts. The border stays in place and keeps its status colors.</p>
|
||||
</section>
|
||||
<section v-if="!projection && state.inspectorPanel === 'lead'" ref="leadPanel" class="gx-layout__panel gx-layout__edit" aria-label="Edit Lead Indicator">
|
||||
<div class="gx-layout__subhead"><h4>Lead Indicator</h4></div>
|
||||
<GalaxySettingRow feedback="draft" v-for="(row, index) in leadRows" :key="row.key" :row="displaySettingRow(row)" :index="index"
|
||||
|
||||
@@ -539,14 +539,19 @@ export const OnroadLayoutPage = {
|
||||
publish: update => 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)
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "8c755579abb61f67aeb8571e8d1e017cdbf9f8bf8f1727f528a4e041001a4b79", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "cc4f511ec71ca7100e9c3f4831582d2ae306d7ea8cbedc654ce2fc259b9b37b5", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user