Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RangedInt.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_UI_RANGEDINT_H_
21 #define OMNI_UI_RANGEDINT_H_
22 
23 #include <QSpinBox>
24 #include "AbstractInputWidget.h"
25 #include "mixin/RangedValue.h"
26 
27 namespace omni {
28  namespace ui {
29  /// Integer slider
30  class RangedInt :
31  public AbstractInputWidget,
32  public mixin::RangedValue<RangedInt, int>{
33  Q_OBJECT
34  public:
35  typedef QSpinBox editor_type;
37 
38  RangedInt(QWidget * = nullptr);
39  RangedInt(QString const& _label,
40  int _value,
41  int _min,
42  int _max,
43  QWidget * = nullptr);
44  ~RangedInt();
45 
46  /// Return flag if default value is used
47  bool useDefaultValue() const;
48 
49  bool drawTicks() const;
50 
51  public slots:
52  void setValue(int);
53  void setMinimum(int);
54  void setMaximum(int);
55  void setRange(int,
56  int);
57  void setEditorVisible(bool);
58 
59  /// Use Default Value and show it
60  void setUseDefaultValue(bool);
61 
62  void setDrawTicks(bool);
63 
64  signals:
65  void valueChanged();
66  void rangeChanged();
67 
68  protected:
69  void paintEvent(QPaintEvent *);
70  void keyPressEvent(QKeyEvent *);
71  void mouseMoveEvent(QMouseEvent *);
72  void mousePressEvent(QMouseEvent *);
73  void mouseReleaseEvent(QMouseEvent *);
74  void wheelEvent(QWheelEvent *);
75 
76  void valueChangedEvent();
77  void rangeChangedEvent();
78 
79  private:
80  void init();
81  void editorSetup();
82  int valueFromPos(double) const;
83  int valueToPos() const;
84 
85  /// Calculate position from value
86  double valueToPos(int) const;
87 
88  bool drawTicks_ = true;
89  bool useDefaultValue_ = false;
90  bool moving_ = false;
91  };
92  }
93 }
94 
95 #endif /* OMNI_UI_RANGEDINT_H_ */
bool moving_
Definition: RangedInt.h:90
bool drawTicks_
Definition: RangedInt.h:88
RangedInt(QWidget *=nullptr)
Definition: RangedInt.cpp:30
void setDrawTicks(bool)
Definition: RangedInt.cpp:87
Input widget with an editor widget.
Definition: AbstractInputWidget.h:30
void init()
Definition: RangedInt.cpp:219
void setValue(int)
Definition: RangedInt.cpp:48
mixin::RangedValue< RangedInt, int > mixin_range_type
Definition: RangedInt.h:36
void mousePressEvent(QMouseEvent *)
Hide editor and set focus on click.
Definition: RangedInt.cpp:192
void mouseMoveEvent(QMouseEvent *)
Definition: RangedInt.cpp:184
QSpinBox editor_type
Definition: RangedInt.h:35
bool drawTicks() const
Definition: RangedInt.cpp:82
void wheelEvent(QWheelEvent *)
Definition: RangedInt.cpp:207
void keyPressEvent(QKeyEvent *)
Show editor when enter key is pressed.
Definition: RangedInt.cpp:166
int valueFromPos(double) const
Definition: RangedInt.cpp:108
~RangedInt()
Definition: RangedInt.cpp:45
void setMaximum(int)
Definition: RangedInt.cpp:61
void mouseReleaseEvent(QMouseEvent *)
Definition: RangedInt.cpp:202
void setRange(int, int)
Definition: RangedInt.cpp:66
void paintEvent(QPaintEvent *)
Definition: RangedInt.cpp:127
bool useDefaultValue() const
Return flag if default value is used.
Definition: RangedInt.cpp:71
Integer slider.
Definition: RangedInt.h:30
void setMinimum(int)
Definition: RangedInt.cpp:56
bool useDefaultValue_
Definition: RangedInt.h:89
void editorSetup()
Definition: RangedInt.cpp:225
void setEditorVisible(bool)
Definition: RangedInt.cpp:213
int valueToPos() const
Definition: RangedInt.cpp:114
Template class for a value within a certain min/max range.
Definition: RangedValue.h:33
void rangeChangedEvent()
Handler to emit rangeChanged signal in derived widgets.
Definition: RangedInt.cpp:102
void valueChangedEvent()
Value changed event which is emitted on changed value.
Definition: RangedInt.cpp:93
void setUseDefaultValue(bool)
Use Default Value and show it.
Definition: RangedInt.cpp:76