From 3eba24f959e2f527ad12db555deb15eb644c8cbe Mon Sep 17 00:00:00 2001
From: Mathieu L Bouchard <matju@artengine.ca>
Date: Tue, 12 Aug 2014 21:49:53 -0400
Subject: [PATCH] =?UTF-8?q?big=20refactoring=20#11=C2=A0:=20replaced=20%lx?=
 =?UTF-8?q?OBJ=20by=20x%lx=20and=20removed=20nlet=5Ftag=20from=20all=20iem?=
 =?UTF-8?q?gui,=20among=20other=20smaller=20changes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 pd/src/g_all_guis.c | 384 +++++++++++++++++---------------------------
 pd/src/g_all_guis.h | 151 ++++++-----------
 pd/src/g_bang.c     |  29 ++--
 pd/src/g_canvas.c   |   6 +-
 pd/src/g_mycanvas.c |  15 +-
 pd/src/g_numbox.c   |  25 ++-
 pd/src/g_radio.c    |  33 ++--
 pd/src/g_slider.c   |  20 +--
 pd/src/g_toggle.c   |  19 +--
 pd/src/g_vumeter.c  |  86 +++++-----
 10 files changed, 300 insertions(+), 468 deletions(-)

diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c
index 7025b69aa..00cb01c11 100644
--- a/pd/src/g_all_guis.c
+++ b/pd/src/g_all_guis.c
@@ -19,29 +19,14 @@
 
 t_symbol *s_empty;
 
-int iemgui_color_hex[]=
-{
-    16579836, 10526880, 4210752, 16572640, 16572608,
-    16579784, 14220504, 14220540, 14476540, 16308476,
-    14737632, 8158332, 2105376, 16525352, 16559172,
-    15263784, 1370132, 2684148, 3952892, 16003312,
-    12369084, 6316128, 0, 9177096, 5779456,
-    7874580, 2641940, 17488, 5256, 5767248
+int iemgui_color_hex[] = {
+    0xfcfcfc, 0xa0a0a0, 0x404040, 0xfce0e0, 0xfce0c0, 0xfcfcc8, 0xd8fcd8, 0xd8fcfc, 0xdce4fc, 0xf8d8fc,
+    0xe0e0e0, 0x7c7c7c, 0x202020, 0xfc2828, 0xfcac44, 0xe8e828, 0x14e814, 0x28f4f4, 0x3c50fc, 0xf430f0,
+    0xbcbcbc, 0x606060, 0x000000, 0x8c0808, 0x583000, 0x782814, 0x285014, 0x004450, 0x001488, 0x580050
 };
 
-int iemgui_clip_size(int size)
-{
-    if(size < IEM_GUI_MINSIZE)
-        size = IEM_GUI_MINSIZE;
-    return(size);
-}
-
-int iemgui_clip_font(int size)
-{
-    if(size < IEM_FONT_MINSIZE)
-        size = IEM_FONT_MINSIZE;
-    return(size);
-}
+int iemgui_clip_size(int size) {return maxi(size,IEM_GUI_MINSIZE);}
+int iemgui_clip_font(int size) {return maxi(size,IEM_FONT_MINSIZE);}
 
 static int iemgui_modulo_color(int col)
 {
@@ -80,65 +65,51 @@ t_symbol *iemgui_raute2dollar(t_symbol *s)
     return(gensym(buf));
 }
 
-void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui)
+void iemgui_verify_snd_ne_rcv(t_iemgui *x)
 {
-    iemgui->x_put_in2out = 1;
-    if(iemgui_has_snd(iemgui) && iemgui_has_rcv(iemgui))
-    {
-        if(iemgui->x_snd==iemgui->x_rcv)
-            iemgui->x_put_in2out = 0;
-    }
+    x->x_put_in2out = 
+        !(iemgui_has_snd(x) && iemgui_has_rcv(x) && x->x_snd==x->x_rcv);
 }
 
-t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv)
+t_symbol *iemgui_getfloatsym(t_atom *a)
 {
-    if (IS_A_SYMBOL(argv, indx))
-        return (atom_getsymbolarg(indx, 100000, argv));
-    else if (IS_A_FLOAT(argv, indx))
-    {
-        char str[80];
-        sprintf(str, "%d", (int)atom_getintarg(indx, 100000, argv));
-        return (gensym(str));
+    if (IS_A_SYMBOL(a,0)) return (atom_getsymbol(a));
+    if (IS_A_FLOAT(a,0)) {
+        char str[40];
+        sprintf(str, "%d", (int)atom_getint(a));
+        return gensym(str);
     }
-    else return s_empty;
+    return s_empty;
+}
+t_symbol *iemgui_getfloatsymarg(int i, int argc, t_atom *argv)
+{
+    if (i>=0 && i<argc) return iemgui_getfloatsym(argv+i);
+    return s_empty;
 }
 
-void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv)
+void iemgui_new_getnames(t_iemgui *x, int indx, t_atom *argv)
 {
     if (argv)
     {
-        iemgui->x_snd = iemgui_new_dogetname(iemgui, indx, argv);
-        iemgui->x_rcv = iemgui_new_dogetname(iemgui, indx+1, argv);
-        iemgui->x_lab = iemgui_new_dogetname(iemgui, indx+2, argv);
+        x->x_snd = iemgui_getfloatsym(argv+indx+0);
+        x->x_rcv = iemgui_getfloatsym(argv+indx+1);
+        x->x_lab = iemgui_getfloatsym(argv+indx+2);
     }
-    else iemgui->x_snd = iemgui->x_rcv = iemgui->x_lab = s_empty;
-    iemgui->x_snd_unexpanded = iemgui->x_rcv_unexpanded =
-        iemgui->x_lab_unexpanded = 0;
-    iemgui->x_binbufindex = indx;
-    iemgui->x_labelbindex = indx + 3;
+    else x->x_snd = x->x_rcv = x->x_lab = s_empty;
+    x->x_snd_unexpanded = x->x_rcv_unexpanded = x->x_lab_unexpanded = 0;
+    x->x_binbufindex = indx;
+    x->x_labelbindex = indx + 3;
 }
 
