lib/score/widgets/ControlWidgets.hpp
1 #pragma once
2 #include <score/widgets/DoubleSlider.hpp>
3 #include <score/widgets/IntSlider.hpp>
4 
5 #include <QPushButton>
6 
7 #include <score_lib_base_export.h>
8 
9 #include <array>
10 namespace score
11 {
12 struct SCORE_LIB_BASE_EXPORT ToggleButton : public QPushButton
13 {
14 public:
15  ToggleButton(std::array<QString, 2> alts, QWidget* parent);
16 
17  ToggleButton(std::array<const char*, 2> alt, QWidget* parent);
18 
19  ToggleButton(QStringList alt, QWidget* parent);
20  ~ToggleButton();
21 
22  std::array<QString, 2> alternatives;
23 
24 protected:
25  void paintEvent(QPaintEvent* event) override;
26 };
27 
28 struct SCORE_LIB_BASE_EXPORT ValueSlider : public score::IntSlider
29 {
30 public:
31  using IntSlider::IntSlider;
32  ~ValueSlider();
33  bool moving = false;
34 
35 protected:
36  void paintEvent(QPaintEvent* event) override;
37 };
38 
39 struct SCORE_LIB_BASE_EXPORT SpeedSlider : public score::DoubleSlider
40 {
41 public:
42  explicit SpeedSlider(QWidget* parent = nullptr);
43  ~SpeedSlider();
44  bool showText = true;
45 
46  double speed() const noexcept;
47  void setSpeed(double);
48  void setTempo(double);
49 
50 protected:
51  using score::DoubleSlider::setValue;
52  using score::DoubleSlider::value;
53 
54  void paintEvent(QPaintEvent* event) override;
55  void mousePressEvent(QMouseEvent*) override;
56  void createPopup(QPoint pos) override;
57 };
58 
59 struct SCORE_LIB_BASE_EXPORT VolumeSlider : public score::DoubleSlider
60 {
61 public:
62  using DoubleSlider::DoubleSlider;
63  double map(double v) const override; //TODO this is not very DRY friendly
64  double unmap(double v) const override;
65  ~VolumeSlider();
66 
67 protected:
68  void paintEvent(QPaintEvent* event) override;
69 };
70 
71 struct SCORE_LIB_BASE_EXPORT ValueDoubleSlider : public score::DoubleSlider
72 {
73 public:
74  using score::DoubleSlider::DoubleSlider;
76 
77 protected:
78  void paintEvent(QPaintEvent* event) override;
79 };
80 
81 struct SCORE_LIB_BASE_EXPORT ValueLogDoubleSlider : public score::DoubleSlider
82 {
83 public:
84  using score::DoubleSlider::DoubleSlider;
85  double map(double v) const override;
86  double unmap(double v) const override;
88 
89 protected:
90  void paintEvent(QPaintEvent* event) override;
91 };
92 
93 struct SCORE_LIB_BASE_EXPORT ComboSlider : public score::IntSlider
94 {
95  QStringList array;
96 
97 public:
98  template <std::size_t N>
99  ComboSlider(const std::array<const char*, N>& arr, QWidget* parent)
100  : score::IntSlider{parent}
101  {
102  array.reserve(N);
103  for(auto str : arr)
104  array.push_back(str);
105  }
106 
107  ComboSlider(const QStringList& arr, QWidget* parent);
108  ~ComboSlider();
109 
110 protected:
111  void paintEvent(QPaintEvent* event) override;
112 };
113 
114 SCORE_LIB_BASE_EXPORT const QPalette& transparentPalette();
115 }
The DoubleSlider class.
Definition: DoubleSlider.hpp:19
Definition: IntSlider.hpp:12
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: lib/score/widgets/ControlWidgets.hpp:94
Definition: lib/score/widgets/ControlWidgets.hpp:40
Definition: lib/score/widgets/ControlWidgets.hpp:13
Definition: lib/score/widgets/ControlWidgets.hpp:72
Definition: lib/score/widgets/ControlWidgets.hpp:82
Definition: lib/score/widgets/ControlWidgets.hpp:29
Definition: lib/score/widgets/ControlWidgets.hpp:60