mGEff API Reference  v1.2.0
An animation framework for MiniGUI apps
Data Structures | Macros | Typedefs | Enumerations | Functions
mgeff-animation.h File Reference

A motion curve headfile. More...

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

Go to the source code of this file.

Data Structures

struct  _PropertyAnimationSetting
 

Macros

#define MGEFF_INFINITE   -1
 infinite value, can be used for set loopcount property.
 

Typedefs

typedef void(* MGEFF_FINISHED_CB) (MGEFF_ANIMATION handle)
 Type of animation finished callback function. More...
 
typedef void(* MGEFF_STATECHANGED_CB) (MGEFF_ANIMATION handle, enum EffState newEffState, enum EffState oldEffState)
 Type of animation state change callback function. More...
 
typedef void(* MGEFF_CURLOOPCHANGED_CB) (MGEFF_ANIMATION handle)
 Type of animation current loop changed callback function. More...
 
typedef void(* MGEFF_DIRCHANGED_CB) (MGEFF_ANIMATION handle)
 Type of animation direction changed callback function. More...
 
typedef void(* MGEFF_SETPROPERTY_CB) (MGEFF_ANIMATION handle, void *target, intptr_t id, void *value)
 Type of animation set property function. This fuction is used to produce every animation frame when animation is running. More...
 
typedef void(* MGEFF_CALCVALUE_CB) (MGEFF_ANIMATION handle, void *s, void *e, void *v, float factor)
 Type of animation motion curve callback function. More...
 
typedef void *(* MGEFF_VARMALLOC_CB) (MGEFF_ANIMATION handle)
 Type of animation memory allocating callback function. More...
 
typedef struct _PropertyAnimationSetting EffPropertyAnimationSetting
 

Enumerations

enum  EffAnimProperty {
  MGEFF_PROP_DURATION = 0, MGEFF_PROP_CURLOOP = 1, MGEFF_PROP_LOOPCOUNT = 2, MGEFF_PROP_DIRECTION = 3,
  MGEFF_PROP_CURFRAME = 4, MGEFF_PROP_STATE = 5, MGEFF_PROP_KEEPALIVE = 6, MGEFF_PROP_MAX
}
 animation property More...
 
enum  EffState {
  MGEFF_STATE_STOPPED = 0, MGEFF_STATE_PAUSED = 1, MGEFF_STATE_RUNNING = 2, MGEFF_STATE_READY = 3,
  MGEFF_STATE_REMOVE = 4
}
 animation state More...
 
enum  EffDirection { MGEFF_DIR_FORWARD = 0, MGEFF_DIR_BACKWARD = 1 }
 animation direction More...
 
enum  EffVariantType {
  MGEFF_INT = 0, MGEFF_FLOAT = 1, MGEFF_DOUBLE = 2, MGEFF_POINT = 3,
  MGEFF_POINTF = 4, MGEFF_3DPOINT = 5, MGEFF_3DPOINTF = 6, MGEFF_RECT = 7,
  MGEFF_COLOR = 8, MGEFF_MAX
}
 animation variant More...
 
enum  EffAnimationType { MGEFF_PARALLEL = 1, MGEFF_SEQUENTIAL = 2 }
 group animation More...
 

Functions

 MGEFF_DECLARE_HANDLE (MGEFF_ANIMATION)
 The handle to the animation.
 
MGEFF_EXPORT MGEFF_ANIMATION mGEffAnimationCreateEx (void *target, MGEFF_SETPROPERTY_CB setproperty, intptr_t id, int size, MGEFF_VARMALLOC_CB cb1, MGEFF_CALCVALUE_CB cb2)
 Create an animation. More...
 
MGEFF_EXPORT MGEFF_ANIMATION mGEffAnimationCreate (void *target, MGEFF_SETPROPERTY_CB setproperty, intptr_t id, enum EffVariantType varianttype)
 Creates an animation. More...
 
MGEFF_EXPORT void mGEffAnimationDelete (MGEFF_ANIMATION handle)
 Deletes an animation. More...
 
MGEFF_EXPORT void mGEffAnimationStop (MGEFF_ANIMATION handle)
 Stops a running animation. More...
 
MGEFF_EXPORT void mGEffAnimationPause (MGEFF_ANIMATION handle)
 Pauses a running animation. More...
 
