#ifndef COLOR_PICKER_H
#define COLOR_PICKER_H


#include <QDialog>
class QPushButton;


struct ColorScheme
{
    static const int modes = 5;

    //   mode (3-bits), primary hue (8-bits), angle / hue-delta (8-bits)
    //   saturation (8-bits), stretch (5-bits)
    unsigned    m_primaryHue : 8;
    unsigned    m_secondaryHueDelta : 8;
    unsigned    m_saturation : 8;
    unsigned    m_stretch : 5;
    unsigned    m_mode : 3;

    const char* modeName();
    int hueCount();

    void setHue(int a_index, float a_val);
    float hue(int a_index);
};
static_assert(sizeof(ColorScheme) == 4, "Not the size we expected");


class SchemeSelection : public QWidget
{
public:
    SchemeSelection(QWidget* a_parent);
private:
    QPushButton* modeButtons[ColorScheme::modes];
};


class ColorPicker : public QDialog
{
    Q_OBJECT
public:
    ColorPicker(QWidget* parent = 0);
    ~ColorPicker();
    void mousePressEvent(QMouseEvent* me);
    void mouseReleaseEvent(QMouseEvent*);
    void mouseMoveEvent(QMouseEvent* me);
    void paintEvent(QPaintEvent*);
public slots:
    void setMode(int);
private:
    int m_hueMovingIdx;
    ColorScheme palette;
    SchemeSelection scheme;
    const float twoPi = 2 * acos(-1);
};


#endif // COLOR_PICKER_H
