2 * Copyright 2014-2015 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 property var surface: null
28 property bool hadSurface: false
29 property bool interactive
30 property int surfaceOrientationAngle: 0
31 property string name: surface ? surface.name : ""
32 property bool resizeSurface: true
34 property int requestedWidth: -1
35 property int requestedHeight: -1
39 surfaceItem.surface = surface;
40 root.hadSurface = false;
46 onTargetPressedChanged: {
47 if (targetPressed && root.interactive) {
49 root.forceActiveFocus();
56 objectName: "surfaceItem"
58 fillMode: MirSurfaceItem.PadOrCrop
62 if (root.resizeSurface) {
63 if (root.requestedWidth >= 0) {
64 return root.requestedWidth;
74 if (root.resizeSurface) {
75 if (root.requestedHeight >= 0) {
76 return root.requestedHeight;
85 enabled: root.interactive
87 antialiasing: !root.interactive
88 orientationAngle: root.surfaceOrientationAngle
91 // MirSurface size drives SurfaceContainer size
93 target: surfaceItem; property: "width"; value: root.surface ? root.surface.size.width : 0
94 when: root.requestedWidth >= 0 && root.surface
97 target: surfaceItem; property: "height"; value: root.surface ? root.surface.size.height : 0
98 when: root.requestedHeight >= 0 && root.surface
101 target: root; property: "width"; value: surfaceItem.width
102 when: root.requestedWidth >= 0
105 target: root; property: "height"; value: surfaceItem.height
106 when: root.requestedHeight >= 0
109 // SurfaceContainer size drives MirSurface size
111 target: surfaceItem; property: "width"; value: root.width
112 when: root.requestedWidth < 0
115 target: surfaceItem; property: "height"; value: root.height
116 when: root.requestedHeight < 0
121 targetItem: surfaceItem
123 enabled: surfaceItem.enabled
129 when: surfaceItem.surface && !surfaceItem.live
134 from: ""; to: "zombie"
135 SequentialAnimation {
136 UbuntuNumberAnimation { target: surfaceItem; property: "opacity"; to: 0.0
137 duration: UbuntuAnimation.BriskDuration }
138 PropertyAction { target: surfaceItem; property: "visible"; value: false }
139 ScriptAction { script: {
140 surfaceItem.surface = null;
141 root.hadSurface = true;
146 from: "zombie"; to: ""
147 ScriptAction { script: {
148 surfaceItem.opacity = 1.0;
149 surfaceItem.visible = true;