2 * Copyright 2014-2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import Ubuntu.Components 1.3
19 import Ubuntu.Gestures 0.1 // For TouchGate
20 import Utils 0.1 // for InputWatcher
21 import Unity.Application 0.1 // for MirSurfaceItem
25 objectName: "surfaceContainer"
27 // Must be set from outside
28 property var surface: null
30 // Might be changed from outside
31 property int requestedWidth: -1
32 property int requestedHeight: -1
33 property bool interactive
34 property int surfaceOrientationAngle: 0
35 property bool resizeSurface: true
36 property bool isPromptSurface: false
37 // FIME - dont export, use interactive property. Need to fix qtmir to handle consumesInputChanged
38 // to update surface activeFocus. See mock MirSurfaceItem.
39 property alias consumesInput: surfaceItem.consumesInput
42 // Not a binding because animations might remove the surface from the surfaceItem
43 // programatically (in order to signal that a zombie surface is free for deletion),
44 // even though root.surface is still !null.
45 surfaceItem.surface = surface;
50 onTargetPressedChanged: {
51 if (targetPressed && root.interactive) {
53 root.forceActiveFocus();
60 objectName: "surfaceItem"
64 fillMode: MirSurfaceItem.PadOrCrop
68 if (root.resizeSurface) {
69 if (root.requestedWidth >= 0) {
70 return root.requestedWidth;
80 if (root.resizeSurface) {
81 if (root.requestedHeight >= 0) {
82 return root.requestedHeight;
91 enabled: root.interactive
92 antialiasing: !root.interactive
93 orientationAngle: root.surfaceOrientationAngle
97 targetItem: surfaceItem
99 enabled: surfaceItem.enabled
102 // MirSurface size drives SurfaceContainer size
104 target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
105 when: root.requestedWidth >= 0 && root.surface
108 target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
109 when: root.requestedHeight >= 0 && root.surface
112 target: root; property: "width"; value: surfaceItem.width
113 when: root.requestedWidth >= 0
116 target: root; property: "height"; value: surfaceItem.height
117 when: root.requestedHeight >= 0
120 // SurfaceContainer size drives MirSurface size
122 target: surfaceItem; property: "width"; value: root.width
123 when: root.requestedWidth < 0
126 target: surfaceItem; property: "height"; value: root.height
127 when: root.requestedHeight < 0
132 objectName: "animationsLoader"
135 if (root.isPromptSurface) {
136 return "PromptSurfaceAnimations.qml";
138 // Let ApplicationWindow do the animations
143 target: animationsLoader.item
144 when: animationsLoader.item
145 property: "surfaceItem"
149 target: animationsLoader.item
150 when: animationsLoader.item
151 property: "container"