feat(ui): one screen picker replaces the D button and the Second screen tab (#2912)

* feat(ui): one screen picker replaces the D button and the Second screen tab

The bottom screen's bar showed the panel's name as plain text, a D
button opened the menu, and the menu's Second screen tab picked the
panel. Now the panel's name is a dropdown right of the X. It lists
"DroidDeck menu" first, then the panels, with a check on the one in
use, so switching panels takes two taps instead of three.

The docked menu's header shows the same dropdown, labelled
"DroidDeck menu", in place of the highlighted D button. Opened there,
focus starts on the last panel, so one press of A goes back to it.
When the menu is on the top screen, the dropdown lists None and the
panels without the menu entry.

The Second screen tab is gone. Its "Show the game on" and display
choices are a Second screen group at the end of the Display tab. The
mode list's hint and its Mode heading are removed with their strings.

Previews of the docked menu (Controller and Display) and of a panel's
bar are added to the rendered preview cases.

* feat(ui): the swap button on the Keyboard + trackpad and Terminal panels

Every bottom-screen panel now has the swap button when the game can move
to the bottom screen; it was only on Deck grips, Profile controls,
Dashboard and Desktop. The swapped top-screen view already shows both
panels.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-20 00:26:28 -05:00
1 parent 5051fc8b32
commit fccd13689c
79 files changed
+314 -167

No files matched your search

@@ -1759,10 +1759,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
onFexPreset = { v -> SessionPrefs.setFexPreset(this@SessionActivity, v); readPrefs() },
onSecondScreenMode = { mode ->
if (docked) drawerOpen = false
typingReturnMode = null
automaticPanel = false
if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this@SessionActivity, desktopSession, mode.id)
selectSecondScreenMode(mode)
pickSecondScreenMode(mode)
},
onSecondScreenDisplay = ::selectSecondScreenDisplay,
onLaunchAndroidApp = { app, displayId ->
@@ -3497,7 +3494,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (drawerOpen) {
if (fromController && (event.keyCode == KeyEvent.KEYCODE_BUTTON_L1 || event.keyCode == KeyEvent.KEYCODE_BUTTON_R1)) {
if (event.action == KeyEvent.ACTION_DOWN && event.repeatCount == 0) {
drawerPage = sessionDrawerPages(secondScreenDisplays.isNotEmpty(), glasses.present)
drawerPage = sessionDrawerPages(glasses.present)
.step(drawerPage, if (event.keyCode == KeyEvent.KEYCODE_BUTTON_R1) 1 else -1)
releaseDrawerDirection()
}
@@ -4232,6 +4229,19 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
}
private fun pickSecondScreenMode(mode: SecondScreenMode) {
typingReturnMode = null
automaticPanel = false
if (mode != SecondScreenMode.NONE) SessionPrefs.setSecondScreenPanel(this, desktopSession, mode.id)
selectSecondScreenMode(mode)
}
private fun bottomScreenPicker(mode: SecondScreenMode) = com.droiddeck.launcher.ui.ScreenPicker(
com.droiddeck.launcher.ui.secondScreenModes(false, SessionState.deckPad, bottomPages().isNotEmpty(),
com.droiddeck.launcher.session.BottomDesktop.available()),
mode, ::pickSecondScreenMode, onMenu = { drawerOpen = true },
)
private fun secondScreenPresentation(target: Display) = SecondScreenPresentation(
this, target,
onSteamMenu = ::tapSteamButton,
@@ -4240,6 +4250,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
pad = padBridge,
onKeyboardClosed = ::bottomKeyboardClosed,
onMenu = { drawerOpen = true },
picker = ::bottomScreenPicker,
onMenuTouched = {
if (drawerPinned) {
drawerPinned = false
@@ -38,6 +38,7 @@ class BottomDesktopPanel(
steamButtons: Pair<() -> Unit, () -> Unit>?,
onSwap: (() -> Unit)? = null,
private val fullResolution: Boolean = false,
picker: (() -> ScreenPicker?)? = null,
) : LinearLayout(context), SurfaceHolder.Callback {
private lateinit var surfaceView: SurfaceView
private val area = FrameLayout(context).apply { clipChildren = true }
@@ -67,7 +68,7 @@ class BottomDesktopPanel(
setBackgroundColor(Color.BLACK)
isFocusable = true
isFocusableInTouchMode = true
addView(bar(onClose, onMenu, steamButtons, onSwap), LayoutParams(-1, -2))
addView(bar(onClose, onMenu, steamButtons, onSwap, picker), LayoutParams(-1, -2))
area.addView(keyboardHost)
addSurface()
area.addView(status, FrameLayout.LayoutParams(-1, -1))
@@ -84,7 +85,8 @@ class BottomDesktopPanel(
area.addView(surfaceView, 1, FrameLayout.LayoutParams(fullWidth.takeIf { it > 0 } ?: -1, fullHeight.takeIf { it > 0 } ?: -1))
}
private fun bar(onClose: (() -> Unit)?, onMenu: (() -> Unit)?, steamButtons: Pair<() -> Unit, () -> Unit>?, onSwap: (() -> Unit)?): View =
private fun bar(onClose: (() -> Unit)?, onMenu: (() -> Unit)?, steamButtons: Pair<() -> Unit, () -> Unit>?, onSwap: (() -> Unit)?,
picker: (() -> ScreenPicker?)?): View =
bottomScreenBarView(context) {
val touch = touchMode.value
BottomBarModel(
@@ -97,6 +99,7 @@ class BottomDesktopPanel(
BarExtra(context.getString(R.string.second_show_keyboard), icon = R.drawable.ic_bottom_keyboard) { keyboardHost.toggle() },
onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, onClick = it) },
),
picker = picker?.invoke(),
)
}
@@ -24,12 +24,24 @@ import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Close
import androidx.compose.material.icons.outlined.Dashboard
import androidx.compose.material.icons.outlined.DesktopAccessDisabled
import androidx.compose.material.icons.outlined.DesktopWindows
import androidx.compose.material.icons.outlined.ExpandLess
import androidx.compose.material.icons.outlined.ExpandMore
import androidx.compose.material.icons.outlined.Keyboard
import androidx.compose.material.icons.outlined.MoreHoriz
import androidx.compose.material.icons.outlined.SportsEsports
import androidx.compose.material.icons.outlined.Terminal
import androidx.compose.material.icons.outlined.Tune
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.foundation.rememberScrollState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@@ -49,6 +61,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.R
import com.droiddeck.launcher.input.DeckPanel
import com.droiddeck.launcher.input.SecondScreenMode
import com.droiddeck.launcher.session.SessionService
import com.droiddeck.launcher.session.SessionState
@@ -61,6 +74,15 @@ internal class BarExtra(
val onClick: () -> Unit,
)
/** What the bottom screen shows: the DroidDeck menu or one of the panels, picked from the bar's dropdown. */
class ScreenPicker(
val modes: List<SecondScreenMode>,
val current: SecondScreenMode,
val onPick: (SecondScreenMode) -> Unit,
val onMenu: (() -> Unit)? = null,
val menuShown: Boolean = false,
)
internal class BarTabs(val labels: List<String>, val selected: Int, val onSelect: (Int) -> Unit)
internal class BottomBarModel(
@@ -72,6 +94,7 @@ internal class BottomBarModel(
val extras: List<BarExtra> = emptyList(),
val menuActive: Boolean = false,
val tabs: BarTabs? = null,
val picker: ScreenPicker? = null,
)
@Composable
@@ -89,9 +112,15 @@ internal fun BottomScreenBar(model: BottomBarModel, modifier: Modifier = Modifie
private fun BarRow(model: BottomBarModel, modifier: Modifier = Modifier) {
val colors = MaterialTheme.colorScheme
BoxWithConstraints(modifier.fillMaxWidth().height(BAR_HEIGHT).blockTouches()) {
val buttons = listOfNotNull(model.onClose, model.onMenu, model.onQam).size + model.extras.size
val picker = model.picker
val onMenu = model.onMenu.takeIf { picker == null }
val buttons = listOfNotNull(model.onClose, onMenu, model.onQam).size + model.extras.size
val steamWidth = if (model.onSteam != null) STEAM_WIDTH + BAR_GAP else 0.dp
val titleWidth = if (model.title != null) MIN_TITLE + BAR_GAP else 0.dp
val titleWidth = when {
picker != null -> PICKER_WIDTH + BAR_GAP
model.title != null -> MIN_TITLE + BAR_GAP
else -> 0.dp
}
val needed = BAR_PAD * 2 + BUTTON * buttons + BAR_GAP * (buttons - 1).coerceAtLeast(0) + steamWidth + titleWidth
val fits = maxWidth >= needed
Row(
@@ -103,7 +132,9 @@ private fun BarRow(model: BottomBarModel, modifier: Modifier = Modifier) {
model.onClose?.let {
BarButton(stringResource(R.string.common_close), Modifier.testTag("bottom-bar-close"), vector = Icons.Outlined.Close, onClick = it)
}
if (model.title != null) Text(
if (picker != null) Box(if (fits) Modifier.weight(1f) else Modifier) {
ScreenPickerChip(picker, Modifier.testTag("bottom-bar-screen"))
} else if (model.title != null) Text(
model.title, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = colors.onSurfaceVariant,
maxLines = 1, overflow = TextOverflow.Ellipsis,
modifier = (if (fits) Modifier.weight(1f) else Modifier).padding(start = 4.dp),
@@ -112,7 +143,7 @@ private fun BarRow(model: BottomBarModel, modifier: Modifier = Modifier) {
BarButton(extra.description, extra.tag?.let { Modifier.testTag(it) } ?: Modifier, icon = extra.icon, vector = extra.vector,
active = extra.active, onClick = extra.onClick)
}
BarActions(model.onMenu, model.menuActive, model.onSteam, model.onQam)
BarActions(onMenu, model.menuActive, model.onSteam, model.onQam)
}
}
}
@@ -197,12 +228,94 @@ internal fun BarButton(
}
}
internal val SecondScreenMode.icon: ImageVector get() = when (this) {
SecondScreenMode.NONE -> Icons.Outlined.DesktopAccessDisabled
SecondScreenMode.KEYBOARD_TRACKPAD -> Icons.Outlined.Keyboard
SecondScreenMode.TERMINAL -> Icons.Outlined.Terminal
SecondScreenMode.DECK_CONTROLS -> Icons.Outlined.SportsEsports
SecondScreenMode.CUSTOM_CONTROLS -> Icons.Outlined.Tune
SecondScreenMode.DASHBOARD -> Icons.Outlined.Dashboard
SecondScreenMode.DESKTOP -> Icons.Outlined.DesktopWindows
}
@Composable
internal fun ScreenPickerChip(picker: ScreenPicker, modifier: Modifier = Modifier) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
var open by remember { mutableStateOf(false) }
val source = remember { MutableInteractionSource() }
val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value
val shape = RoundedCornerShape(22.dp)
val label = if (picker.menuShown) stringResource(R.string.touch_droiddeck_menu) else stringResource(picker.current.label)
val description = stringResource(R.string.screen_picker_description, label)
val toggle = { open = !open }
Box(modifier) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.height(44.dp).widthIn(max = PICKER_MAX_WIDTH)
.semantics { contentDescription = description }
.clip(shape).background(if (hot || open) pal.signal.copy(alpha = 0.14f) else colors.surfaceVariant)
.glideBorder(hot || open, shape, pal.signal, pal.line2)
.hoverable(source)
.clickable(role = Role.Button, interactionSource = source, indication = LocalIndication.current, onClick = toggle)
.controllerConfirm(onClick = toggle)
.padding(start = 14.dp, end = 10.dp),
) {
if (picker.menuShown) Icon(painterResource(R.drawable.ic_stat_session), contentDescription = null, tint = colors.onBackground,
modifier = Modifier.size(18.dp))
else Icon(picker.current.icon, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(18.dp))
Text(label, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, maxLines = 1,
overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
Icon(if (open) Icons.Outlined.ExpandLess else Icons.Outlined.ExpandMore, contentDescription = null,
tint = colors.onSurfaceVariant, modifier = Modifier.size(20.dp))
}
ScreenPickerMenu(picker, open) { open = false }
}
}
/** On a panel, focus starts on the menu entry; from the menu (or with no menu entry), on the panel in use. */
internal fun ScreenPicker.focusTarget(): SecondScreenMode? =
if (onMenu != null && !menuShown) null else current.takeIf { it in modes } ?: modes.firstOrNull()
@Composable
private fun ScreenPickerMenu(picker: ScreenPicker, open: Boolean, dismiss: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val target = picker.focusTarget()
AnchoredMenu(open, dismiss, compact = true, minWidth = 240.dp) { first ->
picker.onMenu?.let { menu ->
MenuItem(
stringResource(R.string.touch_droiddeck_menu), checked = picker.menuShown,
leading = { Icon(painterResource(R.drawable.ic_stat_session), contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(18.dp)) },
focusRequester = first.takeIf { target == null }, modifier = Modifier.testTag("screen-picker-menu"),
) { dismiss(); menu() }
Box(Modifier.fillMaxWidth().padding(vertical = 4.dp).height(1.dp).background(pal.line))
Text(
stringResource(R.string.drawer_second_screen).uppercase(), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 1.5.sp,
color = colors.onSurfaceVariant, modifier = Modifier.padding(start = 10.dp, top = 6.dp, bottom = 4.dp),
)
}
picker.modes.forEach { mode ->
val current = mode == picker.current
MenuItem(
stringResource(mode.label), checked = current && !picker.menuShown,
detail = if (current && picker.menuShown) stringResource(R.string.screen_picker_last_used) else null,
leading = { Icon(mode.icon, contentDescription = null, tint = colors.onBackground, modifier = Modifier.size(18.dp)) },
focusRequester = first.takeIf { mode == target }, modifier = Modifier.testTag("screen-picker:${mode.id}"),
) { dismiss(); picker.onPick(mode) }
}
}
}
internal val BAR_HEIGHT = 64.dp
private val BAR_PAD = 12.dp
private val BAR_GAP = 8.dp
private val BUTTON = 44.dp
private val STEAM_WIDTH = 80.dp
private val MIN_TITLE = 72.dp
private val PICKER_WIDTH = 180.dp
private val PICKER_MAX_WIDTH = 240.dp
internal fun sessionBarModel(
title: String?,
@@ -212,9 +325,10 @@ internal fun sessionBarModel(
onQam: () -> Unit,
extras: List<BarExtra> = emptyList(),
tabs: BarTabs? = null,
picker: ScreenPicker? = null,
): BottomBarModel {
val steam = SessionState.mode == SessionService.MODE_STEAM
return BottomBarModel(title, onClose, onMenu, onSteam.takeIf { steam }, onQam.takeIf { steam }, extras, tabs = tabs)
return BottomBarModel(title, onClose, onMenu, onSteam.takeIf { steam }, onQam.takeIf { steam }, extras, tabs = tabs, picker = picker)
}
internal fun deckPanelTabs(context: Context, selected: DeckPanel, onSelect: (DeckPanel) -> Unit) =
@@ -175,7 +175,7 @@ internal fun SessionDrawerPreview(secondScreens: List<SecondScreenDisplay>) {
val code = e.nativeKeyEvent.keyCode
if (code != android.view.KeyEvent.KEYCODE_BUTTON_L1 && code != android.view.KeyEvent.KEYCODE_BUTTON_R1) return@onPreviewKeyEvent false
if (e.type == KeyEventType.KeyDown && e.nativeKeyEvent.repeatCount == 0) {
page = sessionDrawerPages(secondScreens.isNotEmpty()).step(page, if (code == android.view.KeyEvent.KEYCODE_BUTTON_R1) 1 else -1)
page = sessionDrawerPages().step(page, if (code == android.view.KeyEvent.KEYCODE_BUTTON_R1) 1 else -1)
}
true
}
@@ -42,6 +42,7 @@ class SecondScreenPresentation(
private val onSwap: (() -> Unit)? = null,
private val onMenuTouched: () -> Unit = {},
private val onDeckPanel: (DeckPanel) -> Unit = { SessionPrefs.setDeckPanel(sessionActivity, it) },
private val picker: ((SecondScreenMode) -> ScreenPicker?)? = null,
) : Presentation(sessionActivity, display) {
private val frame = FrameLayout(context)
private var menuView: androidx.compose.ui.platform.ComposeView? = null
@@ -301,7 +302,8 @@ class SecondScreenPresentation(
SecondScreenMode.DASHBOARD -> renderDashboard()
SecondScreenMode.DESKTOP -> {
root.addView(BottomDesktopPanel(context, onClose, onMenu,
(onSteamMenu to onQam).takeIf { SessionState.mode == SessionService.MODE_STEAM }, onSwap), weightParams())
(onSteamMenu to onQam).takeIf { SessionState.mode == SessionService.MODE_STEAM }, onSwap,
picker = picker?.let { pick -> { pick(SecondScreenMode.DESKTOP) } }), weightParams())
}
SecondScreenMode.NONE -> Unit
}
@@ -318,15 +320,15 @@ class SecondScreenPresentation(
internal fun barModel(mode: SecondScreenMode): BottomBarModel? {
val swap = listOfNotNull(onSwap?.let { BarExtra(context.getString(R.string.swap_screens), icon = R.drawable.ic_bottom_swap, tag = "bottom-swap", onClick = it) })
fun model(extras: List<BarExtra>, tabs: BarTabs? = null) =
sessionBarModel(context.getString(mode.label), onClose, onMenu, onSteamMenu, onQam, extras, tabs)
sessionBarModel(context.getString(mode.label), onClose, onMenu, onSteamMenu, onQam, extras, tabs, picker?.invoke(mode))
return when (mode) {
SecondScreenMode.KEYBOARD_TRACKPAD -> model(listOf(BarExtra(
context.getString(if (keyboardShown.value) R.string.second_hide_keyboard else R.string.second_show_keyboard),
icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }))
icon = R.drawable.ic_bottom_keyboard, active = keyboardShown.value, tag = "bottom-keyboard") { showKeyboard() }) + swap)
SecondScreenMode.DECK_CONTROLS -> model(swap, deckPanelTabs(context, deckPanel.value, ::selectDeckPanel))
SecondScreenMode.DASHBOARD, SecondScreenMode.CUSTOM_CONTROLS -> model(swap)
SecondScreenMode.TERMINAL -> model(listOf(BarExtra(context.getString(R.string.drawer_keyboard), icon = R.drawable.ic_bottom_keyboard,
tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }))
tag = "bottom-keyboard") { terminalPanel?.showKeyboard() }) + swap)
else -> null
}
}
@@ -3,7 +3,6 @@ package com.droiddeck.launcher.ui
internal enum class SessionDrawerPage(val firstControl: String) {
CONTROLLER("input-profile"),
GLASSES("glasses-game"),
SECOND_SCREEN("second-screen:custom-controls"),
DISPLAY("fg"),
HUD("hud"),
EFFECTS("look"),
@@ -14,10 +13,10 @@ internal enum class SessionDrawerPage(val firstControl: String) {
}
internal fun sessionDrawerPages(
hasSecondScreen: Boolean, hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentTab.shown,
): List<SessionDrawerPage> =
SessionDrawerPage.entries.filter {
(hasSecondScreen || it != SessionDrawerPage.SECOND_SCREEN) && (hasGlasses || it != SessionDrawerPage.GLASSES) &&
(hasGlasses || it != SessionDrawerPage.GLASSES) &&
(hasAgent || it != SessionDrawerPage.AGENT)
}
@@ -43,7 +43,6 @@ import androidx.compose.material.icons.outlined.PowerSettingsNew
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.material.icons.outlined.DesktopWindows
import androidx.compose.material.icons.outlined.Layers
import androidx.compose.material.icons.outlined.ScreenShare
import androidx.compose.material.icons.outlined.Pause
import androidx.compose.material.icons.outlined.PictureInPictureAlt
import androidx.compose.material.icons.automirrored.outlined.ExitToApp
@@ -166,7 +165,6 @@ import java.util.Locale
private val SessionDrawerPage.title: Int get() = when (this) {
SessionDrawerPage.CONTROLLER -> R.string.drawer_page_controller
SessionDrawerPage.GLASSES -> R.string.drawer_page_glasses
SessionDrawerPage.SECOND_SCREEN -> R.string.drawer_second_screen
SessionDrawerPage.DISPLAY -> R.string.drawer_page_display
SessionDrawerPage.HUD -> R.string.drawer_hud
SessionDrawerPage.VR -> R.string.vr_title
@@ -179,7 +177,6 @@ private val SessionDrawerPage.title: Int get() = when (this) {
private val SessionDrawerPage.icon get() = when (this) {
SessionDrawerPage.CONTROLLER -> Icons.Outlined.SportsEsports
SessionDrawerPage.GLASSES -> GlassesIcon
SessionDrawerPage.SECOND_SCREEN -> Icons.Outlined.ScreenShare
SessionDrawerPage.DISPLAY -> Icons.Outlined.DesktopWindows
SessionDrawerPage.HUD -> Icons.Outlined.Speed
SessionDrawerPage.VR -> VrHeadsetIcon
@@ -386,7 +383,7 @@ class DrawerActions(
@Composable
internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, controllerActive: Boolean, onPageChange: (SessionDrawerPage) -> Unit, a: DrawerActions, docked: Boolean = false,
backRequest: Int = 0, onLayerChange: (Boolean) -> Unit = {}) {
val pages = sessionDrawerPages(a.secondScreenDisplays.isNotEmpty(), a.glassesPresent)
val pages = sessionDrawerPages(a.glassesPresent)
val page = requestedPage.takeIf { it in pages } ?: SessionDrawerPage.CONTROLLER
LaunchedEffect(requestedPage, pages) { if (page != requestedPage) onPageChange(page) }
val colors = MaterialTheme.colorScheme
@@ -460,8 +457,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
val first = when {
page == SessionDrawerPage.GLASSES -> "glasses-tab-$glassesTab"
page == SessionDrawerPage.SESSION && a.isHomeApp -> "apps"
page == SessionDrawerPage.SECOND_SCREEN -> "second-screen:" +
(if (a.secondScreenMode == SecondScreenMode.NONE && !a.secondScreenNone) SecondScreenMode.KEYBOARD_TRACKPAD else a.secondScreenMode).id
else -> page.firstControl
}
if (turned) focus.forget(page)
@@ -510,7 +505,8 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
}
.padding(12.dp),
) {
val roomyHeader = sheetWidth >= 408.dp
val showPicker = a.secondScreenDisplays.isNotEmpty()
val roomyHeader = sheetWidth >= if (showPicker) 560.dp else 408.dp
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(6.dp),
@@ -520,7 +516,16 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
SteamActionPill(
stringResource(R.string.common_close), Icons.Outlined.Close, focus.track(page, "close"),
) { host.open = null; (a.onDismissScreen ?: a.onClose)() }
if (roomyHeader) Spacer(Modifier.weight(1f))
if (showPicker) Box(if (roomyHeader) Modifier.weight(1f) else Modifier) {
ScreenPickerChip(
ScreenPicker(
secondScreenModes(a.secondScreenNone, com.droiddeck.launcher.session.SessionState.deckPad, a.dashboardAvailable, a.desktopAvailable),
a.secondScreenMode, onPick = { host.open = null; a.onSecondScreenMode(it) },
onMenu = if (docked) ({ host.open = null }) else null, menuShown = docked,
),
focus.track(page, "screen").testTag("drawer-screen-picker"),
)
} else if (roomyHeader) Spacer(Modifier.weight(1f))
SteamActionPill(
stringResource(R.string.stores_dl_pause), Icons.Outlined.Pause, focus.track(page, "pause"),
) { host.open = null; a.onPause() }
@@ -543,7 +548,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
}
}
BarActions(
onMenu = if (docked) ({ host.open = null; a.onClose() }) else null, menuActive = true,
onMenu = null, menuActive = false,
onSteam = if (steamActions) ({ host.open = null; a.onSteamMenu?.invoke() }) else null,
onQam = if (steamActions) ({
host.open = null
@@ -650,6 +655,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
stringResource(R.string.display_sharpness), null, a.upscaleSharpness, 0..100, step = 5,
format = { "$it%" }, modifier = focus.track(page, "upscale-sharpness"), onChange = a.onUpscaleSharpness)
}
SecondScreenGroup(host, a) { key -> focus.track(page, key) }
}
SessionDrawerPage.EFFECTS -> {
ScreenEffectsGroup(host, a, advancedEffectsExpanded,
@@ -796,9 +802,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
onToggle = { id, on -> PcKeyboardPrefs.toggleHiddenKey(keyboardContext, PC_KEY_GROUP_IDS.getValue(id), on) })
}
}
SessionDrawerPage.SECOND_SCREEN -> {
SecondScreenGroup(host, a) { key -> focus.track(page, key) }
}
SessionDrawerPage.GLASSES -> if (glassesTab == GlassesTab.CONTROLLERS) {
VrControllerGroups(host) { key -> focus.track(page, key) }
} else {
@@ -1284,43 +1287,17 @@ internal fun secondScreenModes(none: Boolean, deckPad: Boolean, dashboard: Boole
@Composable
private fun SecondScreenGroup(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val modes = secondScreenModes(a.secondScreenNone, com.droiddeck.launcher.session.SessionState.deckPad, a.dashboardAvailable, a.desktopAvailable)
SettingsGroup(stringResource(R.string.drawer_second_screen_mode)) {
Text(stringResource(R.string.input_second_mode_hint), Modifier.padding(14.dp),
style = MaterialTheme.typography.bodySmall, color = colors.onSurfaceVariant)
Column(Modifier.fillMaxWidth().selectableGroup()) {
modes.forEach { mode ->
val selected = a.secondScreenMode == mode
val source = remember { MutableInteractionSource() }
val hot = source.collectIsFocusedAsState().value || source.collectIsHoveredAsState().value
val pick = { host.open = null; a.onSecondScreenMode(mode) }
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = track("second-screen:${mode.id}").fillMaxWidth().heightIn(min = 56.dp)
.background(if (hot) pal.signal.copy(alpha = 0.12f) else Color.Transparent)
.glideBorder(hot, RoundedCornerShape(8.dp), pal.signal)
.hoverable(source)
.selectable(selected, interactionSource = source, indication = null, role = Role.RadioButton, onClick = pick)
.controllerConfirm(onClick = pick)
.padding(horizontal = 14.dp, vertical = 8.dp),
) {
Text(stringResource(mode.label), fontSize = 15.sp, color = colors.onBackground, modifier = Modifier.weight(1f))
RadioButton(selected, onClick = null,
colors = RadioButtonDefaults.colors(selectedColor = pal.signal, unselectedColor = colors.onSurfaceVariant))
}
}
}
if (a.secondScreenDisplays.size > 1) ChoiceRow(host, "second-screen-display", stringResource(R.string.drawer_page_display), null,
a.secondScreenDisplays.map { it.id to it.label }, a.selectedSecondScreenDisplay,
chipModifier = track("second-screen-display"), onPick = a.onSecondScreenDisplay)
}
if (a.gameSwapAvailable || a.gameOnBottom) SettingsGroup(stringResource(R.string.swap_game_screen_group)) {
ChoiceRow(host, "game-screen", stringResource(R.string.swap_game_screen), null,
val choosesDisplay = a.secondScreenDisplays.size > 1
val swapsGame = a.gameSwapAvailable || a.gameOnBottom
if (!choosesDisplay && !swapsGame) return
SettingsGroup(stringResource(R.string.drawer_second_screen)) {
if (swapsGame) ChoiceRow(host, "game-screen", stringResource(R.string.swap_game_screen), null,
if (a.gameSwapBuiltIn) listOf(false to stringResource(R.string.swap_game_screen_top), true to stringResource(R.string.swap_game_screen_bottom))
else listOf(false to stringResource(R.string.main_primary), true to stringResource(R.string.main_secondary)),
a.gameOnBottom, chipModifier = track("game-screen"), onPick = a.onGameOnBottom)
if (choosesDisplay) ChoiceRow(host, "second-screen-display", stringResource(R.string.drawer_page_display), null,
a.secondScreenDisplays.map { it.id to it.label }, a.selectedSecondScreenDisplay,
chipModifier = track("second-screen-display"), onPick = a.onSecondScreenDisplay)
}
}