changeset 344:ab7f3c00fd05

Implement PMNG viewer
author wycc
date Sun, 08 Mar 2009 11:46:09 +0800
parents 5465ff071b47
children d04085404583
files examples/menu/Makefile.am examples/menu/animated_menu.c examples/menu/animated_menu.h examples/menu/browser.svg examples/menu/filebrowser.c
diffstat 5 files changed, 322 insertions(+), 256 deletions(-) [+]
line wrap: on
line diff
--- a/examples/menu/Makefile.am	Sun Mar 08 10:13:44 2009 +0800
+++ b/examples/menu/Makefile.am	Sun Mar 08 11:46:09 2009 +0800
@@ -34,7 +34,7 @@
 
 menu_SOURCES = main.c animated_menu.c animated_menu.h
 nodist_menu_SOURCES = 
-CFLAGS = @pangocairo_CFLAGS@ 
+CFLAGS = @pangocairo_CFLAGS@ -g
 menu_CFLAGS = @pangocairo_CFLAGS@ 
 menu_LDFLAGS = @pangocairo_LIBS@ 
 menu_LDADD = $(top_builddir)/src/libmbfly.la
--- a/examples/menu/animated_menu.c	Sun Mar 08 10:13:44 2009 +0800
+++ b/examples/menu/animated_menu.c	Sun Mar 08 11:46:09 2009 +0800
@@ -4,6 +4,7 @@
 //#include "menu.h"
 #include "mbapp.h"
 #include <animated_menu.h>
+static void mb_animated_menu_update(mb_animated_menu_t *m);
 static void set_text(coord_t *g, char *text)
 {
     geo_t *geo;
@@ -204,15 +205,18 @@
     if (m->cur > 5) {
 	m->cur--;
         mb_animated_menu_moveLightBar(m);
+	mb_animated_menu_update(m);
     } else {
         if (m->top > 0) {
 	    m->top--;
             mb_animated_menu_fillMenuContentUp(m);
+	    mb_animated_menu_update(m);
         } else {
 	    if (m->cur == 0) 
 	        return;
 	    m->cur--;
             mb_animated_menu_moveLightBar(m);
+	    mb_animated_menu_update(m);
 	}
     }
 }
@@ -223,25 +227,38 @@
 	if (m->top+m->cur <= m->max) {
 	    m->cur++;
             mb_animated_menu_moveLightBar(m);
+	    mb_animated_menu_update(m);
 	}
     } else  {
         if ((m->top+8) < m->max-1) {
 	    m->top++;
             mb_animated_menu_fillMenuContentDown(m);
+	    mb_animated_menu_update(m);
         } else {
    	    if (m->cur+m->top < m->max-1) {
 	        m->cur++;
                 mb_animated_menu_moveLightBar(m);
+	        mb_animated_menu_update(m);
 	    } else
 	        return;
 	}
     }
 }
 
+void mb_animated_menu_set_update_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel))
+{
+   m->update_callback = f;
+}
 void mb_animated_menu_set_callback(mb_animated_menu_t *m, void (*f)(mb_animated_menu_t *m, int sel))
 {
    m->callback = f;
 }
