Fix theme changes not reaching the panel; collapsible editor toolbar

The panel reads its colours when it BUILDS its views, so publishing a new
scheme changed nothing for a panel that was already open -- it kept the
colours it was born with, which is why switching theme appeared to do
nothing to it. It now rebuilds when the theme changes, keyed on the
user-facing switches rather than on the scheme object: the RGB mode produces
a new scheme every hue step, and tearing the panel down and back up sixty
times a cycle would be absurd.

The editor's auto-dock addressed the wrong half of the problem. Moving the
panel out of the way once a widget is selected cannot help you SELECT a
widget under the panel, because the obstruction happens before there is
anything to react to. The grip row now has a collapse toggle: one tap leaves
just the grip and uncovers everything beneath it, one tap brings the controls
back. Not persisted, and reset on leaving the editor -- it is a momentary
"let me see under this", and opening the editor to a panel with no controls
on it would look broken. Auto-dock stays; it still helps once a widget is
picked.

Device temperatures on the overlay now default ON, confirmed reading real
values. It sits with CPU/GPU load, the poll is one file read every couple of
seconds, and a device with no readable zone shows nothing rather than
something wrong.
This commit is contained in:
jpolo1224
2026-08-24 11:46:40 -04:00
parent d2a7613fb3
commit 484bd78b51
4 changed files with 43 additions and 3 deletions
@@ -119,12 +119,15 @@ object Thermals {
private val handler = android.os.Handler(android.os.Looper.getMainLooper())
private var feeding = false
val osdEnabled = androidx.compose.runtime.mutableStateOf(false)
// Default ON. It reads as a normal part of the perf overlay next to CPU/GPU load, the poll
// is one file read every couple of seconds, and a device with no readable zone shows nothing
// rather than something wrong -- so there is no device this is worse for.
val osdEnabled = androidx.compose.runtime.mutableStateOf(true)
fun loadOsdEnabled(context: Context) {
osdEnabled.value = runCatching {
com.armsx2.runtime.MainActivityRuntime.prefs.getBoolean(PREF_OSD, false)
}.getOrDefault(false)
com.armsx2.runtime.MainActivityRuntime.prefs.getBoolean(PREF_OSD, true)
}.getOrDefault(true)
applyOsd(context)
}
@@ -578,6 +578,18 @@ fun Armsx2Theme(content: @Composable () -> Unit) {
// RESOLVED scheme (rather than re-deriving it there) means the panel follows every mode,
// including MaterialYou, Custom, OLED and the animated RGB one, for free.
ThemeBridge.scheme = resolved
// The second-screen panel reads these colours when it BUILDS its views, so publishing a new
// scheme is not enough on its own -- an already-open panel keeps the colours it was born
// with, which is why changing theme appeared to do nothing to it. Keyed on the user-facing
// switches rather than on the scheme object: the RGB mode produces a new scheme every hue
// step, and tearing the panel down and back up sixty times a cycle would be absurd.
androidx.compose.runtime.LaunchedEffect(
ThemePreferences.mode.value,
ThemePreferences.oledBase.value,
ThemePreferences.customColor.value,
) {
runCatching { com.armsx2.SecondScreen.rebuild() }
}
MaterialTheme(
colorScheme = resolved,
typography = ArmsTypography,
@@ -104,6 +104,9 @@ object TouchControls {
* No-op if the VM isn't paused. */
fun exitEditMode() {
editMode.value = false
// Next time the editor opens it should have its controls, not the collapsed grip the
// user happened to leave behind.
editorCollapsed.value = false
if (MainActivityRuntime.eState.value == EmuState.PAUSED) MainActivityRuntime.resume()
}
@@ -114,6 +117,20 @@ object TouchControls {
* backdrop to deselect. */
val selectedButton = mutableStateOf<TouchButtonId?>(null)
/**
* Editor panel collapsed to just its grip.
*
* The panel covers a real part of the screen, and to select a widget under it you have to
* touch that widget first -- which the panel is in the way of. Moving it out of the way
* REACTIVELY cannot help with that, because the obstruction happens before there is anything
* to react to. This is the way out that does not involve dragging: one tap uncovers
* everything, one tap brings the controls back.
*
* Not persisted. It is a momentary "let me see under this", and a session that opened the
* editor to a panel with no controls on it would look broken.
*/
val editorCollapsed = mutableStateOf(false)
/** Profile picker / save-as dialog shown over the editor. */
val profileDialogOpen = mutableStateOf(false)
@@ -1936,6 +1936,11 @@ private fun EditToolbar(modifier: Modifier = Modifier) {
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalAlignment = Alignment.CenterVertically,
) {
// Collapse/expand. First control in the row so it is in the same place whether the
// panel is open or shut.
PanelSizeButton(if (TouchControls.editorCollapsed.value) "" else "") {
TouchControls.editorCollapsed.value = !TouchControls.editorCollapsed.value
}
PanelSizeButton("") {
val ls = OverlayDims.last?.let { it.widthPx > it.heightPx } ?: true
TouchControls.editorPanelScale(ls).floatValue =
@@ -1981,6 +1986,9 @@ private fun EditToolbar(modifier: Modifier = Modifier) {
(TouchControls.editorPanelScale(ls).floatValue + 0.1f).coerceIn(0.6f, 1.35f)
}
}
// Collapsed = grip row only, so everything under the panel is reachable. Column is an
// inline composable, so an early return here really does skip the rest of the content.
if (TouchControls.editorCollapsed.value) return@Column
// Scope hint: with no game running the editor edits the GLOBAL Default
// layout (per-game layouts need a running disc).
Text(