feat(ui): Add dedicated Frame Generation tab and better engine selection ( left side menu ) (#3549)

* feat(ui): add dedicated frame generation drawer tab

* fix(ui): keep frame limit label in display settings

* fix(ui): focus display controls on a stable setting

* feat(ui): simplify frame generation engine and multiplier selection

* chore(ui): clean up frame generation selector imports

* fix(ui): restore controller support in frame generation menu

* refactor(ui): keep frame generation controls always visible

* refactor(ui): show frame generation controls inline

* chore(ui): remove obsolete frame generation focus import

* fix(ui): register frame generation engine focus

* fix(ui): remove obsolete frame generation menu host

* fix(ui): update frame generation menu call sites

* fix(ui): stack frame generation controls and restore focus

* fix(ui): gate legacy frame generation card menu

* fix(ui): gate legacy frame generation sheet menu

* Fix FrameGenMenu call signature

* Show frame generation controls only when opened

* ci: trigger checks

* feat(ui): add always-visible frame generation off option

* feat(ui): keep frame generation controls visible

* feat(ui): add custom frame generation vector icon

* feat(ui): use custom icon for frame generation tab

* fix(ui): restore adaptive LSFG target picker

* fix(ui): remove excess top spacing in frame generation menu

* Fix FrameGenMenu disabled-state handling

* Format FrameGenMenu multiplier row

* Add tighter Frame Generation control spacing

* Tighten Frame Generation drawer spacing

* Replace Frame Generation icon with new vector

* Keep legacy Frame Generation buttons available

* Use legacy Frame Generation buttons outside drawer

* chore: trigger CI
This commit is contained in:
LunaDL authored and GitHub committed 2026-12-02 14:32:24 -05:00
1 parent 6d78142a67
commit 90c7dece92
8 files changed
+198 -52

No files matched your search

@@ -1,52 +1,171 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.droiddeck.launcher.R
import com.droiddeck.launcher.gpu.FrameGen
import com.droiddeck.launcher.gpu.Lossless
@Composable
internal fun FrameGenMenu(
host: MenuHost, mode: FrameGen.Mode, lossless: Lossless.State,
mode: FrameGen.Mode,
lossless: Lossless.State,
onPick: (FrameGen.Mode) -> Unit,
onImportLossless: () -> Unit,
gameProfileId: String? = null,
hasGameOverride: Boolean = false,
onResetGame: () -> Unit = {},
focusModifier: Modifier = Modifier,
legacyButtons: Boolean = false,
) {
val context = LocalContext.current
AnchoredMenu(host.open == "fg", onDismiss = { if (host.open == "fg") host.open = null }, title = stringResource(R.string.frame_gen_title)) { firstItemFocus ->
val need = when {
lossless.ready -> null
lossless.owned -> stringResource(R.string.lsfg_needs_install)
else -> stringResource(R.string.lsfg_needs_steam)
}
@Composable
fun item(m: FrameGen.Mode, enabled: Boolean = true, detail: String? = null, focus: FocusRequester? = null) =
MenuItem(FrameGen.label(context, m), checked = mode == m, enabled = enabled, detail = detail, focusRequester = focus) {
onPick(m); host.open = null
val need = when {
lossless.ready -> null
lossless.owned -> stringResource(R.string.lsfg_needs_install)
else -> stringResource(R.string.lsfg_needs_steam)
}
val selectedEngine = mode.engine.takeIf { it != FrameGen.ENGINE_OFF }
val offLabel = FrameGen.label(LocalContext.current, FrameGen.Mode.OFF)
val colors = MaterialTheme.colorScheme
val engines = listOf(FrameGen.ENGINE_LSFG to "LSFG", FrameGen.ENGINE_DDFG to "DDFG")
Column(Modifier.fillMaxWidth().padding(start = 10.dp, end = 10.dp, top = 0.dp, bottom = 8.dp)) {
if (!legacyButtons) OutlinedButton(
onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) },
modifier = Modifier.fillMaxWidth().controllerConfirm(
onClick = { onPick(FrameGen.Mode.OFF.copy(multiplier = mode.multiplier)) },
),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
colors = ButtonDefaults.outlinedButtonColors(
containerColor = if (selectedEngine == null) colors.primary.copy(alpha = 0.16f) else colors.surface,
contentColor = if (selectedEngine == null) colors.primary else colors.onSurface,
),
) { Text(offLabel) }
Row(Modifier.fillMaxWidth().then(if (legacyButtons) Modifier else Modifier.padding(top = 8.dp)), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
val focusIndex = engines.indexOfFirst { (engine, _) ->
selectedEngine == engine || engine != FrameGen.ENGINE_LSFG || lossless.ready
}
item(FrameGen.Mode.OFF, focus = firstItemFocus)
engines.forEachIndexed { index, (engine, label) ->
val selected = selectedEngine == engine
val enabled = selected || engine != FrameGen.ENGINE_LSFG || lossless.ready
val pick = {
onPick(if (selected) FrameGen.Mode.OFF.copy(multiplier = mode.multiplier) else FrameGen.Mode(engine, mode.multiplier.coerceIn(2, 4)))
}
OutlinedButton(
onClick = pick,
enabled = enabled,
modifier = (if (index == focusIndex) focusModifier else Modifier)
.weight(1f).controllerConfirm(enabled = enabled, onClick = pick),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
colors = ButtonDefaults.outlinedButtonColors(
containerColor = if (selected) colors.primary.copy(alpha = 0.16f) else colors.surface,
contentColor = if (selected) colors.primary else colors.onSurface,
),
) { Text(label) }
}
}
if (selectedEngine != null) {
val multiplierEnabled = mode.engine != FrameGen.ENGINE_LSFG || lossless.ready
Row(
Modifier.fillMaxWidth().padding(top = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
(2..4).forEach { multiplier ->
val selected = mode.multiplier == multiplier && mode.target == 0
val pickMultiplier = {
onPick(mode.copy(multiplier = multiplier, target = 0))
}
OutlinedButton(
onClick = pickMultiplier,
enabled = multiplierEnabled,
modifier = Modifier.weight(1f).controllerConfirm(
enabled = multiplierEnabled,
onClick = pickMultiplier,
),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
colors = ButtonDefaults.outlinedButtonColors(
containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface,
contentColor = if (selected) colors.secondary else colors.onSurface,
),
) { Text("${multiplier}×") }
}
}
}
if (selectedEngine == FrameGen.ENGINE_LSFG) {
Row(
Modifier.fillMaxWidth().padding(top = 8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
FrameGen.ADAPTIVE_TARGETS.forEach { target ->
val adaptiveMode = FrameGen.Mode(FrameGen.ENGINE_LSFG, target = target)
val selected = mode.target == target
val pickTarget = { onPick(adaptiveMode) }
OutlinedButton(
onClick = pickTarget,
enabled = lossless.ready,
modifier = Modifier.weight(1f).controllerConfirm(
enabled = lossless.ready,
onClick = pickTarget,
),
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 8.dp),
colors = ButtonDefaults.outlinedButtonColors(
containerColor = if (selected) colors.secondary.copy(alpha = 0.18f) else colors.surface,
contentColor = if (selected) colors.secondary else colors.onSurface,
),
) {
Text(FrameGen.label(LocalContext.current, adaptiveMode))
}
}
}
}
if (selectedEngine == FrameGen.ENGINE_LSFG && !lossless.ready) {
Text(need.orEmpty(), color = colors.onSurfaceVariant,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.padding(top = 6.dp))
}
if (gameProfileId != null) {
MenuItem(stringResource(R.string.comp_game_use_general), checked = !hasGameOverride) {
onResetGame()
host.open = null
val resetGame = onResetGame
OutlinedButton(
onClick = resetGame,
modifier = Modifier.fillMaxWidth().padding(top = 8.dp)
.controllerConfirm(onClick = resetGame),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
) {
Text(stringResource(R.string.comp_game_use_general) + if (hasGameOverride) "" else " ✓")
}
}
for (m in 2..4) item(FrameGen.Mode(FrameGen.ENGINE_DDFG, m))
val lsfg = (2..4).map { FrameGen.Mode(FrameGen.ENGINE_LSFG, it) } +
FrameGen.ADAPTIVE_TARGETS.map { FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it) }
lsfg.forEachIndexed { i, m -> item(m, enabled = lossless.ready, detail = need.takeIf { i == 0 }) }
if (lossless.owned) {
val using = when (lossless.source) {
Lossless.Source.STEAM -> stringResource(R.string.lsfg_using_steam)
Lossless.Source.IMPORT -> stringResource(R.string.lsfg_using_import)
Lossless.Source.NONE -> null
}
MenuItem(stringResource(R.string.lsfg_import), checked = false, detail = using) { host.open = null; onImportLossless() }
OutlinedButton(
onClick = onImportLossless,
modifier = Modifier.fillMaxWidth().padding(top = 8.dp)
.controllerConfirm(onClick = onImportLossless),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
) {
Text(stringResource(R.string.lsfg_import) + (using?.let { " · $it" } ?: ""))
}
}
}
}
@@ -830,7 +830,7 @@ internal fun ReadinessCard(
@Composable
private fun FrameGenMenu(s: FrontEndState, a: FrontEndActions, host: MenuHost) {
FrameGenMenu(host, s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless)
FrameGenMenu(s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless, legacyButtons = true)
}
@Composable
@@ -878,8 +878,7 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
) {
host.open = if (host.open == "fg") null else "fg"
}
FrameGenMenu(
host = host,
if (host.open == "fg") FrameGenMenu(
mode = if (frameGenProfileKey != null) gameFrameGenMode else s.frameGen,
lossless = s.lossless,
onPick = { mode ->
@@ -893,6 +892,7 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost
}
},
onImportLossless = a.onImportLossless,
legacyButtons = true,
gameProfileId = frameGenProfileKey,
hasGameOverride = gameFrameGenOverride,
onResetGame = {
@@ -10,6 +10,7 @@ import com.droiddeck.launcher.session.SessionPrefs
internal enum class SessionDrawerPage(val firstControl: String) {
CONTROLLER("section-controller-input"),
HUD("section-performance-pacing"),
FRAMEGEN("fg"),
DISPLAY("section-display"),
EFFECTS("section-effects-look"),
GAMES("section-game-profile"),
@@ -96,6 +96,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.unit.Dp
import androidx.compose.runtime.rememberUpdatedState
@@ -153,6 +154,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.platform.LocalContext
import com.droiddeck.launcher.R
import com.droiddeck.launcher.core.FexPreset
@@ -178,6 +180,7 @@ internal val SessionDrawerPage.title: Int get() = when (this) {
SessionDrawerPage.CONTROLLER -> R.string.drawer_page_controller
SessionDrawerPage.DISPLAY -> R.string.drawer_page_display
SessionDrawerPage.HUD -> R.string.drawer_page_performance
SessionDrawerPage.FRAMEGEN -> R.string.frame_gen_title
SessionDrawerPage.VR -> R.string.drawer_page_vr
SessionDrawerPage.EFFECTS -> R.string.drawer_page_effects
SessionDrawerPage.GAMES -> R.string.drawer_page_game
@@ -191,6 +194,7 @@ internal val SessionDrawerPage.icon get() = when (this) {
SessionDrawerPage.CONTROLLER -> Icons.Outlined.SportsEsports
SessionDrawerPage.DISPLAY -> Icons.Outlined.DesktopWindows
SessionDrawerPage.HUD -> Icons.Outlined.Speed
SessionDrawerPage.FRAMEGEN -> Icons.Outlined.Layers
SessionDrawerPage.VR -> VrHeadsetIcon
SessionDrawerPage.EFFECTS -> Icons.Outlined.AutoFixHigh
SessionDrawerPage.GAMES -> Icons.Outlined.Layers
@@ -649,6 +653,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
when (page) {
SessionDrawerPage.CONTROLLER -> DrawerControllerPage(host, a, a.controllerConnected || controllerActive, track)
SessionDrawerPage.HUD -> DrawerPerformancePage(host, a, track)
SessionDrawerPage.FRAMEGEN -> DrawerFrameGenPage(host, a, track)
SessionDrawerPage.DISPLAY -> DrawerDisplayPage(host, a, track)
SessionDrawerPage.EFFECTS -> ScreenEffectsGroup(host, a, track)
SessionDrawerPage.GAMES -> DrawerGamePage(host, a, track)
@@ -862,27 +867,8 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
@Composable
private fun DrawerPerformancePage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val offLabel = stringResource(R.string.frame_gen_off)
val fgLabel = FrameGen.label(LocalContext.current, a.frameGen)
val limit = if (a.direct && a.fpsLimit > 0) "${stringResource(R.string.drawer_frame_limit)} ${a.fpsLimit}" else null
SettingsGroup(stringResource(R.string.drawer_section_pacing), key = "performance-pacing", detail = summary(fgLabel, limit)) {
val fgOpen = host.open == "fg"
SettingsRow(
stringResource(R.string.frame_gen_title),
if (a.frameGenTargetGameId != null)
"${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}"
else stringResource(R.string.frame_gen_scope_global),
highlighted = fgOpen,
) {
Box {
ValueChip(fgLabel, fgOpen, modifier = track("fg")) { host.open = if (fgOpen) null else "fg" }
FrameGenMenu(
host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless,
gameProfileId = a.frameGenTargetGameId,
hasGameOverride = a.hasGameOverride,
onResetGame = a.onFrameGenReset,
)
}
}
SettingsGroup(stringResource(R.string.drawer_section_pacing), key = "performance-pacing", detail = summary(limit)) {
if (a.direct) SliderRow(
stringResource(R.string.drawer_frame_limit), stringResource(R.string.drawer_frame_limit_note),
a.fpsLimit.takeIf { it > 0 } ?: SessionPrefs.FPS_LIMIT_OFF,
@@ -908,6 +894,28 @@ private fun DrawerPerformancePage(host: MenuHost, a: DrawerActions, track: (Stri
DroidDeckHudSettings(host, a, track)
}
@Composable
private fun DrawerFrameGenPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val fgLabel = FrameGen.label(LocalContext.current, a.frameGen)
val scope = if (a.frameGenTargetGameId != null)
"${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}"
else stringResource(R.string.frame_gen_scope_global)
SettingsGroup(stringResource(R.string.frame_gen_title), compact = true, key = "frame-generation", detail = summary(fgLabel, scope)) {
SettingsRow(stringResource(R.string.frame_gen_title), scope, stacked = true, tightControlSpacing = true) {
FrameGenMenu(
a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless,
gameProfileId = a.frameGenTargetGameId,
hasGameOverride = a.hasGameOverride,
onResetGame = a.onFrameGenReset,
)
}
}
}
@Composable
private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val orientations = SessionPrefs.orientationOptions.map { (value, label) -> value to stringResource(label) }
@@ -1216,7 +1224,16 @@ private fun DrawerPageTabs(page: SessionDrawerPage, pages: List<SessionDrawerPag
.selectable(selected = selected, role = androidx.compose.ui.semantics.Role.Tab, interactionSource = source, indication = LocalIndication.current, onClick = select)
.controllerConfirm(onClick = select),
) {
Icon(item.icon, contentDescription = null, tint = tint, modifier = Modifier.size(if (compact) 22.dp else 30.dp))
if (item == SessionDrawerPage.FRAMEGEN) {
Icon(
imageVector = ImageVector.vectorResource(R.drawable.ic_frame_generation),
contentDescription = null,
tint = tint,
modifier = Modifier.size(if (compact) 22.dp else 30.dp),
)
} else {
Icon(item.icon, contentDescription = null, tint = tint, modifier = Modifier.size(if (compact) 22.dp else 30.dp))
}
}
}
}
@@ -466,7 +466,7 @@ fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = nul
}
@Composable
fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, control: @Composable () -> Unit) {
fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, tightControlSpacing: Boolean = false, control: @Composable () -> Unit) {
val compact = LocalCompactSettings.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
@@ -488,13 +488,13 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint
} else if (stacked || LocalNarrowPane.current) Column(
modifier = Modifier.fillMaxWidth().background(bg).padding(
horizontal = if (compact) 10.dp else 14.dp,
vertical = if (compact) 6.dp else 12.dp),
vertical = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 12.dp),
) {
Text(label, fontSize = if (compact) 13.sp else 15.sp,
lineHeight = if (compact) 16.sp else androidx.compose.ui.unit.TextUnit.Unspecified,
fontWeight = FontWeight.SemiBold, color = colors.onBackground)
if (hint != null || hintLines != null) hintText(if (compact) 11.sp else 13.sp)
Box(Modifier.padding(top = if (compact) 6.dp else 8.dp)) { control() }
Box(Modifier.padding(top = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 8.dp)) { control() }
} else Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().background(bg).padding(horizontal = 14.dp, vertical = 11.dp),
@@ -13,7 +13,7 @@ internal fun FrameGenGroup(s: FrontEndState, a: FrontEndActions) {
SettingsRow(stringResource(R.string.frame_gen_title), stringResource(R.string.frame_gen_hint), highlighted = host.open == "fg") {
Box {
ValueChip(s.frameGenLabel, host.open == "fg") { host.open = if (host.open == "fg") null else "fg" }
FrameGenMenu(host, s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless)
if (host.open == "fg") FrameGenMenu(s.frameGen, s.lossless, a.onFrameGenPick, a.onImportLossless)
}
}
}