+static void mb_animated_menu_update(mb_animated_menu_t *m)
+{
+   if (m->update_callback)
+	   m->update_callback(m,m->top+m->cur);
+
+}
 static void mb_animated_menu_select(mb_animated_menu_t *m)
 {
    if (m->callback)
@@ -326,6 +343,7 @@
     m->menus_y = (int *) (m->items+ii);
     m->objects = (mb_obj_t **) (m->menus_y+ii);
     m->callback = NULL;
+    m->update_callback = NULL;
     m->speed = 300000;
     for(i=0;i<9;i++) {
         m->items[i] = i;
--- a/examples/menu/animated_menu.h	Sun Mar 08 10:13:44 2009 +0800
+++ b/examples/menu/animated_menu.h	Sun Mar 08 11:46:09 2009 +0800
@@ -14,6 +14,7 @@
 	mb_obj_t **objects;
 	mb_obj_t *lightbar;
 	void (*callback)(struct _mb_animated_menu *m, int sel);
+	void (*update_callback)(struct _mb_animated_menu *m, int sel);
 	mb_progm_t *progm;
 	X_kb_event_t pending_key;
 } mb_animated_menu_t;
--- a/examples/menu/browser.svg	Sun Mar 08 10:13:44 2009 +0800
+++ b/examples/menu/browser.svg	Sun Mar 08 11:46:09 2009 +0800
@@ -43,51 +43,51 @@
     <linearGradient
        id="linearGradient3183">
       <stop
-         style="stop-color:#0000ff;stop-opacity:1;"
+         id="stop3185"
          offset="0"
-         id="stop3185" />
+         style="stop-color:#0000ff;stop-opacity:1;" />
       <stop
-         style="stop-color:#505050;stop-opacity:1;"
+         id="stop3187"
          offset="1"
-         id="stop3187" />
+         style="stop-color:#505050;stop-opacity:1;" />
     </linearGradient>
     <inkscape:perspective
-       id="perspective10"
-       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
+       sodipodi:type="inkscape:persp3d"
        inkscape:vp_x="0 : 526.18109 : 1"
-       sodipodi:type="inkscape:persp3d" />
-    <linearGradient
-       inkscape:collect="always"
-       xlink:href="#linearGradient3183"
-       id="linearGradient3189"
-       x1="0"
-       y1="239.5"
-       x2="719.99998"
-       y2="239.5"
-       gradientUnits="userSpaceOnUse" />
-    <inkscape:perspective
-       id="perspective2495"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
        inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
-       inkscape:vp_y="0 : 1000 : 0"
+       id="perspective10" />
+    <linearGradient
+       gradientUnits="userSpaceOnUse"
+       y2="239.5"
+       x2="719.99998"
+       y1="239.5"
+       x1="0"
+       id="linearGradient3189"
+       xlink:href="#linearGradient3183"
+       inkscape:collect="always" />
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
        inkscape:vp_x="0 : 526.18109 : 1"
-       sodipodi:type="inkscape:persp3d" />
-    <inkscape:perspective
-       id="perspective2496"
-       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="perspective2495" />
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
        inkscape:vp_x="0 : 526.18109 : 1"
-       sodipodi:type="inkscape:persp3d" />
-    <inkscape:perspective
-       id="perspective2498"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
        inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
-       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       id="perspective2496" />
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 526.18109 : 1"
        inkscape:vp_y="0 : 1000 : 0"
-       inkscape:vp_x="0 : 526.18109 : 1"
-       sodipodi:type="inkscape:persp3d" />
+       inkscape:vp_z="744.09448 : 526.18109 : 1"
+       inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+       id="perspective2498" />
   </defs>
   <metadata
      id="metadata7">
@@ -103,278 +103,279 @@
        current="1" />
   </metadata>
   <g
-     inkscape:groupmode="layer"
+     sodipodi:insensitive="true"
+     inkscape:label="Background"
      id="layer2"
-     inkscape:label="Background"
-     sodipodi:insensitive="true">
+     inkscape:groupmode="layer">
     <rect
-       style="opacity:1;fill:url(#linearGradient3189);fill-opacity:1;stroke:#000000;stroke-width:0.9993065;stroke-opacity:1"
-       id="rect3181"
+       y="-0.50034672"
+       x="0.49965325"
+       height="480.0007"
        width="719.00067"
-       height="480.0007"
-       x="0.49965325"
-       y="-0.50034672" />
+       id="rect3181"
+       style="opacity:1;fill:url(#linearGradient3189);fill-opacity:1;stroke:#000000;stroke-width:0.9993065;stroke-opacity:1" />
   </g>
   <g
-     id="layer1"
+     inkscape:label="Layer 1"
      inkscape:groupmode="layer"
-     inkscape:label="Layer 1">
+     id="layer1">
     <g
-       transform="translate(-124.18599,-2.85715)"
+       style="fill-opacity:1"
+       mbname="item1"
        id="item1"
-       mbname="item1"
-       style="fill-opacity:1">
+       transform="translate(-124.18599,-2.85715)">
       <text
-         id="text2395"
-         y="60"
-         x="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Times New Roman;-inkscape-font-specification:Times New Roman Bold"
+         sodipodi:linespacing="125%"
          xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item1text"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Times New Roman;-inkscape-font-specification:Times New Roman Bold"
+         x="157.14285"
+         y="60"
+         id="text2395"><tspan
+           sodipodi:role="line"
+           id="tspan2397"
+           x="157.14285"
            y="60"
+           mbname="item1text">item111111111111111111111111111111</tspan></text>
+    </g>
+    <g
+       style="fill-opacity:1"
+       mbname="item2"
+       id="item2"
+       transform="translate(-124.67566,39.689836)">
+      <text
+         sodipodi:linespacing="125%"
+         xml:space="preserve"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+         x="157.14285"
+         y="60"
+         id="text2421"><tspan
+           sodipodi:role="line"
+           id="tspan2423"
            x="157.14285"
-           id="tspan2397"
-           sodipodi:role="line">item111111111111111111111111111111</tspan></text>
+           y="60"
+           mbname="item2text">item1111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-124.67566,39.689836)"
-       id="item2"
-       mbname="item2"
-       style="fill-opacity:1">
+       style="fill-opacity:1"
+       mbname="item3"
+       id="item3"
+       transform="translate(-123.00225,82.236798)">
       <text
