changeset 226:b24d7889cbda

* Change the color of click frame * hide active and click and show normal at mouse out
author wycc@wycc-desktop
date Tue, 16 Dec 2008 21:24:26 +0800
parents 5c70883c40d5
children a6e559fb76d7
files examples/dynamic/button.svg examples/dynamic/main.c
diffstat 2 files changed, 104 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
     <linearGradient
        id="linearGradient4066">
       <stop
-         id="stop4068"
+         style="stop-color:#000000;stop-opacity:0;"
          offset="0"
-         style="stop-color:#000000;stop-opacity:0;" />
+         id="stop4068" />
       <stop
-         id="stop4070"
+         style="stop-color:#000000;stop-opacity:1"
          offset="1"
-         style="stop-color:#000000;stop-opacity:1" />
+         id="stop4070" />
     </linearGradient>
     <linearGradient
        id="linearGradient4026">
       <stop
-         id="stop4028"
+         style="stop-color:#000000;stop-opacity:1;"
          offset="0"
-         style="stop-color:#000000;stop-opacity:1;" />
+         id="stop4028" />
       <stop
-         id="stop4030"
+         style="stop-color:#ffffff;stop-opacity:0;"
          offset="1"
-         style="stop-color:#ffffff;stop-opacity:0;" />
+         id="stop4030" />
     </linearGradient>
     <linearGradient
        id="linearGradient4018">
       <stop
-         id="stop4020"
+         style="stop-color:#000000;stop-opacity:1;"
          offset="0"
-         style="stop-color:#000000;stop-opacity:1;" />
+         id="stop4020" />
       <stop
-         id="stop4022"
+         style="stop-color:#0000ff;stop-opacity:0;"
          offset="1"
-         style="stop-color:#0000ff;stop-opacity:0;" />
+         id="stop4022" />
     </linearGradient>
     <inkscape:perspective
-       sodipodi:type="inkscape:persp3d"
-       inkscape:vp_x="0 : 526.18109 : 1"
+       id="perspective10"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
        inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       id="perspective10" />
+       inkscape:vp_x="0 : 526.18109 : 1"
+       sodipodi:type="inkscape:persp3d" />
   </defs>
   <metadata
      id="metadata7">
@@ -91,107 +91,107 @@
     </rdf:RDF>
   </metadata>
   <g
-     style="display:inline"
-     inkscape:label="bg"
+     id="layer1"
      inkscape:groupmode="layer"
-     id="layer1">
+     inkscape:label="bg"
+     style="display:inline">
     <text
-       id="text4380"
-       y="282.36218"
-       x="235.71429"
+       xml:space="preserve"
        style="font-size:30px;font-style:normal;font-weight:normal;fill:#000000;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"><tspan
-         y="282.36218"
+       x="235.71429"
+       y="282.36218"
+       id="text4380"><tspan
+         sodipodi:role="line"
+         id="tspan4382"
          x="235.71429"
-         id="tspan4382"
-         sodipodi:role="line" /></text>
+         y="282.36218" /></text>
     <g
-       mbname="btn"
+       id="btn"
        transform="translate(148.57143,98.571429)"
-       id="btn">
+       mbname="btn">
       <g
-         style="display:none"
-         mbname="btn_normal"
+         frame="normal"
+         id="btn_normal"
          transform="translate(148.57143,98.571429)"
-         id="btn_normal"
-         frame="normal">
+         mbname="btn_normal"
+         style="display:none">
         <rect
-           style="fill:#0000ff"
-           id="rect2651"
-           width="122.85714"
-           height="47.142857"
-           x="-1.4285715"
-           y="1.4285747"
+           ry="5.0559778"
            rx="6.0995407"
-           ry="5.0559778" />
+           y="1.4285747"
+           x="-1.4285715"
+           height="47.142857"
+           width="122.85714"
+           id="rect2651"
+           style="fill:#0000ff" />
         <text
-           xml:space="preserve"
-           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"
-           x="10.000002"
+           id="text2653"
            y="32.85714"
-           id="text2653"><tspan
-             sodipodi:role="line"
+           x="10.000002"
+           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"><tspan
+             y="32.85714"
+             x="10.000002"
              id="tspan2655"
-             x="10.000002"
-             y="32.85714">Click Me</tspan></text>
+             sodipodi:role="line">Click Me</tspan></text>
       </g>
       <g
-         style=""
-         mbname="btn_active"
+         frame="active"
+         id="btn_active"
          transform="translate(148.57143,98.571429)"
-         id="btn_active"
-         frame="active">
+         mbname="btn_active"
+         style="display:none">
         <rect
-           style="fill:#00ffff"
-           id="rect2727"
-           width="122.85714"
-           height="47.142857"
-           x="-1.4285715"
+           ry="5.0559778"
+           rx="6.0995407"
            y="1.4285747"
-           rx="6.0995407"
-           ry="5.0559778" />
+           x="-1.4285715"
+           height="47.142857"
+           width="122.85714"
+           id="rect2727"
+           style="fill:#00ffff" />
         <text
-           xml:space="preserve"
-           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"
+           id="text2729"
+           y="32.85714"
            x="10.000002"
-           y="32.85714"
-           id="text2729"><tspan
-             sodipodi:role="line"
+           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"><tspan
+             y="32.85714"
+             x="10.000002"
              id="tspan2731"
-             x="10.000002"
-             y="32.85714">Click Me</tspan></text>
+             sodipodi:role="line">Click Me</tspan></text>
       </g>
       <g
-         style="display:none"
-         mbname="btn_click"
+         frame="click"
+         id="btn_click"
          transform="translate(148.57143,98.571429)"
-         id="btn_click"
-         frame="click">
+         mbname="btn_click"
+         style="">
         <rect
-           style="fill:#0000ff"
-           id="rect2734"
-           width="122.85714"
-           height="47.142857"
-           x="-1.4285715"
+           ry="5.0559778"
+           rx="6.0995407"
            y="1.4285747"
-           rx="6.0995407"
-           ry="5.0559778" />
+           x="-1.4285715"
+           height="47.142857"
+           width="122.85714"
+           id="rect2734"
+           style="fill:#ff0000" />
         <text
-           xml:space="preserve"
-           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"
+           id="text2736"
+           y="32.85714"
            x="10.000002"
-           y="32.85714"
-           id="text2736"><tspan
-             sodipodi:role="line"
+           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"><tspan
+             y="32.85714"
+             x="10.000002"
              id="tspan2738"
-             x="10.000002"
-             y="32.85714">Click Me</tspan></text>
+             sodipodi:role="line">Click Me</tspan></text>
       </g>
     </g>
   </g>
   <g
-     style="display:inline"
-     inkscape:label="text"
+     inkscape:groupmode="layer"
      id="layer2"
-     inkscape:groupmode="layer" />
+     inkscape:label="text"
+     style="display:inline" />
 </svg>
--- 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;
 }