2 * Copyright (C) 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 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 General Public License for more details.
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/>.
18 import Ubuntu.Components 1.3
19 import "../../Components"
25 readonly property real aspectRatio: width / height
26 readonly property real initialAspectRatio: initialWidth / initialHeight
27 readonly property real initialXScale: initialWidth / width
28 readonly property real initialYScale: initialHeight / height
30 property alias delegate: loader.sourceComponent
31 property alias delegateItem: loader.item
32 property alias headerShown: overlayHeader.shown
33 property real initialX: 0
34 property real initialY: 0
35 property real initialWidth: 1
36 property real initialHeight: 1
38 property real xScale: initialXScale
39 property real yScale: initialYScale
40 property real progress: 0
45 clip: progress > 0 && progress < 1
46 color: Qt.rgba(0, 0, 0, progress)
47 transformOrigin: Item.TopLeft
52 xScale: overlay.xScale
53 yScale: overlay.yScale
56 x: overlay.initialX - overlay.initialX * overlay.progress
57 y: overlay.initialY - overlay.initialY * overlay.progress
64 PropertyChanges { target: overlay; progress: 1; xScale: 1; yScale: 1 }
68 PropertyChanges { target: overlay; progress: 0; xScale: initialXScale; yScale: initialYScale }
75 UbuntuNumberAnimation {
77 properties: "progress,xScale,yScale"
78 duration: UbuntuAnimation.FastDuration
84 UbuntuNumberAnimation {
86 properties: "progress,xScale,yScale"
87 duration: UbuntuAnimation.FastDuration / 2
104 readonly property bool verticalScaling: initialAspectRatio / aspectRatio >= 1
105 readonly property real initialXScale: verticalScaling ? 1 : aspectRatio / initialAspectRatio
106 readonly property real initialYScale: verticalScaling ? initialAspectRatio / aspectRatio : 1
107 readonly property real xScale: verticalScaling ? loader.initialXScale - loader.initialXScale * overlay.progress + overlay.progress :
108 loader.yScale * overlay.yScale / overlay.xScale
109 readonly property real yScale: verticalScaling ? loader.xScale * overlay.xScale / overlay.yScale :
110 loader.initialYScale - loader.initialYScale * overlay.progress + overlay.progress
113 origin.x: parent.width / 2
114 origin.y: parent.height / 2
115 xScale: loader.xScale
116 yScale: loader.yScale
123 property bool shown: true
131 opacity: overlay.state == "shown" && overlay.progress > 0.8 && shown ? 0.8 : 0
134 Behavior on opacity {
135 UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }
139 id: overlayCloseButton
140 objectName: "overlayCloseButton"
143 bottom: parent.bottom
148 onClicked: overlay.hide()
152 color: Qt.rgba(1.0, 1.0, 1.0, 0.3)
153 visible: overlayCloseButton.pressed
158 anchors.centerIn: parent
161 color: theme.palette.normal.foregroundText