-    /* convert symbols in "$" form to the expanded symbols */
-void iemgui_all_dollararg2sym(t_iemgui *iemgui, t_symbol **srlsym)
-{
-        /* save unexpanded ones for later */
-    iemgui->x_snd_unexpanded = srlsym[0];
-    iemgui->x_rcv_unexpanded = srlsym[1];
-    iemgui->x_lab_unexpanded = srlsym[2];
-    srlsym[0] = canvas_realizedollar(iemgui->x_glist, srlsym[0]);
-    srlsym[1] = canvas_realizedollar(iemgui->x_glist, srlsym[1]);
-    srlsym[2] = canvas_realizedollar(iemgui->x_glist, srlsym[2]);
-}
-
-    /* initialize a single symbol in unexpanded form.  We reach into the
-    binbuf to grab them; if there's nothing there, set it to the
-    fallback; if still nothing, set to "empty". */
-static void iemgui_init_sym2dollararg(t_iemgui *iemgui, t_symbol **symp,
+/* initialize a single symbol in unexpanded form.  We reach into the
+   binbuf to grab them; if there's nothing there, set it to the
+   fallback; if still nothing, set to "empty". */
+static void iemgui_init_sym2dollararg(t_iemgui *x, t_symbol **symp,
     int indx, t_symbol *fallback)
 {
     if (!*symp)
     {
-        t_binbuf *b = iemgui->x_obj.ob_binbuf;
+        t_binbuf *b = x->x_obj.ob_binbuf;
         if (binbuf_getnatom(b) > indx)
         {
             char buf[80];
@@ -152,27 +123,24 @@ static void iemgui_init_sym2dollararg(t_iemgui *iemgui, t_symbol **symp,
 }
 
 /* get the unexpanded versions of the symbols; initialize them if necessary. */
-void iemgui_all_sym2dollararg(t_iemgui *iemgui, t_symbol **srlsym)
+void iemgui_all_sym2dollararg(t_iemgui *x, t_symbol **srlsym)
 {
-    iemgui_init_sym2dollararg(iemgui, &iemgui->x_snd_unexpanded,
-        iemgui->x_binbufindex+1, iemgui->x_snd);
-    iemgui_init_sym2dollararg(iemgui, &iemgui->x_rcv_unexpanded,
-        iemgui->x_binbufindex+2, iemgui->x_rcv);
-    iemgui_init_sym2dollararg(iemgui, &iemgui->x_lab_unexpanded,
-        iemgui->x_labelbindex, iemgui->x_lab);
-    srlsym[0] = iemgui->x_snd_unexpanded;
-    srlsym[1] = iemgui->x_rcv_unexpanded;
-    srlsym[2] = iemgui->x_lab_unexpanded;
+    iemgui_init_sym2dollararg(x, &x->x_snd_unexpanded, x->x_binbufindex+1, x->x_snd);
+    iemgui_init_sym2dollararg(x, &x->x_rcv_unexpanded, x->x_binbufindex+2, x->x_rcv);
+    iemgui_init_sym2dollararg(x, &x->x_lab_unexpanded, x->x_labelbindex, x->x_lab);
+    srlsym[0] = x->x_snd_unexpanded;
+    srlsym[1] = x->x_rcv_unexpanded;
+    srlsym[2] = x->x_lab_unexpanded;
 }
 
 static int col2save(int col) {
     return -1-(((0xfc0000 & col) >> 6)|((0xfc00 & col) >> 4)|((0xfc & col) >> 2));
 }
-void iemgui_all_col2save(t_iemgui *iemgui, int *bflcol)
+void iemgui_all_col2save(t_iemgui *x, int *bflcol)
 {
-    bflcol[0] = col2save(iemgui->x_bcol);
-    bflcol[1] = col2save(iemgui->x_fcol);
-    bflcol[2] = col2save(iemgui->x_lcol);
+    bflcol[0] = col2save(x->x_bcol);
+    bflcol[1] = col2save(x->x_fcol);
+    bflcol[2] = col2save(x->x_lcol);
 }
 
 static int colfromload(int col) {
@@ -184,11 +152,11 @@ static int colfromload(int col) {
     else
         return iemgui_color_hex[iemgui_modulo_color(col)];
 }
-void iemgui_all_colfromload(t_iemgui *iemgui, int *bflcol)
+void iemgui_all_colfromload(t_iemgui *x, int *bflcol)
 {
-    iemgui->x_bcol = colfromload(bflcol[0]);
-    iemgui->x_fcol = colfromload(bflcol[1]);
-    iemgui->x_lcol = colfromload(bflcol[2]);
+    x->x_bcol = colfromload(bflcol[0]);
+    x->x_fcol = colfromload(bflcol[1]);
+    x->x_lcol = colfromload(bflcol[2]);
 }
 
 static int iemgui_compatible_col(int i)
@@ -198,13 +166,6 @@ static int iemgui_compatible_col(int i)
     return((-1-i)&0xffffff);
 }
 
-void iemgui_all_dollar2raute(t_symbol **srlsym)
-{
-    srlsym[0] = iemgui_dollar2raute(srlsym[0]);
-    srlsym[1] = iemgui_dollar2raute(srlsym[1]);
-    srlsym[2] = iemgui_dollar2raute(srlsym[2]);
-}
-
 void iemgui_all_raute2dollar(t_symbol **srlsym)
 {
     srlsym[0] = iemgui_raute2dollar(srlsym[0]);
@@ -273,8 +234,8 @@ void iemgui_label(t_iemgui *x, t_symbol *s)
 
 void iemgui_label_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
 {
-    x->x_ldx = (int)atom_getintarg(0, ac, av);
-    x->x_ldy = (int)atom_getintarg(1, ac, av);
+    x->x_ldx = atom_getintarg(0, ac, av);
+    x->x_ldy = atom_getintarg(1, ac, av);
     if(glist_isvisible(x->x_glist))
     {
         sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
@@ -287,13 +248,10 @@ void iemgui_label_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
 
 void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
 {
-    int f = (int)atom_getintarg(0, ac, av);
+    int f = atom_getintarg(0, ac, av);
     if (f<0 || f>2) f=0;
     x->x_font_style = f;
-    f = (int)atom_getintarg(1, ac, av);
-    if(f < 4)
-        f = 4;
-    x->x_fontsize = f;
+    x->x_fontsize = maxi(atom_getintarg(1, ac, av),4);
     if(glist_isvisible(x->x_glist))
     {
         sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n",
@@ -469,7 +427,7 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
     else if (x->x_vis)
     {
         //fprintf(stderr,"draw erase %d\n", mode);
-        x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_ERASE);
+        iemgui_draw_erase(x, x->x_glist);
         x->x_vis = 0;
     }
     gop_redraw = 0;
@@ -483,18 +441,16 @@ void iemgui_size(t_iemgui *x)
 
 void iemgui_delta(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
 {
-    x->x_obj.te_xpix += (int)atom_getintarg(0, ac, av);
-    x->x_obj.te_ypix += (int)atom_getintarg(1, ac, av);
+    x->x_obj.te_xpix += atom_getintarg(0, ac, av);
+    x->x_obj.te_ypix += atom_getintarg(1, ac, av);
     if(glist_isvisible(x->x_glist))
-    {
         iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE);
-    }
 }
 
 void iemgui_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av)
 {
-    x->x_obj.te_xpix = (int)atom_getintarg(0, ac, av);
-    x->x_obj.te_ypix = (int)atom_getintarg(1, ac, av);
+    x->x_obj.te_xpix = atom_getintarg(0, ac, av);
+    x->x_obj.te_ypix = atom_getintarg(1, ac, av);
     if(glist_isvisible(x->x_glist))
         iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE);
 }
@@ -537,7 +493,7 @@ void iemgui_select(t_gobj *z, t_glist *glist, int selected)
     t_canvas *canvas=glist_getcanvas(glist);
     x->x_selected = selected;
     char fcol[8]; sprintf(fcol,"#%6.6x", x->x_fcol);
-    sys_vgui(".x%lx.c itemconfigure {%lxOBJ&&border} -stroke %s\n", canvas, x,
+    sys_vgui(".x%lx.c itemconfigure {x%lx&&border} -stroke %s\n", canvas, x,
         x->x_selected && x->x_glist == canvas ? selection_color : fcol);
     x->x_draw((void *)z, glist, IEM_GUI_DRAW_MODE_SELECT);
     scalehandle_draw(x,glist);
@@ -559,102 +515,68 @@ void iemgui_vis(t_gobj *z, t_glist *glist, int vis)
             iemgui_draw_new(x, glist);
         else
         {
-            x->x_draw((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE);
+            iemgui_draw_erase(x, x->x_glist);
             sys_unqueuegui(z);
         }
         x->x_vis = vis;
     }
 }
 
-void iemgui_save(t_iemgui *iemgui, t_symbol **srl, int *bflcol)
+void iemgui_save(t_iemgui *x, t_symbol **srl, int *bflcol)
 {
-    srl[0] = iemgui->x_snd;
-    srl[1] = iemgui->x_rcv;
-    srl[2] = iemgui->x_lab;
-    iemgui_all_sym2dollararg(iemgui, srl);
-    iemgui_all_col2save(iemgui, bflcol);
+    if (srl) {
+       srl[0] = x->x_snd;
+       srl[1] = x->x_rcv;
+       srl[2] = x->x_lab;
+    }
+    iemgui_all_sym2dollararg(x, srl);
+    iemgui_all_col2save(x, bflcol);
 }
 
-void iemgui_properties(t_iemgui *iemgui, t_symbol **srl)
+void iemgui_properties(t_iemgui *x, t_symbol **srl)
 {
-    srl[0] = iemgui->x_snd;
-    srl[1] = iemgui->x_rcv;
-    srl[2] = iemgui->x_lab;
-    iemgui_all_sym2dollararg(iemgui, srl);
-    iemgui_all_dollar2raute(srl);
+    srl[0] = x->x_snd;
+    srl[1] = x->x_rcv;
+    srl[2] = x->x_lab;
+    iemgui_all_sym2dollararg(x, srl);
+    srl[0] = iemgui_dollar2raute(srl[0]);
+    srl[1] = iemgui_dollar2raute(srl[1]);
+    srl[2] = iemgui_dollar2raute(srl[2]);
 }
 
-int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv)
+int iemgui_dialog(t_iemgui *x, t_symbol **srl, int argc, t_atom *argv)
 {
-    char str[144];
-    int init = (int)atom_getintarg(5, argc, argv);
-    int ldx = (int)atom_getintarg(10, argc, argv);
-    int ldy = (int)atom_getintarg(11, argc, argv);
-    int f = (int)atom_getintarg(12, argc, argv);
-    int fs = (int)atom_getintarg(13, argc, argv);
-    int bcol = (int)atom_getintarg(14, argc, argv);
-    int fcol = (int)atom_getintarg(15, argc, argv);
-    int lcol = (int)atom_getintarg(16, argc, argv);
-    int rcvable=1, oldsndrcvable=0;
-
-    if(iemgui_has_rcv(iemgui))
-        oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
-    if(iemgui_has_snd(iemgui))
-        oldsndrcvable += IEM_GUI_OLD_SND_FLAG;
-    if(IS_A_SYMBOL(argv,7))
-        srl[0] = atom_getsymbolarg(7, argc, argv);
-    else if(IS_A_FLOAT(argv,7))
-    {
-        sprintf(str, "%d", (int)atom_getintarg(7, argc, argv));
-        srl[0] = gensym(str);
-    }
-    if(IS_A_SYMBOL(argv,8))
-        srl[1] = atom_getsymbolarg(8, argc, argv);
-    else if(IS_A_FLOAT(argv,8))
-    {
-        sprintf(str, "%d", (int)atom_getintarg(8, argc, argv));
-        srl[1] = gensym(str);
-    }
-    if(IS_A_SYMBOL(argv,9))
-        srl[2] = atom_getsymbolarg(9, argc, argv);
-    else if(IS_A_FLOAT(argv,9))
-    {
-        sprintf(str, "%d", (int)atom_getintarg(9, argc, argv));
-        srl[2] = gensym(str);
-    }
-    if(init != 0) init = 1;
-    iemgui->x_loadinit = init;
+    x->x_loadinit = !!atom_getintarg(5, argc, argv);
+    srl[0] = iemgui_getfloatsymarg(7,argc,argv);
+    srl[1] = iemgui_getfloatsymarg(8,argc,argv);
+    srl[2] = iemgui_getfloatsymarg(9,argc,argv);
+    x->x_ldx = atom_getintarg(10, argc, argv);
+    x->x_ldy = atom_getintarg(11, argc, argv);
+    int f = atom_getintarg(12, argc, argv);
+    x->x_fontsize = maxi(atom_getintarg(13, argc, argv),4);
+    x->x_bcol = atom_getintarg(14, argc, argv) & 0xffffff;
+    x->x_fcol = atom_getintarg(15, argc, argv) & 0xffffff;
+    x->x_lcol = atom_getintarg(16, argc, argv) & 0xffffff;
+    int oldsndrcvable=0;
+    if(iemgui_has_rcv(x)) oldsndrcvable += IEM_GUI_OLD_RCV_FLAG;
+    if(iemgui_has_snd(x)) oldsndrcvable += IEM_GUI_OLD_SND_FLAG;
     iemgui_all_raute2dollar(srl);
-    iemgui_all_dollararg2sym(iemgui, srl);
-    if(rcvable)
+    x->x_snd_unexpanded=srl[0]; srl[0]=canvas_realizedollar(x->x_glist, srl[0]);
+    x->x_rcv_unexpanded=srl[1]; srl[1]=canvas_realizedollar(x->x_glist, srl[1]);
+    x->x_lab_unexpanded=srl[2]; srl[2]=canvas_realizedollar(x->x_glist, srl[2]);
+    if(srl[1]!=x->x_rcv)
     {
-        if(srl[1]!=iemgui->x_rcv)
-        {
-            if(iemgui_has_rcv(iemgui))
-                pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
-            iemgui->x_rcv = srl[1];
-            pd_bind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
-        }
+        if(iemgui_has_rcv(x))
+            pd_unbind((t_pd *)x, x->x_rcv);
+        x->x_rcv = srl[1];
+        pd_bind((t_pd *)x, x->x_rcv);
     }
-    else if(!rcvable && iemgui_has_rcv(iemgui))
-    {
-        pd_unbind(&iemgui->x_obj.ob_pd, iemgui->x_rcv);
-        iemgui->x_rcv = srl[1];
-    }
-    iemgui->x_snd = srl[0];
-    iemgui->x_lcol = lcol & 0xffffff;
-    iemgui->x_fcol = fcol & 0xffffff;
-    iemgui->x_bcol = bcol & 0xffffff;
-    iemgui->x_lab = srl[2];
-    iemgui->x_ldx = ldx;
-    iemgui->x_ldy = ldy;
+    x->x_snd = srl[0];
+    x->x_lab = srl[2];
     if(f<0 || f>2) f=0;
-    iemgui->x_font_style = f;
-    if(fs < 4)
-        fs = 4;
-    iemgui->x_fontsize = fs;
-    iemgui_verify_snd_ne_rcv(iemgui);
-    canvas_dirty(iemgui->x_glist, 1);
+    x->x_font_style = f;
+    iemgui_verify_snd_ne_rcv(x);
+    canvas_dirty(x->x_glist, 1);
     return(oldsndrcvable);
 }
 
@@ -684,22 +606,6 @@ int iem_fstyletoint(t_iemgui *x)
     return ((x->x_font_style << 0) & 63);
 }
 
-char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj)
-{
-    t_gobj *y = (t_gobj *)iem_obj;
-    t_object *ob = pd_checkobject(&y->g_pd);
-
-    /* GOP objects are unable to call findrtext
-       triggering consistency check error */
-    t_rtext *yyyy = NULL;
-    if (!glist->gl_isgraph || glist_istoplevel(glist))
-        yyyy = glist_findrtext(glist_getcanvas(glist), (t_text *)&ob->ob_g);
-
-    /* on GOP we cause segfault as text_gettag() returns bogus data */
-    if (yyyy) return(rtext_gettag(yyyy));
-    else return("bogus");
-}
-
 //----------------------------------------------------------------
 // SCALEHANDLE COMMON CODE (by Mathieu, refactored from existing code)
 
@@ -723,10 +629,9 @@ void scalehandle_bind(t_scalehandle *h) {
 // in 18 cases only, because canvas does not fit the pattern below.
 // canvas has no label handle and has a motion handle
 // but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally)
-void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag) {
+void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py) {
     char tags[128]; // BNG may need up to 100 chars in 64-bit mode, for example
     t_iemgui *x = (t_iemgui *)h->h_master;
-    //if (!nlet_tag) nlet_tag = iem_get_tag(canvas, (t_iemgui *)x);
 
     //int px,py;
     //t_class *c = pd_class((t_pd *)x);
@@ -743,8 +648,6 @@ void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py,
     int sx = h->h_scale ? SCALEHANDLE_WIDTH  : LABELHANDLE_WIDTH;
     int sy = h->h_scale ? SCALEHANDLE_HEIGHT : LABELHANDLE_HEIGHT;
 
-    //printf("scalehandle_draw_select(x%lx,x%lx,%d,%d,\"%s\",\"%s\")\n",h,canvas,px,py,nlet_tag);
-
     if (h->h_vis) scalehandle_draw_erase(h,canvas);
 
     sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 "
@@ -753,12 +656,12 @@ void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py,
     // there was a %lxBNG tag (or similar) in every scalehandle,
     // but it didn't seem to be used —mathieu
     if (h->h_scale) {
-        sprintf(tags,"%lxOBJ %lxSCALE iemgui %s",
-            (long)x,(long)x,nlet_tag);
+        sprintf(tags,"x%lx %lxSCALE iemgui",
+            (long)x,(long)x);
     } else {
         //sprintf(tags,"%lx%s %lxLABEL %lxLABELH iemgui %s", // causes unknown option "-fill"
-        sprintf(tags,"%lxOBJ %lx%s iemgui %s", (long)x,
-            (long)x,pd_class((t_pd *)x)==canvas_class?"MOVE":"LABELH",nlet_tag);
+        sprintf(tags,"x%lx %lx%s iemgui", (long)x,
+            (long)x,pd_class((t_pd *)x)==canvas_class?"MOVE":"LABELH");
     }
     sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d "
         "-window %s -tags {%s}\n", canvas, x->x_obj.te_xpix+px-sx, x->x_obj.te_ypix+py-sy,
@@ -768,13 +671,12 @@ void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py,
 }
 
 void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas) {
-    char *nlet_tag = iem_get_tag(canvas, (t_iemgui *)x);
     t_class *c = pd_class((t_pd *)x);
     int x1,y1,x2,y2;
     c->c_wb->w_getrectfn((t_gobj *)x,canvas,&x1,&y1,&x2,&y2);
-    scalehandle_draw_select(x->x_handle,canvas,x2-x1-1,y2-y1-1,nlet_tag);
+    scalehandle_draw_select(x->x_handle,canvas,x2-x1-1,y2-y1-1);
     if (x->x_lab!=s_empty)
-        scalehandle_draw_select(x->x_lhandle,canvas,x->x_ldx,x->x_ldy,nlet_tag);
+        scalehandle_draw_select(x->x_lhandle,canvas,x->x_ldx,x->x_ldy);
 }
 
 void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas) {
@@ -939,24 +841,28 @@ void iemgui__clickhook3(t_scalehandle *sh, int newstate) {
 
 void iemgui_tag_selected(t_iemgui *x, t_glist *canvas) {
     if(x->x_selected)
-        sys_vgui(".x%lx.c addtag selected withtag %lxOBJ\n", canvas, x);
+        sys_vgui(".x%lx.c addtag selected withtag x%lx\n", canvas, x);
     else
-        sys_vgui(".x%lx.c dtag %lxOBJ selected\n", canvas, x);
+        sys_vgui(".x%lx.c dtag x%lx selected\n", canvas, x);
 }
 
-void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag) {
+void iemgui_label_draw_new(t_iemgui *x, t_glist *canvas) {
+    int x1=text_xpix(&x->x_obj, x->x_glist);
+    int y1=text_ypix(&x->x_obj, x->x_glist);
     sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w "
              "-font {{%s} -%d %s} -fill #%6.6x "
-             "-tags {%lxLABEL %lxOBJ text iemgui %s}\n",
-         canvas, xpos+x->x_ldx, ypos+x->x_ldy,
+             "-tags {%lxLABEL x%lx text iemgui}\n",
+         canvas, x1+x->x_ldx, y1+x->x_ldy,
          x->x_lab!=s_empty?x->x_lab->s_name:"",
          iemgui_font(x), x->x_fontsize, sys_fontweight,
-         x->x_lcol, x, x, nlet_tag);
+         x->x_lcol, x, x);
 }
 
-void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas, int xpos, int ypos) {
+void iemgui_label_draw_move(t_iemgui *x, t_glist *canvas) {
+    int x1=text_xpix(&x->x_obj, x->x_glist);
+    int y1=text_ypix(&x->x_obj, x->x_glist);
     sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
-        canvas, x, xpos+x->x_ldx, ypos+x->x_ldy);
+        canvas, x, x1+x->x_ldx, y1+x->x_ldy);
 }
 
 void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas) {
@@ -985,7 +891,6 @@ extern t_class *vu_class;
 void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags) {
 	if (x->x_glist != canvas) return; // is gop
     t_class *c = pd_class((t_pd *)x);
-    char *nlet_tag = iem_get_tag(/*glist*/ x->x_glist, (t_iemgui *)x);
 
     if (!(old_sr_flags&4) && (!glist_isvisible(canvas) || !(canvas == x->x_glist))) {
         return;
@@ -1002,49 +907,49 @@ void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags) {
     if(a && !b) for (i=0; i<n; i++)
         sys_vgui(".x%lx.c create prect %d %d %d %d "
                  "-stroke $pd_colors(iemgui_nlet) "
-                 "-tags {%lxOBJ%so%d %so%d %lxOBJ outlet iemgui %s}\n",
+                 "-tags {x%lxo%d x%lx outlet iemgui}\n",
              canvas, x1+i*k, y2-1, x1+i*k + IOWIDTH, y2,
-             x, nlet_tag, i, nlet_tag, i, x, nlet_tag);
+             x, i, x);
     if(!a && b) for (i=0; i<n; i++)
-        sys_vgui(".x%lx.c delete %lxOBJ%so%d\n", canvas, x, nlet_tag, 0);
+        sys_vgui(".x%lx.c delete x%lxo%d\n", canvas, x, 0);
 
     a=old_sr_flags&IEM_GUI_OLD_RCV_FLAG;
     b=x->x_rcv!=s_empty;
     if(a && !b) for (i=0; i<n; i++)
         sys_vgui(".x%lx.c create prect %d %d %d %d "
                  "-stroke $pd_colors(iemgui_nlet) "
-                 "-tags {%lxOBJ%si%d %si%d %lxOBJ inlet iemgui %s}\n",
+                 "-tags {x%lxi%d x%lx inlet iemgui}\n",
              canvas, x1+i*k, y1, x1+i*k + IOWIDTH, y1+1,
-             x, nlet_tag, i, nlet_tag, i, x, nlet_tag);
+             x, i, x);
     if(!a && b) for (i=0; i<n; i++)
