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/>.
23
* true: fade out old image in parallel with fading in the new one.
24
* false: fade in new image above old one.
26
* The reason why this is required is that crossfading has the isse that in
27
* the middle of the animation, both images are only 50% opaque which make
28
* any background shine through. Not wanted for background images etc, but
29
* wanted for overlays.
31
property bool crossFade: true
34
* true: the very first source url should be faded in already.
35
* false: the very first source url should just be shown without animation.
37
property bool fadeInFirst: true
39
readonly property size sourceSize: __currentImage.sourceSize
40
readonly property var status: __currentImage ? __currentImage.status : Image.Null
41
readonly property bool running: crossFadeImages.running || nextImageFadeIn.running
43
property Image __currentImage: image1
44
property Image __nextImage: image2
46
function swapImages() {
50
crossFadeImages.start();
52
nextImageFadeIn.start();
55
var tmpImage = __currentImage
56
__currentImage = __nextImage
57
__nextImage = tmpImage
61
// On creation, the souce handler is called before image pointers are set.
62
if (__currentImage === null) {
63
__currentImage = image1;
67
crossFadeImages.stop();
68
nextImageFadeIn.stop();
70
// Don't fade in initial picture, only fade changes
71
if (__currentImage.source == "" && !fadeInFirst) {
72
__currentImage.source = source;
74
nextImageFadeIn.stop();
75
__nextImage.opacity = 0.0;
76
__nextImage.source = source;
78
// If case the image is still in QML's cache, status will be "Ready" immediately
79
if (__nextImage.status == Image.Ready || __nextImage.source == "") {
88
if (__nextImage.status == Image.Ready) {
116
easing.type: Easing.InOutQuad
120
__nextImage.source = "";
132
easing.type: Easing.InOutQuad
136
target: __currentImage
140
easing.type: Easing.InOutQuad
145
__nextImage.source = "";