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

View File

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

View File

@ -8,11 +8,6 @@ package emu.skyline.input.onscreen
import android.content.res.Resources
import android.util.TypedValue
enum class EditMode {
None,
Move
}
typealias OnEditButtonChangedListener = ((ConfigurableButton) -> Unit)
/**
@ -21,9 +16,9 @@ typealias OnEditButtonChangedListener = ((ConfigurableButton) -> Unit)
*/
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
@ -47,8 +42,6 @@ class OnScreenEditInfo {
var arrowKeyMoveAmount : Int = ArrowKeyMoveAmount
val isEditing get() = editMode != EditMode.None
companion object {
/**
* The size of the grid, calculated from the value of 8dp