package com.bomostory.sceneeditmodule.view

import android.view.MotionEvent
import android.view.View

class OnTouchBoMoSceneListener : View.OnTouchListener{
    var positionX = 0f
    var dX = 0
    var onSceneMoveCallBack: OnSceneMoveListener? = null

    override fun onTouch(v: View?, event: MotionEvent?): Boolean {
            when (event?.action) {
                MotionEvent.ACTION_DOWN -> {
                    positionX = event.x
                }
                MotionEvent.ACTION_MOVE -> {
                    dX = (event.rawX - positionX).toInt()
                    onSceneMoveCallBack?.onSceneMove(dX)

                }
                MotionEvent.ACTION_UP -> {

                }
            }
        return true
    }

    fun setCallBack(onSceneMoveCallBack: OnSceneMoveListener){
        this.onSceneMoveCallBack = onSceneMoveCallBack
    }
    interface OnSceneMoveListener{
        fun onSceneMove(dX: Int)
    }
}


