diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index ab7c7f63f5efd37a9bfa3fdce9ee936b53d30024..6630fc6af0919bd525f11b5d7a4a25e6ec0866da 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -892,3 +892,78 @@ char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj) else return("bogus"); } +//---------------------------------------------------------------- +// SCALEHANDLE COMMON CODE + +// in all 20 cases : +// [bng], [tgl], [hradio], [vradio], [hsl], [vsl], [cnv], [nbx], [vu] +// for both scale & label, plus canvas' scale & move. +void scalehandle_bind(t_scalehandle *h) { + sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", + h->h_pathname, h->h_bindsym->s_name); + sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", + h->h_pathname, h->h_bindsym->s_name); + sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n", + h->h_pathname, h->h_bindsym->s_name); +} + +// in 18 cases only, because canvas does not fit the pattern below. +// this works only on iemgui, and also, canvas has no label handle and has a motion handle +void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, +const char *nlet_tag, const char *class_tag) { + char tags[128]; // BNG may need up to 100 chars in 64-bit mode, for example + t_iemgui *x = (t_iemgui *)h->h_master; + //if (!nlet_tag) nlet_tag = iem_get_tag(canvas, (t_iemgui *)x); + + const char *cursor = h->h_scale ? "bottom_right_corner" : "crosshair"; + int sx = h->h_scale ? SCALEHANDLE_WIDTH : LABELHANDLE_WIDTH; + int sy = h->h_scale ? SCALEHANDLE_HEIGHT : LABELHANDLE_HEIGHT; + //int px = h->h_scale ? (x->x_gui.x_w-1) : x->x_gui.x_ldx; + //int py = h->h_scale ? (x->x_gui.x_h-1) : x->x_gui.x_ldy; + + //printf("scalehandle_draw_select(x%lx,x%lx,%d,%d,\"%s\",\"%s\")\n",h,canvas,px,py,nlet_tag,class_tag); + + if (h->h_scale ? x->scale_vis : x->label_vis) + scalehandle_draw_erase(h,canvas); + +// sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 " + sys_vgui("canvas %s -width %d -height %d -bg #0080ff -bd 0 " + "-cursor %s\n", h->h_pathname, sx, sy, cursor); + // there was a %lxBNG tag (or similar) in every scalehandle, + // but it didn't seem to be used —mathieu + if (h->h_scale) { + sprintf(tags,"%lx%s %lxSCALE iemgui %s", + (long)x,class_tag,(long)x,nlet_tag); + } else { + //sprintf(tags,"%lx%s %lxLABEL %lxLABELH iemgui %s", // causes unknown option "-fill" + sprintf(tags,"%lx%s %lxLABELH iemgui %s", + (long)x,class_tag,(long)x,nlet_tag); + } + sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d " + "-window %s -tags {%s}\n", canvas, x->x_obj.te_xpix+px-sx, x->x_obj.te_ypix+py-sy, + sx, sy, h->h_pathname, tags); + scalehandle_bind(h); + if (h->h_scale) x->scale_vis = 1; + else x->label_vis = 1; +} + +void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas) { + sys_vgui("destroy %s\n", h->h_pathname); + sys_vgui(".x%lx.c delete %lx%s\n", canvas, h->h_master, h->h_scale ? "SCALE" : "LABELH"); +} + +void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas) { + /*if (x->x_fsf.x_selected) + { + scalehandle_draw_erase((t_scalehandle *)(x->x_handle),canvas); + scalehandle_draw_erase((t_scalehandle *)(x->x_lhandle),canvas); + }*/ + if (x->scale_vis) { + scalehandle_draw_erase((t_scalehandle *)(x->x_handle),canvas); + x->scale_vis = 0; + } + if (x->label_vis) { + scalehandle_draw_erase((t_scalehandle *)(x->x_lhandle),canvas); + x->label_vis = 0; + } +} diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index f8cb173209708720bfda6f8d3f095a2928fdf8db..9f077cdbed2fc08bdc4b1bcbba1eb2ce780ba66d 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -404,3 +404,9 @@ EXTERN int iem_fstyletoint(t_iem_fstyle_flags *fstylep); EXTERN char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj); EXTERN void canvas_apply_setundo(t_canvas *x, t_gobj *y); + +// scalehandle code, as refactored by Mathieu +EXTERN void scalehandle_bind(t_scalehandle *h); +EXTERN void scalehandle_draw_select(t_scalehandle *h, t_glist *canvas, int px, int py, const char *nlet_tag, const char *class_tag); +EXTERN void scalehandle_draw_erase(t_scalehandle *h, t_glist *canvas); +EXTERN void scalehandle_draw_erase2(t_iemgui *x, t_glist *canvas); diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index 8e10a625b420f6cbab0d8ac230745a4b30b51656..e4a04ea30b358f592c4f8a33ae90fa303f796262 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -45,6 +45,7 @@ void bng_draw_update(t_gobj *xgobj, t_glist *glist) sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", glist_getcanvas(glist), x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); + //vcanvas_itemconf(glist,x,"BUT","-fill",x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); } x->x_gui.x_changed = x->x_flashed; } @@ -156,15 +157,7 @@ void bng_draw_erase(t_bng* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c delete %lxBNG\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxBNG\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); /* sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); sys_vgui(".x%lx.c delete %lxBUT\n", canvas, x); @@ -264,62 +257,10 @@ void bng_draw_select(t_bng* x, t_glist* glist) 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 %lxBNG iemgui %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 + 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; - + scalehandle_draw_select(sh,canvas,x->x_gui.x_w-1,x->x_gui.x_h-1,nlet_tag,"BNG"); 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 %lxBNG iemgui %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"BNG"); } } sys_vgui(".x%lx.c addtag selected withtag %lxBNG\n", canvas, x); @@ -333,12 +274,7 @@ void bng_draw_select(t_bng* x, t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%lx.c dtag %lxBNG 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 70c030581547b1b47bca57630beab1f613d3fb69..98388c7ef63d45ff658110f01096ece06d17abdc 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -737,6 +737,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) sprintf(sh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)sh); sys_vgui("destroy %s\n", sh->h_pathname); sys_vgui(".x%lx.c delete GOP_resblob\n", 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); @@ -747,13 +748,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) x->gl_ymargin + 3 + x->gl_pixheight - SCALEHANDLE_HEIGHT - 4, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, sh->h_pathname, x, x); - - 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); + scalehandle_bind(sh); //Drawing and Binding Move_Blob for GOP sprintf(mh->h_pathname, ".x%lx.h%lx", (t_int)x, (t_int)mh); @@ -768,14 +763,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) x->gl_ymargin + 2 , SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT, mh->h_pathname, x, x); - - sys_vgui("bind %s <Button> {pd [concat %s _click 1 %%x %%y \\;]}\n", - mh->h_pathname, mh->h_bindsym->s_name); - sys_vgui("bind %s <ButtonRelease> {pd [concat %s _click 0 0 0 \\;]}\n", - mh->h_pathname, mh->h_bindsym->s_name); - sys_vgui("bind %s <Motion> {pd [concat %s _motion %%x %%y \\;]}\n", - mh->h_pathname, mh->h_bindsym->s_name); - + scalehandle_bind(mh); } else { diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index aef8b43bcf7ee091f5361cec8d7988ed63a5f13b..f51bc02f08e133776759b2c9ad242581c0ea070b 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -160,15 +160,7 @@ void hradio_draw_erase(t_hradio* x, t_glist* glist) sys_vgui(".x%lx.c delete %lxHRDO\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxHRDO\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); /* for(i=0; i<n; i++) { @@ -288,66 +280,10 @@ void hradio_draw_select(t_hradio* x, t_glist* glist) "-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 %lxHRDO %s iemgui}\n", - canvas, x->x_gui.x_obj.te_xpix + - x->x_gui.x_w * x->x_number - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + - 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; + scalehandle_draw_select(sh,canvas,x->x_gui.x_w*x->x_number-1,x->x_gui.x_h-1,nlet_tag,"HRDO"); 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 %lxHRDO %s iemgui}\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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"HRDO"); } } @@ -363,12 +299,7 @@ void hradio_draw_select(t_hradio* x, t_glist* glist) } 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } @@ -376,7 +307,6 @@ void hradio_draw_select(t_hradio* x, t_glist* glist) static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) { - t_hradio *x = (t_hradio *)(sh->h_master); if (xxx) diff --git a/pd/src/g_hslider.c b/pd/src/g_hslider.c index ec6656207b13b2e54f00b201151d7eed237485b8..6bbdbe1752b576507f86d4efcb9db03eb58fb90e 100644 --- a/pd/src/g_hslider.c +++ b/pd/src/g_hslider.c @@ -165,15 +165,7 @@ static void hslider_draw_erase(t_hslider* x,t_glist* glist) sys_vgui(".x%lx.c delete %lxHSLDR\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxHSLDR\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); /* sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); sys_vgui(".x%lx.c delete %lxKNOB\n", canvas, x); @@ -267,67 +259,10 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist) "-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 %lxHSLDR %s}\n", - canvas, x->x_gui.x_obj.te_xpix + - x->x_gui.x_w + 5 - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + - 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; - + scalehandle_draw_select(sh,canvas,x->x_gui.x_w+5-1,x->x_gui.x_h-1,nlet_tag,"HSLDR"); 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 %lxHSLDR %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"HSLDR"); } } @@ -340,12 +275,8 @@ static void hslider_draw_select(t_hslider* x,t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%lx.c dtag %lxHSLDR 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; + scalehandle_draw_erase2(&x->x_gui,glist); + } //} } diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index b7a5f55d895ed80c1eb1c82c0e596f32667e3e6b..2018e1e3860fb07b5ba14e0d8d679ba3b764ce5f 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -102,15 +102,7 @@ void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist) sys_vgui(".x%lx.c delete %lxMYCNV\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxMYCNV\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); //sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); //sys_vgui(".x%lx.c delete %lxRECT\n", canvas, x); //sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x); @@ -165,63 +157,10 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxBASE " "-stroke $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 %lxMYCNV %s}\n", - canvas, - x->x_gui.x_obj.te_xpix + x->x_vis_w - - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + x->x_vis_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; - + scalehandle_draw_select(sh,canvas,x->x_vis_w-1,x->x_vis_h-1,nlet_tag,"MYCNV"); 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 %lxMYCNV %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"MYCNV"); } } @@ -232,12 +171,7 @@ void my_canvas_draw_select(t_my_canvas* x, t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%lx.c dtag %lxMYCNV 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_numbox.c b/pd/src/g_numbox.c index b8f86b182bd90c7d9e76b95a8959d6649bfbabef..9e449fd0de7b93bfbb78652d20c1208b184e9578 100644 --- a/pd/src/g_numbox.c +++ b/pd/src/g_numbox.c @@ -324,15 +324,7 @@ static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist) sys_vgui(".x%lx.c delete %lxNUM\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxNUM\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); } static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist) @@ -486,60 +478,10 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) "-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 %lxNUM %s}\n", - canvas, x->x_gui.x_obj.te_xpix + x->x_numwidth - - SCALEHANDLE_WIDTH - 1, - x->x_gui.x_obj.te_ypix + 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; + scalehandle_draw_select(sh,canvas,x->x_numwidth-1,x->x_gui.x_h-1,nlet_tag,"NUM"); 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 %lxNUM %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"NUM"); } } @@ -561,12 +503,7 @@ static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist) canvas, x, x->x_gui.x_lcol); sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol); - 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_toggle.c b/pd/src/g_toggle.c index f98fcaaac86c9c431130a07a03584a407df18456..65fba1541816edcb489bde5cf435026d7f08253f 100644 --- a/pd/src/g_toggle.c +++ b/pd/src/g_toggle.c @@ -163,15 +163,7 @@ void toggle_draw_erase(t_toggle* x, t_glist* glist) sys_vgui(".x%lx.c delete %lxTGL\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxTGL\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); } void toggle_draw_config(t_toggle* x, t_glist* glist) @@ -272,70 +264,17 @@ void toggle_draw_select(t_toggle* x, t_glist* glist) 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); - } + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)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 %lxTGL %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 + 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; + 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); + scalehandle_draw_select(sh,canvas,x->x_gui.x_w-1,x->x_gui.x_h-1,nlet_tag,"TGL"); 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 %lxTGL %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"TGL"); } } @@ -348,12 +287,7 @@ void toggle_draw_select(t_toggle* x, t_glist* glist) sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); sys_vgui(".x%lx.c dtag %lxTGL 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_vdial.c b/pd/src/g_vdial.c index 0fb3f00fc26897b96db70fc981346124d48e0b8b..ccdafd511628e4415763cb160657b0f35f1b9f27 100644 --- a/pd/src/g_vdial.c +++ b/pd/src/g_vdial.c @@ -157,15 +157,7 @@ void vradio_draw_erase(t_vradio* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c delete %lxVRDO\n", canvas, x); sys_vgui(".x%lx.c dtag all %lxVRDO\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); - } + scalehandle_draw_erase2(&x->x_gui,glist); } void vradio_draw_config(t_vradio* x, t_glist* glist) @@ -278,68 +270,10 @@ void vradio_draw_select(t_vradio* x, t_glist* glist) "-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 %lxVRDO %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 + - x->x_gui.x_h * x->x_number - 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; - + scalehandle_draw_select(sh,canvas,x->x_gui.x_w-1,x->x_gui.x_h*x->x_number-1,nlet_tag,"VRDO"); 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 %lxVRDO %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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"VRDO"); } } @@ -355,12 +289,7 @@ void vradio_draw_select(t_vradio* x, t_glist* glist) } 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.scale_vis = 0; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_vslider.c b/pd/src/g_vslider.c index 6631e521b106f505bcabc1e8dc7732096c075bbb..c9cd40c213da967b063d7bad4dd2c611087233d5 100644 --- a/pd/src/g_vslider.c +++ b/pd/src/g_vslider.c @@ -169,15 +169,7 @@ static void vslider_draw_erase(t_vslider* x,t_glist* 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); - } + scalehandle_draw_erase2(&x->x_gui,glist); } static void vslider_draw_config(t_vslider* x,t_glist* glist) @@ -274,69 +266,10 @@ static void vslider_draw_select(t_vslider *x, t_glist *glist) "-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; - + scalehandle_draw_select(sh,canvas,x->x_gui.x_w-1,x->x_gui.x_h+5-1,nlet_tag,"VSLDR"); 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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"VSLDR"); } } @@ -349,12 +282,7 @@ static void vslider_draw_select(t_vslider *x, t_glist *glist) 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} } diff --git a/pd/src/g_vumeter.c b/pd/src/g_vumeter.c index 47a45ebd527c7cbd6fce37ea3c4e986a171e655c..dbafcf5d0037d2398d7f9f983ee7b1384826e109 100644 --- a/pd/src/g_vumeter.c +++ b/pd/src/g_vumeter.c @@ -284,15 +284,7 @@ static void vu_draw_erase(t_vu* x,t_glist* 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); - } + scalehandle_draw_erase2(&x->x_gui,glist); } static void vu_draw_config(t_vu* x, t_glist* glist) @@ -464,68 +456,10 @@ static void vu_draw_select(t_vu* x,t_glist* glist) "-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; + scalehandle_draw_select(sh,canvas,x->x_gui.x_w+2-1,x->x_gui.x_h+4-1,nlet_tag,"VU"); 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; + scalehandle_draw_select(lh,canvas,x->x_gui.x_ldx,x->x_gui.x_ldy,nlet_tag,"VU"); } } @@ -550,12 +484,7 @@ static void vu_draw_select(t_vu* x,t_glist* glist) } 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; + scalehandle_draw_erase2(&x->x_gui,glist); } //} }