MGEFF_EXPORT void mGEffAnimationResume (MGEFF_ANIMATION handle)
 Resumes a paused animation. More...
 
MGEFF_EXPORT void mGEffAnimationSetProperty (MGEFF_ANIMATION handle, enum EffAnimProperty id, int value)
 Sets property of an animation. More...
 
MGEFF_EXPORT int mGEffAnimationGetProperty (MGEFF_ANIMATION handle, enum EffAnimProperty id)
 Gets property of an animation. More...
 
MGEFF_EXPORT void mGEffAnimationSetStartValue (MGEFF_ANIMATION handle, const void *value)
 set the animation start value. More...
 
MGEFF_EXPORT const void * mGEffAnimationGetStartValue (MGEFF_ANIMATION handle)
 Get the animation start value. More...
 
MGEFF_EXPORT void mGEffAnimationSetEndValue (MGEFF_ANIMATION handle, const void *value)
 set the animation end value. More...
 
MGEFF_EXPORT const void * mGEffAnimationGetEndValue (MGEFF_ANIMATION handle)
 Get the animation end value. More...
 
MGEFF_EXPORT void mGEffAnimationSetFinishedCb (MGEFF_ANIMATION handle, MGEFF_FINISHED_CB cb)
 Sets the animation Finished callback function. More...
 
MGEFF_EXPORT void mGEffAnimationSetStateChangedCb (MGEFF_ANIMATION handle, MGEFF_STATECHANGED_CB cb)
 Sets the animation StateChanged callback function. More...
 
MGEFF_EXPORT void mGEffAnimationSetCurLoopChangedCb (MGEFF_ANIMATION handle, MGEFF_CURLOOPCHANGED_CB cb)
 Sets the animation CurLoopChanged callback function. More...
 
MGEFF_EXPORT void mGEffAnimationSetDirChangedCb (MGEFF_ANIMATION handle, MGEFF_DIRCHANGED_CB cb)
 Sets the animation DirChanged callback function. More...
 
MGEFF_EXPORT void mGEffAnimationSetContext (MGEFF_ANIMATION handle, void *context)
 Sets the animation context. More...
 
MGEFF_EXPORT void * mGEffAnimationGetContext (MGEFF_ANIMATION handle)
 Gets the animation context. More...
 
MGEFF_EXPORT void mGEffAnimationSetCurve (MGEFF_ANIMATION handle, enum EffMotionType type)
 Sets the motion cureve of the animation. More...
 
MGEFF_EXPORT void mGEffAnimationSetCurveEx (MGEFF_ANIMATION handle, MGEFF_MOTIONCURVE_CB cb)
 Sets the motion cureve of the animation. More...
 
MGEFF_EXPORT MGEFF_MOTIONCURVE mGEffAnimationGetCurve (MGEFF_ANIMATION handle)
 Gets the motion cureve of the animation. More...
 
MGEFF_EXPORT void * mGEffAnimationGetTarget (MGEFF_ANIMATION handle)
 Gets the target of the animation. More...
 
MGEFF_EXPORT int mGEffAnimationAsyncRun (MGEFF_ANIMATION handle)
 Run the animation in the default schedular asynchronous. More...
 
MGEFF_EXPORT int mGEffAnimationSyncRun (MGEFF_ANIMATION handle)
 Run the animation in the default schedular synchronous. More...
 
MGEFF_EXPORT MGEFF_ANIMATION mGEffCreatePropertyAnimation (const EffPropertyAnimationSetting *settings)
 Create an animation group ready to run. More...
 
MGEFF_EXPORT MGEFF_BOOL mGEffAnimationWait (void *hWnd, MGEFF_ANIMATION handle)
 Wait an animation. More...
 

Detailed Description

A motion curve headfile.

============================================================================

Author
Houhuihua
Version
1.0
Date
02/03/2010 05:18:25 PM
   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/en/about/licensing-policy/>.

Typedef Documentation

structure defines a all parameters to create a group animation ready to run.

void(* MGEFF_CALCVALUE_CB)(MGEFF_ANIMATION handle, void *s, void *e, void *v, float factor)

Type of animation motion curve callback function.

The callback is going to be called every frame, when the animation specified by handle is created by mGEffAnimationCreateEx

