annotate examples/menu/main.c @ 303:f894b30676e9

Add MBAF object suport. This is still work in progress yet. However, it won't affect other features. Therefore, it is checked in before it become mature.
author wycc
date Sun, 15 Feb 2009 08:34:57 +0800
parents 8b45e7b374b8
children c8f31eef947b
rev   line source
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
1 /*! \file
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
2 *
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
3 * This is the demo program for the animated menu. We will use to test the MBAF API.
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
4 * We need to have group item1-item9 in the SVG file. Initially, we will show
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
5 * item1-item8 only. When a up/down key is pressed, we will draw the next item in item9 and
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
6 * add two words to move item1-item9 smoothly. The first word move items to the 3/4 position
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
7 * fastly. The second will move it from 3/4 to the final position slowly to make retard effect.
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
8 *
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
9 * If we press another key before the second words finish, we will delete the word and replace
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
10 * it with a word to move it fastly to the final position and then we will repeat the procedure
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
11 * to add another two words to move it to the next position.
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
12 */
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
13 #include <stdio.h>
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
14 #include <mb.h>
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
15 #include <string.h>
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
16 #include "menu.h"
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
17 #include "mbapp.h"
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
18
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
19
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
20 typedef struct {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
21 char **titles;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
22 int *menus_y;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
23 int *items;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
24 int top;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
25 int cur;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
26 int max;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
27 int ready;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
28 MBApp *app;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
29 mb_sprite_t *sprite;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
30 mb_obj_t **objects;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
31 mb_obj_t *lightbar;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
32 } mb_animated_menu_t;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
33
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
34 char *menus[] = {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
35 "Item 1",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
36 "Item 2",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
37 "Item 3",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
38 "Item 4",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
39 "Item 5",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
40 "Item 6",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
41 "Item 7",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
42 "Item 8",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
43 "Item 9",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
44 "Item 10",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
45 "Item 11",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
46 "Item 12",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
47 "Item 13",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
48 "Item 14",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
49 "Item 15",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
50 "Item 16",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
51 "Item 17",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
52 "Item 18",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
53 };
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
54
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
55 int menus_y[10];
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
56 int items[10];
298
959c4ac544a1 Add SPPED marcro to adjust the speed
wycc
parents: 297
diff changeset
57 #define SPEED 600000
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
58
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
59 typedef struct {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
60 mb_animated_menu_t *m;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
61 }MyAppData;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
62
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
63 MBApp *myApp;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
64
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
65
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
66 static void set_text(coord_t *g, char *text)
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
67 {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
68 geo_t *geo;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
69 shape_t *shape;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
70
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
71 FOR_COORD_MEMBERS(g, geo) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
72 shape = geo_get_shape(geo);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
73 if(shape->obj.obj_type == MBO_TEXT) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
74 sh_text_set_text(shape, text);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
75 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
76 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
77 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
78
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
79 static void mb_animated_menu_fillMenuContent(mb_animated_menu_t *m)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
80 {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
81 int i;
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
82 coord_t *textgroup;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
83 shape_t *text;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
84 coord_t *group;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
85 coord_t *lightbar;
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
86 int tmp;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
87 mb_timeval_t start, playing, now;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
88 mb_progm_t *progm;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
89 mb_word_t *word;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
90
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
91
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
92 // fill new item
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
93 for(i=0;i<8;i++) {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
94 text = (shape_t *) m->objects[m->items[i]];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
95 set_text(text, m->titles[m->top+i]);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
96 //rdman_shape_changed(MBAPP_RDMAN(m->app),text);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
97 }
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
98
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
99
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
100 textgroup = (coord_t *) m->objects[m->items[i]];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
101 coord_hide(textgroup);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
102 rdman_coord_changed(MBAPP_RDMAN(m->app),textgroup);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
103
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
104 lightbar = (coord_t *) m->lightbar;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
105 group = (coord_t *) m->objects[m->cur+1];
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
106 coord_x(lightbar) = coord_x(group);
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
107 coord_y(lightbar) = coord_y(group);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
108 rdman_redraw_changed(MBAPP_RDMAN(m->app));
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
109 }
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
110
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
111 static void mb_animated_menu_complete(void *arg)
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
112 {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
113 mb_animated_menu_t *m = (mb_animated_menu_t *) arg;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
114
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
115 m->ready++;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
116 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
117
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
118 static void mb_animated_menu_fillMenuContentUp(mb_animated_menu_t *m)
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
119 {
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
120 int i;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
121 coord_t *textgroup;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
122 shape_t *text;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
123 coord_t *group;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
124 coord_t *lightbar;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
125 int tmp;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
126 mb_timeval_t start, playing, now;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
127 mb_progm_t *progm;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
128 mb_word_t *word;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
129
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
130
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
131 // fill new item
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
132 text = (shape_t *) m->objects[m->items[8]];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
133 set_text(text, m->titles[m->top]);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
134
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
135 progm = mb_progm_new(2, MBAPP_RDMAN(m->app));
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
136 MB_TIMEVAL_SET(&start, 0, 0);
298
959c4ac544a1 Add SPPED marcro to adjust the speed
wycc
parents: 297
diff changeset
137 MB_TIMEVAL_SET(&playing, 0, SPEED);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
138 word = mb_progm_next_word(progm, &start, &playing);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
139 get_now(&now);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
140
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
141 for(i=0;i<7;i++) {
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
142 //shift to the next item
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
143 textgroup = (coord_t *) m->objects[m->items[i]];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
144 mb_shift_new(0,m->menus_y[i+1]-coord_y(textgroup), textgroup,word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
145 }
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
146 // fade out the item[7]
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
147 textgroup = (coord_t *) m->objects[m->items[7]];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
148 mb_shift_new(0,100, textgroup,word);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
149
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
150 // fade in the item[8]
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
151 textgroup = (coord_t *) m->objects[m->items[8]];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
152 group = (coord_t *) m->objects[m->items[0]];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
153 coord_y(textgroup) = m->menus_y[0]-100;
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
154 coord_show(textgroup);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
155 mb_shift_new(0,100, textgroup,word);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
156
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
157 lightbar = (coord_t *) m->lightbar;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
158 mb_shift_new(0,m->menus_y[m->cur]-coord_y(lightbar),lightbar,word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
159
298
959c4ac544a1 Add SPPED marcro to adjust the speed
wycc
parents: 297
diff changeset
160 MB_TIMEVAL_SET(&start, 0, SPEED);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
161 MB_TIMEVAL_SET(&playing, 0, 0);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
162 word = mb_progm_next_word(progm, &start, &playing);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
163 textgroup = (coord_t *) m->objects[m->items[7]];
299
5bf503270419 Fix the Fade out issue in scroll up.
wycc
parents: 298
diff changeset
164 mb_visibility_new(VIS_HIDDEN, textgroup,word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
165
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
166 mb_progm_free_completed(progm);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
167 m->ready--;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
168 subject_add_observer(mb_progm_get_complete(progm), mb_animated_menu_complete,m);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
169 mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
170 rdman_redraw_changed(MBAPP_RDMAN(m->app));
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
171 tmp = m->items[8];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
172 for(i=8;i>0;i--) {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
173 m->items[i] = m->items[i-1];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
174 }
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
175 m->items[0] = tmp;
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
176 }
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
177
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
178
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
179 static void mb_animated_menu_fillMenuContentDown(mb_animated_menu_t *m)
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
180 {
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
181 int i;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
182 coord_t *textgroup;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
183 shape_t *text;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
184 coord_t *group;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
185 coord_t *lightbar;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
186 char name[255];
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
187 int tmp;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
188 mb_timeval_t start, playing, now;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
189 mb_progm_t *progm;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
190 mb_word_t *word;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
191
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
192
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
193 // fill new item
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
194 set_text(m->objects[m->items[8]], m->titles[m->top+7]);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
195
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
196 progm = mb_progm_new(2, MBAPP_RDMAN(m->app));
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
197 MB_TIMEVAL_SET(&start, 0, 0);
298
959c4ac544a1 Add SPPED marcro to adjust the speed
wycc
parents: 297
diff changeset
198 MB_TIMEVAL_SET(&playing, 0, SPEED);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
199 word = mb_progm_next_word(progm, &start, &playing);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
200 get_now(&now);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
201
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
202 for(i=1;i<8;i++) {
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
203 //shift to the next item
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
204 mb_shift_new(0,m->menus_y[i-1]-coord_y((coord_t *)m->objects[m->items[i]]), (coord_t *) m->objects[m->items[i]],word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
205 }
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
206 // fade out the item[0]
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
207 mb_shift_new(0,-100, (coord_t *)m->objects[m->items[0]],word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
208
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
209 // fade in the item[8]
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
210 coord_y((coord_t *)m->objects[m->items[8]]) = m->menus_y[7]+100;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
211 coord_show(((coord_t *)(m->objects[m->items[8]])));
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
212 mb_shift_new(0,-100, (coord_t *)m->objects[m->items[8]],word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
213
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
214 mb_shift_new(0,m->menus_y[m->cur]-coord_y((coord_t *)m->lightbar),((coord_t *)(m->lightbar)),word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
215
298
959c4ac544a1 Add SPPED marcro to adjust the speed
wycc
parents: 297
diff changeset
216 MB_TIMEVAL_SET(&start, 0, SPEED);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
217 MB_TIMEVAL_SET(&playing, 0, 0);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
218 word = mb_progm_next_word(progm, &start, &playing);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
219 mb_visibility_new(VIS_VISIBLE, (coord_t *) m->objects[m->items[0]],word);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
220
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
221 mb_progm_free_completed(progm);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
222 m->ready--;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
223 subject_add_observer(mb_progm_get_complete(progm), mb_animated_menu_complete,m);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
224 mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
225 rdman_redraw_changed(MBAPP_RDMAN(m->app));
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
226 tmp = m->items[0];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
227 for(i=0;i<8;i++) {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
228 m->items[i] = m->items[i+1];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
229 }
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
230 m->items[8] = tmp;
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
231 }
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
232
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
233 void mb_animated_menu_moveLightBar(mb_animated_menu_t *m)
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
234 {
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
235 mb_timeval_t start, playing, now;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
236 mb_progm_t *progm;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
237 mb_word_t *word;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
238 coord_t *group;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
239 coord_t *lightbar;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
240
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
241 progm = mb_progm_new(1, MBAPP_RDMAN(m->app));
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
242 MB_TIMEVAL_SET(&start, 0, 0);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
243 MB_TIMEVAL_SET(&playing, 0, 200000);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
244 word = mb_progm_next_word(progm, &start, &playing);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
245 get_now(&now);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
246
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
247 lightbar = (coord_t *) m->lightbar;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
248 group = (coord_t *) m->objects[m->cur];
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
249 mb_shift_new(coord_x(group)-coord_x(lightbar),coord_y(group)-coord_y(lightbar),lightbar,word);
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
250 mb_progm_free_completed(progm);
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
251 mb_progm_start(progm, X_MB_tman(MBAPP_RDMAN(m->app)->rt), &now);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
252 rdman_redraw_changed(MBAPP_RDMAN(m->app));
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
253 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
254
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
255 void mb_animated_menu_up(mb_animated_menu_t *m)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
256 {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
257 if (m->cur > 5) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
258 m->cur--;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
259 mb_animated_menu_moveLightBar(m);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
260 } else {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
261 if (m->top > 0) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
262 m->top--;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
263 mb_animated_menu_fillMenuContentUp(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
264 } else {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
265 if (m->cur == 0)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
266 return;
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
267 m->cur--;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
268 mb_animated_menu_moveLightBar(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
269 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
270 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
271 }
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
272 void mb_animated_menu_down(mb_animated_menu_t *m)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
273 {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
274
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
275 if (m->cur < 4) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
276 if (m->top+m->cur <= m->max) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
277 m->cur++;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
278 mb_animated_menu_moveLightBar(m);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
279 }
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
280 } else {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
281 if ((m->top+8) < m->max) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
282 m->top++;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
283 mb_animated_menu_fillMenuContentDown(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
284 } else {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
285 if (m->cur+m->top < m->max-1) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
286 m->cur++;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
287 mb_animated_menu_moveLightBar(m);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
288 } else
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
289 return;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
290 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
291 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
292 }
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
293 void mb_animated_menu_select(mb_animated_menu_t *m)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
294 {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
295 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
296
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
297 void mb_animated_menu_keyHandler(event_t *ev, void *arg)
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
298 {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
299 mb_animated_menu_t *m = (mb_animated_menu_t *) arg;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
300 X_kb_event_t *xkey = (X_kb_event_t *)ev;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
301 if(xkey->event.type != EVT_KB_PRESS) {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
302 return;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
303 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
304 switch(xkey->sym) {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
305 case 0xff51: /* left */
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
306 break;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
307
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
308 case 0xff52: /* up */
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
309 mb_animated_menu_up(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
310 break;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
311
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
312 case 0xff53: /* right */
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
313 break;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
314
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
315 case 0xff54: /* down */
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
316 mb_animated_menu_down(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
317 break;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
318
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
319 case 0xff0d: /* enter */
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
320 mb_animated_menu_select(m);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
321 break;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
322 default:
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
323 return;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
324 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
325 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
326
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
327 /** \brief Create an instace of animated menu.
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
328 *
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
329 * The objectnames is used to extract symbols from the SVG file.
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
330 * ${objectnames}0 - ${objectnames}8 is the text object.
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
331 * ${objectnames}_lightbar is the lightbar.
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
332 *
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
333 */
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
334 mb_animated_menu_t *mb_animated_menu_new(MBApp *app,mb_sprite_t *sp,char *objnames,char *menus[])
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
335 {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
336 mb_animated_menu_t *m;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
337 int i,len;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
338 char name[255];
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
339 mb_obj_t *l;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
340
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
341 for(i=0;menus[i];i++);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
342 len = i;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
343
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
344 m = (mb_animated_menu_t *) malloc(sizeof(mb_animated_menu_t)+sizeof(int)*len*2+sizeof(mb_obj_t *)*len);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
345 m->app = app;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
346 m->sprite = sp;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
347 m->top = 0;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
348 m->cur = 0;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
349 m->ready = 1;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
350 m->max = len;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
351 m->items = (int *) (m+1);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
352 m->menus_y = (int *) (m->items+len);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
353 m->objects = (mb_obj_t **) (m->menus_y+len);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
354 for(i=0;i<9;i++) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
355 m->items[i] = i;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
356 snprintf(name,sizeof(name),"%s%d", objnames, i+1);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
357 l = MB_SPRITE_GET_OBJ(sp,name);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
358 if (l == NULL) {
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
359 fprintf(stderr,"Can not find symbol %s\n",name);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
360 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
361 m->objects[i] = (mb_obj_t *) l;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
362 m->menus_y[i] = coord_y((coord_t*)l);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
363 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
364 m->titles = menus;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
365 snprintf(name,sizeof(name), "%s_lightbar", objnames);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
366 m->lightbar = (mb_obj_t *) MB_SPRITE_GET_OBJ(sp,name);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
367 if (m->lightbar)
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
368 fprintf(stderr,"Can not find object %s\n",name);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
369 mb_animated_menu_fillMenuContent(m);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
370 subject_add_observer(MBAPP_keySubject(myApp), mb_animated_menu_keyHandler,m);
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
371 return m;
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
372 }
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
373
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
374 MyApp_InitContent()
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
375 {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
376 MyAppData *data = MBAPP_DATA(myApp,MyAppData);
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
377 subject_t *key = MBAPP_keySubject(myApp);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
378 char name[255];
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
379 coord_t *l;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
380 int i;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
381 mb_sprite_t *sprite=myApp->rootsprite;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
382
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
383 data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",menus);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
384 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
385
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
386 int main(int argc, char * const argv[]) {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
387 subject_t *subject;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
388 mb_obj_t *button;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
389 MyAppData data;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
390 mb_timeval_t tmo,interval;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
391
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
392 if (argc > 1)
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
393 myApp = MBApp_Init(argv[1]);
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
394 else
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
395 myApp = MBApp_Init("list");
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
396 MBApp_setData(myApp,&data);
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
397 MyApp_InitContent();
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
398
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
399 MBApp_loop(myApp);
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
400
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
401 return 0;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
402 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
403
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
404 /* vim: set ts=4 */