Device editors: grouped, colour-coded cards with knobs, switches, tabs and live drawings (0.35.0)

Instruments and effects without a bespoke editor are laid out by DeviceLayouts
as titled cards per function (source, filter, envelope, modulation, output),
with knobs, segmented switches for short choices, tabs for the larger devices,
envelope / filter / LFO drawings, unit-aware values and a fader-bank graphic EQ.
Replaces the two-column slider grid and the fixed-height swipe pager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Reactorcoremeltdown
2026-11-13 12:31:46 +01:00
co-authored by Claude Opus 5.5
parent e38e2a2707
commit 2d285592e2
14 changed files with 695 additions and 216 deletions
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
package cc.tiredsysadmin.android.sizzle.ui.toolbox
import cc.tiredsysadmin.android.sizzle.model.ParamSpec
import cc.tiredsysadmin.android.sizzle.model.ToolboxType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class DeviceLayoutsTest {
/** Devices with editors of their own; every other one is laid out by DeviceLayouts. */
private val bespoke = setOf(
ToolboxType.NES_SYNTH, ToolboxType.SAMPLER, ToolboxType.SOUNDFONT, ToolboxType.DELAY,
ToolboxType.TAPE_ENGINE, ToolboxType.MIX_TIGHTENER, ToolboxType.GRANULAR,
)
@Test fun everyParameterIsOnExactlyOneCard() {
for (type in ToolboxType.entries.filter { it !in bespoke }) {
val keys = DeviceLayouts.pagesFor(type).flatMap { p -> p.panels.flatMap { it.keys } }
val params = type.params.map { it.key }
assertEquals("$type: duplicated ${keys.groupBy { it }.filter { it.value.size > 1 }.keys}", keys.size, keys.toSet().size)
assertEquals("$type: missing ${params - keys.toSet()}, unknown ${keys - params.toSet()}", params.toSet(), keys.toSet())
}
}
@Test fun labelsAreShortEnoughForAKnob() {
for (type in ToolboxType.entries.filter { it !in bespoke }) {
val byKey = type.params.associateBy { it.key }
for (page in DeviceLayouts.pagesFor(type)) for (panel in page.panels) for (k in panel.keys) {
val spec = byKey.getValue(k)
if (spec.isEnum) continue
val l = shortLabel(spec, panel)
assertTrue("$type $k '$l'", l.length <= 11)
}
}
}
@Test fun valuesReadInTheirUnits() {
assertEquals("250ms", formatParam(ParamSpec("attack", "Attack", 0f, 0f, 2f), 0.25f))
assertEquals("1.50s", formatParam(ParamSpec("release", "Release", 0f, 0f, 3f), 1.5f))
assertEquals("45%", formatParam(ParamSpec("x", "X", 0f, 0f, 1f), 0.45f))
assertEquals("+20%", formatParam(ParamSpec("x", "X", 0f, -1f, 1f), 0.2f))
assertEquals("+7st", formatParam(ParamSpec("o1semi", "Osc1 Semi", 0f, -12f, 12f, isInt = true), 7f))
assertEquals("-4.0dB", formatParam(ParamSpec("wet", "Wet (dB)", 0f, -60f, 0f), -4f))
assertEquals("1/8", formatParam(ParamSpec("division", "Division", 3f, 0f, 6f, isInt = true), 3f))
assertEquals("→ Position", shortLabel(ParamSpec("lfopos", "LFO > Position"), Panel("LFO", Tone.MOD, emptyList())))
assertEquals("Level", shortLabel(ParamSpec("o2level", "Osc2 Level"), Panel("O", Tone.SOURCE, emptyList())))
assertEquals("Thresh", shortLabel(ParamSpec("duckthresh", "Duck Thresh (dB)"), Panel("D", Tone.ENV, emptyList())))
}
}