QGraphicsLogKnob.hpp
1 #pragma once
2 #include <score/graphics/widgets/Constants.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QObject>
6 
7 #include <score_lib_base_export.h>
8 
9 #include <verdigris>
10 
11 namespace score
12 {
13 class SCORE_LIB_BASE_EXPORT QGraphicsLogKnob final
14  : public QObject
15  , public QGraphicsItem
16 {
17  W_OBJECT(QGraphicsLogKnob)
18  Q_INTERFACES(QGraphicsItem)
19  friend struct DefaultGraphicsKnobImpl;
20 
21  double m_value{};
22  double m_execValue{};
23  QRectF m_rect{defaultKnobSize};
24 
25 public:
26  double min{}, max{};
27 
28 private:
29  bool m_grab{};
30  bool m_hasExec{};
31 
32 public:
33  QGraphicsLogKnob(QGraphicsItem* parent);
34 
35  double map(double v) const noexcept;
36  double unmap(double v) const noexcept;
37 
38  void setRect(const QRectF& r);
39  void setRange(double min, double max);
40  void setValue(double v);
41  double value() const;
42  void setExecutionValue(double v);
43  void resetExecution();
44 
45  QRectF boundingRect() const override;
46 
47  bool moving = false;
48 
49 public:
50  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
51  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
52 
53 private:
54  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
55  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
56  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
57  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
58  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
59 
60  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
61  override;
62 };
63 }
Definition: QGraphicsLogKnob.hpp:16
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DefaultGraphicsKnobImpl.hpp:22