2 * Copyright (C) 2013 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/>.
19 import QtGraphicalEffects 1.0
20 import Unity.Application 0.1
21 import Ubuntu.Components 0.1
27 * Valid values are "left", "right", "top", "bottom", or "none".
29 property string edge: "top"
32 * This is the header displayed, like "Right edge".
34 property alias title: titleLabel.text
37 * This is the block of text displayed below the header.
39 property alias text: textLabel.text
42 * This is the text for the skip button.
44 property alias skipText: skipLabel.text
47 * This is the visible status of the skip button.
49 property alias showSkip: skipLabel.visible
52 * Whether this demo is running currently.
54 readonly property bool active: available && visible
57 * Whether animations are paused.
59 property alias paused: wholeAnimation.paused
62 * Whether animations are running.
64 readonly property alias running: wholeAnimation.running
74 overlay.visible = false;
75 overlay.available = false;
81 showAnimation: StandardAnimation {
84 onRunningChanged: if (running) overlay.visible = true
86 hideAnimation: StandardAnimation {
89 duration: UbuntuAnimation.BriskDuration
90 onRunningChanged: if (!running) overlay.hideNow()
95 property bool skipOnHide: false
96 property int edgeMargin: units.gu(4)
100 objectName: "backgroundShade"
105 visible: overlay.active
108 objectName: "backgroundShadeMouseArea"
111 enabled: overlay.edge == "none" && overlay.opacity == 1.0
112 onClicked: overlay.doSkip()
121 height: parent.height
122 visible: overlay.active
129 margins: d.edgeMargin
131 top: overlay.edge == "bottom" ? undefined : parent.top
132 bottom: overlay.edge == "bottom" ? parent.bottom : undefined
139 wrapMode: Text.WordWrap
145 wrapMode: Text.WordWrap
150 objectName: "skipLabel"
151 text: i18n.tr("Skip intro")
152 color: UbuntuColors.orange
156 anchors.left: parent.right
157 anchors.verticalCenter: parent.verticalCenter
161 color: UbuntuColors.orange
165 // Make clickable area bigger than just the link because
166 // otherwise, the edge demo will feel hard to dismiss.
168 anchors.margins: -units.gu(5)
169 onClicked: overlay.doSkip()
178 visible: overlay.edge != "none"
182 color: Qt.hsla(16.0/360.0, 0.83, 0.47, 0.4) // UbuntuColors.orange, but transparent
191 if (overlay.edge == "right") {
192 return Qt.point(width, 0);
193 } else if (overlay.edge == "left") {
194 return Qt.point(0, 0);
195 } else if (overlay.edge == "top") {
196 return Qt.point(0, 0);
198 return Qt.point(0, height);
202 if (overlay.edge == "right") {
203 return Qt.point(width - size, 0);
204 } else if (overlay.edge == "left") {
205 return Qt.point(size, 0);
206 } else if (overlay.edge == "top") {
207 return Qt.point(0, size);
209 return Qt.point(0, height - size);
215 SequentialAnimation {
217 objectName: "wholeAnimation"
218 running: overlay.active
226 if (overlay.edge == "right" || overlay.edge == "left") {
227 return "anchors.leftMargin";
228 } else if (overlay.edge == "bottom") {
229 return "anchors.bottomMargin";
231 return "anchors.topMargin";
235 if (overlay.edge == "right") {
236 return d.edgeMargin + units.gu(3)
238 return d.edgeMargin - units.gu(3)
242 duration: overlay.edge == "none" ? 0 : UbuntuAnimation.SleepyDuration
249 duration: UbuntuAnimation.SleepyDuration
253 SequentialAnimation {
255 loops: Animation.Infinite
256 property string prop: (overlay.edge == "left" || overlay.edge == "right") ? "x" : "y"
257 property double endVal: units.dp(5) * ((overlay.edge == "left" || overlay.edge == "top") ? 1 : -1)
258 property double maxGlow: units.dp(20)
259 property int duration: overlay.edge == "none" ? 0 : UbuntuAnimation.SleepyDuration
262 StandardAnimation { target: hintGroup; property: hintAnimation.prop; from: 0; to: hintAnimation.endVal; duration: hintAnimation.duration }
263 StandardAnimation { target: edgeHint; property: "size"; from: 1; to: hintAnimation.maxGlow; duration: hintAnimation.duration }
268 StandardAnimation { target: hintGroup; property: hintAnimation.prop; from: hintAnimation.endVal; to: 0; duration: hintAnimation.duration }
269 StandardAnimation { target: edgeHint; property: "size"; from: hintAnimation.maxGlow; to: 1; duration: hintAnimation.duration }