annotate examples/menu/filebrowser.c @ 348:04d22dc38bc0

Change declaration of sh_image_set_img_data(). - x, y, w, h are not passed to sh_image_set_img_data() any more. - Applications should manage life-cycle of mb_img_data_t, paint_image_t do not manage it for applications any more.
author Thinker K.F. Li <thinker@branda.to>
date Sun, 08 Mar 2009 22:24:54 +0800
parents b247beaac4f0
children 3e84458968ec
rev   line source
309
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
1 /*! \file
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
2 *
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
3 * This is the demo program for the animated menu. We will use to test the MBAF API.
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
4 * We need to have group item1-item9 in the SVG file. Initially, we will show
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
5 * item1-item8 only. When a up/down key is pressed, we will draw the next item in item9 and
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
6 * add two words to move item1-item9 smoothly. The first word move items to the 3/4 position
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
7 * fastly. The second will move it from 3/4 to the final position slowly to make retard effect.
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
8 *
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
9 * If we press another key before the second words finish, we will delete the word and replace
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
10 * it with a word to move it fastly to the final position and then we will repeat the procedure
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
11 * to add another two words to move it to the next position.
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
12 */
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
13 #include <stdio.h>
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
14 #include <mb.h>
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
15 #include <string.h>
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
16 #include <dirent.h>
325
4453ea44a83d Remove the menu.h
root@localhost.localdomain
parents: 309
diff changeset
17 //#include "menu.h"
309
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
18 #include "mbapp.h"
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
19 #include <animated_menu.h>
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
20
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
21
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
22
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
23 struct fileinfo {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
24 int height;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
25 int width;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
26 int depth;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
27 int bitrate;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
28 int duration;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
29 int year;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
30 char *comment;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
31 };
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
32 #define MAX_ENTRY 1000
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
33 typedef struct {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
34 mb_animated_menu_t *m;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
35 char *curDir;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
36 struct fileinfo *files[MAX_ENTRY];
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
37 char *titles[MAX_ENTRY];
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
38 int nFiles;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
39 }MyAppData;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
40
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
41 MBApp *myApp;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
42
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
43
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
44
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
45 void myselect(mb_animated_menu_t *m, int select)
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
46 {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
47 MyAppData *data = MBAPP_DATA(myApp,MyAppData);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
48 char path[1024];
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
49 int len,i;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
50
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
51 if (strcmp(data->titles[select],"..")==0) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
52 strcpy(path, data->curDir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
53 len = strlen(path);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
54 for(i=len-1;i>0;i--) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
55 if (path[i] == '/') {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
56 path[i] = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
57 break;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
58 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
59 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
60 } else {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
61 snprintf(path,1024,"%s/%s", data->curDir,data->titles[select]);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
62 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
63
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
64 MyApp_fillDirInfo(myApp, path);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
65 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
66
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
67
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
68 void mypreview(MyAppData *data, char *path)
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
69 {
346
b391722bf20e sh_image_t::img_data is managed by paint_image_t.
Thinker K.F. Li <thinker@branda.to>
parents: 345
diff changeset
70 redraw_man_t *rdman = MBAPP_RDMAN(myApp);
b391722bf20e sh_image_t::img_data is managed by paint_image_t.
Thinker K.F. Li <thinker@branda.to>
parents: 345
diff changeset
71 mb_img_ldr_t *ldr = rdman_img_ldr(rdman);
b391722bf20e sh_image_t::img_data is managed by paint_image_t.
Thinker K.F. Li <thinker@branda.to>
parents: 345
diff changeset
72 mb_img_data_t *img = MB_IMG_LDR_LOAD(ldr, path);
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
73 shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg");
348
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
74 mb_img_data_t *previewimg_img_data;
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
75 mb_img_data_t *old_img;
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
76
348
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
77 previewimg_img_data =
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
78 (mb_img_data_t *)MB_SPRITE_GET_OBJ(myApp->rootsprite,
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
79 "previewimg_img_data");
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
80 printf("Preview %s\n",path);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
81 if (img) {
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
82 printf("image %d %d\n",img->w,img->h);
348
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
83 old_img = sh_image_get_img_data(obj);
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
84 sh_image_set_img_data(obj,img);
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
85 if(old_img != previewimg_img_data)
04d22dc38bc0 Change declaration of sh_image_set_img_data().
Thinker K.F. Li <thinker@branda.to>
parents: 347
diff changeset
86 MB_IMG_DATA_FREE(old_img);
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
87 rdman_shape_changed(MBAPP_RDMAN(myApp),obj);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
88 rdman_redraw_changed(MBAPP_RDMAN(myApp));
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
89 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
90 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
91
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
92 int endWith(char *path, char *ext)
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
93 {
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
94 int i;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
95 char *s;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
96
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
97 s = path+strlen(path)-1;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
98 for(i=strlen(ext)-1;i>=0;i--) {
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
99 if (*s != ext[i]) return 0;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
100 s--;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
101 if (s < path) return 0;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
102 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
103 return 1;
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
104 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
105
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
106 void myupdate(mb_animated_menu_t *m, int select)
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
107 {
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
108 MyAppData *data = MBAPP_DATA(myApp,MyAppData);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
109 char *s = data->titles[select];
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
110 char path[1024];
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
111
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
112 printf("check %s\n",s);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
113
345
d04085404583 Remove jpg sinc ethe image loader is not ready yet.
wycc
parents: 344
diff changeset
114 if (endWith(s,".png")) {
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
115 snprintf(path,1024,"%s%s", data->curDir,data->titles[select]);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
116 mypreview(data,path);
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
117 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
118 }
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
119
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
120
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
121
309
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
122 struct fileinfo *fileinfo_new()
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
123 {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
124 struct fileinfo *f = (struct fileinfo *) malloc(sizeof(struct fileinfo));
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
125
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
126 f->width = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
127 f->height = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
128 f->depth = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
129 f->bitrate = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
130 f->duration = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
131 f->year = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
132 f->comment = NULL;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
133 return f;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
134 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
135
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
136 void fileinfo_free(struct fileinfo *f)
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
137 {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
138 free(f);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
139 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
140
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
141
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
142 MyApp_fillDirInfo(MBApp *app,char *curdir)
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
143 {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
144 MyAppData *data = MBAPP_DATA(myApp,MyAppData);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
145 DIR *dir;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
146 struct dirent *e;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
147 struct fileinfo *f;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
148 int i;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
149
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
150 dir = opendir(curdir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
151 if (dir == NULL) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
152 printf("We can not open the direftory %s\n", curdir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
153 return;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
154 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
155
329
740844ee48c4 Update position of light-bar after update menu item
Thinker K.F. Li <thinker@branda.to>
parents: 325
diff changeset
156 if (data->curDir)
740844ee48c4 Update position of light-bar after update menu item
Thinker K.F. Li <thinker@branda.to>
parents: 325
diff changeset
157 free(data->curDir);
740844ee48c4 Update position of light-bar after update menu item
Thinker K.F. Li <thinker@branda.to>
parents: 325
diff changeset
158 data->curDir = strdup(curdir);
740844ee48c4 Update position of light-bar after update menu item
Thinker K.F. Li <thinker@branda.to>
parents: 325
diff changeset
159
309
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
160 if (data->files) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
161 for(i=0;i<data->nFiles;i++) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
162 fileinfo_free(data->files[i]);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
163 free(data->titles[i]);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
164 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
165 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
166 data->nFiles = 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
167 while(e = readdir(dir)) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
168 if (strcmp(e->d_name,".")==0) continue;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
169 if (e->d_type == DT_DIR) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
170 if (data->nFiles < MAX_ENTRY) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
171 f = fileinfo_new();
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
172 data->files[data->nFiles] = f;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
173 data->titles[data->nFiles++] = strdup(e->d_name);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
174 printf("%s\n", e->d_name);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
175 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
176 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
177 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
178
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
179 closedir(dir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
180 dir = opendir(curdir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
181 while(e = readdir(dir)) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
182 if (strcmp(e->d_name,".")==0) continue;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
183 if (e->d_type == DT_REG) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
184 if (data->nFiles < MAX_ENTRY) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
185 f = fileinfo_new();
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
186 data->files[data->nFiles] = f;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
187 data->titles[data->nFiles++] = strdup(e->d_name);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
188 printf("%s\n", e->d_name);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
189 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
190 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
191 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
192 closedir(dir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
193 data->titles[data->nFiles] = NULL;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
194 mb_animated_menu_set_titles(data->m,data->titles);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
195 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
196
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
197
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
198 MyApp_InitContent(char *dir)
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
199 {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
200 MyAppData *data = MBAPP_DATA(myApp,MyAppData);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
201 subject_t *key = MBAPP_keySubject(myApp);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
202 char name[255];
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
203 coord_t *l;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
204 int i;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
205 mb_sprite_t *sprite=myApp->rootsprite;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
206
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
207 data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",NULL);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
208 mb_animated_menu_set_callback(data->m, myselect);
344
ab7f3c00fd05 Implement PMNG viewer
wycc
parents: 329
diff changeset
209 mb_animated_menu_set_update_callback(data->m, myupdate);
309
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
210 data->curDir = NULL;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
211 data->nFiles=0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
212 MyApp_fillDirInfo(myApp,dir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
213 mb_animated_menu_set_speed(data->m,300);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
214 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
215
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
216 int main(int argc, char * const argv[]) {
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
217 subject_t *subject;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
218 mb_obj_t *button;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
219 MyAppData data;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
220 mb_timeval_t tmo,interval;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
221 char *dir;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
222
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
223 if (argc > 1)
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
224 dir = argv[1];
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
225 else
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
226 dir ="/tmp";
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
227 myApp = MBApp_Init("browser");
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
228 MBApp_setData(myApp,&data);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
229 MyApp_InitContent(dir);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
230
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
231 MBApp_loop(myApp);
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
232
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
233 return 0;
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
234 }
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
235
4dfb850dee92 Add filebrowser program and SVG file.
wycc
parents:
diff changeset
236 /* vim: set ts=4 */