~sergiusens/camera-app/pseudo_adt

54.2.7 by Ugo Riboni
Adjust fading times and easings
1
/*
94.2.1 by Ugo Riboni
Update copyright to be only GPL3
2
 * Copyright (C) 2012 Canonical, Ltd.
54.2.7 by Ugo Riboni
Adjust fading times and easings
3
 *
4
 * This program is free software; you can redistribute it and/or modify
94.2.1 by Ugo Riboni
Update copyright to be only GPL3
5
 * it under the terms of the GNU General Public License as published by
54.2.7 by Ugo Riboni
Adjust fading times and easings
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
94.2.1 by Ugo Riboni
Update copyright to be only GPL3
11
 * GNU General Public License for more details.
54.2.7 by Ugo Riboni
Adjust fading times and easings
12
 *
94.2.1 by Ugo Riboni
Update copyright to be only GPL3
13
 * You should have received a copy of the GNU General Public License
54.2.7 by Ugo Riboni
Adjust fading times and easings
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16
54.2.2 by Ugo Riboni
Add two button classes that fade between images, one sequentially and one crossing.
17
import QtQuick 2.0
18
import Ubuntu.Components 0.1
54.2.7 by Ugo Riboni
Adjust fading times and easings
19
import "constants.js" as Const
54.2.2 by Ugo Riboni
Add two button classes that fade between images, one sequentially and one crossing.
20
21
AbstractButton {
22
    id: button
23
    property string iconSource
24
25
    property Image __active: icon1
26
    property Image __inactive: icon2
27
28
    onIconSourceChanged: {
29
        if (__active && __inactive) {
30
            __inactive.source = iconSource
31
            __active.opacity = 0.0
32
            __inactive.opacity = 1.0
33
            var swap = __active
34
            __active = __inactive
35
            __inactive = swap
36
        } else icon1.source = iconSource
37
    }
38
39
    Image {
40
        id: icon1
41
        anchors.fill: parent
54.2.7 by Ugo Riboni
Adjust fading times and easings
42
        Behavior on opacity {
43
            NumberAnimation {
44
                duration: Const.iconFadeDuration; easing.type: Easing.InOutQuad
45
            }
46
        }
54.2.2 by Ugo Riboni
Add two button classes that fade between images, one sequentially and one crossing.
47
    }
48
49
    Image {
50
        id: icon2
51
        anchors.fill: parent
52
        opacity: 0.0
54.2.7 by Ugo Riboni
Adjust fading times and easings
53
        Behavior on opacity {
54
            NumberAnimation {
55
                duration: Const.iconFadeDuration; easing.type: Easing.InOutQuad
56
            }
57
        }
54.2.2 by Ugo Riboni
Add two button classes that fade between images, one sequentially and one crossing.
58
    }
59
}
60