mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix(input): show the panel tabs under the controls-below-the-game bar (#2302)
* fix(input): show the panel tabs under the controls-below-the-game bar * fix(input): take the tab row out of the game, not the controls below it
This commit is contained in:
1 parent
a7c10e3f51
commit
ecd916d43f
3 files changed
+19
-5
No files matched your search
@@ -3609,7 +3609,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
val width = sessionRoot.width
|
val width = sessionRoot.width
|
||||||
val height = sessionRoot.height
|
val height = sessionRoot.height
|
||||||
val wanted = controlsBelowWanted()
|
val wanted = controlsBelowWanted()
|
||||||
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height)
|
val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let {
|
||||||
|
it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()
|
||||||
|
} ?: 0
|
||||||
|
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow)
|
||||||
else FrameLayout.LayoutParams.MATCH_PARENT
|
else FrameLayout.LayoutParams.MATCH_PARENT
|
||||||
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
|
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
|
||||||
if (params.height != gameHeight) {
|
if (params.height != gameHeight) {
|
||||||
@@ -3635,8 +3638,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
panel = OnScreenControls(this, padBridge, dock).also { it.updateLayout(primaryInputLayout) }
|
panel = OnScreenControls(this, padBridge, dock).also { it.updateLayout(primaryInputLayout) }
|
||||||
val column = android.widget.LinearLayout(this).apply {
|
val column = android.widget.LinearLayout(this).apply {
|
||||||
orientation = android.widget.LinearLayout.VERTICAL
|
orientation = android.widget.LinearLayout.VERTICAL
|
||||||
addView(unfoldedBar(), android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
|
addView(unfoldedBar().apply {
|
||||||
(com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()))
|
addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
|
||||||
|
if (bottom - top != oldBottom - oldTop) post { applyUnfoldedControls() }
|
||||||
|
}
|
||||||
|
}, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT))
|
||||||
addView(panel, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
|
addView(panel, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
|
||||||
}
|
}
|
||||||
sessionRoot.addView(column, sessionRoot.indexOfChild(surfaceView) + 1)
|
sessionRoot.addView(column, sessionRoot.indexOfChild(surfaceView) + 1)
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ object SessionDisplay {
|
|||||||
|
|
||||||
const val UNFOLDED_MIN_DP = 600
|
const val UNFOLDED_MIN_DP = 600
|
||||||
|
|
||||||
fun unfoldedGameHeight(width: Int, height: Int): Int =
|
fun unfoldedGameHeight(width: Int, height: Int, tabRow: Int = 0): Int =
|
||||||
minOf(width * 9 / 16, (height * UNFOLDED_MAX_GAME_SHARE).toInt()) and 1.inv()
|
(minOf(width * 9 / 16, (height * UNFOLDED_MAX_GAME_SHARE).toInt()) - tabRow.coerceAtLeast(0)).coerceAtLeast(0) and 1.inv()
|
||||||
|
|
||||||
fun unfoldedControlsWanted(
|
fun unfoldedControlsWanted(
|
||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ class SessionDisplayTest {
|
|||||||
assertEquals(864, SessionDisplay.unfoldedGameHeight(1920, 1080))
|
assertEquals(864, SessionDisplay.unfoldedGameHeight(1920, 1080))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun aTabRowUnderTheBarComesOutOfTheGameNotTheControls() {
|
||||||
|
assertEquals(1376, SessionDisplay.unfoldedGameHeight(2448, 1848, 0))
|
||||||
|
assertEquals(1240, SessionDisplay.unfoldedGameHeight(2448, 1848, 136))
|
||||||
|
assertEquals(1376, SessionDisplay.unfoldedGameHeight(2448, 1848, -20))
|
||||||
|
assertEquals(0, SessionDisplay.unfoldedGameHeight(200, 100, 500))
|
||||||
|
}
|
||||||
|
|
||||||
private fun unfoldedWanted(
|
private fun unfoldedWanted(
|
||||||
enabled: Boolean = true,
|
enabled: Boolean = true,
|
||||||
controller: Boolean = false,
|
controller: Boolean = false,
|
||||||
|
|||||||
Reference in new issue
Block a user