~bfiller/gallery-app/revert-1245

« back to all changes in this revision

Viewing changes to rc/qml/AlbumViewer/AlbumViewerTransitionPortraitPage.qml

  • Committer: Bill Filler
  • Date: 2015-11-10 02:39:01 UTC
  • Revision ID: bill.filler@canonical.com-20151110023901-h0w20x8dyznnzldy
revert back to rev 1242

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
 * Eric Gregory <eric@yorba.org>
 
18
 */
 
19
 
 
20
import QtQuick 2.0
 
21
import Gallery 1.0
 
22
import "../Components"
 
23
 
 
24
// AlbumViewerTransitionPortraitPage is just like AlbumOpener, except it only 
 
25
// shows one page at a time.  This is intended for use in AlbumViewerTransition
 
26
// as a replacement for AlbumOpener when used in portrait mode and closing
 
27
// an even-numbered page.
 
28
Item {
 
29
    id: albumViewerTransitionPortraitPage
 
30
 
 
31
    // public
 
32
    property Album album
 
33
    /*!
 
34
    */
 
35
    property bool isPreview: false
 
36
    /*!
 
37
    */
 
38
    property bool contentHasPreviewFrame: false
 
39
    /*!
 
40
    */
 
41
    property int viewingPage
 
42
 
 
43
    /*!
 
44
    */
 
45
    property int insideLeftPage: defaultInsideLeftPage
 
46
    /*!
 
47
    */
 
48
    property int insideRightPage: defaultInsideRightPage
 
49
 
 
50
    // Here, openFraction refers to how "flipped" the page is, rather than
 
51
    // how open the album is.
 
52
    property real openFraction: 0
 
53
 
 
54
    /*!
 
55
    */
 
56
    property real topMargin: previewTopMargin
 
57
    /*!
 
58
    */
 
59
    property real bottomMargin: previewBottomMargin
 
60
    /*!
 
61
    */
 
62
    property real gutterMargin: previewGutterMargin
 
63
    /*!
 
64
    */
 
65
    property real outerMargin: previewOuterMargin
 
66
    /*!
 
67
    */
 
68
    property real insideMargin: previewInsideMargin
 
69
 
 
70
    // readonly
 
71
    /*!
 
72
    */
 
73
    property bool isFlipping: (openFraction != 0 && openFraction != 1)
 
74
    /*!
 
75
    */
 
76
    property alias frameToContentWidth: page.frameToContentWidth
 
77
    /*!
 
78
    */
 
79
    property alias frameToContentHeight: page.frameToContentHeight
 
80
 
 
81
    /*!
 
82
    */
 
83
    property alias load: page.load
 
84
 
 
85
    /*!
 
86
    */
 
87
    property int defaultInsideLeftPage: page.leftPageForCurrent(currentOrFirstContentPage)
 
88
    /*!
 
89
    */
 
90
    property int defaultInsideRightPage: page.rightPageForCurrent(currentOrFirstContentPage)
 
91
 
 
92
    /*!
 
93
    */
 
94
    property alias pageTopMargin: page.pageTopMargin
 
95
    /*!
 
96
    */
 
97
    property alias pageBottomMargin: page.pageBottomMargin
 
98
    /*!
 
99
    */
 
100
    property alias pageGutterMargin: page.pageGutterMargin
 
101
    /*!
 
102
    */
 
103
    property alias pageOuterMargin: page.pageOuterMargin
 
104
    /*!
 
105
    */
 
106
    property alias pageInsideMargin: page.pageInsideMargin
 
107
 
 
108
    /*!
 
109
    */
 
110
    property alias previewTopMargin: page.previewTopMargin
 
111
    /*!
 
112
    */
 
113
    property alias previewBottomMargin: page.previewBottomMargin
 
114
    /*!
 
115
    */
 
116
    property alias previewGutterMargin: page.previewGutterMargin
 
117
    /*!
 
118
    */
 
119
    property alias previewOuterMargin: page.previewOuterMargin
 
120
    /*!
 
121
    */
 
122
    property alias previewInsideMargin: page.previewInsideMargin
 
123
 
 
124
    // internal
 
125
    /*!
 
126
    */
 
127
    property int currentOrFirstContentPage: (!album
 
128
                                             ? -1
 
129
                                             : (album.currentPage == album.firstValidCurrentPage
 
130
                                                ? album.firstContentPage
 
131
                                                : album.currentPage))
 
132
 
 
133
    onAlbumChanged: openFraction = (!album || album.closed ? 0 : 1)
 
134
 
 
135
    Connections {
 
136
        target: album
 
137
        ignoreUnknownSignals: true
 
138
        onClosedChanged: openFraction = (album.closed ? 0 : 1)
 
139
    }
 
140
 
 
141
    Item {
 
142
        id: shifter
 
143
 
 
144
        x: width * openFraction // Shift it over as it opens so the visuals stay centered.
 
145
        y: 0
 
146
        width: parent.width
 
147
        height: parent.height
 
148
 
 
149
        AlbumPageComponent {
 
150
            id: page
 
151
 
 
152
            anchors.fill: parent
 
153
 
 
154
            album: albumViewerTransitionPortraitPage.album
 
155
 
 
156
            frontPage: viewingPage
 
157
            backPage: album !== null ? album.currentPage : viewingPage
 
158
 
 
159
            isPreview: albumOpenerPortrait.isPreview
 
160
            contentHasPreviewFrame: albumViewerTransitionPortraitPage.contentHasPreviewFrame
 
161
 
 
162
            flipFraction: -openFraction
 
163
 
 
164
            topMargin: albumViewerTransitionPortraitPage.topMargin
 
165
            bottomMargin: albumViewerTransitionPortraitPage.bottomMargin
 
166
            gutterMargin: albumViewerTransitionPortraitPage.gutterMargin
 
167
            outerMargin: albumViewerTransitionPortraitPage.outerMargin
 
168
            insideMargin: albumViewerTransitionPortraitPage.insideMargin
 
169
        }
 
170
    }
 
171
}