HuePanel.h 700 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef HUEPANEL_H
  2. #define HUEPANEL_H
  3. #include <QWidget>
  4. class HuePanel : public QWidget
  5. {
  6. Q_OBJECT
  7. public:
  8. explicit HuePanel(const QColor &c = QColor(255, 0, 0), QWidget *parent = nullptr);
  9. void setColor(const QColor &c);
  10. int hue() const; // 0 <= hue < 360
  11. int saturation() const;
  12. void setPickerPosition(const QPoint &pos);
  13. // QWidget interface
  14. protected:
  15. void mousePressEvent(QMouseEvent *event) override;
  16. void mouseMoveEvent(QMouseEvent *event) override;
  17. void paintEvent(QPaintEvent *event) override;
  18. signals:
  19. void colorChanged(const QColor &);
  20. private:
  21. QPixmap huePixmap;
  22. QColor color;
  23. QPoint pickerPos;
  24. };
  25. #endif // HUEPANEL_H