# HG changeset patch # User wycc # Date 1236483969 -28800 # Node ID ab7f3c00fd0546a147dba0300ecdd0f743cdff2f # Parent 5465ff071b47aa1d00092e18ec61a46f96f25618 Implement PMNG viewer diff -r 5465ff071b47 -r ab7f3c00fd05 examples/menu/Makefile.am --- a/examples/menu/Makefile.am Sun Mar 08 10:13:44 2009 +0800 +++ b/examples/menu/Makefile.am Sun Mar 08 11:46:09 2009 +0800 @@ -34,7 +34,7 @@ menu_SOURCES = main.c animated_menu.c animated_menu.h nodist_menu_SOURCES = -CFLAGS = @pangocairo_CFLAGS@ +CFLAGS = @pangocairo_CFLAGS@ -g menu_CFLAGS = @pangocairo_CFLAGS@ menu_LDFLAGS = @pangocairo_LIBS@ menu_LDADD = $(top_builddir)/src/libmbfly.la diff -r 5465ff071b47 -r ab7f3c00fd05 examples/menu/animated_menu.c --- a/examples/menu/animated_menu.c Sun Mar 08 10:13:44 2009 +0800 +++ b/examples/menu/animated_menu.c Sun Mar 08 11:46:09 2009 +0800 @@ -4,6 +4,7 @@ //#include "menu.h" #include "mbapp.h" #include +static void mb_animated_menu_update(mb_animated_menu_t *m); static void set_text(coord_t *g, char *text) { geo_t *geo; @@ -204,15 +205,18 @@ if (m->cur > 5) { m->cur--; mb_animated_menu_moveLightBar(m); + mb_animated_menu_update(m); } else { if (m->top > 0) { m->top--; mb_animated_menu_fillMenuContentUp(m); + mb_animated_menu_update(m); } else { if (m->cur == 0) return; m->cur--; mb_animated_menu_moveLightBar(m); + mb_animated_menu_update(m); } } } @@ -223,25 +227,38 @@ if (m->top+m->cur <= m->max) { m->cur++; mb_animated_menu_moveLightBar(m); + mb_animated_menu_update(m); } } else { if ((m->top+8) < m->max-1) { m->top++; mb_animated_menu_fillMenuContentDown(m); + mb_animated_menu_update(m); } else { if (m->cur+m->top < m->max-1) { m->cur++; mb_animated_menu_moveLightBar(m); + mb_animated_menu_update(m); } else return; } } } +void mb_animated_menu_set_update_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel)) +{ + m->update_callback = f; +} void mb_animated_menu_set_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel)) { m->callback = f; } +static void mb_animated_menu_update(mb_animated_menu_t *m) +{ + if (m->update_callback) + m->update_callback(m,m->top+m->cur); + +} static void mb_animated_menu_select(mb_animated_menu_t *m) { if (m->callback) @@ -326,6 +343,7 @@ m->menus_y = (int *) (m->items+ii); m->objects = (mb_obj_t **) (m->menus_y+ii); m->callback = NULL; + m->update_callback = NULL; m->speed = 300000; for(i=0;i<9;i++) { m->items[i] = i; diff -r 5465ff071b47 -r ab7f3c00fd05 examples/menu/animated_menu.h --- a/examples/menu/animated_menu.h Sun Mar 08 10:13:44 2009 +0800 +++ b/examples/menu/animated_menu.h Sun Mar 08 11:46:09 2009 +0800 @@ -14,6 +14,7 @@ mb_obj_t **objects; mb_obj_t *lightbar; void (*callback)(struct _mb_animated_menu *m, int sel); + void (*update_callback)(struct _mb_animated_menu *m, int sel); mb_progm_t *progm; X_kb_event_t pending_key; } mb_animated_menu_t; diff -r 5465ff071b47 -r ab7f3c00fd05 examples/menu/browser.svg --- a/examples/menu/browser.svg Sun Mar 08 10:13:44 2009 +0800 +++ b/examples/menu/browser.svg Sun Mar 08 11:46:09 2009 +0800 @@ -43,51 +43,51 @@ + style="stop-color:#0000ff;stop-opacity:1;" /> + style="stop-color:#505050;stop-opacity:1;" /> - - + + - + - + + inkscape:vp_z="744.09448 : 526.18109 : 1" + inkscape:persp3d-origin="372.04724 : 350.78739 : 1" + id="perspective2498" /> @@ -103,278 +103,279 @@ current="1" /> + inkscape:groupmode="layer"> + id="rect3181" + style="opacity:1;fill:url(#linearGradient3189);fill-opacity:1;stroke:#000000;stroke-width:0.9993065;stroke-opacity:1" /> + id="layer1"> + transform="translate(-124.18599,-2.85715)"> item111111111111111111111111111111 + + + item111111111111111111111111111111 + y="60" + mbname="item2text">item1111111111111111111 + style="fill-opacity:1" + mbname="item3" + id="item3" + transform="translate(-123.00225,82.236798)"> item1111111111111111111 + mbname="item3text">item1111111111111111111 + style="fill-opacity:1" + mbname="item4" + id="item4" + transform="translate(-123.49193,124.7838)"> item1111111111111111111 + mbname="item4text">item1111111111111111111 + style="fill-opacity:1" + mbname="item5" + id="item5" + transform="translate(-125.0227,167.33077)"> item1111111111111111111 + + + item1111111111111111111 + mbname="item6text">item1111111111111111111 + style="fill-opacity:1" + mbname="item7" + id="item7" + transform="translate(-123.83896,252.42474)"> item1111111111111111111 + mbname="item7text">item111111111111111111111 + style="fill-opacity:1" + mbname="item8" + id="item8" + transform="translate(-124.32864,294.97172)"> item111111111111111111111 + + + item1111111111111111111 + mbname="item9text">item111111111111111111111 - + + + + item111111111111111111111 - + id="flowRoot2582" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + mbname="fileinfo">File infiormation + + + + - item111111111111111111111 - - - item111111111111111111111 - - + style="stroke:none" + id="item_lightbar" + transform="matrix(0.9148913,0,0,1,17.648985,179.69752)" + mbname="item_lightbar"> + - - - File infiormation - - - - - - - + style="opacity:0.3669725;fill:#eafbf3;fill-opacity:1;stroke:none;stroke-width:0.99680871;stroke-opacity:1" /> + id="previewimg" + x="514.40265" + y="98.114113" /> diff -r 5465ff071b47 -r ab7f3c00fd05 examples/menu/filebrowser.c --- a/examples/menu/filebrowser.c Sun Mar 08 10:13:44 2009 +0800 +++ b/examples/menu/filebrowser.c Sun Mar 08 11:46:09 2009 +0800 @@ -65,6 +65,51 @@ } +void mypreview(MyAppData *data, char *path) +{ + mb_img_data_t *img = MB_IMG_LDR_LOAD(rdman_img_ldr(MBAPP_RDMAN(myApp)), path); + shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg"); + + printf("Preview %s\n",path); + if (img) { + printf("image %d %d\n",img->w,img->h); + sh_image_set_img_data(obj,img,0,0,img->w,img->h); + sh_image_transform(obj); + rdman_shape_changed(MBAPP_RDMAN(myApp),obj); + rdman_redraw_changed(MBAPP_RDMAN(myApp)); + } +} + +int endWith(char *path, char *ext) +{ + int i; + char *s; + + s = path+strlen(path)-1; + for(i=strlen(ext)-1;i>=0;i--) { + if (*s != ext[i]) return 0; + s--; + if (s < path) return 0; + } + return 1; +} + +void myupdate(mb_animated_menu_t *m, int select) +{ + MyAppData *data = MBAPP_DATA(myApp,MyAppData); + char *s = data->titles[select]; + char path[1024]; + + printf("check %s\n",s); + + if (endWith(s,".jpg") || endWith(s,".png")) { + snprintf(path,1024,"%s%s", data->curDir,data->titles[select]); + mypreview(data,path); + } +} + + + struct fileinfo *fileinfo_new() { struct fileinfo *f = (struct fileinfo *) malloc(sizeof(struct fileinfo)); @@ -152,6 +197,7 @@ data->m = mb_animated_menu_new(myApp,myApp->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);