From aea8e211d07272d6a6e2abd5114490491e7e0027 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jancsika@yahoo.com> Date: Sun, 15 Jun 2014 16:28:23 -0400 Subject: [PATCH] more reformatting per Miller's guidelines --- pd/src/g_vumeter.c | 1463 ++++++++++++++++++++++++-------------------- 1 file changed, 803 insertions(+), 660 deletions(-) diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index 974b1e214..e8ca2f1a8 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -38,14 +38,15 @@ static t_class *vu_class; static void vu_update_rms(t_vu *x, t_glist *glist) { - if(glist_isvisible(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 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; sys_vgui(".x%lx.c coords %lxRCOVER %d %d %d %d\n", - glist_getcanvas(glist), x, quad1+1, off+2, quad3+1, - off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms)+2); + glist_getcanvas(glist), x, quad1 + 1, off + 2, quad3 + 1, + off + (x->x_led_size + 1) * (IEM_VU_STEPS - x->x_rms) + 2); } } @@ -55,30 +56,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 xpos = text_xpix(&x->x_gui.x_obj, glist); + int ypos = 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) - - (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); - sys_vgui(".x%lx.c itemconfigure %lxPLED -fill #%6.6x\n", canvas, x, - iemgui_color_hex[i]); + int i = iemgui_vu_col[x->x_peak]; + int j = ypos + (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); + sys_vgui(".x%lx.c itemconfigure %lxPLED -fill #%6.6x\n", + canvas, x, iemgui_color_hex[i]); } else { - int mid=xpos+x->x_gui.x_w/2; + int mid = xpos + x->x_gui.x_w / 2; sys_vgui(".x%lx.c itemconfigure %lxPLED -fill #%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, ypos+22, mid+1, ypos+22); } } } @@ -111,83 +110,102 @@ static void vu_draw_new(t_vu *x, t_glist *glist) int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; int led_col, yyy, i, k4=ypos-k3; - t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle; - sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)sh); - t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle; - sprintf(lh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)lh); - - //if (glist_isvisible(canvas)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_border) -fill #%6.6x -tags {%lxBASE %lxVU %s text iemgui border}\n", - canvas, xpos, ypos, - xpos+x->x_gui.x_w+2, - ypos+x->x_gui.x_h+4, x->x_gui.x_bcol, x, x, nlet_tag); - for(i=1; i<=IEM_VU_STEPS; i++) - { - led_col = iemgui_vu_col[i]; - yyy = k4 + k1*(k2-i); - sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d -stroke #%6.6x -tags {%lxRLED%d %lxVU %s 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); - if(((i+2)&3) && (x->x_scale)) - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxSCALE%d %lxVU %s text iemgui}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, - sys_fontweight, x->x_gui.x_lcol, x, i, x, nlet_tag); - } - if(x->x_scale) - { - 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 %lxVU %s text iemgui}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x, i, x, nlet_tag); - } - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x -stroke #%6.6x -tags {%lxRCOVER %lxVU %s text iemgui}\n", - canvas, quad1+1, ypos+1, quad3, - ypos+1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth %d -fill #%6.6x -tags {%lxPLED %lxVU %s text iemgui}\n", - canvas, mid+1, ypos+12, - mid+1, ypos+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxLABEL %lxVU %s text iemgui}\n", - canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", - x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, x, x, nlet_tag); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h+3, - xpos + IOWIDTH, ypos + x->x_gui.x_h+4, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\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, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) - { - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos + IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos, - xpos+x->x_gui.x_w+2, ypos+1, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - x->x_updaterms = x->x_updatepeak = 1; - sys_queuegui(x, x->x_gui.x_glist, vu_draw_update); - //} + t_scalehandle *sh = (t_scalehandle *)x->x_gui.x_handle; + sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)sh); + t_scalehandle *lh = (t_scalehandle *)x->x_gui.x_lhandle; + sprintf(lh->h_pathname, ".x%lx.h%lx", (t_int)canvas, (t_int)lh); + + //if (glist_isvisible(canvas)) { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_border) -fill #%6.6x " + "-tags {%lxBASE %lxVU %s text iemgui border}\n", + canvas, xpos, ypos, xpos+x->x_gui.x_w+2, + ypos+x->x_gui.x_h+4, x->x_gui.x_bcol, x, x, nlet_tag); + for(i = 1; i <= IEM_VU_STEPS; i++) + { + led_col = iemgui_vu_col[i]; + yyy = k4 + k1 * (k2-i); + sys_vgui(".x%lx.c create polyline %d %d %d %d " + "-strokewidth %d -stroke #%6.6x " + "-tags {%lxRLED%d %lxVU %s 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); + if(((i+2) & 3) && (x->x_scale)) + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxSCALE%d %lxVU %s text iemgui}\n", + canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], + x->x_gui.x_font, x->x_gui.x_fontsize, + sys_fontweight, x->x_gui.x_lcol, x, i, x, nlet_tag); + } + if(x->x_scale) + { + 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 %lxVU %s text iemgui}\n", + canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x, i, x, nlet_tag); + } + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " + "-stroke #%6.6x -tags {%lxRCOVER %lxVU %s text iemgui}\n", + canvas, quad1+1, ypos+1, quad3, + ypos+1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, + x, x, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d " + "-strokewidth %d -fill #%6.6x " + "-tags {%lxPLED %lxVU %s text iemgui}\n", + canvas, mid+1, ypos+12, + mid+1, ypos+12, x->x_led_size, x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxLABEL %lxVU %s text iemgui}\n", + canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", + x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, x, x, nlet_tag); + if (!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + { + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_h+3, + xpos + IOWIDTH, ypos + x->x_gui.x_h+4, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%so%d %so%d %lxVU %s outlet iemgui}\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, + x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); + } + if (!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + { + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", + canvas, + xpos, ypos, + xpos + IOWIDTH, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%si%d %si%d %lxVU %s inlet iemgui}\n", + canvas, + xpos+x->x_gui.x_w+2-IOWIDTH, ypos, + xpos+x->x_gui.x_w+2, ypos+1, + x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); + } + x->x_updaterms = x->x_updatepeak = 1; + sys_queuegui(x, x->x_gui.x_glist, vu_draw_update); + //} } @@ -195,68 +213,69 @@ static void vu_draw_move(t_vu *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas)) { - - 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 k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; - int yyy, i, k4=ypos-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); - for(i=1; i<=IEM_VU_STEPS; i++) - { - yyy = k4 + k1*(k2-i); - sys_vgui(".x%lx.c coords %lxRLED%d %d %d %d %d\n", - canvas, x, i, quad1+1, yyy+2, quad3, yyy+2); - if(((i+2)&3) && (x->x_scale)) - sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", - canvas, x, i, end+1, yyy+k3+2); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - yyy = k4 + k1*(k2-i); - sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", - canvas, x, i, end+1, yyy+k3+2); - } - x->x_updaterms = x->x_updatepeak = 1; - sys_queuegui(x, glist, vu_draw_update); - 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 && canvas == x->x_gui.x_glist) - { - 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 %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 && canvas == x->x_gui.x_glist) - { - 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 %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); - } - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) - vu_draw_select(x, x->x_gui.x_glist); - } + if (glist_isvisible(canvas)) + { + + 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 k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; + int yyy, i, k4=ypos-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); + for(i=1; i<=IEM_VU_STEPS; i++) + { + yyy = k4 + k1*(k2-i); + sys_vgui(".x%lx.c coords %lxRLED%d %d %d %d %d\n", + canvas, x, i, quad1+1, yyy+2, quad3, yyy+2); + if(((i+2)&3) && (x->x_scale)) + sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", + canvas, x, i, end+1, yyy+k3+2); + } + if(x->x_scale) + { + i=IEM_VU_STEPS+1; + yyy = k4 + k1*(k2-i); + sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n", + canvas, x, i, end+1, yyy+k3+2); + } + x->x_updaterms = x->x_updatepeak = 1; + sys_queuegui(x, glist, vu_draw_update); + 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 && canvas == x->x_gui.x_glist) + { + 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 %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 && canvas == x->x_gui.x_glist) + { + 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 %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); + } + /* redraw scale handle rectangle if selected */ + if (x->x_gui.x_fsf.x_selected) + vu_draw_select(x, x->x_gui.x_glist); + } } static void vu_draw_erase(t_vu* x,t_glist* glist) @@ -264,16 +283,17 @@ static void vu_draw_erase(t_vu* x,t_glist* glist) int i; t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%lx.c delete %lxVU\n", canvas, x); - sys_vgui(".x%lx.c dtag all %lxVU\n", canvas, x); - if (x->x_gui.x_fsf.x_selected) { - t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - } + sys_vgui(".x%lx.c delete %lxVU\n", canvas, x); + sys_vgui(".x%lx.c dtag all %lxVU\n", canvas, x); + if (x->x_gui.x_fsf.x_selected) + { + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + } } static void vu_draw_config(t_vu* x, t_glist* glist) @@ -281,59 +301,69 @@ static void vu_draw_config(t_vu* x, t_glist* glist) int i; t_canvas *canvas=glist_getcanvas(glist); - /* - char color[64]; - if (x->x_gui.x_fsf.x_selected) - sprintf(color, "$pd_colors(selection)"); - else - sprintf(color, "#%6.6x", x->x_gui.x_lcol); - */ + /* + char color[64]; + if (x->x_gui.x_fsf.x_selected) + sprintf(color, "$pd_colors(selection)"); + else + sprintf(color, "#%6.6x", x->x_gui.x_lcol); + */ - for(i=1; i<=IEM_VU_STEPS; i++) + for(i = 1; i <= IEM_VU_STEPS; i++) { - sys_vgui(".x%lx.c itemconfigure %lxRLED%d -strokewidth %d\n", canvas, x, i, - x->x_led_size); - if(((i+2)&3) && (x->x_scale)) - if (x->x_gui.x_fsf.x_selected) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill $pd_colors(selection)\n", + sys_vgui(".x%lx.c itemconfigure %lxRLED%d -strokewidth %d\n", + canvas, x, i, x->x_led_size); + if(((i + 2) & 3) && (x->x_scale)) + if (x->x_gui.x_fsf.x_selected) + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " + "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight); - else - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill #%6.6x\n", + x->x_gui.x_fontsize, sys_fontweight); + else + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " + "-font {{%s} -%d %s} -fill #%6.6x\n", canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_fontsize, sys_fontweight, x->x_gui.x_lcol); } if(x->x_scale) { - i=IEM_VU_STEPS+1; - if (x->x_gui.x_fsf.x_selected) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill $pd_colors(selection)\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight); - else - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill #%6.6x\n", - canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, - x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol); + i = IEM_VU_STEPS + 1; + if (x->x_gui.x_fsf.x_selected) + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " + "-font {{%s} -%d %s} -fill $pd_colors(selection)\n", + canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight); + else + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} " + "-font {{%s} -%d %s} -fill #%6.6x\n", + canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font, + x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol); } - if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) - sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill $pd_colors(selection) -text {%s} \n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); - else - sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n", - canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, - x->x_gui.x_lcol, - strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); - - sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x\n .x%lx.c itemconfigure %lxPLED -strokewidth %d\n .x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", - canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol, canvas, x, x->x_led_size, - canvas, x, x->x_gui.x_bcol); + if (x->x_gui.x_fsf.x_selected && x->x_gui.x_glist == canvas) + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " + "-fill $pd_colors(selection) -text {%s} \n", + canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); + else + sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} " + "-fill #%6.6x -text {%s} \n", + canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight, + x->x_gui.x_lcol, + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); + + sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -stroke #%6.6x\n " + ".x%lx.c itemconfigure %lxPLED -strokewidth %d\n " + ".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", + canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol, + canvas, x, x->x_led_size, + canvas, x, x->x_gui.x_bcol); /* - sys_vgui(".x%lx.c itemconfigure %lxPLED -width %d\n", canvas, x, - x->x_led_size); - sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxPLED -width %d\n", canvas, x, + x->x_led_size); + sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", + canvas, x, x->x_gui.x_bcol); */ } @@ -343,357 +373,425 @@ static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags) int ypos=text_ypix(&x->x_gui.x_obj, glist); t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas) && canvas == x->x_gui.x_glist) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) - { - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%so%d %so%d %lxVU %s outlet}\n", - canvas, - xpos, ypos + x->x_gui.x_h+3, - xpos + IOWIDTH, ypos + x->x_gui.x_h+4, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVU%so%d %so%d %lxVU %s 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, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) - { - 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 prect %d %d %d %d -tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", - canvas, - xpos, ypos, - xpos + IOWIDTH, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", - canvas, - xpos+x->x_gui.x_w+2-IOWIDTH, ypos, - xpos+x->x_gui.x_w+2, ypos+1, - x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); - } - if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) - { - 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); - } - } + if (glist_isvisible(canvas) && canvas == x->x_gui.x_glist) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + if ((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && + !x->x_gui.x_fsf.x_snd_able) + { + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%so%d %so%d %lxVU %s outlet}\n", + canvas, xpos, ypos + x->x_gui.x_h+3, xpos + IOWIDTH, + ypos + x->x_gui.x_h+4, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVU%so%d %so%d %lxVU %s 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, + x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); + } + if (!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && + x->x_gui.x_fsf.x_snd_able) + { + 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 prect %d %d %d %d " + "-tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", + canvas, + xpos, ypos, + xpos + IOWIDTH, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-tags {%lxVU%si%d %si%d %lxVU %s outlet}\n", + canvas, + xpos+x->x_gui.x_w+2-IOWIDTH, ypos, + xpos+x->x_gui.x_w+2, ypos+1, + x, nlet_tag, 1, nlet_tag, 1, x, nlet_tag); + } + if (!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && + x->x_gui.x_fsf.x_rcv_able) + { + 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); + } + } } static void vu_draw_select(t_vu* x,t_glist* glist) { int i; t_canvas *canvas=glist_getcanvas(glist); - t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); - t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); - - //if (glist_isvisible(canvas)) { - - if(x->x_gui.x_fsf.x_selected) - { - // check if we are drawing inside a gop abstraction visible on parent canvas - // if so, disable highlighting - if (x->x_gui.x_glist == glist_getcanvas(glist)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke $pd_colors(selection)\n", canvas, x); - for(i=1; i<=IEM_VU_STEPS; i++) - { - if(((i+2)&3) && (x->x_scale)) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill $pd_colors(selection)\n", - canvas, x, i); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill $pd_colors(selection)\n", - canvas, x, i); - } - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill $pd_colors(selection)\n", canvas, x); - - if (x->x_gui.scale_vis) { - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - } - - sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 -cursor bottom_right_corner\n", - sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT); - sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %lxVU %s}\n", - canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w + 2 - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + x->x_gui.x_h + 4 - SCALEHANDLE_HEIGHT - 1, - SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, - sh->h_pathname, x, x, nlet_tag); - sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n", - sh->h_pathname, sh->h_bindsym->s_name); - x->x_gui.scale_vis = 1; - if (strcmp(x->x_gui.x_lab->s_name, "empty") != 0) - { - if (x->x_gui.label_vis) { - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - } - - sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 -cursor crosshair\n", - lh->h_pathname, LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT); - sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxLABEL %lxLABELH %lxVU %s}\n", - canvas, x->x_gui.x_obj.te_xpix+ x->x_gui.x_ldx - LABELHANDLE_WIDTH, - x->x_gui.x_obj.te_ypix + x->x_gui.x_ldy - LABELHANDLE_HEIGHT, - LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT, - lh->h_pathname, x, x, x, nlet_tag); - sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", - lh->h_pathname, lh->h_bindsym->s_name); - sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", - lh->h_pathname, lh->h_bindsym->s_name); - sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n", - lh->h_pathname, lh->h_bindsym->s_name); - x->x_gui.label_vis = 1; - } - } - - sys_vgui(".x%lx.c addtag selected withtag %lxVU\n", canvas, x); - } - else - { - sys_vgui(".x%lx.c dtag %lxVU selected\n", canvas, x); - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", canvas, x, IEM_GUI_COLOR_NORMAL); - for(i=1; i<=IEM_VU_STEPS; i++) - { - if(((i+2)&3) && (x->x_scale)) - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", - canvas, x, i, x->x_gui.x_lcol); - } - if(x->x_scale) - { - i=IEM_VU_STEPS+1; - sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", - canvas, x, i, x->x_gui.x_lcol); - } - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - x->x_gui.scale_vis = 0; - sys_vgui("destroy %s\n", lh->h_pathname); - sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); - x->x_gui.label_vis = 0; - } - //} + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); + + //if (glist_isvisible(canvas)) { + + if(x->x_gui.x_fsf.x_selected) + { + // check if we are drawing inside a gop abstraction + // visible on parent canvas. If so, disable highlighting + if (x->x_gui.x_glist == glist_getcanvas(glist)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c itemconfigure %lxBASE " + "-stroke $pd_colors(selection)\n", + canvas, x); + for(i = 1; i <= IEM_VU_STEPS; i++) + { + if(((i + 2) & 3) && (x->x_scale)) + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d " + "-fill $pd_colors(selection)\n", + canvas, x, i); + } + if(x->x_scale) + { + i=IEM_VU_STEPS+1; + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d " + "-fill $pd_colors(selection)\n", + canvas, x, i); + } + sys_vgui(".x%lx.c itemconfigure %lxLABEL " + "-fill $pd_colors(selection)\n", + canvas, x); + + if (x->x_gui.scale_vis) + { + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + } + + sys_vgui("canvas %s -width %d -height %d " + "-bg $pd_colors(selection) -bd 0 " + "-cursor bottom_right_corner\n", + sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT); + sys_vgui(".x%x.c create window %d %d -anchor nw " + "-width %d -height %d -window %s " + "-tags {%lxSCALE %lxVU %s}\n", + canvas, + x->x_gui.x_obj.te_xpix + + x->x_gui.x_w + 2 - SCALEHANDLE_WIDTH - 1, + x->x_gui.x_obj.te_ypix + + x->x_gui.x_h + 4 - SCALEHANDLE_HEIGHT - 1, + SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, + sh->h_pathname, x, x, nlet_tag); + sys_vgui("bind %s <Button> " + "{pd [concat %s _click 1 %%x %%y \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + sys_vgui("bind %s <ButtonRelease> " + "{pd [concat %s _click 0 0 0 \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + sys_vgui("bind %s <Motion> " + "{pd [concat %s _motion %%x %%y \\;]}\n", + sh->h_pathname, sh->h_bindsym->s_name); + x->x_gui.scale_vis = 1; + if (strcmp(x->x_gui.x_lab->s_name, "empty") != 0) + { + if (x->x_gui.label_vis) + { + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + } + + sys_vgui("canvas %s -width %d -height %d " + "-bg $pd_colors(selection) -bd 0 " + "-cursor crosshair\n", + lh->h_pathname, LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT); + sys_vgui(".x%x.c create window %d %d -anchor nw " + "-width %d -height %d -window %s " + "-tags {%lxLABEL %lxLABELH %lxVU %s}\n", + canvas, + x->x_gui.x_obj.te_xpix + + x->x_gui.x_ldx - LABELHANDLE_WIDTH, + x->x_gui.x_obj.te_ypix + + x->x_gui.x_ldy - LABELHANDLE_HEIGHT, + LABELHANDLE_WIDTH, LABELHANDLE_HEIGHT, + lh->h_pathname, x, x, x, nlet_tag); + sys_vgui("bind %s <Button> " + "{pd [concat %s _click 1 %%x %%y \\;]}\n", + lh->h_pathname, lh->h_bindsym->s_name); + sys_vgui("bind %s <ButtonRelease> " + "{pd [concat %s _click 0 0 0 \\;]}\n", + lh->h_pathname, lh->h_bindsym->s_name); + sys_vgui("bind %s <Motion> " + "{pd [concat %s _motion %%x %%y \\;]}\n", + lh->h_pathname, lh->h_bindsym->s_name); + x->x_gui.label_vis = 1; + } + } + + sys_vgui(".x%lx.c addtag selected withtag %lxVU\n", canvas, x); + } + else + { + sys_vgui(".x%lx.c dtag %lxVU selected\n", canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", + canvas, x, IEM_GUI_COLOR_NORMAL); + for(i = 1; i <= IEM_VU_STEPS; i++) + { + if(((i + 2) & 3) && (x->x_scale)) + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", + canvas, x, i, x->x_gui.x_lcol); + } + if(x->x_scale) + { + i = IEM_VU_STEPS + 1; + sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n", + canvas, x, i, x->x_gui.x_lcol); + } + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", + canvas, x, x->x_gui.x_lcol); + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + x->x_gui.scale_vis = 0; + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + x->x_gui.label_vis = 0; + } + //} } -static void vu__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) +static void vu__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, + t_floatarg yyy) { - t_vu *x = (t_vu *)(sh->h_master); + t_vu *x = (t_vu *)(sh->h_master); - if (xxx) { - x->x_gui.scale_offset_x = xxx; - x->x_gui.label_offset_x = xxx; - } - if (yyy) { - x->x_gui.scale_offset_y = yyy; - x->x_gui.label_offset_y = yyy; - } + if (xxx) + { + x->x_gui.scale_offset_x = xxx; + x->x_gui.label_offset_x = xxx; + } + if (yyy) + { + x->x_gui.scale_offset_y = yyy; + x->x_gui.label_offset_y = yyy; + } int newstate = (int)f; if (sh->h_dragon && newstate == 0 && sh->h_scale) { - /* done dragging */ - - /* first set up the undo apply */ - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); - - if (sh->h_dragx || sh->h_dragy) { - - x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x; - if (x->x_gui.x_w < SCALE_BNG_MINWIDTH) - x->x_gui.x_w = SCALE_BNG_MINWIDTH; - x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - x->x_gui.scale_offset_y; - if (x->x_gui.x_h < SCALE_BNG_MINHEIGHT) - x->x_gui.x_h = SCALE_BNG_MINHEIGHT; - - canvas_dirty(x->x_gui.x_glist, 1); - } - - int properties = gfxstub_haveproperties((void *)x); - - if (properties) { - sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, x->x_gui.x_w); - sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, x->x_gui.x_h); - } - - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - vu_check_height(x, x->x_gui.x_h); - vu_draw_move(x, x->x_gui.x_glist); - vu_draw_config(x, x->x_gui.x_glist); - vu_draw_update((t_gobj *)x, x->x_gui.x_glist); - iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); - canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); - } + /* done dragging */ + + /* first set up the undo apply */ + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + + if (sh->h_dragx || sh->h_dragy) + { + + x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_x; + if (x->x_gui.x_w < SCALE_BNG_MINWIDTH) + x->x_gui.x_w = SCALE_BNG_MINWIDTH; + x->x_gui.x_h = x->x_gui.x_h + sh->h_dragy - x->x_gui.scale_offset_y; + if (x->x_gui.x_h < SCALE_BNG_MINHEIGHT) + x->x_gui.x_h = SCALE_BNG_MINHEIGHT; + + canvas_dirty(x->x_gui.x_glist, 1); + } + + int properties = gfxstub_haveproperties((void *)x); + + if (properties) + { + sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", + properties, x->x_gui.x_w); + sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", + properties, x->x_gui.x_h); + } + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + vu_check_height(x, x->x_gui.x_h); + vu_draw_move(x, x->x_gui.x_glist); + vu_draw_config(x, x->x_gui.x_glist); + vu_draw_update((t_gobj *)x, x->x_gui.x_glist); + iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); + canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); + } } else if (!sh->h_dragon && newstate && sh->h_scale) { - /* dragging */ - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui("lower %s\n", sh->h_pathname); - sys_vgui(".x%x.c create prect %d %d %d %d\ - -stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", - x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, x->x_gui.x_obj.te_ypix, - x->x_gui.x_obj.te_xpix + x->x_gui.x_w + 2, - x->x_gui.x_obj.te_ypix + x->x_gui.x_h + 4, sh->h_outlinetag); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* dragging */ + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui("lower %s\n", sh->h_pathname); + sys_vgui(".x%x.c create prect %d %d %d %d " + "-stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", + x->x_gui.x_glist, + x->x_gui.x_obj.te_xpix, x->x_gui.x_obj.te_ypix, + x->x_gui.x_obj.te_xpix + x->x_gui.x_w + 2, + x->x_gui.x_obj.te_ypix + x->x_gui.x_h + 4, sh->h_outlinetag); + } + + sh->h_dragx = 0; + sh->h_dragy = 0; } - else if (sh->h_dragon && newstate == 0 && !sh->h_scale) + else if (sh->h_dragon && newstate == 0 && !sh->h_scale) { - /* done dragging */ + /* done dragging */ - /* first set up the undo apply */ - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + /* first set up the undo apply */ + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); - if (sh->h_dragx || sh->h_dragy) { + if (sh->h_dragx || sh->h_dragy) + { - x->x_gui.x_ldx = x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x; - x->x_gui.x_ldy = x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y; + x->x_gui.x_ldx = x->x_gui.x_ldx + + sh->h_dragx - x->x_gui.label_offset_x; + x->x_gui.x_ldy = x->x_gui.x_ldy + + sh->h_dragy - x->x_gui.label_offset_y; - canvas_dirty(x->x_gui.x_glist, 1); - } + canvas_dirty(x->x_gui.x_glist, 1); + } - int properties = gfxstub_haveproperties((void *)x); + int properties = gfxstub_haveproperties((void *)x); - if (properties) { - sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, x->x_gui.x_w); - //sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); - //sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, x->x_gui.x_h); - } + if (properties) + { + sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", + properties, x->x_gui.x_w); + //sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); + //sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, x->x_gui.x_h); + } - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - vu_draw_move(x, x->x_gui.x_glist); - iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); - canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); - } + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + vu_draw_move(x, x->x_gui.x_glist); + iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); + canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); + } } else if (!sh->h_dragon && newstate && !sh->h_scale) { - /* dragging */ - if (glist_isvisible(x->x_gui.x_glist)) { - sys_vgui("lower %s\n", sh->h_pathname); - t_scalehandle *othersh = (t_scalehandle *)x->x_gui.x_handle; - sys_vgui("lower .x%lx.h%lx\n", (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* dragging */ + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui("lower %s\n", sh->h_pathname); + t_scalehandle *othersh = (t_scalehandle *)x->x_gui.x_handle; + sys_vgui("lower .x%lx.h%lx\n", + (t_int)glist_getcanvas(x->x_gui.x_glist), (t_int)othersh); + } + + sh->h_dragx = 0; + sh->h_dragy = 0; } sh->h_dragon = newstate; } static void vu__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { if (sh->h_dragon && sh->h_scale) { - t_vu *x = (t_vu *)(sh->h_master); - int dx = (int)f1, dy = (int)f2; - int newx, newy; - - int y_incr = (int)((dy - x->x_gui.scale_offset_y) / IEM_VU_STEPS); - if (dy - x->x_gui.scale_offset_y < 0) - y_incr -= 1; - - newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w - x->x_gui.scale_offset_x + dx; - newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h + y_incr * IEM_VU_STEPS; - - if (newx < x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH) - newx = x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH; - if (newy < x->x_gui.x_obj.te_ypix + SCALE_BNG_MINHEIGHT) - newy = x->x_gui.x_obj.te_ypix + SCALE_BNG_MINHEIGHT; - - if (glist_isvisible(x->x_gui.x_glist)) { - sys_vgui(".x%x.c coords %s %d %d %d %d\n", - x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, - x->x_gui.x_obj.te_ypix, newx + 2, newy + 4); - } - sh->h_dragx = dx; - sh->h_dragy = dy; - - int properties = gfxstub_haveproperties((void *)x); - - if (properties) { - int new_w = x->x_gui.x_w - x->x_gui.scale_offset_x + sh->h_dragx; - int new_h = x->x_gui.x_h - x->x_gui.scale_offset_y + sh->h_dragy; - sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, new_w); - sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, new_h); - } + t_vu *x = (t_vu *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + + int y_incr = (int)((dy - x->x_gui.scale_offset_y) / IEM_VU_STEPS); + if (dy - x->x_gui.scale_offset_y < 0) + y_incr -= 1; + + newx = x->x_gui.x_obj.te_xpix + + x->x_gui.x_w - x->x_gui.scale_offset_x + dx; + newy = x->x_gui.x_obj.te_ypix + + x->x_gui.x_h + y_incr * IEM_VU_STEPS; + + if (newx < x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH) + newx = x->x_gui.x_obj.te_xpix + SCALE_BNG_MINWIDTH; + if (newy < x->x_gui.x_obj.te_ypix + SCALE_BNG_MINHEIGHT) + newy = x->x_gui.x_obj.te_ypix + SCALE_BNG_MINHEIGHT; + + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c coords %s %d %d %d %d\n", + x->x_gui.x_glist, sh->h_outlinetag, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, newx + 2, newy + 4); + } + sh->h_dragx = dx; + sh->h_dragy = dy; + + int properties = gfxstub_haveproperties((void *)x); + + if (properties) + { + int new_w = x->x_gui.x_w - x->x_gui.scale_offset_x + sh->h_dragx; + int new_h = x->x_gui.x_h - x->x_gui.scale_offset_y + sh->h_dragy; + sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, new_w); + sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, new_h); + } } - if (sh->h_dragon && !sh->h_scale) + if (sh->h_dragon && !sh->h_scale) { - t_bng *x = (t_bng *)(sh->h_master); - int dx = (int)f1, dy = (int)f2; - int newx, newy; - newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w - x->x_gui.scale_offset_x + dx; - newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h - x->x_gui.scale_offset_y + dy; - - sh->h_dragx = dx; - sh->h_dragy = dy; - - int properties = gfxstub_haveproperties((void *)x); - - if (properties) { - int new_x = x->x_gui.x_ldx - x->x_gui.label_offset_x + sh->h_dragx; - int new_y = x->x_gui.x_ldy - x->x_gui.label_offset_y + sh->h_dragy; - sys_vgui(".gfxstub%lx.label.xy.x_entry delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n", properties, new_x); - sys_vgui(".gfxstub%lx.label.xy.y_entry delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.label.xy.y_entry insert 0 %d\n", properties, new_y); - } - - if (glist_isvisible(x->x_gui.x_glist)) { - int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); - int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist); - t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist); - sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - canvas, x, xpos+x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x, - ypos+x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y); - } + t_bng *x = (t_bng *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + newx = x->x_gui.x_obj.te_xpix + + x->x_gui.x_w - x->x_gui.scale_offset_x + dx; + newy = x->x_gui.x_obj.te_ypix + + x->x_gui.x_h - x->x_gui.scale_offset_y + dy; + + sh->h_dragx = dx; + sh->h_dragy = dy; + + int properties = gfxstub_haveproperties((void *)x); + + if (properties) + { + int new_x = x->x_gui.x_ldx - x->x_gui.label_offset_x + sh->h_dragx; + int new_y = x->x_gui.x_ldy - x->x_gui.label_offset_y + sh->h_dragy; + sys_vgui(".gfxstub%lx.label.xy.x_entry delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.label.xy.x_entry insert 0 %d\n", + properties, new_x); + sys_vgui(".gfxstub%lx.label.xy.y_entry delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.label.xy.y_entry insert 0 %d\n", + properties, new_y); + } + + if (glist_isvisible(x->x_gui.x_glist)) + { + int xpos=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); + int ypos=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist); + t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist); + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, + xpos+x->x_gui.x_ldx + sh->h_dragx - x->x_gui.label_offset_x, + ypos+x->x_gui.x_ldy + sh->h_dragy - x->x_gui.label_offset_y); + } } } void vu_draw(t_vu *x, t_glist *glist, int mode) { - //fprintf(stderr,"vu_draw %d\n", mode); + //fprintf(stderr,"vu_draw %d\n", mode); if(mode == IEM_GUI_DRAW_MODE_UPDATE) - sys_queuegui((t_gobj*)x, x->x_gui.x_glist, vu_draw_update); + sys_queuegui((t_gobj*)x, x->x_gui.x_glist, vu_draw_update); if(mode == IEM_GUI_DRAW_MODE_MOVE) vu_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { vu_draw_new(x, glist); - sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); - } + sys_vgui(".x%lx.c raise all_cords\n", glist_getcanvas(glist)); + } else if(mode == IEM_GUI_DRAW_MODE_SELECT) vu_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -706,96 +804,120 @@ 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) +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); - } + 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) + 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; + 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) + 2; *xp2 = *xp1 + x->x_gui.x_w + 2; *yp2 = *yp1 + x->x_gui.x_h + 2; - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); - if (x->x_scale) { - //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); - } + if (x->x_scale) + { + //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) @@ -829,7 +951,7 @@ void vu_check_height(t_vu *x, int h) static void vu_scale(t_vu *x, t_floatarg fscale) { - //fprintf(stderr,"vu_scale\n"); + //fprintf(stderr,"vu_scale\n"); int i, scale = (int)fscale; @@ -852,7 +974,8 @@ static void vu_scale(t_vu *x, t_floatarg fscale) } if(!x->x_scale && scale) { - int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4; + int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, + x->x_gui.x_glist)+x->x_gui.x_w+4; int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2; int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3; t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist); @@ -863,20 +986,22 @@ static void vu_scale(t_vu *x, t_floatarg fscale) for(i=1; i<=IEM_VU_STEPS; i++) { yyy = k4 + k1*(k2-i); - if((i+2)&3) - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxSCALE%d %lxVU %lx}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, - sys_fontweight, x->x_gui.x_lcol, x, i, x, x); + if((i + 2) & 3) + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxSCALE%d %lxVU %lx}\n", + canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], + x->x_gui.x_font, x->x_gui.x_fontsize, + sys_fontweight, x->x_gui.x_lcol, x, i, x, x); } - i=IEM_VU_STEPS+1; + 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 %lxVU %lx}\n", - canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], - x->x_gui.x_font, x->x_gui.x_fontsize, - sys_fontweight, x->x_gui.x_lcol, x, i, x, x); + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxSCALE%d %lxVU %lx}\n", + canvas, end+1, yyy+k3+2, iemgui_vu_scale_str[i], + x->x_gui.x_font, x->x_gui.x_fontsize, + sys_fontweight, x->x_gui.x_lcol, x, i, x, x); } } } @@ -896,19 +1021,21 @@ static void vu_properties(t_gobj *z, t_glist *owner) {%s} %d %d \ %d %d \ %d %d %d\n", - x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_VU_STEPS*IEM_VU_MINSIZE, + x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, + IEM_VU_STEPS*IEM_VU_MINSIZE, 0,/*no_schedule*/ x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/ "nosndno", srl[1]->s_name,/*no send*/ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, - 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol); + 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, + 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) { - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); t_symbol *srl[3]; int w = (int)atom_getintarg(0, argc, argv); @@ -929,16 +1056,18 @@ static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv) (*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); - iemgui_shouldvis((void *)x, &x->x_gui, 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) { - vu_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + vu_draw_select(x, x->x_gui.x_glist); + } - //ico@bukvic.net 100518 update scrollbars when object potentially exceeds window size + // ico@bukvic.net 100518 + // update scrollbars when object potentially exceeds window size t_canvas *canvas=(t_canvas *)glist_getcanvas(x->x_gui.x_glist); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)canvas); } static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av) @@ -1028,10 +1157,11 @@ static void vu_bang(t_vu *x) static void *vu_new(t_symbol *s, int argc, t_atom *argv) { t_vu *x = (t_vu *)pd_new(vu_class); - int bflcol[]={-66577, -1, -1}; - int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE; - int ldx=-1, ldy=-8, f=0, fs=10, scale=1; - int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; + int bflcol[] = {-66577, -1, -1}; + int w = IEM_GUI_DEFAULTSIZE, h = IEM_VU_STEPS*IEM_VU_DEFAULTSIZE; + int ldx = -1, ldy = -8, f = 0, fs = 10, scale = 1; + int ftbreak = IEM_BNG_DEFAULTBREAKFLASHTIME, + fthold = IEM_BNG_DEFAULTHOLDFLASHTIME; char str[144]; iem_inttosymargs(&x->x_gui.x_isa, 0); @@ -1069,8 +1199,11 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) strcpy(x->x_gui.x_font, "helvetica"); else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); - else { x->x_gui.x_fsf.x_font_style = 0; - strcpy(x->x_gui.x_font, sys_font); } + else + { + x->x_gui.x_fsf.x_font_style = 0; + strcpy(x->x_gui.x_font, sys_font); + } if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); x->x_gui.x_ldx = ldx; @@ -1094,7 +1227,7 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float); x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float); - /* scale handle init */ + /* scale handle init */ t_scalehandle *sh; char buf[64]; x->x_gui.x_handle = pd_new(scalehandle_class); @@ -1104,27 +1237,27 @@ static void *vu_new(t_symbol *s, int argc, t_atom *argv) pd_bind(x->x_gui.x_handle, sh->h_bindsym = gensym(buf)); sprintf(sh->h_outlinetag, "h%lx", (t_int)sh); sh->h_dragon = 0; - sh->h_scale = 1; - x->x_gui.scale_offset_x = 0; - x->x_gui.scale_offset_y = 0; - x->x_gui.scale_vis = 0; - - /* label handle init */ - t_scalehandle *lh; - char lhbuf[64]; - x->x_gui.x_lhandle = pd_new(scalehandle_class); - lh = (t_scalehandle *)x->x_gui.x_lhandle; - lh->h_master = (t_gobj*)x; - sprintf(lhbuf, "_h%lx", (t_int)lh); - pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf)); - sprintf(lh->h_outlinetag, "h%lx", (t_int)lh); - lh->h_dragon = 0; - lh->h_scale = 0; - x->x_gui.label_offset_x = 0; - x->x_gui.label_offset_y = 0; - x->x_gui.label_vis = 0; - - x->x_gui.x_obj.te_iemgui = 1; + sh->h_scale = 1; + x->x_gui.scale_offset_x = 0; + x->x_gui.scale_offset_y = 0; + x->x_gui.scale_vis = 0; + + /* label handle init */ + t_scalehandle *lh; + char lhbuf[64]; + x->x_gui.x_lhandle = pd_new(scalehandle_class); + lh = (t_scalehandle *)x->x_gui.x_lhandle; + lh->h_master = (t_gobj*)x; + sprintf(lhbuf, "_h%lx", (t_int)lh); + pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf)); + sprintf(lh->h_outlinetag, "h%lx", (t_int)lh); + lh->h_dragon = 0; + lh->h_scale = 0; + x->x_gui.label_offset_x = 0; + x->x_gui.label_offset_y = 0; + x->x_gui.label_vis = 0; + + x->x_gui.x_obj.te_iemgui = 1; return (x); } @@ -1135,46 +1268,56 @@ static void vu_free(t_vu *x) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); - /* scale handle deconstructor */ + /* scale handle deconstructor */ if (x->x_gui.x_handle) { - pd_unbind(x->x_gui.x_handle, ((t_scalehandle *)x->x_gui.x_handle)->h_bindsym); - pd_free(x->x_gui.x_handle); + pd_unbind(x->x_gui.x_handle, + ((t_scalehandle *)x->x_gui.x_handle)->h_bindsym); + pd_free(x->x_gui.x_handle); } - /* label handle deconstructor */ - if (x->x_gui.x_lhandle) - { - pd_unbind(x->x_gui.x_lhandle, ((t_scalehandle *)x->x_gui.x_lhandle)->h_bindsym); - pd_free(x->x_gui.x_lhandle); - } + /* label handle deconstructor */ + if (x->x_gui.x_lhandle) + { + pd_unbind(x->x_gui.x_lhandle, + ((t_scalehandle *)x->x_gui.x_lhandle)->h_bindsym); + pd_free(x->x_gui.x_lhandle); + } } void g_vumeter_setup(void) { vu_class = class_new(gensym("vu"), (t_newmethod)vu_new, (t_method)vu_free, - sizeof(t_vu), 0, A_GIMME, 0); + sizeof(t_vu), 0, A_GIMME, 0); class_addbang(vu_class,vu_bang); class_addfloat(vu_class,vu_float); class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0); class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"), - A_GIMME, 0); + A_GIMME, 0); class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0); - class_addmethod(vu_class, (t_method)vu_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_color, gensym("color"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(vu_class, (t_method)vu_scale, + gensym("scale"), A_DEFFLOAT, 0); + class_addmethod(vu_class, (t_method)vu_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(vu_class, (t_method)vu_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(vu_class, (t_method)vu_color, + gensym("color"), A_GIMME, 0); + class_addmethod(vu_class, (t_method)vu_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(vu_class, (t_method)vu_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(vu_class, (t_method)vu_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(vu_class, (t_method)vu_label_font, + gensym("label_font"), A_GIMME, 0); scalehandle_class = class_new(gensym("_scalehandle"), 0, 0, - sizeof(t_scalehandle), CLASS_PD, 0); + sizeof(t_scalehandle), CLASS_PD, 0); class_addmethod(scalehandle_class, (t_method)vu__clickhook, - gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0); + gensym("_click"), A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(scalehandle_class, (t_method)vu__motionhook, - gensym("_motion"), A_FLOAT, A_FLOAT, 0); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); vu_widgetbehavior.w_getrectfn = vu_getrect; vu_widgetbehavior.w_displacefn = iemgui_displace; @@ -1183,7 +1326,7 @@ void g_vumeter_setup(void) vu_widgetbehavior.w_deletefn = iemgui_delete; vu_widgetbehavior.w_visfn = iemgui_vis; vu_widgetbehavior.w_clickfn = NULL; - vu_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; + vu_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; class_setwidget(vu_class,&vu_widgetbehavior); class_sethelpsymbol(vu_class, gensym("vu")); class_setsavefn(vu_class, vu_save); -- GitLab