-        sys_vgui(".x%lx.c delete %lxOBJ%si%d\n", canvas, x, nlet_tag, 0);
+        sys_vgui(".x%lx.c delete x%lxi%d\n", canvas, x, 0);
 }
 
-void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag) {
+void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas) {
     t_class *c = pd_class((t_pd *)x);
     int x1,y1,x2,y2;
     c->c_wb->w_getrectfn((t_gobj *)x,canvas,&x1,&y1,&x2,&y2);
     int i, n = c==vu_class ? 2 : 1, k=(x2-x1)-IOWIDTH;
     if(!iemgui_has_snd(x) && canvas == x->x_glist) for (i=0; i<n; i++)
-        sys_vgui(".x%lx.c coords %lxOBJ%so%d %d %d %d %d\n",
-            canvas, x, nlet_tag, i, x1+i*k, y2-1, x1+i*k+IOWIDTH, y2);
+        sys_vgui(".x%lx.c coords x%lxo%d %d %d %d %d\n",
+            canvas, x, i, x1+i*k, y2-1, x1+i*k+IOWIDTH, y2);
     if(!iemgui_has_rcv(x) && canvas == x->x_glist) for (i=0; i<n; i++)
-        sys_vgui(".x%lx.c coords %lxOBJ%si%d %d %d %d %d\n",
-            canvas, x, nlet_tag, i, x1+i*k, y1, x1+i*k+IOWIDTH, y1+1);
+        sys_vgui(".x%lx.c coords x%lxi%d %d %d %d %d\n",
+            canvas, x, i, x1+i*k, y1, x1+i*k+IOWIDTH, y1+1);
 }
 
