annotate examples/menu/main.c @ 1435:b12c513212af

A prelimanary support for the SVG 1.2 flowRoot style text support. This is useless unless the region is rectangle. sort the scenes by layer and start attribute.
author wycc
date Mon, 11 Apr 2011 12:54:39 +0800
parents 26c302b47de1
children
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>
325
4453ea44a83d Remove the menu.h
root@localhost.localdomain
parents: 320
diff changeset
16 //#include "menu.h"
456
26c302b47de1 Change name of header files.
Thinker K.F. Li <thinker@branda.to>
parents: 454
diff changeset
17 #include "mb_af.h"
26c302b47de1 Change name of header files.
Thinker K.F. Li <thinker@branda.to>
parents: 454
diff changeset
18 #include "mb_ani_menu.h"
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
19
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
20
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
21
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
22 char *menus[] = {
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
23 "Item 1",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
24 "Item 2",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
25 "Item 3",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
26 "Item 4",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
27 "Item 5",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
28 "Item 6",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
29 "Item 7",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
30 "Item 8",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
31 "Item 9",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
32 "Item 10",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
33 "Item 11",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
34 "Item 12",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
35 "Item 13",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
36 "Item 14",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
37 "Item 15",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
38 "Item 16",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
39 "Item 17",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
40 "Item 18",
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
41 };
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
42
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
43 typedef struct {
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
44 mb_animated_menu_t *m;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
45 }app_data_t;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
46
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
47 mbaf_t *app;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
48
302
8b45e7b374b8 Rewrite the menu as a widget style
wycc
parents: 299
diff changeset
49
306
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
50
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
51 void myselect(mb_animated_menu_t *m, int select)
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
52 {
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
53 printf("menu %d is selected\n", select);
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
54 }
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
55
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
56
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
57 app_init_content()
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
58 {
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
59 app_data_t *data = MBAF_DATA(app,app_data_t);
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
60 subject_t *key = MBAF_KB_SUBJECT(app);
297
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
61 char name[255];
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
62 coord_t *l;
e885dc875f30 Implement animation menu
wycc
parents: 296
diff changeset
63 int i;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
64 mb_sprite_t *sprite=app->rootsprite;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
65
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
66 data->m = mb_animated_menu_new(app,app->rootsprite,"item",menus);
306
c981e561ac37 * Keep the font name as the original case.
wycc
parents: 305
diff changeset
67 mb_animated_menu_set_callback(data->m, myselect);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
68 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
69
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
70 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
71 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
72 mb_obj_t *button;
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
73 app_data_t data;
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
74 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
75
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
76 if (argc > 1)
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
77 app = mbaf_init(argv[1], "");
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
78 else
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
79 app = mbaf_init("list", ".libs");
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
80 mbaf_set_data(app,&data);
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
81 app_init_content();
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
82
454
9b8dda201ccb Make naming convention consistent with MadButterfly.
Thinker K.F. Li <thinker@branda.to>
parents: 453
diff changeset
83 mbaf_loop(app);
296
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
84
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
85 return 0;
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
86 }
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
87
2e97e8082d83 * Fix the symbol definition code which does not assume the id is the same as the mbname.
wycc
parents:
diff changeset
88 /* vim: set ts=4 */