# HG changeset patch # User wycc # Date 1302499025 -28800 # Node ID 167873cd35c52c562711c98deff1f48b7c696ba1 # Parent 2f8e9d66c4c1f0d893fb33c23aa900efd601e941# Parent 6fa411fd9549836f8bbf4196701b044eaa137811 Merge diff -r 6fa411fd9549 -r 167873cd35c5 configure.ac --- a/configure.ac Wed Apr 06 21:35:21 2011 +0800 +++ b/configure.ac Mon Apr 11 13:17:05 2011 +0800 @@ -5,7 +5,8 @@ AC_INIT([MadButterfly],[0.0],[http://www.assembla.com/spaces/MadButterfly]) AC_CONFIG_SRCDIR([README.h]) AC_CONFIG_HEADER([config.h include/mb_config.h]) -AM_INIT_AUTOMAKE([foreign]) +AM_INIT_AUTOMAKE([foreign silent-rules]) +AM_SILENT_RULES([yes]) # Checks for programs. AC_PROG_CC diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/animate.js --- a/nodejs/animate.js Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/animate.js Mon Apr 11 13:17:05 2011 +0800 @@ -11,11 +11,9 @@ function shift_draw(percent) { var x, y; - x = (this.targetx - this.startposx) * percent + this.startposx; y = (this.targety - this.startposy) * percent + this.startposy; this.obj.center.move(x, y); - this._app.refresh(); } function shift(app,obj,shiftx,shifty) { @@ -120,6 +118,7 @@ } + bbox = obj.bbox; bbox.update(); obj.animated_scale = this; @@ -211,6 +210,9 @@ { var now = Date.now(); var i; + + //now = this.lasttime + 300; + //this.lasttime += 300; if (now >= this.end) { this.timer.stop(); @@ -223,7 +225,13 @@ if (now < this.startmove) return; var per = (now-this.startmove)/this.duration/1000; if (per > 1) per = 1; - this.action.draw(per); + try { + for(a in this.action) { + this.action[a].draw(per); + } + } catch(e) { + sys.puts(e); + } } function linear_start() @@ -231,9 +239,20 @@ var self = this; if (this.timer) this.timer.stop(); - this.timer = setInterval(function() { self.update();}, frame_interval); + this.timer = setInterval(function() { + var n = Date.now(); + try { + self.update(); + self._app.refresh(); + } catch(e) { + sys.puts("libnear: "+e); + } + + //while( Date.now() - n < 1000); + }, frame_interval); this.startmove = Date.now()+this.starttime*1000; this.end = this.startmove+this.duration*1000; + this.lasttime = this.startmove; } function linear_stop() { @@ -245,19 +264,21 @@ function linear_finish() { - this.action.draw(1); + for(a in this.action) + this.action[a].draw(1); if (this.callback_end) { this.callback_end(); this.callback_end=null; } } -function linear(action,start, duration) +function linear(app,action,start, duration) { this.action = action; this.duration = duration; this.starttime = start; this.callback_end = null; this.timer=null; + this._app =app; } function linear_callback(cb) @@ -344,12 +365,10 @@ } } -exports.run = function(actions,start,duration,cb) { +exports.run = function(app,actions,start,duration,cb) { var li; - for(a in actions) { - li = new linear(actions[a],start,duration); - li.start(); - } + li = new linear(app,actions,start,duration); + li.start(); li.callbackAtEnd(cb); } exports.runexp=function(actions,start,exp) { diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/component.js --- a/nodejs/component.js Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/component.js Mon Apr 11 13:17:05 2011 +0800 @@ -73,9 +73,13 @@ } Component.prototype.toCoord=function() { - return this.coord; + return this.realize(); } +Component.prototype.set_text=function(text) { + this.realize(); + this.coord.set_text("asdsad"); +} function ComponentManager(app) { diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/coord.cc --- a/nodejs/coord.cc Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/coord.cc Mon Apr 11 13:17:05 2011 +0800 @@ -8,6 +8,7 @@ #include "mb_X_supp.h" #include "mb_tools.h" #include "njs_mb_supp.h" +#include } #include "mbfly_njs.h" @@ -15,7 +16,6 @@ #ifndef ASSERT #define ASSERT(x) #endif - #define OK 0 /*! \page jsgc How to Manage Life-cycle of Objects for Javascript. @@ -81,7 +81,14 @@ FOR_COORDS_PREORDER(coord, child) { child_hdl = (Persistent *)mb_prop_get(&child->obj.props, PROP_JSOBJ); - if (child_hdl == NULL) continue; + /* There is no associated JS object. Perhaps, it is created + * by xnjsmb_coord_clone_from_subtree(). + */ + if(child_hdl == NULL) { + preorder_coord_skip_subtree(child); + continue; + } + SET(*child_hdl, "valid", _false); WRAP(*child_hdl, NULL); child_hdl->Dispose(); @@ -91,7 +98,12 @@ FOR_COORD_SHAPES(child, mem) { mem_hdl = (Persistent *)mb_prop_get(&mem->obj.props, PROP_JSOBJ); - if (mem_hdl == NULL) continue; + /* There is no associated JS object. Perhaps, it is + * created by xnjsmb_coord_clone_from_subtree(). + */ + if(mem_hdl == NULL) + continue; + SET(*mem_hdl, "valid", _false); WRAP(*mem_hdl, NULL); mem_hdl->Dispose(); @@ -189,6 +201,8 @@ return 0; } + if (coord_get_matrix(coord)[idx] == v) return v; + coord_get_matrix(coord)[idx] = v; js_rt = GET(self, "mbrt")->ToObject(); @@ -238,9 +252,20 @@ _xnjsmb_coord_clone_from_subtree_mod(Handle src, Handle ret) { Handle js_rt; Handle ret_obj = ret->ToObject(); + coord_t *ret_coord, *child; + Handle child_obj; js_rt = GET(src, "mbrt")->ToObject(); SET(ret_obj, "mbrt", js_rt); + + /* Only root of the subtree is warpped. Descendants of subtree + * are not wrapped by JS object. We have no any method to access + * children and members of a coord, now. So, it is fine. But, + * sometime later, we will provide APIs for traveling a tree. At + * that time, we need to create wrappers for all descendants. + */ + ret_coord = (coord_t *)UNWRAP(ret_obj); + xnjsmb_coord_mod(ret_obj, ret_coord); } static coord_t * @@ -259,6 +284,7 @@ *err = "can not clone a subtree (allocate memory)"; return NULL; } + rdman_coord_changed(rdman, cloning); return cloning; } @@ -271,7 +297,7 @@ js_rt = GET(self, "mbrt")->ToObject(); ASSERT(js_rt != NULL); rdman = xnjsmb_rt_rdman(js_rt); - + if ((coord->flags & COF_HIDDEN) == 0) return; coord_show(coord); rdman_coord_changed(rdman, coord); } @@ -285,6 +311,7 @@ ASSERT(js_rt != NULL); rdman = xnjsmb_rt_rdman(js_rt); + if ((coord->flags & COF_HIDDEN) != 0) return; coord_hide(coord); rdman_coord_changed(rdman, coord); } @@ -299,6 +326,7 @@ ASSERT(js_rt != NULL); rdman = xnjsmb_rt_rdman(js_rt); + if (coord_get_opacity(coord) == value->NumberValue()) return; coord_set_opacity(coord, value->NumberValue()); rdman_coord_changed(rdman, coord); @@ -379,6 +407,50 @@ x = cc(0)*xx+cc(1)*yy+cc(2); return Number::New(x); } + +static int +xnjsmb_coord_set_text_recursive(coord_t *coord, Handle self, + const char *txt) { + shape_t *sh; + coord_t *child; + Handle rt; + redraw_man_t *rdman; + + FOR_COORD_SHAPES(coord, sh) { + printf("shape type %d\n",sh->obj.obj_type); + if (sh->obj.obj_type == MBO_STEXT) { + sh_stext_set_text(sh, txt); + /* + * Mark changed. + */ + rt = GET(self, "mbrt")->ToObject(); + ASSERT(rt != NULL); + rdman = xnjsmb_rt_rdman(rt); + + if(sh_get_coord(sh)) + rdman_shape_changed(rdman, sh); + return 1; + } + } + for((child) = STAILQ_HEAD((coord)->children); + (child) != NULL; + (child) = STAILQ_NEXT(coord_t, sibling, (child))) { + /* Invalidate members of a coord */ + if ( xnjsmb_coord_set_text_recursive(child, self, txt)) + return 1; + } + return 0; + +} + +static void +xnjsmb_coord_set_text(coord_t *coord, Handle self, + const char *txt) { + printf("text=%s\n",txt); + xnjsmb_coord_set_text_recursive(coord,self,txt); +} + + #undef m #include "coord-inc.h" diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/coord.m4 --- a/nodejs/coord.m4 Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/coord.m4 Mon Apr 11 13:17:05 2011 +0800 @@ -7,6 +7,9 @@ ], [METHOD([add_shape], [xnjsmb_coord_add_shape], (SELF, OBJ([shape], [shape], [shape_t]), ERR), 1, []), + + METHOD([set_text], [xnjsmb_coord_set_text], + (SELF, STR([txt])), 1, []), METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, []), METHOD([clone_from_subtree], [xnjsmb_coord_clone_from_subtree], (SELF, OBJ([src], [coord], [coord_t]), ERR), 1, diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/examples/mce/epg.js --- a/nodejs/examples/mce/epg.js Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/examples/mce/epg.js Mon Apr 11 13:17:05 2011 +0800 @@ -170,28 +170,32 @@ EPG.prototype.getList=function(item,func) { var epgsrv = http.createClient(8080, '211.23.50.144'); - var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+item.Category+'"}'; + for (k in this.maincat[item]) { + sys.puts(k+"--->"+this.maincat[item][k]); + } + var catID = this.maincat[item]['Category']; + sys.puts(catID); + var cmd = '{"Protocol":"EPG-CSP","Command":"SearchRequest","ProgramSub":"'+catID+'"}'; var headers={ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Host':'211.23.50.144:8080', 'User-Agent':'MadButterfly', - 'Content-Type':'application/x-www-form-urlencoded' + 'Content-Type':'application/x-www-form-urlencoded;charset=utf-8' }; - headers['Content-Length'] = cmd.length; + //headers['Content-Length'] = cmd.length; var request = epgsrv.request('POST', '/IPTV_EPG/EPGService.do?timestamp='+new Date().getTime(),headers); var self = this; - sys.puts("aaaa"); var js = ''; - request.write(cmd); + request.write(cmd,encoding='utf-8'); request.end(); request.on('response', function(res) { - sys.puts("connected"); res.on('data',function (data) { js = js + data; }); res.on('end', function () { - res = JSON.parse(js); + res = JSON.parse(unescape(js)); sys.puts("parsed"); + sys.puts(js); func(); }); diff -r 6fa411fd9549 -r 167873cd35c5 nodejs/examples/mce/main.svg --- a/nodejs/examples/mce/main.svg Wed Apr 06 21:35:21 2011 +0800 +++ b/nodejs/examples/mce/main.svg Mon Apr 11 13:17:05 2011 +0800 @@ -1,19 +1,41 @@ - + - + + + + image/svg+xml + + + @@ -28,43 +50,131 @@ + + - - -