Debian Codegraph @

rc/qml/AlbumViewer/AlbumPageComponent.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 * Jim Nelson <[email protected]>
18 * Charles Lindsay <[email protected]>
19 */
20
21 import QtQuick 2.9
22 import Gallery 1.0
23 import "AlbumInternals"
24 import "../../js/Gallery.js" as Gallery
25
26 // One "piece of paper" in an album. Contains album content i.e. photos (or
27 // the cover) from the album and handles rotating, displaying an arbitrary page
28 // on the front (right) or back (left) sides.
29 Flipable {
30 id: albumPageComponent
31
32 /*!
33 */
34 property Album album // The album this page is in.
35
36 /*!
37 */
38 property alias frontPage: frontContents.page // On the right when viewed like in a book.
39 /*!
40 */
41 property alias backPage: backContents.page // On the left when viewed like in a book.
42
43 // [0,2]: 0 = flat right page, 1 = flat left page, 2 = back to right page.
44 // The page turns 360 degrees from 0-2 in a normal "book" fashion.
45 property real flipFraction: 0
46
47 /*!
48 */
49 property bool isPreview: false // Whether to load preview or normal images.
50 /*!
51 */
52 property bool load: false
53 // These override the isPreview option if specified.
54 property alias frontIsPreview: frontContents.isPreview
55 /*!
56 */
57 property alias backIsPreview: backContents.isPreview
58
59 // Whether to draw a frame around the page, if it's a content page.
60 property bool contentHasPreviewFrame: false
61
62 /*!
63 */
64 property real topMargin: pageTopMargin
65 /*!
66 */
67 property real bottomMargin: pageBottomMargin
68 /*!
69 */
70 property real gutterMargin: pageGutterMargin
71 /*!
72 */
73 property real outerMargin: pageOuterMargin
74 /*!
75 */
76 property real insideMargin: pageInsideMargin
77
78 // Prevent the page from reflecting the album as its modified
79 property bool freeze: false
80
81 // Whether to draw the cover (defaults to true)
82 // This is used to prevent the cover from being drawn during certain transitions.
83 property bool showCover: true
84
85 // readonly
86 /*!
87 */
88 property alias frontIsCover: frontContents.isCover
89 /*!
90 */
91 property alias backIsCover: backContents.isCover
92 /*!
93 */
94 property alias frameToContentWidth: frontContents.frameToContentWidth
95 /*!
96 */
97 property alias frameToContentHeight: frontContents.frameToContentHeight
98 /*!
99 */
100 property alias frameHingeInset: frontContents.frameHingeInset
101
102 /*!
103 */
104 property real pageTopMargin: getDeviceSpecific('albumPageTopMargin')
105 /*!
106 */
107 property real pageBottomMargin: getDeviceSpecific('albumPageBottomMargin')
108 /*!
109 */
110 property real pageGutterMargin: getDeviceSpecific('albumPageGutterMargin')
111 /*!
112 */
113 property real pageOuterMargin: getDeviceSpecific('albumPageOuterMargin')
114 /*!
115 */
116 property real pageInsideMargin: getDeviceSpecific('albumPageInsideMargin')
117
118 /*!
119 */
120 property real previewTopMargin: getDeviceSpecific('albumPreviewTopMargin')
121 /*!
122 */
123 property real previewBottomMargin: getDeviceSpecific('albumPreviewBottomMargin')
124 /*!
125 */
126 property real previewGutterMargin: getDeviceSpecific('albumPreviewGutterMargin')
127 /*!
128 */
129 property real previewOuterMargin: getDeviceSpecific('albumPreviewOuterMargin')
130 /*!
131 */
132 property real previewInsideMargin: getDeviceSpecific('albumPreviewInsideMargin')
133
134 // Returns the page number of the left page of the current "spread", denoted
135 // by a currentPage number from an album. This will go on the backPage.
136 function leftPageForCurrent(currentPage) {
137 return currentPage;
138 }
139
140 // Returns the page number of the right page of the current "spread", denoted
141 // by a currentPage number from an album. This will go on the frontPage.
142 function rightPageForCurrent(currentPage) {
143 return currentPage + 1;
144 }
145
146 front: AlbumPageContents {
147 id: frontContents
148
149 x: isPreview ? -frontContents.frameHingeInset : 0 // origin offset
150 width: albumPageComponent.width
151 height: albumPageComponent.height
152
153 album: albumPageComponent.album
154
155 isPreview: albumPageComponent.isPreview
156 load: albumPageComponent.load
157 contentHasPreviewFrame: albumPageComponent.contentHasPreviewFrame
158
159 topMargin: albumPageComponent.topMargin
160 bottomMargin: albumPageComponent.bottomMargin
161 gutterMargin: albumPageComponent.gutterMargin
162 outerMargin: albumPageComponent.outerMargin
163 insideMargin: albumPageComponent.insideMargin
164
165 freeze: albumPageComponent.freeze
166 showCover: albumPageComponent.showCover
167 }
168
169 back: AlbumPageContents {
170 id: backContents
171
172 x: isPreview ? frontContents.frameHingeInset : 0 // origin offset
173 width: albumPageComponent.width
174 height: albumPageComponent.height
175
176 album: albumPageComponent.album
177
178 isPreview: albumPageComponent.isPreview
179 load: albumPageComponent.load
180 contentHasPreviewFrame: albumPageComponent.contentHasPreviewFrame
181
182 topMargin: albumPageComponent.topMargin
183 bottomMargin: albumPageComponent.bottomMargin
184 gutterMargin: albumPageComponent.gutterMargin
185 outerMargin: albumPageComponent.outerMargin
186 insideMargin: albumPageComponent.insideMargin
187
188 freeze: albumPageComponent.freeze
189 showCover: albumPageComponent.showCover
190 }
191
192 transform: Rotation {
193 id: rotation
194
195 origin.x: 0
196 origin.y: albumPageComponent.height / 2
197
198 axis.x: 0
199 axis.y: 1
200 axis.z: 0
201
202 angle: (flipFraction * -180)
203 }
204 }