//
// Created by Krad on 2021/11/24.
//

#ifndef GUI_SLIDEPICKERBOX_H
#define GUI_SLIDEPICKERBOX_H

#include <QWidget>
class QLabel;
class SlidePickerBox:public QWidget {
    Q_OBJECT
public:
    explicit SlidePickerBox(QWidget *parent = nullptr);
    QString getSelectedValue();
    void setItems(QStringList itemsList);
    void addItem(QString& item)
    {
        this->items.append(item);
    }
    void setSelectedValue(const QString& val);
protected:

    bool isDragging;
//    QPropertyAnimation *homingAni;

    void mousePressEvent(QMouseEvent * ev) override ;
    void mouseMoveEvent(QMouseEvent * ev) override ;
    void mouseReleaseEvent(QMouseEvent * ev) override ;
    void paintEvent(QPaintEvent * ev) override ;
    void paintText(QString txt,int x, int y, const QColor& color);
    void paintText(QString txt,int x, int y){
        paintText(txt, x, y, QColor(0,0,0));
    }
    void setCurrentLabel(QLabel* label);

    void setPrevLabel(QLabel* label);
    void setNextLabel(QLabel* label);
    void hideLabel(QLabel* label);
private:
    int o_x=0,o_y=10;
    int selectedIndex = -1;
    QLabel* selectedLbl = nullptr;
    QLabel* prevLbl = nullptr;
    QLabel* nextLbl = nullptr;
    QList<QLabel*> lbls;
    QStringList items;

    void adjustPositon() const;
};


#endif //GUI_SLIDEPICKERBOX_H
