# HG changeset patch # User wycc # Date 1235223904 -28800 # Node ID c981e561ac37e08af49e1737acb8fcda54257937 # Parent 0231b05552fe64db0e7f2291a7243418287ff377 * Keep the font name as the original case. * Add some new functions for the mb_animated_menu_t widget class. diff -r 0231b05552fe -r c981e561ac37 examples/menu/list.svg --- a/examples/menu/list.svg Sun Feb 15 09:19:59 2009 +0800 +++ b/examples/menu/list.svg Sat Feb 21 21:45:04 2009 +0800 @@ -29,10 +29,10 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.0347223" - inkscape:cx="255.43399" - inkscape:cy="240.5" + inkscape:cx="267.0313" + inkscape:cy="228.90269" inkscape:document-units="px" - inkscape:current-layer="layer1" + inkscape:current-layer="item7" showgrid="false" inkscape:window-width="1124" inkscape:window-height="867" @@ -107,8 +107,9 @@ id="text2395" y="60" x="157.14285" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"> app)); MB_TIMEVAL_SET(&start, 0, 0); - MB_TIMEVAL_SET(&playing, 0, SPEED); + MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); get_now(&now); @@ -158,7 +156,7 @@ lightbar = (coord_t *) m->lightbar; mb_shift_new(0,m->menus_y[m->cur]-coord_y(lightbar),lightbar,word); - MB_TIMEVAL_SET(&start, 0, SPEED); + MB_TIMEVAL_SET(&start, 0, m->speed); MB_TIMEVAL_SET(&playing, 0, 0); word = mb_progm_next_word(progm, &start, &playing); textgroup = (coord_t *) m->objects[m->items[7]]; @@ -196,7 +194,7 @@ progm = mb_progm_new(2, MBAPP_RDMAN(m->app)); MB_TIMEVAL_SET(&start, 0, 0); - MB_TIMEVAL_SET(&playing, 0, SPEED); + MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); get_now(&now); @@ -214,7 +212,7 @@ mb_shift_new(0,m->menus_y[m->cur]-coord_y((coord_t *)m->lightbar),((coord_t *)(m->lightbar)),word); - MB_TIMEVAL_SET(&start, 0, SPEED); + MB_TIMEVAL_SET(&start, 0, m->speed); MB_TIMEVAL_SET(&playing, 0, 0); word = mb_progm_next_word(progm, &start, &playing); mb_visibility_new(VIS_VISIBLE, (coord_t *) m->objects[m->items[0]],word); @@ -241,11 +239,20 @@ progm = mb_progm_new(1, MBAPP_RDMAN(m->app)); MB_TIMEVAL_SET(&start, 0, 0); - MB_TIMEVAL_SET(&playing, 0, SPEED); + MB_TIMEVAL_SET(&playing, 0, m->speed); word = mb_progm_next_word(progm, &start, &playing); get_now(&now); lightbar = (coord_t *) m->lightbar; +#if 1 + // The redraw algorithm has bugs so that the items is not redrawed correctly. We redraw the items under the lightbar to work around it. + // Comment these lines if the algprothm is fixed. + rdman_coord_changed(MBAPP_RDMAN(m->app),m->objects[m->cur]); + if (m->cur != 0) + mb_shift_new(0,0,m->objects[m->cur-1],word); + if (m->cur != 7) + mb_shift_new(0,0,m->objects[m->cur+1],word); +#endif mb_shift_new(0,m->menus_y[m->cur]-coord_y(lightbar),lightbar,word); mb_progm_free_completed(progm); m->ready--; @@ -292,8 +299,15 @@ } } } + +void mb_animated_menu_set_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel)) +{ + m->callback = f; +} void mb_animated_menu_select(mb_animated_menu_t *m) { + if (m->callback) + m->callback(m,m->top+m->cur); } void mb_animated_menu_keyHandler(event_t *ev, void *arg) @@ -355,6 +369,8 @@ m->items = (int *) (m+1); m->menus_y = (int *) (m->items+len); m->objects = (mb_obj_t **) (m->menus_y+len); + m->callback = NULL; + m->speed = 300000; for(i=0;i<9;i++) { m->items[i] = i; snprintf(name,sizeof(name),"%s%d", objnames, i+1); @@ -375,6 +391,23 @@ return m; } + +void mb_animated_menu_set_speed(mb_animated_menu_t *m,int speed) +{ + m->speed = speed*1000; +} + +int mb_animated_menu_get_speed(mb_animated_menu_t *m) +{ + return m->speed/1000; +} + +void myselect(mb_animated_menu_t *m, int select) +{ + printf("menu %d is selected\n", select); +} + + MyApp_InitContent() { MyAppData *data = MBAPP_DATA(myApp,MyAppData); @@ -385,6 +418,7 @@ mb_sprite_t *sprite=myApp->rootsprite; data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",menus); + mb_animated_menu_set_callback(data->m, myselect); } int main(int argc, char * const argv[]) { diff -r 0231b05552fe -r c981e561ac37 tools/svg2code.py --- a/tools/svg2code.py Sun Feb 15 09:19:59 2009 +0800 +++ b/tools/svg2code.py Sat Feb 21 21:45:04 2009 +0800 @@ -489,7 +489,7 @@ pass if style_map.has_key('font-family'): - font_family = style_map['font-family'].lower() + font_family = style_map['font-family'] print >> codefo, 'PANGO_FAMILY(%s,%d,%d)' % (font_family,start,end) pass if style_map.has_key('text-anchor'):