Parameters
handleanimation handle
svalue
evalue
vvalue
factorcalc factor
void(* MGEFF_CURLOOPCHANGED_CB)(MGEFF_ANIMATION handle)

Type of animation current loop changed callback function.

The callback is going to be called, when animation's current loop is changed.

Parameters
handleanimation handle.
void(* MGEFF_DIRCHANGED_CB)(MGEFF_ANIMATION handle)

Type of animation direction changed callback function.

The callback is going to be called, when animation's direction is changed.

Parameters
handleanimation handle.
void(* MGEFF_FINISHED_CB)(MGEFF_ANIMATION handle)

Type of animation finished callback function.

The callback is going to be called,when animation is finished.

Parameters
handleanimation handle
void(* MGEFF_SETPROPERTY_CB)(MGEFF_ANIMATION handle, void *target, intptr_t id, void *value)

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.

Parameters
handleanimation handle.
targetanimation target.
idanimation id
valueanimation current value,startvalue <= value <= endvalue
void(* MGEFF_STATECHANGED_CB)(MGEFF_ANIMATION handle, enum EffState newEffState, enum EffState oldEffState)

Type of animation state change callback function.

The callback is going to be called, when animation state specified by handle is changed.

Parameters
handleanimation handle.
newEffStatenew animation state.
oldEffStateold animation state.
(* MGEFF_VARMALLOC_CB)(MGEFF_ANIMATION handle)

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.

Parameters
handleanimation handle
Returns
address of memory

Enumeration Type Documentation

group animation

Enumerator
MGEFF_PARALLEL 

parallel animation

MGEFF_SEQUENTIAL 

sequential animation

animation property

Enumerator
MGEFF_PROP_DURATION 

r/w duration of animation

MGEFF_PROP_CURLOOP 

r current loop

MGEFF_PROP_LOOPCOUNT 

r/w loop count of animation

MGEFF_PROP_DIRECTION 

r/w direction of animation

MGEFF_PROP_CURFRAME 

r current frame

MGEFF_PROP_STATE 

r current state

MGEFF_PROP_KEEPALIVE 

r/w keepalive when finished

animation direction

Enumerator
MGEFF_DIR_FORWARD 

forward

MGEFF_DIR_BACKWARD 

backward

enum EffState

animation state

Enumerator
MGEFF_STATE_STOPPED 

animation is stopped

MGEFF_STATE_PAUSED 

animation is paused

MGEFF_STATE_RUNNING 

animation is running

MGEFF_STATE_READY 

animation is ready

MGEFF_STATE_REMOVE 

animation is remove

animation variant

Enumerator
MGEFF_INT 

int

MGEFF_FLOAT 

float

MGEFF_DOUBLE 

double

MGEFF_POINT 

POINT

MGEFF_POINTF 

POINTF

MGEFF_3DPOINT 

3DPOINT

MGEFF_3DPOINTF 

3DPOINTF

MGEFF_RECT 

RECT

MGEFF_COLOR 

COLOR

Function Documentation

int mGEffAnimationAsyncRun ( MGEFF_ANIMATION  handle)

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.

Parameters
handleThe handle of the animation to be attached.
Returns
If succeed, return 0; otherwise return -1.
See also
mGEffAnimationSyncRun, mGEffAnimationSetPreporty.
MGEFF_ANIMATION mGEffAnimationCreate ( void *  target,
MGEFF_SETPROPERTY_CB  setproperty,
intptr_t  id,
enum EffVariantType  varianttype 
)

Creates an animation.

This funcion creates an animation for the target specified by target. The animation's setproperty call back is specified by setproperty, id is the identifier for the animation, and the property of the animation is specified by varianttype.

Parameters
targetThe target to be animated.
setpropertyThe animation set property call back, this function is used to genareate every frame of the animation.
idThe identifier of the animation, which may be used in SetProperty callback to distinguish different animation.
varianttypeThe data type of the property variable.
Returns
handle to the newly created animation.
See also
mGEffAnimationCreateEx.
MGEFF_ANIMATION mGEffAnimationCreateEx ( void *  target,
MGEFF_SETPROPERTY_CB  setproperty,
intptr_t  id,
int  size,
MGEFF_VARMALLOC_CB  cb1,
MGEFF_CALCVALUE_CB  cb2 
)

Create an animation.

