soui 5.0.0.1
Soui5 Doc
 
Loading...
Searching...
No Matches
SAnimation-i.h
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * Abstraction for an Animation that can be applied to Views, Surfaces, or
19 * other objects. See the {@link android.view.animation animation package
20 * description file}.
21 */
22#ifndef __SANIMATION_I__H__
23#define __SANIMATION_I__H__
24
25#include <interface/sinterpolator-i.h>
26#include <interface/sobject-i.h>
27#include <interface/STransform-i.h>
28#include <stdint.h>
29SNSBEGIN
30
31typedef struct IAnimation IAnimation;
32
33#undef INTERFACE
34#define INTERFACE IAnimationListener
35DECLARE_INTERFACE(IAnimationListener)
36{
37 /**
38 * @brief 通知动画开始
39 * @param animation IAnimation* -- 开始的动画
40 * @return void
41 */
42 STDMETHOD_(void, OnAnimationStart)(THIS_ IAnimation * animation) PURE;
43
44 /**
45 * @brief 通知动画结束。对于重复次数设置为INFINITE的动画,不会调用此回调。
46 * @param animation IAnimation* -- 结束的动画
47 * @return void
48 */
49 STDMETHOD_(void, OnAnimationStop)(THIS_ IAnimation * animation) PURE;
50
51 /**
52 * @brief 通知动画重复
53 * @param animation IAnimation* -- 重复的动画
54 * @return void
55 */
56 STDMETHOD_(void, OnAnimationRepeat)(THIS_ IAnimation * animation) PURE;
57
58 /**
59 * @brief 通知动画暂停状态变化
60 * @param animation IAnimation* -- 状态变化的动画
61 * @param bPaused BOOL -- TRUE: 暂停,FALSE: 继续
62 * @return void
63 */
64 STDMETHOD_(void, OnAnimationPauseChange)(THIS_ IAnimation * animation, BOOL bPaused) PURE;
65};
66
67/**
68 * <p>An animation listener receives notifications from an animation.
69 * Notifications indicate animation related events, such as the end or the
70 * repetition of the animation.</p>
71 */
72typedef enum RepeatMode
73{
74 RESTART = 1,
75 REVERSE = 2,
76} RepeatMode;
77
78/**
79 * Can be used as the start time to indicate the start time should be the current
80 * time when {@link #getTransformation(long, STransformation)} is invoked for the
81 * first animation frame. This can is useful for short animations.
82 */
83enum
84{
85 START_ON_FIRST_FRAME = -1,
86};
87
88typedef enum AniValueType
89{
90 /**
91 * The specified dimension is an ABSOLUTE_VALUE number of pixels.
92 */
93 ABSOLUTE_VALUE = 0,
94 /**
95 * The specified dimension holds a float and should be multiplied by the
96 * height or width of the parent of the object being animated.
97 */
98 RELATIVE_TO_SELF = 1,
99 /**
100 * The specified dimension holds a float and should be multiplied by the
101 * height or width of the parent of the object being animated.
102 */
103 RELATIVE_TO_PARENT = 2,
104} AniValueType;
105
106typedef enum ZAdjustment
107{
108 /**
109 * Requests that the content being animated be kept in its current Z
110 * order.
111 */
112 ZORDER_NORMAL = 0,
113 /**
114 * Requests that the content being animated be forced on top of all other
115 * content for the duration of the animation.
116 */
117 ZORDER_TOP = 1,
118 /**
119 * Requests that the content being animated be forced under all other
120 * content for the duration of the animation.
121 */
122 ZORDER_BOTTOM = -1
123} ZAdjustment;
124
125#undef INTERFACE
126#define INTERFACE IAnimation
127DECLARE_INTERFACE_(IAnimation, IObject)
128{
129 DEF_OBJ_BASE(IAnimation, Animation)
130#include <interface/SobjectApi.h>
131
132 /**
133 * @brief 克隆动画对象
134 * @return IAnimation* -- 克隆的动画对象
135 */
136 STDMETHOD_(IAnimation *, clone)(CTHIS) SCONST PURE;
137
138 /**
139 * @brief 复制动画对象
140 * @param src const IAnimation* -- 源动画对象
141 * @return void
142 */
143 STDMETHOD_(void, copy)(THIS_ const IAnimation *src) PURE;
144
145 /**
146 * @brief 重置动画的初始化状态
147 * @return void
148 */
149 STDMETHOD_(void, reset)(THIS) PURE;
150
151 /**
152 * @brief 取消动画。取消动画会调用动画监听器(如果设置了)来通知动画结束。
153 * @return void
154 */
155 STDMETHOD_(void, cancel)(THIS) PURE;
156
157 /**
158 * @brief 设置动画的加速曲线。默认为线性插值。
159 * @param i IInterpolator* -- 定义加速曲线的插值器
160 * @return void
161 */
162 STDMETHOD_(void, setInterpolator)(THIS_ IInterpolator * i) PURE;
163
164 /**
165 * @brief 设置动画持续时间。持续时间不能为负数。
166 * @param durationMillis long -- 持续时间(毫秒)
167 * @return void
168 */
169 STDMETHOD_(void, setDuration)(THIS_ long durationMillis) PURE;
170
171 /**
172 * @brief 缩放当前持续时间
173 * @param scale float -- 缩放比例
174 * @return void
175 */
176 STDMETHOD_(void, scaleCurrentDuration)(THIS_ float scale) PURE;
177
178 /**
179 * @brief 设置动画开始前是否应用动画效果
180 * @param bFill BOOL -- TRUE: 应用,FALSE: 不应用
181 * @return void
182 */
183 STDMETHOD_(void, setFillBefore)(THIS_ BOOL bFill) PURE;
184
185 /**
186 * @brief 设置动画结束后是否应用动画效果
187 * @param bFill BOOL -- TRUE: 应用,FALSE: 不应用
188 * @return void
189 */
190 STDMETHOD_(void, setFillAfter)(THIS_ BOOL bFill) PURE;
191
192 /**
193 * @brief 获取动画开始前是否应用动画效果
194 * @return BOOL -- TRUE: 应用,FALSE: 不应用
195 */
196 STDMETHOD_(BOOL, getFillBefore)(CTHIS) SCONST PURE;
197
198 /**
199 * @brief 获取动画结束后是否应用动画效果
200 * @return BOOL -- TRUE: 应用,FALSE: 不应用
201 */
202 STDMETHOD_(BOOL, getFillAfter)(CTHIS) SCONST PURE;
203
204 /**
205 * @brief 设置动画开始偏移时间
206 * @param offset long -- 偏移时间(毫秒)
207 * @return void
208 */
209 STDMETHOD_(void, setStartOffset)(THIS_ long offset) PURE;
210
211 /**
212 * @brief 获取动画是否启用填充效果
213 * @return BOOL -- TRUE: 启用,FALSE: 不启用
214 */
215 STDMETHOD_(BOOL, isFillEnabled)(CTHIS) SCONST PURE;
216
217 /**
218 * @brief 设置动画是否启用填充效果
219 * @param fillEnabled BOOL -- TRUE: 启用,FALSE: 不启用
220 * @return void
221 */
222 STDMETHOD_(void, setFillEnabled)(THIS_ BOOL fillEnabled) PURE;
223
224 /**
225 * @brief 设置动画开始时间
226 * @param startTimeMillis int64_t -- 开始时间(毫秒)
227 * @return void
228 */
229 STDMETHOD_(void, setStartTime)(THIS_ int64_t startTimeMillis) PURE;
230
231 /**
232 * @brief 方便方法,设置动画在第一次调用getTransformation时开始
233 * @return void
234 */
235 STDMETHOD_(void, start)(THIS) PURE;
236
237 /**
238 * @brief 方便方法,设置动画在当前时间开始
239 * @return void
240 */
241 STDMETHOD_(void, startNow)(THIS) PURE;
242
243 /**
244 * @brief 设置动画结束时的行为
245 * @param repeatMode RepeatMode -- RESTART或REVERSE
246 * @return void
247 */
248 STDMETHOD_(void, setRepeatMode)(THIS_ RepeatMode repeatMode) PURE;
249
250 /**
251 * @brief 设置动画重复次数
252 * @param repeatCount int -- 重复次数
253 * @return void
254 */
255 STDMETHOD_(void, setRepeatCount)(THIS_ int repeatCount) PURE;
256
257 /**
258 * @brief 设置动画运行时的Z顺序模式
259 * @param zAdjustment ZAdjustment -- ZORDER_NORMAL, ZORDER_TOP, 或 ZORDER_BOTTOM
260 * @return void
261 */
262 STDMETHOD_(void, setZAdjustment)(THIS_ ZAdjustment zAdjustment) PURE;
263
264 /**
265 * @brief 获取动画的加速曲线类型
266 * @return IInterpolator* -- 插值器
267 */
268 STDMETHOD_(IInterpolator *, getInterpolator)(CTHIS) SCONST PURE;
269
270 /**
271 * @brief 获取动画开始时间
272 * @return int64_t -- 开始时间(毫秒)
273 */
274 STDMETHOD_(int64_t, getStartTime)(CTHIS) SCONST PURE;
275
276 /**
277 * @brief 获取动画持续时间
278 * @return long -- 持续时间(毫秒)
279 */
280 STDMETHOD_(long, getDuration)(CTHIS) SCONST PURE;
281
282 /**
283 * @brief 获取动画开始偏移时间
284 * @return long -- 偏移时间(毫秒)
285 */
286 STDMETHOD_(long, getStartOffset)(CTHIS) SCONST PURE;
287
288 /**
289 * @brief 获取动画结束时的行为
290 * @return RepeatMode -- RESTART或REVERSE
291 */
292 STDMETHOD_(RepeatMode, getRepeatMode)(CTHIS) SCONST PURE;
293
294 /**
295 * @brief 获取动画重复次数
296 * @return int -- 重复次数
297 */
298 STDMETHOD_(int, getRepeatCount)(CTHIS) SCONST PURE;
299
300 /**
301 * @brief 获取动画运行时的Z顺序模式
302 * @return ZAdjustment -- ZORDER_NORMAL, ZORDER_TOP, 或 ZORDER_BOTTOM
303 */
304 STDMETHOD_(ZAdjustment, getZAdjustment)(CTHIS) SCONST PURE;
305
306 /**
307 * @brief 绑定动画监听器
308 * @param listener IAnimationListener* -- 动画监听器
309 * @return void
310 */
311 STDMETHOD_(void, setAnimationListener)(THIS_ IAnimationListener * listener) PURE;
312
313 /**
314 * @brief 计算整个动画可能持续的时间(毫秒)
315 * @return long -- 持续时间(毫秒)
316 */
317 STDMETHOD_(long, computeDurationHint)(CTHIS) SCONST PURE;
318
319 /**
320 * @brief 获取指定时间点的变换
321 * @param currentTime uint64_t -- 当前时间(毫秒)
322 * @param outTransformation ITransformation* -- 输出变换对象
323 * @param scale float -- 缩放比例
324 * @return BOOL -- TRUE: 动画仍在运行,FALSE: 动画已结束
325 */
326 STDMETHOD_(BOOL, getTransformation2)
327 (THIS_ uint64_t currentTime, ITransformation * outTransformation, float scale) PURE;
328
329 /**
330 * @brief 获取指定时间点的变换
331 * @param currentTime uint64_t -- 当前时间(毫秒)
332 * @param outTransformation ITransformation* -- 输出变换对象
333 * @return BOOL -- TRUE: 动画仍在运行,FALSE: 动画已结束
334 */
335 STDMETHOD_(BOOL, getTransformation)
336 (THIS_ uint64_t currentTime, ITransformation * outTransformation) PURE;
337
338 /**
339 * @brief 判断动画是否已开始
340 * @return BOOL -- TRUE: 已开始,FALSE: 未开始
341 */
342 STDMETHOD_(BOOL, hasStarted)(CTHIS) SCONST PURE;
343
344 /**
345 * @brief 判断动画是否已结束
346 * @return BOOL -- TRUE: 已结束,FALSE: 未结束
347 */
348 STDMETHOD_(BOOL, hasEnded)(CTHIS) SCONST PURE;
349
350 /**
351 * @brief 应用变换
352 * @param interpolatedTime float -- 插值时间
353 * @param t ITransformation* -- 变换对象
354 * @return void
355 */
356 STDMETHOD_(void, applyTransformation)(THIS_ float interpolatedTime, ITransformation *t) PURE;
357
358 /**
359 * @brief 判断动画是否改变视图的alpha属性
360 * @return BOOL -- TRUE: 改变,FALSE: 不改变
361 */
362 STDMETHOD_(BOOL, hasAlpha)(CTHIS) SCONST PURE;
363
364 /**
365 * @brief 初始化动画
366 * @param width int -- 宽度
367 * @param height int -- 高度
368 * @param parentWidth int -- 父级宽度
369 * @param parentHeight int -- 父级高度
370 * @param nScale int -- 缩放比例
371 * @return void
372 */
373 STDMETHOD_(void, initialize)
374 (THIS_ int width, int height, int parentWidth, int parentHeight, int nScale) PURE;
375
376 /**
377 * @brief 设置用户数据
378 * @param data ULONG_PTR -- 用户数据
379 * @return void
380 */
381 STDMETHOD_(void, setUserData)(THIS_ ULONG_PTR data) PURE;
382
383 /**
384 * @brief 获取用户数据
385 * @return ULONG_PTR -- 用户数据
386 */
387 STDMETHOD_(ULONG_PTR, getUserData)(CTHIS) SCONST PURE;
388
389 /**
390 * @brief 暂停动画
391 * @return void
392 */
393 STDMETHOD_(void, pause)(THIS) PURE;
394
395 /**
396 * @brief 恢复动画
397 * @return void
398 */
399 STDMETHOD_(void, resume)(THIS) PURE;
400};
401
402SNSEND
403#endif // __SANIMATION_I__H__