Olive
labelslider.h
Go to the documentation of this file.
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 
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:
195 
197  double min_value;
199  double max_value;
200 
202  bool drag_proc;
205 
206  bool set;
207 
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
int display_type
Definition: labelslider.h:208
double max_value
Definition: labelslider.h:199
void set_maximum_value(double v)
Set the maximum value.
Definition: labelslider.cpp:146
bool min_enabled
Definition: labelslider.h:196
void set_default_value(double v)
Set the default value.
Definition: labelslider.cpp:133
double frame_rate
Definition: labelslider.h:210
double previous_value
Definition: labelslider.h:194
bool is_dragging()
Returns whether the user is currently dragging.
Definition: labelslider.cpp:80
bool drag_proc
Definition: labelslider.h:202
bool set
Definition: labelslider.h:206
LabelSliderDisplayType
Definition: labelslider.h:27
double drag_start_value
Definition: labelslider.h:193
void mousePressEvent(QMouseEvent *ev)
Definition: labelslider.cpp:151
LabelSlider(QWidget *parent=nullptr)
Definition: labelslider.cpp:33
void clicked()
clicked signal
Definition: labelslider.h:30
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
Definition: labelslider.h:29
int drag_start_x
Definition: labelslider.h:203
bool is_set()
Returns whether a value has been set or not.
Definition: labelslider.cpp:76
void mouseReleaseEvent(QMouseEvent *ev)
Definition: labelslider.cpp:239
bool drag_start
Definition: labelslider.h:201
void set_previous_value()
Updates previous value.
Definition: labelslider.cpp:120
double min_value
Definition: labelslider.h:197
double getPreviousValue()
Returns whatever value was set before the last set_value()
Definition: labelslider.cpp:116
double internal_value
Definition: labelslider.h:192
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
Definition: labelslider.h:28
void valueChanged()
valueChanged signal
double default_value
Definition: labelslider.h:191
int drag_start_y
Definition: labelslider.h:204
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
bool max_enabled
Definition: labelslider.h:198
void set_default_cursor()
Internal function to set the standard cursor (usually SizeHorCursor)
Definition: labelslider.cpp:335
void mouseMoveEvent(QMouseEvent *ev)
Definition: labelslider.cpp:197
QString valueToString()
Convert the internal value to a displayed string according to display_type
Definition: labelslider.cpp:84
Definition: labelslider.h:31