tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
color_wheel.hpp
Go to the documentation of this file.
1 
23 #ifndef COLOR_WHEEL_HPP
24 #define COLOR_WHEEL_HPP
25 
26 #include "colorpicker_global.hpp"
27 
28 #include <QWidget>
29 
36 class QCP_EXPORT Color_Wheel : public QWidget
37 {
38  Q_OBJECT
39 
40  Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true STORED false )
41  Q_PROPERTY(qreal hue READ hue WRITE setHue DESIGNABLE false )
42  Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation DESIGNABLE false )
43  Q_PROPERTY(qreal value READ value WRITE setValue DESIGNABLE false )
44  Q_PROPERTY(unsigned wheelWidth READ wheelWidth WRITE setWheelWidth DESIGNABLE true )
45  Q_PROPERTY(Display_Flags displayFlags READ displayFlags WRITE setDisplayFlags NOTIFY displayFlagsChanged DESIGNABLE true )
46 
47 public:
49  {
50  SHAPE_DEFAULT = 0x000,
51  SHAPE_TRIANGLE = 0x001,
52  SHAPE_SQUARE = 0x002,
53  SHAPE_FLAGS = 0x00f,
54 
55  ANGLE_DEFAULT = 0x000,
56  ANGLE_FIXED = 0x010,
57  ANGLE_ROTATING = 0x020,
58  ANGLE_FLAGS = 0x0f0,
59 
60  COLOR_DEFAULT = 0x000,
61  COLOR_HSV = 0x100,
62  COLOR_HSL = 0x200,
63  COLOR_LCH = 0x400,
64  COLOR_FLAGS = 0xf00,
65 
66  FLAGS_DEFAULT = 0x000,
67  FLAGS_ALL = 0xfff
68  };
69  Q_DECLARE_FLAGS(Display_Flags, Display_Enum)
70  Q_FLAGS(Display_Flags)
71 
72  explicit Color_Wheel(QWidget *parent = 0);
73  ~Color_Wheel();
74 
76  QColor color() const;
77 
78  QSize sizeHint() const;
79 
81  qreal hue() const;
82 
84  qreal saturation() const;
85 
87  qreal value() const;
88 
90  unsigned int wheelWidth() const;
91 
93  void setWheelWidth(unsigned int w);
94 
96  Display_Flags displayFlags(Display_Flags mask = FLAGS_ALL) const;
97 
99  static void setDefaultDisplayFlags(Display_Flags flags);
100 
102  static Display_Flags defaultDisplayFlags(Display_Flags mask = FLAGS_ALL);
103 
109  void setDisplayFlag(Display_Flags flag, Display_Flags mask);
110 
111 public slots:
112 
114  void setColor(QColor c);
115 
119  void setHue(qreal h);
120 
124  void setSaturation(qreal s);
125 
129  void setValue(qreal v);
130 
135  void setDisplayFlags(Color_Wheel::Display_Flags flags);
136 
137 signals:
141  void colorChanged(QColor);
142 
146  void colorSelected(QColor);
147 
148  void displayFlagsChanged(Color_Wheel::Display_Flags flags);
149 
150 protected:
151  void paintEvent(QPaintEvent *);
152  void mouseMoveEvent(QMouseEvent *);
153  void mousePressEvent(QMouseEvent *);
154  void mouseReleaseEvent(QMouseEvent *);
155  void resizeEvent(QResizeEvent *);
156 
157 private:
158  class Private;
159  Private * const p;
160 };
161 
162 Q_DECLARE_OPERATORS_FOR_FLAGS(Color_Wheel::Display_Flags)
163 
164 #endif // COLOR_WHEEL_HPP
Display_Enum
Definition: color_wheel.hpp:48
#define QCP_EXPORT
Definition: colorpicker_global.hpp:9
Display an analog widget that allows the selection of a HSV color.
Definition: color_wheel.hpp:36