QGraphicsXYSpinbox.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 #include <score/graphics/widgets/QGraphicsSpinbox.hpp>
4 
5 #include <ossia-qt/value_metatypes.hpp>
6 
7 #include <QGraphicsItem>
8 #include <QObject>
9 
10 #include <score_lib_base_export.h>
11 
12 #include <verdigris>
13 
14 namespace score
15 {
16 struct DefaultGraphicsSpinboxImpl;
17 class SCORE_LIB_BASE_EXPORT QGraphicsXYSpinboxChooser final
18  : public QObject
19  , public QGraphicsItem
20 {
22  SCORE_GRAPHICS_ITEM_TYPE(260)
23  friend struct DefaultGraphicsSpinboxImpl;
24  QRectF m_rect{0., 0., 150., 24.};
25  QGraphicsSpinbox m_x, m_y;
26 
27  bool m_isRange{};
28 
29 public:
30  explicit QGraphicsXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
32 
33  void setPoint(const QPointF& r);
34  void setValue(ossia::vec2f v);
35  void setRange(
36  ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
37  ossia::vec2f init = {0.f, 0.f});
38 
39  ossia::vec2f value() const noexcept;
40  ossia::vec2f getMin() const noexcept;
41  ossia::vec2f getMax() const noexcept;
42 
43  bool moving = false;
44 
45 public:
46  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
47  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
48 
49 private:
50  ossia::vec2f scaledValue(float x, float y) const noexcept;
51  QRectF boundingRect() const override;
52  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
53  override;
54 };
55 
56 class SCORE_LIB_BASE_EXPORT QGraphicsIntXYSpinboxChooser final
57  : public QObject
58  , public QGraphicsItem
59 {
61  SCORE_GRAPHICS_ITEM_TYPE(270)
62  friend struct DefaultGraphicsSpinboxImpl;
63  QRectF m_rect{0., 0., 150., 24.};
64  QGraphicsIntSpinbox m_x, m_y;
65 
66  bool m_grab{};
67  bool m_isRange{};
68 
69 public:
70  explicit QGraphicsIntXYSpinboxChooser(bool isRange, QGraphicsItem* parent);
72 
73  void setPoint(const QPointF& r);
74  void setValue(ossia::vec2f v);
75  void setRange(
76  ossia::vec2f min = {0.f, 0.f}, ossia::vec2f max = {1.f, 1.f},
77  ossia::vec2f init = {0.f, 0.f});
78 
79  ossia::vec2f value() const noexcept;
80  ossia::vec2f getMin() const noexcept;
81  ossia::vec2f getMax() const noexcept;
82 
83  bool moving = false;
84 
85 public:
86  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
87  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
88 
89 private:
90  ossia::vec2f scaledValue(float x, float y) const noexcept;
91  QRectF boundingRect() const override;
92  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
93  override;
94 };
95 }
Definition: QGraphicsSpinbox.hpp:64
Definition: QGraphicsXYSpinbox.hpp:59
Definition: QGraphicsSpinbox.hpp:15
Definition: QGraphicsXYSpinbox.hpp:20
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DefaultGraphicsSpinboxImpl.hpp:24