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 && application.session && application.session.lastSurface ? application.session.lastSurface.size.width : 0
33  property int windowHeight: application && application.session && application.session.lastSurface ? application.session.lastSurface.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  scale: highlightShown ? 1.025 : 1
60  Behavior on scale {
61  UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
62  }
63 
64  BorderImage {
65  anchors {
66  fill: root
67  margins: -units.gu(2)
68  }
69  source: "graphics/dropshadow2gu.sci"
70  opacity: root.shadowOpacity * .3
71  }
72 
73  Rectangle {
74  id: selectionHighlight
75  anchors.fill: parent
76  anchors.margins: -units.gu(1)
77  color: "white"
78  opacity: highlightShown ? 0.55 : 0
79  antialiasing: true
80  }
81 
82  Rectangle {
83  anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
84  height: units.dp(2)
85  color: UbuntuColors.orange
86  visible: root.highlightShown
87  antialiasing: true
88  }
89 
90  Item {
91  id: clipper
92  anchors.fill: parent
93 
94  ApplicationWindow {
95  id: applicationWindow
96  objectName: application ? "appWindow_" + application.appId : "appWindow_null"
97  anchors.top: parent.top
98  anchors.topMargin: 0
99  anchors.left: parent.left
100  width: root.windowWidth
101  height: root.windowHeight
102  interactive: false
103  resizeSurface: false
104  focus: false
105 
106  property real itemScale: 1
107  transform: [
108  Scale {
109  origin.x: 0; origin.y: 0
110  xScale: applicationWindow.itemScale
111  yScale: applicationWindow.itemScale
112  }
113  ]
114  }
115  }
116 
117  Rectangle {
118  anchors.fill: parent
119  color: "black"
120  opacity: root.highlightShown ? 0 : .1
121  Behavior on opacity {
122  UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
123  }
124  }
125 }