QGraphicsXYChooser.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 QGraphicsXYChooser final
16  : public QObject
17  , public QGraphicsItem
18 {
19  W_OBJECT(QGraphicsXYChooser)
20  SCORE_GRAPHICS_ITEM_TYPE(250)
21  QRectF m_rect{0., 0., 100., 100.};
22 
23 private:
24  ossia::vec2f m_value{}, m_min{}, m_max{}, m_init{};
25  bool m_grab{};
26 
27 public:
28  explicit QGraphicsXYChooser(QGraphicsItem* parent);
30 
31  void setPoint(const QPointF& r);
32  void setValue(ossia::vec2f v);
33  void setRange(ossia::vec2f min, ossia::vec2f max, ossia::vec2f init);
34  ossia::vec2f value() const;
35 
36  bool moving = false;
37 
38 public:
39  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
40  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
41 
42 private:
43  ossia::vec2f scaledValue(float x, float y) const noexcept;
44  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
45  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
46  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
47  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
48  QRectF boundingRect() const override;
49  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
50  override;
51 };
52 }
Definition: QGraphicsXYChooser.hpp:18
Base toolkit upon which the software is built.
Definition: Application.cpp:90