Unity 8
DesktopSpreadDelegate.qml
1 /*
2  * Copyright (C) 2014-2016 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  property alias surface: applicationWindow.surface
29 
30  property bool highlightShown: false
31  property real shadowOpacity: 1
32 
33  property int windowWidth: surface ? surface.size.width : 0
34  property int windowHeight: surface ? surface.size.height : 0
35 
36  state: "normal"
37  states: [
38  State {
39  name: "normal"
40  PropertyChanges {
41  target: root
42  width: windowWidth
43  height: windowHeight
44  }
45  },
46  State {
47  name: "transformed"
48  PropertyChanges {
49  target: applicationWindow
50  itemScale: Math.max(root.width / root.windowWidth, root.height / root.windowHeight)
51  interactive: false
52  }
53  PropertyChanges {
54  target: clipper
55  clip: true
56  }
57  }
58  ]
59 
60  scale: highlightShown ? 1.025 : 1
61  Behavior on scale {
62  UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
63  }
64 
65  BorderImage {
66  anchors {
67  fill: root
68  margins: -units.gu(2)
69  }
70  source: "graphics/dropshadow2gu.sci"
71  opacity: root.shadowOpacity * .3
72  }
73 
74  Rectangle {
75  id: selectionHighlight
76  anchors.fill: parent
77  anchors.margins: -units.gu(1)
78  color: "white"
79  opacity: highlightShown ? 0.55 : 0
80  antialiasing: true
81  }
82 
83  Rectangle {
84  anchors { left: selectionHighlight.left; right: selectionHighlight.right; bottom: selectionHighlight.bottom; }
85  height: units.dp(2)
86  color: theme.palette.normal.focus
87  visible: root.highlightShown
88  antialiasing: true
89  }
90 
91  Item {
92  id: clipper
93  anchors.fill: parent
94 
95  ApplicationWindow {
96  id: applicationWindow
97  objectName: application ? "appWindow_" + application.appId : "appWindow_null"
98  anchors.top: parent.top
99  anchors.topMargin: 0
100  anchors.left: parent.left
101  width: root.windowWidth
102  height: root.windowHeight
103  interactive: false
104  resizeSurface: false
105  focus: false
106 
107  property real itemScale: 1
108  transform: [
109  Scale {
110  origin.x: 0; origin.y: 0
111  xScale: applicationWindow.itemScale
112  yScale: applicationWindow.itemScale
113  }
114  ]
115  }
116  }
117 
118  Rectangle {
119  anchors.fill: parent
120  color: "black"
121  opacity: root.highlightShown ? 0 : .1
122  Behavior on opacity {
123  UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
124  }
125  }
126 }