All Classes Namespaces Functions Variables Enumerations Properties Pages
spinslider.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 
19 #ifndef SPINSLIDER_H
20 #define SPINSLIDER_H
21 
22 #include <QWidget>
23 
24 class QLabel;
25 class QSlider;
26 class QStyle;
27 
28 
29 class SpinSlider : public QWidget
30 {
31  Q_OBJECT
32 public:
33  enum GROWTH_TYPE
34  {
35  LINEAR,
36  LOG,
37  EXPONENT,
38  };
39 
40  enum VALUE_TYPE
41  {
42  INTEGER,
43  FLOAT,
44  };
45  SpinSlider(QWidget* parent = nullptr);
46  void init(QString text, GROWTH_TYPE, VALUE_TYPE, qreal min, qreal max);
47  void setValue(qreal);
48  void setPixelPos(qreal min, qreal max, int val, int space, bool upsideDown);
49  void setExponent(const qreal);
50  void setLabel(QString newText);
51 
52 signals:
53  void valueChanged(qreal);
54 
55 private:
56  void onSliderValueChanged(int);
57  void changeValue(qreal);
58 
59 private:
60  QSlider* mSlider = nullptr;
61  qreal mValue = 50.0;
62  qreal mMin = 0.1;
63  qreal mMax = 100.0;
64  qreal mExp = 2.0;
65  QString mText = "";
66  QLabel* mLabel = nullptr;
67 
68  GROWTH_TYPE mGrowthType = LINEAR;
69  VALUE_TYPE mValueType = INTEGER;
70 };
71 
72 #endif // SPINSLIDER_H
Q_OBJECTQ_OBJECT
QObject * parent() const const