Unity 8
DesktopSpreadDelegate.qml
1 /*
2  * Copyright (C) 2014-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  * Authors: Michael Zanetti <michael.zanetti@canonical.com>
17  */
18 
19 import QtQuick 2.4
20 import Ubuntu.Components 1.3
21 import Unity.Application 0.1
22 
23 Item {
24  id: root
25 
26  property alias window: applicationWindow
27  property alias application: applicationWindow.application
28 
29  property bool highlightShown: false
30  property real shadowOpacity: 1
31 
32  property int windowWidth: application.session && application.session.surface ? application.session.surface.size.width : 0
33  property int windowHeight: application.session && application.session.surface ? application.session.surface.size.height : 0
34 
35  state: "normal"
36  states: [
37  State {
38  name: "normal"
39  PropertyChanges {
40  target: root
41  width: windowWidth
42  height: windowHeight
43  }
44  },
45  State {
46  name: "transformed"
47  PropertyChanges {
48  target: applicationWindow
49  itemScale: Math.max(root.width / root.windowWidth, root.height / root.windowHeight)
50  interactive: false
51  }
52  PropertyChanges {
53  target: clipper
54  clip: true
55  }
56  }
57  ]
58 
59  BorderImage {
60  anchors {
61  fill: root
62  margins: -units.gu(2)
63  }
64  source: "graphics/dropshadow2gu.sci"
65  opacity: root.shadowOpacity * .3
66  }
67 
68  Rectangle {
69  id: selectionHighlight
70  anchors.fill: parent
71  anchors.margins: -units.gu(1)
72  color: "white"
73  opacity: highlightShown ? 0.15 : 0
74  antialiasing: true
75  }
76 
77  Rectangle {
78  anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
79  height: units.dp(2)
80  color: UbuntuColors.orange
81  visible: root.highlightShown
82  antialiasing: true
83  }
84 
85  Item {
86  id: clipper
87  anchors.fill: parent
88 
89  ApplicationWindow {
90  id: applicationWindow
91  objectName: application ? "appWindow_" + application.appId : "appWindow_null"
92  anchors.top: parent.top
93  anchors.topMargin: 0
94  anchors.left: parent.left
95  width: root.windowWidth
96  height: root.windowHeight
97  interactive: false
98  resizeSurface: false
99  focus: false
100 
101  property real itemScale: 1
102  transform: [
103  Scale {
104  origin.x: 0; origin.y: 0
105  xScale: applicationWindow.itemScale
106  yScale: applicationWindow.itemScale
107  }
108  ]
109  }
110  }
111 }