Skip to content

Commit ab334dd

Browse files
kieranhjclaude
andcommitted
Grey out pitch inputs on channel 0 instead of hiding
Switching to channel 0 used to hide the pitch envelope subsection and the SOUND pitch input, which made the layout jump. Now they stay in place but get a disabled attribute and reduced opacity, so the noise-channel state is visually obvious without rearranging the UI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4e98ec3 commit ab334dd

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/main.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,26 @@ const pitchInputWrap = soundInputs.get("pitch")!.closest("label") as HTMLElement
282282

283283
function applyChannelMode(): void {
284284
const isNoise = sound.channel === 0;
285-
pitchH3.style.display = isNoise ? "none" : "";
286-
pitchGrid.style.display = isNoise ? "none" : "";
287-
pitchInputWrap.style.display = isNoise ? "none" : "";
285+
// Grey out the pitch envelope inputs rather than hiding the section, so
286+
// the layout doesn't jump when switching channels. Same treatment for the
287+
// SOUND pitch number input (replaced by the noise-mode dropdown).
288+
pitchH3.classList.toggle("disabled", isNoise);
289+
pitchGrid.classList.toggle("disabled", isNoise);
290+
for (const f of PITCH_FIELDS) {
291+
const i = envInputs.get(f.key);
292+
if (i) i.disabled = isNoise;
293+
}
294+
pitchInputWrap.classList.toggle("disabled", isNoise);
295+
const pitchInput = soundInputs.get("pitch");
296+
if (pitchInput) pitchInput.disabled = isNoise;
288297
noiseModeWrap.style.display = isNoise ? "" : "none";
289298
if (isNoise) {
290299
// Channel 0 only uses low 3 bits of P; clamp once on entry so the URL,
291300
// BASIC line, and select all stay consistent.
292301
const clamped = sound.pitch & 0x07;
293302
if (clamped !== sound.pitch) {
294303
sound.pitch = clamped;
295-
const pi = soundInputs.get("pitch");
296-
if (pi) pi.value = String(sound.pitch);
304+
if (pitchInput) pitchInput.value = String(sound.pitch);
297305
}
298306
noiseSelect.value = String(sound.pitch);
299307
}

src/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
114114
}
115115
.field input:focus,
116116
.field select:focus { outline: 1px solid #58a6ff; }
117+
.field input:disabled,
118+
.field select:disabled { color: #484f58; cursor: not-allowed; }
119+
.field.disabled,
120+
h3.disabled,
121+
.grid.disabled { opacity: 0.45; }
122+
.grid.disabled { pointer-events: none; }
117123

118124
#play, #stop, #share-link, #run-emulator {
119125
color: white;

0 commit comments

Comments
 (0)