Mercurial > MadButterfly
changeset 454:9b8dda201ccb
Make naming convention consistent with MadButterfly.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Thu, 06 Aug 2009 09:38:51 +0800 |
parents | 84ce2d4a8c3f |
children | 58b6337fb3b2 |
files | examples/dynamic/hello.c examples/dynamic/main.c examples/dynamic/text.c examples/menu/filebrowser.c examples/menu/main.c include/animated_menu.h include/mbapp.h inkscape/firefox/template/textmenu/app.c inkscape/firefox/template/textmenu/app.h inkscape/firefox/template/textmenu/main.c src/mbaf/animated_menu.c src/mbaf/mbapp.c |
diffstat | 12 files changed, 142 insertions(+), 139 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/dynamic/hello.c Wed Aug 05 19:34:59 2009 +0800 +++ b/examples/dynamic/hello.c Thu Aug 06 09:38:51 2009 +0800 @@ -11,7 +11,7 @@ #include "mbapp.h" -MBApp *myApp; +mbaf_t *app; typedef struct { shape_t *rect; @@ -19,46 +19,46 @@ int start_x,start_y; observer_t *obs1,*obs2; int currentscene; -}MyAppData; +}app_data_t; void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mb_timeval_t timer,interval; get_now(&timer); MB_TIMEVAL_SET(&interval, 1 ,0); MB_TIMEVAL_ADD(&timer, &interval); - mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &timer, switch_scene, app); en->currentscene = (en->currentscene + 1) % 2; printf("switch to scene %d\n", en->currentscene + 1); - MB_SPRITE_GOTO_SCENE(myApp->rootsprite,en->currentscene + 1); + MB_SPRITE_GOTO_SCENE(app->rootsprite,en->currentscene + 1); } int main(int argc, char * const argv[]) { subject_t *subject; mb_button_t *b; mb_obj_t *button; - MyAppData data; + app_data_t data; mb_timeval_t tmo,interval; if (argc > 1) - myApp = MBApp_Init(argv[1], ""); + app = mbaf_init(argv[1], ""); else - myApp = MBApp_Init("scene", ".libs"); + app = mbaf_init("scene", ".libs"); data.currentscene=0; - MBApp_setData(myApp,&data); - //b = mb_button_new(myApp, myApp->rootsprite, "btn"); + mbaf_set_data(app,&data); + //b = mb_button_new(app, app->rootsprite, "btn"); //mb_button_add_onClick(b, test,NULL); get_now(&tmo); MB_TIMEVAL_SET(&interval, 1 ,0); - mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &tmo, switch_scene, app); - MBApp_loop(myApp); + mbaf_loop(app); return 0; }
--- a/examples/dynamic/main.c Wed Aug 05 19:34:59 2009 +0800 +++ b/examples/dynamic/main.c Thu Aug 06 09:38:51 2009 +0800 @@ -18,35 +18,35 @@ int start_x,start_y; observer_t *obs1,*obs2; int currentscene; -}MyAppData; +} app_data_t; #define CMOUSE(e) (coord_get_mouse_event(e)) static void add_rect_move(event_t *evt, void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mouse_event_t *mev = (mouse_event_t *) evt; printf("resize rectangle\n"); sh_rect_set(en->rect, en->start_x, en->start_y, mev->x - en->start_x, mev->y-en->start_y,0,0); - rdman_shape_changed(MBAPP_RDMAN(arg),en->rect); - rdman_redraw_changed(MBAPP_RDMAN(arg)); + rdman_shape_changed(MBAF_RDMAN(arg),en->rect); + rdman_redraw_changed(MBAF_RDMAN(arg)); } static void add_rect_release(event_t *evt, void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mouse_event_t *mev = (mouse_event_t *) evt; printf("rectangle done\n"); - subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs1); - subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs2); + subject_remove_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), en->obs1); + subject_remove_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), en->obs2); } static void add_rect_2(event_t *evt, void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mouse_event_t *mev = (mouse_event_t *) evt; paint_t *color; @@ -55,41 +55,41 @@ en->start_x = mev->x; en->start_y = mev->y; - subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs1); - subject_remove_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), en->obs2); - en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_move, en); - en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_RELEASE, add_rect_release, en); + subject_remove_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), en->obs1); + subject_remove_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), en->obs2); + en->obs1 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_move, en); + en->obs2 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_RELEASE, add_rect_release, en); } static void add_rect_2_move(event_t *evt, void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mouse_event_t *mev = (mouse_event_t *) evt; sh_rect_set(en->rect, mev->x, mev->y, 50,50,0,0); - rdman_shape_changed(MBAPP_RDMAN(arg),en->rect); - rdman_redraw_changed(MBAPP_RDMAN(arg)); + rdman_shape_changed(MBAF_RDMAN(arg),en->rect); + rdman_redraw_changed(MBAF_RDMAN(arg)); } static void add_rect(event_t *evt, void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mouse_event_t *mev = (mouse_event_t *) evt; paint_t *color; printf("menut selected\n"); - en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en); - en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en); - en->rect = rdman_shape_rect_new(MBAPP_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0); + en->obs1 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en); + en->obs2 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en); + en->rect = rdman_shape_rect_new(MBAF_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0); // Paint it with color - en->obs1 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en); - en->obs2 = subject_add_event_observer(CMOUSE(MBAPP_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en); - en->rect = rdman_shape_rect_new(MBAPP_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0); + en->obs1 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_BUT_PRESS, add_rect_2, en); + en->obs2 = subject_add_event_observer(CMOUSE(MBAF_RDMAN(arg)->root_coord), EVT_MOUSE_MOVE, add_rect_2_move, en); + en->rect = rdman_shape_rect_new(MBAF_RDMAN(arg), mev->x, mev->y, 50 , 50, 0,0); // Paint it with color - color = rdman_paint_color_new(MBAPP_RDMAN(arg), 0.800000, 0.800000, 0.400000, 1.000000); - rdman_paint_fill(MBAPP_RDMAN(arg), color, en->rect); + color = rdman_paint_color_new(MBAF_RDMAN(arg), 0.800000, 0.800000, 0.400000, 1.000000); + rdman_paint_fill(MBAF_RDMAN(arg), color, en->rect); // Add to the stage - //rdman_add_shape(MBAPP_RDMAN(arg), en->rect, en->menu->root_coord); + //rdman_add_shape(MBAF_RDMAN(arg), en->rect, en->menu->root_coord); } @@ -98,22 +98,22 @@ printf("Button is pressed.....\n"); } -MBApp *myApp; +mbaf_t *app; void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mb_timeval_t timer,interval; get_now(&timer); MB_TIMEVAL_SET(&interval, 1 ,0); MB_TIMEVAL_ADD(&timer, &interval); - mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &timer, switch_scene, app); en->currentscene = (en->currentscene + 1) % 2; printf("switch to scene %d\n", en->currentscene + 1); - MB_SPRITE_GOTO_SCENE(myApp->rootsprite,en->currentscene + 1); + MB_SPRITE_GOTO_SCENE(app->rootsprite,en->currentscene + 1); } MyApp_InitContent() @@ -121,8 +121,8 @@ mb_button_t *b; mb_sprite_t *sprite; - sprite = sprite_load("button", myApp->rdman, myApp->rdman->root_coord); - b = mb_button_new(myApp->rdman, sprite, "btn"); + sprite = sprite_load("button", app->rdman, app->rdman->root_coord); + b = mb_button_new(app->rdman, sprite, "btn"); mb_button_add_onClick(b, test,NULL); } @@ -134,23 +134,23 @@ int main(int argc, char * const argv[]) { subject_t *subject; mb_obj_t *button; - MyAppData data; + app_data_t data; mb_timeval_t tmo,interval; if (argc > 1) - myApp = MBApp_Init(argv[1], ""); + app = mbaf_init(argv[1], ""); else - myApp = MBApp_Init("scene", ".libs"); + app = mbaf_init("scene", ".libs"); data.currentscene=0; draw_text(); - MBApp_setData(myApp,&data); + mbaf_set_data(app,&data); MyApp_InitContent(); get_now(&tmo); MB_TIMEVAL_SET(&interval, 1 ,0); - mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &tmo, switch_scene, app); - MBApp_loop(myApp); + mbaf_loop(app); return 0; }
--- a/examples/dynamic/text.c Wed Aug 05 19:34:59 2009 +0800 +++ b/examples/dynamic/text.c Thu Aug 06 09:38:51 2009 +0800 @@ -11,7 +11,7 @@ #include "mbapp.h" -MBApp *myApp; +mbaf_t *app; typedef struct { shape_t *rect; @@ -19,14 +19,14 @@ int start_x,start_y; observer_t *obs1,*obs2; int currentscene; -}MyAppData; +}app_data_t; void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) { - MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); + app_data_t *en = MBAF_DATA((mbaf_t *)arg,app_data_t ); mb_timeval_t timer,interval; - shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext"); + shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(app->rootsprite,"mytext"); mb_textstyle_t style; mb_textstyle_init(&style); @@ -35,7 +35,7 @@ get_now(&timer); MB_TIMEVAL_SET(&interval, 1 ,0); MB_TIMEVAL_ADD(&timer, &interval); - mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &timer, switch_scene, app); en->currentscene = (en->currentscene + 1) % 2; printf("xxx\n"); @@ -48,12 +48,12 @@ mb_textstyle_set_color(&style, TEXTCOLOR_RGB(0,255,0)); sh_text_set_style(text,0,5,&style); } - rdman_shape_changed(MBAPP_RDMAN(myApp), text); + rdman_shape_changed(MBAF_RDMAN(app), text); #if 0 /* Removed! * X_MB_handle_connection() will invoke it automatically. */ - rdman_redraw_changed(MBAPP_RDMAN(myApp)); + rdman_redraw_changed(MBAF_RDMAN(app)); #endif } @@ -61,21 +61,21 @@ subject_t *subject; mb_button_t *b; mb_obj_t *button; - MyAppData data; + app_data_t data; mb_timeval_t tmo,interval; if (argc > 1) - myApp = MBApp_Init(argv[1], ""); + app = mbaf_init(argv[1], ""); else - myApp = MBApp_Init("mytext", ".libs"); + app = mbaf_init("mytext", ".libs"); data.currentscene=0; - MBApp_setData(myApp,&data); + mbaf_set_data(app,&data); get_now(&tmo); MB_TIMEVAL_SET(&interval, 1 ,0); - mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp); + mb_tman_timeout( mbaf_get_timer(app), &tmo, switch_scene, app); - MBApp_loop(myApp); + mbaf_loop(app); return 0; }
--- a/examples/menu/filebrowser.c Wed Aug 05 19:34:59 2009 +0800 +++ b/examples/menu/filebrowser.c Thu Aug 06 09:38:51 2009 +0800 @@ -36,15 +36,15 @@ struct fileinfo *files[MAX_ENTRY]; char *titles[MAX_ENTRY]; int nFiles; -}MyAppData; +}app_data_t; -MBApp *myApp; +mbaf_t *app; void myselect(mb_animated_menu_t *m, int select) { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); + app_data_t *data = MBAF_DATA(app,app_data_t); char path[1024]; int len,i; @@ -61,20 +61,20 @@ snprintf(path,1024,"%s/%s", data->curDir,data->titles[select]); } - MyApp_fillDirInfo(myApp, path); + MyApp_fillDirInfo(app, path); } -void mypreview(MyAppData *data, char *path) +void mypreview(app_data_t *data, char *path) { - redraw_man_t *rdman = MBAPP_RDMAN(myApp); + redraw_man_t *rdman = MBAF_RDMAN(app); paint_t *paint, *old_paint; paint_t *previewimg_paint; - shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg"); + shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(app->rootsprite, "previewimg"); int w, h; previewimg_paint = - (paint_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite, + (paint_t *)MB_SPRITE_GET_OBJ(app->rootsprite, "previewimg_paint_img"); printf("Preview %s\n",path); paint = rdman_img_ldr_load_paint(rdman, path); @@ -86,8 +86,8 @@ if(old_paint != previewimg_paint) rdman_paint_free(rdman, old_paint); - rdman_shape_changed(MBAPP_RDMAN(myApp),obj); - rdman_redraw_changed(MBAPP_RDMAN(myApp)); + rdman_shape_changed(MBAF_RDMAN(app),obj); + rdman_redraw_changed(MBAF_RDMAN(app)); } } @@ -107,7 +107,7 @@ void myupdate(mb_animated_menu_t *m, int select) { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); + app_data_t *data = MBAF_DATA(app,app_data_t); char *s = data->titles[select]; char path[1024]; @@ -141,9 +141,9 @@ } -MyApp_fillDirInfo(MBApp *app,char *curdir) +MyApp_fillDirInfo(mbaf_t *app,char *curdir) { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); + app_data_t *data = MBAF_DATA(app,app_data_t); DIR *dir; struct dirent *e; struct fileinfo *f; @@ -199,26 +199,26 @@ MyApp_InitContent(char *dir) { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); - subject_t *key = MBAPP_keySubject(myApp); + app_data_t *data = MBAF_DATA(app,app_data_t); + subject_t *key = MBAF_KB_SUBJECT(app); char name[255]; coord_t *l; int i; - mb_sprite_t *sprite=myApp->rootsprite; + mb_sprite_t *sprite=app->rootsprite; - data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",NULL); + data->m = mb_animated_menu_new(app,app->rootsprite,"item",NULL); mb_animated_menu_set_callback(data->m, myselect); mb_animated_menu_set_update_callback(data->m, myupdate); data->curDir = NULL; data->nFiles=0; - MyApp_fillDirInfo(myApp,dir); + MyApp_fillDirInfo(app,dir); mb_animated_menu_set_speed(data->m,300); } int main(int argc, char * const argv[]) { subject_t *subject; mb_obj_t *button; - MyAppData data; + app_data_t data; mb_timeval_t tmo,interval; char *dir; @@ -226,11 +226,11 @@ dir = argv[1]; else dir ="/tmp"; - myApp = MBApp_Init("browser", ".libs"); - MBApp_setData(myApp,&data); + app = mbaf_init("browser", ".libs"); + mbaf_set_data(app,&data); MyApp_InitContent(dir); - MBApp_loop(myApp); + mbaf_loop(app); return 0; }
--- a/examples/menu/main.c Wed Aug 05 19:34:59 2009 +0800 +++ b/examples/menu/main.c Thu Aug 06 09:38:51 2009 +0800 @@ -42,9 +42,9 @@ typedef struct { mb_animated_menu_t *m; -}MyAppData; +}app_data_t; -MBApp *myApp; +mbaf_t *app; @@ -54,33 +54,33 @@ } -MyApp_InitContent() +app_init_content() { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); - subject_t *key = MBAPP_keySubject(myApp); + app_data_t *data = MBAF_DATA(app,app_data_t); + subject_t *key = MBAF_KB_SUBJECT(app); char name[255]; coord_t *l; int i; - mb_sprite_t *sprite=myApp->rootsprite; + mb_sprite_t *sprite=app->rootsprite; - data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",menus); + data->m = mb_animated_menu_new(app,app->rootsprite,"item",menus); mb_animated_menu_set_callback(data->m, myselect); } int main(int argc, char * const argv[]) { subject_t *subject; mb_obj_t *button; - MyAppData data; + app_data_t data; mb_timeval_t tmo,interval; if (argc > 1) - myApp = MBApp_Init(argv[1], ""); + app = mbaf_init(argv[1], ""); else - myApp = MBApp_Init("list", ".libs"); - MBApp_setData(myApp,&data); - MyApp_InitContent(); + app = mbaf_init("list", ".libs"); + mbaf_set_data(app,&data); + app_init_content(); - MBApp_loop(myApp); + mbaf_loop(app); return 0; }
--- a/include/animated_menu.h Wed Aug 05 19:34:59 2009 +0800 +++ b/include/animated_menu.h Thu Aug 06 09:38:51 2009 +0800 @@ -9,7 +9,7 @@ int max; int ready; int speed; - MBApp *app; + mbaf_t *app; mb_sprite_t *sprite; mb_obj_t **objects; mb_obj_t *lightbar; @@ -25,7 +25,7 @@ * ${objectnames}_lightbar is the lightbar. * */ -mb_animated_menu_t *mb_animated_menu_new(MBApp *app,mb_sprite_t *sp,char *objnames,char *menus[]); +mb_animated_menu_t *mb_animated_menu_new(mbaf_t *app,mb_sprite_t *sp,char *objnames,char *menus[]); void mb_animated_menu_set_speed(mb_animated_menu_t *m,int speed); int mb_animated_menu_get_speed(mb_animated_menu_t *m); void mb_animated_menu_set_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel));
--- a/include/mbapp.h Wed Aug 05 19:34:59 2009 +0800 +++ b/include/mbapp.h Thu Aug 06 09:38:51 2009 +0800 @@ -1,6 +1,7 @@ #ifndef __APP_H #define __APP_H -typedef struct _mbapp MBApp; + +typedef struct _mbapp mbaf_t; struct _mbapp { void *rt; redraw_man_t *rdman; @@ -9,13 +10,14 @@ subject_t *kbevents; void *private; }; -MBApp *MBApp_Init(const char *module, const char *module_dir); -void MBApp_setData(MBApp *app,void *data); -mb_tman_t *MBApp_getTimer(MBApp *app); -void MBApp_loop(MBApp *en); -#define MBAPP_DATA(app,type) ((type *) ((app)->private)) -#define MBAPP_RDMAN(app) (((MBApp *) app)->rdman) -#define MBAPP_keySubject(app) ((app)->kbevents) +mbaf_t *mbaf_init(const char *module, const char *module_dir); +void mbaf_set_data(mbaf_t *app,void *data); +mb_tman_t *mbaf_get_timer(mbaf_t *app); +void mbaf_loop(mbaf_t *app); +#define MBAF_DATA(app,type) ((type *) ((app)->private)) +#define MBAF_RDMAN(app) (((mbaf_t *) app)->rdman) +#define MBAF_KB_SUBJECT(app) ((app)->kbevents) #include "mbbutton.h" -#endif + +#endif /* __MBAF_H_ */
--- a/inkscape/firefox/template/textmenu/app.c Wed Aug 05 19:34:59 2009 +0800 +++ b/inkscape/firefox/template/textmenu/app.c Thu Aug 06 09:38:51 2009 +0800 @@ -10,7 +10,7 @@ // Put the callback function for menu select here } -void MyApp_InitContent(MBApp *app,int argc,char *argv[]) +void MyApp_InitContent(mbaf_t *app,int argc,char *argv[]) { // This function is called when the application is started. }
--- a/inkscape/firefox/template/textmenu/app.h Wed Aug 05 19:34:59 2009 +0800 +++ b/inkscape/firefox/template/textmenu/app.h Thu Aug 06 09:38:51 2009 +0800 @@ -4,7 +4,7 @@ mb_animated_menu_t *m; }MyAppData; -extern void MyApp_InitContent(MBApp *app,int argc, char *argv[]); +extern void MyApp_InitContent(mbaf_t *app,int argc, char *argv[]); void myselect_callback(mb_animated_menu_t *m, int select); #endif
--- a/inkscape/firefox/template/textmenu/main.c Wed Aug 05 19:34:59 2009 +0800 +++ b/inkscape/firefox/template/textmenu/main.c Thu Aug 06 09:38:51 2009 +0800 @@ -19,12 +19,12 @@ }; -MBApp *myApp; +mbaf_t *myApp; _MyApp_InitContent(int argc, char *argv[]) { - MyAppData *data = MBAPP_DATA(myApp,MyAppData); - subject_t *key = MBAPP_keySubject(myApp); + MyAppData *data = MBAF_DATA(myApp,MyAppData); + subject_t *key = MBAF_KB_SUBJECT(myApp); char name[255]; coord_t *l; int i; @@ -40,11 +40,11 @@ mb_obj_t *button; MyAppData data; - myApp = MBApp_Init("list"); - MBApp_setData(myApp,&data); + myApp = mbaf_init("list"); + mbaf_set_data(myApp,&data); _MyApp_InitContent(argc,argv); - MBApp_loop(myApp); + mbaf_loop(myApp); return 0; }
--- a/src/mbaf/animated_menu.c Wed Aug 05 19:34:59 2009 +0800 +++ b/src/mbaf/animated_menu.c Thu Aug 06 09:38:51 2009 +0800 @@ -38,19 +38,19 @@ set_text(group, m->titles[m->top+i]); else set_text(group, ""); - rdman_coord_changed(MBAPP_RDMAN(m->app),group); + rdman_coord_changed(MBAF_RDMAN(m->app),group); } textgroup = (coord_t *) m->objects[m->items[i]]; coord_hide(textgroup); - rdman_coord_changed(MBAPP_RDMAN(m->app),textgroup); + rdman_coord_changed(MBAF_RDMAN(m->app),textgroup); lightbar = (coord_t *) m->lightbar; group = (coord_t *) m->objects[m->cur]; coord_y(lightbar) = coord_y(group); - rdman_coord_changed(MBAPP_RDMAN(m->app),lightbar); - rdman_redraw_changed(MBAPP_RDMAN(m->app)); + rdman_coord_changed(MBAF_RDMAN(m->app),lightbar); + rdman_redraw_changed(MBAF_RDMAN(m->app)); } static void mb_animated_menu_complete(event_t *ev,void *arg) @@ -78,7 +78,7 @@ group = (coord_t *) m->objects[m->items[8]]; set_text(group, m->titles[m->top]); - m->progm = progm = mb_progm_new(2, MBAPP_RDMAN(m->app)); + m->progm = progm = mb_progm_new(2, MBAF_RDMAN(m->app)); MB_TIMEVAL_SET(&start, 0, 0); MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); @@ -112,8 +112,8 @@ mb_progm_free_completed(progm); m->ready--; subject_add_observer(mb_progm_get_complete(progm), mb_animated_menu_complete,m); - mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now); - rdman_redraw_changed(MBAPP_RDMAN(m->app)); + mb_progm_start(progm, X_MB_tman(MBAF_RDMAN(m->app)->rt), &now); + rdman_redraw_changed(MBAF_RDMAN(m->app)); tmp = m->items[8]; for(i=8;i>0;i--) { m->items[i] = m->items[i-1]; @@ -140,7 +140,7 @@ // fill new item set_text((coord_t *)m->objects[m->items[8]], m->titles[m->top+7]); - m->progm = progm = mb_progm_new(2, MBAPP_RDMAN(m->app)); + m->progm = progm = mb_progm_new(2, MBAF_RDMAN(m->app)); MB_TIMEVAL_SET(&start, 0, 0); MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); @@ -168,8 +168,8 @@ mb_progm_free_completed(progm); m->ready--; subject_add_observer(mb_progm_get_complete(progm), mb_animated_menu_complete,m); - mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now); - rdman_redraw_changed(MBAPP_RDMAN(m->app)); + mb_progm_start(progm, X_MB_tman(MBAF_RDMAN(m->app)->rt), &now); + rdman_redraw_changed(MBAF_RDMAN(m->app)); tmp = m->items[0]; for(i=0;i<8;i++) { m->items[i] = m->items[i+1]; @@ -185,7 +185,7 @@ coord_t *group; coord_t *lightbar; - m->progm = progm = mb_progm_new(1, MBAPP_RDMAN(m->app)); + m->progm = progm = mb_progm_new(1, MBAF_RDMAN(m->app)); MB_TIMEVAL_SET(&start, 0, 0); MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); @@ -196,8 +196,8 @@ mb_progm_free_completed(progm); m->ready--; subject_add_observer(mb_progm_get_complete(progm), mb_animated_menu_complete,m); - mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now); - rdman_redraw_changed(MBAPP_RDMAN(m->app)); + mb_progm_start(progm, X_MB_tman(MBAF_RDMAN(m->app)->rt), &now); + rdman_redraw_changed(MBAF_RDMAN(m->app)); } static void mb_animated_menu_up(mb_animated_menu_t *m) @@ -318,7 +318,7 @@ * ${objectnames}_lightbar is the lightbar. * */ -mb_animated_menu_t *mb_animated_menu_new(MBApp *app,mb_sprite_t *sp,char *objnames,char *menus[]) +mb_animated_menu_t *mb_animated_menu_new(mbaf_t *app,mb_sprite_t *sp,char *objnames,char *menus[]) { mb_animated_menu_t *m; int i,len; @@ -361,7 +361,7 @@ if (m->lightbar==NULL) fprintf(stderr,"Can not find object %s\n",name); mb_animated_menu_fillMenuContent(m); - subject_add_observer(MBAPP_keySubject(app), mb_animated_menu_keyHandler,m); + subject_add_observer(MBAF_KB_SUBJECT(app), mb_animated_menu_keyHandler,m); return m; }
--- a/src/mbaf/mbapp.c Wed Aug 05 19:34:59 2009 +0800 +++ b/src/mbaf/mbapp.c Thu Aug 06 09:38:51 2009 +0800 @@ -1,8 +1,9 @@ #include <mb.h> #include <mbapp.h> -MBApp *MBApp_Init(const char *module, const char *module_dir) + +mbaf_t *mbaf_init(const char *module, const char *module_dir) { - MBApp *app = (MBApp *) malloc(sizeof(MBApp)); + mbaf_t *app = (mbaf_t *) malloc(sizeof(mbaf_t)); X_MB_runtime_t *rt; rt = X_MB_new(":0.0", 800, 600); @@ -28,27 +29,27 @@ return app; } -void MBApp_setData(MBApp *app,void *data) +void mbaf_set_data(mbaf_t *app,void *data) { app->private = (void *) data; } -mb_tman_t *MBApp_getTimer(MBApp *app) +mb_tman_t *mbaf_get_timer(mbaf_t *app) { return X_MB_tman(app->rt); } -void MBApp_loop(MBApp *en) +void mbaf_loop(mbaf_t *app) { /* * Start handle connections, includes one to X server. * User start to interact with the application. */ - X_MB_handle_connection(en->rt); + X_MB_handle_connection(app->rt); /* * Clean */ - X_MB_free(en->rt); - free(en); + X_MB_free(app->rt); + free(app); }