color_wheel.hpp
Go to the documentation of this file.
1 
22 #ifndef COLOR_WHEEL_HPP
23 #define COLOR_WHEEL_HPP
24 
25 #include <QWidget>
26 
27 namespace color_widgets {
28 
35 class ColorWheel : public QWidget
36 {
37  Q_OBJECT
38 
39  Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged DESIGNABLE true STORED false )
40  Q_PROPERTY(qreal hue READ hue WRITE setHue DESIGNABLE false )
41  Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation DESIGNABLE false )
42  Q_PROPERTY(qreal value READ value WRITE setValue DESIGNABLE false )
43  Q_PROPERTY(unsigned wheelWidth READ wheelWidth WRITE setWheelWidth DESIGNABLE true )
44  Q_PROPERTY(DisplayFlags displayFlags READ displayFlags WRITE setDisplayFlags NOTIFY displayFlagsChanged DESIGNABLE true )
45 
46 public:
48  {
49  SHAPE_DEFAULT = 0x000,
50  SHAPE_TRIANGLE = 0x001,
51  SHAPE_SQUARE = 0x002,
52  SHAPE_FLAGS = 0x00f,
53 
54  ANGLE_DEFAULT = 0x000,
55  ANGLE_FIXED = 0x010,
56  ANGLE_ROTATING = 0x020,
57  ANGLE_FLAGS = 0x0f0,
58 
59  COLOR_DEFAULT = 0x000,
60  COLOR_HSV = 0x100,
61  COLOR_HSL = 0x200,
62  COLOR_LCH = 0x400,
63  COLOR_FLAGS = 0xf00,
64 
65  FLAGS_DEFAULT = 0x000,
66  FLAGS_ALL = 0xfff
67  };
68  Q_DECLARE_FLAGS(DisplayFlags, DisplayEnum)
69  Q_FLAGS(DisplayFlags)
70 
71  explicit ColorWheel(QWidget *parent = 0);
72  ~ColorWheel();
73 
75  QColor color() const;
76 
77  QSize sizeHint() const Q_DECL_OVERRIDE;
78 
80  qreal hue() const;
81 
83  qreal saturation() const;
84 
86  qreal value() const;
87 
89  unsigned int wheelWidth() const;
90 
92  void setWheelWidth(unsigned int w);
93 
95  DisplayFlags displayFlags(DisplayFlags mask = FLAGS_ALL) const;
96 
98  static void setDefaultDisplayFlags(DisplayFlags flags);
99 
101  static DisplayFlags defaultDisplayFlags(DisplayFlags mask = FLAGS_ALL);
102 
108  void setDisplayFlag(DisplayFlags flag, DisplayFlags mask);
109 
110 public slots:
111 
113  void setColor(QColor c);
114 
118  void setHue(qreal h);
119 
123  void setSaturation(qreal s);
124 
128  void setValue(qreal v);
129 
134  void setDisplayFlags(ColorWheel::DisplayFlags flags);
135 
136 signals:
140  void colorChanged(QColor);
141 
145  void colorSelected(QColor);
146 
147  void displayFlagsChanged(ColorWheel::DisplayFlags flags);
148 
149 protected:
150  void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
151  void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
152  void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
153  void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
154  void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
155  void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
156  void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
157 
158 private:
159  class Private;
160  Private * const p;
161 };
162 
163 Q_DECLARE_OPERATORS_FOR_FLAGS(ColorWheel::DisplayFlags)
164 
165 } // namespace color_widgets
166 
167 #endif // COLOR_WHEEL_HPP
Display an analog widget that allows the selection of a HSV color.
Definition: color_wheel.hpp:35
Mask for the angle flags.
Definition: color_wheel.hpp:57
void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE
QSize sizeHint() const Q_DECL_OVERRIDE
void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE
Use the HSL color space.
Definition: color_wheel.hpp:61
Use the HSV color space.
Definition: color_wheel.hpp:60
Use the default rotation style.
Definition: color_wheel.hpp:54
Mask for the shape flags.
Definition: color_wheel.hpp:52
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE
void setColor(QColor c)
Set current color.
void setWheelWidth(unsigned int w)
Set the width in pixels of the outer wheel.
The inner part doesn&#39;t rotate.
Definition: color_wheel.hpp:55
qreal saturation() const
Get current saturation in the range [0-1].
void setDisplayFlags(ColorWheel::DisplayFlags flags)
Set the display flags.
qreal value() const
Get current value in the range [0-1].
void setDisplayFlag(DisplayFlags flag, DisplayFlags mask)
Set a specific display flag.
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE
Mask matching all flags.
Definition: color_wheel.hpp:66
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE
static DisplayFlags defaultDisplayFlags(DisplayFlags mask=FLAGS_ALL)
Get default display flags.
void displayFlagsChanged(ColorWheel::DisplayFlags flags)
Use Luma Chroma Hue (Y_601&#39;)
Definition: color_wheel.hpp:62
unsigned wheelWidth READ
Definition: color_wheel.hpp:43
static void setDefaultDisplayFlags(DisplayFlags flags)
Set the default display flags.
Use the default colorspace.
Definition: color_wheel.hpp:59
unsigned int wheelWidth() const
Get the width in pixels of the outer wheel.
QColor color() const
Get current color.
Mask for the color space flags.
Definition: color_wheel.hpp:63
qreal hue() const
Get current hue in the range [0-1].
The inner part follows the hue selector.
Definition: color_wheel.hpp:56
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17