-void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas, const char *nlet_tag) {
+void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas) {
     t_class *c = pd_class((t_pd *)x);
     int x1,y1,x2,y2,gr=gop_redraw; gop_redraw=0;
     c->c_wb->w_getrectfn((t_gobj *)x,x->x_glist,&x1,&y1,&x2,&y2);
     gop_redraw=gr;
     sys_vgui(".x%lx.c create prect %d %d %d %d "
              "-stroke $pd_colors(iemgui_border) -fill #%6.6x "
-             "-tags {%lxBASE %lxOBJ text iemgui border %s}\n",
-         canvas, x1,y1,x2,y2, x->x_bcol, x, x, nlet_tag);
+             "-tags {%lxBASE x%lx text iemgui border}\n",
+         canvas, x1,y1,x2,y2, x->x_bcol, x, x);
 }
 
-void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag) {
+void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas) {
     t_class *c = pd_class((t_pd *)x);
     int x1,y1,x2,y2,gr=gop_redraw; gop_redraw=0;
     c->c_wb->w_getrectfn((t_gobj *)x,x->x_glist,&x1,&y1,&x2,&y2);
@@ -1060,22 +965,19 @@ void iemgui_base_draw_config(t_iemgui *x, t_glist *canvas) {
 void iemgui_draw_new(t_iemgui *x, t_glist *glist) {
     x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_NEW);
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    int x1=text_xpix(&x->x_obj, glist);
-    int y1=text_ypix(&x->x_obj, glist);
-    iemgui_label_draw_new(x,canvas,x1,y1,nlet_tag);
+    iemgui_label_draw_new(x,canvas);
     iemgui_draw_io(x,glist,7);
     sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(x->x_glist)); // used to be inside x_draw
 }
-void iemgui_draw_io(t_iemgui *x, t_glist *glist, int old_snd_rcv_flags)
+void iemgui_draw_io(t_iemgui *x, t_glist *glist, int old_sr_flags)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    iemgui_io_draw(x,glist_getcanvas(canvas),old_snd_rcv_flags);
+    iemgui_io_draw(x,glist_getcanvas(canvas),old_sr_flags);
 }
 void iemgui_draw_erase(t_iemgui *x, t_glist *glist) {
     t_canvas *canvas=glist_getcanvas(glist);
-    sys_vgui(".x%lx.c delete %lxOBJ\n", canvas, x);
-    sys_vgui(".x%lx.c dtag all %lxOBJ\n", canvas, x);
+    sys_vgui(".x%lx.c delete x%lx\n", canvas, x);
+    sys_vgui(".x%lx.c dtag all x%lx\n", canvas, x);
     scalehandle_draw_erase2(x,glist);
 }
 
diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h
index 6810093b6..abbfc0a13 100644
--- a/pd/src/g_all_guis.h
+++ b/pd/src/g_all_guis.h
@@ -4,38 +4,11 @@
 /* g_7_guis.h written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
 
 
-#define IEM_GUI_COLNR_WHITE          0
-#define IEM_GUI_COLNR_ML_GREY        1
-#define IEM_GUI_COLNR_D_GREY         2
-#define IEM_GUI_COLNR_L_RED          3
-#define IEM_GUI_COLNR_L_ORANGE       4
-#define IEM_GUI_COLNR_L_YELLOW       5
-#define IEM_GUI_COLNR_L_GREEN        6
-#define IEM_GUI_COLNR_L_CYAN         7
-#define IEM_GUI_COLNR_L_BLUE         8
-#define IEM_GUI_COLNR_L_MAGENTA      9
-
-#define IEM_GUI_COLNR_LL_GREY        10
-#define IEM_GUI_COLNR_M_GREY         11
-#define IEM_GUI_COLNR_DD_GREY        12
-#define IEM_GUI_COLNR_RED            13
-#define IEM_GUI_COLNR_ORANGE         14
-#define IEM_GUI_COLNR_YELLOW         15
+// the three used by any externals ([room_sim_2d] [room_sim_3d] [cube_sphere])
+// the other colours still exist in the array but are not referred by name.
 #define IEM_GUI_COLNR_GREEN          16
-#define IEM_GUI_COLNR_CYAN           17
-#define IEM_GUI_COLNR_BLUE           18
-#define IEM_GUI_COLNR_MAGENTA        19
-
 #define IEM_GUI_COLNR_L_GREY         20
-#define IEM_GUI_COLNR_MD_GREY        21
-#define IEM_GUI_COLNR_BLACK          22
-#define IEM_GUI_COLNR_D_RED          23
 #define IEM_GUI_COLNR_D_ORANGE       24
-#define IEM_GUI_COLNR_D_YELLOW       25
-#define IEM_GUI_COLNR_D_GREEN        26
-#define IEM_GUI_COLNR_D_CYAN         27
-#define IEM_GUI_COLNR_D_BLUE         28
-#define IEM_GUI_COLNR_D_MAGENTA      29
 
 /* deprecated in favor of the global iemgui_select var
    left here for legacy externals that may rely upon this */
@@ -53,36 +26,16 @@
 #define IEM_SL_MINSIZE 2
 #define IEM_FONT_MINSIZE 4
 
-#define IEM_BNG_DEFAULTHOLDFLASHTIME 250
-#define IEM_BNG_DEFAULTBREAKFLASHTIME 50
-#define IEM_BNG_MINHOLDFLASHTIME 50
-#define IEM_BNG_MINBREAKFLASHTIME 10
-
-#define IEM_VU_DEFAULTSIZE 3
-#define IEM_VU_LARGESMALL  2
-#define IEM_VU_MINSIZE     2
-#define IEM_VU_MAXSIZE     25
-#define IEM_VU_STEPS       40
-
-#define IEM_VU_MINDB    -99.9
-#define IEM_VU_MAXDB    12.0
-#define IEM_VU_OFFSET   100.0
-
-#define IEM_RADIO_MAX   128
-
 #define IEM_GUI_DRAW_MODE_UPDATE 0
 #define IEM_GUI_DRAW_MODE_MOVE   1
 #define IEM_GUI_DRAW_MODE_NEW    2
 #define IEM_GUI_DRAW_MODE_SELECT 3
-#define IEM_GUI_DRAW_MODE_ERASE  4
+//#define IEM_GUI_DRAW_MODE_ERASE  4 // obsolete since 2014.08
 #define IEM_GUI_DRAW_MODE_CONFIG 5
 #define IEM_GUI_DRAW_MODE_IO     6 /* also reserves 7,8,9 by adding old_sr_flags */
 
-#define IS_A_POINTER(atom,index) ((atom+index)->a_type == A_POINTER)
 #define IS_A_FLOAT(atom,index) ((atom+index)->a_type == A_FLOAT)
 #define IS_A_SYMBOL(atom,index) ((atom+index)->a_type == A_SYMBOL)
-#define IS_A_DOLLAR(atom,index) ((atom+index)->a_type == A_DOLLAR)
-#define IS_A_DOLLSYM(atom,index) ((atom+index)->a_type == A_DOLLSYM)
 
 #define IEM_FSTYLE_FLAGS_ALL 0x007fffff
 #define IEM_INIT_ARGS_ALL    0x01ffffff
@@ -90,7 +43,6 @@
 #define IEM_GUI_OLD_SND_FLAG 1
 #define IEM_GUI_OLD_RCV_FLAG 2
 
-#define IEM_GUI_COLOR_EDITED 16711680
 #define IEMGUI_MAX_NUM_LEN 32
 
 #define SCALE_NUM_MINWIDTH 1
@@ -122,43 +74,43 @@ typedef struct _scalehandle
 
 typedef struct _iemgui
 {
-    t_object           x_obj;
-    t_glist            *x_glist;
-    t_iemfunptr        x_draw;
-    int                x_h;
-    int                x_w;
-    int                x_ldx;
-    int                x_ldy;
-    int                x_fontsize;
-    int                x_fcol;
-    int                x_bcol;
-    int                x_lcol;
-    t_symbol          *x_snd;              /* send symbol */
-    t_symbol          *x_rcv;              /* receive */
-    t_symbol          *x_lab;              /* label */
-    t_symbol          *x_snd_unexpanded;   /* same 3, with '$' unexpanded */
-    t_symbol          *x_rcv_unexpanded;
-    t_symbol          *x_lab_unexpanded;
-    int                x_binbufindex;       /* where in binbuf to find these */
-    int                x_labelbindex;       /* where in binbuf to find label */
-    t_scalehandle     *x_handle;
-    t_scalehandle     *x_lhandle;
-    int                x_vis;               /* is the object drawn? */
-    int                x_changed;           /* has the value changed so that we need to do graphic update */
+    t_object       x_obj;
+    t_glist       *x_glist;
+    t_iemfunptr    x_draw;           //46    /* this should be static */
+    int            x_h;              //80
+    int            x_w;              //119
+    int            x_ldx;            //33
+    int            x_ldy;            //33
+    int            x_fontsize;       //49
+    int            x_fcol;           //35
+    int            x_bcol;           //41
+    int            x_lcol;           //21
+    t_symbol      *x_snd;            //18  /* send symbol */
+    t_symbol      *x_rcv;            //33  /* receive */
+    t_symbol      *x_lab;            //15  /* label */
+    t_symbol      *x_snd_unexpanded; //7  /* same 3, with '$' unexpanded */
+    t_symbol      *x_rcv_unexpanded; //7
+    t_symbol      *x_lab_unexpanded; //6
+    int            x_binbufindex;    //4   /* where in binbuf to find these (this should be static) */
+    int            x_labelbindex;    //5   /* where in binbuf to find label (this should be static) */
+    t_scalehandle *x_handle;         //24
+    t_scalehandle *x_lhandle;        //17
+    int            x_vis;            //64   /* is the object drawn? */
+    int            x_changed;        //30   /* has the value changed so that we need to do graphic update */
 
                                   // grep -w "$1" *.[ch]|wc -l
     // from t_iem_fstyle_flags
-    unsigned int x_font_style:6;  // 39 matches
-    unsigned int x_selected:1;    // 38 matches
-    unsigned int x_finemoved:1;   // 11 matches (sliders and [nbx] only)
-    unsigned int x_put_in2out:1;  // 17 matches
-    unsigned int x_change:1;      // 37 matches  // what's this and why is there also a x_changed ?
+    unsigned int x_font_style:6;  // 33 matches
+    unsigned int x_selected:1;    // 15 matches
+    unsigned int x_finemoved:1;   //  7 matches (sliders and [nbx] only)
+    unsigned int x_put_in2out:1;  //  9 matches
+    unsigned int x_change:1;      // 28 matches  // what's this and why is there also a x_changed ?
     unsigned int dummy2:3;
     // from t_iem_init_symargs
-    unsigned int x_loadinit:1;    // 33 matches
+    unsigned int x_loadinit:1;    // 21 matches
     unsigned int dummy3:2;
-    unsigned int x_locked:1;      //  8 matches ([bng] only)
-    unsigned int x_reverse:1;     //  8 matches (sliders only)
+    unsigned int x_locked:1;      //  7 matches ([bng] only)
+    unsigned int x_reverse:1;     //  4 matches (sliders only)
     unsigned int dummy:14;
 } t_iemgui;
 
