MuseScore  3.4
Music composition and notation
aslider.h
Go to the documentation of this file.
1 //=============================================================================
2 // Awl
3 // Audio Widget Library
4 //
5 // Copyright (C) 2002-2006 by Werner Schweer and others
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19 
20 #ifndef __AWLASLIDER_H__
21 #define __AWLASLIDER_H__
22 
23 // #include "synthesizer/sparm.h"
24 #include <QAccessibleWidget>
25 
26 namespace Awl {
27 
28 //---------------------------------------------------------
29 // AbstractSlider
30 //
33 //
37 //---------------------------------------------------------
38 
39 class AbstractSlider : public QWidget {
40  Q_OBJECT
41  Q_PROPERTY(double value READ value WRITE setValue)
42  Q_PROPERTY(bool center READ center WRITE setCenter)
44 
45  Q_PROPERTY(int scaleWidth READ scaleWidth WRITE setScaleWidth)
46  Q_PROPERTY(QColor scaleColor READ scaleColor WRITE setScaleColor)
47  Q_PROPERTY(QColor scaleValueColor READ scaleValueColor WRITE setScaleValueColor)
48 
49  Q_PROPERTY(int id READ id WRITE setId)
50 
51  Q_PROPERTY(double minValue READ minValue WRITE setMinValue)
52  Q_PROPERTY(double maxValue READ maxValue WRITE setMaxValue)
53  Q_PROPERTY(double lineStep READ lineStep WRITE setLineStep)
54  Q_PROPERTY(double pageStep READ pageStep WRITE setPageStep)
55  Q_PROPERTY(bool log READ log WRITE setLog)
56 
57  Q_PROPERTY(double dclickValue1 READ dclickValue1 WRITE setDclickValue1)
58  Q_PROPERTY(double dclickValue2 READ dclickValue2 WRITE setDclickValue2)
59 
60  protected:
61  int __id;
62  double _value;
64  double _dclickValue1;
65  double _dclickValue2;
66  bool _center;
68  bool _invert;
70  QColor _scaleColor;
72  bool _log;
74 
75  virtual void wheelEvent(QWheelEvent*);
76  virtual void keyPressEvent(QKeyEvent*);
77  virtual void mouseDoubleClickEvent(QMouseEvent*);
78  virtual void valueChange();
79 
80  signals:
81  void valueChanged(double, int);
82 
83  public slots:
84  virtual void setValue(double v);
85 
86  public:
87  AbstractSlider(QWidget* parent = 0);
88 
89  virtual void setCenter(bool val);
90  virtual void setScaleWidth(int);
91  virtual void setScaleColor(const QColor&);
92  virtual void setScaleValueColor(const QColor&);
93 
95  virtual void setEnableMouseWheel(bool enabled);
96 
98  bool center() const { return _center; }
99 
101  int scaleWidth() const { return _scaleWidth; }
102 
104  QColor scaleColor() const { return _scaleColor; }
105 
107  QColor scaleValueColor() const { return _scaleValueColor; }
108 
109  virtual void setInvertedAppearance(bool val) { _invert = val; }
110  bool invertedAppearance() const { return _invert; }
111 
112  int id() const { return __id; }
113  void setId(int i) { __id = i; }
114 
115  virtual double value() const;
116  virtual QString userValue() const;
117 
118  double minValue() const { return _minValue; }
119  void setMinValue(double v) { _minValue = v; }
120  void setMinLogValue(double v);
121  double maxValue() const {return _maxValue; }
122  void setMaxValue(double v) { _maxValue = v; }
123  void setMaxLogValue(double v);
124  void setRange(double a, double b) {
125  setMinValue(a);
126  setMaxValue(b);
127  }
128  void setLogRange(double a, double b) {
129  setMinLogValue(a);
130  setMaxLogValue(b);
131  }
132  bool log() const { return _log; }
133  void setLog(bool v) { _log = v; }
134  double lineStep() const { return _lineStep; }
135  void setLineStep(double v) { _lineStep = v; }
136  double pageStep() const { return _pageStep; }
137  void setPageStep(double f) { _pageStep = f; }
138  double dclickValue1() const { return _dclickValue1; }
139  double dclickValue2() const { return _dclickValue2; }
140  void setDclickValue1(double val) { _dclickValue1 = val; }
141  void setDclickValue2(double val) { _dclickValue2 = val; }
142  void setEnabled(bool val);
143  void setUseActualValue(bool v) { _useActualValue = v; }
144  };
145 
146 class AccessibleAbstractSlider : public QObject, QAccessibleWidget {
147  Q_OBJECT
149  QAccessible::Role role() const Q_DECL_OVERRIDE;
150  QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
151 public:
152  static QAccessibleInterface* AbstractSliderFactory(const QString &classname, QObject *object);
154 public slots:
155  void valueChanged(double,int);
156 };
157 
158 }
159 
160 #endif
161 
virtual void setEnableMouseWheel(bool enabled)
Definition: aslider.cpp:63
void valueChanged(double, int)
void setDclickValue2(double val)
Definition: aslider.h:141
void setDclickValue1(double val)
Definition: aslider.h:140
void setLineStep(double v)
Definition: aslider.h:135
double lineStep() const
Definition: aslider.h:134
void setLog(bool v)
Definition: aslider.h:133
double maxValue() const
Definition: aslider.h:121
bool log() const
Definition: aslider.h:132
void setMaxLogValue(double v)
Definition: aslider.cpp:277
virtual void setScaleValueColor(const QColor &)
Definition: aslider.cpp:110
virtual void setInvertedAppearance(bool val)
Definition: aslider.h:109
QColor scaleValueColor() const
return color of active scale part
Definition: aslider.h:107
double minValue() const
Definition: aslider.h:118
virtual void setScaleWidth(int)
Definition: aslider.cpp:86
void setRange(double a, double b)
Definition: aslider.h:124
bool _enableMouseWheel
Definition: aslider.h:67
double _pageStep
Definition: aslider.h:63
virtual void setCenter(bool val)
If the center flag is set, a notch is drawn to show the center position.
Definition: aslider.cpp:74
bool _log
Definition: aslider.h:72
double _value
Definition: aslider.h:62
int id() const
Definition: aslider.h:112
AbstractSlider * slider
Definition: aslider.h:148
double _dclickValue2
Definition: aslider.h:65
double _minValue
Definition: aslider.h:63
double _maxValue
Definition: aslider.h:63
void setUseActualValue(bool v)
Definition: aslider.h:143
Definition: aslider.h:146
void setMinValue(double v)
Definition: aslider.h:119
QColor _scaleValueColor
Definition: aslider.h:71
int __id
Definition: aslider.h:61
void setEnabled(bool val)
Definition: aslider.cpp:53
bool _useActualValue
Definition: aslider.h:73
virtual void setValue(double v)
Definition: aslider.cpp:185
virtual void wheelEvent(QWheelEvent *)
for user value
Definition: aslider.cpp:122
QColor scaleColor() const
return current scale color
Definition: aslider.h:104
bool center() const
return the center flag
Definition: aslider.h:98
virtual void setScaleColor(const QColor &)
Definition: aslider.cpp:98
bool _center
Definition: aslider.h:66
void setPageStep(double f)
Definition: aslider.h:137
bool enableMouseWheel()
Definition: aslider.h:94
The AwlAbstractSlider class provides an double value within a range.
Definition: aslider.h:39
void setId(int i)
Definition: aslider.h:113
virtual double value() const
double dclickValue2() const
Definition: aslider.h:139
double _lineStep
Definition: aslider.h:63
virtual void mouseDoubleClickEvent(QMouseEvent *)
Definition: aslider.cpp:172
void setLogRange(double a, double b)
Definition: aslider.h:128
bool invertedAppearance() const
Definition: aslider.h:110
Definition: aslider.cpp:23
QColor _scaleColor
scale line width
Definition: aslider.h:70
void setMinLogValue(double v)
Definition: aslider.cpp:253
int _scaleWidth
Definition: aslider.h:69
Definition: text.h:24
int scaleWidth() const
return the scale line width
Definition: aslider.h:101
double pageStep() const
Definition: aslider.h:136
virtual QString userValue() const
Definition: aslider.cpp:230
virtual void keyPressEvent(QKeyEvent *)
Definition: aslider.cpp:142
virtual void valueChange()
Definition: aslider.cpp:211
double dclickValue1() const
Definition: aslider.h:138
bool _invert
Definition: aslider.h:68
void setMaxValue(double v)
Definition: aslider.h:122
double _dclickValue1
Definition: aslider.h:64