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
color_widgets::ColorWheel::ANGLE_FIXED
@ ANGLE_FIXED
The inner part doesn't rotate.
Definition: color_wheel.hpp:55
color
color
Definition: color.h:16
color_widgets::ColorWheel::setDisplayFlags
void setDisplayFlags(ColorWheel::DisplayFlags flags)
Set the display flags.
Definition: color_wheel.cpp:465
color_widgets::ColorWheel::COLOR_FLAGS
@ COLOR_FLAGS
Mask for the color space flags.
Definition: color_wheel.hpp:63
color_widgets::ColorWheel::displayFlagsChanged
void displayFlagsChanged(ColorWheel::DisplayFlags flags)
color_widgets::ColorWheel::FLAGS_ALL
@ FLAGS_ALL
Mask matching all flags.
Definition: color_wheel.hpp:66
color_widgets::ColorWheel::hue
qreal hue
Definition: color_wheel.hpp:40
color_widgets::ColorWheel::setDisplayFlag
void setDisplayFlag(DisplayFlags flag, DisplayFlags mask)
Set a specific display flag.
Definition: color_wheel.cpp:531
color_widgets::ColorWheel::~ColorWheel
~ColorWheel()
Definition: color_wheel.cpp:255
color_widgets::ColorWheel::defaultDisplayFlags
static DisplayFlags defaultDisplayFlags(DisplayFlags mask=FLAGS_ALL)
Get default display flags.
Definition: color_wheel.cpp:526
color_widgets::ColorWheel::dropEvent
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:543
color_widgets::ColorWheel::p
Private *const p
Definition: color_wheel.hpp:159
color_widgets::ColorWheel::READ
unsigned wheelWidth READ
Definition: color_wheel.hpp:43
color_widgets::ColorWheel::setDefaultDisplayFlags
static void setDefaultDisplayFlags(DisplayFlags flags)
Set the default display flags.
Definition: color_wheel.cpp:515
color_widgets::ColorWheel::COLOR_DEFAULT
@ COLOR_DEFAULT
Use the default colorspace.
Definition: color_wheel.hpp:59
color_widgets::ColorWheel::displayFlags
DisplayFlags displayFlags
Definition: color_wheel.hpp:44
color_widgets::ColorWheel::Private
Definition: color_wheel.cpp:46
color_widgets::ColorWheel::colorSelected
void colorSelected(QColor)
color_widgets
Definition: color_dialog.hpp:33
color_widgets::ColorWheel::COLOR_LCH
@ COLOR_LCH
Use Luma Chroma Hue (Y_601')
Definition: color_wheel.hpp:62
color_widgets::ColorWheel
Display an analog widget that allows the selection of a HSV color.
Definition: color_wheel.hpp:35
color_widgets::ColorWheel::SHAPE_SQUARE
@ SHAPE_SQUARE
A square.
Definition: color_wheel.hpp:51
color_widgets::ColorWheel::saturation
qreal saturation
Definition: color_wheel.hpp:41
color_widgets::ColorWheel::ColorWheel
ColorWheel(QWidget *parent=0)
Definition: color_wheel.cpp:248
color_widgets::ColorWheel::DisplayEnum
DisplayEnum
Definition: color_wheel.hpp:47
color_widgets::ColorWheel::colorChanged
void colorChanged(QColor)
color_widgets::ColorWheel::COLOR_HSL
@ COLOR_HSL
Use the HSL color space.
Definition: color_wheel.hpp:61
color_widgets::ColorWheel::FLAGS_DEFAULT
@ FLAGS_DEFAULT
Use all defaults.
Definition: color_wheel.hpp:65
color_widgets::ColorWheel::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:361
color_widgets::ColorWheel::paintEvent
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:299
color_widgets::ColorWheel::SHAPE_TRIANGLE
@ SHAPE_TRIANGLE
A triangle.
Definition: color_wheel.hpp:50
color_widgets::ColorWheel::setValue
void setValue(qreal v)
Definition: color_wheel.cpp:458
color_widgets::ColorWheel::color
QColor color
Definition: color_wheel.hpp:39
color_widgets::ColorWheel::resizeEvent
void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:429
color_widgets::ColorWheel::wheelWidth
unsigned int wheelWidth() const
Get the width in pixels of the outer wheel.
Definition: color_wheel.cpp:287
color_widgets::ColorWheel::sizeHint
QSize sizeHint() const Q_DECL_OVERRIDE
Definition: color_wheel.cpp:265
color_widgets::ColorWheel::ANGLE_ROTATING
@ ANGLE_ROTATING
The inner part follows the hue selector.
Definition: color_wheel.hpp:56
color_widgets::ColorWheel::mousePressEvent
void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:407
color_widgets::ColorWheel::value
qreal value
Definition: color_wheel.hpp:42
color_widgets::ColorWheel::ANGLE_FLAGS
@ ANGLE_FLAGS
Mask for the angle flags.
Definition: color_wheel.hpp:57
color_widgets::ColorWheel::SHAPE_FLAGS
@ SHAPE_FLAGS
Mask for the shape flags.
Definition: color_wheel.hpp:52
color_widgets::ColorWheel::setSaturation
void setSaturation(qreal s)
Definition: color_wheel.cpp:452
color_widgets::ColorWheel::ANGLE_DEFAULT
@ ANGLE_DEFAULT
Use the default rotation style.
Definition: color_wheel.hpp:54
color_widgets::ColorWheel::COLOR_HSV
@ COLOR_HSV
Use the HSV color space.
Definition: color_wheel.hpp:60
color_widgets::ColorWheel::SHAPE_DEFAULT
@ SHAPE_DEFAULT
Use the default shape.
Definition: color_wheel.hpp:49
color_widgets::ColorWheel::mouseReleaseEvent
void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:423
color_widgets::ColorWheel::setColor
void setColor(QColor c)
Set current color.
Definition: color_wheel.cpp:435
color_widgets::ColorWheel::setWheelWidth
void setWheelWidth(unsigned int w)
Set the width in pixels of the outer wheel.
Definition: color_wheel.cpp:292
color_widgets::ColorWheel::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE
Definition: color_wheel.cpp:536
color_widgets::ColorWheel::setHue
void setHue(qreal h)
Definition: color_wheel.cpp:445


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:22