mgeff-animation.h 22.5 KB
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 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
///////////////////////////////////////////////////////////////////////////////
//
//                          IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
/*!============================================================================
 * \file mgeff-animation.h
 * \brief A motion curve headfile.
 * \author Houhuihua
 * \version 1.0
 * \date 02/03/2010 05:18:25 PM
 *
 \verbatim

    This file is part of mGEff, a component for MiniGUI.

    Copyright (C) 2008~2018, Beijing FMSoft Technologies Co., Ltd.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Or,

    As this program is a library, any link to this program must follow
    GNU General Public License version 3 (GPLv3). If you cannot accept
    GPLv3, you need to be licensed from FMSoft.

    If you have got a commercial license of this program, please use it
    under the terms and conditions of the commercial license.

    For more information about the commercial license, please refer to
    <http://www.minigui.com/blog/minigui-licensing-policy/>.

  	\endverbatim
 */
#ifndef _MGEFF_ANIMATION_H_
#define _MGEFF_ANIMATION_H_

#include <stdint.h>
#include "mgeff-motioncurve.h"

/**
 * \brief The handle to the animation.
 */
MGEFF_DECLARE_HANDLE(MGEFF_ANIMATION);

/**
 * \def MGEFF_INFINITE
 * \brief infinite value, can be used for set loopcount property.
 */
#define MGEFF_INFINITE -1

/**
 * \enum EffAnimProperty
 * \brief animation property
 */
enum EffAnimProperty {
    MGEFF_PROP_DURATION   = 0, /**< r/w duration of animation   */
    MGEFF_PROP_CURLOOP    = 1, /**< r   current loop            */
    MGEFF_PROP_LOOPCOUNT  = 2, /**< r/w loop count of animation */
    MGEFF_PROP_DIRECTION  = 3, /**< r/w direction of animation  */
    MGEFF_PROP_CURFRAME   = 4, /**< r   current frame           */
    MGEFF_PROP_STATE      = 5, /**< r   current state           */
    MGEFF_PROP_KEEPALIVE  = 6, /**< r/w keepalive when finished */
    MGEFF_PROP_MAX
};

/**
 * \enum EffState
 * \brief animation state
 */
enum EffState {
    MGEFF_STATE_STOPPED   = 0, /**< animation is stopped  */
    MGEFF_STATE_PAUSED    = 1, /**< animation is paused   */
    MGEFF_STATE_RUNNING   = 2, /**< animation is running  */
    MGEFF_STATE_READY     = 3, /**< animation is ready    */
    MGEFF_STATE_REMOVE    = 4  /**< animation is remove   */
};

/**
 * \enum EffDirection
 * \brief animation direction
 */
enum EffDirection {
    MGEFF_DIR_FORWARD     = 0, /**< forward  */
    MGEFF_DIR_BACKWARD    = 1  /**< backward */
};

/**
 * \enum EffVariantType
 * \brief animation variant
 */
enum EffVariantType{
    MGEFF_INT             = 0, /**< int       */
    MGEFF_FLOAT           = 1, /**< float     */
    MGEFF_DOUBLE          = 2, /**< double    */
    MGEFF_POINT           = 3, /**< POINT     */
    MGEFF_POINTF          = 4, /**< POINTF    */
    MGEFF_3DPOINT         = 5, /**< 3DPOINT   */
    MGEFF_3DPOINTF        = 6, /**< 3DPOINTF  */
    MGEFF_RECT            = 7, /**< RECT      */
    MGEFF_COLOR           = 8, /**< COLOR     */
    MGEFF_MAX
};

/**
 * \enum EffAnimationType
 * \brief group animation
 */
enum EffAnimationType {
    MGEFF_PARALLEL        = 1, /**< parallel animation   */
    MGEFF_SEQUENTIAL      = 2  /**< sequential animation */
};

/**
 * \typedef void (*MGEFF_FINISHED_CB)(MGEFF_ANIMATION handle)
 * \brief Type of animation finished callback function.
 *
 * The callback is going to be called,when animation is finished.
 *
 * \param handle animation handle
 */
typedef void (*MGEFF_FINISHED_CB)(MGEFF_ANIMATION handle);