-         id="text2421"
-         y="60"
+         sodipodi:linespacing="125%"
+         xml:space="preserve"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
          x="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
-         xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item2text"
+         y="60"
+         id="item3text"><tspan
+           sodipodi:role="line"
+           id="tspan2429"
+           x="157.14285"
            y="60"
-           x="157.14285"
-           id="tspan2423"
-           sodipodi:role="line">item1111111111111111111</tspan></text>
+           mbname="item3text">item1111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-123.00225,82.236798)"
-       id="item3"
-       mbname="item3"
-       style="fill-opacity:1">
+       style="fill-opacity:1"
+       mbname="item4"
+       id="item4"
+       transform="translate(-123.49193,124.7838)">
       <text
-         id="item3text"
-         y="60"
+         sodipodi:linespacing="125%"
+         xml:space="preserve"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
          x="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
-         xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item3text"
+         y="60"
+         id="item4text"><tspan
+           sodipodi:role="line"
+           id="tspan2435"
+           x="157.14285"
            y="60"
-           x="157.14285"
-           id="tspan2429"
-           sodipodi:role="line">item1111111111111111111</tspan></text>
+           mbname="item4text">item1111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-123.49193,124.7838)"
-       id="item4"
-       mbname="item4"
-       style="fill-opacity:1">
+       style="fill-opacity:1"
+       mbname="item5"
+       id="item5"
+       transform="translate(-125.0227,167.33077)">
       <text
-         id="item4text"
-         y="60"
+         sodipodi:linespacing="125%"
+         xml:space="preserve"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
          x="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+         y="60"
+         id="item5text"><tspan
+           sodipodi:role="line"
+           id="tspan2441"
+           x="157.14285"
+           y="60"
+           mbname="item5text">item1111111111111111111</tspan></text>
+    </g>
+    <g
+       style="fill-opacity:1"
+       mbname="item6"
+       id="item6"
+       transform="translate(-125.51237,209.87776)">
+      <text
+         sodipodi:linespacing="125%"
          xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item4text"
+         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+         x="157.14285"
+         y="60"
+         id="item6text"><tspan
+           sodipodi:role="line"
+           id="tspan2447"
+           x="157.14285"
            y="60"