This funcion creates an animation for the target specified by target. The animation's setproperty call back is specified by setproperty, id is the identifier for the animation, the size of the animation property varible is specified by size, memory allocating function used to allocating memory for animation internal use is specified by cb1, motion curve for the animation is specified by cb2.

Parameters
targetThe target to be animated.
setpropertyThe animation set property call back, this function is used to genareate every frame of the animation.
idThe identifier of the animation, which may be used in SetProperty callback to distinguish different animation.
sizeThe size of the animation property variable.
cb1The memory allocating callback function.
cb2The motion curve value calculating callback function.
Returns
handle to the newly created animation
See also
mGEffAnimationCreate.
void mGEffAnimationDelete ( MGEFF_ANIMATION  handle)

Deletes an animation.

This function deletes an animation specified by handle.

Parameters
handleThe animation to be deleted.
See also
mGEffAnimationCreate, mGEffAnimationCreateEx.
void * mGEffAnimationGetContext ( MGEFF_ANIMATION  handle)

Gets the animation context.

This function gets the context of the animation specified by handle.

Parameters
handleThe hanle of the animation.
Returns
The context of the animation.
See also
mGEffAnimationSetContext.
MGEFF_MOTIONCURVE mGEffAnimationGetCurve ( MGEFF_ANIMATION  handle)

Gets the motion cureve of the animation.

This function gets the motion curve of the animation specified by handle.

Parameters
handleThe hanle of the animation.
Returns
the handle of the motion curve of the animation.
See also
mGEffAnimationSetCurveEx, mGEffAnimationSetCurve.
const void * mGEffAnimationGetEndValue ( MGEFF_ANIMATION  handle)

Get the animation end value.

This function get the end value of the animation specified by handle.

Parameters
handleThe handle of the animation.
Returns
The end value of the animation specified by handle.
See also
mGEffAnimationSetEndValue.
int mGEffAnimationGetProperty ( MGEFF_ANIMATION  handle,
enum EffAnimProperty  id 
)

Gets property of an animation.

This function gets the animation property specified by id.

Parameters
handleThe handle of the animation.
idThe identifier of the property.
Returns
value The property value.
See also
mGEffAnimationSetProperty.
const void * mGEffAnimationGetStartValue ( MGEFF_ANIMATION  handle)

Get the animation start value.

This function get the start value of the animation specified by handle

Parameters
handlethe handle of the animation.
Returns
start value of the animation specified by handle
See also
mGEffAnimationSetStartValue.
void * mGEffAnimationGetTarget ( MGEFF_ANIMATION  handle)

Gets the target of the animation.

This function gets the target of the animation specified by handle.

Parameters
handleThe handle of the animation.
Returns
the target of the animation specified by handle.
See also
mGEffAnimationCreate, mGEffAnimationCreateEx.
void mGEffAnimationPause ( MGEFF_ANIMATION  handle)

Pauses a running animation.

This function pauses a running animation specified by handle.

Parameters
handleThe animation to be paused.
See also
mGEffAnimationResume.
void mGEffAnimationResume ( MGEFF_ANIMATION  handle)

Resumes a paused animation.

This function resumes a paused animation specified by handle.

Parameters
handleThe animation to be resumed.
See also
mGEffAnimationPause.
void mGEffAnimationSetContext ( MGEFF_ANIMATION  handle,
void *  context 
)

Sets the animation context.

This function sets the context of the animation specified by handle to context.

Parameters
handleThe hanle of the animation.
contextThe context to be set.
See also
mGEffAnimationGetContext.
void mGEffAnimationSetCurLoopChangedCb ( MGEFF_ANIMATION  handle,
MGEFF_CURLOOPCHANGED_CB  cb 
)

Sets the animation CurLoopChanged callback function.

This function sets the CurLoopChanged callback of the animation specified by handle to cb.

Parameters
handleThe handle of the animation.
cbThe CurLoopChanged callback to be set.
See also
mGEffAnimationSetDirChangedCb, mGEffAnimationSetFinishedCb.
void mGEffAnimationSetCurve ( MGEFF_ANIMATION  handle,
enum EffMotionType  type 
)

Sets the motion cureve of the animation.

This function sets the motion curve of the animation specified by handle to the curve specified by type.

