mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-12 11:31:08 +00:00
fix(ui): show launch and tab hints where a pad does that
This commit is contained in:
2 files changed
+20
-5
No files matched your search
@@ -53,6 +53,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
@@ -78,7 +80,7 @@ import com.droiddeck.launcher.core.PhantomProcessLimit
|
||||
|
||||
/** What the pad's face buttons do here, along the bottom edge as on a console. */
|
||||
@Composable
|
||||
internal fun ControllerHints() {
|
||||
internal fun ControllerHints(select: String = "Select", tabs: Boolean = false) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
@@ -88,7 +90,8 @@ internal fun ControllerHints() {
|
||||
horizontalArrangement = Arrangement.spacedBy(18.dp, Alignment.End),
|
||||
modifier = Modifier.fillMaxWidth().height(34.dp).background(colors.surface).padding(horizontal = 20.dp),
|
||||
) {
|
||||
HintGlyph("A", "Select")
|
||||
if (tabs) HintGlyph("LB RB", "Tabs")
|
||||
HintGlyph("A", select)
|
||||
HintGlyph("B", "Back")
|
||||
}
|
||||
}
|
||||
@@ -98,7 +101,12 @@ internal fun ControllerHints() {
|
||||
private fun HintGlyph(button: String, action: String) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(20.dp).clip(CircleShape).background(colors.onBackground)) {
|
||||
// Face buttons are round; bumpers are a wider keycap.
|
||||
val shape = if (button.length == 1) CircleShape else RoundedCornerShape(6.dp)
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.height(20.dp).widthIn(min = 20.dp).clip(shape).background(colors.onBackground).padding(horizontal = if (button.length == 1) 0.dp else 6.dp),
|
||||
) {
|
||||
Text(button, fontSize = 12.sp, fontWeight = FontWeight.Bold, color = colors.background)
|
||||
}
|
||||
Text(action, fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
|
||||
@@ -229,7 +229,8 @@ internal class FrontFocus {
|
||||
// and the last one focused.
|
||||
val items = HashMap<String, FocusRequester>()
|
||||
val attached = HashMap<String, Int>()
|
||||
var last: String? = null
|
||||
// State, so the controller hints follow it: A launches from a game row but selects elsewhere.
|
||||
var last by mutableStateOf<String?>(null)
|
||||
// The first tile of the page's grid: Down from the page's buttons goes to it, not to whichever
|
||||
// tile happens to sit under the button.
|
||||
val firstTile = FocusRequester()
|
||||
@@ -417,7 +418,13 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
AnimatedVisibility(
|
||||
inputModeManager.inputMode == InputMode.Keyboard,
|
||||
enter = expandVertically() + fadeIn(), exit = shrinkVertically() + fadeOut(),
|
||||
) { ControllerHints() }
|
||||
) {
|
||||
val onGame = frontFocus.focusedRail == null && frontFocus.last?.startsWith("game:") == true
|
||||
ControllerHints(
|
||||
select = if (onGame) "Launch" else "Select",
|
||||
tabs = railSelection == "setup" && s.pageKey == null && frontFocus.focusedRail == null,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user