Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ScreenItem.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 #ifndef OMNI_UI_SCREENITEM_H_
20 #define OMNI_UI_SCREENITEM_H_
21 
22 #include <QColor>
23 #include <QScreen>
24 #include <omni/util.h>
25 #include "FullScreen.h"
26 
27 namespace omni {
28 
29  namespace ui {
30  namespace proj {
31  class Tuning;
32  }
33 
34  class ScreenItem;
35  class ScreenSetup;
36 
37  /// Subscreen Item for which a tuning can be assigned
38  class SubScreenItem {
39  public:
40  SubScreenItem();
41  SubScreenItem(ScreenItem* _parent,
42  int _index);
43 
44  /// Currently assigned tuning widget
46 
47  /// Currently assigned tuning widget (const version)
48  omni::ui::proj::Tuning const* tuningWidget() const;
49 
50  /// Attach tuning widget to this subscreen
51  void attachTuningWidget(
52  omni::ui::proj::Tuning *_tuning);
53 
54  /// Detach current tuning widget from this subscreen
55  void detachTuningWidget();
56 
57  /// Return rectangle of this subscreen item
58  QRect rect() const;
59 
60  /// Return size of this subscreen
61  QSize size() const;
62 
63  /// Pointer to parent screen
64  ScreenItem* parent();
65 
66  /// Const pointer to parent screen
67  ScreenItem const* parent() const;
68 
69 
70  /// Paint this item with painter
71  void paint(bool _hover,
72  bool _drop,
73  QColor _dropColor,
74  QPainter&);
75 
76 
77  private:
78  ScreenItem *parent_ = nullptr;
79  int index_ = -1;
81  };
82 
83  /// A screen rectangle item representing a QScreen with drawing functionality
84  class ScreenItem {
85  public:
86  friend class SubScreenItem;
87 
89  QScreen const *_screen);
90  ~ScreenItem();
91 
92 
93  /// Detach tuning widget
95 
96  /// Screen this screen item is assigned to
97  QScreen const* screen() const;
98 
99  void paint(QPainter&);
100 
101  /// Detach all tunings/projectors
102  void detachTunings();
103 
104  SubScreenItem* item(int _index);
105 
106  SubScreenItem const* item(int _index) const;
107 
108  /// Return pointer to currently hovered item
110 
111  /// Return pointer to currently hovered item (const)
112  SubScreenItem const* hoveredItem() const;
113 
114  /// Returns flag whether mouse is currently over this item
115  int hoverIndex() const;
116 
117  /// Set index of current hovered subscreen
118  void setHoverIndex(int);
119 
120  /// Set hover index from mouse position
121  void setHoverIndex(QPoint const&);
122 
123  /// Flag whether a drop is supposed to happen on this item
124  bool drop() const;
125 
126  /// Drop and color of drop
127  void startDrop(QColor const& _color = QColor("#FFFFFF"));
128 
129  /// Hides fullscreen widget if no tunings are attached
130  void endDrop();
131 
132  QRect rect() const;
133 
135 
136  inline int numSubScreens() const {
137  return int(subScreens_.size());
138  }
139 
140  private:
141  int hoverIndex_ = -1;
142  bool drop_ = false;
143  QColor dropColor_;
145  QScreen const *screen_ = nullptr;
146  QUniquePtr<FullScreen> fullscreen_;
147  std::vector<SubScreenItem> subScreens_;
148  };
149  }
150 }
151 
152 #endif /* OMNI_UI_SCREENITEM_H_ */
A widget for seting up fullscreen windows.
Definition: ScreenSetup.h:44
QScreen const * screen() const
Screen this screen item is assigned to.
Definition: ScreenItem.cpp:171
FullScreen * fullscreen()
Definition: ScreenItem.cpp:233
~ScreenItem()
Definition: ScreenItem.cpp:159
void detachTuningWidget(omni::ui::proj::Tuning *)
Detach tuning widget.
Definition: ScreenItem.cpp:163
SubScreenItem()
Definition: ScreenItem.cpp:28
SubScreenItem * hoveredItem()
Return pointer to currently hovered item.
Definition: ScreenItem.cpp:280
void paint(QPainter &)
Definition: ScreenItem.cpp:237
ScreenItem(ScreenSetup &, QScreen const *_screen)
ScreenSetup::Item.
Definition: ScreenItem.cpp:144
ScreenSetup & screenSetup_
Definition: ScreenItem.h:144
QSize size() const
Return size of this subscreen.
Definition: ScreenItem.cpp:55
void paint(bool _hover, bool _drop, QColor _dropColor, QPainter &)
Paint this item with painter.
Definition: ScreenItem.cpp:64
omni::ui::proj::Tuning * tuningWidget_
Definition: ScreenItem.h:80
int hoverIndex_
Definition: ScreenItem.h:141
ScreenItem * parent()
Pointer to parent screen.
Definition: ScreenItem.cpp:37
void detachTunings()
Detach all tunings/projectors.
Definition: ScreenItem.cpp:263
QColor dropColor_
Definition: ScreenItem.h:143
int numSubScreens() const
Definition: ScreenItem.h:136
A screen rectangle item representing a QScreen with drawing functionality.
Definition: ScreenItem.h:84
void endDrop()
Hides fullscreen widget if no tunings are attached.
Definition: ScreenItem.cpp:217
int hoverIndex() const
Returns flag whether mouse is currently over this item.
Definition: ScreenItem.cpp:176
std::vector< SubScreenItem > subScreens_
Definition: ScreenItem.h:147
ScreenItem * parent_
Definition: ScreenItem.h:78
bool drop_
Definition: ScreenItem.h:142
QUniquePtr< FullScreen > fullscreen_
Definition: ScreenItem.h:146
void attachTuningWidget(omni::ui::proj::Tuning *_tuning)
Attach tuning widget to this subscreen.
Definition: ScreenItem.cpp:124
QRect rect() const
Return rectangle of this subscreen item.
Definition: ScreenItem.cpp:46
Subscreen Item for which a tuning can be assigned.
Definition: ScreenItem.h:38
void detachTuningWidget()
Detach current tuning widget from this subscreen.
Definition: ScreenItem.cpp:132
omni::ui::proj::Tuning * tuningWidget()
Currently assigned tuning widget.
Definition: ScreenItem.cpp:114
Widget for fullscreen display.
Definition: FullScreen.h:31
void setHoverIndex(int)
Set index of current hovered subscreen.
Definition: ScreenItem.cpp:181
Widget for manipulating projector parameters Also holds a preview OpenGL widget. ...
Definition: Tuning.h:46
bool drop() const
Flag whether a drop is supposed to happen on this item.
Definition: ScreenItem.cpp:204
int index_
Definition: ScreenItem.h:79
void startDrop(QColor const &_color=QColor("#FFFFFF"))
Drop and color of drop.
Definition: ScreenItem.cpp:209
QScreen const * screen_
Definition: ScreenItem.h:145
QRect rect() const
Definition: ScreenItem.cpp:223
SubScreenItem * item(int _index)
Definition: ScreenItem.cpp:271