@@ -205,8 +157,8 @@ typedef struct _radio
 typedef struct _toggle
 {
     t_iemgui x_gui;
-    t_float    x_on;
-    t_float    x_nonzero;
+    t_float  x_on;
+    t_float  x_nonzero;
 } t_toggle;
 
 typedef struct _my_canvas
@@ -223,8 +175,8 @@ typedef struct _vu
     int      x_led_size;
     int      x_peak;
     int      x_rms;
-    t_float    x_fp;
-    t_float    x_fr;
+    t_float  x_fp;
+    t_float  x_fr;
     int      x_scale;
     void     *x_out_rms;
     void     *x_out_peak;
@@ -257,7 +209,8 @@ extern int iemgui_color_hex[];
 EXTERN int iemgui_clip_size(int size);
 EXTERN int iemgui_clip_font(int size);
 EXTERN void iemgui_verify_snd_ne_rcv(t_iemgui *iemgui);
-EXTERN t_symbol *iemgui_new_dogetname(t_iemgui *iemgui, int indx, t_atom *argv);
+EXTERN t_symbol *iemgui_getfloatsym(t_atom *a);
+EXTERN t_symbol *iemgui_getfloatsymarg(int i, int argc, t_atom *argv);
 EXTERN void iemgui_new_getnames(t_iemgui *iemgui, int indx, t_atom *argv);
 EXTERN void iemgui_all_colfromload(t_iemgui *iemgui, int *bflcol);
 EXTERN void iemgui_send(t_iemgui *x, t_symbol *s);
@@ -276,21 +229,20 @@ EXTERN void iemgui_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy);
 EXTERN void iemgui_select(t_gobj *z, t_glist *glist, int selected);
 EXTERN void iemgui_delete(t_gobj *z, t_glist *glist);
 EXTERN void iemgui_vis(t_gobj *z, t_glist *glist, int vis);
-EXTERN void iemgui_save(t_iemgui *iemgui, t_symbol **srl, int *bflcol);
-EXTERN void iemgui_properties(t_iemgui *iemgui, t_symbol **srl);
-EXTERN int iemgui_dialog(t_iemgui *iemgui, t_symbol **srl, int argc, t_atom *argv);
+EXTERN void iemgui_save(t_iemgui *x, t_symbol **srl, int *bflcol);
+EXTERN void iemgui_properties(t_iemgui *x, t_symbol **srl);
+EXTERN int iemgui_dialog(t_iemgui *x, t_symbol **srl, int argc, t_atom *argv);
 
 EXTERN void iem_inttosymargs(t_iemgui *x, int n);
 EXTERN int iem_symargstoint(t_iemgui *x);
 EXTERN void iem_inttofstyle(t_iemgui *x, int n);
 EXTERN int iem_fstyletoint(t_iemgui *x);
-EXTERN char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj);
 
 EXTERN void canvas_apply_setundo(t_canvas *x, t_gobj *y);
 
 // scalehandle code, as refactored by Mathieu
 EXTERN void scalehandle_bind(t_scalehandle *h);
-EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag);
+EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py);
 EXTERN void scalehandle_draw_select2(t_iemgui *x, t_glist *canvas);
 EXTERN void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas);
 EXTERN void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas);
@@ -311,15 +263,15 @@ EXTERN int maxi(int a, int b);
 
 // other refactor by Mathieu
 EXTERN void iemgui_tag_selected(     t_iemgui *x, t_glist *canvas);
-EXTERN void iemgui_label_draw_new(   t_iemgui *x, t_glist *canvas, int xpos, int ypos, const char *nlet_tag);
-EXTERN void iemgui_label_draw_move(  t_iemgui *x, t_glist *canvas, int xpos, int ypos);
+EXTERN void iemgui_label_draw_new(   t_iemgui *x, t_glist *canvas);
+EXTERN void iemgui_label_draw_move(  t_iemgui *x, t_glist *canvas);
 EXTERN void iemgui_label_draw_config(t_iemgui *x, t_glist *canvas);
 EXTERN void iemgui_label_draw_select(t_iemgui *x, t_glist *canvas);
 EXTERN void iemgui_io_draw(t_iemgui *x, t_glist *canvas, int old_sr_flags);
-EXTERN void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag);
-EXTERN void iemgui_draw_io(t_iemgui *x, t_glist *glist, int old_snd_rcv_flags);
-EXTERN void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas, const char *nlet_tag);
-EXTERN void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas, const char *nlet_tag);
+EXTERN void iemgui_io_draw_move(t_iemgui *x, t_glist *canvas);
+EXTERN void iemgui_draw_io(t_iemgui *x, t_glist *glist, int old_sr_flags);
+EXTERN void iemgui_base_draw_new(t_iemgui *x, t_glist *canvas);
+EXTERN void iemgui_base_draw_move(t_iemgui *x, t_glist *canvas);
 EXTERN void iemgui_base_draw_config(t_iemgui *x, t_glist *canvas);
 EXTERN void iemgui_draw_new(t_iemgui *x, t_glist *glist);
 EXTERN void iemgui_draw_erase(t_iemgui *x, t_glist* glist);
@@ -328,8 +280,6 @@ EXTERN void wb_init(t_widgetbehavior *wb, t_getrectfn gr, t_clickfn cl); // rena
 extern t_symbol *s_empty;
 EXTERN const char *selection_color;
 
-//static inline int iemgui_has_snd (t_iemgui *x) {return x->x_snd_unexpanded!=s_empty;}
-//static inline int iemgui_has_rcv (t_iemgui *x) {return x->x_rcv_unexpanded!=s_empty;}
 static inline int iemgui_has_snd (t_iemgui *x) {return x->x_snd!=s_empty;}
 static inline int iemgui_has_rcv (t_iemgui *x) {return x->x_rcv!=s_empty;}
 EXTERN const char *iemgui_font(t_iemgui *x);
@@ -340,3 +290,4 @@ EXTERN void iemgui_init(t_iemgui *x, t_floatarg f);
 EXTERN void iemgui_out_bang(t_iemgui *x, int o, int chk_putin);
 EXTERN void iemgui_out_float(t_iemgui *x, int o, int chk_putin, t_float f);
 EXTERN void iemgui_out_list(t_iemgui *x, int o, int chk_putin, t_symbol *s, int argc, t_atom *argv);
+
diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c
index 99c8142e5..9eb90583e 100644
--- a/pd/src/g_bang.c
+++ b/pd/src/g_bang.c
@@ -13,9 +13,13 @@
 #include "g_all_guis.h"
 #include <math.h>
 
+#define IEM_BNG_DEFAULTHOLDFLASHTIME 250
+#define IEM_BNG_DEFAULTBREAKFLASHTIME 50
+#define IEM_BNG_MINHOLDFLASHTIME 50
+#define IEM_BNG_MINBREAKFLASHTIME 10
+
 static t_class *scalehandle_class;
 extern int gfxstub_haveproperties(void *key);
- 
 t_widgetbehavior bng_widgetbehavior;
 static t_class *bng_class;
 
@@ -34,19 +38,18 @@ void bng_draw_update(t_gobj *xgobj, t_glist *glist)
 void bng_draw_new(t_bng *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     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, canvas, nlet_tag);
+    iemgui_base_draw_new(&x->x_gui, canvas);
     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;
     sys_vgui(".x%lx.c create circle %f %f -r %f "
              "-stroke $pd_colors(iemgui_border) -fill #%6.6x "
-             "-tags {%lxBUT %lxOBJ text iemgui border %s}\n",
+             "-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, nlet_tag);
+         x, x);
 }
 
 void bng_draw_move(t_bng *x, t_glist *glist)
@@ -56,16 +59,15 @@ void bng_draw_move(t_bng *x, t_glist *glist)
     int x1=text_xpix(&x->x_gui.x_obj, glist);
     int y1=text_ypix(&x->x_gui.x_obj, glist);
 
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_move(&x->x_gui, canvas);
     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;
     sys_vgui(".x%lx.c coords %lxBUT %f %f\n", canvas, x, cx, cy);
     sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n",
         canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr);
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
-    iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+    iemgui_label_draw_move(&x->x_gui,canvas);
+    iemgui_io_draw_move(&x->x_gui,canvas);
 }
 
 void bng_draw_config(t_bng* x, t_glist* glist)
@@ -127,7 +129,6 @@ void bng_draw(t_bng *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_UPDATE)      sys_queuegui(x, x->x_gui.x_glist, bng_draw_update);
     else if(mode == IEM_GUI_DRAW_MODE_MOVE)   bng_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    bng_draw_new(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) bng_draw_config(x, glist);
 }
 
@@ -171,12 +172,8 @@ void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
         ftbreak = fthold;
         fthold = h;
     }
-    if(ftbreak < IEM_BNG_MINBREAKFLASHTIME)
-        ftbreak = IEM_BNG_MINBREAKFLASHTIME;
-    if(fthold < IEM_BNG_MINHOLDFLASHTIME)
-        fthold = IEM_BNG_MINHOLDFLASHTIME;
-    x->x_flashtime_break = ftbreak;
-    x->x_flashtime_hold = fthold;
+    x->x_flashtime_break = maxi(ftbreak,IEM_BNG_MINBREAKFLASHTIME);
+    x->x_flashtime_hold  = maxi(fthold,  IEM_BNG_MINHOLDFLASHTIME);
 }
 
 static void bng_properties(t_gobj *z, t_glist *owner)
diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c
index e6902685b..040ab1212 100644
--- a/pd/src/g_canvas.c
+++ b/pd/src/g_canvas.c
@@ -712,12 +712,10 @@ void canvas_draw_gop_resize_hooks(t_canvas* x)
 
         scalehandle_draw_select(sh,x,
             -1-x->gl_obj.te_xpix+x->gl_xmargin + x->gl_pixwidth,
-            -1-x->gl_obj.te_ypix+x->gl_ymargin + x->gl_pixheight,
-            "GOP_resblob");
+            -1-x->gl_obj.te_ypix+x->gl_ymargin + x->gl_pixheight/*,GOP_resblob*/);
         scalehandle_draw_select(mh,x,
             2+SCALEHANDLE_WIDTH -x->gl_obj.te_xpix+x->gl_xmargin,
-            2+SCALEHANDLE_HEIGHT-x->gl_obj.te_ypix+x->gl_ymargin,
-            "GOP_movblob");
+            2+SCALEHANDLE_HEIGHT-x->gl_obj.te_ypix+x->gl_ymargin /*,"GOP_movblob"*/);
     }
     else
     {
diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c
index 17fd97633..b04974c2e 100644
--- a/pd/src/g_mycanvas.c
+++ b/pd/src/g_mycanvas.c
@@ -23,18 +23,17 @@ t_widgetbehavior my_canvas_widgetbehavior;
 void my_canvas_draw_new(t_my_canvas *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int x1=text_xpix(&x->x_gui.x_obj, glist);
     int y1=text_ypix(&x->x_gui.x_obj, glist);
 
     sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x -stroke #%6.6x "
-        "-tags {%lxRECT %lxOBJ %s text iemgui}\n",
+        "-tags {%lxRECT x%lx text iemgui}\n",
         canvas, x1, y1, x1+x->x_vis_w, y1+x->x_vis_h,
-        x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag);
+        x->x_gui.x_bcol, x->x_gui.x_bcol, x, x);
     sys_vgui(".x%lx.c create prect %d %d %d %d -stroke #%6.6x "
-        "-tags {%lxBASE %lxOBJ %s text iemgui}\n",
+        "-tags {%lxBASE x%lx text iemgui}\n",
         canvas, x1, y1, x1+x->x_gui.x_w, y1+x->x_gui.x_h,
-        x->x_gui.x_bcol, x, x, nlet_tag);
+        x->x_gui.x_bcol, x, x);
 }
 
 void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
@@ -48,7 +47,7 @@ void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
         canvas, x, x1, y1, x1+x->x_vis_w, y1+x->x_vis_h);
     sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
         canvas, x, x1, y1, x1+x->x_gui.x_w, y1+x->x_gui.x_h);
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
+    iemgui_label_draw_move(&x->x_gui,canvas);
 }
 
 void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
@@ -131,7 +130,6 @@ void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_MOVE)        my_canvas_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    my_canvas_draw_new(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_canvas_draw_select(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) my_canvas_draw_config(x, glist);
 }
 
@@ -163,7 +161,6 @@ static void my_canvas_save(t_gobj *z, t_binbuf *b)
     t_my_canvas *x = (t_my_canvas *)z;
     int bflcol[3];
     t_symbol *srl[3];
-
     iemgui_save(&x->x_gui, srl, bflcol);
     binbuf_addv(b, "ssiisiiisssiiiiiii;", gensym("#X"),gensym("obj"),
         (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
@@ -294,7 +291,7 @@ static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
             /* disastrously, the "label" sits in a different part of the
             message.  So we have to track its location separately (in
             the slot x_labelbindex) and initialize it specially here. */
-        iemgui_new_dogetname(&x->x_gui, i+3, argv);
+        iemgui_getfloatsym(argv+i+3);
         x->x_gui.x_labelbindex = i+4;
         ldx = atom_getintarg(i+4, argc, argv);
         ldy = atom_getintarg(i+5, argc, argv);
diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c
index 0fd600f6a..96b0ea181 100644
--- a/pd/src/g_numbox.c
+++ b/pd/src/g_numbox.c
@@ -11,6 +11,7 @@
 #include "g_canvas.h"
 #include "g_all_guis.h"
 #include <math.h>
+#define IEM_GUI_COLOR_EDITED 0xff0000
 
 static t_class *scalehandle_class;
 extern int gfxstub_haveproperties(void *key);
@@ -148,7 +149,6 @@ static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
 static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
     int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_numwidth;
     int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h;
@@ -156,24 +156,24 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
 
     sys_vgui(
         ".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d -stroke %s"
-        " -fill %s -tags {%lxBASE1 %lxOBJ %s text iemgui}\n",
+        " -fill %s -tags {%lxBASE1 x%lx text iemgui}\n",
         canvas, x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2,
         x->x_hide_frame <= 1 ? IEM_GUI_COLOR_NORMAL : bcol,
-        bcol, x, x, nlet_tag);
+        bcol, x, x);
 
     if (x->x_hide_frame <= 1) iemgui_draw_io(&x->x_gui,glist,7);
     if (!x->x_hide_frame || x->x_hide_frame == 2)
         sys_vgui(".x%lx.c create polyline %d %d %d %d %d %d -stroke #%6.6x "
-            "-tags {%lxBASE2 %lxOBJ %s text iemgui}\n",
+            "-tags {%lxBASE2 x%lx text iemgui}\n",
             canvas, x1, y1, x1 + half, y1 + half, x1, y2,
-            x->x_gui.x_fcol, x, x, nlet_tag);
+            x->x_gui.x_fcol, x, x);
     my_numbox_ftoa(x);
     sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w "
         "-font {{%s} -%d %s} -fill #%6.6x "
-        "-tags {%lxNUMBER %lxOBJ %s noscroll text iemgui}\n",
+        "-tags {%lxNUMBER x%lx noscroll text iemgui}\n",
         canvas, x1+half+2, y1+half+d,
         x->x_buf, iemgui_font(&x->x_gui), x->x_gui.x_fontsize, sys_fontweight,
-        x->x_gui.x_fcol, x, x, nlet_tag);
+        x->x_gui.x_fcol, x, x);
 }
 
 static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
@@ -184,15 +184,14 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
     int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_numwidth;
     int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h;
 
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     sys_vgui(".x%lx.c coords %lxBASE1 %d %d %d %d %d %d %d %d %d %d\n",
         canvas, x, x1, y1, x2-4, y1, x2, y1+4, x2, y2, x1, y2);
     if (x->x_hide_frame <= 1)
-        iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+        iemgui_io_draw_move(&x->x_gui,canvas);
     if (!x->x_hide_frame || x->x_hide_frame == 2)
         sys_vgui(".x%lx.c coords %lxBASE2 %d %d %d %d %d %d\n",
             canvas, x, x1, y1, x1 + half, y1 + half, x1, y2);
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
+    iemgui_label_draw_move(&x->x_gui,canvas);
     sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n",
         canvas, x, x1+half+2, y1+half+d);
 }
@@ -340,7 +339,6 @@ void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode)
     else if(mode == IEM_GUI_DRAW_MODE_MOVE)   my_numbox_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    my_numbox_draw_new(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_SELECT) my_numbox_draw_select(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) my_numbox_draw_config(x, glist);
 }
 
@@ -481,7 +479,7 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
     x->x_numwidth = my_numbox_calc_fontwidth(x);
     my_numbox_check_minmax(x, min, max);
     //if (need_to_redraw) {
-    x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+    iemgui_draw_erase(&x->x_gui, x->x_gui.x_glist);
     iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_NEW);
     /*} else {
         x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
@@ -491,8 +489,7 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
         iemgui_shouldvis(&x->x_gui, IEM_GUI_DRAW_MODE_MOVE);
     }*/
     scalehandle_draw(&x->x_gui, x->x_gui.x_glist);
-    canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x,
-        iem_get_tag(x->x_gui.x_glist, (t_iemgui *)x), -1);
+    //canvas_restore_original_position(x->x_gui.x_glist, (t_gobj *)x,"bogus",-1);
     scrollbar_update(x->x_gui.x_glist);
 }
 
diff --git a/pd/src/g_radio.c b/pd/src/g_radio.c
index 7d008daf2..7824c05d4 100644
--- a/pd/src/g_radio.c
+++ b/pd/src/g_radio.c
@@ -16,6 +16,8 @@
 #include "g_all_guis.h"
 #include <math.h>
 
+#define IEM_RADIO_MAX   128
+
 static t_class *scalehandle_class;
 extern int gfxstub_haveproperties(void *key);
 t_widgetbehavior radio_widgetbehavior;
@@ -37,36 +39,35 @@ void radio_draw_update(t_gobj *client, t_glist *glist)
 void radio_draw_new(t_radio *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int n=x->x_number, i, d=x->x_gui.x_w, s=d/4;
     int x1=text_xpix(&x->x_gui.x_obj, glist), xi=x1;
     int y1=text_ypix(&x->x_gui.x_obj, glist), yi=y1; 
-    iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_new(&x->x_gui, canvas);
 
     for(i=0; i<n; i++) if (x->x_orient) {
         if (i) sys_vgui(".x%lx.c create pline %d %d %d %d "
             "-stroke $pd_colors(iemgui_border) "
-            "-tags {%lxBASE%d %lxBASEL %lxOBJ %s text iemgui border}\n",
-            canvas, x1, yi, x1+d, yi, x, i, x, x, nlet_tag);
+            "-tags {%lxBASE%d %lxBASEL x%lx text iemgui border}\n",
+            canvas, x1, yi, x1+d, yi, x, i, x, x);
         sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x "
-            "-stroke #%6.6x -tags {%lxBUT%d %lxOBJ %s text iemgui}\n",
+            "-stroke #%6.6x -tags {%lxBUT%d x%lx text iemgui}\n",
             canvas, x1+s, yi+s, x1+d-s, yi+d-s,
             (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
             (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
-            x, i, x, nlet_tag);
+            x, i, x);
         yi += d;
         x->x_drawn = x->x_on;
     } else {
         if (i) sys_vgui(".x%lx.c create pline %d %d %d %d "
             "-stroke $pd_colors(iemgui_border) "
-            "-tags {%lxBASE%d %lxBASEL %lxOBJ %s text iemgui border}\n",
-            canvas, xi, y1, xi, y1+d, x, i, x, x, nlet_tag);
+            "-tags {%lxBASE%d %lxBASEL x%lx text iemgui border}\n",
+            canvas, xi, y1, xi, y1+d, x, i, x, x);
         sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x "
