From 6fab90273a1639b1c9a0741f89a47f970d99e827 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Sun, 28 Apr 2013 19:07:31 -0400 Subject: [PATCH] added ability for gop to intelligently detect when iemgui objects fit (or don't) inside gop window. the same also applies to dynamic changes to iemgui properties (size, font, label, delta, position, etc.) --- pd/src/g_all_guis.c | 121 +++++++++++++++++++++++++++++++++----- pd/src/g_all_guis.h | 3 + pd/src/g_bang.c | 35 ++++++----- pd/src/g_editor.c | 15 +++-- pd/src/g_hdial.c | 35 ++++++----- pd/src/g_hslider.c | 35 ++++++----- pd/src/g_mycanvas.c | 4 +- pd/src/g_numbox.c | 38 ++++++------ pd/src/g_toggle.c | 35 ++++++----- pd/src/g_vdial.c | 38 ++++++------ pd/src/g_vslider.c | 35 ++++++----- pd/src/g_vumeter.c | 139 ++++++++++++++++++++++++++++++++++---------- 12 files changed, 368 insertions(+), 165 deletions(-) diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 0d905fedd..e1b177007 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -415,21 +415,25 @@ void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s) iemgui->x_lab_unexpanded = lab; iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab); - if(glist_isvisible(iemgui->x_glist)) + if(glist_isvisible(iemgui->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -text {%s} \n", glist_getcanvas(iemgui->x_glist), x, strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:""); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } } void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) { iemgui->x_ldx = (int)atom_getintarg(0, ac, av); iemgui->x_ldy = (int)atom_getintarg(1, ac, av); - if(glist_isvisible(iemgui->x_glist)) + if(glist_isvisible(iemgui->x_glist)) { sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", glist_getcanvas(iemgui->x_glist), x, text_xpix((t_object *)x,iemgui->x_glist)+iemgui->x_ldx, text_ypix((t_object *)x,iemgui->x_glist)+iemgui->x_ldy); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } } void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) @@ -448,18 +452,109 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a if(f < 4) f = 4; iemgui->x_fontsize = f; - if(glist_isvisible(iemgui->x_glist)) + if(glist_isvisible(iemgui->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n", glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, iemgui->x_fontsize, sys_fontweight); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } +} + +//Sans: 84 x 10 (14) -> 6 x 10 -> 1.0 +//Helvetica: 70 x 10 (14) -> 5 x 10 -> 0.83333 +//Times: 61 x 10 (14) -> 4.357 x 10 -> 0.72619; 0.735 appears to work better + +void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, int *xp2, int *yp2) +{ + t_float width_multiplier; + int label_length; + int label_x1; + int label_y1; + int label_x2; + int label_y2; + int actual_fontsize; //seems tk does its own thing when it comes to rendering + int actual_height; + + if (x->gl_isgraph && !glist_istoplevel(x)) { + //fprintf(stderr,"iemgui_label_getrect\n"); + + if (strcmp(x_gui.x_lab->s_name, "empty")) { + switch(x_gui.x_fsf.x_font_style) { + case 1: + width_multiplier = 0.83333; + break; + case 2: + width_multiplier = 0.735; + break; + default: + width_multiplier = 1.0; + break; + } + if (x_gui.x_fontsize % 2 == 0) { + actual_fontsize = x_gui.x_fontsize; + } else { + actual_fontsize = x_gui.x_fontsize; + } + actual_height = actual_fontsize; + //exceptions + if (x_gui.x_fsf.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || (actual_fontsize > 48 && actual_fontsize < 100 && (actual_fontsize %10 == 4 || actual_fontsize %10 == 9))) ) { + actual_fontsize += 1; + } + else if (x_gui.x_fsf.x_font_style == 1 && actual_fontsize >= 5 && actual_fontsize < 13 && actual_fontsize % 2 == 1) + actual_fontsize += 1; + else if (x_gui.x_fsf.x_font_style == 2 && actual_fontsize >= 5 && actual_fontsize % 2 == 1) + actual_fontsize += 1; + if (actual_height == 9) + actual_height += 1; + //done with exceptions + + width_multiplier = width_multiplier * (actual_fontsize * 0.6); + + label_length = strlen(x_gui.x_lab->s_name); + label_x1 = *xp1 + x_gui.x_ldx; + label_y1 = *yp1 + x_gui.x_ldy - actual_height/2; + label_x2 = label_x1 + (label_length * width_multiplier); + label_y2 = label_y1 + actual_height*1.1; + + //DEBUG + //fprintf(stderr,"%f %d %d\n", width_multiplier, label_length, x_gui.x_fsf.x_font_style); + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", x, label_x1, label_y1, label_x2, label_y2); + if (label_x1 < *xp1) *xp1 = label_x1; + if (label_x2 > *xp2) *xp2 = label_x2; + if (label_y1 < *yp1) *yp1 = label_y1; + if (label_y2 > *yp2) *yp2 = label_y2; + //DEBUG + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", x, *xp1, *yp1, *xp2, *yp2); + } + } +} + +void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) +{ + if(gobj_shouldvis(x, iemgui->x_glist)) { + if (!iemgui->x_vis) { + //fprintf(stderr,"draw new\n"); + (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_NEW); + canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + iemgui->x_vis = 1; + } + //fprintf(stderr,"draw move iemgui->x_w=%d\n", iemgui->x_w); + (*iemgui->x_draw)(x, iemgui->x_glist, mode); + canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + } else if (iemgui->x_vis) { + //fprintf(stderr,"draw erase\n"); + (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_ERASE); + iemgui->x_vis = 0; + } } void iemgui_size(void *x, t_iemgui *iemgui) { if(glist_isvisible(iemgui->x_glist)) { - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } } @@ -469,8 +564,7 @@ void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av); if(glist_isvisible(iemgui->x_glist)) { - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } } @@ -479,10 +573,7 @@ void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av); iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av); if(glist_isvisible(iemgui->x_glist)) - { - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); - } + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) @@ -504,8 +595,7 @@ void iemgui_displace(t_gobj *z, t_glist *glist, int dx, int dy) t_iemguidummy *x = (t_iemguidummy *)z; x->x_gui.x_obj.te_xpix += dx; x->x_gui.x_obj.te_ypix += dy; - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(glist), (t_text *)z); + iemgui_shouldvis(x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } void iemgui_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) @@ -535,12 +625,15 @@ void iemgui_vis(t_gobj *z, t_glist *glist, int vis) { t_iemguidummy *x = (t_iemguidummy *)z; if (gobj_shouldvis(z, glist)) { - if (vis) + if (vis) { (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW); + x->x_gui.x_vis = 1; + } else { (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE); sys_unqueuegui(z); + x->x_gui.x_vis = 0; } } } diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index b0bdf67ac..67baa07a4 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -214,6 +214,7 @@ typedef struct _iemgui int label_offset_x; int label_offset_y; int label_vis; + int x_vis; /* is the object drawn? */ } t_iemgui; typedef struct _iemguidummy @@ -372,6 +373,8 @@ EXTERN void iemgui_receive(void *x, t_iemgui *iemgui, t_symbol *s); EXTERN void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s); EXTERN void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av); EXTERN void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av); +EXTERN void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, int *xp2, int *yp2); +EXTERN void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode); EXTERN void iemgui_size(void *x, t_iemgui *iemgui); EXTERN void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av); EXTERN void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av); diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index 259033199..4ded1525b 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -88,15 +88,15 @@ void bng_draw_new(t_bng *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxBNG outlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxBNG%so%d %lxBNG outlet}\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h, nlet_tag, 0, x); + ypos + x->x_gui.x_h, x, nlet_tag, 0, x); } if(!x->x_gui.x_fsf.x_rcv_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxBNG inlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxBNG%si%d %lxBNG inlet}\n", canvas, xpos, ypos, - xpos + IOWIDTH, ypos+1, nlet_tag, 0, x); + xpos + IOWIDTH, ypos+1, x, nlet_tag, 0, x); } //} } @@ -133,13 +133,13 @@ void bng_draw_move(t_bng *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, xpos, + sys_vgui(".x%lx.c coords %lxBNG%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, ypos + x->x_gui.x_h); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, xpos, ypos, + sys_vgui(".x%lx.c coords %lxBNG%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, xpos + IOWIDTH, ypos+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) @@ -221,18 +221,18 @@ void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxBNG%so%d\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h, nlet_tag, 0); + ypos + x->x_gui.x_h, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxBNG%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxBNG%si%d\n", canvas, xpos, ypos, - xpos + IOWIDTH, ypos+1, nlet_tag, 0); + xpos + IOWIDTH, ypos+1, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxBNG%si%d\n", canvas, x, nlet_tag, 0); } } @@ -545,6 +545,8 @@ static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void bng_save(t_gobj *z, t_binbuf *b) @@ -683,8 +685,9 @@ static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv) bng_check_minmax(x, ftbreak, fthold); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 1aa7d2af9..e0b3f53e0 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -2136,13 +2136,16 @@ void canvas_vis(t_canvas *x, t_floatarg f) } g = g->g_next; } - // now check if canvas has its properties open - properties = gfxstub_haveproperties((void *)x); - if (properties) { - //sys_vgui("destroy .gfxstub%lx\n", properties); - gfxstub_deleteforkey((void *)x); + // now check if canvas has its properties open and + // if the canvas is not gop-enabled or its parent is not visible + // close its properties + if (!x->gl_isgraph || x->gl_owner && !glist_isvisible(x->gl_owner)) { + properties = gfxstub_haveproperties((void *)x); + if (properties) { + //sys_vgui("destroy .gfxstub%lx\n", properties); + gfxstub_deleteforkey((void *)x); + } } - for (i = 1, x2 = x; x2; x2 = x2->gl_next, i++) ; diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index 69146529b..2aa640ac7 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -105,11 +105,11 @@ void hradio_draw_new(t_hradio *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxHRDO outlet}\n", - canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxHRDO%so%d %lxHRDO c outlet}\n", + canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxHRDO inlet}\n", - canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxHRDO%si%d %lxHRDO inlet}\n", + canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, x, nlet_tag, 0, x); //} } @@ -153,11 +153,11 @@ void hradio_draw_move(t_hradio *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); + sys_vgui(".x%lx.c coords %lxHRDO%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); + sys_vgui(".x%lx.c coords %lxHRDO%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) hradio_draw_select(x, x->x_gui.x_glist); @@ -249,20 +249,20 @@ void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxHRDO%so%d\n", canvas, xpos, ypos + x->x_gui.x_w-1, xpos + IOWIDTH, ypos + x->x_gui.x_w, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxHRDO%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxHRDO%si%d\n", canvas, xpos, ypos, - xpos + IOWIDTH, ypos+1, nlet_tag, 0); + xpos + IOWIDTH, ypos+1, x,nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxHRDO%si%d\n", canvas, x, nlet_tag, 0); } } @@ -572,6 +572,8 @@ static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *x *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w*x->x_number; *yp2 = *yp1 + x->x_gui.x_h; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void hradio_save(t_gobj *z, t_binbuf *b) @@ -652,8 +654,9 @@ static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } /* forcing redraw of the scale handle */ diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index aa97573fb..fd08d4008 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -111,13 +111,13 @@ static void hslider_draw_new(t_hslider *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxHSLDR outlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxHSLDR%so%d %lxHSLDR outlet}\n", canvas, xpos, ypos + x->x_gui.x_h-1, - xpos+7, ypos + x->x_gui.x_h, nlet_tag, 0, x); + xpos+7, ypos + x->x_gui.x_h, x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxHSLDR inlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxHSLDR%si%d %lxHSLDR inlet}\n", canvas, xpos, ypos, - xpos+7, ypos+1, nlet_tag, 0, x); + xpos+7, ypos+1, x, nlet_tag, 0, x); //} } @@ -153,13 +153,13 @@ static void hslider_draw_move(t_hslider *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxHSLDR%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos+7, ypos + x->x_gui.x_h); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxHSLDR%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, xpos+7, ypos+1); /* redraw scale handle rectangle if selected */ @@ -242,17 +242,17 @@ static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxHSLDR%so%d\n", canvas, xpos, ypos + x->x_gui.x_h-1, - xpos+7, ypos + x->x_gui.x_h, nlet_tag, 0); + xpos+7, ypos + x->x_gui.x_h, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxHSLDR%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxHSLDR%si%d\n", canvas, xpos, ypos, - xpos+7, ypos+1, nlet_tag, 0); + xpos+7, ypos+1, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxHSLDR%si%d\n", canvas, x, nlet_tag, 0); } } @@ -559,6 +559,8 @@ static void hslider_getrect(t_gobj *z, t_glist *glist, *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w + 8; *yp2 = *yp1 + x->x_gui.x_h; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void hslider_save(t_gobj *z, t_binbuf *b) @@ -727,8 +729,9 @@ static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv) hslider_check_minmax(x, min, max); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index 9eef50ea2..a59d012ce 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -439,6 +439,7 @@ static void my_canvas_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h; } + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void my_canvas_save(t_gobj *z, t_binbuf *b) @@ -514,7 +515,8 @@ static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv h = 1; x->x_vis_h = h; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index d01051f17..e1d96d7df 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -224,17 +224,17 @@ static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist) xpos, ypos + x->x_gui.x_h, IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxNUM outlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxNUM%so%d %lxNUM outlet}\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos+IOWIDTH, ypos + x->x_gui.x_h, - nlet_tag, 0, x); + x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxNUM inlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxNUM%si%d %lxNUM inlet}\n", canvas, xpos, ypos, xpos+IOWIDTH, ypos+1, - nlet_tag, 0, x); + x, nlet_tag, 0, x); } else { sys_vgui( ".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d -outline #%6.6x \ @@ -298,13 +298,13 @@ static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist) xpos, ypos + x->x_gui.x_h); if (x->x_hide_frame <= 1) { if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxNUM%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h-1, xpos+IOWIDTH, ypos + x->x_gui.x_h); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxNUM%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, xpos+IOWIDTH, ypos+1); } @@ -417,21 +417,21 @@ static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_fla else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxNUM%so%d\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos+IOWIDTH, ypos + x->x_gui.x_h, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxNUM%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxNUM%si%d\n", canvas, xpos, ypos, xpos+IOWIDTH, ypos+1, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxNUM%si%d\n", canvas, x, nlet_tag, 0); } } @@ -784,6 +784,8 @@ static void my_numbox_getrect(t_gobj *z, t_glist *glist, *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_numwidth; *yp2 = *yp1 + x->x_gui.x_h; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void my_numbox_save(t_gobj *z, t_binbuf *b) @@ -928,12 +930,14 @@ static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc, 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); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); + iemgui_shouldvis((void *)x, &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); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index b24a5087e..6dc447679 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -96,11 +96,11 @@ void toggle_draw_new(t_toggle *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxTGL outlet}\n", - canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxTGL%so%d %lxTGL outlet}\n", + canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxTGL inlet}\n", - canvas, xx, yy, xx + IOWIDTH, yy+1, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxTGL%si%d %lxTGL inlet}\n", + canvas, xx, yy, xx + IOWIDTH, yy+1, x, nlet_tag, 0, x); //} } @@ -140,11 +140,11 @@ void toggle_draw_move(t_toggle *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); + sys_vgui(".x%lx.c coords %lxTGL%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx, yy, xx + IOWIDTH, yy+1); + sys_vgui(".x%lx.c coords %lxTGL%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx, yy, xx + IOWIDTH, yy+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) toggle_draw_select(x, x->x_gui.x_glist); @@ -239,18 +239,18 @@ void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxTGL%so%d\n", canvas, xpos, ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h, nlet_tag, 0); + ypos + x->x_gui.x_h, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxTGL%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxTGL%si%d\n", canvas, xpos, ypos, - xpos + IOWIDTH, ypos+1, nlet_tag, 0); + xpos + IOWIDTH, ypos+1, x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxTGL%si%d\n", canvas, x, nlet_tag, 0); } } @@ -563,6 +563,8 @@ static void toggle_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *x *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void toggle_save(t_gobj *z, t_binbuf *b) @@ -637,8 +639,9 @@ static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv) x->x_gui.x_h = x->x_gui.x_w; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index 171f75e83..0fb8446ff 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -104,11 +104,11 @@ void vradio_draw_new(t_vradio *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxVRDO outlet}\n", - canvas, xx11, yy11-1, xx11 + IOWIDTH, yy11, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVRDO%so%d %lxVRDO outlet}\n", + canvas, xx11, yy11-1, xx11 + IOWIDTH, yy11, x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxVRDO inlet}\n", - canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVRDO%si%d %lxVRDO inlet}\n", + canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, nlet_tag, 0, x); //} } @@ -151,11 +151,11 @@ void vradio_draw_move(t_vradio *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11); + sys_vgui(".x%lx.c coords %lxVRDO%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); + sys_vgui(".x%lx.c coords %lxVRDO%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1); /* redraw scale handle rectangle if selected */ if (x->x_gui.x_fsf.x_selected) vradio_draw_select(x, x->x_gui.x_glist); @@ -248,20 +248,20 @@ void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVRDO%so%d\n", canvas, xpos, ypos+(x->x_number*x->x_gui.x_h)-1, xpos+ IOWIDTH, - ypos+(x->x_number*x->x_gui.x_h), nlet_tag, 0); + ypos+(x->x_number*x->x_gui.x_h), x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVRDO%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVRDO%si%d\n", canvas, xpos, ypos, xpos+ IOWIDTH, ypos+1, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVRDO%si%d\n", canvas, x, nlet_tag, 0); } } @@ -573,6 +573,8 @@ static void vradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *x *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h*x->x_number; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void vradio_save(t_gobj *z, t_binbuf *b) @@ -648,14 +650,16 @@ static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv) x->x_on = x->x_number - 1; x->x_on_old = x->x_on; } - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_NEW); } else { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); } /* forcing redraw of the scale handle */ diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index 41963db2c..72b19b365 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -110,17 +110,17 @@ static void vslider_draw_new(t_vslider *x, t_glist *glist) x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxVSLDR outlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVSLDR%so%d %lxVSLDR outlet}\n", canvas, xpos, ypos + x->x_gui.x_h+4, xpos+7, ypos + x->x_gui.x_h+5, - nlet_tag, 0, x); + x, nlet_tag, 0, x); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxVSLDR inlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVSLDR%si%d %lxVSLDR inlet}\n", canvas, xpos, ypos, xpos+7, ypos+1, - nlet_tag, 0, x); + x, nlet_tag, 0, x); //} } @@ -156,13 +156,13 @@ static void vslider_draw_move(t_vslider *x, t_glist *glist) sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxVSLDR%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h+4, xpos+7, ypos + x->x_gui.x_h+5); if(!x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxVSLDR%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, xpos+7, ypos+1); /* redraw scale handle rectangle if selected */ @@ -246,21 +246,21 @@ static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags) else nlet_tag = "bogus"; if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVSLDR%so%d\n", canvas, xpos, ypos + x->x_gui.x_h+4, xpos+7, ypos + x->x_gui.x_h+5, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVSLDR%so%d\n", canvas, x, nlet_tag, 0); if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVSLDR%si%d\n", canvas, xpos, ypos, xpos+7, ypos+1, - nlet_tag, 0); + x, nlet_tag, 0); if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVSLDR%si%d\n", canvas, x, nlet_tag, 0); } } @@ -569,6 +569,8 @@ static void vslider_getrect(t_gobj *z, t_glist *glist, *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h + 7; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void vslider_save(t_gobj *z, t_binbuf *b) @@ -711,8 +713,9 @@ static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv) vslider_check_minmax(x, min, max); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index f3e1c98d9..f5cbe0df6 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -172,29 +172,29 @@ static void vu_draw_new(t_vu *x, t_glist *glist) x->x_gui.x_lcol, x, x); if(!x->x_gui.x_fsf.x_snd_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxVU outlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVU%so%d %lxVU outlet}\n", canvas, xpos, ypos + x->x_gui.x_h+3, xpos + IOWIDTH, ypos + x->x_gui.x_h+4, - nlet_tag, 0, x); - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%so%d %lxVU outlet}\n", + x, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVU%so%d %lxVU outlet}\n", canvas, xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4, - nlet_tag, 1, x); + x, nlet_tag, 1, x); } if(!x->x_gui.x_fsf.x_rcv_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxVU inlet}\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVU%si%d %lxVU inlet}\n", canvas, xpos, ypos, xpos + IOWIDTH, ypos+1, - nlet_tag, 0, x); - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%si%d %lxVU inlet}\n", + x, nlet_tag, 0, x); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags {%lxVU%si%d %lxVU inlet}\n", canvas, xpos+x->x_gui.x_w+2-IOWIDTH, ypos, xpos+x->x_gui.x_w+2, ypos+1, - nlet_tag, 1, x); + x, nlet_tag, 1, x); } x->x_updaterms = x->x_updatepeak = 1; sys_queuegui(x, x->x_gui.x_glist, vu_draw_update); @@ -255,23 +255,23 @@ static void vu_draw_move(t_vu *x, t_glist *glist) ypos+x->x_gui.x_ldy); if(!x->x_gui.x_fsf.x_snd_able) { - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxVU%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos + x->x_gui.x_h+3, xpos + IOWIDTH, ypos + x->x_gui.x_h+4); - sys_vgui(".x%lx.c coords %so%d %d %d %d %d\n", - canvas, nlet_tag, 1, + sys_vgui(".x%lx.c coords %lxVU%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 1, xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4); } if(!x->x_gui.x_fsf.x_rcv_able) { - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 0, + sys_vgui(".x%lx.c coords %lxVU%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, xpos + IOWIDTH, ypos+1); - sys_vgui(".x%lx.c coords %si%d %d %d %d %d\n", - canvas, nlet_tag, 1, + sys_vgui(".x%lx.c coords %lxVU%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 1, xpos+x->x_gui.x_w+2-IOWIDTH, ypos, xpos+x->x_gui.x_w+2, ypos+1); } @@ -410,39 +410,39 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVU%so%d\n", canvas, xpos, ypos + x->x_gui.x_h+3, xpos + IOWIDTH, ypos + x->x_gui.x_h+4, - nlet_tag, 0); - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %so%d\n", + x, nlet_tag, 0); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVU%so%d\n", canvas, xpos+x->x_gui.x_w+2-IOWIDTH, ypos + x->x_gui.x_h+3, xpos+x->x_gui.x_w+2, ypos + x->x_gui.x_h+4, - nlet_tag, 1); + x, nlet_tag, 1); } if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) { - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 0); - sys_vgui(".x%lx.c delete %so%d\n", canvas, nlet_tag, 1); + sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVU%so%d\n", canvas, x, nlet_tag, 1); } if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) { - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVU%si%d\n", canvas, xpos, ypos, xpos + IOWIDTH, ypos+1, - nlet_tag, 0); - sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %si%d\n", + x, nlet_tag, 0); + sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxVU%si%d\n", canvas, xpos+x->x_gui.x_w+2-IOWIDTH, ypos, xpos+x->x_gui.x_w+2, ypos+1, - nlet_tag, 1); + x, nlet_tag, 1); } if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) { - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 0); - sys_vgui(".x%lx.c delete %si%d\n", canvas, nlet_tag, 1); + sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 0); + sys_vgui(".x%lx.c delete %lxVU%si%d\n", canvas, x, nlet_tag, 1); } } } @@ -763,16 +763,94 @@ void vu_draw(t_vu *x, t_glist *glist, int mode) /* ------------------------ vu widgetbehaviour----------------------------- */ +static void vu_scale_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, int *xp2, int *yp2, int scale_x, int scale_y) +{ + t_float width_multiplier; + int scale_length; + int scale_x1; + int scale_y1; + int scale_x2; + int scale_y2; + int actual_fontsize; //seems tk does its own thing when it comes to rendering + int actual_height; + + if (x->gl_isgraph && !glist_istoplevel(x)) { + //fprintf(stderr,"vu_scale_getrect\n"); + + switch(x_gui.x_fsf.x_font_style) { + case 1: + width_multiplier = 0.83333; + break; + case 2: + width_multiplier = 0.735; + break; + default: + width_multiplier = 1.0; + break; + } + if (x_gui.x_fontsize % 2 == 0) { + actual_fontsize = x_gui.x_fontsize; + } else { + actual_fontsize = x_gui.x_fontsize; + } + actual_height = actual_fontsize; + //exceptions + if (x_gui.x_fsf.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || (actual_fontsize > 48 && actual_fontsize < 100 && (actual_fontsize %10 == 4 || actual_fontsize %10 == 9))) ) { + actual_fontsize += 1; + } + else if (x_gui.x_fsf.x_font_style == 1 && actual_fontsize >= 5 && actual_fontsize < 13 && actual_fontsize % 2 == 1) + actual_fontsize += 1; + else if (x_gui.x_fsf.x_font_style == 2 && actual_fontsize >= 5 && actual_fontsize % 2 == 1) + actual_fontsize += 1; + if (actual_height == 9) + actual_height += 1; + //done with exceptions + + width_multiplier = width_multiplier * (actual_fontsize * 0.6); + + scale_length = 4; + scale_x1 = scale_x; + scale_y1 = scale_y - actual_height/2; + scale_x2 = scale_x1 + (scale_length * width_multiplier); + scale_y2 = scale_y1 + actual_height*1.1; + + //DEBUG + //fprintf(stderr,"%f %d %d\n", width_multiplier, scale_length, x_gui.x_fsf.x_font_style); + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", x, scale_x1, scale_y1, scale_x2, scale_y2); + if (scale_x1 < *xp1) *xp1 = scale_x1; + if (scale_x2 > *xp2) *xp2 = scale_x2; + if (scale_y1 < *yp1) *yp1 = scale_y1; + if (scale_y2 > *yp2) *yp2 = scale_y2; + //DEBUG + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", glist_getcanvas(x)); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", glist_getcanvas(x), *xp1, *yp1, *xp2, *yp2); + } +} static void vu_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { 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; + *xp1 = text_xpix(&x->x_gui.x_obj, glist); *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w + 3; *yp2 = *yp1 + x->x_gui.x_h + 6; + + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + + //vu has custom scale all labels unlike other iemgui object + end=xpos+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; + vu_scale_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2, end+1, yyy+k3+2); } static void vu_save(t_gobj *z, t_binbuf *b) @@ -904,8 +982,9 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) vu_scale(x, (t_float)scale); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); - canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + //(*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); + //canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); + iemgui_shouldvis((void *)x, &x->x_gui, IEM_GUI_DRAW_MODE_MOVE); /* forcing redraw of the scale handle */ if (x->x_gui.x_fsf.x_selected) { -- GitLab