/**
 * \typedef void (*MGEFF_STATECHANGED_CB)(MGEFF_ANIMATION handle,
 *          enum EffState newEffState, enum EffState oldEffState)
 * \brief Type of animation state change callback function.
 *
 * The callback is going to be called, when animation state specified by \a handle
 * is changed.
 *
 * \param handle animation handle.
 * \param newEffState new animation state.
 * \param oldEffState old animation state.
 */
typedef void (*MGEFF_STATECHANGED_CB)(MGEFF_ANIMATION handle,
        enum EffState newEffState, enum EffState oldEffState);

/**
 * \typedef void (*MGEFF_CURLOOPCHANGED_CB)(MGEFF_ANIMATION handle)
 * \brief Type of animation current loop changed callback function.
 *
 * The callback is going to be called, when animation's current loop is changed.
 *
 * \param handle animation handle.
 */
typedef void (*MGEFF_CURLOOPCHANGED_CB)(MGEFF_ANIMATION handle);

/**
 * \typedef void (*MGEFF_DIRCHANGED_CB)(MGEFF_ANIMATION handle)
 * \brief Type of animation direction changed callback function.
 *
 * The callback is going to be called, when animation's direction is changed.
 *
 * \param handle animation handle.
 */
typedef void (*MGEFF_DIRCHANGED_CB)(MGEFF_ANIMATION handle);

/**
 * \typedef void (*MGEFF_SETPROPERTY_CB)(MGEFF_ANIMATION handle,
 *                  void *target, intptr_t id, void *value)
 * \brief Type of animation set property function. This fuction is used to produce
 * every animation frame when animation is running
 *
 * The callback is going to be called every frame.
 *
 * \param handle animation handle.
 * \param target animation target.
 * \param id animation id
 * \param value animation current value,startvalue <= value <= endvalue
 */
typedef void (*MGEFF_SETPROPERTY_CB)(MGEFF_ANIMATION handle,
        void *target, intptr_t id, void *value);

/**
 * \typedef void (*MGEFF_CALCVALUE_CB)(MGEFF_ANIMATION handle,
 *                  void *s, void *e, void *v, float factor)
 * \brief Type of animation motion curve callback function.
 *
 * The callback is going to be called every frame, when the animation specified by \a handle
 * is created by mGEffAnimationCreateEx
 *
 * \param handle animation handle
 * \param s value
 * \param e value
 * \param v value
 * \param factor calc factor
 */
typedef void (*MGEFF_CALCVALUE_CB)(MGEFF_ANIMATION handle,
        void *s, void *e, void *v, float factor);

/**
 * \typedef (*MGEFF_VARMALLOC_CB)(MGEFF_ANIMATION handle)
 * \brief Type of animation memory allocating callback function.
 *
 * The callback is going to be called, when the animation is creating.
 * The animation created by mGEffAnimationCreateEx will specify the callback.
 *
 * \param handle animation handle
 *
 * \return address of memory
 */
typedef void *(*MGEFF_VARMALLOC_CB)(MGEFF_ANIMATION handle);

/**
 * \fn MGEFF_ANIMATION mGEffAnimationCreateEx(void *target,
 *             MGEFF_SETPROPERTY_CB setproperty, intptr_t id, int size,
 *             MGEFF_VARMALLOC_CB cb1, MGEFF_CALCVALUE_CB cb2);
 * \brief Create an animation.
 *
 * This funcion creates an animation for the target specified by \a target.
 * The animation's setproperty call back is specified by \a setproperty, \a id
 * is the identifier for the animation, the size of the animation property
 * varible is specified by \a size, memory allocating function used to
 * allocating memory for animation internal use is specified by \a cb1,
 * motion curve for the animation is specified by \a cb2.
 *
 * \param target The target to be animated.
 * \param setproperty The animation set property call back, this function is
 *        used to genareate every frame of the animation.
 * \param id The identifier of the animation, which may be used in SetProperty
 *        callback to distinguish different animation.
 * \param size The size of the animation property variable.
 * \param cb1 The memory allocating callback function.
 * \param cb2 The motion curve value calculating callback function.
 *
 * \return handle to the newly created animation
 *
 * \sa  mGEffAnimationCreate.
 */
