Mercurial > MadButterfly
annotate examples/dynamic/text.c @ 289:13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
- It is wrong to compute bounding box.
- location of left-top corner is (text->d_x, text->d_y)
not (text->x, text->y).
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 31 Jan 2009 18:28:50 +0800 |
parents | 22d771e1b710 |
children | 137a73822d48 |
rev | line source |
---|---|
286 | 1 /*! \file |
2 * | |
3 * svg2code_ex is an example that show programmers how to create a | |
4 * menu with MadButterfly. | |
5 * | |
6 */ | |
7 #include <stdio.h> | |
8 #include <mb.h> | |
9 #include <string.h> | |
10 #include "menu.h" | |
11 #include "mbapp.h" | |
12 | |
13 | |
14 MBApp *myApp; | |
15 | |
16 typedef struct { | |
17 shape_t *rect; | |
18 co_aix orx,ory; | |
19 int start_x,start_y; | |
20 observer_t *obs1,*obs2; | |
21 int currentscene; | |
22 }MyAppData; | |
23 | |
24 | |
25 void switch_scene(const mb_timeval_t *tmo, const mb_timeval_t *now,void *arg) | |
26 { | |
27 MyAppData *en = MBAPP_DATA((MBApp *)arg,MyAppData ); | |
28 mb_timeval_t timer,interval; | |
29 shape_t *text = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite,"mytext"); | |
30 | |
31 | |
32 get_now(&timer); | |
33 MB_TIMEVAL_SET(&interval, 1 ,0); | |
34 MB_TIMEVAL_ADD(&timer, &interval); | |
35 mb_tman_timeout( MBApp_getTimer(myApp), &timer, switch_scene, myApp); | |
36 | |
37 en->currentscene = (en->currentscene + 1) % 2; | |
38 printf("xxx\n"); | |
39 if (en->currentscene == 0) { | |
40 sh_text_set_text(text,"This is 0"); | |
41 } else { | |
42 sh_text_set_text(text,"This is 1"); | |
43 } | |
44 rdman_shape_changed(MBAPP_RDMAN(myApp), text); | |
289
13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
Thinker K.F. Li <thinker@branda.to>
parents:
286
diff
changeset
|
45 #if 0 |
13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
Thinker K.F. Li <thinker@branda.to>
parents:
286
diff
changeset
|
46 /* Removed! |
13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
Thinker K.F. Li <thinker@branda.to>
parents:
286
diff
changeset
|
47 * X_MB_handle_connection() will invoke it automatically. |
13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
Thinker K.F. Li <thinker@branda.to>
parents:
286
diff
changeset
|
48 */ |
286 | 49 rdman_redraw_changed(MBAPP_RDMAN(myApp)); |
289
13ce87b6dbf5
Fix bug of sh_text_t that do not update it-self after changes.
Thinker K.F. Li <thinker@branda.to>
parents:
286
diff
changeset
|
50 #endif |
286 | 51 } |
52 | |
53 int main(int argc, char * const argv[]) { | |
54 subject_t *subject; | |
55 mb_button_t *b; | |
56 mb_obj_t *button; | |
57 MyAppData data; | |
58 mb_timeval_t tmo,interval; | |
59 | |
60 if (argc > 1) | |
61 myApp = MBApp_Init(argv[1]); | |
62 else | |
63 myApp = MBApp_Init("mytext"); | |
64 data.currentscene=0; | |
65 MBApp_setData(myApp,&data); | |
66 get_now(&tmo); | |
67 MB_TIMEVAL_SET(&interval, 1 ,0); | |
68 mb_tman_timeout( MBApp_getTimer(myApp), &tmo, switch_scene, myApp); | |
69 | |
70 | |
71 MBApp_loop(myApp); | |
72 | |
73 return 0; | |
74 } | |
75 | |
76 /* vim: set ts=4 */ |