-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzglAnimationGroup.cpp
executable file
·209 lines (177 loc) · 3.18 KB
/
zglAnimationGroup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* Copyright (C) 2010 ZiiLABS Pte Ltd
* All Rights Reserved.
*
* This software and its associated documentation may contain some
* proprietary, confidential and trade secret information of
* ZiiLABS Pte Ltd and except as provided by written agreement with
* ZiiLABS Pte Ltd
*
* a) no part may be disclosed, distributed, reproduced, transmitted,
* transcribed, stored in a retrieval system, adapted or translated
* in any form or by any means electronic, mechanical, magnetic,
* optical, chemical, manual or otherwise,
*
* and
*
* b) the recipient is not entitled to discover through reverse
* engineering or reverse compiling or other such techniques or
* processes the trade secrets contained therein or in the
* documentation.
*/
#include <stdlib.h>
#include "zglAnimationGroup.h"
zglAnimationGroup::zglAnimationGroup()
{
m_head = NULL;
m_tail = NULL;
}
void zglAnimationGroup::reset()
{
zglAnimation* a = m_head;
while (a != NULL)
{
a->reset();
a = a->m_next;
}
zglAnimation::reset();
}
void zglAnimationGroup::start(long time, long delay)
{
zglAnimation* a = m_head;
while (a != NULL)
{
a->start(time);
a = a->m_next;
}
zglAnimation::start(time, delay);
}
void zglAnimationGroup::stop()
{
zglAnimation* a = m_head;
while (a != NULL)
{
a->stop();
a = a->m_next;
}
zglAnimation::stop();
}
bool zglAnimationGroup::isRunning()
{
zglAnimation* a = m_head;
while (a != NULL)
{
if (a->isRunning())
{
return true;
}
a = a->m_next;
}
return false;
}
bool zglAnimationGroup::isStopped()
{
zglAnimation* a = m_head;
while (a != NULL)
{
if (a->isStopped())
{
return true;
}
a = a->m_next;
}
return false;
}
bool zglAnimationGroup::update(long time)
{
bool bRet = false;
zglAnimation* a = m_head;
while (a != NULL)
{
if (a->isRunning())
{
bRet = a->update(time) || bRet;
}
a = a->m_next;
}
return bRet;
}
void zglAnimationGroup::bindWidget(zglWidget * widget)
{
zglAnimation* a = m_head;
while (a != NULL)
{
a->bindWidget(widget);
a = a->m_next;
}
zglAnimation::bindWidget(widget);
}
void zglAnimationGroup::addAnimation(zglAnimation * anim)
{
if (anim == NULL)
return;
if (m_head == NULL && m_tail == NULL)
{
m_head = anim;
m_tail = anim;
anim->m_next = NULL;
anim->m_prev = NULL;
}
else
{
zglAnimation *a = m_tail;
anim->m_next = NULL;
anim->m_prev = a;
a->m_next = anim;
}
anim->stop();
if (m_widget != NULL)
{
anim->bindWidget(m_widget);
}
}
void zglAnimationGroup::removeAnimation(zglAnimation * anim)
{
if (anim == NULL)
return;
if (anim == m_head)
{
m_head = anim->m_next;
if (m_head != NULL)
{
m_head->m_prev = NULL;
}
else
{
m_tail = NULL;
}
}
else if (anim == m_tail)
{
m_tail = anim->m_prev;
if (m_tail != NULL)
{
m_tail->m_next = NULL;
}
}
else
{
anim->m_next->m_prev = anim->m_prev;
anim->m_prev->m_next = anim->m_next;
}
anim->m_next = NULL;
anim->m_prev = NULL;
anim->bindWidget(NULL);
}
void zglAnimationGroup::removeAllAnimation()
{
zglAnimation* a = NULL;
while (m_head != NULL)
{
a = m_head;
m_head = m_head ->m_next;
a->m_next = NULL;
a->m_prev = NULL;
a->bindWidget(NULL);
}
}