My Project
MirSurfaceItemInterface.h
1 /*
2  * Copyright (C) 2015 Canonical, Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
18 #define UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
19 
20 #include "Mir.h"
21 
22 #include <QQuickItem>
23 
24 namespace unity
25 {
26 namespace shell
27 {
28 namespace application
29 {
30 
31 class MirSurfaceInterface;
32 
40 class MirSurfaceItemInterface : public QQuickItem
41 {
42  Q_OBJECT
43 
44  Q_ENUMS(FillMode)
45 
46 
49  Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
50 
54  Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
55 
59  Q_PROPERTY(Mir::State surfaceState READ surfaceState NOTIFY surfaceStateChanged)
60 
64  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
65 
70  Q_PROPERTY(bool live READ live NOTIFY liveChanged)
71 
77  Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
78  NOTIFY orientationAngleChanged DESIGNABLE false)
79 
80 
86  Q_PROPERTY(bool consumesInput READ consumesInput
87  WRITE setConsumesInput
88  NOTIFY consumesInputChanged)
89 
95  Q_PROPERTY(int surfaceWidth READ surfaceWidth
96  WRITE setSurfaceWidth
97  NOTIFY surfaceWidthChanged)
98 
104  Q_PROPERTY(int surfaceHeight READ surfaceHeight
105  WRITE setSurfaceHeight
106  NOTIFY surfaceHeightChanged)
107 
108  Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
109 
113  Q_PROPERTY(Mir::ShellChrome shellChrome READ shellChrome NOTIFY shellChromeChanged)
114 
115 public:
116 
117  enum FillMode {
118  Stretch,
119  PadOrCrop
120  };
121 
123  MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {}
124  virtual ~MirSurfaceItemInterface() {}
125 
126  virtual Mir::Type type() const = 0;
127  virtual QString name() const = 0;
128  virtual bool live() const = 0;
129 
130  virtual Mir::State surfaceState() const = 0;
131 
132  virtual Mir::OrientationAngle orientationAngle() const = 0;
133  virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
134 
135  virtual MirSurfaceInterface* surface() const = 0;
136  virtual void setSurface(MirSurfaceInterface*) = 0;
137 
138  virtual bool consumesInput() const = 0;
139  virtual void setConsumesInput(bool value) = 0;
140 
141  virtual int surfaceWidth() const = 0;
142  virtual void setSurfaceWidth(int value) = 0;
143 
144  virtual int surfaceHeight() const = 0;
145  virtual void setSurfaceHeight(int value) = 0;
146 
147  virtual FillMode fillMode() const = 0;
148  virtual void setFillMode(FillMode value) = 0;
149 
150  virtual Mir::ShellChrome shellChrome() const = 0;
152 
153 Q_SIGNALS:
155  void typeChanged(Mir::Type);
156  void surfaceStateChanged(Mir::State);
157  void liveChanged(bool live);
158  void orientationAngleChanged(Mir::OrientationAngle angle);
159  void surfaceChanged(MirSurfaceInterface*);
160  void consumesInputChanged(bool value);
161  void surfaceWidthChanged(int value);
162  void surfaceHeightChanged(int value);
163  void nameChanged(const QString &name);
164  void fillModeChanged(FillMode value);
165  void shellChromeChanged(Mir::ShellChrome value);
167 };
168 
169 } // namespace application
170 } // namespace shell
171 } // namespace unity
172 
173 #endif // UNITY_SHELL_APPLICATION_MIRSURFACEITEM_H
unity::shell::application::MirSurfaceInterface surface
The surface to be displayed.
Definition: MirSurfaceItemInterface.h:49
Mir::State surfaceState
State of the given surface or Mir.UnknownState if no surface is set.
Definition: MirSurfaceItemInterface.h:59
Mir::OrientationAngle orientationAngle
Orientation angle of the given surface.
Definition: MirSurfaceItemInterface.h:78
bool live
True if the item has a surface and that surface has a mir client bound to it. A "zombie" (live == fal...
Definition: MirSurfaceItemInterface.h:70
Type
Surface type.
Definition: Mir.h:45
Mir::ShellChrome shellChrome
The Shell chrome mode.
Definition: MirSurfaceItemInterface.h:113
State
Surface state.
Definition: Mir.h:61
ShellChrome
Shell chrome.
Definition: Mir.h:91
Top-level namespace for all things Unity-related.
Definition: Version.h:37
int surfaceWidth
The desired width for the contained MirSurface. It&#39;s ignored if set to zero or a negative number The ...
Definition: MirSurfaceItemInterface.h:97
Renders a MirSurface in a QML scene and forwards the input events it receives to it.
Definition: MirSurfaceItemInterface.h:40
int surfaceHeight
The desired height for the contained MirSurface. It&#39;s ignored if set to zero or a negative number The...
Definition: MirSurfaceItemInterface.h:106
QString name
Name of the given surface or an empty string if no surface is set.
Definition: MirSurfaceItemInterface.h:64
OrientationAngle
Surface orientation angle.
Definition: Mir.h:81
bool consumesInput
Whether the item will forward activeFocus, touch events, mouse events and key events to its surface...
Definition: MirSurfaceItemInterface.h:88
Acting mostly as a namespace to hold enums and such for use in QML.
Definition: Mir.h:25
Mir::Type type
Type of the given surface or Mir.UnknownType if no surface is set.
Definition: MirSurfaceItemInterface.h:54
Holds a Mir surface. Pretty much an opaque class.
Definition: MirSurfaceInterface.h:41