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