~elopio/gallery-app/revert_workaround-1302706-click_toolbar_button_failure

« back to all changes in this revision

Viewing changes to rc/qml/AlbumEditor/AlbumEditorTransition.qml

  • Committer: Leo Arias
  • Date: 2015-05-15 08:05:23 UTC
  • mfrom: (954.1.241 gallery-app)
  • Revision ID: leo.arias@canonical.com-20150515080523-i2of3vr8h7dioj59
Now the toolbar object is not needed at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2012 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 version 3 as
6
 
 * published by the Free Software Foundation.
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:
17
 
 * Charles Lindsay <chaz@yorba.org>
18
 
 */
19
 
 
20
 
import QtQuick 2.0
21
 
import "../AlbumViewer"
22
 
import "../Utility"
23
 
 
24
 
// Provides a smooth transition between the album overview and album editor.
25
 
Item {
26
 
    id: albumEditorTransition
27
 
 
28
 
    /*!
29
 
    */
30
 
    signal editorEntered(variant album)
31
 
    /*!
32
 
    */
33
 
    signal editorExited(variant album)
34
 
 
35
 
    /*!
36
 
    */
37
 
    property alias album: thumbnail.album
38
 
 
39
 
    /*!
40
 
    */
41
 
    property Rectangle backgroundGlass
42
 
    /*!
43
 
    */
44
 
    property AlbumEditor editor
45
 
 
46
 
    /*!
47
 
    */
48
 
    property int duration: 500
49
 
 
50
 
    // Read-only
51
 
    /*!
52
 
    */
53
 
    property bool animationRunning: enterFadeAnimation.running ||
54
 
                                    exitFadeAnimation.running || enterExpandAnimation.running ||
55
 
                                    exitExpandAnimation.running;
56
 
 
57
 
    /*!
58
 
    */
59
 
    function enterEditor(album, thumbnailRect) {
60
 
        albumEditorTransition.album = album || null;
61
 
 
62
 
        if (thumbnailRect) {
63
 
            thumbnail.x = thumbnailRect.x;
64
 
            thumbnail.y = thumbnailRect.y;
65
 
            thumbnail.width = thumbnailRect.width;
66
 
            thumbnail.height = thumbnailRect.height;
67
 
 
68
 
            enterExpandAnimation.restart();
69
 
        } else {
70
 
            enterFadeAnimation.restart();
71
 
        }
72
 
    }
73
 
 
74
 
    /*!
75
 
    */
76
 
    function exitEditor(album, thumbnailRect) {
77
 
        albumEditorTransition.album = album || null;
78
 
 
79
 
        if (thumbnailRect) {
80
 
            exitExpandAnimation.thumbnailRect = thumbnailRect;
81
 
 
82
 
            thumbnail.x = editor.editorRect.x;
83
 
            thumbnail.y = editor.editorRect.y;
84
 
            thumbnail.width = editor.editorRect.width;
85
 
            thumbnail.height = editor.editorRect.height;
86
 
 
87
 
            exitExpandAnimation.restart();
88
 
        } else {
89
 
            exitFadeAnimation.restart();
90
 
        }
91
 
    }
92
 
 
93
 
    // internal
94
 
    /*!
95
 
    */
96
 
    function onExitFinished() {
97
 
        editorExited(album);
98
 
        album = null;
99
 
    }
100
 
 
101
 
    AlbumOpener {
102
 
        id: thumbnail
103
 
 
104
 
        isPreview: true
105
 
        contentHasPreviewFrame: true
106
 
 
107
 
        visible: false
108
 
        load: visible
109
 
    }
110
 
 
111
 
    ParallelAnimation {
112
 
        id: enterFadeAnimation
113
 
 
114
 
        onRunningChanged: {
115
 
            if (!running)
116
 
                editorEntered(albumEditorTransition.album);
117
 
        }
118
 
 
119
 
        FadeInAnimation {
120
 
            target: backgroundGlass
121
 
            endOpacity: 0.75
122
 
            duration: albumEditorTransition.duration
123
 
        }
124
 
 
125
 
        FadeInAnimation {
126
 
            target: editor
127
 
            duration: albumEditorTransition.duration
128
 
        }
129
 
    }
130
 
 
131
 
    ParallelAnimation {
132
 
        id: exitFadeAnimation
133
 
 
134
 
        onRunningChanged: {
135
 
            if (!running)
136
 
                onExitFinished();
137
 
        }
138
 
 
139
 
        FadeOutAnimation {
140
 
            target: backgroundGlass
141
 
            startOpacity: 0.75
142
 
            duration: albumEditorTransition.duration
143
 
        }
144
 
 
145
 
        FadeOutAnimation {
146
 
            target: editor
147
 
            duration: albumEditorTransition.duration
148
 
        }
149
 
    }
150
 
 
151
 
    SequentialAnimation {
152
 
        id: enterExpandAnimation
153
 
 
154
 
        onRunningChanged: {
155
 
            if (!running)
156
 
                editorEntered(albumEditorTransition.album);
157
 
        }
158
 
 
159
 
        PropertyAction { target: thumbnail; property: "visible"; value: true; }
160
 
 
161
 
        ParallelAnimation {
162
 
            ExpandAnimation {
163
 
                target: thumbnail
164
 
                endX: editor.editorRect.x
165
 
                endY: editor.editorRect.y
166
 
                endWidth: editor.editorRect.width
167
 
                endHeight: editor.editorRect.height
168
 
                duration: albumEditorTransition.duration
169
 
                easingType: Easing.OutQuad
170
 
            }
171
 
 
172
 
            NumberAnimation {
173
 
                target: thumbnail
174
 
                property: "openFraction"
175
 
                from: (!album || album.closed ? 0 : 1)
176
 
                to: 0
177
 
                duration: albumEditorTransition.duration
178
 
                easing.type: Easing.OutQuad
179
 
            }
180
 
 
181
 
            FadeInAnimation {
182
 
                target: backgroundGlass
183
 
                endOpacity: 0.75
184
 
                duration: albumEditorTransition.duration
185
 
            }
186
 
        }
187
 
 
188
 
        PropertyAction { target: thumbnail; property: "visible"; value: false; }
189
 
        PropertyAction { target: editor; property: "visible"; value: true; }
190
 
    }
191
 
 
192
 
    SequentialAnimation {
193
 
        id: exitExpandAnimation
194
 
 
195
 
        property variant thumbnailRect: {"x": 0, "y": 0, "width": 0, "height": 0}
196
 
 
197
 
        onRunningChanged: {
198
 
            if (!running)
199
 
                onExitFinished();
200
 
        }
201
 
 
202
 
        PropertyAction { target: editor; property: "visible"; value: false; }
203
 
        PropertyAction { target: thumbnail; property: "visible"; value: true; }
204
 
 
205
 
        ParallelAnimation {
206
 
            ExpandAnimation {
207
 
                target: thumbnail
208
 
                endX: exitExpandAnimation.thumbnailRect.x
209
 
                endY: exitExpandAnimation.thumbnailRect.y
210
 
                endWidth: exitExpandAnimation.thumbnailRect.width
211
 
                endHeight: exitExpandAnimation.thumbnailRect.height
212
 
                duration: albumEditorTransition.duration
213
 
                easingType: Easing.OutQuad
214
 
            }
215
 
 
216
 
            NumberAnimation {
217
 
                target: thumbnail
218
 
                property: "openFraction"
219
 
                from: 0
220
 
                to: (!album || album.closed ? 0 : 1)
221
 
                duration: albumEditorTransition.duration
222
 
                easing.type: Easing.InQuad
223
 
            }
224
 
 
225
 
            FadeOutAnimation {
226
 
                target: backgroundGlass
227
 
                startOpacity: 0.75
228
 
                duration: albumEditorTransition.duration
229
 
            }
230
 
        }
231
 
 
232
 
        PropertyAction { target: thumbnail; property: "visible"; value: false; }
233
 
    }
234
 
}