package fr.iutfbleau.dev45.wamster.tp05ex01_reticule;

import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

public class Evenement implements View.OnTouchListener{

    private Dessin dessin;
    private boolean mouvementEnCours;
    private float distance = 50f;

    public Evenement(Dessin dessin){
        this.dessin = dessin;
        this.mouvementEnCours = false;
    }

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        int action = event.getActionMasked();
        int index = event.getActionIndex();
        int id = event.getPointerId(index);
        Log.v("test1", id+"");
        float x,y;

        switch (action) {
            case MotionEvent.ACTION_DOWN:
                this.mouvementEnCours = true;
                break;

            case MotionEvent.ACTION_POINTER_DOWN:
                this.mouvementEnCours = false;
                break;

            case MotionEvent.ACTION_MOVE:
                if (this.mouvementEnCours){
                    this.dessin.setCoordonnee(event.getX(), event.getY());
                }
                break;

            case MotionEvent.ACTION_UP:
                this.mouvementEnCours = false;
                break;
            case MotionEvent.ACTION_CANCEL:
                this.mouvementEnCours = false;
                break;
        }
        return true;
    }

    public float isDistancePetite(float x1, float y1){
        float x2 = this.dessin.getX();
        float y2 = this.dessin.getX();
    }
}
