File: MirSurfaceItemInterface.h

package info (click to toggle)
lomiri-api 0.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,248 kB
  • sloc: cpp: 6,415; python: 264; ansic: 96; makefile: 29; sh: 17
file content (172 lines) | stat: -rw-r--r-- 5,570 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Copyright (C) 2015 Canonical, Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H
#define LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H

#include "Mir.h"

#include <QQuickItem>

namespace lomiri
{
namespace shell
{
namespace application
{

class MirSurfaceInterface;

/**
   @brief Renders a MirSurface in a QML scene and forwards the input events it receives to it.

   You can have multiple MirSurfaceItems displaying the same MirSurface. But care must
   be taken that only one of them feeds the MirSurface with input events and also only
   one resizes it.
 */
class MirSurfaceItemInterface : public QQuickItem
{
    Q_OBJECT

    /**
     * @brief The surface to be displayed
     */
    Q_PROPERTY(lomiri::shell::application::MirSurfaceInterface* surface READ surface WRITE setSurface NOTIFY surfaceChanged)

    /**
     * @brief Type of the given surface or Mir.UnknownType if no surface is set
     */
    Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)

    /**
     * @brief State of the given surface or Mir.UnknownState if no surface is set
     */
    Q_PROPERTY(Mir::State surfaceState READ surfaceState NOTIFY surfaceStateChanged)

    /**
     * @brief Name of the given surface or an empty string if no surface is set
     */
    Q_PROPERTY(QString name READ name NOTIFY nameChanged)

    /**
     * @brief True if the item has a surface and that surface has a mir client bound to it.
     * A "zombie" (live == false) surface never becomes alive again.
     */
    Q_PROPERTY(bool live READ live NOTIFY liveChanged)

    /**
     * @brief  Orientation angle of the given surface
     *
     * How many degrees, clockwise, the UI in the surface has to rotate to match shell's UI orientation
     */
    Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
               NOTIFY orientationAngleChanged DESIGNABLE false)


    /**
     * @brief Whether the item will forward activeFocus, touch events, mouse events and key events to its surface.
     * It's false by default.
     * Only one item should have this property enabled for a given surface.
     */
    Q_PROPERTY(bool consumesInput READ consumesInput
                                  WRITE setConsumesInput
                                  NOTIFY consumesInputChanged)

    /**
     * @brief The desired width for the contained MirSurface.
     * It's ignored if set to zero or a negative number
     * The default value is zero
     */
    Q_PROPERTY(int surfaceWidth READ surfaceWidth
                                WRITE setSurfaceWidth
                                NOTIFY surfaceWidthChanged)

    /**
     * @brief The desired height for the contained MirSurface.
     * It's ignored if set to zero or a negative number
     * The default value is zero
     */
    Q_PROPERTY(int surfaceHeight READ surfaceHeight
                                WRITE setSurfaceHeight
                                NOTIFY surfaceHeightChanged)

    Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)

    /**
     * @brief The Shell chrome mode
     */
    Q_PROPERTY(Mir::ShellChrome shellChrome READ shellChrome NOTIFY shellChromeChanged)

public:

    enum FillMode {
        Stretch,
        PadOrCrop
    };
    Q_ENUM(FillMode)

    /// @cond
    MirSurfaceItemInterface(QQuickItem *parent = 0) : QQuickItem(parent) {}
    virtual ~MirSurfaceItemInterface() {}

    virtual Mir::Type type() const = 0;
    virtual QString name() const = 0;
    virtual bool live() const = 0;

    virtual Mir::State surfaceState() const = 0;

    virtual Mir::OrientationAngle orientationAngle() const = 0;
    virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;

    virtual MirSurfaceInterface* surface() const = 0;
    virtual void setSurface(MirSurfaceInterface*) = 0;

    virtual bool consumesInput() const = 0;
    virtual void setConsumesInput(bool value) = 0;

    virtual int surfaceWidth() const = 0;
    virtual void setSurfaceWidth(int value) = 0;

    virtual int surfaceHeight() const = 0;
    virtual void setSurfaceHeight(int value) = 0;

    virtual FillMode fillMode() const = 0;
    virtual void setFillMode(FillMode value) = 0;

    virtual Mir::ShellChrome shellChrome() const = 0;
    /// @endcond

Q_SIGNALS:
    /// @cond
    void typeChanged(Mir::Type);
    void surfaceStateChanged(Mir::State);
    void liveChanged(bool live);
    void orientationAngleChanged(Mir::OrientationAngle angle);
    void surfaceChanged(lomiri::shell::application::MirSurfaceInterface* surface);
    void consumesInputChanged(bool value);
    void surfaceWidthChanged(int value);
    void surfaceHeightChanged(int value);
    void nameChanged(const QString &name);
    void fillModeChanged(FillMode value);
    void shellChromeChanged(Mir::ShellChrome value);
    /// @endcond
};

} // namespace application
} // namespace shell
} // namespace lomiri

#endif // LOMIRI_SHELL_APPLICATION_MIRSURFACEITEM_H