2
* Copyright 2011 Canonical Ltd.
5
* Olivier Tilloy <olivier@tilloy.net>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 3.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
property int duration: 200
26
property alias currentIndex: frames.currentIndex
27
property alias count: frames.count
33
property int currentIndex: -1
37
for (var i = 0; i < frames.count; i++) {
38
frames.get(i).frame.width = frameSwitch.width
40
if (frames.count > 0) {
41
frames.get(0).frame.x = -frameSwitch.width * frames.currentIndex
45
function pushFrame(frame) {
46
frame.duration = frameSwitch.duration
47
frames.append({ frame: frame })
48
frame.parent = frameSwitch
49
frame.width = frame.parent.width
50
frame.anchors.top = frame.parent.top
51
frame.anchors.bottom = frame.parent.bottom
52
if (frames.count == 1) {
55
frames.currentIndex = 0
57
frame.anchors.left = frames.get(frames.count - 2).frame.right
61
function currentFrame() {
62
if (frames.count > 0) {
63
return frames.get(frames.currentIndex).frame
69
function changeIndex(newIndex) {
70
if (frames.count <= 1) return
71
if (frames.currentIndex == newIndex) return
72
if (newIndex < 0 || newIndex >= frames.count) return
73
frameConnection.target = frames.get(0).frame
74
frames.get(0).frame.x = -frameSwitch.width * newIndex
75
frames.currentIndex = newIndex
78
function goToFrame(frame) {
79
for (var i = 0; i < frames.count; i++) {
80
if (frames.get(i).frame == frame) {
91
if (!frameConnection.target.running) {
92
frameConnection.target = null
93
currentFrame().shown()
94
currentFrame().focus = true