Remove OSC EditMode enum

An enum isn't needed anymore, as there's no state to enumerate anymore.
This commit is contained in:
lynxnb 2023-03-31 00:45:26 +02:00 committed by Billy Laws
parent 2556b25ebf
commit e91993698f
3 changed files with 9 additions and 15 deletions

View File

@ -68,7 +68,6 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
} }
internal val editInfo = OnScreenEditInfo() internal val editInfo = OnScreenEditInfo()
val isEditing get() = editInfo.isEditing
val editButton get() = editInfo.editButton val editButton get() = editInfo.editButton
fun setOnEditButtonChangedListener(listener : OnEditButtonChangedListener?) { fun setOnEditButtonChangedListener(listener : OnEditButtonChangedListener?) {
editInfo.onEditButtonChangedListener = listener editInfo.onEditButtonChangedListener = listener
@ -283,9 +282,12 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
setOnTouchListener(playingTouchHandler) setOnTouchListener(playingTouchHandler)
} }
fun setEditMode(editMode : EditMode) { fun setEditMode(isEdit : Boolean) {
editInfo.editMode = editMode // Select all buttons when entering edit if we weren't already editing
setOnTouchListener(if (isEditing) editingTouchHandler else playingTouchHandler) if (!editInfo.isEditing)
selectAllButtons()
editInfo.isEditing = isEdit
setOnTouchListener(if (isEdit) editingTouchHandler else playingTouchHandler)
} }
fun selectAllButtons() { fun selectAllButtons() {

View File

@ -133,8 +133,7 @@ class OnScreenEditActivity : AppCompatActivity() {
binding.dragHandle.setOnTouchListener(dragPanelListener) binding.dragHandle.setOnTouchListener(dragPanelListener)
binding.onScreenControllerView.setEditMode(EditMode.Move) binding.onScreenControllerView.setEditMode(true)
binding.onScreenControllerView.selectAllButtons()
} }
override fun onResume() { override fun onResume() {

View File

@ -8,11 +8,6 @@ package emu.skyline.input.onscreen
import android.content.res.Resources import android.content.res.Resources
import android.util.TypedValue import android.util.TypedValue
enum class EditMode {
None,
Move
}
typealias OnEditButtonChangedListener = ((ConfigurableButton) -> Unit) typealias OnEditButtonChangedListener = ((ConfigurableButton) -> Unit)
/** /**
@ -21,9 +16,9 @@ typealias OnEditButtonChangedListener = ((ConfigurableButton) -> Unit)
*/ */
class OnScreenEditInfo { class OnScreenEditInfo {
/** /**
* The current edit mode * Whether the buttons are currently in edit mode
*/ */
var editMode : EditMode = EditMode.None var isEditing : Boolean = false
/** /**
* The button that is currently being edited * The button that is currently being edited
@ -47,8 +42,6 @@ class OnScreenEditInfo {
var arrowKeyMoveAmount : Int = ArrowKeyMoveAmount var arrowKeyMoveAmount : Int = ArrowKeyMoveAmount
val isEditing get() = editMode != EditMode.None
companion object { companion object {
/** /**
* The size of the grid, calculated from the value of 8dp * The size of the grid, calculated from the value of 8dp