DoubleSlider.hpp
1 #pragma once
2 #include <QProxyStyle>
3 #include <QSlider>
4 
5 #include <score_lib_base_export.h>
6 
7 #include <limits>
8 #include <verdigris>
9 
10 namespace score
11 {
18 class SCORE_LIB_BASE_EXPORT DoubleSlider : public QWidget //: public QSlider
19 {
20  W_OBJECT(DoubleSlider)
21 public:
22  DoubleSlider(Qt::Orientation ort, QWidget* widg);
23  DoubleSlider(QWidget* widg);
24  ~DoubleSlider() override;
25  bool moving = false;
26  void setValue(double val);
27  void setOrientation(Qt::Orientation ort) { m_orientation = ort; }
28  void setBorderWidth(double border) { m_borderWidth = border; }
29 
30  double value() const { return m_value; }
31  virtual double map(double v) const;
32  virtual double unmap(double v) const;
33  double min{}; //TODO make it private. Warning used like this in a lot of places.
34  double max{}; //ditto
35  double init{}; //ditto
36 
37  void valueChanged(double arg_1) E_SIGNAL(SCORE_LIB_BASE_EXPORT, valueChanged, arg_1)
38  void sliderMoved(double arg_1) E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderMoved, arg_1)
39  void sliderReleased() E_SIGNAL(SCORE_LIB_BASE_EXPORT, sliderReleased)
40 
41  void mousePressEvent(QMouseEvent* event) override;
42  void mouseMoveEvent(QMouseEvent* event) override;
43  void mouseReleaseEvent(QMouseEvent* event) override;
44  virtual void createPopup(QPoint pos);
45  virtual void setRange(double min, double max, double init) noexcept;
46 
47 protected:
48  void paintEvent(QPaintEvent*) override;
49  void paint(QPainter& p);
50  void paintWithText(const QString& s);
51 
52 private:
53  void updateValue(QPointF mousePos);
54 
55  double m_value{};
56  Qt::Orientation m_orientation{};
57  double m_borderWidth{};
58 };
59 }
The DoubleSlider class.
Definition: DoubleSlider.hpp:19
Base toolkit upon which the software is built.
Definition: Application.cpp:90