Dashboard curve: Overlay as its own entry next to the single channels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a9059d420
commit
fe24b620bf
3 files changed
+27
-15
No files matched your search
+23
-12
@@ -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() };
|
||||
|
||||
Reference in new issue
Block a user