package com.example.Reticule;

import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.View;

public class Reticule implements View.OnTouchListener {

    private Fenetre mavue;
    private float x=-1;
    private float y=-1;

    public Reticule() {
    }

    public void setVue(Fenetre vue){
        this.mavue = vue;
    }

    public float getReticuleX(){
        return this.x;
    }

    public float getReticuleY(){
        return this.y;
    }

    public void setReticuleX(float X){
        this.x = X;
    }

    public void setReticuleY(float Y){
        this.y = Y;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouch(View v, MotionEvent e) {
        int action = e.getActionMasked();
        if (action==MotionEvent.ACTION_DOWN){
            this.x=e.getX(0);
            this.y=e.getY(0);
            mavue.invalidate();
        }
        if (action==MotionEvent.ACTION_UP){
            this.x=-1;
            this.y=-1;
            mavue.invalidate();
        }
        if (action==MotionEvent.ACTION_MOVE){
            this.x=e.getX(0);
            this.y=e.getY(0);
            mavue.invalidate();
        }
        return true;
    }
}