-            "-stroke #%6.6x -tags {%lxBUT%d %lxOBJ %s text iemgui}\n",
+            "-stroke #%6.6x -tags {%lxBUT%d x%lx text iemgui}\n",
             canvas, xi+s, y1+s, xi+d-s, y1+d-s,
             (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
             (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
-            x, i, x, nlet_tag);
+            x, i, x);
         xi += d;
         x->x_drawn = x->x_on;
     }
@@ -79,8 +80,7 @@ void radio_draw_move(t_radio *x, t_glist *glist)
     int n=x->x_number, i, d=x->x_gui.x_w, s=d/4;
     int x1=text_xpix(&x->x_gui.x_obj, glist), xi=x1;
     int y1=text_ypix(&x->x_gui.x_obj, glist), yi=y1;
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_move(&x->x_gui, canvas);
     for(i=0; i<n; i++) if (x->x_orient) {
         sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n",
             canvas, x, i, x1, yi, x1+d, yi);
@@ -94,8 +94,8 @@ void radio_draw_move(t_radio *x, t_glist *glist)
             canvas, x, i, xi+s, y1+s, xi+d-s, y1+d-s);
         xi += d;
     }
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
-    iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+    iemgui_label_draw_move(&x->x_gui,canvas);
+    iemgui_io_draw_move(&x->x_gui,canvas);
 }
 
 void radio_draw_config(t_radio *x, t_glist *glist)
@@ -174,7 +174,6 @@ void radio_draw(t_radio *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_UPDATE)        sys_queuegui(x, glist, radio_draw_update);
     else if(mode == IEM_GUI_DRAW_MODE_MOVE)     radio_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)      radio_draw_new(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)    iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG)   radio_draw_config(x, glist);
 }
 
@@ -252,7 +251,7 @@ static void radio_dialog(t_radio *x, t_symbol *s, int argc, t_atom *argv)
     int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
     if(x->x_number != num)
     {
-        x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+        iemgui_draw_erase(&x->x_gui, x->x_gui.x_glist);
         x->x_number = num;
         if(x->x_on >= x->x_number)
         {
@@ -392,7 +391,7 @@ static void radio_number(t_radio *x, t_floatarg num)
     int n=mini(maxi((int)num,1),IEM_RADIO_MAX);
     if(n != x->x_number)
     {
-        x->x_gui.x_draw(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+        iemgui_draw_erase(&x->x_gui, x->x_gui.x_glist);
         x->x_number = n;
         if(x->x_on >= x->x_number)
             x->x_on = x->x_number - 1;
diff --git a/pd/src/g_slider.c b/pd/src/g_slider.c
index 49c58c3ec..61ab9cd3b 100644
--- a/pd/src/g_slider.c
+++ b/pd/src/g_slider.c
@@ -49,22 +49,21 @@ static void slider_draw_update(t_gobj *client, t_glist *glist)
 static void slider_draw_new(t_slider *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_gui.x_w;
     int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h;
     if (x->x_orient) y2+=5; else x2+=5;
     int r;
     if (x->x_orient) r = y2-3 - (x->x_val + 50)/100;
     else             r = x1+3 + (x->x_val + 50)/100;
-    iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_new(&x->x_gui, canvas);
     if (x->x_orient) {
         sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 "
-            "-stroke #%6.6x -tags {%lxKNOB %lxOBJ %s text iemgui}\n",
-            canvas, x1+2, r, x2-2, r, x->x_gui.x_fcol, x, x, nlet_tag);
+            "-stroke #%6.6x -tags {%lxKNOB x%lx text iemgui}\n",
+            canvas, x1+2, r, x2-2, r, x->x_gui.x_fcol, x, x);
     } else {
         sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 "
-            "-stroke #%6.6x -tags {%lxKNOB %lxOBJ %s text iemgui}\n",
-            canvas, r, y1+2, r, y2-2, x->x_gui.x_fcol, x, x, nlet_tag);
+            "-stroke #%6.6x -tags {%lxKNOB x%lx text iemgui}\n",
+            canvas, r, y1+2, r, y2-2, x->x_gui.x_fcol, x, x);
     }
 }
 
@@ -78,16 +77,15 @@ static void slider_draw_move(t_slider *x, t_glist *glist)
     int r;
     if (x->x_orient) r = y2-3 - (x->x_val + 50)/100;
     else             r = x1+3 + (x->x_val + 50)/100;
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_move(&x->x_gui, canvas);
     if (x->x_orient)
         sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
             canvas, x, x1+2, r, x2-2, r);
     else
         sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
             canvas, x, r, y1+2, r, y2-2);
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
-    iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+    iemgui_label_draw_move(&x->x_gui,canvas);
+    iemgui_io_draw_move(&x->x_gui,canvas);
 }
 
 static void slider_draw_config(t_slider *x, t_glist *glist)
@@ -174,7 +172,6 @@ void slider_draw(t_slider *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_UPDATE)      sys_queuegui(x, glist, slider_draw_update);
     else if(mode == IEM_GUI_DRAW_MODE_MOVE)   slider_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    slider_draw_new(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) slider_draw_config(x, glist);
 }
 
@@ -196,7 +193,6 @@ static void slider_save(t_gobj *z, t_binbuf *b)
     t_slider *x = (t_slider *)z;
     int bflcol[3];
     t_symbol *srl[3];
-
     iemgui_save(&x->x_gui, srl, bflcol);
     binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
         (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c
index 0a8bdf244..d5a54f097 100644
--- a/pd/src/g_toggle.c
+++ b/pd/src/g_toggle.c
@@ -39,20 +39,19 @@ void toggle_draw_update(t_gobj *xgobj, t_glist *glist)
 void toggle_draw_new(t_toggle *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int w=(x->x_gui.x_w+29)/30;
     int x1=text_xpix(&x->x_gui.x_obj, glist);
     int y1=text_ypix(&x->x_gui.x_obj, glist);
     int x2=x1+x->x_gui.x_w, y2=y1+x->x_gui.x_h;
     int col = (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol;
 
-    iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_new(&x->x_gui, canvas);
     sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d "
-        "-stroke #%6.6x -tags {%lxX1 %lxOBJ %s text iemgui}\n",
-        canvas, x1+w+1, y1+w+1, x2-w-1, y2-w-1, w, col, x, x, nlet_tag);
+        "-stroke #%6.6x -tags {%lxX1 x%lx text iemgui}\n",
+        canvas, x1+w+1, y1+w+1, x2-w-1, y2-w-1, w, col, x, x);
     sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d "
-        "-stroke #%6.6x -tags {%lxX2 %lxOBJ %s text iemgui}\n",
-        canvas, x1+w+1, y2-w-1, x2-w-1, y1+w+1, w, col, x, x, nlet_tag);
+        "-stroke #%6.6x -tags {%lxX2 x%lx text iemgui}\n",
+        canvas, x1+w+1, y2-w-1, x2-w-1, y1+w+1, w, col, x, x);
 }
 
 void toggle_draw_move(t_toggle *x, t_glist *glist)
@@ -63,15 +62,14 @@ void toggle_draw_move(t_toggle *x, t_glist *glist)
     int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_gui.x_w;
     int y1=text_ypix(&x->x_gui.x_obj, glist), y2=y1+x->x_gui.x_h;
 
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    iemgui_base_draw_move(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_move(&x->x_gui, canvas);
     sys_vgui(".x%lx.c itemconfigure {%lxX1||%lxX2} -strokewidth %d\n", canvas, x, x, w);
     sys_vgui(".x%lx.c coords %lxX1 %d %d %d %d\n",
         canvas, x, x1+s, y1+s, x2-s, y2-s);
     sys_vgui(".x%lx.c coords %lxX2 %d %d %d %d\n",
         canvas, x, x1+s, y2-s, x2-s, y1+s);
-    iemgui_label_draw_move(&x->x_gui,canvas,x1,y1);
-    iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+    iemgui_label_draw_move(&x->x_gui,canvas);
+    iemgui_io_draw_move(&x->x_gui,canvas);
 }
 
 void toggle_draw_config(t_toggle* x, t_glist* glist)
@@ -133,7 +131,6 @@ void toggle_draw(t_toggle *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_UPDATE)      sys_queuegui(x, x->x_gui.x_glist, toggle_draw_update);
     else if(mode == IEM_GUI_DRAW_MODE_MOVE)   toggle_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    toggle_draw_new(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) toggle_draw_config(x, glist);
 }
 
diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c
index 11b968866..14a49af5f 100644
--- a/pd/src/g_vumeter.c
+++ b/pd/src/g_vumeter.c
@@ -13,13 +13,14 @@
 #include "g_all_guis.h"
 #include <math.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
