From d1b65dcb652cae87833cd8cbfaeb49a4da357ce1 Mon Sep 17 00:00:00 2001 From: Danny Date: Mon, 16 Nov 2026 05:42:22 -0800 Subject: [PATCH] Layout: Show a magnified view clear of your finger while dragging widgets on touch --- .../starpilot/galaxy/web/css/settings.css | 3 ++ .../galaxy/web/js/onroad-layout-template.js | 5 ++++ .../starpilot/galaxy/web/js/onroad-layout.js | 30 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/openpilot/starpilot/galaxy/web/css/settings.css b/openpilot/starpilot/galaxy/web/css/settings.css index a8511f2c5a..894f834c4b 100644 --- a/openpilot/starpilot/galaxy/web/css/settings.css +++ b/openpilot/starpilot/galaxy/web/css/settings.css @@ -608,6 +608,9 @@ input[type="range"].gx-slider:active::-moz-range-thumb { .gx-layout__layer.is-drop-target.is-drop-after::before { top: auto; bottom: -5px; } .gx-layout__drag-ghost { position: fixed; z-index: 1000; pointer-events: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 44px; box-sizing: border-box; border: 2px solid var(--primary); border-radius: 16px; background: var(--background); color: var(--on-surface); box-shadow: 0 12px 32px #0008; transform: scale(1.03); } .gx-layout__drag-ghost strong { flex: 1; } +.gx-layout__loupe { position: fixed; z-index: 1000; pointer-events: none; overflow: hidden; box-sizing: border-box; border: 2px solid var(--primary); border-radius: 16px; box-shadow: 0 12px 32px #0008; + background: repeating-linear-gradient(135deg, #090c10 0 6px, #131820 6px 12px); } +.gx-layout__loupe svg { display: block; width: 100%; height: 100%; } .gx-layout__outline { pointer-events: none; } .gx-layout__help > summary { cursor: pointer; min-height: 40px; align-content: center; } .gx-layout__layer.is-dragging { opacity: .45; } diff --git a/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js b/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js index 8c6d9e4e48..6a7dd1f9a2 100644 --- a/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js +++ b/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js @@ -73,6 +73,7 @@ export const ONROAD_LAYOUT_TEMPLATE = ` + + +
diff --git a/openpilot/starpilot/galaxy/web/js/onroad-layout.js b/openpilot/starpilot/galaxy/web/js/onroad-layout.js index 0703ab5df7..216768c37c 100644 --- a/openpilot/starpilot/galaxy/web/js/onroad-layout.js +++ b/openpilot/starpilot/galaxy/web/js/onroad-layout.js @@ -556,6 +556,34 @@ export const OnroadLayoutPage = { width: widget.width, height: widget.height + widget.visualInsetTop + widget.visualInsetBottom } }, + // On touch, a magnified copy of the area around the dragged widget sits clear of the finger. + loupe() { + const drag = this.state.drag + if (!drag?.touch || !drag.moved || drag.resize || (drag.fromTray && !drag.inside) || drag.clientX == null || !this.$refs.preview) return null + const rect = this.$refs.preview.getBoundingClientRect(), viewWidth = window.innerWidth, viewHeight = window.innerHeight + if (!rect.width) return null + const gap = 48, edge = 8, x = drag.clientX, y = drag.clientY + let width = Math.round(Math.max(150, Math.min(240, viewWidth / 2 - 8))), height = Math.round(width * .62) + let left = Math.max(edge, Math.min(viewWidth - width - edge, x - width / 2)), top = y - gap - height + if (top < edge) { + // No room above: sit beside the finger on the roomier side, narrower if needed, before falling back to below. + const right = x < viewWidth / 2, beside = Math.min(width, Math.floor((right ? viewWidth - x : x) - 24 - edge)) + if (beside >= 140) { + width = beside + height = Math.round(width * .62) + left = right ? x + 24 : x - 24 - width + top = Math.max(edge, Math.min(viewHeight - height - edge, y - height / 2)) + } else top = Math.min(viewHeight - height - edge, y + gap) + } + const [widgetWidth, widgetHeight] = widgetSize(this.profile.widgets[drag.id], this.layout[drag.id]) + const span = Math.max(width / (rect.width / this.profile.width * 2), widgetWidth * 1.5, widgetHeight * 1.5 * width / height) + const spanY = span * height / width + const centerX = this.previewX(drag.id) + widgetWidth / 2, centerY = this.layout[drag.id].y + widgetHeight / 2 + return { + viewBox: [centerX - span / 2, centerY - spanY / 2, span, spanY].map(value => Math.round(value * 10) / 10).join(" "), + style: { left: Math.round(left) + "px", top: Math.round(top) + "px", width: width + "px", height: height + "px" } + } + }, activeWidgets() { return this.widgets.filter(({ id }) => this.layout[id].enabled) }, renderWidgets() { return this.layerWidgets.filter(item => !this.previewHidden(item.id)).reverse().map((item) => { @@ -1242,6 +1270,8 @@ export const OnroadLayoutPage = { // A finger wobbles a few pixels on every tap; only a deliberate move drags the widget. if (!drag.moved && Math.hypot(event.clientX - drag.startX, event.clientY - drag.startY) < DRAG_SLOP) return drag.moved = true + drag.clientX = event.clientX + drag.clientY = event.clientY drag.inside = point.x >= 0 && point.y >= 0 && point.x <= this.profile.width && point.y <= this.profile.height if (!drag.fromTray || drag.inside) { const raw = { x: point.x - drag.offsetX, y: point.y - drag.offsetY }