Device editors: redraw knobs, switches, faders and drawings on every edit (0.35.1)
The controls were skipped on a revision bump because their arguments compared equal by identity; they now take the revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2d285592e2
commit
1eafe20410
@@ -4,6 +4,12 @@ Sizzletracker for Android (`cc.tiredsysadmin.android.sizzle`). One entry per
|
|||||||
version in `versions.properties`; versions before 0.28.0 are described in the git
|
version in `versions.properties`; versions before 0.28.0 are described in the git
|
||||||
log (one commit per version).
|
log (one commit per version).
|
||||||
|
|
||||||
|
## 0.35.1 (versionCode 67)
|
||||||
|
|
||||||
|
- **Fix:** knobs, switches, EQ faders and the envelope/filter/LFO drawings in the
|
||||||
|
new device editors did not move when touched (the value changed, the screen
|
||||||
|
didn't). They now redraw on every edit.
|
||||||
|
|
||||||
## 0.35.0 (versionCode 66)
|
## 0.35.0 (versionCode 66)
|
||||||
|
|
||||||
- **Device editors redesigned:** instruments and effects no longer show two
|
- **Device editors redesigned:** instruments and effects no longer show two
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ fun PanelCard(vm: AppViewModel, slot: ToolboxSlot, panel: Panel, rev: Int = vm.r
|
|||||||
Text(panel.title.uppercase(), color = tone, fontFamily = FontFamily.Monospace, fontSize = 11.sp,
|
Text(panel.title.uppercase(), color = tone, fontFamily = FontFamily.Monospace, fontSize = 11.sp,
|
||||||
letterSpacing = 1.sp)
|
letterSpacing = 1.sp)
|
||||||
}
|
}
|
||||||
panel.viz?.let { VizCanvas(slot, it, byKey, tone) }
|
panel.viz?.let { VizCanvas(slot, it, byKey, tone, rev) }
|
||||||
|
|
||||||
if (panel.faders != null) {
|
if (panel.faders != null) {
|
||||||
FaderBank(vm, slot, specs, panel, tone)
|
FaderBank(vm, slot, specs, panel, tone, rev)
|
||||||
return@Column
|
return@Column
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ fun PanelCard(vm: AppViewModel, slot: ToolboxSlot, panel: Panel, rev: Int = vm.r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
segmented.forEach { Segmented(vm, slot, it, shortLabel(it, panel), tone) }
|
segmented.forEach { Segmented(vm, slot, it, shortLabel(it, panel), tone, rev) }
|
||||||
|
|
||||||
if (knobs.isNotEmpty()) {
|
if (knobs.isNotEmpty()) {
|
||||||
val n = knobs.size
|
val n = knobs.size
|
||||||
@@ -211,7 +211,7 @@ fun PanelCard(vm: AppViewModel, slot: ToolboxSlot, panel: Panel, rev: Int = vm.r
|
|||||||
val pad = (slots - row.size) / 2f
|
val pad = (slots - row.size) / 2f
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
if (pad > 0f) Spacer(Modifier.weight(pad))
|
if (pad > 0f) Spacer(Modifier.weight(pad))
|
||||||
row.forEach { spec -> SpecKnob(vm, slot, spec, shortLabel(spec, panel), tone, Modifier.weight(1f)) }
|
row.forEach { spec -> SpecKnob(vm, slot, spec, shortLabel(spec, panel), tone, rev, Modifier.weight(1f)) }
|
||||||
if (pad > 0f) Spacer(Modifier.weight(pad))
|
if (pad > 0f) Spacer(Modifier.weight(pad))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,8 @@ fun PanelCard(vm: AppViewModel, slot: ToolboxSlot, panel: Panel, rev: Int = vm.r
|
|||||||
// ---------------------------------------------------------------- controls
|
// ---------------------------------------------------------------- controls
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SpecKnob(vm: AppViewModel, slot: ToolboxSlot, spec: ParamSpec, label: String, tone: Color, modifier: Modifier) {
|
private fun SpecKnob(vm: AppViewModel, slot: ToolboxSlot, spec: ParamSpec, label: String, tone: Color, rev: Int, modifier: Modifier) {
|
||||||
|
@Suppress("UNUSED_PARAMETER") val ignored = rev
|
||||||
val value = slot.float(spec.key, spec.default).coerceIn(spec.min, spec.max)
|
val value = slot.float(spec.key, spec.default).coerceIn(spec.min, spec.max)
|
||||||
Knob(
|
Knob(
|
||||||
label = label.uppercase(), value = value, min = spec.min, max = spec.max,
|
label = label.uppercase(), value = value, min = spec.min, max = spec.max,
|
||||||
@@ -238,7 +239,8 @@ private fun isSegmentable(spec: ParamSpec): Boolean =
|
|||||||
spec.choices.size <= 6 && spec.choices.sumOf { it.length } <= 34
|
spec.choices.size <= 6 && spec.choices.sumOf { it.length } <= 34
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun Segmented(vm: AppViewModel, slot: ToolboxSlot, spec: ParamSpec, label: String, tone: Color) {
|
private fun Segmented(vm: AppViewModel, slot: ToolboxSlot, spec: ParamSpec, label: String, tone: Color, rev: Int) {
|
||||||
|
@Suppress("UNUSED_PARAMETER") val ignored = rev
|
||||||
val c = LocalRetro.current
|
val c = LocalRetro.current
|
||||||
val cur = slot.string(spec.key, spec.choices.first())
|
val cur = slot.string(spec.key, spec.choices.first())
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||||
@@ -265,7 +267,8 @@ private fun Segmented(vm: AppViewModel, slot: ToolboxSlot, spec: ParamSpec, labe
|
|||||||
|
|
||||||
/** Vertical bipolar faders, one per key: drag or tap to set, double-tap to zero. */
|
/** Vertical bipolar faders, one per key: drag or tap to set, double-tap to zero. */
|
||||||
@Composable
|
@Composable
|
||||||
private fun FaderBank(vm: AppViewModel, slot: ToolboxSlot, specs: List<ParamSpec>, panel: Panel, tone: Color) {
|
private fun FaderBank(vm: AppViewModel, slot: ToolboxSlot, specs: List<ParamSpec>, panel: Panel, tone: Color, rev: Int) {
|
||||||
|
@Suppress("UNUSED_PARAMETER") val ignored = rev
|
||||||
val c = LocalRetro.current
|
val c = LocalRetro.current
|
||||||
val captions = panel.faders ?: return
|
val captions = panel.faders ?: return
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(3.dp)) {
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(3.dp)) {
|
||||||
@@ -313,13 +316,17 @@ private fun FaderBank(vm: AppViewModel, slot: ToolboxSlot, specs: List<ParamSpec
|
|||||||
// ---------------------------------------------------------------- drawings
|
// ---------------------------------------------------------------- drawings
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun VizCanvas(slot: ToolboxSlot, viz: Viz, byKey: Map<String, ParamSpec>, tone: Color) {
|
private fun VizCanvas(slot: ToolboxSlot, viz: Viz, byKey: Map<String, ParamSpec>, tone: Color, rev: Int) {
|
||||||
|
@Suppress("UNUSED_PARAMETER") val ignored = rev
|
||||||
val c = LocalRetro.current
|
val c = LocalRetro.current
|
||||||
fun num(key: String?): Float? = key?.let { k -> byKey[k]?.let { slot.float(k, it.default).coerceIn(it.min, it.max) } }
|
fun num(key: String?): Float? = key?.let { k -> byKey[k]?.let { slot.float(k, it.default).coerceIn(it.min, it.max) } }
|
||||||
fun frac(key: String?): Float? = key?.let { k -> byKey[k]?.let { s -> num(k)!!.let { (it - s.min) / (s.max - s.min) } } }
|
fun frac(key: String?): Float? = key?.let { k -> byKey[k]?.let { s -> num(k)!!.let { (it - s.min) / (s.max - s.min) } } }
|
||||||
fun choice(key: String?): String = key?.let { k -> byKey[k]?.let { slot.string(k, it.choices.firstOrNull() ?: "") } } ?: ""
|
fun choice(key: String?): String = key?.let { k -> byKey[k]?.let { slot.string(k, it.choices.firstOrNull() ?: "") } } ?: ""
|
||||||
|
|
||||||
Canvas(Modifier.fillMaxWidth().height(56.dp).background(c.background).border(1.dp, c.grid, RectangleShape)) {
|
Canvas(Modifier.fillMaxWidth().height(56.dp).background(c.background).border(1.dp, c.grid, RectangleShape)) {
|
||||||
|
// Capture the revision so this lambda isn't memoized across parameter edits
|
||||||
|
// (it reads the slot map directly, which Compose can't observe).
|
||||||
|
if (rev < 0) return@Canvas
|
||||||
val w = size.width; val h = size.height
|
val w = size.width; val h = size.height
|
||||||
val top = h * 0.12f; val bottom = h * 0.92f
|
val top = h * 0.12f; val bottom = h * 0.92f
|
||||||
val path = Path()
|
val path = Path()
|
||||||
|
|||||||
@@ -349,6 +349,14 @@ table). `DeviceLayoutsTest` checks that every parameter of every laid-out device
|
|||||||
is on exactly one card and that knob labels stay short. A device missing from
|
is on exactly one card and that knob labels stay short. A device missing from
|
||||||
`DeviceLayouts` falls back to one card with all its parameters.
|
`DeviceLayouts` falls back to one card with all its parameters.
|
||||||
|
|
||||||
|
**Recomposition pitfall (fixed in 0.35.1).** Slot params live in a plain map that
|
||||||
|
Compose can't observe; edits bump `vm.revision` instead. Because the compiler's
|
||||||
|
strong skipping compares `vm`/`slot` by identity, a child composable that receives
|
||||||
|
only those is *skipped* on a revision bump and shows stale values, and a `Canvas`
|
||||||
|
lambda that captures only them is memoized and never redraws. So every control in
|
||||||
|
Panels.kt (`SpecKnob`, `Segmented`, `FaderBank`, `VizCanvas`) takes `rev: Int`,
|
||||||
|
and `VizCanvas` reads `rev` inside its draw lambda. Do the same in any new control.
|
||||||
|
|
||||||
### 5.4.1 Opening a device's settings from another tab
|
### 5.4.1 Opening a device's settings from another tab
|
||||||
|
|
||||||
The Toolbox owns its editor state (`editing` in `ToolboxScreen`). Other screens ask
|
The Toolbox owns its editor state (`editing` in `ToolboxScreen`). Other screens ask
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@
|
|||||||
# or polish. android.versionCode is monotonic and bumps by 1 on every release,
|
# or polish. android.versionCode is monotonic and bumps by 1 on every release,
|
||||||
# because F-Droid and the Android package manager order installs by it alone.
|
# because F-Droid and the Android package manager order installs by it alone.
|
||||||
|
|
||||||
android.versionName = 0.35.0
|
android.versionName = 0.35.1
|
||||||
android.versionCode = 66
|
android.versionCode = 67
|
||||||
|
|
||||||
# No desktop builds exist yet. These lines are the agreed slots so a port starts
|
# No desktop builds exist yet. These lines are the agreed slots so a port starts
|
||||||
# with a version instead of inventing one; `-` means "not built on this
|
# with a version instead of inventing one; `-` means "not built on this
|
||||||
|
|||||||
Reference in New Issue
Block a user