# HG changeset patch # User Thinker K.F. Li # Date 1283193361 -28800 # Node ID 7ec13634c97dac0280b7f0168e0a2c8f8636c67b # Parent 0899dcac441c451de6a8d556dc023d84f9411453 Add holder for animate diff -r 0899dcac441c -r 7ec13634c97d nodejs/animate.js --- a/nodejs/animate.js Tue Aug 31 01:26:22 2010 +0800 +++ b/nodejs/animate.js Tue Aug 31 02:36:01 2010 +0800 @@ -112,3 +112,35 @@ exports.scale = scale; scale.prototype.start = scale_draw; scale.prototype.draw = scale_draw; + +function holder(app, coord) { + var mtx = [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]; + + this._mtx = mtx; + this._coord = coord; + this._app = app; +} + +holder.prototype = { + go_center: function(o) { + var sx, sy; + + sx = o.center_x - this._coord.center_x; + sy = o.center_y - this._coord.center_y; + this.shift(sx, sy); + }, + + home: function() { + this._coord[2] = this._mtx[2]; + this._coord[5] = this._mtx[5]; + this._app.refresh(); + }, + + shift: function(sx, sy) { + this._coord[2] = this._mtx[2] + sx; + this._coord[5] = this._mtx[5] + sy; + this._app.refresh(); + } +}; + +exports.holder = holder; diff -r 0899dcac441c -r 7ec13634c97d nodejs/observer.cc --- a/nodejs/observer.cc Tue Aug 31 01:26:22 2010 +0800 +++ b/nodejs/observer.cc Tue Aug 31 02:36:01 2010 +0800 @@ -98,7 +98,7 @@ Persistent *hdl; hdl = (Persistent *) - mb_prop_get(&((mb_obj_t *)evt->tgt)->props, + mb_prop_get(&((mb_obj_t *)evt->tgt->obj)->props, PROP_JSOBJ); return Local::New(*hdl); } @@ -115,7 +115,7 @@ Persistent *hdl; hdl = (Persistent *) - mb_prop_get(&((mb_obj_t *)evt->cur_tgt)->props, + mb_prop_get(&((mb_obj_t *)evt->cur_tgt->obj)->props, PROP_JSOBJ); return Local::New(*hdl); } diff -r 0899dcac441c -r 7ec13634c97d nodejs/svg.js --- a/nodejs/svg.js Tue Aug 31 01:26:22 2010 +0800 +++ b/nodejs/svg.js Tue Aug 31 02:36:01 2010 +0800 @@ -474,6 +474,8 @@ this._set_paint(n, rect); this._set_bbox(n, tcoord); tcoord.add_shape(rect); + + make_mbnames(this.mb_rt, n, tcoord); }; // When we parse a group, we need to calculate the origin of the group