# HG changeset patch # User Thinker K.F. Li # Date 1283396342 -28800 # Node ID 84853c8559cf1910162923824f702a4a3173f732 # Parent e21ccbc4afb1214bc37b62f7b5d71faf3f12276d Support opacity on coords diff -r e21ccbc4afb1 -r 84853c8559cf nodejs/coord.cc --- a/nodejs/coord.cc Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/coord.cc Thu Sep 02 10:59:02 2010 +0800 @@ -256,6 +256,20 @@ rdman_coord_changed(rdman, coord); } +static void +xnjsmb_coord_set_opacity(coord_t *coord, Handle self, + float opacity) { + Handle js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + coord_set_opacity(coord, opacity); + rdman_coord_changed(rdman, coord); +} + #include "coord-inc.h" /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object. diff -r e21ccbc4afb1 -r 84853c8559cf nodejs/coord.m4 --- a/nodejs/coord.m4 Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/coord.m4 Thu Sep 02 10:59:02 2010 +0800 @@ -4,7 +4,9 @@ (SELF, OBJ([shape], [shape], [shape_t]), ERR), 1, []), METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, []), METHOD([show], [xnjsmb_coord_show], (SELF), 0, []), - METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, [])], + METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, []), + METHOD([set_opacity], [xnjsmb_coord_set_opacity], + (SELF, NUMBER([opacity])), 1, [])], ((GET_INDEX, (coord_get_index, NUMBER)), (SET_INDEX, (coord_set_index, NUMBER)), ([STMOD], [xnjsmb_coord_mod]))) diff -r e21ccbc4afb1 -r 84853c8559cf nodejs/svg.js --- a/nodejs/svg.js Wed Sep 01 21:51:13 2010 +0800 +++ b/nodejs/svg.js Thu Sep 02 10:59:02 2010 +0800 @@ -491,6 +491,29 @@ // Each element must be responsible to calculate its absolute origin // point and update the origin of its parent. +function parseGroupStyle(style,n) +{ + var attr; + if (n) { + attr = n.attr('style'); + } else { + attr = null; + } + if (attr == null) { + return; + } + var f = attr.value().split(';'); + + for(i in f) { + var kv = f[i].split(':'); + if (kv[0] == 'opacity') { + style.opacity = parseFloat(kv[1]); + } else { + sys.puts("Unknown style: "+kv[0]); + } + } +} + loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { var k; var nodes = n.childNodes(); @@ -498,6 +521,8 @@ // Parse the transform and style here var trans = n.attr('transform'); var accu=[1,0,0,0,1,0]; + var style; + coord.center= new Object(); coord.center.x = 10000; coord.center.y = 10000; @@ -507,6 +532,13 @@ multiply(accu,accu_matrix); multiply(accu,coord); + style = {}; + parseGroupStyle(style, n); + if(style.opacity) { + sys.puts(style.opacity); + coord.set_opacity(style.opacity); + } + for(k in nodes) { var c = nodes[k].name(); var attr = nodes[k].attr('id');