Mercurial > MadButterfly
comparison examples/menu/filebrowser.c @ 356:3e84458968ec
Move mb_img_data_t out from argument list of rdman_shape_image_new().
- Application should specify content of sh_image_t by fill the shape
with a paint_image_t.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 09 Mar 2009 23:05:57 +0800 |
parents | 04d22dc38bc0 |
children | 31b6633e3538 |
comparison
equal
deleted
inserted
replaced
355:958b67d911db | 356:3e84458968ec |
---|---|
66 | 66 |
67 | 67 |
68 void mypreview(MyAppData *data, char *path) | 68 void mypreview(MyAppData *data, char *path) |
69 { | 69 { |
70 redraw_man_t *rdman = MBAPP_RDMAN(myApp); | 70 redraw_man_t *rdman = MBAPP_RDMAN(myApp); |
71 mb_img_ldr_t *ldr = rdman_img_ldr(rdman); | 71 paint_t *paint, *old_paint; |
72 mb_img_data_t *img = MB_IMG_LDR_LOAD(ldr, path); | 72 paint_t *previewimg_paint; |
73 shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg"); | 73 shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg"); |
74 mb_img_data_t *previewimg_img_data; | 74 int w, h; |
75 mb_img_data_t *old_img; | 75 |
76 | 76 previewimg_paint = |
77 previewimg_img_data = | 77 (paint_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite, |
78 (mb_img_data_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite, | 78 "previewimg_paint_img"); |
79 "previewimg_img_data"); | |
80 printf("Preview %s\n",path); | 79 printf("Preview %s\n",path); |
81 if (img) { | 80 paint = rdman_img_ldr_load_paint(rdman, path); |
82 printf("image %d %d\n",img->w,img->h); | 81 if (paint) { |
83 old_img = sh_image_get_img_data(obj); | 82 paint_image_get_size(paint, &w, &h); |
84 sh_image_set_img_data(obj,img); | 83 printf("image %d %d\n",w, h); |
85 if(old_img != previewimg_img_data) | 84 old_paint = sh_get_fill(obj); |
86 MB_IMG_DATA_FREE(old_img); | 85 rdman_paint_fill(rdman, paint, obj); |
87 rdman_shape_changed(MBAPP_RDMAN(myApp),obj); | 86 if(old_paint != previewimg_paint) |
88 rdman_redraw_changed(MBAPP_RDMAN(myApp)); | 87 rdman_paint_free(rdman, old_paint); |
88 | |
89 rdman_shape_changed(MBAPP_RDMAN(myApp),obj); | |
90 rdman_redraw_changed(MBAPP_RDMAN(myApp)); | |
89 } | 91 } |
90 } | 92 } |
91 | 93 |
92 int endWith(char *path, char *ext) | 94 int endWith(char *path, char *ext) |
93 { | 95 { |