Names for link groups, shown as coloured brackets above the mixer strips
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
83548c9620
commit
4b33fc2665
7 files changed
+97
-14
No files matched your search
+47
-8
@@ -154,9 +154,12 @@ function linkInfo(d, kind, i) { // {group, color} if the channel is linked, el
|
||||
const gs = linkedGroups(d, kind), n = gs.findIndex(g => g.includes(i));
|
||||
return n < 0 ? null : { group: gs[n], color: LINK_COLORS[n % LINK_COLORS.length] };
|
||||
}
|
||||
// group names are kept by the app, keyed by the members (a changed group starts without a name)
|
||||
const linkKey = (kind, g) => `${kind}:${g.join(",")}`;
|
||||
const linkName = (d, kind, g) => (d.linknames || {})[linkKey(kind, g)] || "";
|
||||
const linkBadge = (d, kind, i) => {
|
||||
const l = linkInfo(d, kind, i);
|
||||
return l ? h("span", { class: "lnk", style: `--lc:${l.color}`, title: t("Linked: ") + l.group.map(j => chLabel(kind, j)).join(" + ") },
|
||||
return l ? h("span", { class: "lnk", style: `--lc:${custColor(d, kind, i) || l.color}`, title: t("Linked: ") + l.group.map(j => chLabel(kind, j)).join(" + ") },
|
||||
svgIcon(ICON.link)) : null;
|
||||
};
|
||||
// polarity inverted ("Phase Ø" in the channel view)
|
||||
@@ -884,7 +887,7 @@ function strip(d, kind, i) {
|
||||
const ch = chans(d, kind)[i];
|
||||
const db = h("button", { class: "db" + (ch.gain === 280 ? " z" : ""), title: t("Enter value") }, sign(gainDb(ch.gain)));
|
||||
const showDb = v => { db.textContent = sign(gainDb(v)); db.classList.toggle("z", v === 280); };
|
||||
const el = h("div", { class: `strip ${kind}` + (ch.mute ? " muted" : "") + (custColor(d, kind, i) ? " tinted" : ""), style: ccStyle(d, kind, i) });
|
||||
const el = h("div", { class: `strip ${kind}` + (ch.mute ? " muted" : "") + (custColor(d, kind, i) ? " tinted" : ""), style: `${ccStyle(d, kind, i)};grid-column:${i + 1}` });
|
||||
const f = fader({ min: 0, max: 400, value: ch.gain, zero: 280, ticks: GAIN_TICKS, label: `${chLabel(kind, i)} Gain`,
|
||||
cap: () => gainCap(dev(), kind, i), limit: maxGain(d, kind, i),
|
||||
onInput: v => { showDb(v); setParam(kind, i, "gain", v); } });
|
||||
@@ -905,10 +908,29 @@ function strip(d, kind, i) {
|
||||
return el;
|
||||
}
|
||||
|
||||
// bracket over a run of neighbouring strips of one link group (a group with gaps gets one per run)
|
||||
function linkBands(d, kind) {
|
||||
const bands = [];
|
||||
linkedGroups(d, kind).forEach(g => {
|
||||
const color = custColor(d, kind, g[0]) || linkInfo(d, kind, g[0]).color, name = linkName(d, kind, g);
|
||||
const title = (name ? name + " · " : "") + g.map(j => chLabel(kind, j)).join(" + ");
|
||||
g.forEach((j, n) => {
|
||||
if (n && g[n - 1] === j - 1) return;
|
||||
let len = 1;
|
||||
while (g.includes(j + len)) len++;
|
||||
bands.push(h("div", { class: "lkband" + (len === 1 ? " single" : ""), style: `--lc:${color};grid-column:${j + 1} / span ${len}`, title },
|
||||
h("span", { class: "lkname" + (name ? "" : " anon") }, svgIcon(ICON.link), name ? h("b", {}, name) : null)));
|
||||
});
|
||||
});
|
||||
return bands;
|
||||
}
|
||||
|
||||
function viewMixer(d) {
|
||||
const group = (kind, title) => h("section", { class: "mgroup", style: `flex-grow:${chans(d, kind).length}` },
|
||||
h("h4", {}, title), h("div", { class: "strips" }, chans(d, kind).map((_, i) => strip(d, kind, i))));
|
||||
return [h("div", { class: "mixer" }, group("in", t("Inputs")), group("out", t("Outputs"))),
|
||||
h("h4", {}, title), h("div", { class: "strips", style: `--n:${chans(d, kind).length}` },
|
||||
linkBands(d, kind), chans(d, kind).map((_, i) => strip(d, kind, i))));
|
||||
const bands = linkedGroups(d, "in").length + linkedGroups(d, "out").length > 0;
|
||||
return [h("div", { class: "mixer" + (bands ? " hasbands" : "") }, group("in", t("Inputs")), group("out", t("Outputs"))),
|
||||
h("p", { class: "info hint" }, t("Drag a fader by its knob · snaps at 0 dB · double-tap the knob = 0 dB · tap the dB value to type one · tap the name = edit channel"))];
|
||||
}
|
||||
|
||||
@@ -1354,12 +1376,28 @@ async function saveLinks(d, kind, groups, msg) {
|
||||
S.linkBusy = false; S.linkSel[kind] = []; render();
|
||||
}
|
||||
|
||||
function linkNameInput(d, kind, g) {
|
||||
const input = h("input", { type: "text", class: "lkname-in", maxlength: 16, value: linkName(d, kind, g),
|
||||
placeholder: t("Group name"), "aria-label": t("Group name"), autocomplete: "off", spellcheck: "false", enterkeyhint: "done" });
|
||||
const save = async () => {
|
||||
const v = input.value.trim();
|
||||
if (v === linkName(dev(), kind, g)) return;
|
||||
const next = { ...(dev().linknames || {}) };
|
||||
if (v) next[linkKey(kind, g)] = v; else delete next[linkKey(kind, g)];
|
||||
try { await api("POST", `/api/devices/${d.id}/linknames`, { linknames: next }); toast(v ? t("Group name saved") : t("Group name removed")); }
|
||||
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
|
||||
};
|
||||
input.addEventListener("change", save);
|
||||
input.addEventListener("keydown", e => { if (e.key === "Enter") input.blur(); });
|
||||
return input;
|
||||
}
|
||||
|
||||
function linkCard(d, kind) {
|
||||
const list = chans(d, kind), linked = linkedGroups(d, kind);
|
||||
const sel = S.linkSel[kind] = S.linkSel[kind].filter(i => i < list.length && !linkInfo(d, kind, i));
|
||||
const btns = list.map((ch, i) => {
|
||||
const l = linkInfo(d, kind, i), on = sel.includes(i);
|
||||
return h("button", { class: "lkch" + (on ? " sel" : "") + (l ? " taken" : ""), style: l ? `--lc:${l.color}` : "", "aria-pressed": String(on),
|
||||
return h("button", { class: "lkch" + (on ? " sel" : "") + (l ? " taken" : ""), style: l ? `--lc:${custColor(d, kind, i) || l.color}` : "", "aria-pressed": String(on),
|
||||
title: l ? t("Already linked – unlink the group first") : "", disabled: S.linkBusy || !!l, onclick: () => { S.linkSel[kind] = on ? sel.filter(j => j !== i) : [...sel, i].sort((a, b) => a - b); render(); } },
|
||||
h("b", {}, chLabel(kind, i)), h("small", {}, ch.name || "\u00a0"),
|
||||
h("span", { class: "lkmark" }, l ? svgIcon(ICON.link) : null));
|
||||
@@ -1379,9 +1417,10 @@ function linkCard(d, kind) {
|
||||
h("span", { class: "grow info" }, sel.length < 2 ? t("Tap at least two channels") : t("{n} channels selected", { n: sel.length })),
|
||||
h("button", { class: "on", disabled: sel.length < 2 || S.linkBusy, onclick: link }, t("Link"))),
|
||||
linked.length ? h("div", { class: "lkgroups" }, linked.map((g, n) =>
|
||||
h("div", { class: "row lkgroup", style: `--lc:${LINK_COLORS[n % LINK_COLORS.length]}` },
|
||||
svgIcon(ICON.link), h("span", { class: "grow" }, g.map(i => chLabel(kind, i)).join(" + ")),
|
||||
h("button", { class: "small", disabled: S.linkBusy, onclick: () => unlink(g) }, t("Unlink")))))
|
||||
h("div", { class: "lkgroup", style: `--lc:${custColor(d, kind, g[0]) || LINK_COLORS[n % LINK_COLORS.length]}` },
|
||||
h("div", { class: "row" }, svgIcon(ICON.link), h("span", { class: "grow lkmembers" }, g.map(i => chLabel(kind, i)).join(" + ")),
|
||||
h("button", { class: "small", disabled: S.linkBusy, onclick: () => unlink(g) }, t("Unlink"))),
|
||||
linkNameInput(d, kind, g))))
|
||||
: h("p", { class: "info" }, t("No channels linked.")));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user