Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: E.h mod-misc.c timers.c timers.h Log Message: Add animators. =================================================================== RCS file: /cvs/e/e16/e/src/E.h,v retrieving revision 1.575 retrieving revision 1.576 diff -u -3 -r1.575 -r1.576 --- E.h 17 Jan 2007 01:10:41 -0000 1.575 +++ E.h 28 Jan 2007 04:59:45 -0000 1.576 @@ -247,6 +247,10 @@ { struct { + unsigned int step; /* Animation time step, ms */ + } animation; + struct + { char enable; int delay; /* milliseconds */ } autoraise; =================================================================== RCS file: /cvs/e/e16/e/src/mod-misc.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- mod-misc.c 13 Jan 2007 19:14:28 -0000 1.50 +++ mod-misc.c 28 Jan 2007 04:59:45 -0000 1.51 @@ -108,6 +108,8 @@ static const CfgItem MiscCfgItems[] = { + CFG_ITEM_INT(Conf, animation.step, 10), + CFG_ITEM_INT(Conf, buttons.move_resistance, 10), CFG_ITEM_BOOL(Conf, dialogs.headers, 0), =================================================================== RCS file: /cvs/e/e16/e/src/timers.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- timers.c 17 Jan 2007 01:10:43 -0000 1.26 +++ timers.c 28 Jan 2007 04:59:46 -0000 1.27 @@ -166,6 +166,9 @@ return 0; } +/* + * Idlers + */ static Ecore_List *idler_list = NULL; typedef void (IdlerFunc) (void *data); @@ -211,4 +214,98 @@ Idler *id; ECORE_LIST_FOR_EACH(idler_list, id) id->func(id->data); +} + +/* + * Animators + */ +#define DEBUG_ANIMATORS 0 +static Ecore_List *animator_list = NULL; + +typedef int (AnimatorFunc) (void *data); + +struct _animator +{ + char *name; + AnimatorFunc *func; + void *data; +}; + +static void +AnimatorsRun(int val __UNUSED__, void *data __UNUSED__) +{ + Animator *an; + int again; + + ECORE_LIST_FOR_EACH(animator_list, an) + { +#if DEBUG_ANIMATORS > 1 + Eprintf("AnimatorRun %p\n", an); +#endif + again = an->func(an->data); + if (!again) + AnimatorDel(an); + } + + if (ecore_list_nodes(animator_list)) + DoIn("Anim", 1e-3 * Conf.animation.step, AnimatorsRun, 0, NULL); +} + +Animator * +AnimatorAdd(AnimatorFunc * func, void *data) +{ + Animator *an; + + an = Emalloc(sizeof(Animator)); + if (!an) + return NULL; + +#if DEBUG_ANIMATORS + Eprintf("AnimatorAdd %p func=%p data=%p\n", an, func, data); +#endif + an->name = NULL; + an->func = func; + an->data = data; + + if (!animator_list) + animator_list = ecore_list_new(); + + ecore_list_append(animator_list, an); + + if (ecore_list_nodes(animator_list) == 1) + { + if (Conf.animation.step <= 0) + Conf.animation.step = 1; + /* Animator list was empty - Add to timer qeueue */ + DoIn("Anim", 1e-3 * Conf.animation.step, AnimatorsRun, 0, NULL); + } + + return an; +} + +void +AnimatorDel(Animator * an) +{ +#if DEBUG_ANIMATORS + Eprintf("AnimatorDel %p func=%p data=%p\n", an, an->func, an->data); +#endif + + ecore_list_remove_node(animator_list, an); + if (an->name) + Efree(an->name); + if (an->data) + Efree(an->data); + Efree(an); + + if (ecore_list_nodes(animator_list) == 0) + { + /* Animator list was empty - Add to timer qeueue */ + RemoveTimerEvent("Anim"); + } +} + +void * +AnimatorGetData(Animator * an) +{ + return an->data; } =================================================================== RCS file: /cvs/e/e16/e/src/timers.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- timers.h 13 Jan 2007 19:14:28 -0000 1.2 +++ timers.h 28 Jan 2007 04:59:46 -0000 1.3 @@ -39,4 +39,9 @@ void IdlerDel(Idler * id); void IdlersRun(void); +typedef struct _animator Animator; +Animator *AnimatorAdd(int (*func) (void *data), void *data); +void AnimatorDel(Animator * an); +void *AnimatorGetData(Animator * an); + #endif /* _TIMERS_H_ */ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs