MuseScore  3.4
Music composition and notation
styledslider.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 __STYLEDSLIDER_H__
21 #define __STYLEDSLIDER_H__
22 
23 #include <QWidget>
24 #include <QIcon>
25 
26 
27 namespace Awl {
28 
29 class StyledSlider : public QWidget
30  {
31  Q_OBJECT
32 
33  QList<double> marks;
34 
35  double _minValue = 0;
36  double _maxValue = 127;
37  double _value;
38  double _barThickness = 4;
39  double _margin = 20;
40  int _numMajorTicks = 10;
41  int _numMinorTicks = 4;
42  double _majorTickWidth = 30;
43  double _minorTickWidth = 10;
44  double _doubleClickValue = 63;
45 
46  QColor _backgroundColor = QColor(10, 10, 10);
47  QColor _hilightColor = QColor(0, 255, 0);
48  QColor _tickColor = QColor(150, 150, 150);
49 
51  QPoint mouseDownPos;
52  double mouseDownVal;
53 
55 
56 public:
57  explicit StyledSlider(QWidget *parent = nullptr);
58  virtual QSize sizeHint() const { return QSize(50, 50); }
59  virtual void paintEvent(QPaintEvent *ev);
60  virtual void mousePressEvent(QMouseEvent*);
61  virtual void mouseReleaseEvent(QMouseEvent*);
62  virtual void mouseMoveEvent(QMouseEvent*);
63  virtual void wheelEvent(QWheelEvent*);
64  virtual void keyPressEvent(QKeyEvent*);
65 
66  double maxValue() const { return _maxValue; }
67  double minValue() const { return _minValue; }
68  double value() const { return _value; }
69  double barThickness() const { return _barThickness; }
70  double margin() const { return _margin; }
71  double numMajorTicks() const { return _numMajorTicks; }
72  int numMinorTicks() const { return _numMinorTicks; }
73  double majorTickWidth() const { return _majorTickWidth; }
74  double minorTickWidth() const { return _minorTickWidth; }
75  QColor backgroundColor() const { return _backgroundColor; }
76  QColor hilightColor() const { return _hilightColor; }
77  QColor tickColor() const { return _tickColor; }
78  QIcon sliderHeadIcon() const { return _sliderHeadIcon; }
79  void addMark(double value) { marks.append(value); }
80  void mouseDoubleClickEvent(QMouseEvent*);
81  void setDoubleClickValue(double value) { _doubleClickValue = value; }
82 
83 signals:
84  void valueChanged(double);
85  void minValueChanged(double);
86  void maxValueChanged(double);
87  void sliderPressed();
88 
89 public slots:
90  void setValue(double v);
91  void setMinValue(double v);
92  void setMaxValue(double v);
93  void setBarThickness(double v);
94  void setMargin(double v);
95  void setNumMajorTicks(int v);
96  void setNumMinorTicks(int v);
97  void setMajorTickWidth(double v);
98  void setMinorTickWidth(double v);
99 
100  void setBackgroundColor(QColor v);
101  void setHilightColor(QColor v);
102  void setTickColor(QColor v);
103  void setSliderHeadIcon(QIcon v);
104  };
105 
106 }
107 #endif // __STYLEDSLIDER_H__
double mouseDownVal
Definition: styledslider.h:52
double _majorTickWidth
Definition: styledslider.h:42
void addMark(double value)
Definition: styledslider.h:79
void setMinorTickWidth(double v)
Definition: styledslider.cpp:335
QColor hilightColor() const
Definition: styledslider.h:76
double numMajorTicks() const
Definition: styledslider.h:71
void minValueChanged(double)
double _minorTickWidth
Definition: styledslider.h:43
virtual void mouseReleaseEvent(QMouseEvent *)
Definition: styledslider.cpp:95
QColor _hilightColor
Definition: styledslider.h:47
int _numMajorTicks
Definition: styledslider.h:40
double _margin
Definition: styledslider.h:39
virtual void mousePressEvent(QMouseEvent *)
Definition: styledslider.cpp:83
double margin() const
Definition: styledslider.h:70
void setHilightColor(QColor v)
Definition: styledslider.cpp:265
StyledSlider(QWidget *parent=nullptr)
Definition: styledslider.cpp:34
virtual QSize sizeHint() const
Definition: styledslider.h:58
void valueChanged(double)
int numMinorTicks() const
Definition: styledslider.h:72
void setMaxValue(double v)
Definition: styledslider.cpp:242
Definition: styledslider.h:29
double majorTickWidth() const
Definition: styledslider.h:73
virtual void keyPressEvent(QKeyEvent *)
Definition: styledslider.cpp:66
double _minValue
Definition: styledslider.h:35
virtual void paintEvent(QPaintEvent *ev)
Definition: styledslider.cpp:124
void setSliderHeadIcon(QIcon v)
Definition: styledslider.cpp:345
QPoint mouseDownPos
Definition: styledslider.h:51
double minorTickWidth() const
Definition: styledslider.h:74
void setNumMajorTicks(int v)
Definition: styledslider.cpp:305
QColor tickColor() const
Definition: styledslider.h:77
void mouseDoubleClickEvent(QMouseEvent *)
Definition: styledslider.cpp:41
double _barThickness
Definition: styledslider.h:38
void setNumMinorTicks(int v)
Definition: styledslider.cpp:315
int _numMinorTicks
Definition: styledslider.h:41
void setMinValue(double v)
Definition: styledslider.cpp:229
QList< double > marks
Definition: styledslider.h:33
double value() const
Definition: styledslider.h:68
double maxValue() const
Definition: styledslider.h:66
QIcon _sliderHeadIcon
Definition: styledslider.h:54
QIcon sliderHeadIcon() const
Definition: styledslider.h:78
double _doubleClickValue
Definition: styledslider.h:44
void setMajorTickWidth(double v)
Definition: styledslider.cpp:325
bool draggingMouse
Definition: styledslider.h:50
void setDoubleClickValue(double value)
Definition: styledslider.h:81
QColor backgroundColor() const
Definition: styledslider.h:75
void setMargin(double v)
Definition: styledslider.cpp:295
double minValue() const
Definition: styledslider.h:67
QColor _backgroundColor
Definition: styledslider.h:46
void setValue(double v)
Definition: styledslider.cpp:215
Definition: aslider.cpp:23
void setTickColor(QColor v)
Definition: styledslider.cpp:275
virtual void wheelEvent(QWheelEvent *)
Definition: styledslider.cpp:52
double _maxValue
Definition: styledslider.h:36
void setBackgroundColor(QColor v)
Definition: styledslider.cpp:255
void setBarThickness(double v)
Definition: styledslider.cpp:285
double _value
Definition: styledslider.h:37
QColor _tickColor
Definition: styledslider.h:48
double barThickness() const
Definition: styledslider.h:69
void maxValueChanged(double)
virtual void mouseMoveEvent(QMouseEvent *)
Definition: styledslider.cpp:105