mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-22 20:09:17 +01:00
Make the OSC control panel draggable
This commit is contained in:
parent
d7e38e9556
commit
d69c9f472f
@ -11,6 +11,7 @@ import android.os.Bundle
|
|||||||
import android.os.Vibrator
|
import android.os.Vibrator
|
||||||
import android.os.VibratorManager
|
import android.os.VibratorManager
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import android.view.View.OnTouchListener
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
@ -72,6 +73,7 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
override fun onCreate(savedInstanceState : Bundle?) {
|
override fun onCreate(savedInstanceState : Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||||
@ -129,6 +131,8 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
binding.gridButton.setIconResource(if (!snapToGrid) R.drawable.ic_grid_on else R.drawable.ic_grid_off)
|
binding.gridButton.setIconResource(if (!snapToGrid) R.drawable.ic_grid_on else R.drawable.ic_grid_off)
|
||||||
binding.resetButton.setOnClickListener { resetAction() }
|
binding.resetButton.setOnClickListener { resetAction() }
|
||||||
|
|
||||||
|
binding.dragHandle.setOnTouchListener(dragPanelListener)
|
||||||
|
|
||||||
binding.onScreenControllerView.setEditMode(EditMode.Move)
|
binding.onScreenControllerView.setEditMode(EditMode.Move)
|
||||||
binding.onScreenControllerView.selectAllButtons()
|
binding.onScreenControllerView.selectAllButtons()
|
||||||
}
|
}
|
||||||
@ -182,4 +186,13 @@ class OnScreenEditActivity : AppCompatActivity() {
|
|||||||
binding.scaleSlider.slider.value = (button.config.scale - OnScreenConfiguration.MinScale) / (OnScreenConfiguration.MaxScale - OnScreenConfiguration.MinScale) * 100f
|
binding.scaleSlider.slider.value = (button.config.scale - OnScreenConfiguration.MinScale) / (OnScreenConfiguration.MaxScale - OnScreenConfiguration.MinScale) * 100f
|
||||||
binding.opacitySlider.slider.value = (button.config.alpha - OnScreenConfiguration.MinAlpha) / (OnScreenConfiguration.MaxAlpha - OnScreenConfiguration.MinAlpha).toFloat() * 100f
|
binding.opacitySlider.slider.value = (button.config.alpha - OnScreenConfiguration.MinAlpha) / (OnScreenConfiguration.MaxAlpha - OnScreenConfiguration.MinAlpha).toFloat() * 100f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
|
private val dragPanelListener = OnTouchListener { view : View, event : MotionEvent ->
|
||||||
|
if (event.action == MotionEvent.ACTION_MOVE) {
|
||||||
|
binding.controlPanel.x = event.rawX - binding.controlPanel.width / 2
|
||||||
|
binding.controlPanel.y = event.rawY - view.height / 2
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user