-           x="157.14285"
-           id="tspan2435"
-           sodipodi:role="line">item1111111111111111111</tspan></text>
+           mbname="item6text">item1111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-125.0227,167.33077)"
-       id="item5"
-       mbname="item5"
-       style="fill-opacity:1">
+       style="fill-opacity:1"
+       mbname="item7"
+       id="item7"
+       transform="translate(-123.83896,252.42474)">
       <text
-         id="item5text"
-         y="60"
+         sodipodi:linespacing="125%"
+         xml:space="preserve"
+         style="font-size:24px;font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Oblique"
          x="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
-         xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item5text"
+         y="60"
+         id="item7text"><tspan
+           sodipodi:role="line"
+           id="tspan2453"
+           x="157.14285"
            y="60"
-           x="157.14285"
-           id="tspan2441"
-           sodipodi:role="line">item1111111111111111111</tspan></text>
+           mbname="item7text">item111111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-125.51237,209.87776)"
-       id="item6"
-       mbname="item6"
-       style="fill-opacity:1">
+       style="fill-opacity:1"
+       mbname="item8"
+       id="item8"
+       transform="translate(-124.32864,294.97172)">
       <text
-         id="item6text"
-         y="60"
+         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="157.14285"
-         style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold"
+         y="60"
+         id="item8text"><tspan
+           sodipodi:role="line"
+           id="tspan2459"
+           x="157.14285"
+           y="60"
+           mbname="item8text">item111111111111111111111</tspan></text>
+    </g>
+    <g
+       style="fill-opacity:1"
+       mbname="item9"
+       id="item9"
+       transform="translate(-127.53281,337.5187)">
+      <text
          xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item6text"
+         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="157.14285"
+         y="60"
+         id="text2407"
+         mbname=""><tspan
+           sodipodi:role="line"
+           id="tspan2409"
+           x="157.14285"
            y="60"
-           x="157.14285"
-           id="tspan2447"
-           sodipodi:role="line">item1111111111111111111</tspan></text>
+           mbname="item9text">item111111111111111111111</tspan></text>
     </g>
     <g
-       transform="translate(-123.83896,252.42474)"
-       id="item7"
-       mbname="item7"
-       style="fill-opacity:1">
-      <text
-         id="item7text"
-         y="60"
-         x="157.14285"
-         style="font-size:24px;font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Oblique"
+       id="preview"
+       mbname="preview">
+      <rect
+         style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-opacity:1"
+         id="rect2418"
+         width="252.24159"
+         height="237.74495"
+         x="449.39597"
+         y="26.738289"
+         rx="10"
+         ry="10" />
+    </g>
+    <flowRoot
+       style="font-size:22px;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="flowRoot2420"
+       xml:space="preserve"><flowRegion
+         id="flowRegion2422"><rect
+           style="font-size:22px;fill:#ffffff;fill-opacity:1"
+           y="295.40942"
+           x="458.09393"
+           height="162.36241"
+           width="240.64427"
+           id="rect2424" /></flowRegion><flowPara
+         id="flowPara2426" /></flowRoot>    <g
+       id="fileinfo"
+       mbname="fileinfo">
+      <flowRoot
          xml:space="preserve"
-         sodipodi:linespacing="125%"><tspan
-           mbname="item7text"
-           y="60"
-           x="157.14285"
-           id="tspan2453"
-           sodipodi:role="line">item111111111111111111111</tspan></text>
-    </g>
+         id="flowRoot2582"
+         style="font-size:24px;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"
+         mbname="fileinfo"><flowRegion
+           id="flowRegion3200"><rect
+             id="rect3202"
+             width="244.51006"
+             height="172.99327"
+             x="454.22815"
+             y="287.67786"
+             style="font-size:24px" /></flowRegion><flowPara
+           id="flowPara3204"
+           style="fill:#ffffff;fill-opacity:1">File infiormation</flowPara></flowRoot>    </g>
+    <text
+       id="text2427"
+       y="185.23492"
+       x="155.59731"
+       style="font-size:40px;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
+         id="tspan2430"
+         sodipodi:role="line" /></text>
+    <text
+       id="text2429"
+       y="393.02014"
+       x="236.7785"
+       style="font-size:40px;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
+         id="tspan2431"
+         sodipodi:role="line" /></text>
+  </g>
+  <g
+     inkscape:label="lightbar"
+     id="layer4"
+     inkscape:groupmode="layer">
     <g
-       transform="translate(-124.32864,294.97172)"
-       id="item8"
-       mbname="item8"
-       style="fill-opacity:1">
-      <text
-         id="item8text"
-         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"><tspan
-           mbname="item8text"
-           y="60"
-           x="157.14285"
-           id="tspan2459"
-           sodipodi:role="line">item111111111111111111111</tspan></text>
-    </g>
-    <g
-       transform="translate(-127.53281,337.5187)"
-       id="item9"
-       mbname="item9"
-       style="fill-opacity:1">
-      <text
-         mbname=""
-         id="text2407"
-         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"><tspan
-           mbname="item9text"
-           y="60"
-           x="157.14285"
-           id="tspan2409"
-           sodipodi:role="line">item111111111111111111111</tspan></text>
-    </g>
-    <g
-       mbname="preview"
-       id="preview">
+       style="stroke:none"
+       id="item_lightbar"
+       transform="matrix(0.9148913,0,0,1,17.648985,179.69752)"
+       mbname="item_lightbar">
+      <rect
+         ry="10"
+         rx="10.000001"
+         transform="matrix(0.9999958,-2.895334e-3,0,1,0,0)"
+         y="31.140766"
+         x="0.19951171"
+         height="29.190758"
+         width="442.8623"
+         id="rect3191"
+         style="opacity:0.3669725;fill:#001f41;fill-opacity:1;stroke:none;stroke-width:0.99680871;stroke-opacity:1" />
       <rect
          ry="10"
          rx="10"
-         y="26.738289"
-         x="449.39597"
-         height="237.74495"
-         width="252.24159"
-         id="rect2418"
-         style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-opacity:1" />
-    </g>
-    <flowRoot
-       xml:space="preserve"
-       id="flowRoot2420"
-       style="font-size:22px;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"><flowRegion
-         id="flowRegion2422"><rect
-           id="rect2424"
-           width="240.64427"
-           height="162.36241"
-           x="458.09393"
-           y="295.40942"
-           style="font-size:22px;fill:#ffffff;fill-opacity:1" /></flowRegion><flowPara
-         id="flowPara2426" /></flowRoot>    <g
-       mbname="fileinfo"
-       id="fileinfo">
-      <flowRoot
-         mbname="fileinfo"
-         style="font-size:24px;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"
-         id="flowRoot2582"
-         xml:space="preserve"><flowRegion
-           id="flowRegion3200"><rect
-             style="font-size:24px"
-             y="287.67786"
-             x="454.22815"
-             height="172.99327"
-             width="244.51006"
-             id="rect3202" /></flowRegion><flowPara
-           style="fill:#ffffff;fill-opacity:1"
-           id="flowPara3204">File infiormation</flowPara></flowRoot>    </g>
-    <text
-       xml:space="preserve"
-       style="font-size:40px;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"
-       x="155.59731"
-       y="185.23492"
-       id="text2427"><tspan
-         sodipodi:role="line"
-         id="tspan2430" /></text>
-    <text
-       xml:space="preserve"
-       style="font-size:40px;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"
-       x="236.7785"
-       y="393.02014"
-       id="text2429"><tspan
-         sodipodi:role="line"
-         id="tspan2431" /></text>
-  </g>
-  <g
-     inkscape:groupmode="layer"
-     id="layer4"
-     inkscape:label="lightbar">
-    <g
-       mbname="item_lightbar"
-       transform="matrix(0.9148913,0,0,1,17.648985,179.69752)"
-       id="item_lightbar"
-       style="stroke:none">
-      <rect
-         style="opacity:0.3669725;fill:#001f41;fill-opacity:1;stroke:none;stroke-width:0.99680871;stroke-opacity:1"
-         id="rect3191"
-         width="442.8623"
+         transform="matrix(0.9999958,-2.8953343e-3,0,1,0,0)"
+         y="27.920256"
+         x="-4.099226"
          height="29.190758"
-         x="0.19951171"
-         y="31.140766"
-         transform="matrix(0.9999958,-2.895334e-3,0,1,0,0)"
-         rx="10.000001"
-         ry="10" />
-      <rect
-         style="opacity:0.3669725;fill:#eafbf3;fill-opacity:1;stroke:none;stroke-width:0.99680871;stroke-opacity:1"
+         width="442.86224"
          id="rect2405"
-         width="442.86224"
-         height="29.190758"
-         x="-4.099226"
-         y="27.920256"
-         transform="matrix(0.9999958,-2.8953343e-3,0,1,0,0)"
-         rx="10"
-         ry="10" />
+         style="opacity:0.3669725;fill:#eafbf3;fill-opacity:1;stroke:none;stroke-width:0.99680871;stroke-opacity:1" />
     </g>
     <image
-       y="98.114113"
-       x="514.40265"
-       id="image2500"
+       mbname="previewimg"
+       xlink:href="../svg2code_ex/dsc_3241.png"
+       sodipodi:absref="../svg2code_ex/dsc_3241.png"
+       width="100"
        height="66"
-       width="100"
-       sodipodi:absref="../svg2code_ex/dsc_3241.png"
-       xlink:href="../svg2code_ex/dsc_3241.png" />
+       id="previewimg"
+       x="514.40265"
+       y="98.114113" />
   </g>
 </svg>
--- a/examples/menu/filebrowser.c	Sun Mar 08 10:13:44 2009 +0800
+++ b/examples/menu/filebrowser.c	Sun Mar 08 11:46:09 2009 +0800
@@ -65,6 +65,51 @@
 }
 
 
+void mypreview(MyAppData *data, char *path)
+{
+    mb_img_data_t *img = MB_IMG_LDR_LOAD(rdman_img_ldr(MBAPP_RDMAN(myApp)), path);
+    shape_t *obj = (shape_t *) MB_SPRITE_GET_OBJ(myApp->rootsprite, "previewimg");
+
+    printf("Preview %s\n",path);
+    if (img) {
+	    printf("image %d %d\n",img->w,img->h);
+	    sh_image_set_img_data(obj,img,0,0,img->w,img->h);
+	    sh_image_transform(obj);
+	    rdman_shape_changed(MBAPP_RDMAN(myApp),obj);
+            rdman_redraw_changed(MBAPP_RDMAN(myApp));
+    }
+}
+
+int endWith(char *path, char *ext)
+{
+    int i;
+    char *s;
+
+    s = path+strlen(path)-1;
+    for(i=strlen(ext)-1;i>=0;i--) {
+	    if (*s != ext[i]) return 0;
+	    s--;
+	    if (s < path) return 0;
+    }
+    return 1;
+}
+
+void myupdate(mb_animated_menu_t *m, int select)
+{
+    MyAppData *data = MBAPP_DATA(myApp,MyAppData);
+    char *s = data->titles[select];
+    char path[1024];
+
+    printf("check %s\n",s);
+
+    if (endWith(s,".jpg") || endWith(s,".png")) {
+    	    snprintf(path,1024,"%s%s", data->curDir,data->titles[select]);
+	    mypreview(data,path);
+    }
+}
+
+
+
 struct fileinfo *fileinfo_new()
 {
     struct fileinfo *f = (struct fileinfo *) malloc(sizeof(struct fileinfo));
@@ -152,6 +197,7 @@
     
     data->m = mb_animated_menu_new(myApp,myApp->rootsprite,"item",NULL);
     mb_animated_menu_set_callback(data->m, myselect);
+    mb_animated_menu_set_update_callback(data->m, myupdate);
     data->curDir = NULL;
     data->nFiles=0;
     MyApp_fillDirInfo(myApp,dir);