QGraphicsCombo.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QObject>
6 #include <QStringList>
7 
8 #include <score_lib_base_export.h>
9 
10 #include <array>
11 #include <verdigris>
12 
13 namespace score
14 {
15 class SCORE_LIB_BASE_EXPORT QGraphicsCombo final
16  : public QObject
17  , public QGraphicsItem
18 {
19  W_OBJECT(QGraphicsCombo)
20  SCORE_GRAPHICS_ITEM_TYPE(30)
21  friend struct DefaultComboImpl;
22  QRectF m_rect{defaultSliderSize};
23 
24 public:
25  QStringList array;
26 
27 private:
28  int m_value{};
29  bool m_grab{};
30 
31 public:
32  template <std::size_t N>
33  QGraphicsCombo(const std::array<const char*, N>& arr, QGraphicsItem* parent)
34  : QGraphicsCombo{parent}
35  {
36  array.reserve(N);
37  for(auto str : arr)
38  array.push_back(str);
39  }
40 
41  QGraphicsCombo(QStringList arr, QGraphicsItem* parent)
42  : QGraphicsCombo{parent}
43  {
44  array = std::move(arr);
45  }
46 
47  QGraphicsCombo(QGraphicsItem* parent);
48 
49  void setRect(const QRectF& r);
50  void setValue(int v);
51  int value() const;
52 
53  bool moving = false;
54 
55  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
56  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
57 
58  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
59  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
60  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
61  QRectF boundingRect() const override;
62  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
63  override;
64 };
65 }
Definition: QGraphicsCombo.hpp:18
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: QGraphicsCombo.cpp:94