using UnityEngine.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using System;

public class ProgressBarView : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    private Transform _transform;
    public RawImage waveFormImage { get; set; }
    public Slider progressSlider { get; set; }
    public bool isDrag { get; private set; }

    public Action OnDrag { get; set; }

    private void Awake()
    {   
        _transform=gameObject.GetComponent<Transform>();
        progressSlider = gameObject.gameObject.GetComponent<Slider>();
        waveFormImage =_transform.Find("WaveForm").gameObject.GetComponent<RawImage>();
        waveFormImage.gameObject.SetActive(false);
    }
    
    /// <summary>
    /// 鼠标按下
    /// </summary>
    public void OnPointerDown(PointerEventData eventData)
    {
        isDrag = true;
    }
    /// <summary>
    /// 鼠标抬起
    /// </summary>
    public void OnPointerUp(PointerEventData eventData)
    {
        OnMouseUp();
        isDrag = false;
    }
    void OnMouseUp()
    {
        OnDrag?.Invoke();
    }
}
