Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
33 class LabelSlider : public QLabel
34 {
35  Q_OBJECT
36 public:
37  LabelSlider(QWidget* parent = nullptr);
38 
51  void SetValue(double v);
52 
62  void SetDefault(double v);
63 
69  double value();
70 
71  enum DisplayType {
76  };
77 
92  void SetDisplayType(const DisplayType& type);
93 
98  bool IsDragging();
99 
106  void SetColor(QString c = nullptr);
107 
116  void SetFrameRate(double d);
117 
123  void SetDecimalPlaces(int places);
124 public slots:
135  void SetMinimum(double v);
136 
147  void SetMaximum(double v);
148 
149 protected:
150  void mousePressEvent(QMouseEvent *ev);
151  void mouseMoveEvent(QMouseEvent *ev);
152  void mouseReleaseEvent(QMouseEvent *ev);
153 private:
154 
159  QString ValueToString();
160 
164 
166 
168  double min_value;
170  double max_value;
171 
173  bool drag_proc;
176 
177  bool set;
178 
180 
181  double frame_rate;
182 
186  void SetDefaultCursor();
187 
191  void SetActiveCursor();
192 private slots:
200  void ShowContextMenu(const QPoint& pos);
201 
205  void ResetToDefault();
206 
214  void ShowDialog();
215 signals:
221  void valueChanged(double d);
222 
228  void clicked();
229 };
230 
231 #endif // LABELSLIDER_H
int drag_start_y
Definition: labelslider.h:175
void SetMinimum(double v)
Set the minimum value.
Definition: labelslider.cpp:146
void ShowDialog()
Show prompt asking for value.
Definition: labelslider.cpp:293
void SetColor(QString c=nullptr)
Set the display color.
Definition: labelslider.cpp:123
void SetMaximum(double v)
Set the maximum value.
Definition: labelslider.cpp:151
void SetFrameRate(double d)
Set the display frame rate.
Definition: labelslider.cpp:57
bool min_enabled
Definition: labelslider.h:167
LabelSlider(QWidget *parent=nullptr)
Definition: labelslider.cpp:36
void valueChanged(double d)
valueChanged signal
double min_value
Definition: labelslider.h:168
void SetDefault(double v)
Set the default value.
Definition: labelslider.cpp:138
void mouseReleaseEvent(QMouseEvent *ev)
Definition: labelslider.cpp:236
void SetDecimalPlaces(int places)
Set how many decimal places to show for a floating-point number.
Definition: labelslider.cpp:61
void mouseMoveEvent(QMouseEvent *ev)
Definition: labelslider.cpp:193
void ShowContextMenu(const QPoint &pos)
Context menu slot to be connected to QWidget::customContextMenuRequested(const QPoint&amp;) ...
Definition: labelslider.cpp:267
Definition: labelslider.h:73
void ResetToDefault()
Slot to reset current value to the default value.
Definition: labelslider.cpp:280
double max_value
Definition: labelslider.h:170
double internal_value
Definition: labelslider.h:162
The LabelSlider class.
Definition: labelslider.h:33
bool IsDragging()
Returns whether the user is currently dragging.
Definition: labelslider.cpp:86
DisplayType display_type
Definition: labelslider.h:179
Definition: labelslider.h:72
Definition: labelslider.h:74
QString ValueToString()
Convert the internal value to a displayed string according to display_type
Definition: labelslider.cpp:90
bool max_enabled
Definition: labelslider.h:169
void clicked()
clicked signal
void SetDisplayType(const DisplayType &type)
Sets the way to display the value.
Definition: labelslider.cpp:66
void mousePressEvent(QMouseEvent *ev)
Definition: labelslider.cpp:156
int drag_start_x
Definition: labelslider.h:174
double frame_rate
Definition: labelslider.h:181
void SetValue(double v)
Set the value.
Definition: labelslider.cpp:71
double value()
Returns the internal value as a double.
Definition: labelslider.cpp:134
double drag_start_value
Definition: labelslider.h:163
void SetActiveCursor()
Internal function to set the cursor while dragging (usually NoCursor aka invisible) ...
Definition: labelslider.cpp:263
bool drag_start
Definition: labelslider.h:172
DisplayType
Definition: labelslider.h:71
bool set
Definition: labelslider.h:177
void SetDefaultCursor()
Internal function to set the standard cursor (usually SizeHorCursor)
Definition: labelslider.cpp:259
Definition: labelslider.h:75
bool drag_proc
Definition: labelslider.h:173
double default_value
Definition: labelslider.h:161
int decimal_places
Definition: labelslider.h:165