Parameters
handleThe hanle of the animation.
typethe type of the motion curve to be set.
Note
there are some predefined motion curves in mGEff and each one has a unique type.
See also
mGEffAnimationSetCurveEx.
void mGEffAnimationSetCurveEx ( MGEFF_ANIMATION  handle,
MGEFF_MOTIONCURVE_CB  cb 
)

Sets the motion cureve of the animation.

This function sets the motion curve of the animation specified by handle to the curve specified by cb.

Parameters
handleThe hanle of the animation.
cbthe function of the curve be set.
Note
use this to set your own motion curve.
See also
mGEffAnimationSetCurve.
void mGEffAnimationSetDirChangedCb ( MGEFF_ANIMATION  handle,
MGEFF_DIRCHANGED_CB  cb 
)

Sets the animation DirChanged callback function.

This function sets the DirChanged callback of the animation specified by handle to cb.

Parameters
handleThe handle of the animation.
cbThe DirChanged callback to be set.
See also
mGEffAnimationSetCurLoopChangedCb, mGEffAnimationSetFinishedCb.
void mGEffAnimationSetEndValue ( MGEFF_ANIMATION  handle,
const void *  value 
)

set the animation end value.

This function set the end value of the animation specified by handle to value.

Parameters
handlethe handle of the animation.
valuethe end value.
See also
mGEffAnimationGetEndValue, mGEffAnimationSetStartValue.
void mGEffAnimationSetFinishedCb ( MGEFF_ANIMATION  handle,
MGEFF_FINISHED_CB  cb 
)

Sets the animation Finished callback function.

This function sets the Finished callback of the animation specified by handle to cb.

Parameters
handleThe handle of the animation.
cbThe Finished callback to be set.
See also
mGEffAnimationSetStateChangedCb, mGEffAnimationSetDirChangedCb.
void mGEffAnimationSetProperty ( MGEFF_ANIMATION  handle,
enum EffAnimProperty  id,
int  value 
)

Sets property of an animation.

This function sets the property specified by id to new value specified value.

Parameters
handleThe handle of the animation.
idThe identifier of the property.
valueThe new value to be set.
See also
mGEffAnimationGetProperty.
void mGEffAnimationSetStartValue ( MGEFF_ANIMATION  handle,
const void *  value 
)

set the animation start value.

This function set the start value of the animation specified by handle to value.

Parameters
handlethe handle of the animation.
valuethe start value to be set.
See also
mGEffAnimationGetStartValue, mGEffAnimationSetEndValue.
void mGEffAnimationSetStateChangedCb ( MGEFF_ANIMATION  handle,
MGEFF_STATECHANGED_CB  cb 
)

Sets the animation StateChanged callback function.

This function sets the StateChanged callback of the animation specified by handle to cb.

Parameters
handleThe handle of the animation.
cbThe StateChanged callback to be set.
See also
mGEffAnimationSetDirChangedCb, mGEffAnimationSetFinishedCb.
void mGEffAnimationStop ( MGEFF_ANIMATION  handle)

Stops a running animation.

This function stops a running animation specified by handle.

Parameters
handleThe animation to be deleted.
See also
mGEffAnimationAsyncRun, mGEffAnimationSyncRun.
int mGEffAnimationSyncRun ( MGEFF_ANIMATION  handle)

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.

Parameters
handleThe handle of the animation to be attached.
Returns
If succeed, return 0; otherwise return -1.
See also
mGEffAnimationAsyncRun, mGEffAnimationSetPreporty.
MGEFF_BOOL mGEffAnimationWait ( void *  hWnd,
MGEFF_ANIMATION  handle 
)

Wait an animation.

This function wait an animation specified by handle, it will return util the special animation run over, it can receive other message between the wait time.

Parameters
hWndthe window handle of that animation's timer relative.
handlethe handle of the animation to be wait.
See also
mGEffAnimationAsyncRun.
MGEFF_ANIMATION mGEffCreatePropertyAnimation ( const EffPropertyAnimationSetting settings)

Create an animation group ready to run.

This function creates an animation group ready to run using the input param settings.

Parameters
settingsparameters for create and setup an group animation, it contains one or more animation property.
Returns
the handle of the created animation group.
See also
mGEffAnimationCreate, mGEffAnimationCreate, mGEffAnimationSetProperty.