QGraphicsHSVChooser.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 
4 #include <ossia-qt/value_metatypes.hpp>
5 
6 #include <QGraphicsItem>
7 #include <QObject>
8 
9 #include <score_lib_base_export.h>
10 
11 #include <verdigris>
12 
13 namespace score
14 {
15 class SCORE_LIB_BASE_EXPORT QGraphicsHSVChooser final
16  : public QObject
17  , public QGraphicsItem
18 {
19  W_OBJECT(QGraphicsHSVChooser)
20  SCORE_GRAPHICS_ITEM_TYPE(50)
21 private:
22  QRectF m_rect{0., 0., 140., 100.};
23 
24  double h{}, s{}, v{};
25  double prev_v{-1.};
26  ossia::vec4f m_value{};
27  QImage hs_zone;
28  bool m_grab{};
29 
30 public:
31  QGraphicsHSVChooser(QGraphicsItem* parent);
32 
33  void setRect(const QRectF& r);
34  void setRgbaValue(ossia::vec4f v);
35  void setHsvValue(ossia::vec4f v);
36  ossia::vec4f rgbaValue() const;
37  ossia::vec4f hsvValue() const;
38 
39  bool moving = false;
40 
41 public:
42  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
43  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
44 
45 private:
46  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
47  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
48  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
49  QRectF boundingRect() const override;
50  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
51  override;
52 };
53 }
Definition: QGraphicsHSVChooser.hpp:18
Base toolkit upon which the software is built.
Definition: Application.cpp:90