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 LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H
18 #define LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H
19 
20 #include "Mir.h"
21 
22 #include <QQuickItem>
23 
24 namespace lomiri
25 {
26 namespace shell
27 {
28 namespace application
29 {
30 
31 class MirSurfaceInterface;
32 
40 class MirSurfaceItemInterface : public QQuickItem
41 {
42  Q_OBJECT
43 
47  Q_PROPERTY(lomiri::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)
48 
49 
52  Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
53 
57  Q_PROPERTY(Mir::State surfaceState READ surfaceState NOTIFY surfaceStateChanged)
58 
62  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
63 
68  Q_PROPERTY(bool live READ live NOTIFY liveChanged)
69 
75  Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
76  NOTIFY orientationAngleChanged DESIGNABLE false)
77 
78 
84  Q_PROPERTY(bool consumesInput READ consumesInput
85  WRITE setConsumesInput
86  NOTIFY consumesInputChanged)
87 
93  Q_PROPERTY(int surfaceWidth READ surfaceWidth
94  WRITE setSurfaceWidth
95  NOTIFY surfaceWidthChanged)
96 
102  Q_PROPERTY(int surfaceHeight READ surfaceHeight
103  WRITE setSurfaceHeight
104  NOTIFY surfaceHeightChanged)
105 
106  Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
107 
111  Q_PROPERTY(Mir::ShellChrome shellChrome READ shellChrome NOTIFY shellChromeChanged)
112 
113 public:
114 
115  enum FillMode {
116  Stretch,
117  PadOrCrop
118  };
119  Q_ENUM(FillMode)
120 
121 
122  MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {}
123  virtual ~MirSurfaceItemInterface() {}
124 
125  virtual Mir::Type type() const = 0;
126  virtual QString name() const = 0;
127  virtual bool live() const = 0;
128 
129  virtual Mir::State surfaceState() const = 0;
130 
131  virtual Mir::OrientationAngle orientationAngle() const = 0;
132  virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
133 
134  virtual MirSurfaceInterface* surface() const = 0;
135  virtual void setSurface(MirSurfaceInterface*) = 0;
136 
137  virtual bool consumesInput() const = 0;
138  virtual void setConsumesInput(bool value) = 0;
139 
140  virtual int surfaceWidth() const = 0;
141  virtual void setSurfaceWidth(int value) = 0;
142 
143  virtual int surfaceHeight() const = 0;
144  virtual void setSurfaceHeight(int value) = 0;
145 
146  virtual FillMode fillMode() const = 0;
147  virtual void setFillMode(FillMode value) = 0;
148 
149  virtual Mir::ShellChrome shellChrome() const = 0;
151 
152 Q_SIGNALS:
154  void typeChanged(Mir::Type);
155  void surfaceStateChanged(Mir::State);
156  void liveChanged(bool live);
157  void orientationAngleChanged(Mir::OrientationAngle angle);
159  void consumesInputChanged(bool value);
160  void surfaceWidthChanged(int value);
161  void surfaceHeightChanged(int value);
162  void nameChanged(const QString &name);
163  void fillModeChanged(FillMode value);
164  void shellChromeChanged(Mir::ShellChrome value);
166 };
167 
168 } // namespace application
169 } // namespace shell
170 } // namespace lomiri
171 
172 #endif // LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H
Mir::OrientationAngle
OrientationAngle
Surface orientation angle.
Definition: Mir.h:85
Mir::ShellChrome
ShellChrome
Shell chrome.
Definition: Mir.h:96
Mir
Acting mostly as a namespace to hold enums and such for use in QML.
Definition: Mir.h:25
lomiri::shell::application::MirSurfaceItemInterface::type
Mir::Type type
Type of the given surface or Mir.UnknownType if no surface is set.
Definition: MirSurfaceItemInterface.h:52
lomiri::shell::application::MirSurfaceItemInterface
Renders a MirSurface in a QML scene and forwards the input events it receives to it.
Definition: MirSurfaceItemInterface.h:40
lomiri::shell::application::MirSurfaceItemInterface::orientationAngle
Mir::OrientationAngle orientationAngle
Orientation angle of the given surface.
Definition: MirSurfaceItemInterface.h:76
lomiri::shell::application::MirSurfaceItemInterface::name
QString name
Name of the given surface or an empty string if no surface is set.
Definition: MirSurfaceItemInterface.h:62
lomiri::shell::application::MirSurfaceItemInterface::shellChrome
Mir::ShellChrome shellChrome
The Shell chrome mode.
Definition: MirSurfaceItemInterface.h:111
lomiri::shell::application::MirSurfaceItemInterface::surfaceWidth
int surfaceWidth
The desired width for the contained MirSurface. It's ignored if set to zero or a negative number The ...
Definition: MirSurfaceItemInterface.h:95
lomiri::shell::application::MirSurfaceItemInterface::consumesInput
bool consumesInput
Whether the item will forward activeFocus, touch events, mouse events and key events to its surface....
Definition: MirSurfaceItemInterface.h:86
lomiri::shell::application::MirSurfaceItemInterface::live
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:68
lomiri
Top-level namespace for all things Lomiri-related.
Definition: Version.h:37
lomiri::shell::application::MirSurfaceInterface
Holds a Mir surface. Pretty much an opaque class.
Definition: MirSurfaceInterface.h:41
lomiri::shell::application::MirSurfaceItemInterface::surfaceState
Mir::State surfaceState
State of the given surface or Mir.UnknownState if no surface is set.
Definition: MirSurfaceItemInterface.h:57
lomiri::shell::application::MirSurfaceItemInterface::surfaceHeight
int surfaceHeight
The desired height for the contained MirSurface. It's ignored if set to zero or a negative number The...
Definition: MirSurfaceItemInterface.h:104
lomiri::shell::application::MirSurfaceItemInterface::surface
lomiri::shell::application::MirSurfaceInterface surface
The surface to be displayed.
Definition: MirSurfaceItemInterface.h:47
Mir::Type
Type
Surface type.
Definition: Mir.h:47
Mir::State
State
Surface state.
Definition: Mir.h:64