Mercurial > MadButterfly
changeset 749:ed59e659a202
Implement binding for hide/show for shapes and coords
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 25 Aug 2010 19:37:52 +0800 |
parents | 56a5e08cd8af |
children | 199bac90b90a |
files | nodejs/coord.cc nodejs/coord.m4 nodejs/shapes.cc nodejs/shapes.m4 nodejs/testcase.js |
diffstat | 5 files changed, 81 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/coord.cc Wed Aug 25 18:46:47 2010 +0800 +++ b/nodejs/coord.cc Wed Aug 25 19:37:52 2010 +0800 @@ -227,6 +227,32 @@ xnjsmb_coord_free_subtree(rdman, coord); } +static void +xnjsmb_coord_show(coord_t *coord, Handle<Object> self) { + Handle<Object> js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + coord_show(coord); + rdman_coord_changed(rdman, coord); +} + +static void +xnjsmb_coord_hide(coord_t *coord, Handle<Object> self) { + Handle<Object> js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + coord_hide(coord); + rdman_coord_changed(rdman, coord); +} + #include "coord-inc.h" /*! \brief This function used by \ref xnjsmb_mb_rt to wrap coord object.
--- a/nodejs/coord.m4 Wed Aug 25 18:46:47 2010 +0800 +++ b/nodejs/coord.m4 Wed Aug 25 19:37:52 2010 +0800 @@ -2,7 +2,9 @@ STRUCT([coord], [coord_t], [], [METHOD([add_shape], [xnjsmb_coord_add_shape], (SELF, OBJ([shape], [shape], [shape_t]), ERR), 1, []), - METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, [])], + METHOD([remove], [xnjsmb_coord_remove], (SELF), 0, []), + METHOD([show], [xnjsmb_coord_show], (SELF), 0, []), + METHOD([hide], [xnjsmb_coord_hide], (SELF), 0, [])], ((GET_INDEX, (coord_get_index, NUMBER)), (SET_INDEX, (coord_set_index, NUMBER)), ([STMOD], [xnjsmb_coord_mod])))
--- a/nodejs/shapes.cc Wed Aug 25 18:46:47 2010 +0800 +++ b/nodejs/shapes.cc Wed Aug 25 19:37:52 2010 +0800 @@ -129,6 +129,32 @@ } static void +xnjsmb_shape_show(shape_t *sh, Handle<Object> self) { + Handle<Object> js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + sh_show(sh); + rdman_shape_changed(rdman, sh); +} + +static void +xnjsmb_shape_hide(shape_t *sh, Handle<Object> self) { + Handle<Object> js_rt; + redraw_man_t *rdman; + + js_rt = GET(self, "mbrt")->ToObject(); + ASSERT(js_rt != NULL); + rdman = xnjsmb_rt_rdman(js_rt); + + sh_hide(sh); + rdman_shape_changed(rdman, sh); +} + +static void xnjsmb_shape_remove(shape_t *sh, Handle<Object> self) { Handle<Object> js_rt; redraw_man_t *rdman;
--- a/nodejs/shapes.m4 Wed Aug 25 18:46:47 2010 +0800 +++ b/nodejs/shapes.m4 Wed Aug 25 19:37:52 2010 +0800 @@ -4,8 +4,8 @@ [ACCESSOR([stroke_width], [xnjsmb_shape_stroke_width_get], [xnjsmb_shape_stroke_width_set])], - [METHOD([show], [sh_show], (), 0, []), - METHOD([hide], [sh_hide], (), 0, []), + [METHOD([show], [xnjsmb_shape_show], (SELF), 0, []), + METHOD([hide], [xnjsmb_shape_hide], (SELF), 0, []), METHOD([remove], [xnjsmb_shape_remove], (SELF), 0, [])]) STRUCT([path], [shape_t], [], [],
--- a/nodejs/testcase.js Wed Aug 25 18:46:47 2010 +0800 +++ b/nodejs/testcase.js Wed Aug 25 19:37:52 2010 +0800 @@ -42,6 +42,30 @@ paint.fill(rect); root.add_shape(rect); +/* test hide of shapes */ +var sw = 1; +setInterval(function() { + if(sw) { + rect.hide(); + sw = 0; + } else { + rect.show(); + sw = 1; + } + }, 1000); + +/* test hide of coord */ +var cw = 1; +setInterval(function() { + if(sw) { + coord.hide(); + cw = 0; + } else { + coord.show(); + cw = 1; + } + }, 3000); + /* test removing a coord */ var rm_coord = mb_rt.coord_new(root); var rm_rect1 = mb_rt.rect_new(150, 150, 50, 50, 10, 10);