Changeset View
Changeset View
Standalone View
Standalone View
src/controls/PageRow.qml
Show All 32 Lines | |||||
33 | */ | 33 | */ | ||
34 | T.Control { | 34 | T.Control { | ||
35 | id: root | 35 | id: root | ||
36 | 36 | | |||
37 | //BEGIN PROPERTIES | 37 | //BEGIN PROPERTIES | ||
38 | /** | 38 | /** | ||
39 | * This property holds the number of items currently pushed onto the view | 39 | * This property holds the number of items currently pushed onto the view | ||
40 | */ | 40 | */ | ||
41 | readonly property alias depth: pagesLogic.count | 41 | readonly property int depth: popScrollAnim.running && popScrollAnim.pendingDepth > -1 ? popScrollAnim.pendingDepth : pagesLogic.count | ||
42 | 42 | | |||
43 | /** | 43 | /** | ||
44 | * The last Page in the Row | 44 | * The last Page in the Row | ||
45 | */ | 45 | */ | ||
46 | readonly property Item lastItem: pagesLogic.count ? pagesLogic.get(pagesLogic.count - 1).page : null | 46 | readonly property Item lastItem: pagesLogic.count ? pagesLogic.get(pagesLogic.count - 1).page : null | ||
47 | 47 | | |||
48 | /** | 48 | /** | ||
49 | * The currently visible Item | 49 | * The currently visible Item | ||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 87 | //BEGIN FUNCTIONS | |||
108 | */ | 108 | */ | ||
109 | function push(page, properties) { | 109 | function push(page, properties) { | ||
110 | //don't push again things already there | 110 | //don't push again things already there | ||
111 | if (page.createObject === undefined && typeof page != "string" && pagesLogic.containsPage(page)) { | 111 | if (page.createObject === undefined && typeof page != "string" && pagesLogic.containsPage(page)) { | ||
112 | print("The item " + page + " is already in the PageRow"); | 112 | print("The item " + page + " is already in the PageRow"); | ||
113 | return; | 113 | return; | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | if (popScrollAnim.running) { | ||||
117 | popScrollAnim.running = false; | ||||
118 | popScrollAnim.popPageCleanup(popScrollAnim.pendingPage); | ||||
119 | } | ||||
120 | | ||||
116 | popScrollAnim.popPageCleanup(currentItem); | 121 | popScrollAnim.popPageCleanup(currentItem); | ||
117 | 122 | | |||
118 | // figure out if more than one page is being pushed | 123 | // figure out if more than one page is being pushed | ||
119 | var pages; | 124 | var pages; | ||
120 | if (page instanceof Array) { | 125 | if (page instanceof Array) { | ||
121 | pages = page; | 126 | pages = page; | ||
122 | page = pages.pop(); | 127 | page = pages.pop(); | ||
123 | if (page.createObject === undefined && page.parent === undefined && typeof page != "string") { | 128 | if (page.createObject === undefined && page.parent === undefined && typeof page != "string") { | ||
Show All 38 Lines | |||||
162 | * page as null. | 167 | * page as null. | ||
163 | * @return The page instance that was popped off the stack. | 168 | * @return The page instance that was popped off the stack. | ||
164 | */ | 169 | */ | ||
165 | function pop(page) { | 170 | function pop(page) { | ||
166 | if (depth == 0) { | 171 | if (depth == 0) { | ||
167 | return; | 172 | return; | ||
168 | } | 173 | } | ||
169 | 174 | | |||
175 | //if a pop was animating, stop it | ||||
170 | if (popScrollAnim.running) { | 176 | if (popScrollAnim.running) { | ||
171 | popScrollAnim.running = false; | 177 | popScrollAnim.running = false; | ||
172 | popScrollAnim.popPageCleanup(popScrollAnim.pendingPage); | 178 | popScrollAnim.popPageCleanup(popScrollAnim.pendingPage); | ||
179 | //if a push was animating, stop it | ||||
180 | } else { | ||||
181 | mainView.positionViewAtIndex(mainView.currentIndex, ListView.Beginning); | ||||
173 | } | 182 | } | ||
174 | 183 | | |||
175 | popScrollAnim.from = mainView.contentX | 184 | popScrollAnim.from = mainView.contentX | ||
176 | 185 | | |||
177 | popScrollAnim.to = page ? page.parent.x : (mainView.contentX > 10 ? mainView.itemAt(mainView.contentX - 10, 1).x : 0); | 186 | if ((!page || !page.parent) && pagesLogic.count > 1) { | ||
187 | page = pagesLogic.get(pagesLogic.count - 2).page; | ||||
188 | } | ||||
189 | popScrollAnim.to = page && page.parent ? page.parent.x : 0; | ||||
178 | popScrollAnim.pendingPage = page; | 190 | popScrollAnim.pendingPage = page; | ||
191 | popScrollAnim.pendingDepth = page && page.parent ? page.parent.level + 1 : 0; | ||||
192 | | ||||
179 | popScrollAnim.running = true; | 193 | popScrollAnim.running = true; | ||
180 | //popScrollAnim.popPageCleanup(popScrollAnim.pendingPage); | | |||
181 | } | 194 | } | ||
182 | 195 | | |||
183 | SequentialAnimation { | 196 | SequentialAnimation { | ||
184 | id: popScrollAnim | 197 | id: popScrollAnim | ||
185 | property real from | 198 | property real from | ||
186 | property real to | 199 | property real to | ||
187 | property var pendingPage | 200 | property var pendingPage | ||
201 | property int pendingDepth: -1 | ||||
188 | function popPageCleanup(page) { | 202 | function popPageCleanup(page) { | ||
189 | if (depth == 0) { | 203 | if (pagesLogic.count == 0) { | ||
190 | return; | 204 | return; | ||
191 | } | 205 | } | ||
192 | if (popScrollAnim.running) { | 206 | if (popScrollAnim.running) { | ||
193 | popScrollAnim.running = false; | 207 | popScrollAnim.running = false; | ||
194 | } | 208 | } | ||
195 | 209 | | |||
196 | var oldPage = pagesLogic.get(pagesLogic.count-1).page; | 210 | var oldPage = pagesLogic.get(pagesLogic.count-1).page; | ||
197 | if (page !== undefined) { | 211 | if (page !== undefined) { | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 338 | function removePage(id) { | |||
337 | pagesLogic.remove(id); | 351 | pagesLogic.remove(id); | ||
338 | item.parent = root; | 352 | item.parent = root; | ||
339 | if (item.page.parent==item) { | 353 | if (item.page.parent==item) { | ||
340 | item.page.destroy(1) | 354 | item.page.destroy(1) | ||
341 | } | 355 | } | ||
342 | item.destroy(); | 356 | item.destroy(); | ||
343 | } | 357 | } | ||
344 | function clearPages () { | 358 | function clearPages () { | ||
359 | popScrollAnim.running = false; | ||||
360 | popScrollAnim.pendingDepth = -1; | ||||
345 | while (count > 0) { | 361 | while (count > 0) { | ||
346 | removePage(count-1); | 362 | removePage(count-1); | ||
347 | } | 363 | } | ||
348 | } | 364 | } | ||
349 | function initPage(page, properties) { | 365 | function initPage(page, properties) { | ||
350 | var container = containerComponent.createObject(mainView, { | 366 | var container = containerComponent.createObject(mainView, { | ||
351 | "level": pagesLogic.count, | 367 | "level": pagesLogic.count, | ||
352 | "page": page | 368 | "page": page | ||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |