Mercurial > MadButterfly
changeset 285:248a40d51473
Check in test program for sh_text_set_text for debugging. It is not working yet.
author | wycc |
---|---|
date | Sat, 31 Jan 2009 16:52:28 +0800 |
parents | 046a02a93fd9 |
children | 22d771e1b710 |
files | examples/dynamic/Makefile.am examples/dynamic/mbapp.c examples/dynamic/scene.svg src/redraw_man.c src/shape_text.c tools/svg2code.py |
diffstat | 6 files changed, 72 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/dynamic/Makefile.am Sat Jan 31 13:03:56 2009 +0800 +++ b/examples/dynamic/Makefile.am Sat Jan 31 16:52:28 2009 +0800 @@ -9,7 +9,7 @@ make $(<:.svg=.o) gcc -shared -o $@ $(<:.svg=.o) -noinst_PROGRAMS = dynamic hello +noinst_PROGRAMS = dynamic hello text EXTRA_DIST = menu.svg button.svg dynamic_SOURCES = main.c mbapp.c mbapp.h mbbutton.c mbbutton.h @@ -26,4 +26,7 @@ hello_LDADD = $(top_builddir)/src/libmbfly.la +text_SOURCES = text.c mbapp.c mbapp.h +text_LDFLAGS = @pangocairo_LIBS@ +text_LDADD = $(top_builddir)/src/libmbfly.la
--- a/examples/dynamic/mbapp.c Sat Jan 31 13:03:56 2009 +0800 +++ b/examples/dynamic/mbapp.c Sat Jan 31 16:52:28 2009 +0800 @@ -11,6 +11,7 @@ app->rdman = X_MB_rdman(rt); app->rootsprite= sprite_load(module,app->rdman, app->rdman->root_coord); rdman_attach_backend(app->rdman, rt); + MB_SPRITE_GOTO_SCENE(app->rootsprite, 1); return app; }
--- a/examples/dynamic/scene.svg Sat Jan 31 13:03:56 2009 +0800 +++ b/examples/dynamic/scene.svg Sat Jan 31 16:52:28 2009 +0800 @@ -36,12 +36,12 @@ <defs id="defs2385"> <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 240 : 1" + id="perspective2391" + inkscape:persp3d-origin="320 : 160 : 1" + inkscape:vp_z="640 : 240 : 1" inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="640 : 240 : 1" - inkscape:persp3d-origin="320 : 160 : 1" - id="perspective2391" /> + inkscape:vp_x="0 : 240 : 1" + sodipodi:type="inkscape:persp3d" /> </defs> <metadata id="metadata2388"> @@ -67,39 +67,58 @@ </ns0:scenes> </metadata> <g - id="layer1" + inkscape:groupmode="layer" inkscape:label="Layer 1" - inkscape:groupmode="layer"> + id="layer1"> <g - id="s7737" - style="display:none"> - <text - id="text2554" - y="189.57446" - x="188.4539" - 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" - xml:space="preserve"><tspan - y="189.57446" - x="188.4539" - id="tspan2556" - sodipodi:role="line">This is scene 1</tspan></text> - </g> - <g - id="s4405" - style="display:none"> + style="display:none" + opacity="0.5" + id="s7737"> <text xml:space="preserve" 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" - x="196.19858" - y="199.90071" - id="text2576"><tspan + x="188.4539" + y="189.57446" + id="text2554"><tspan sodipodi:role="line" - id="tspan2578" - x="196.19858" - y="199.90071">This is scene 2</tspan></text> + id="tspan2556" + x="188.4539" + y="189.57446">This is scene 1</tspan></text> + <rect + style="fill:#00d300;fill-opacity:1;stroke:#00d300;stroke-opacity:1" + id="rect2410" + width="233.63121" + height="24.524822" + x="158.76596" + y="131.48936" + rx="4.0216751" + ry="5.0559778" /> </g> <g - style="" - id="s4702" /> + style="display:none" + id="s4405"> + <text + id="text2576" + y="199.90071" + x="196.19858" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:0.5;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + y="199.90071" + x="196.19858" + id="tspan2578" + sodipodi:role="line">This is scene 2aaaaaaaa</tspan></text> + <rect + ry="5.0559778" + rx="4.0216751" + y="127.61702" + x="157.47517" + height="24.524822" + width="289.13477" + id="rect2387" + style="fill:#0068d3;fill-opacity:1;stroke:#00d300;stroke-opacity:1" /> + </g> + <g + id="s4702" + style="" /> </g> </svg>
--- a/src/redraw_man.c Sat Jan 31 13:03:56 2009 +0800 +++ b/src/redraw_man.c Sat Jan 31 16:52:28 2009 +0800 @@ -1024,7 +1024,7 @@ set_shape_stroke_param(shape, cr); stroke_path(rdman); } - } + } } #ifndef UNITTEST @@ -1152,7 +1152,8 @@ if(dirty && coord->flags & COF_OWN_CANVAS) { update_canvas_2_parent(rdman, coord); clean_canvas_black(coord->canvas, rdman->w, rdman->h); - } + printf("update\n"); + } return dirty; }
--- a/src/shape_text.c Sat Jan 31 13:03:56 2009 +0800 +++ b/src/shape_text.c Sat Jan 31 16:52:28 2009 +0800 @@ -110,17 +110,17 @@ //printf("x=%f y=%f text=%s ascent=%d,descent=%d,width=%d height=%d\n", x,y,text->data,PANGO_ASCENT(extents), PANGO_DESCENT(extents), extents.width, extents.height); ASSERT(r == OK); - text->d_x = x; - text->d_y = y-text->font_size; + text->d_x = x-5; + text->d_y = y-PANGO_DESCENT(extents)+5; shw = shape->stroke_width / 2; /* FIXME: It is unreasonable that a font exceed it's bbox. * We add 5 pixels in get right bbox. But, it is unreasonable. */ - poses[0][0] = x + extents.x - 5 - shw; - poses[0][1] = y + extents.y - 5 - shw; - poses[1][0] = poses[0][0] + extents.width + 10 + shape->stroke_width; - poses[1][1] = poses[0][1] + extents.height + 10 + shape->stroke_width; + poses[0][0] = x + extents.x - shw; + poses[0][1] = y + extents.y - shw; + poses[1][0] = poses[0][0] + extents.width + shape->stroke_width; + poses[1][1] = poses[0][1] + extents.height + shape->stroke_width; geo_from_positions(shape->geo, 2, poses); /*! \todo Support ratation for shape_text. */ } @@ -136,10 +136,11 @@ } text->layout = pango_cairo_create_layout(cr); desc = pango_font_description_from_string("Sans Bold"); + cairo_set_source_rgb (cr, 0, 0, 0); pango_layout_set_font_description (text->layout, desc); - pango_cairo_update_layout(cr,text->layout); pango_layout_set_text(text->layout,text->data,strlen(text->data)); pango_layout_set_attributes(text->layout, text->attrs); + pango_cairo_update_layout(cr,text->layout); } static void draw_text(sh_text_t *text, cairo_t *cr) { sh_text_P_generate_layout(text, cr);
--- a/tools/svg2code.py Sat Jan 31 13:03:56 2009 +0800 +++ b/tools/svg2code.py Sat Jan 31 16:52:28 2009 +0800 @@ -134,7 +134,7 @@ try: opacity = float(node.getAttribute('opacity')) except: - opacity = 1.0 + opacity = 0.5 pass if prop_map.has_key('fill'): @@ -568,6 +568,11 @@ text_id.encode('utf8'), u''.join(txt_strs).encode('utf8'), x, y, coord_id.encode('utf8')) translate_style(text, coord_id, codefo, doc, 'TEXT_') + if text.hasAttribute('mbname'): + ## \note mbname declare that this node should be in the + # symbol table. + mbname = text.getAttribute('mbname') + print >> codefo, 'ADD_SYMBOL([%s])dnl' % (mbname) pass pass