Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
colorwheel.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2013-2017 Matt Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #ifndef COLORWHEEL_H
18 #define COLORWHEEL_H
19 
20 #include <QWidget>
21 
22 
23 class ColorWheel : public QWidget
24 {
25  Q_OBJECT
26 public:
27  explicit ColorWheel(QWidget *parent = 0);
28 
29  virtual QSize sizeHint () const;
30  virtual QSize minimumSizeHint () const;
31  QColor color();
32 
33 
34 signals:
35  void colorSelected(const QColor &color);
36  void colorChanged(const QColor &color);
37 
38 public slots:
39  void setColor(const QColor &color);
40 
41 protected:
42  void mousePressEvent(QMouseEvent *event);
43  void mouseMoveEvent(QMouseEvent *event);
44  void mouseReleaseEvent(QMouseEvent *);
45  void resizeEvent(QResizeEvent *event);
46  void paintEvent(QPaintEvent *);
47 
48 private:
49  void changeColor(const QColor &color);
50  void hueChanged(const int &hue);
51  void svChanged(const QColor &newcolor);
52  void alphaChanged(const int &alpha);
53 
54  QColor pickColor(const QPoint &point);
55 
56  void drawHueIndicator(const int &hue);
57  void drawPicker(const QColor &color);
58 
59  void drawWheelImage(const QSize &newSize);
60  void drawSquareImage(const int &hue);
61  void composeWheel(QPixmap& pixmap);
62 
63  QSize m_initSize;
64  QImage m_wheelImage;
65  QImage m_squareImage;
66  QPixmap m_wheelPixmap;
67 
68  int m_wheelThickness;
69  QRegion m_wheelRegion;
70  QRegion m_squareRegion;
71  QColor m_currentColor;
72  bool m_isInWheel;
73  bool m_isInSquare;
74 
75 };
76 
77 #endif // COLORWHEEL_H