Max level: confirm typed values above the limit, cleaner limit display
- typing a gain above the max level shows the limit and a warning; Apply has to be
clicked twice ("Set anyway"), the forced value also passes the server's lock
- sliders and faders show the locked range as a subtle striped zone in the track with a
stop edge at the limit, behind the knob (no more line drawn over the knob)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
52695d20a5
commit
06bc767f2c
4 files changed
+72
-26
No files matched your search
@@ -825,7 +825,7 @@ class App:
|
|||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
if action == "set":
|
if action == "set":
|
||||||
kind, idx, value = body["kind"], int(body["idx"]), body["value"]
|
kind, idx, value = body["kind"], int(body["idx"]), body["value"]
|
||||||
if body["param"] == "gain":
|
if body["param"] == "gain" and not body.get("force"): # force: confirmed twice in the app
|
||||||
value = dev.gain_cap(kind, idx, int(value)) # software max level
|
value = dev.gain_cap(kind, idx, int(value)) # software max level
|
||||||
dev.set_param(kind, idx, body["param"], value)
|
dev.set_param(kind, idx, body["param"], value)
|
||||||
return {"ok": True, "value": value}
|
return {"ok": True, "value": value}
|
||||||
|
|||||||
+50
-19
@@ -279,18 +279,43 @@ async function openFile(accept = ".json,.bin,application/json,application/octet-
|
|||||||
return { name, b64: btoa(bin), json };
|
return { name, b64: btoa(bin), json };
|
||||||
}
|
}
|
||||||
|
|
||||||
function askValue(label, spec, raw) {
|
// cap: highest raw value allowed without confirmation (software max level), or null.
|
||||||
|
// Above it the dialog warns and Apply has to be clicked twice; the result is then {value, force: true}.
|
||||||
|
function askValue(label, spec, raw, cap = null) {
|
||||||
const input = h("input", { type: "text", value: spec.fmt(raw).replace(/^Q /, "").replace(/ ·.*$/, ""),
|
const input = h("input", { type: "text", value: spec.fmt(raw).replace(/^Q /, "").replace(/ ·.*$/, ""),
|
||||||
autocomplete: "off", spellcheck: "false", enterkeyhint: "done" });
|
autocomplete: "off", spellcheck: "false", enterkeyhint: "done" });
|
||||||
const quick = spec.zero != null
|
const quick = spec.zero != null
|
||||||
? h("button", { class: "chip", onclick: () => { input.value = "0"; input.focus(); } }, "0 dB") : null;
|
? h("button", { class: "chip", onclick: () => { input.value = "0"; input.focus(); check(); } }, "0 dB") : null;
|
||||||
|
const warn = h("div", { class: "overlim", hidden: true });
|
||||||
|
let armed = false;
|
||||||
|
const parsed = () => { const s = input.value.trim(); return !s || isNaN(num(s)) ? null : clamp(spec.parse(s), spec.min, spec.max); };
|
||||||
|
const applyBtn = () => document.querySelector("#modal .dlg-actions button:last-child");
|
||||||
|
const check = () => {
|
||||||
|
const v = parsed(), over = cap != null && v != null && v > cap;
|
||||||
|
warn.hidden = !over;
|
||||||
|
if (over) warn.replaceChildren(svgIcon(ICON.lock), h("span", {}, t("Above the max level of {lim} – press Apply twice to set it anyway.", { lim: spec.fmt(cap) })));
|
||||||
|
if (armed && !over) { armed = false; const b = applyBtn(); if (b) { b.textContent = t("Apply"); b.className = "on"; } }
|
||||||
|
};
|
||||||
|
input.addEventListener("input", check);
|
||||||
return modal({
|
return modal({
|
||||||
title: label,
|
title: label,
|
||||||
body: h("div", {}, h("div", { class: "row" }, input, quick), h("p", { class: "info" }, spec.hint || "")),
|
body: h("div", {}, h("div", { class: "row" }, input, quick),
|
||||||
|
cap != null ? h("p", { class: "info limnote" }, svgIcon(ICON.lock), t("Max level: {lim}", { lim: spec.fmt(cap) })) : null,
|
||||||
|
warn, h("p", { class: "info" }, spec.hint || "")),
|
||||||
|
onOpen: check,
|
||||||
actions: [{ label: t("Cancel") }, { label: t("Apply"), primary: true, value: () => {
|
actions: [{ label: t("Cancel") }, { label: t("Apply"), primary: true, value: () => {
|
||||||
const s = input.value.trim();
|
const v = parsed();
|
||||||
if (!s || isNaN(num(s))) { input.classList.add("bad"); return undefined; }
|
if (v == null) { input.classList.add("bad"); return undefined; }
|
||||||
return clamp(spec.parse(s), spec.min, spec.max);
|
if (cap != null && v > cap) {
|
||||||
|
if (!armed) { // first click: ask again
|
||||||
|
armed = true;
|
||||||
|
const b = applyBtn();
|
||||||
|
if (b) { b.textContent = t("Set anyway"); b.className = "danger-on"; }
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return { value: v, force: true };
|
||||||
|
}
|
||||||
|
return v;
|
||||||
} }],
|
} }],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -308,10 +333,10 @@ const showLive = (key, v) => (live.get(key) || []).forEach(fn => fn(v));
|
|||||||
const LINK_OWN = ["name", "mix", "matrix", "link"]; // per channel even when linked (see protocol.py)
|
const LINK_OWN = ["name", "mix", "matrix", "link"]; // per channel even when linked (see protocol.py)
|
||||||
|
|
||||||
const sendTimers = new Map(), sendPending = new Map(), recentlySet = new Map();
|
const sendTimers = new Map(), sendPending = new Map(), recentlySet = new Map();
|
||||||
function setParam(kind, idx, param, value) {
|
function setParam(kind, idx, param, value, force = false) {
|
||||||
const d = dev();
|
const d = dev();
|
||||||
if (!d || !d.state) return;
|
if (!d || !d.state) return;
|
||||||
if (param === "gain") { const c = gainCap(d, kind, idx); if (c != null) value = Math.min(value, c); }
|
if (param === "gain" && !force) { const c = gainCap(d, kind, idx); if (c != null) value = Math.min(value, c); }
|
||||||
setPath(chans(d, kind)[idx], param, value);
|
setPath(chans(d, kind)[idx], param, value);
|
||||||
const key = `${d.id}|${kind}|${idx}|${param}`;
|
const key = `${d.id}|${kind}|${idx}|${param}`;
|
||||||
recentlySet.set(key, Date.now());
|
recentlySet.set(key, Date.now());
|
||||||
@@ -322,7 +347,7 @@ function setParam(kind, idx, param, value) {
|
|||||||
recentlySet.set(`${d.id}|${kind}|${j}|${param}`, Date.now());
|
recentlySet.set(`${d.id}|${kind}|${j}|${param}`, Date.now());
|
||||||
showLive(`${d.id}|${kind}|${j}|${param}`, value);
|
showLive(`${d.id}|${kind}|${j}|${param}`, value);
|
||||||
}
|
}
|
||||||
const body = { kind, idx, param, value };
|
const body = { kind, idx, param, value, ...(force ? { force: true } : {}) };
|
||||||
const fire = b => api("POST", `/api/devices/${d.id}/set`, b).catch(e => toast(t("Error: ") + e.message));
|
const fire = b => api("POST", `/api/devices/${d.id}/set`, b).catch(e => toast(t("Error: ") + e.message));
|
||||||
if (sendTimers.has(key)) { sendPending.set(key, body); return; }
|
if (sendTimers.has(key)) { sendPending.set(key, body); return; }
|
||||||
fire(body);
|
fire(body);
|
||||||
@@ -364,15 +389,15 @@ function paramSlider(label, kind, idx, path, specName, onChange) {
|
|||||||
const home = spec.zero ?? spec.def;
|
const home = spec.zero ?? spec.def;
|
||||||
const wrap = h("div", { class: "param" + (cur() === spec.zero ? " atzero" : "") });
|
const wrap = h("div", { class: "param" + (cur() === spec.zero ? " atzero" : "") });
|
||||||
let dragging = false;
|
let dragging = false;
|
||||||
const commit = v => {
|
const commit = (v, force = false) => {
|
||||||
v = clamp(Math.round(v), spec.min, spec.max);
|
v = clamp(Math.round(v), spec.min, spec.max);
|
||||||
if (path === "gain") { const c = gainCap(dev(), kind, idx); if (c != null) v = Math.min(v, c); } // software max level
|
if (path === "gain" && !force) { const c = gainCap(dev(), kind, idx); if (c != null) v = Math.min(v, c); } // software max level
|
||||||
input.value = v;
|
input.value = v;
|
||||||
if (v === cur()) return;
|
if (v === cur()) return;
|
||||||
if (v === spec.zero) buzz();
|
if (v === spec.zero) buzz();
|
||||||
val.textContent = spec.fmt(v);
|
val.textContent = spec.fmt(v);
|
||||||
wrap.classList.toggle("atzero", v === spec.zero);
|
wrap.classList.toggle("atzero", v === spec.zero);
|
||||||
setParam(kind, idx, path, v);
|
setParam(kind, idx, path, v, force);
|
||||||
onChange && onChange(v);
|
onChange && onChange(v);
|
||||||
};
|
};
|
||||||
onLive(kind, idx, path, v => { input.value = v; val.textContent = spec.fmt(v); wrap.classList.toggle("atzero", v === spec.zero); });
|
onLive(kind, idx, path, v => { input.value = v; val.textContent = spec.fmt(v); wrap.classList.toggle("atzero", v === spec.zero); });
|
||||||
@@ -393,13 +418,17 @@ function paramSlider(label, kind, idx, path, specName, onChange) {
|
|||||||
input.addEventListener("pointercancel", release);
|
input.addEventListener("pointercancel", release);
|
||||||
input.addEventListener("blur", release);
|
input.addEventListener("blur", release);
|
||||||
val.addEventListener("click", async () => {
|
val.addEventListener("click", async () => {
|
||||||
const v = await askValue(label, spec, cur());
|
const v = await askValue(label, spec, cur(), path === "gain" ? gainCap(dev(), kind, idx) : null);
|
||||||
if (v != null) commit(v);
|
if (v != null) typeof v === "object" ? commit(v.value, true) : commit(v);
|
||||||
});
|
});
|
||||||
const lim = path === "gain" ? maxGain(dev(), kind, idx) : null;
|
const lim = path === "gain" ? maxGain(dev(), kind, idx) : null;
|
||||||
|
if (lim != null) { // locked range above the max level, part of the track (stays behind the knob)
|
||||||
|
input.classList.add("haslim");
|
||||||
|
input.style.setProperty("--lim", (lim - spec.min) / (spec.max - spec.min));
|
||||||
|
input.title = `${t("Max level")}: ${spec.fmt(lim)}`;
|
||||||
|
}
|
||||||
const track = h("div", { class: "rangewrap" },
|
const track = h("div", { class: "rangewrap" },
|
||||||
spec.zero != null ? h("div", { class: "zmark", style: `--f:${(spec.zero - spec.min) / (spec.max - spec.min)}` }) : null,
|
spec.zero != null ? h("div", { class: "zmark", style: `--f:${(spec.zero - spec.min) / (spec.max - spec.min)}` }) : null, input);
|
||||||
lim != null ? h("div", { class: "limmark", style: `--f:${(lim - spec.min) / (spec.max - spec.min)}`, title: t("Max level") }) : null, input);
|
|
||||||
wrap.append(
|
wrap.append(
|
||||||
h("div", { class: "lbl" }, h("span", {}, label),
|
h("div", { class: "lbl" }, h("span", {}, label),
|
||||||
h("div", { class: "valbox" }, stepper(-1, d => commit(cur() + d)), val, stepper(1, d => commit(cur() + d)))),
|
h("div", { class: "valbox" }, stepper(-1, d => commit(cur() + d)), val, stepper(1, d => commit(cur() + d)))),
|
||||||
@@ -434,7 +463,7 @@ function fader({ min, max, value, zero, ticks, label, onInput, cap, limit }) {
|
|||||||
const tickEls = (ticks || []).map(([v, label]) => h("div", { class: "tick" + (v === zero ? " z" : ""), style: `--f:${(v - min) / (max - min)}` }, label ? h("span", {}, label) : null));
|
const tickEls = (ticks || []).map(([v, label]) => h("div", { class: "tick" + (v === zero ? " z" : ""), style: `--f:${(v - min) / (max - min)}` }, label ? h("span", {}, label) : null));
|
||||||
const el = h("div", { class: "fader", tabindex: "0", role: "slider", "aria-label": label || "Fader",
|
const el = h("div", { class: "fader", tabindex: "0", role: "slider", "aria-label": label || "Fader",
|
||||||
"aria-valuemin": min, "aria-valuemax": max }, h("div", { class: "track" }), tickEls,
|
"aria-valuemin": min, "aria-valuemax": max }, h("div", { class: "track" }), tickEls,
|
||||||
limit != null ? h("div", { class: "limmark", style: `--f:${(limit - min) / (max - min)}`, title: t("Max level") }) : null, capEl);
|
limit != null ? h("div", { class: "limzone", style: `--f:${(limit - min) / (max - min)}`, title: t("Max level") }) : null, capEl);
|
||||||
let cur = value;
|
let cur = value;
|
||||||
const place = () => {
|
const place = () => {
|
||||||
capEl.style.setProperty("--f", (cur - min) / (max - min));
|
capEl.style.setProperty("--f", (cur - min) / (max - min));
|
||||||
@@ -853,8 +882,10 @@ function strip(d, kind, i) {
|
|||||||
onInput: v => { showDb(v); setParam(kind, i, "gain", v); } });
|
onInput: v => { showDb(v); setParam(kind, i, "gain", v); } });
|
||||||
onLive(kind, i, "gain", v => { f.setValue(v); showDb(v); });
|
onLive(kind, i, "gain", v => { f.setValue(v); showDb(v); });
|
||||||
db.addEventListener("click", async () => {
|
db.addEventListener("click", async () => {
|
||||||
const v = await askValue(`${chTitle(d, kind, i)} – Gain`, SPEC.gain, chans(dev(), kind)[i].gain);
|
const r = await askValue(`${chTitle(d, kind, i)} – Gain`, SPEC.gain, chans(dev(), kind)[i].gain, gainCap(dev(), kind, i));
|
||||||
if (v != null) { f.setValue(v); showDb(v); setParam(kind, i, "gain", v); }
|
if (r == null) return;
|
||||||
|
const force = typeof r === "object", v = force ? r.value : Math.min(r, gainCap(dev(), kind, i) ?? r);
|
||||||
|
f.setValue(v); showDb(v); setParam(kind, i, "gain", v, force);
|
||||||
});
|
});
|
||||||
el.append(
|
el.append(
|
||||||
h("button", { class: "strip-head", onclick: () => openChannel(kind, i), title: t("Edit channel") },
|
h("button", { class: "strip-head", onclick: () => openChannel(kind, i), title: t("Edit channel") },
|
||||||
|
|||||||
@@ -498,6 +498,9 @@ const DE = {
|
|||||||
"no limit": "keine Grenze",
|
"no limit": "keine Grenze",
|
||||||
"now above – set on the DSP": "liegt gerade darüber – am DSP eingestellt",
|
"now above – set on the DSP": "liegt gerade darüber – am DSP eingestellt",
|
||||||
"Software lock for the gain faders: the app does not let them go higher. If the DSP itself is turned up further, the app shows it and the fader can only be pulled down until it snaps into the limit again.": "Software-Sperre für die Gain-Fader: Die App lässt sie nicht höher. Wird am DSP selbst weiter aufgedreht, zeigt die App das an, und der Fader lässt sich nur nach unten ziehen, bis er wieder in die Grenze einrastet.",
|
"Software lock for the gain faders: the app does not let them go higher. If the DSP itself is turned up further, the app shows it and the fader can only be pulled down until it snaps into the limit again.": "Software-Sperre für die Gain-Fader: Die App lässt sie nicht höher. Wird am DSP selbst weiter aufgedreht, zeigt die App das an, und der Fader lässt sich nur nach unten ziehen, bis er wieder in die Grenze einrastet.",
|
||||||
|
"Above the max level of {lim} – press Apply twice to set it anyway.": "Über dem max. Pegel von {lim} – zum Setzen trotzdem zweimal Übernehmen drücken.",
|
||||||
|
"Max level: {lim}": "Max. Pegel: {lim}",
|
||||||
|
"Set anyway": "Trotzdem setzen",
|
||||||
};
|
};
|
||||||
|
|
||||||
const DE_PATTERNS = [
|
const DE_PATTERNS = [
|
||||||
|
|||||||
+18
-6
@@ -686,12 +686,24 @@ button.devadd .plus svg { width: 32px; height: 32px; fill: none; stroke: current
|
|||||||
.scanrow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: var(--panel2); }
|
.scanrow { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: var(--panel2); }
|
||||||
.scanrow small { display: block; color: var(--dim); font-size: 12px; }
|
.scanrow small { display: block; color: var(--dim); font-size: 12px; }
|
||||||
|
|
||||||
/* ---- software max level */
|
/* ---- software max level: a striped "locked" zone in the track above the limit, behind the knob */
|
||||||
.fader .limmark { position: absolute; left: 50%; width: 30px; height: 3px; margin-left: -15px; border-radius: 2px; background: var(--bad);
|
:root { --limstripe: repeating-linear-gradient(-45deg, #ef444466 0 3px, #ef444414 3px 6px); }
|
||||||
box-shadow: 0 0 6px #ef4444aa; bottom: calc(12px + var(--f) * (100% - 24px)); transform: translateY(50%); pointer-events: none; z-index: 1; }
|
input[type=range].haslim { --p: calc(13px + var(--lim) * (100% - 26px)); }
|
||||||
.rangewrap { position: relative; }
|
input[type=range].haslim::-webkit-slider-runnable-track {
|
||||||
.rangewrap .limmark { position: absolute; top: 50%; width: 3px; height: 18px; margin-top: -9px; border-radius: 2px; background: var(--bad);
|
background: linear-gradient(90deg, var(--line) 0 var(--p), #f87171 var(--p) calc(var(--p) + 2px), transparent calc(var(--p) + 2px)),
|
||||||
left: calc(13px + var(--f) * (100% - 26px)); transform: translateX(-50%); pointer-events: none; z-index: 1; }
|
var(--limstripe) var(--line); }
|
||||||
|
input[type=range].haslim::-moz-range-track {
|
||||||
|
background: linear-gradient(90deg, var(--line) 0 var(--p), #f87171 var(--p) calc(var(--p) + 2px), transparent calc(var(--p) + 2px)),
|
||||||
|
var(--limstripe) var(--line); }
|
||||||
|
.fader .limzone { position: absolute; left: var(--tx); width: 10px; margin-left: -5px; top: 12px; border-radius: 5px 5px 2px 2px;
|
||||||
|
height: calc((1 - var(--f)) * (100% - 24px)); background: var(--limstripe); pointer-events: none; z-index: 0; }
|
||||||
|
.fader .limzone::after { content: ""; position: absolute; left: -6px; right: -6px; bottom: -1px; height: 2px; border-radius: 1px;
|
||||||
|
background: #f87171; box-shadow: 0 0 6px #ef444488; }
|
||||||
|
.limnote { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; }
|
||||||
|
.limnote svg, .overlim svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; }
|
||||||
|
.overlim { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; padding: 9px 10px; border-radius: 8px; font-size: 13px;
|
||||||
|
color: #fecaca; background: #ef44441f; border: 1px solid #ef444466; }
|
||||||
|
.overlim[hidden] { display: none; }
|
||||||
.mlrow { display: grid; grid-template-columns: 110px minmax(0, 1fr) 84px; align-items: center; gap: 10px; margin-top: 8px; }
|
.mlrow { display: grid; grid-template-columns: 110px minmax(0, 1fr) 84px; align-items: center; gap: 10px; margin-top: 8px; }
|
||||||
.mllabel { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
|
.mllabel { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
|
||||||
.mlval { font-size: 12px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
|
.mlval { font-size: 12px; color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
|
||||||
|
|||||||
Reference in new issue
Block a user