MGEFF_EXPORT MGEFF_ANIMATION mGEffAnimationCreateEx(void *target,
        MGEFF_SETPROPERTY_CB setproperty, intptr_t id, int size,
        MGEFF_VARMALLOC_CB cb1, MGEFF_CALCVALUE_CB cb2);

/**
 * \fn MGEFF_ANIMATION mGEffAnimationCreate(void *target,
 *             MGEFF_SETPROPERTY_CB setproperty, intptr_t id,
 *             enum EffVariantType varianttype);
 * \brief Creates an animation.
 *
 * This funcion creates an animation for the target specified by \a target.
 * The animation's setproperty call back is specified by \a setproperty, id is
 * the identifier for the animation,  and the property of the animation is
 * specified by varianttype.
 *
 * \param target The target to be animated.
 * \param setproperty The animation set property call back, this function is
 *      used to genareate every frame of the animation.
 * \param id The identifier of the animation, which may be used in SetProperty
 *      callback to distinguish different animation.
 * \param varianttype The data type of the property variable.
 *
 * \return handle to the newly created animation.
 *
 * \sa  mGEffAnimationCreateEx.
 */
MGEFF_EXPORT MGEFF_ANIMATION mGEffAnimationCreate(void *target,
        MGEFF_SETPROPERTY_CB setproperty, intptr_t id,
        enum EffVariantType varianttype);

/**
 * \fn void  mGEffAnimationDelete(MGEFF_ANIMATION handle)
 * \brief Deletes an animation.
 *
 * This function deletes an animation specified by \a handle.
 *
 * \param handle The animation to be deleted.
 *
 * \sa  mGEffAnimationCreate, mGEffAnimationCreateEx.
 */
