From fe24b620bf1a254c562c278441dac624cc9cec9d Mon Sep 17 00:00:00 2001 From: Givou Date: Mon, 2 Nov 2026 17:51:57 +0100 Subject: [PATCH] Dashboard curve: Overlay as its own entry next to the single channels Co-Authored-By: Claude Opus 5.5 --- static/app.js | 5 +++-- static/dashboard.js | 35 +++++++++++++++++++++++------------ static/i18n.js | 2 +- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/static/app.js b/static/app.js index d7cd792..ade3542 100644 --- a/static/app.js +++ b/static/app.js @@ -1164,7 +1164,7 @@ const hasQ = type => [0, 4, 6, 7, 8].includes(type); const OUT_COLORS = ["#f97316", "#facc15", "#4ade80", "#e879f9", "#60a5fa", "#fb7185", "#2dd4bf", "#c084fc"]; const chColor = (d, kind, i) => custColor(d, kind, i) || (kind === "in" ? IN_COLORS[i] : OUT_COLORS[i]); -// opts: { mode: "mag" | "phase", overlays: [{ ch, color }] } +// opts: { mode: "mag" | "phase", overlays: [{ ch, color }], overlaysOnly: no curve or bands of `ch` itself } function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOpts() : {}) { const dpr = window.devicePixelRatio || 1, W = canvas.clientWidth, H = canvas.clientHeight; if (!W || !H) return null; @@ -1211,7 +1211,8 @@ function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOp g.strokeStyle = color; g.lineWidth = width; g.lineJoin = "round"; for (const sg of segs) { g.beginPath(); sg.forEach(([x, y], i) => i ? g.lineTo(x, y) : g.moveTo(x, y)); g.stroke(); } }; - for (const o of opts.overlays || []) stroke(trace(f => channelH(o.ch, f)), o.color + "cc", 1.5); + for (const o of opts.overlays || []) stroke(trace(f => channelH(o.ch, f)), o.color + "cc", opts.overlaysOnly ? 2 : 1.5); + if (opts.overlaysOnly) return { fx, dy, W, H, phase }; // dashboard: only the compared channels const sb = ch.peq[selBand]; if (!phase && sb && !sb.bypass && !ch.peq_bypass) { // selected band's own contribution, filled g.beginPath(); g.moveTo(0, dy(0)); diff --git a/static/dashboard.js b/static/dashboard.js index 8329f5a..6fb4c04 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -41,17 +41,23 @@ const dashChannels = d => [...chans(d, "in").map((_, i) => ["in", i]), ...chans( function dashSel(m, d) { const all = dashChannels(d); let s = dashBrowse.get(m.id); - if (!s) { s = { kind: m.cfg.kind || "in", idx: m.cfg.idx || 0, band: 0 }; dashBrowse.set(m.id, s); } + if (!s) { s = { kind: m.cfg.kind || "in", idx: m.cfg.idx || 0, band: 0, overlay: !!(m.cfg.overlays || []).length }; dashBrowse.set(m.id, s); } if (!all.some(([k, i]) => k === s.kind && i === s.idx)) { s.kind = all[0][0]; s.idx = all[0][1]; } return s; } -function dashChannelNav(m, d, s) { - const all = dashChannels(d), at = all.findIndex(([k, i]) => k === s.kind && i === s.idx); - const go = dir => { const [k, i] = all[(at + dir + all.length) % all.length]; s.kind = k; s.idx = i; s.band = 0; render(); }; - const ch = chans(d, s.kind)[s.idx]; +// arrows through the channels; the frequency response module has "Overlay" as one more entry, in front +function dashChannelNav(m, d, s, overlay = false) { + const all = [...(overlay ? [["overlay", 0]] : []), ...dashChannels(d)]; + const at = all.findIndex(([k, i]) => (s.overlay ? k === "overlay" : k === s.kind && i === s.idx)); + const go = dir => { + const [k, i] = all[(at + dir + all.length) % all.length]; + s.overlay = k === "overlay"; + if (!s.overlay) { s.kind = k; s.idx = i; } + s.band = 0; render(); + }; return h("div", { class: "dnav" }, h("button", { class: "small", "data-view-ok": "", "aria-label": t("Previous channel"), onclick: () => go(-1) }, "‹"), - h("span", { class: "dnavname" }, h("b", {}, chLabel(s.kind, s.idx)), " ", ch.name), + h("span", { class: "dnavname" }, s.overlay ? h("b", {}, "Overlay") : [h("b", {}, chLabel(s.kind, s.idx)), " ", chans(d, s.kind)[s.idx].name]), h("button", { class: "small", "data-view-ok": "", "aria-label": t("Next channel"), onclick: () => go(1) }, "›")); } @@ -131,12 +137,17 @@ const DASH_MODULES = { const canvas = h("canvas", { class: "dcurve" }); const shown = (m.cfg.overlays || []).map(key => { const k = key.startsWith("in") ? "in" : "out", i = +key.replace(/\D/g, ""); - return i < chans(d, k).length && !(k === s.kind && i === s.idx) ? { k, i, ch: chans(d, k)[i], color: chColor(d, k, i) } : null; + return i < chans(d, k).length ? { k, i, ch: chans(d, k)[i], color: chColor(d, k, i) } : null; }).filter(Boolean); - requestAnimationFrame(() => drawCurve(canvas, ch, s.band, { mode: "mag", overlays: shown })); + if (!shown.length) s.overlay = false; + const nav = dashChannelNav(m, d, s, shown.length > 0); + if (s.overlay) { + requestAnimationFrame(() => drawCurve(canvas, ch, -1, { mode: "mag", overlays: shown, overlaysOnly: true })); + return [nav, canvas, h("div", { class: "dlegend" }, shown.map(o => h("span", {}, h("i", { style: `background:${o.color}` }), chLabel(o.k, o.i))))]; + } + requestAnimationFrame(() => drawCurve(canvas, ch, s.band, { mode: "mag", overlays: [] })); const b = ch.peq[s.band]; - return [dashChannelNav(m, d, s), canvas, - shown.length ? h("div", { class: "dlegend" }, shown.map(o => h("span", {}, h("i", { style: `background:${o.color}` }), chLabel(o.k, o.i)))) : null, + return [nav, canvas, h("div", { class: "dbands" }, ch.peq.map((bb, i) => h("button", { class: "dband" + (i === s.band ? " on" : "") + (bb.bypass ? " off" : "") + (bb.gain !== 120 ? " act" : ""), "data-view-ok": "", onclick: () => { s.band = i; render(); } }, h("b", {}, i + 1), h("small", {}, fmtHzShort(freqHz(bb.freq)))))), h("p", { class: "info dbandinfo" }, `${PEQ_TYPES[b.type]} · ${SPEC.freq.fmt(b.freq)} · ${sign((b.gain - 120) / 10)} dB · Q ${Q_TABLE[b.q]}${b.bypass ? " · Bypass" : ""}`)]; @@ -235,7 +246,7 @@ async function dashSettings(m) { const title = h("input", { type: "text", maxlength: 40, value: m.cfg.title || "", placeholder: def.title() }); const dev_ = def.global ? null : h("select", {}, dashDevs().map(x => h("option", { value: x.id, selected: x === d }, x.name))); const text = m.type === "notes" ? h("textarea", { rows: 6, maxlength: 2000 }, m.cfg.text || "") : null; - // channels drawn over the curve: fixed per module, whichever channel is being looked at + // channels of the "Overlay" entry const overlays = new Set(m.cfg.overlays || []); const overlayBox = m.type === "curve" ? h("div", { class: "doverlays" }) : null; const fillOverlays = () => { @@ -250,7 +261,7 @@ async function dashSettings(m) { const res = await modal({ title: def.title(), body: h("div", { class: "form dform" }, h("label", { class: "full" }, t("Title"), title), dev_ ? h("label", { class: "full" }, "DSP", dev_) : null, text ? h("label", { class: "full" }, t("Text"), text) : null, - overlayBox ? h("div", { class: "full" }, h("div", { class: "sub" }, t("Show on top of the curve")), overlayBox) : null), + overlayBox ? h("div", { class: "full" }, h("div", { class: "sub" }, t("Channels shown together as “Overlay”")), overlayBox) : null), actions: [{ label: t("Cancel") }, { label: t("Save"), primary: true, value: () => true }] }); if (!res) return; m.cfg = { ...m.cfg, title: title.value.trim() }; diff --git a/static/i18n.js b/static/i18n.js index 425f47d..a811cad 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -574,7 +574,7 @@ const DE = { "Done": "Fertig", "Customise": "Anpassen", "Nothing here yet – press “Customise” and add modules.": "Noch nichts da – „Anpassen“ drücken und Module hinzufügen.", - "Show on top of the curve": "Über der Kurve anzeigen", + "Channels shown together as “Overlay”": "Kanäle, die zusammen als „Overlay“ angezeigt werden", "Drag to resize": "Zum Ändern der Größe ziehen", "Read-only – tap to edit": "Nur ansehen – antippen zum Bearbeiten", "Editing – tap for read-only": "Bearbeiten – antippen für Nur ansehen",