Debian Codegraph @

rc/qml/AlbumViewer/AlbumInternals/AlbumPageFlipperPage.qml

raw
1 /*
2 * Copyright (C) 2012-2015 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 <[email protected]>
18 */
19
20 import QtQuick 2.9
21 import ".."
22
23 // A page included inside the AlbumPageFlipper; see notes there. Tightly
24 // coupled.
25 AlbumPageComponent {
26 id: albumPageFlipperPage
27
28 /*!
29 */
30 property int flipperPage
31
32 // internal
33 /*!
34 */
35 property int page // For some reason QML chokes unless this is broken up onto
36 page: { // two lines like so.
37 // Last page's number is one spread back from lastPage.
38 if (flipperPage == numPages - 1)
39 return lastPage - pagesPerSpread;
40
41 // Second to last page's number is two spreads back.
42 if (flipperPage == numPages - 2)
43 return lastPage - 2 * pagesPerSpread;
44
45 // Otherwise, we do sequential spreads forward from firstPage.
46 return firstPage + pagesPerSpread * flipperPage;
47 }
48
49 property real flipFractionIntercept:
50 -flipSlope * flipperPage * gapBetweenPages
51
52 // These are from AlbumPageFlipper.
53 /*!
54 */
55 property int numPages: parent.numPages
56 /*!
57 */
58 property int firstPage: parent.firstPage
59 /*!
60 */
61 property int lastPage: parent.lastPage
62 /*!
63 */
64 property real gapBetweenPages: parent.gapBetweenPages
65 /*!
66 */
67 property real pageFlipFraction: parent.pageFlipFraction
68 /*!
69 */
70 property real flipSlope: parent.flipSlope
71 /*!
72 */
73 property bool isPortrait: parent.isPortrait
74 /*!
75 */
76 property int pagesPerSpread: parent.pagesPerSpread
77
78 anchors.fill: parent
79 z: flipFraction < 0.5 ? numPages - flipperPage : flipperPage
80
81 visible: numPages > flipperPage
82 load: visible
83
84 album: parent.album
85
86 frontPage: (isPortrait ? page : rightPageForCurrent(page))
87 // backPage is the next spread or blank for portrait mode.
88 backPage: (isPortrait ? -1 : leftPageForCurrent(page + pagesPerSpread))
89
90 frontIsPreview: flipperPage > 0
91 backIsPreview: numPages > flipperPage + 1
92
93 // The 0.55 factor causes the animation to end juuuuust past vertical in
94 // portrait mode. This looks better to my eyes than directly vertical (0.5).
95 flipFraction: (isPortrait ? 0.55 : 1) * Math.min(1, Math.max(0,
96 flipSlope * pageFlipFraction + flipFractionIntercept))
97 }