+#define IEM_VU_DEFAULTSIZE 3
+#define IEM_VU_LARGESMALL  2
+#define IEM_VU_MINSIZE     2
+#define IEM_VU_MAXSIZE     25
+#define IEM_VU_STEPS       40
+#define IEM_VU_MINDB    -99.9
+#define IEM_VU_MAXDB    12.0
+#define IEM_VU_OFFSET   100.0
 
 char *iemgui_vu_scale_str[]={
     "<-99", "-50", "-30", "-20", "-12", "-6",
@@ -70,8 +71,8 @@ static void vu_update_rms(t_vu *x, t_glist *glist)
     if (glist_isvisible(glist))
     {
         int w4 = x->x_gui.x_w / 4, off=text_ypix(&x->x_gui.x_obj, glist) - 1;
-        int xpos = text_xpix(&x->x_gui.x_obj, glist),
-            quad1 = xpos + w4 + 1, quad3 = xpos + x->x_gui.x_w-w4 - 1;
+        int x1 = text_xpix(&x->x_gui.x_obj, glist),
+            quad1 = x1 + w4 + 1, quad3 = x1 + x->x_gui.x_w-w4 - 1;
 
         sys_vgui(".x%lx.c coords %lxRCOVER %d %d %d %d\n",
             glist_getcanvas(glist), x, quad1 + 1, off + 2, quad3 + 1,
@@ -85,28 +86,28 @@ static void vu_update_peak(t_vu *x, t_glist *glist)
 
     if(glist_isvisible(glist))
     {
-        int xpos = text_xpix(&x->x_gui.x_obj, glist);
-        int ypos = text_ypix(&x->x_gui.x_obj, glist);
+        int x1 = text_xpix(&x->x_gui.x_obj, glist);
+        int y1 = text_ypix(&x->x_gui.x_obj, glist);
 
         if(x->x_peak)
         {
             int i = iemgui_vu_col[x->x_peak];
-            int j = ypos + (x->x_led_size + 1) * (IEM_VU_STEPS + 1 - x->x_peak)
+            int j = y1 + (x->x_led_size + 1) * (IEM_VU_STEPS + 1 - x->x_peak)
                 - (x->x_led_size + 1) / 2;
 
             sys_vgui(".x%lx.c coords %lxPLED %d %d %d %d\n",
-                canvas, x, xpos + 1, j + 2, xpos + x->x_gui.x_w + 2, j + 2);
+                canvas, x, x1 + 1, j + 2, x1 + x->x_gui.x_w + 2, j + 2);
             sys_vgui(".x%lx.c itemconfigure %lxPLED -stroke #%6.6x\n",
                 canvas, x, iemgui_color_hex[i]);
         }
         else
         {
-            int mid = xpos + x->x_gui.x_w / 2;
+            int mid = x1 + x->x_gui.x_w / 2;
 
             sys_vgui(".x%lx.c itemconfigure %lxPLED -stroke #%6.6x\n",
                      canvas, x, x->x_gui.x_bcol);
             sys_vgui(".x%lx.c coords %lxPLED %d %d %d %d\n",
-                     canvas, x, mid+1, ypos+22, mid+1, ypos+22);
+                     canvas, x, mid+1, y1+22, mid+1, y1+22);
         }
     }
 }
@@ -129,14 +130,13 @@ static void vu_draw_update(t_gobj *client, t_glist *glist)
 static void vu_draw_new(t_vu *x, t_glist *glist)
 {
     t_canvas *canvas=glist_getcanvas(glist);
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
     int x1=text_xpix(&x->x_gui.x_obj, glist), x2=x1+x->x_gui.x_w;
     int y1=text_ypix(&x->x_gui.x_obj, glist);
     int w4=x->x_gui.x_w/4, mid=x1+x->x_gui.x_w/2, quad1=x1+w4+1;
     int quad3=x2-w4, end=x2+4;
     int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
     int led_col, yyy, i, k4=y1-k3;
-    iemgui_base_draw_new(&x->x_gui, canvas, nlet_tag);
+    iemgui_base_draw_new(&x->x_gui, canvas);
 
     for(i = 1; i <= IEM_VU_STEPS+1; i++)
     {
@@ -144,27 +144,27 @@ static void vu_draw_new(t_vu *x, t_glist *glist)
         if((i&3)==1 && (x->x_scale))
             sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w "
                 "-font {{%s} -%d %s} -fill #%6.6x "
-                "-tags {%lxSCALEN %lxSCALE%d %lxOBJ %s text iemgui}\n",
+                "-tags {%lxSCALEN %lxSCALE%d x%lx text iemgui}\n",
                 canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i/4], 
                 iemgui_font(&x->x_gui), x->x_gui.x_fontsize,
-                sys_fontweight, x->x_gui.x_lcol, x, x, i, x, nlet_tag);
+                sys_fontweight, x->x_gui.x_lcol, x, x, i, x);
 
         led_col = iemgui_vu_col[i];
         if (i<=IEM_VU_STEPS) sys_vgui(".x%lx.c create polyline %d %d %d %d "
             "-strokewidth %d -stroke #%6.6x "
-            "-tags {%lxRLED%d %lxOBJ %s text iemgui}\n",
+            "-tags {%lxRLED%d x%lx text iemgui}\n",
             canvas, quad1+1, yyy+2, quad3, yyy+2,
-            x->x_led_size, iemgui_color_hex[led_col], x, i, x, nlet_tag);
+            x->x_led_size, iemgui_color_hex[led_col], x, i, x);
     }
     sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x "
-        "-stroke #%6.6x -tags {%lxRCOVER %lxOBJ %s text iemgui}\n",
+        "-stroke #%6.6x -tags {%lxRCOVER x%lx text iemgui}\n",
         canvas, quad1+1, y1+1, quad3, y1+1 + k1*IEM_VU_STEPS,
-        x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag);
+        x->x_gui.x_bcol, x->x_gui.x_bcol, x, x);
     sys_vgui(".x%lx.c create polyline %d %d %d %d "
         "-strokewidth %d -fill #%6.6x "
-        "-tags {%lxPLED %lxOBJ %s text iemgui}\n",
+        "-tags {%lxPLED x%lx text iemgui}\n",
         canvas, mid+1, y1+12,
-        mid+1, y1+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag);
+        mid+1, y1+12, x->x_led_size, x->x_gui.x_bcol, x, x);
     iemgui_draw_io(&x->x_gui,glist,7);
     x->x_updaterms = x->x_updatepeak = 1;
     sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);
@@ -175,16 +175,15 @@ static void vu_draw_move(t_vu *x, t_glist *glist)
     t_canvas *canvas=glist_getcanvas(glist);
     if (!glist_isvisible(canvas)) return;
 
-    char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x);
-    int xpos=text_xpix(&x->x_gui.x_obj, glist);
-    int ypos=text_ypix(&x->x_gui.x_obj, glist);
-    int w4=x->x_gui.x_w/4, quad1=xpos+w4+1;
-    int quad3=xpos+x->x_gui.x_w-w4,
-          end=xpos+x->x_gui.x_w+4;
+    int x1=text_xpix(&x->x_gui.x_obj, glist);
+    int y1=text_ypix(&x->x_gui.x_obj, glist);
+    int w4=x->x_gui.x_w/4, quad1=x1+w4+1;
+    int quad3=x1+x->x_gui.x_w-w4,
+          end=x1+x->x_gui.x_w+4;
     int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
-    int yyy, i, k4=ypos-k3;
+    int yyy, i, k4=y1-k3;
     sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
-        canvas, x, xpos, ypos, xpos+x->x_gui.x_w+2,ypos+x->x_gui.x_h+4);
+        canvas, x, x1, y1, x1+x->x_gui.x_w+2,y1+x->x_gui.x_h+4);
     for(i=1; i<=IEM_VU_STEPS; i++)
     {
         yyy = k4 + k1*(k2-i);
@@ -203,8 +202,8 @@ static void vu_draw_move(t_vu *x, t_glist *glist)
     }
     x->x_updaterms = x->x_updatepeak = 1;
     sys_queuegui(x, glist, vu_draw_update);
-    iemgui_label_draw_move(&x->x_gui,canvas,xpos,ypos);
-    iemgui_io_draw_move(&x->x_gui,canvas,nlet_tag);
+    iemgui_label_draw_move(&x->x_gui,canvas);
+    iemgui_io_draw_move(&x->x_gui,canvas);
 }
 
 static void vu_draw_config(t_vu* x, t_glist* glist)
@@ -296,7 +295,6 @@ void vu_draw(t_vu *x, t_glist *glist, int mode)
     if(mode == IEM_GUI_DRAW_MODE_MOVE)        vu_draw_move(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_NEW)    vu_draw_new(x, glist);
     else if(mode == IEM_GUI_DRAW_MODE_SELECT) vu_draw_select(x, glist);
-    else if(mode == IEM_GUI_DRAW_MODE_ERASE)  iemgui_draw_erase(&x->x_gui, glist);
     else if(mode == IEM_GUI_DRAW_MODE_CONFIG) vu_draw_config(x, glist);
 }
 
@@ -371,9 +369,9 @@ static void vu_getrect(t_gobj *z, t_glist *glist,
     t_vu* x = (t_vu*)z;
 
     int yyy, end;
-    int xpos=text_xpix(&x->x_gui.x_obj, glist);
-    int ypos=text_ypix(&x->x_gui.x_obj, glist);
-    int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2, k4=ypos-k3;
+    int x1=text_xpix(&x->x_gui.x_obj, glist);
+    int y1=text_ypix(&x->x_gui.x_obj, glist);
+    int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2, k4=y1-k3;
 
     *xp1 = text_xpix(&x->x_gui.x_obj, glist);
     *yp1 = text_ypix(&x->x_gui.x_obj, glist);
@@ -385,7 +383,7 @@ static void vu_getrect(t_gobj *z, t_glist *glist,
     if (x->x_scale)
     {
         //vu has custom scale all labels unlike other iemgui object
-        end=xpos+x->x_gui.x_w+4;
+        end=x1+x->x_gui.x_w+4;
         yyy = k4 + k1*(k2-1);
         vu_scale_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2, end+1, yyy+k3+2);
         yyy = k4;
@@ -453,19 +451,19 @@ static void vu_scale(t_vu *x, t_floatarg fscale)
                 if((i&3)==1)
                     sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w "
                              "-font {{%s} -%d %s} -fill #%6.6x "
-                             "-tags {%lxSCALE%d %lxOBJ %lx}\n",
+                             "-tags {%lxSCALE%d x%lx}\n",
                         canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i/4], 
                         iemgui_font(&x->x_gui), x->x_gui.x_fontsize,
-                        sys_fontweight, x->x_gui.x_lcol, x, i, x, x);
+                        sys_fontweight, x->x_gui.x_lcol, x, i, x);
             }
             i = IEM_VU_STEPS + 1;
             yyy = k4 + k1*(k2-i);
             sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w "
                      "-font {{%s} -%d %s} -fill #%6.6x "
-                     "-tags {%lxSCALE%d %lxOBJ %lx}\n",
+                     "-tags {%lxSCALE%d x%lx}\n",
                 canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i/4], 
                 iemgui_font(&x->x_gui), x->x_gui.x_fontsize,
-                sys_fontweight, x->x_gui.x_lcol, x, i, x, x);
+                sys_fontweight, x->x_gui.x_lcol, x, i, x);
         }
     }
 }
-- 
GitLab