diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index 51e626a42095959d471bb841fb59d41e1171e9ea..e923e862949a8785749377ee1677f3794a369022 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -52,7 +52,9 @@ static void vslider_draw_update(t_gobj *client, t_glist *glist) { if(!x->x_thick) { - sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth 7\n", canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxKNOB " + "-strokewidth 7\n", + canvas, x); x->x_thick = 1; } } @@ -60,7 +62,9 @@ static void vslider_draw_update(t_gobj *client, t_glist *glist) { if(x->x_thick) { - sys_vgui(".x%lx.c itemconfigure %lxKNOB -strokewidth 3\n", canvas, x); + sys_vgui(".x%lx.c itemconfigure %lxKNOB " + "-strokewidth 3\n", + canvas, x); x->x_thick = 0; } } @@ -75,41 +79,49 @@ static void vslider_draw_new(t_vslider *x, t_glist *glist) int r = ypos + 2 + x->x_gui.x_h - (x->x_val + 50)/100; t_canvas *canvas=glist_getcanvas(glist); - 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 %lxVSLDR %s text iemgui border}\n", - canvas, xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5, - x->x_gui.x_bcol, x, x, nlet_tag); - sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 -stroke #%6.6x -tags {%lxKNOB %lxVSLDR %s text iemgui}\n", - canvas, xpos+2, r, - xpos + x->x_gui.x_w-2, r, x->x_gui.x_fcol, 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 %lxVSLDR %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 {%lxVSLDR%so%d %so%d %lxVSLDR %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h+4, - xpos+7, ypos + x->x_gui.x_h+5, - x, nlet_tag, 0, nlet_tag, 0, 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 {%lxVSLDR%si%d %si%d %lxVSLDR %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos+7, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); - //} + 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 %lxVSLDR %s text iemgui border}\n", + canvas, xpos, ypos, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5, + x->x_gui.x_bcol, x, x, nlet_tag); + sys_vgui(".x%lx.c create polyline %d %d %d %d -strokewidth 3 " + "-stroke #%6.6x -tags {%lxKNOB %lxVSLDR %s text iemgui}\n", + canvas, xpos+2, r, + xpos + x->x_gui.x_w-2, r, x->x_gui.x_fcol, 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 %lxVSLDR %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 {%lxVSLDR%so%d %so%d %lxVSLDR %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_h+4, + xpos+7, ypos + x->x_gui.x_h+5, + x, nlet_tag, 0, nlet_tag, 0, 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 {%lxVSLDR%si%d %si%d %lxVSLDR %s inlet iemgui}\n", + canvas, + xpos, ypos, + xpos+7, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + //} } static void vslider_draw_move(t_vslider *x, t_glist *glist) @@ -119,75 +131,83 @@ static void vslider_draw_move(t_vslider *x, t_glist *glist) int r = ypos + 2 + x->x_gui.x_h - (x->x_val + 50)/100; t_canvas *canvas=glist_getcanvas(glist); - if (glist_isvisible(canvas)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", - canvas, x, - xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5); - sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", - canvas, x, xpos+2, r, - xpos + x->x_gui.x_w-2, r); - 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 %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 && canvas == x->x_gui.x_glist) - 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 */ - if (x->x_gui.x_fsf.x_selected) { - vslider_draw_select(x, x->x_gui.x_glist); - } - } + if (glist_isvisible(canvas)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n", + canvas, x, + xpos, ypos, + xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+5); + sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n", + canvas, x, xpos+2, r, + xpos + x->x_gui.x_w-2, r); + 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 %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 && canvas == x->x_gui.x_glist) + 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 */ + if (x->x_gui.x_fsf.x_selected) + { + vslider_draw_select(x, x->x_gui.x_glist); + } + } } static void vslider_draw_erase(t_vslider* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); - sys_vgui(".x%lx.c delete %lxVSLDR\n", canvas, x); - sys_vgui(".x%lx.c dtag all %lxVSLDR\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 %lxVSLDR\n", canvas, x); + sys_vgui(".x%lx.c dtag all %lxVSLDR\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 vslider_draw_config(t_vslider* x,t_glist* glist) { 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); - */ - - 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 %lxKNOB -stroke #%6.6x\n .x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", - canvas, x, x->x_gui.x_fcol, canvas, x, x->x_gui.x_bcol); + /* + 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); + */ + + 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 %lxKNOB " + "-stroke #%6.6x\n .x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", + canvas, x, x->x_gui.x_fcol, canvas, x, x->x_gui.x_bcol); /*sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);*/ } @@ -198,300 +218,365 @@ static void vslider_draw_io(t_vslider* 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 {%lxVSLDR%so%d %so%d %lxVSLDR %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_h+4, - xpos+7, ypos + x->x_gui.x_h+5, - x, nlet_tag, 0, nlet_tag, 0, 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 %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 prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxVSLDR%si%d %si%d %lxVSLDR %s inlet iemgui}\n", - canvas, - xpos, ypos, - xpos+7, ypos+1, - x, nlet_tag, 0, nlet_tag, 0, 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 %lxVSLDR%si%d\n", canvas, x, nlet_tag, 0); - } + 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 {%lxVSLDR%so%d %so%d %lxVSLDR %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_h+4, + xpos+7, ypos + x->x_gui.x_h+5, + x, nlet_tag, 0, nlet_tag, 0, 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 %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 prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxVSLDR%si%d %si%d %lxVSLDR %s inlet iemgui}\n", + canvas, + xpos, ypos, + xpos+7, ypos+1, + x, nlet_tag, 0, nlet_tag, 0, 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 %lxVSLDR%si%d\n", canvas, x, nlet_tag, 0); + } } static void vslider_draw_select(t_vslider *x, t_glist *glist) { 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); - 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 %lxVSLDR %s}\n", - canvas, x->x_gui.x_obj.te_xpix + x->x_gui.x_w - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + 5 + x->x_gui.x_h - 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 %lxVSLDR %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 %lxVSLDR\n", canvas, x); - } - else - { - sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", canvas, x, IEM_GUI_COLOR_NORMAL); - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); - sys_vgui(".x%lx.c dtag %lxVSLDR selected\n", canvas, x); - 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); + 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 %lxVSLDR %s}\n", + canvas, + x->x_gui.x_obj.te_xpix + + x->x_gui.x_w - SCALEHANDLE_WIDTH - 1, + x->x_gui.x_obj.te_ypix + 5 + + x->x_gui.x_h - 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 %lxVSLDR %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 %lxVSLDR\n", canvas, x); + } + else + { + sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", + canvas, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", + canvas, x, x->x_gui.x_lcol); + sys_vgui(".x%lx.c dtag %lxVSLDR selected\n", canvas, x); + 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; + } + //} } void vslider_check_minmax(t_vslider *x, double min, double max); void vslider_check_height(t_vslider *x, int w); -static void vslider__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) +static void vslider__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, + t_floatarg yyy) { - t_vslider *x = (t_vslider *)(sh->h_master); + t_vslider *x = (t_vslider *)(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) { - - double height_change_ratio = (double)(x->x_gui.x_h + sh->h_dragy - x->x_gui.scale_offset_y)/(double)x->x_gui.x_h; - x->x_val = x->x_val * height_change_ratio; - - 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_VSLD_MINWIDTH) - x->x_gui.x_w = SCALE_VSLD_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_VSLD_MINHEIGHT) - x->x_gui.x_h = SCALE_VSLD_MINHEIGHT; - - canvas_dirty(x->x_gui.x_glist, 1); - } - - vslider_check_height(x, x->x_gui.x_h); - vslider_check_minmax(x, x->x_min, x->x_max); - - 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); - vslider_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); - } + /* 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) + { + + double height_change_ratio = (double)(x->x_gui.x_h + sh->h_dragy - + x->x_gui.scale_offset_y)/(double)x->x_gui.x_h; + x->x_val = x->x_val * height_change_ratio; + + 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_VSLD_MINWIDTH) + x->x_gui.x_w = SCALE_VSLD_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_VSLD_MINHEIGHT) + x->x_gui.x_h = SCALE_VSLD_MINHEIGHT; + + canvas_dirty(x->x_gui.x_glist, 1); + } + + vslider_check_height(x, x->x_gui.x_h); + vslider_check_minmax(x, x->x_min, x->x_max); + + 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); + vslider_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); - 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, - x->x_gui.x_obj.te_ypix + 5 + x->x_gui.x_h, 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, + x->x_gui.x_obj.te_ypix + 5 + x->x_gui.x_h, 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); - vslider_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); + vslider_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 vslider__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { if (sh->h_dragon && sh->h_scale) { - t_vslider *x = (t_vslider *)(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; - - if (newx < x->x_gui.x_obj.te_xpix + SCALE_VSLD_MINWIDTH) - newx = x->x_gui.x_obj.te_xpix + SCALE_VSLD_MINWIDTH; - if (newy < x->x_gui.x_obj.te_ypix + SCALE_VSLD_MINHEIGHT) - newy = x->x_gui.x_obj.te_ypix + SCALE_VSLD_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, newy + 5); - } - 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_vslider *x = (t_vslider *)(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; + + if (newx < x->x_gui.x_obj.te_xpix + SCALE_VSLD_MINWIDTH) + newx = x->x_gui.x_obj.te_xpix + SCALE_VSLD_MINWIDTH; + if (newy < x->x_gui.x_obj.te_ypix + SCALE_VSLD_MINHEIGHT) + newy = x->x_gui.x_obj.te_ypix + SCALE_VSLD_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, newy + 5); + } + 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); + } } } @@ -503,10 +588,11 @@ void vslider_draw(t_vslider *x, t_glist *glist, int mode) sys_queuegui(x, glist, vslider_draw_update); else if(mode == IEM_GUI_DRAW_MODE_MOVE) vslider_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { vslider_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) vslider_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -529,7 +615,7 @@ static void vslider_getrect(t_gobj *z, t_glist *glist, *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h + 5; - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void vslider_save(t_gobj *z, t_binbuf *b) @@ -557,7 +643,7 @@ void vslider_check_height(t_vslider *x, int h) if(h < IEM_SL_MINSIZE) h = IEM_SL_MINSIZE; x->x_gui.x_h = h; - x->x_center = (x->x_gui.x_h-1)*50; + x->x_center = (x->x_gui.x_h-1)*50; if(x->x_val > (x->x_gui.x_h*100 - 100)) { x->x_pos = x->x_gui.x_h*100 - 100; @@ -620,7 +706,8 @@ static void vslider_properties(t_gobj *z, t_glist *owner) srl[0]->s_name, srl[1]->s_name, 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, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); + 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, + 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } @@ -631,10 +718,11 @@ static void vslider_bang(t_vslider *x) if(x->x_lin0_log1) out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01); else - if (x->x_is_last_float && x->x_last <= x->x_max && x->x_last >= x->x_min) - out = x->x_last; - else - out = (double)(x->x_val)*0.01*x->x_k + x->x_min; + if (x->x_is_last_float && x->x_last <= x->x_max && + x->x_last >= x->x_min) + out = x->x_last; + else + out = (double)(x->x_val)*0.01*x->x_k + x->x_min; if((out < 1.0e-10)&&(out > -1.0e-10)) out = 0.0; @@ -645,7 +733,7 @@ static void vslider_bang(t_vslider *x) static void vslider_dialog(t_vslider *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); @@ -664,31 +752,34 @@ static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv) x->x_steady = 0; sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); x->x_gui.x_w = iemgui_clip_size(w); - int old_height = x->x_gui.x_h; + int old_height = x->x_gui.x_h; vslider_check_height(x, h); - if (x->x_gui.x_h != old_height) { - x->x_val = x->x_val * ((double)x->x_gui.x_h/(double)old_height); - } + if (x->x_gui.x_h != old_height) + { + x->x_val = x->x_val * ((double)x->x_gui.x_h/(double)old_height); + } 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); - 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) { - vslider_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + vslider_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 vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy) { - x->x_is_last_float = 0; + x->x_is_last_float = 0; int old = x->x_val; if(x->x_gui.x_fsf.x_finemoved) @@ -708,26 +799,29 @@ static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy) x->x_pos -= 50; x->x_pos -= x->x_pos%100; } - if(old != x->x_val) { - x->x_gui.x_changed = 1; + if(old != x->x_val) + { + x->x_gui.x_changed = 1; (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); vslider_bang(x); } } static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos, - t_floatarg shift, t_floatarg ctrl, t_floatarg alt) + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { if(!x->x_steady) - x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos)); + x->x_val = (int)(100.0 * (x->x_gui.x_h + + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos)); if(x->x_val > (100*x->x_gui.x_h - 100)) x->x_val = 100*x->x_gui.x_h - 100; if(x->x_val < 0) x->x_val = 0; - if (x->x_pos != x->x_val) { - x->x_pos = x->x_val; - x->x_gui.x_changed = 1; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + if (x->x_pos != x->x_val) + { + x->x_pos = x->x_val; + x->x_gui.x_changed = 1; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } vslider_bang(x); glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, @@ -735,14 +829,14 @@ static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos, } static int vslider_newclick(t_gobj *z, struct _glist *glist, - int xpix, int ypix, int shift, int alt, int dbl, int doit) + int xpix, int ypix, int shift, int alt, int dbl, int doit) { t_vslider* x = (t_vslider *)z; if(doit) { vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, - 0, (t_floatarg)alt); + 0, (t_floatarg)alt); if(shift) x->x_gui.x_fsf.x_finemoved = 1; else @@ -774,17 +868,18 @@ static void vslider_set(t_vslider *x, t_floatarg f) else g = (f - x->x_min) / x->x_k; x->x_val = (int)(100.0*g + 0.49999); - if(x->x_pos != x->x_val) { - x->x_pos = x->x_val; - x->x_gui.x_changed = 1; - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + if(x->x_pos != x->x_val) + { + x->x_pos = x->x_val; + x->x_gui.x_changed = 1; + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } } static void vslider_float(t_vslider *x, t_floatarg f) { - x->x_is_last_float = 1; - x->x_last = f; + x->x_is_last_float = 1; + x->x_last = f; vslider_set(x, f); if(x->x_gui.x_fsf.x_put_in2out) vslider_bang(x); @@ -904,8 +999,8 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_draw = (t_iemfunptr)vslider_draw; x->x_gui.x_fsf.x_snd_able = 1; x->x_gui.x_fsf.x_rcv_able = 1; - x->x_is_last_float = 0; - x->x_last = 0.0; + x->x_is_last_float = 0; + x->x_last = 0.0; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); if(x->x_gui.x_isa.x_loadinit) x->x_val = v; @@ -920,9 +1015,13 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0; if(x->x_gui.x_fsf.x_font_style == 1) 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); } - if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); + 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; x->x_gui.x_ldy = ldy; if(fs < 4) @@ -932,11 +1031,11 @@ static void *vslider_new(t_symbol *s, int argc, t_atom *argv) vslider_check_height(x, h); vslider_check_minmax(x, min, max); iemgui_all_colfromload(&x->x_gui, bflcol); - x->x_thick = 0; + x->x_thick = 0; iemgui_verify_snd_ne_rcv(&x->x_gui); 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); @@ -946,28 +1045,28 @@ static void *vslider_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; - x->x_gui.x_changed = 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; + x->x_gui.x_changed = 0; return (x); } @@ -978,19 +1077,21 @@ static void vslider_free(t_vslider *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_vslider_setup(void) @@ -1006,29 +1107,43 @@ void g_vslider_setup(void) A_FLOAT, A_FLOAT, 0); class_addmethod(vslider_class, (t_method)vslider_dialog, gensym("dialog"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_loadbang, gensym("loadbang"), 0); - class_addmethod(vslider_class, (t_method)vslider_set, gensym("set"), A_FLOAT, 0); - class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_delta, gensym("delta"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_color, gensym("color"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(vslider_class, (t_method)vslider_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(vslider_class, (t_method)vslider_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_loadbang, + gensym("loadbang"), 0); + class_addmethod(vslider_class, (t_method)vslider_set, + gensym("set"), A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_size, + gensym("size"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_delta, + gensym("delta"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_pos, + gensym("pos"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_range, + gensym("range"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_color, + gensym("color"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_send, + gensym("send"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_receive, + gensym("receive"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_label, + gensym("label"), A_DEFSYM, 0); + class_addmethod(vslider_class, (t_method)vslider_label_pos, + gensym("label_pos"), A_GIMME, 0); + class_addmethod(vslider_class, (t_method)vslider_label_font, + gensym("label_font"), A_GIMME, 0); class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0); class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0); - class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0); - class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_init, + gensym("init"), A_FLOAT, 0); + class_addmethod(vslider_class, (t_method)vslider_steady, + gensym("steady"), A_FLOAT, 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)vslider__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)vslider__motionhook, - gensym("_motion"), A_FLOAT, A_FLOAT, 0); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); vslider_widgetbehavior.w_getrectfn = vslider_getrect; vslider_widgetbehavior.w_displacefn = iemgui_displace; @@ -1037,7 +1152,7 @@ void g_vslider_setup(void) vslider_widgetbehavior.w_deletefn = iemgui_delete; vslider_widgetbehavior.w_visfn = iemgui_vis; vslider_widgetbehavior.w_clickfn = vslider_newclick; - vslider_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; + vslider_widgetbehavior.w_displacefnwtag = iemgui_displace_withtag; class_setwidget(vslider_class, &vslider_widgetbehavior); class_sethelpsymbol(vslider_class, gensym("vslider")); class_setsavefn(vslider_class, vslider_save);