MGEFF_EXPORT void mGEffAnimationDelete(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationStop(MGEFF_ANIMATION handle)
 * \brief Stops a running animation.
 *
 * This function stops a running animation specified by \a handle.
 *
 * \param handle The animation to be deleted.
 *
 * \sa  mGEffAnimationAsyncRun, mGEffAnimationSyncRun.
 */
MGEFF_EXPORT void mGEffAnimationStop(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationPause(MGEFF_ANIMATION handle)
 * \brief Pauses a running animation.
 *
 * This function pauses a running animation specified by \a handle.
 *
 * \param handle The animation to be paused.
 *
 * \sa  mGEffAnimationResume.
 */
MGEFF_EXPORT void mGEffAnimationPause(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationResume(MGEFF_ANIMATION handle)
 * \brief Resumes a paused animation.
 *
 * This function resumes a paused animation specified by \a handle.
 *
 * \param handle The animation to be resumed.
 *
 * \sa  mGEffAnimationPause.
 */
MGEFF_EXPORT void mGEffAnimationResume(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationSetProperty(MGEFF_ANIMATION handle,
 *             enum EffAnimProperty id, int value)
 * \brief Sets property of an animation.
 *
 * This function sets the property specified by \a id to new value
 * specified \a value.
 *
 * \param handle The handle of the animation.
 * \param id The identifier of the property.
 * \param value The new value to be set.
 *
 * \sa  mGEffAnimationGetProperty.
 */
MGEFF_EXPORT void mGEffAnimationSetProperty(MGEFF_ANIMATION handle,
        enum EffAnimProperty id, int value);

/**
 * \fn int mGEffAnimationGetProperty(MGEFF_ANIMATION handle,
 *             enum EffAnimProperty id);
 * \brief Gets property of an animation.
 *
 * This function gets the animation property specified by \a id.
 *
 * \param handle The handle of the animation.
 * \param id The identifier of the property.
 *
 * \return value The property value.
 *
 * \sa  mGEffAnimationSetProperty.
 */
MGEFF_EXPORT int mGEffAnimationGetProperty(MGEFF_ANIMATION handle,
        enum EffAnimProperty id);

/**
 * \fn void mGEffAnimationSetDuration(MGEFF_ANIMATION handle,
 *             int duration_ms).
 * \brief Sets the animation's duration.
 *
 * This function sets the animation's duration to new value specified
 * by \a duration_ms, the unit is millisecond.
 *
 * \param handle The handle of the animation.
 * \param duration_ms The new duration.
 *
 * \sa  mGEffAnimationGetDuration.
 */
static inline void mGEffAnimationSetDuration(MGEFF_ANIMATION handle,
        int duration_ms)
{
    mGEffAnimationSetProperty(handle, MGEFF_PROP_DURATION, duration_ms);
}

/**
 * \fn int mGEffAnimationGetDuration(MGEFF_ANIMATION handle).
 * \brief Gets the animation's duration.
 *
 * This function gets the animation's duration. Tthe unit is millisecond.
 *
 * \param handle The handle of the animation.
 *
 * \return The duration in millisecond.
 *
 * \sa  mGEffAnimationSetDuration.
 */
static inline int mGEffAnimationGetDuration(MGEFF_ANIMATION handle)
{
    return mGEffAnimationGetProperty(handle, MGEFF_PROP_DURATION);
}

/**
 * \fn void mGEffAnimationSetStartValue(MGEFF_ANIMATION handle,
 *             const void *value)
 * \brief set the animation start value.
 *
 * This function set the start value of the animation specified by \a
 * handle to \a value.
 *
 * \param  handle the handle of the animation.
 * \param  value the start value to be set.
 *
 * \sa  mGEffAnimationGetStartValue, mGEffAnimationSetEndValue.
 */
MGEFF_EXPORT void mGEffAnimationSetStartValue(MGEFF_ANIMATION handle,
        const void *value);

/**
 * \fn const void *mGEffAnimationGetStartValue(MGEFF_ANIMATION handle)
 * \brief Get the animation start value.
 *
 * This function get the start value of the animation specified by \a handle
 *
 * \param  handle the handle of the animation.
 *
 * \return start value of the animation specified by \a handle
 *
 * \sa  mGEffAnimationSetStartValue.
 */
MGEFF_EXPORT const void *mGEffAnimationGetStartValue(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationSetEndValue(MGEFF_ANIMATION handle,
 *             const void *value)
 * \brief set the animation end value.
 *
 * This function set the end value of the animation specified by \a handle
 * to \a value.
 *
 * \param  handle the handle of the animation.
 * \param  value the end value.
 *
 * \sa  mGEffAnimationGetEndValue, mGEffAnimationSetStartValue.
 */

MGEFF_EXPORT void mGEffAnimationSetEndValue(MGEFF_ANIMATION handle,
        const void *value);

/**
 * \fn const void *mGEffAnimationGetEndValue(MGEFF_ANIMATION handle)
 * \brief Get the animation end value.
 *
 * This function get the end value of the animation specified by \a handle.
 *
 * \param  handle The handle of the animation.
 *
 * \return The end value of the animation specified by \a handle.
 *
 * \sa  mGEffAnimationSetEndValue.
 */
MGEFF_EXPORT const void *mGEffAnimationGetEndValue(MGEFF_ANIMATION handle);


/**
 * \fn void mGEffAnimationSetFinishedCb(MGEFF_ANIMATION handle,
 *             MGEFF_FINISHED_CB cb)
 * \brief Sets the animation Finished callback function.
 *
 * This function sets the Finished callback of the animation specified by \a
 * handle to \a cb.
 *
 * \param handle The handle of the animation.
 * \param cb The Finished callback to be set.
 *
 * \sa  mGEffAnimationSetStateChangedCb, mGEffAnimationSetDirChangedCb.
 */
MGEFF_EXPORT void mGEffAnimationSetFinishedCb(MGEFF_ANIMATION handle,
        MGEFF_FINISHED_CB cb);

/**
 * \fn void mGEffAnimationSetStateChangedCb(MGEFF_ANIMATION handle,
 *             MGEFF_STATECHANGED_CB cb);
 * \brief Sets the animation StateChanged callback function.
 *
 * This function sets the StateChanged callback of the animation specified by \a
 * handle to \a cb.
 *
 * \param handle The handle of the animation.
 * \param cb The StateChanged callback to be set.
 *
 * \sa  mGEffAnimationSetDirChangedCb, mGEffAnimationSetFinishedCb.
 */
MGEFF_EXPORT void  mGEffAnimationSetStateChangedCb(MGEFF_ANIMATION handle,
        MGEFF_STATECHANGED_CB cb);

/**
 * \fn void mGEffAnimationSetCurLoopChangedCb(MGEFF_ANIMATION handle,
 *             MGEFF_CURLOOPCHANGED_CB cb);
 * \brief Sets the animation CurLoopChanged callback function.
 *
 * This function sets the CurLoopChanged callback of the animation specified by \a
 * handle to \a cb.
 *
 * \param handle The handle of the animation.
 * \param cb The CurLoopChanged callback to be set.
 *
 * \sa  mGEffAnimationSetDirChangedCb, mGEffAnimationSetFinishedCb.
 */
MGEFF_EXPORT void mGEffAnimationSetCurLoopChangedCb(MGEFF_ANIMATION handle,
        MGEFF_CURLOOPCHANGED_CB cb);

/**
 * \fn void mGEffAnimationSetDirChangedCb(MGEFF_ANIMATION handle,
 *             MGEFF_DIRCHANGED_CB cb);
 * \brief Sets the animation DirChanged callback function.
 *
 * This function sets the DirChanged callback of the animation specified by \a
 * handle to \a cb.
 *
 * \param handle The handle of the animation.
 * \param cb The DirChanged callback to be set.
 *
 * \sa  mGEffAnimationSetCurLoopChangedCb, mGEffAnimationSetFinishedCb.
 */
MGEFF_EXPORT void  mGEffAnimationSetDirChangedCb(MGEFF_ANIMATION handle,
        MGEFF_DIRCHANGED_CB cb);

/**
 * \fn void mGEffAnimationSetContext(MGEFF_ANIMATION handle,
 *             void *context)
 * \brief Sets the animation context.
 *
 * This function sets the context of the animation specified by \a handle to
 * \a context.
 *
 * \param handle The hanle of the animation.
 * \param  context The context to be set.
 *
 * \sa  mGEffAnimationGetContext.
 */
MGEFF_EXPORT void mGEffAnimationSetContext(MGEFF_ANIMATION handle,
        void *context);

/**
 * \fn void *mGEffAnimationGetContext(MGEFF_ANIMATION handle)
 * \brief Gets the animation context.
 *
 * This function gets the context of the animation specified by \a handle.
 *
 * \param handle The hanle of the animation.
 *
 * \return  The context of the animation.
 *
 * \sa  mGEffAnimationSetContext.
 */
MGEFF_EXPORT void *mGEffAnimationGetContext(MGEFF_ANIMATION handle);

/**
 * \fn void mGEffAnimationSetCurve(MGEFF_ANIMATION handle,
 *             enum EffMotionType type)
 * \brief Sets the motion cureve of the animation.
 *
 * This function sets the motion curve of the animation specified by \a handle
 * to the curve specified by \a type.
 *
 * \param handle The hanle of the animation.
 * \param type the type of the motion curve to be set.
 *
 * \note there are some predefined motion curves in mGEff and each one has a
 * unique type.
 *
 * \sa  mGEffAnimationSetCurveEx.
 */
MGEFF_EXPORT void mGEffAnimationSetCurve(MGEFF_ANIMATION handle,
        enum EffMotionType type);

/**
 * \fn void mGEffAnimationSetCurveEx(MGEFF_ANIMATION handle,
 *             MGEFF_MOTIONCURVE_CB cb)
 * \brief Sets the motion cureve of the animation.
 *
 * This function sets the motion curve of the animation specified by \a handle
 * to the curve specified by \a cb.
 *
 * \param handle The hanle of the animation.
 * \param cb the function of the curve be set.
 *
 * \note use this to set your own motion curve.
 *
 * \sa  mGEffAnimationSetCurve.
 */
MGEFF_EXPORT void  mGEffAnimationSetCurveEx(MGEFF_ANIMATION handle,
        MGEFF_MOTIONCURVE_CB cb);

/**
 * \fn MGEFF_MOTIONCURVE mGEffAnimationGetCurve(MGEFF_ANIMATION handle)
 * \brief Gets the motion cureve of the animation.
 *
 * This function gets the motion curve of the animation specified by \a handle.
 *
 * \param handle The hanle of the animation.
 *
 * \return the handle of the motion curve of the animation.
 *
 * \sa  mGEffAnimationSetCurveEx, mGEffAnimationSetCurve.
 */
MGEFF_EXPORT MGEFF_MOTIONCURVE mGEffAnimationGetCurve(MGEFF_ANIMATION handle);

/**
 * \fn void *mGEffAnimationGetTarget(MGEFF_ANIMATION handle)
 * \brief Gets the target of the animation.
 *
 * This function gets the target of the animation specified by \a handle.
 *
 * \param handle The handle of the animation.
 *
 * \return the target of the animation specified by \a handle.
 *
 * \sa  mGEffAnimationCreate, mGEffAnimationCreateEx.
 */
MGEFF_EXPORT void *mGEffAnimationGetTarget(MGEFF_ANIMATION handle);

/**
 * \fn int mGEffAnimationAsyncRun(MGEFF_ANIMATION handle)
 * \brief Run the animation in the default schedular asynchronous.
 *
 * This function attachs the animation to the default schedular and start the animation.
 * The animation run immediately if schedular is already started, otherwise it will
 * wait until the schedular started.
 *
 * \param handle The handle of the animation to be attached.
 *
 * \return If succeed, return 0; otherwise return -1.
 *
 * \sa  mGEffAnimationSyncRun, mGEffAnimationSetPreporty.
 */
MGEFF_EXPORT int  mGEffAnimationAsyncRun(MGEFF_ANIMATION handle);

/**
 * \fn int mGEffAnimationSyncRun(MGEFF_ANIMATION handle)
 * \brief Run the animation in the default schedular synchronous.
 *
 * This function attachs the animation to the default schedular and start the animation.
 * The animation run immediately and return until the animation finished.
 *
 * \param handle The handle of the animation to be attached.
 *
 * \return If succeed, return 0; otherwise return -1.
 *
 * \sa  mGEffAnimationAsyncRun, mGEffAnimationSetPreporty.
 */
MGEFF_EXPORT int  mGEffAnimationSyncRun(MGEFF_ANIMATION handle);

/**
 * structure defines a all parameters to create a group animation ready to run.
 */
typedef struct _PropertyAnimationSetting {
    void                  *property;       /**< property              */
    enum EffVariantType    type;           /**< variant type          */
    const void            *start_value;    /**< start value           */
    const void            *end_value;      /**< end value             */
    enum EffMotionType     curve;          /**< motion type           */
    int                    duration;       /**< duration of animation */
    MGEFF_FINISHED_CB      cb;             /**< finished callback     */
} EffPropertyAnimationSetting;

/**
 * \fn MGEFF_ANIMATION mGEffCreatePropertyAnimation(const
 *             EffPropertyAnimationSetting *settings)
 * \brief Create an animation group ready to run.
 *
 * This function creates an animation group ready to run using the input param \a settings.
 *
 * \param settings parameters for create and setup an group animation, it contains one or 
 * more animation property.
 *
 * \return the handle of the created animation group.
 *
 * \sa  mGEffAnimationCreate, mGEffAnimationCreate, mGEffAnimationSetProperty.
 */
MGEFF_EXPORT MGEFF_ANIMATION mGEffCreatePropertyAnimation(const EffPropertyAnimationSetting *settings);

/**
 * \fn MGEFF_BOOL mGEffAnimationWait(void *hWnd, MGEFF_ANIMATION handle)
 * \brief Wait an animation.
 *
 * This function wait an animation specified by \a handle, it will
 * return util the special animation run over, it can receive other
 * message between the wait time.
 *
 * \param hWnd   the window handle of that animation's timer relative.
 * \param handle the handle of the animation to be wait.
 *
 * \sa  mGEffAnimationAsyncRun.
 */
MGEFF_EXPORT MGEFF_BOOL mGEffAnimationWait(void *hWnd, MGEFF_ANIMATION handle);

#endif