diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index f257712bdef18b9057c009167a0999b34afc023d..d4a9e4852a8c670823edf7649cbfa43e0e1f4681 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -1840,9 +1840,9 @@ function gui_hide_selection_rectangle(cid) { // iemguis -function gui_create_bng(cid, tag, cx, cy, radius) { - var g = get_gobj(cid, tag), - circle = create_item(cid, "circle", { +function gui_create_bng(c, id, cx, cy, radius) { + var g = get_gobj(c, id), + circle = create_item(c, "circle", { cx: cx, cy: cy, r: radius, @@ -1850,14 +1850,30 @@ function gui_create_bng(cid, tag, cx, cy, radius) { fill: "none", stroke: "black", "stroke-width": 1, - id: tag + "button" + id: id + "button" }); g.appendChild(circle); } -function gui_bng_flash(cid, tag, color) { - var button = get_item(cid, tag + "button"); - configure_item(button, { fill: color }); +// change "x123456" to "#123456". Used as a convenience function for +// iemgui colors. +function x2h(x_val) { + return "#" + x_val.slice(1); +} + +function gui_bng_button_color(c, id, x_color) { + var button = get_item(c, id + "button"); + configure_item(button, { fill: x2h(x_color) }); +} + +function gui_bng_configure(c, id, x_color, cx, cy, r) { + var b = get_item(c, id + "button"); + configure_item(b, { + cx: cx, + cy: cy, + r: r, + fill: x2h(x_color) + }); } function gui_create_toggle(cid, tag, color, width, state, p1,p2,p3,p4,p5,p6,p7,p8,basex,basey) { diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index 81ba17cc8174103e0c025be63d15d401b9e3bbd5..ee10c366767422457269da4e7f2151c772355967 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -24,28 +24,22 @@ static t_class *bng_class; void bng_draw_update(t_gobj *xgobj, t_glist *glist) { - char tagbuf[MAXPDSTRING]; - char flashcol[8]; t_bng *x = (t_bng *)xgobj; - sprintf(tagbuf, "x%lx", (long unsigned int)&x->x_gui); if (x->x_gui.x_changed != x->x_flashed && glist_isvisible(glist)) { - sprintf(flashcol, "#%6.6x", + gui_vmess("gui_bng_button_color", "xxx", + glist_getcanvas(glist), + &x->x_gui, x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol); - gui_vmess("gui_bng_flash", "xss", - glist_getcanvas(glist), tagbuf, flashcol); } x->x_gui.x_changed = x->x_flashed; } void bng_draw_new(t_bng *x, t_glist *glist) { - char tagbuf[MAXPDSTRING]; - sprintf(tagbuf, "x%lx", (long unsigned int)&x->x_gui); t_canvas *canvas=glist_getcanvas(glist); int x1=text_xpix(&x->x_gui.x_obj, glist); int y1=text_ypix(&x->x_gui.x_obj, glist); - iemgui_base_draw_new(&x->x_gui); t_float cr = (x->x_gui.x_w-2)/2.0; t_float cx = x1+cr+1.5; @@ -58,8 +52,12 @@ void bng_draw_new(t_bng *x, t_glist *glist) // "-tags {%lxBUT x%lx text iemgui border}\n", // canvas, cx, cy, cr, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, // x, x); - gui_vmess("gui_create_bng", "xsfff", canvas, tagbuf, - cx - x1, cy - y1, cr); + gui_vmess("gui_create_bng", "xxfff", + canvas, + &x->x_gui, + cx - x1, + cy - y1, + cr); } void bng_draw_move(t_bng *x, t_glist *glist) @@ -73,40 +71,23 @@ void bng_draw_move(t_bng *x, t_glist *glist) t_float cr = (x->x_gui.x_w-2)/2.0; t_float cx = x1+cr+1.5; t_float cy = y1+cr+1.5; - char tagbuf[MAXPDSTRING]; - sprintf(tagbuf, "x%lxbutton", (long unsigned int)x); - char col[8]; - sprintf(col, "#%6.6x", x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol); - gui_start_vmess("gui_configure_item", "xs", - canvas, tagbuf); - gui_start_array(); - gui_s("cx"); - gui_f(cx - x1); // 0.5 is fudge factor... might be better - gui_s("cy"); - gui_f(cy - y1); // handled by shape-rendering css attr - gui_s("r"); - gui_f(cr); - gui_s("fill"); - gui_s(col); - gui_end_array(); - gui_end_vmess(); + gui_vmess("gui_bng_configure", "xxxfff", + canvas, + x, + x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol, + cx - x1, + cy - y1, + cr); } void bng_draw_config(t_bng* x, t_glist* glist) { - char tagbuf[MAXPDSTRING]; t_canvas *canvas=glist_getcanvas(glist); iemgui_base_draw_config(&x->x_gui); - sprintf(tagbuf, "x%lxbutton", (long unsigned int)x); - char fcol[8]; - sprintf(fcol, "#%6.6x", x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol); - gui_start_vmess("gui_configure_item", "xs", - canvas, tagbuf); - gui_start_array(); - gui_s("fill"); - gui_s(fcol); - gui_end_array(); - gui_end_vmess(); + gui_vmess("gui_bng_button_color", "xxx", + canvas, + x, + x->x_flashed ? x->x_gui.x_fcol : x->x_gui.x_bcol); } /* we may no longer need h_dragon... */