[UI Ribbon] move prev and next buttons to underneath panel

This commit is contained in:
amwatson 2024-03-19 16:01:18 -05:00
parent 4baecd2a51
commit a70a7a4290
3 changed files with 140 additions and 74 deletions

View file

@ -1,5 +1,6 @@
package org.citra.citra_emu.vr.ui package org.citra.citra_emu.vr.ui
import android.view.KeyEvent
import android.view.MotionEvent import android.view.MotionEvent
import android.widget.Button import android.widget.Button
import android.widget.ImageButton import android.widget.ImageButton
@ -10,25 +11,46 @@ import org.citra.citra_emu.vr.VrActivity
class VrRibbonLayer(activity: VrActivity) : VrUILayer(activity, R.layout.vr_ribbon) { class VrRibbonLayer(activity: VrActivity) : VrUILayer(activity, R.layout.vr_ribbon) {
override fun onSurfaceCreated() { override fun onSurfaceCreated() {
super.onSurfaceCreated() super.onSurfaceCreated()
initializeMainView()
}
fun initializeMainView() {
window?.findViewById<Button>(R.id.buttonSelect)?.setOnTouchListener { _, motionEvent -> window?.findViewById<Button>(R.id.buttonSelect)?.setOnTouchListener { _, motionEvent ->
val action: Int = when (motionEvent.action) {
KeyEvent.ACTION_DOWN -> {
// Normal key events.
NativeLibrary.ButtonState.PRESSED
}
KeyEvent.ACTION_UP -> NativeLibrary.ButtonState.RELEASED
else -> return@setOnTouchListener false
}
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice,
NativeLibrary.ButtonType.BUTTON_SELECT, NativeLibrary.ButtonType.BUTTON_SELECT,
if (motionEvent.action == MotionEvent.ACTION_DOWN) action)
NativeLibrary.ButtonState.PRESSED
else NativeLibrary.ButtonState.RELEASED)
false false
} }
window?.findViewById<Button>(R.id.buttonStart)?.setOnTouchListener { _, motionEvent -> window?.findViewById<Button>(R.id.buttonStart)?.setOnTouchListener { _, motionEvent ->
val action: Int = when (motionEvent.action) {
KeyEvent.ACTION_DOWN -> {
// Normal key events.
NativeLibrary.ButtonState.PRESSED
}
KeyEvent.ACTION_UP -> NativeLibrary.ButtonState.RELEASED
else -> return@setOnTouchListener false
}
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice,
NativeLibrary.ButtonType.BUTTON_START, NativeLibrary.ButtonType.BUTTON_START,
if (motionEvent.action == MotionEvent.ACTION_DOWN) action)
NativeLibrary.ButtonState.PRESSED
else NativeLibrary.ButtonState.RELEASED)
false false
} }
window?.findViewById<Button>(R.id.buttonExit)?.setOnTouchListener { _, motionEvent -> window?.findViewById<Button>(R.id.buttonExit)?.setOnTouchListener { _, motionEvent ->
activity.quitToMenu() activity.quitToMenu()
false false
} }
window?.findViewById<Button>(R.id.buttonNextMenu)?.setOnTouchListener { _, motionEvent ->
false
}
} }
} }

View file

@ -8,8 +8,8 @@
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_margin="5dp" android:layout_margin="5dp"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -22,91 +22,67 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/frame"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/vr_menu_background" android:background="@drawable/vr_menu_background"
android:backgroundTint="#011627" android:backgroundTint="#011627"
android:padding="50dp" android:paddingHorizontal="50dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<FrameLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="1000dp" android:id="@+id/panelHolder"
android:layout_height="0dp" android:layout_width="wrap_content"
app:layout_constraintEnd_toEndOf="parent" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/lowerPanelPlaceHolder"
android:layout_width="900dp"
android:layout_height="675dp"
android:layout_marginTop="10dp"
android:background="#093A60"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="100dp"
android:layout_height="400dp"
android:layout_gravity="center"
android:layout_marginStart="50dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/lowerPanelPlaceHolder"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/lowerPanelPlaceHolder" app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="@+id/lowerPanelPlaceHolder">
<Button <include layout="@layout/vr_ribbon_main_panel" />
android:id="@+id/buttonSelect"
style="@style/VrRibbonButtonStyle" </androidx.constraintlayout.widget.ConstraintLayout>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/button_select" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/buttonStart"
style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/button_start" /> android:layout_marginTop="18dp"
android:layout_marginEnd="150dp"
android:layout_marginBottom="18dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/panelHolder">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="500dp"
android:layout_height="0dp" android:layout_height="wrap_content"
android:layout_weight="1" /> android:orientation="horizontal">
<Button <Button
android:id="@+id/buttonExit" android:id="@+id/buttonPrevMenu"
style="@style/VrRibbonButtonStyle" style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/emulation_close_game" /> android:layout_weight="1"
android:minHeight="0dp"
<LinearLayout android:padding="0dp"
android:layout_width="match_parent" android:paddingVertical="8dp"
android:layout_height="0dp" android:text="&lt;" />
android:layout_weight="3" />
<Button <Button
android:id="@+id/buttonNextMenu" android:id="@+id/buttonNextMenu"
style="@style/VrRibbonButtonStyle" style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=">" /> android:layout_weight="1"
android:minHeight="0dp"
android:padding="0dp"
android:paddingVertical="8dp"
android:text="&gt;" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="1000dp"
android:layout_height="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/lowerPanelPlaceHolder"
android:layout_width="900dp"
android:layout_height="675dp"
android:layout_marginTop="18dp"
android:background="#093A60"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="100dp"
android:layout_height="400dp"
android:layout_gravity="center"
android:layout_marginStart="50dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/lowerPanelPlaceHolder"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/lowerPanelPlaceHolder"
app:layout_constraintTop_toTopOf="@+id/lowerPanelPlaceHolder">
<Button
android:id="@+id/buttonSelect"
style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:text="@string/button_select" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/buttonStart"
style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/button_start" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/buttonExit"
style="@style/VrRibbonButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/emulation_close_game" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>