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  SCORE_GRAPHICS_ITEM_TYPE(100)
20  friend struct DefaultControlImpl;
21  friend struct DefaultGraphicsSliderImpl;
23 
24  double m_value{};
25  double m_execValue{};
26 
27 public:
28  double min{}, max{}, init{};
29 
30 private:
31  bool m_grab{};
32  bool m_hasExec{};
33 
34 public:
35  explicit QGraphicsLogSlider(QGraphicsItem* parent);
37 
38  void setRange(double min, double max, double init);
39  void setValue(double v);
40  double value() const;
41  void setExecutionValue(double v);
42  void resetExecution();
43 
44  double from01(double v) const noexcept;
45  double map(double v) const noexcept;
46  double unmap(double v) const noexcept;
47 
48  bool moving = false;
49 
50 public:
51  void sliderMoved() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved)
52  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
53 
54 private:
55  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
56  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
57  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
58  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
59  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
60  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
61  override;
62 };
63 }
Definition: QGraphicsLogSlider.hpp:17
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DefaultControlImpl.hpp:10
Definition: DefaultGraphicsSliderImpl.hpp:31
Definition: QGraphicsSliderBase.hpp:17