# HG changeset patch # User wycc@wycc-desktop # Date 1229433866 -28800 # Node ID b24d7889cbda0db63c6dbe087ecfaf6b811aaeeb # Parent 5c70883c40d571c6e8669972363d90858dcbfe5a * Change the color of click frame * hide active and click and show normal at mouse out diff -r 5c70883c40d5 -r b24d7889cbda examples/dynamic/button.svg --- a/examples/dynamic/button.svg Mon Dec 15 10:17:20 2008 +0800 +++ b/examples/dynamic/button.svg Tue Dec 16 21:24:26 2008 +0800 @@ -30,7 +30,7 @@ inkscape:cx="257.06285" inkscape:cy="365.06674" inkscape:document-units="px" - inkscape:current-layer="layer1" + inkscape:current-layer="btn_click" showgrid="false" inkscape:window-width="1400" inkscape:window-height="978" @@ -41,43 +41,43 @@ + id="stop4068" /> + id="stop4070" /> + id="stop4028" /> + id="stop4030" /> + id="stop4020" /> + id="stop4022" /> + inkscape:vp_x="0 : 526.18109 : 1" + sodipodi:type="inkscape:persp3d" /> @@ -91,107 +91,107 @@ + inkscape:label="bg" + style="display:inline"> + y="282.36218" /> + mbname="btn"> + mbname="btn_active" + style="display:none"> + x="-1.4285715" + height="47.142857" + width="122.85714" + id="rect2727" + style="fill:#00ffff" /> Click Me + sodipodi:role="line">Click Me + inkscape:label="text" + style="display:inline" /> diff -r 5c70883c40d5 -r b24d7889cbda examples/dynamic/main.c --- a/examples/dynamic/main.c Mon Dec 15 10:17:20 2008 +0800 +++ b/examples/dynamic/main.c Tue Dec 16 21:24:26 2008 +0800 @@ -35,6 +35,7 @@ void (*press)(); void *arg; observer_t *obs_move,*obs_out,*obs_press; + mb_progm_t *progm; } mb_button_t; @@ -65,10 +66,16 @@ mb_button_t *btn = (mb_button_t *) arg; engine_t *en = btn->en; + if (btn->progm) { + mb_progm_abort(btn->progm); + btn->progm = NULL; + } printf("mouse out\n"); + COORD_HIDE(btn->click); COORD_HIDE(btn->active); -#if 0 - rdman_coord_changed(btn->en->rdman,btn->root); + COORD_SHOW(btn->normal); +#if 1 + rdman_coord_changed(btn->en->rdman,btn->normal); #endif rdman_redraw_changed(btn->en->rdman); } @@ -92,12 +99,16 @@ mb_word_t *word; printf("Pressed\n"); + if (btn->progm) { + mb_progm_abort(btn->progm); + btn->progm = NULL; + } COORD_SHOW(btn->click); COORD_HIDE(btn->active); rdman_coord_changed(en->rdman,en->button->root_coord); rdman_redraw_changed(en->rdman); - progm = mb_progm_new(1, en->rdman); + btn->progm = progm = mb_progm_new(1, en->rdman); MB_TIMEVAL_SET(&start, 0, 500000); MB_TIMEVAL_SET(&playing, 0, 0); word = mb_progm_next_word(progm, &start, &playing); @@ -113,6 +124,7 @@ char *buf = (char *) malloc(strlen(name)+5); btn->root = (coord_t *) MB_SPRITE_GET_OBJ(sp, name); + printf("btn->root=%x\n",btn->root); sprintf(buf, "%s_normal", name); btn->normal = (coord_t *) MB_SPRITE_GET_OBJ(sp, buf); if (btn->normal == NULL) { @@ -141,9 +153,11 @@ btn->click->matrix[2] = 200; btn->click->matrix[5] = 200; btn->en = en; + printf("btn->root=%x\n",CMOUSE(btn->root)); btn->obs_move = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_MOVE, mb_button_move,btn); btn->obs_press = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_BUT_PRESS, mb_button_pressed,btn); btn->obs_out = subject_add_event_observer(CMOUSE(btn->root), EVT_MOUSE_OUT, mb_button_out,btn); + btn->progm = NULL; rdman_redraw_changed(en->rdman); return btn; }