Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AbstractInputWidget.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_ABSTRACTINPUTWIDGET_H_
21 #define OMNI_UI_ABSTRACTINPUTWIDGET_H_
22 
23 #include <QLayout>
24 #include <omni/ui/mixin/Editor.h>
25 #include "Widget.h"
26 
27 namespace omni {
28  namespace ui {
29  /// Input widget with an editor widget
31  public Widget,
32  protected mixin::Editor<AbstractInputWidget, QWidget>{
33  Q_OBJECT
34 
35  public:
37  AbstractInputWidget(QWidget * = nullptr);
38  virtual ~AbstractInputWidget() {}
39 
40  public slots:
41  /// Set editor visible
42  virtual void setEditorVisible(bool);
43 
44  /// Show editor
45  void showEditor();
46 
47  /// Hide editor
48  void hideEditor();
49 
50  signals:
51  /// Value changed event
52  void valueChanged();
53 
54  protected:
55  /// Show editor on double click
56  virtual void mouseDoubleClickEvent(QMouseEvent *);
57 
58  /// Hide editor and set focus on click
59  virtual void mousePressEvent(QMouseEvent *);
60 
61  /// Show editor when enter key is pressed
62  virtual void keyPressEvent(QKeyEvent *);
63 
64  /// Draw slider handle
65  void drawHandle(QPainter& _p,
66  double _pos,
67  double _heightFactor = 1.0) const;
68 
69  void drawTrack(QPainter& _p,
70  double _pos) const;
71 
72  void drawTrack(QPainter& _p,
73  double _left,
74  double _right) const;
75 
76  void init();
77 
78  QLabel *valueLabel_ = nullptr;
79  };
80  }
81 }
82 
83 #endif /* OMNI_UI_ABSTRACTINPUTWIDGET_H_ */
virtual void mousePressEvent(QMouseEvent *)
Hide editor and set focus on click.
Definition: AbstractInputWidget.cpp:68
Input widget with an editor widget.
Definition: AbstractInputWidget.h:30
virtual void mouseDoubleClickEvent(QMouseEvent *)
Show editor on double click.
Definition: AbstractInputWidget.cpp:74
virtual ~AbstractInputWidget()
Definition: AbstractInputWidget.h:38
void showEditor()
Show editor.
Definition: AbstractInputWidget.cpp:58
mixin::Editor< AbstractInputWidget, QWidget > mixin_editor_type
Definition: AbstractInputWidget.h:36
void valueChanged()
Value changed event.
A single parameter widget with a label and color set.
Definition: Widget.h:31
void hideEditor()
Hide editor.
Definition: AbstractInputWidget.cpp:63
void drawHandle(QPainter &_p, double _pos, double _heightFactor=1.0) const
Draw slider handle.
Definition: AbstractInputWidget.cpp:87
virtual void setEditorVisible(bool)
Set editor visible.
Definition: AbstractInputWidget.cpp:45
AbstractInputWidget(QWidget *=nullptr)
Definition: AbstractInputWidget.cpp:28
void init()
Definition: AbstractInputWidget.cpp:35
virtual void keyPressEvent(QKeyEvent *)
Show editor when enter key is pressed.
Definition: AbstractInputWidget.cpp:79
QLabel * valueLabel_
Definition: AbstractInputWidget.h:78
void drawTrack(QPainter &_p, double _pos) const
Definition: AbstractInputWidget.cpp:119
Mixin for a widget that holds an editor widget.
Definition: Editor.h:30