Olive
labelslider.h
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
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  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef LABELSLIDER_H
22 #define LABELSLIDER_H
23 
24 #include <QLabel>
25 #include <QUndoCommand>
26 
27 enum LabelSliderDisplayType {
28  LABELSLIDER_NORMAL,
29  LABELSLIDER_FRAMENUMBER,
30  LABELSLIDER_PERCENT,
31  LABELSLIDER_DECIBEL
32 };
33 
40 class LabelSlider : public QLabel
41 {
42  Q_OBJECT
43 public:
44  LabelSlider(QWidget* parent = nullptr);
45 
54  void set_frame_rate(double d);
55 
70  void set_display_type(int type);
71 
84  void set_value(double v, bool userSet);
85 
95  void set_default_value(double v);
96 
107  void set_minimum_value(double v);
108 
119  void set_maximum_value(double v);
120 
126  double value();
127 
139  bool is_set();
140 
145  bool is_dragging();
146 
151  QString valueToString();
152 
162  double getPreviousValue();
163 
170  void set_previous_value();
171 
178  void set_color(QString c = nullptr);
179 
186 protected:
187  void mousePressEvent(QMouseEvent *ev);
188  void mouseMoveEvent(QMouseEvent *ev);
189  void mouseReleaseEvent(QMouseEvent *ev);
190 private:
191  double default_value;
192  double internal_value;
193  double drag_start_value;
194  double previous_value;
195 
196  bool min_enabled;
197  double min_value;
198  bool max_enabled;
199  double max_value;
200 
201  bool drag_start;
202  bool drag_proc;
203  int drag_start_x;
204  int drag_start_y;
205 
206  bool set;
207 
208  int display_type;
209 
210  double frame_rate;
211 
215  void set_default_cursor();
216 
220  void set_active_cursor();
221 signals:
227  void valueChanged();
228 
234  void clicked();
235 };
236 
237 #endif // LABELSLIDER_H
void set_display_type(int type)
Sets the way to display the value.
Definition: labelslider.cpp:55
void set_maximum_value(double v)
Set the maximum value.
Definition: labelslider.cpp:146
void set_default_value(double v)
Set the default value.
Definition: labelslider.cpp:133
bool is_dragging()
Returns whether the user is currently dragging.
Definition: labelslider.cpp:80
void clicked()
clicked signal
void set_minimum_value(double v)
Set the minimum value.
Definition: labelslider.cpp:141
void set_color(QString c=nullptr)
Set the display color.
Definition: labelslider.cpp:124
void set_value(double v, bool userSet)
Set the value.
Definition: labelslider.cpp:60
bool is_set()
Returns whether a value has been set or not.
Definition: labelslider.cpp:76
void set_previous_value()
Updates previous value.
Definition: labelslider.cpp:120
double getPreviousValue()
Returns whatever value was set before the last set_value()
Definition: labelslider.cpp:116
void set_frame_rate(double d)
Set the display frame rate.
Definition: labelslider.cpp:51
int decimal_places
Set how many decimal places to show for a floating-point number.
Definition: labelslider.h:185
The LabelSlider class.
Definition: labelslider.h:40
void valueChanged()
valueChanged signal
double value()
Returns the internal value as a double.
Definition: labelslider.cpp:129
void set_active_cursor()
Internal function to set the cursor while dragging (usually NoCursor aka invisible)
Definition: labelslider.cpp:339
void set_default_cursor()
Internal function to set the standard cursor (usually SizeHorCursor)
Definition: labelslider.cpp:335
QString valueToString()
Convert the internal value to a displayed string according to display_type
Definition: labelslider.cpp:84