Olive
labelslider.h
1 #ifndef LABELSLIDER_H
2 #define LABELSLIDER_H
3 
4 #include <QLabel>
5 #include <QUndoCommand>
6 
7 enum LabelSliderDisplayType {
8  LABELSLIDER_NORMAL,
9  LABELSLIDER_FRAMENUMBER,
10  LABELSLIDER_PERCENT,
11  LABELSLIDER_DECIBEL
12 };
13 
20 class LabelSlider : public QLabel
21 {
22  Q_OBJECT
23 public:
24  LabelSlider(QWidget* parent = nullptr);
25 
34  void set_frame_rate(double d);
35 
50  void set_display_type(int type);
51 
64  void set_value(double v, bool userSet);
65 
75  void set_default_value(double v);
76 
87  void set_minimum_value(double v);
88 
99  void set_maximum_value(double v);
100 
106  double value();
107 
119  bool is_set();
120 
125  bool is_dragging();
126 
131  QString valueToString();
132 
142  double getPreviousValue();
143 
150  void set_previous_value();
151 
158  void set_color(QString c = nullptr);
159 
166 protected:
167  void mousePressEvent(QMouseEvent *ev);
168  void mouseMoveEvent(QMouseEvent *ev);
169  void mouseReleaseEvent(QMouseEvent *ev);
170 private:
171  double default_value;
172  double internal_value;
173  double drag_start_value;
174  double previous_value;
175 
176  bool min_enabled;
177  double min_value;
178  bool max_enabled;
179  double max_value;
180 
181  bool drag_start;
182  bool drag_proc;
183  int drag_start_x;
184  int drag_start_y;
185 
186  bool set;
187 
188  int display_type;
189 
190  double frame_rate;
191 
195  void set_default_cursor();
196 
200  void set_active_cursor();
201 signals:
207  void valueChanged();
208 
214  void clicked();
215 };
216 
217 #endif // LABELSLIDER_H
void set_display_type(int type)
Sets the way to display the value.
Definition: labelslider.cpp:35
void set_maximum_value(double v)
Set the maximum value.
Definition: labelslider.cpp:126
void set_default_value(double v)
Set the default value.
Definition: labelslider.cpp:113
bool is_dragging()
Returns whether the user is currently dragging.
Definition: labelslider.cpp:60
void clicked()
clicked signal
void set_minimum_value(double v)
Set the minimum value.
Definition: labelslider.cpp:121
void set_color(QString c=nullptr)
Set the display color.
Definition: labelslider.cpp:104
void set_value(double v, bool userSet)
Set the value.
Definition: labelslider.cpp:40
bool is_set()
Returns whether a value has been set or not.
Definition: labelslider.cpp:56
void set_previous_value()
Updates previous value.
Definition: labelslider.cpp:100
double getPreviousValue()
Returns whatever value was set before the last set_value()
Definition: labelslider.cpp:96
void set_frame_rate(double d)
Set the display frame rate.
Definition: labelslider.cpp:31
int decimal_places
Set how many decimal places to show for a floating-point number.
Definition: labelslider.h:165
The LabelSlider class.
Definition: labelslider.h:20
void valueChanged()
valueChanged signal
double value()
Returns the internal value as a double.
Definition: labelslider.cpp:109
void set_active_cursor()
Internal function to set the cursor while dragging (usually NoCursor aka invisible)
Definition: labelslider.cpp:319
void set_default_cursor()
Internal function to set the standard cursor (usually SizeHorCursor)
Definition: labelslider.cpp:315
QString valueToString()
Convert the internal value to a displayed string according to display_type
Definition: labelslider.cpp:64