diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 912b37e8b74b3322863ff2d1b04b6029e8cfbb94..83391e2960a3849d9ed63609af76a179bfacced9 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -406,37 +406,40 @@ void iemgui_label(void *x, t_iemgui *iemgui, t_symbol *s) int pargc, tail_len, nth_arg; t_atom *pargv; - /* tb: fix for empty label { */ - if (s == gensym("")) - s = gensym("empty"); - /* tb } */ + /* tb: fix for empty label { */ + if (s == gensym("")) + s = gensym("empty"); + /* tb } */ lab = iemgui_raute2dollar(s); iemgui->x_lab_unexpanded = lab; iemgui->x_lab = lab = canvas_realizedollar(iemgui->x_glist, lab); - if(glist_isvisible(iemgui->x_glist)) { + if(glist_isvisible(iemgui->x_glist)) + { sys_vgui(".x%lx.c itemconfigure %lxLABEL -text {%s} \n", - glist_getcanvas(iemgui->x_glist), x, - strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:""); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); - } + glist_getcanvas(iemgui->x_glist), x, + strcmp(s->s_name, "empty")?iemgui->x_lab->s_name:""); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } } void iemgui_label_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) { iemgui->x_ldx = (int)atom_getintarg(0, ac, av); iemgui->x_ldy = (int)atom_getintarg(1, ac, av); - if(glist_isvisible(iemgui->x_glist)) { - sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - glist_getcanvas(iemgui->x_glist), x, - text_xpix((t_object *)x,iemgui->x_glist)+iemgui->x_ldx, - text_ypix((t_object *)x,iemgui->x_glist)+iemgui->x_ldy); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); - } + if(glist_isvisible(iemgui->x_glist)) + { + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + glist_getcanvas(iemgui->x_glist), x, + text_xpix((t_object *)x,iemgui->x_glist)+iemgui->x_ldx, + text_ypix((t_object *)x,iemgui->x_glist)+iemgui->x_ldy); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } } -void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) +void iemgui_label_font(void *x, t_iemgui *iemgui, + t_symbol *s, int ac, t_atom *av) { int f = (int)atom_getintarg(0, ac, av); @@ -452,12 +455,13 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a if(f < 4) f = 4; iemgui->x_fontsize = f; - if(glist_isvisible(iemgui->x_glist)) { + if(glist_isvisible(iemgui->x_glist)) + { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s}\n", - glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, - iemgui->x_fontsize, sys_fontweight); - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); - } + glist_getcanvas(iemgui->x_glist), x, iemgui->x_font, + iemgui->x_fontsize, sys_fontweight); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_CONFIG); + } } //Sans: 84 x 10 (14) -> 6 x 10 -> 1.0 @@ -470,148 +474,187 @@ void iemgui_label_font(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *a // misinterpreted as part of the "hot" area of a widget (e.g. toggle) extern int gop_redraw; -void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, int *xp1, int *yp1, int *xp2, int *yp2) -{ - //fprintf(stderr,"gop_redraw = %d\n", gop_redraw); - if (!gop_redraw) { - //fprintf(stderr,"ignoring label\n"); - return; - } - - t_float width_multiplier; - int label_length; - int label_x1; - int label_y1; - int label_x2; - int label_y2; - int actual_fontsize; //seems tk does its own thing when it comes to rendering - int actual_height; - - if (x->gl_isgraph && !glist_istoplevel(x)) { - //fprintf(stderr,"iemgui_label_getrect\n"); - - if (strcmp(x_gui.x_lab->s_name, "empty")) { - switch(x_gui.x_fsf.x_font_style) { - case 1: - width_multiplier = 0.83333; - break; - case 2: - width_multiplier = 0.735; - break; - default: - width_multiplier = 1.0; - break; - } - if (x_gui.x_fontsize % 2 == 0) { - actual_fontsize = x_gui.x_fontsize; - } else { - actual_fontsize = x_gui.x_fontsize; - } - actual_height = actual_fontsize; - //exceptions - if (x_gui.x_fsf.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || (actual_fontsize > 48 && actual_fontsize < 100 && (actual_fontsize %10 == 4 || actual_fontsize %10 == 9))) ) { - actual_fontsize += 1; - } - else if (x_gui.x_fsf.x_font_style == 1 && actual_fontsize >= 5 && actual_fontsize < 13 && actual_fontsize % 2 == 1) - actual_fontsize += 1; - else if (x_gui.x_fsf.x_font_style == 2 && actual_fontsize >= 5 && actual_fontsize % 2 == 1) - actual_fontsize += 1; - if (actual_height == 9) - actual_height += 1; - //done with exceptions - - width_multiplier = width_multiplier * (actual_fontsize * 0.6); - - label_length = strlen(x_gui.x_lab->s_name); - label_x1 = *xp1 + x_gui.x_ldx; - label_y1 = *yp1 + x_gui.x_ldy - actual_height/2; - label_x2 = label_x1 + (label_length * width_multiplier); - label_y2 = label_y1 + actual_height*1.1; - - //DEBUG - //fprintf(stderr,"%f %d %d\n", width_multiplier, label_length, x_gui.x_fsf.x_font_style); - //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); - //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", x, label_x1, label_y1, label_x2, label_y2); - if (label_x1 < *xp1) *xp1 = label_x1; - if (label_x2 > *xp2) *xp2 = label_x2; - if (label_y1 < *yp1) *yp1 = label_y1; - if (label_y2 > *yp2) *yp2 = label_y2; - //DEBUG - //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); - //sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags iemguiDEBUG\n", x, *xp1, *yp1, *xp2, *yp2); - } - } +void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, + int *xp1, int *yp1, int *xp2, int *yp2) +{ + //fprintf(stderr,"gop_redraw = %d\n", gop_redraw); + if (!gop_redraw) + { + //fprintf(stderr,"ignoring label\n"); + return; + } + + t_float width_multiplier; + int label_length; + int label_x1; + int label_y1; + int label_x2; + int label_y2; + int actual_fontsize; //seems tk does its own thing when it comes to rendering + int actual_height; + + if (x->gl_isgraph && !glist_istoplevel(x)) + { + //fprintf(stderr,"iemgui_label_getrect\n"); + + if (strcmp(x_gui.x_lab->s_name, "empty")) + { + switch(x_gui.x_fsf.x_font_style) + { + case 1: + width_multiplier = 0.83333; + break; + case 2: + width_multiplier = 0.735; + break; + default: + width_multiplier = 1.0; + break; + } + if (x_gui.x_fontsize % 2 == 0) + { + actual_fontsize = x_gui.x_fontsize; + } + else + { + actual_fontsize = x_gui.x_fontsize; + } + actual_height = actual_fontsize; + //exceptions + if (x_gui.x_fsf.x_font_style == 0 && + (actual_fontsize == 8 || actual_fontsize == 13 || + actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || + (actual_fontsize > 48 && actual_fontsize < 100 && + (actual_fontsize %10 == 4 || actual_fontsize %10 == 9)))) + { + actual_fontsize += 1; + } + else if (x_gui.x_fsf.x_font_style == 1 && actual_fontsize >= 5 && + actual_fontsize < 13 && actual_fontsize % 2 == 1) + actual_fontsize += 1; + else if (x_gui.x_fsf.x_font_style == 2 && actual_fontsize >= 5 && + actual_fontsize % 2 == 1) + actual_fontsize += 1; + if (actual_height == 9) + actual_height += 1; + //done with exceptions + + width_multiplier = width_multiplier * (actual_fontsize * 0.6); + + label_length = strlen(x_gui.x_lab->s_name); + label_x1 = *xp1 + x_gui.x_ldx; + label_y1 = *yp1 + x_gui.x_ldy - actual_height/2; + label_x2 = label_x1 + (label_length * width_multiplier); + label_y2 = label_y1 + actual_height*1.1; + + //DEBUG + //fprintf(stderr,"%f %d %d\n", width_multiplier, + // label_length, x_gui.x_fsf.x_font_style); + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d " + // "-tags iemguiDEBUG\n", + // x, label_x1, label_y1, label_x2, label_y2); + if (label_x1 < *xp1) *xp1 = label_x1; + if (label_x2 > *xp2) *xp2 = label_x2; + if (label_y1 < *yp1) *yp1 = label_y1; + if (label_y2 > *yp2) *yp2 = label_y2; + //DEBUG + //sys_vgui(".x%lx.c delete iemguiDEBUG\n", x); + //sys_vgui(".x%lx.c create rectangle %d %d %d %d " + // "-tags iemguiDEBUG\n", x, *xp1, *yp1, *xp2, *yp2); + } + } } void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) { - gop_redraw = 1; - if(gobj_shouldvis(x, iemgui->x_glist)) { - if (!iemgui->x_vis) { - //fprintf(stderr,"draw new %d\n", mode); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_NEW); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); - iemgui->x_vis = 1; - if (iemgui->x_glist != glist_getcanvas(iemgui->x_glist)) { - // if we are inside gop and just have had our object's properties changed - // we'll adjust our layer position to ensure that ordering is honored - t_canvas *canvas = glist_getcanvas(iemgui->x_glist); - t_gobj *y = (t_gobj *)iemgui->x_glist; - gobj_vis(y, canvas, 0); - gobj_vis(y, canvas, 1); - // reorder it visually - glist_redraw(canvas); - /* some day when the object tagging is properly done for all GUI objects - glist_noselect(canvas); - glist_select(canvas, y); - t_gobj *yy = canvas->gl_list; - if (yy != y) { - fprintf(stderr,"not bottom\n"); - while (yy && yy->g_next != y) { - fprintf(stderr,"+\n"); - yy = yy->g_next; - } - // now we have yy which is right before our y graph - t_object *ob = NULL; - t_rtext *yr = NULL; - if (yy) { - yr = glist_findrtext(canvas, (t_text *)yy); - } - if (yr) { - fprintf(stderr,"lower\n"); - sys_vgui(".x%lx.c lower selected %s\n", canvas, rtext_gettag(yr)); - sys_vgui(".x%lx.c raise selected %s\n", canvas, rtext_gettag(yr)); - //sys_vgui(".x%lx.c raise all_cords\n", canvas); - } else { - // fall back to legacy redraw for objects that are not patchable - fprintf(stderr,"lower fallback redraw\n"); - canvas_redraw(canvas); - } - } else { - // we get here if we are supposed to go all the way to the bottom - fprintf(stderr,"lower to the bottom\n"); - sys_vgui(".x%lx.c lower selected\n", canvas); - } - glist_noselect(canvas);*/ - } - } - //fprintf(stderr,"draw move iemgui->x_w=%d\n", iemgui->x_w); - (*iemgui->x_draw)(x, iemgui->x_glist, mode); - canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); - } else if (iemgui->x_vis) { - //fprintf(stderr,"draw erase %d\n", mode); - (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_ERASE); - iemgui->x_vis = 0; - } - gop_redraw = 0; + gop_redraw = 1; + if(gobj_shouldvis(x, iemgui->x_glist)) + { + if (!iemgui->x_vis) + { + //fprintf(stderr,"draw new %d\n", mode); + (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_NEW); + canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + iemgui->x_vis = 1; + if (iemgui->x_glist != glist_getcanvas(iemgui->x_glist)) + { + /* if we are inside gop and just have had our object's + properties changed we'll adjust our layer position + to ensure that ordering is honored */ + t_canvas *canvas = glist_getcanvas(iemgui->x_glist); + t_gobj *y = (t_gobj *)iemgui->x_glist; + gobj_vis(y, canvas, 0); + gobj_vis(y, canvas, 1); + // reorder it visually + glist_redraw(canvas); + + /* + // some day when the object tagging is + // properly done for all GUI objects + glist_noselect(canvas); + glist_select(canvas, y); + t_gobj *yy = canvas->gl_list; + if (yy != y) + { + fprintf(stderr,"not bottom\n"); + while (yy && yy->g_next != y) + { + fprintf(stderr,"+\n"); + yy = yy->g_next; + } + // now we have yy which is right before our y graph + t_object *ob = NULL; + t_rtext *yr = NULL; + if (yy) + { + yr = glist_findrtext(canvas, (t_text *)yy); + } + if (yr) + { + fprintf(stderr,"lower\n"); + sys_vgui(".x%lx.c lower selected %s\n", + canvas, rtext_gettag(yr)); + sys_vgui(".x%lx.c raise selected %s\n", + canvas, rtext_gettag(yr)); + //sys_vgui(".x%lx.c raise all_cords\n", canvas); + } + else + { + // fall back to legacy redraw for objects + // that are not patchable + fprintf(stderr,"lower fallback redraw\n"); + canvas_redraw(canvas); + } + } + else + { + // we get here if we are supposed to go + // all the way to the bottom + fprintf(stderr,"lower to the bottom\n"); + sys_vgui(".x%lx.c lower selected\n", canvas); + } + glist_noselect(canvas); + */ + } + } + //fprintf(stderr,"draw move iemgui->x_w=%d\n", iemgui->x_w); + (*iemgui->x_draw)(x, iemgui->x_glist, mode); + canvas_fixlinesfor(glist_getcanvas(iemgui->x_glist), (t_text*)x); + } + else if (iemgui->x_vis) + { + //fprintf(stderr,"draw erase %d\n", mode); + (*iemgui->x_draw)(x, iemgui->x_glist, IEM_GUI_DRAW_MODE_ERASE); + iemgui->x_vis = 0; + } + gop_redraw = 0; } void iemgui_size(void *x, t_iemgui *iemgui) { if(glist_isvisible(iemgui->x_glist)) - { - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); - } + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) @@ -620,7 +663,7 @@ void iemgui_delta(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) iemgui->x_obj.te_ypix += (int)atom_getintarg(1, ac, av); if(glist_isvisible(iemgui->x_glist)) { - //fprintf(stderr,"iemgui_delta->shouldvis\n"); + //fprintf(stderr,"iemgui_delta->shouldvis\n"); iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } } @@ -630,7 +673,7 @@ void iemgui_pos(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) iemgui->x_obj.te_xpix = (int)atom_getintarg(0, ac, av); iemgui->x_obj.te_ypix = (int)atom_getintarg(1, ac, av); if(glist_isvisible(iemgui->x_glist)) - iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); + iemgui_shouldvis(x, iemgui, IEM_GUI_DRAW_MODE_MOVE); } void iemgui_color(void *x, t_iemgui *iemgui, t_symbol *s, int ac, t_atom *av) @@ -681,18 +724,20 @@ void iemgui_delete(t_gobj *z, t_glist *glist) void iemgui_vis(t_gobj *z, t_glist *glist, int vis) { t_iemguidummy *x = (t_iemguidummy *)z; - if (gobj_shouldvis(z, glist)) { - if (vis) { - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW); - x->x_gui.x_vis = 1; - } - else - { - (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE); - sys_unqueuegui(z); - x->x_gui.x_vis = 0; - } - } + if (gobj_shouldvis(z, glist)) + { + if (vis) + { + (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_NEW); + x->x_gui.x_vis = 1; + } + else + { + (*x->x_gui.x_draw)((void *)z, glist, IEM_GUI_DRAW_MODE_ERASE); + sys_unqueuegui(z); + x->x_gui.x_vis = 0; + } + } } void iemgui_save(t_iemgui *iemgui, t_symbol **srl, int *bflcol) @@ -837,16 +882,17 @@ int iem_fstyletoint(t_iem_fstyle_flags *fstylep) char *iem_get_tag(t_canvas *glist, t_iemgui *iem_obj) { - t_gobj *y = (t_gobj *)iem_obj; - t_object *ob = pd_checkobject(&y->g_pd); + t_gobj *y = (t_gobj *)iem_obj; + t_object *ob = pd_checkobject(&y->g_pd); - /* GOP objects are unable to call findrtext triggering consistency check error */ - t_rtext *yyyy = NULL; - if (!glist->gl_isgraph || glist_istoplevel(glist)) - yyyy = glist_findrtext(glist_getcanvas(glist), (t_text *)&ob->ob_g); + /* GOP objects are unable to call findrtext + triggering consistency check error */ + t_rtext *yyyy = NULL; + if (!glist->gl_isgraph || glist_istoplevel(glist)) + yyyy = glist_findrtext(glist_getcanvas(glist), (t_text *)&ob->ob_g); - /* on GOP we cause segfault as text_gettag() returns bogus data */ - if (yyyy) return(rtext_gettag(yyyy)); - else return("bogus"); + /* on GOP we cause segfault as text_gettag() returns bogus data */ + if (yyyy) return(rtext_gettag(yyyy)); + else return("bogus"); } diff --git a/pd/src/g_array.c b/pd/src/g_array.c index 4aeadbc33815960fe4be74e40fa005f7f61d35c6..23f4c89fe176660a4e53fa80d2c40aac1f1556c8 100644 --- a/pd/src/g_array.c +++ b/pd/src/g_array.c @@ -68,7 +68,7 @@ void garray_arrayviewlist_close(t_garray *x); void array_resize(t_array *x, int n) { - //fprintf(stderr,"array_resize\n"); + //fprintf(stderr,"array_resize\n"); int elemsize, oldn; t_gpointer *gp; t_template *template = template_findbyname(x->a_templatesym); @@ -94,7 +94,7 @@ void array_resize(t_array *x, int n) static void array_resize_and_redraw(t_array *array, t_glist *glist, int n) { - //fprintf(stderr,"array_resize_and_redraw\n"); + //fprintf(stderr,"array_resize_and_redraw\n"); t_array *a2 = array; int vis = glist_isvisible(glist); while (a2->a_gp.gp_stub->gs_which == GP_ARRAY) @@ -214,9 +214,9 @@ static t_garray *graph_scalar(t_glist *gl, t_symbol *s, t_symbol *templatesym, outline, 1); glist_add(gl, &x->x_gobj); x->x_glist = gl; - char buf[MAXPDSTRING]; - sprintf(buf, "%s_changed", x->x_realname->s_name); - x->x_send = gensym(buf); + char buf[MAXPDSTRING]; + sprintf(buf, "%s_changed", x->x_realname->s_name); + x->x_send = gensym(buf); return (x); } @@ -281,7 +281,7 @@ int garray_joc(t_garray *x) to fit a new size and style for the garray */ void garray_fittograph(t_garray *x, int n) { - //fprintf(stderr,"garray_fittoraph %d\n", n); + //fprintf(stderr,"garray_fittoraph %d\n", n); t_array *array = garray_getarray(x); t_glist *gl = x->x_glist; if (gl->gl_list == &x->x_gobj && !x->x_gobj.g_next) @@ -328,7 +328,7 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, int argc, t_atom *argv) int flags = fflags; t_gpointer gp; int filestyle = ((flags & 6) >> 1); - //fprintf(stderr,"filestyle = %d\n", filestyle); + //fprintf(stderr,"filestyle = %d\n", filestyle); int style = (filestyle == 0 ? PLOTSTYLE_POINTS : (filestyle == 1 ? PLOTSTYLE_POLY : filestyle)); if (templateargsym != &s_float) @@ -397,7 +397,7 @@ void canvas_menuarray(t_glist *canvas) { if (canvas_hasarray(canvas)) return; t_glist *x = (t_glist *)canvas; - pd_vmess(&x->gl_pd, gensym("editmode"), "i", 1); + pd_vmess(&x->gl_pd, gensym("editmode"), "i", 1); char cmdbuf[200]; sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 3 1 .x%lx black black\n", ++gcount, (long unsigned int)canvas); @@ -448,9 +448,11 @@ void glist_arraydialog(t_glist *parent, t_symbol *s, int argc, t_atom *argv) int flags = fflags; if (size < 1) size = 1; - if (otherflag == 0 || (!(gl = glist_findgraph(parent)))) { + if (otherflag == 0 || (!(gl = glist_findgraph(parent)))) + { gl = glist_addglist(parent, &s_, 0, 1, - (size > 1 ? size-1 : size), -1, xdraw+30, ydraw+30, xdraw+30+GLIST_DEFGRAPHWIDTH, ydraw+30+GLIST_DEFGRAPHHEIGHT); + (size > 1 ? size-1 : size), -1, xdraw+30, ydraw+30, + xdraw+30+GLIST_DEFGRAPHWIDTH, ydraw+30+GLIST_DEFGRAPHHEIGHT); gl->gl_hidetext = 1; } //a = graph_array(gl, sharptodollar(name), &s_float, size, flags); @@ -470,9 +472,10 @@ void glist_arraydialog(t_glist *parent, t_symbol *s, int argc, t_atom *argv) a = graph_array(gl, gensym("array"), 8, at); canvas_dirty(parent, 1); - //canvas_redraw(glist_getcanvas(parent)); - garray_fittograph(a, (int)size); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", (long unsigned int)glist_getcanvas(parent)); + //canvas_redraw(glist_getcanvas(parent)); + garray_fittograph(a, (int)size); + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", + (long unsigned int)glist_getcanvas(parent)); } extern void canvas_apply_setundo(t_canvas *x, t_gobj *y); @@ -485,14 +488,14 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) int deleteit = atom_getfloatarg(3, argc, argv); if (deleteit != 0) { - //fprintf(stderr,"deleteit\n"); - //glist_select(x->x_glist, &x->x_gobj); - //canvas_undo_add(x->x_glist, 3, "delete", canvas_undo_set_cut(x->x_glist, 2)); // 2 = UCUT_CLEAR (from g_editor.c) - //currently cannot be undo'd until we do a new kind of undo - int dspwas = canvas_suspend_dsp(); + //fprintf(stderr,"deleteit\n"); + //glist_select(x->x_glist, &x->x_gobj); + //canvas_undo_add(x->x_glist, 3, "delete", canvas_undo_set_cut(x->x_glist, 2)); // 2 = UCUT_CLEAR (from g_editor.c) +//currently cannot be undo'd until we do a new kind of undo + int dspwas = canvas_suspend_dsp(); glist_delete(x->x_glist, &x->x_gobj); - canvas_resume_dsp(dspwas); - canvas_redraw(glist_getcanvas(x->x_glist)); + canvas_resume_dsp(dspwas); + canvas_redraw(glist_getcanvas(x->x_glist)); } else { @@ -508,16 +511,20 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) int flags = atom_getfloatarg(2, argc, argv); t_symbol *fill = atom_getsymbolarg(6, argc, argv); t_symbol *outline = atom_getsymbolarg(7, argc, argv); - int saveit = ((flags & 1) != 0); - int style = ((flags & 6) >> 1); + int saveit = ((flags & 1) != 0); + int style = ((flags & 6) >> 1); + /* todo: revisit this filestyle business if (style < 2) style = !style; */ + int hidename = ((flags & 8) >> 3); int joc = ((flags & 16) >> 4); - /*t_float stylewas = template_getfloat( - template_findbyname(x->x_scalar->sc_template), - gensym("style"), x->x_scalar->sc_vec, 1);*/ + + /*t_float stylewas = template_getfloat( + template_findbyname(x->x_scalar->sc_template), + gensym("style"), x->x_scalar->sc_vec, 1);*/ + int size; int styleonset, styletype; t_symbol *stylearraytype; @@ -549,32 +556,34 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) pd_bind(&x->x_gobj.g_pd, x->x_realname); } /* redraw the whole glist, just so the name change shows up */ - if (x->x_glist->gl_havewindow) { + if (x->x_glist->gl_havewindow) + { canvas_redraw(glist_getcanvas(x->x_glist)); - //fprintf(stderr,"================REDRAW\n"); - } + //fprintf(stderr,"================REDRAW\n"); + } size = fsize; if (size < 1) size = 1; if (size != a->a_n) garray_resize(x, size); - if (style != x->x_style) { - x->x_style = style; + if (style != x->x_style) + { + x->x_style = style; garray_fittograph(x, size); - } - //fprintf(stderr,"style=%d %f\n", style, (t_float)x->x_style); + } + //fprintf(stderr,"style=%d %f\n", style, (t_float)x->x_style); template_setfloat(scalartemplate, gensym("style"), x->x_scalar->sc_vec, (t_float)x->x_style, 0); - template_setfloat(scalartemplate, gensym("linewidth"), - x->x_scalar->sc_vec, ((x->x_style == PLOTSTYLE_POINTS) ? 2 : 1), 1); + template_setfloat(scalartemplate, gensym("linewidth"), + x->x_scalar->sc_vec, ((x->x_style == PLOTSTYLE_POINTS) ? 2 : 1), 1); template_setsymbol(scalartemplate, gensym("fillcolor"), x->x_scalar->sc_vec, fill, 0); template_setsymbol(scalartemplate, gensym("outlinecolor"), x->x_scalar->sc_vec, outline, 0); - char buf[MAXPDSTRING]; - sprintf(buf, "%s_changed", x->x_realname->s_name); - x->x_send = gensym(buf); + char buf[MAXPDSTRING]; + sprintf(buf, "%s_changed", x->x_realname->s_name); + x->x_send = gensym(buf); garray_setsaveit(x, (saveit != 0)); x->x_joc = joc; @@ -582,7 +591,7 @@ void garray_arraydialog(t_garray *x, t_symbol *s, int argc, t_atom *argv) x->x_fillcolor = fill; x->x_outlinecolor = outline; x->x_style = style; - //fprintf(stderr,"GARRAY_REDRAW\n"); + //fprintf(stderr,"GARRAY_REDRAW\n"); garray_redraw(x); canvas_dirty(x->x_glist, 1); } @@ -624,7 +633,7 @@ void garray_arrayviewlist_fillpage(t_garray *x, t_float page, t_float fTopItem) { - //fprintf(stderr,"garray_fillpage\n"); + //fprintf(stderr,"garray_fillpage\n"); int i, xonset=0, yonset=0, type=0, elemsize=0, topItem; t_float yval; char cmdbuf[200]; @@ -638,13 +647,15 @@ void garray_arrayviewlist_fillpage(t_garray *x, error("error in garray_arrayviewlist_new()"); } - if (page < 0) { + if (page < 0) + { page = 0; sys_vgui("pdtk_array_listview_setpage %s %d\n", x->x_realname->s_name, (int)page); } - else if ((page * ARRAYPAGESIZE) >= a->a_n) { + else if ((page * ARRAYPAGESIZE) >= a->a_n) + { page = (int)(((int)a->a_n - 1)/ (int)ARRAYPAGESIZE); sys_vgui("pdtk_array_listview_setpage %s %d\n", x->x_realname->s_name, @@ -762,16 +773,17 @@ static int array_motion_fatten; /* LATER protect against the template changing or the scalar disappearing probably by attaching a gpointer here ... */ -// this is called when a mouse drag happens inside an array (either scalar or the whole array--this needs to be tested) + /* this is called when a mouse drag happens inside an array (either + scalar or the whole array--this needs to be tested) */ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) { array_motion_xcumulative += dx * array_motion_xperpix; array_motion_ycumulative += dy * array_motion_yperpix; //fprintf(stderr,"array_motion %f %f %f %f\n", array_motion_xcumulative, array_motion_ycumulative, dx, dy); - // used to set up boundaries and update sends accordingly - t_glist *graph = NULL; - if (array_garray != NULL) graph = array_garray->x_glist; + // used to set up boundaries and update sends accordingly + t_glist *graph = NULL; + if (array_garray != NULL) graph = array_garray->x_glist; if (array_motion_xfield) { @@ -821,18 +833,21 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) (t_word *)(((char *)array_motion_wp) + array_motion_elemsize * array_motion_lastx), 1); - // here we block scalar from exceeding the array GOP edges - if (graph) { - if (graph->gl_y1 > graph->gl_y2) { - if (newy > graph->gl_y1) newy = graph->gl_y1; - if (newy < graph->gl_y2) newy = graph->gl_y2; - } - else { - if (newy < graph->gl_y1) newy = graph->gl_y1; - if (newy > graph->gl_y2) newy = graph->gl_y2; - } - } - //fprintf(stderr, "y = %f\n", newy); + // here we block scalar from exceeding the array GOP edges + if (graph) + { + if (graph->gl_y1 > graph->gl_y2) + { + if (newy > graph->gl_y1) newy = graph->gl_y1; + if (newy < graph->gl_y2) newy = graph->gl_y2; + } + else + { + if (newy < graph->gl_y1) newy = graph->gl_y1; + if (newy > graph->gl_y2) newy = graph->gl_y2; + } + } + //fprintf(stderr, "y = %f\n", newy); t_float ydiff = newy - oldy; if (thisx < 0) thisx = 0; else if (thisx >= array_motion_npoints) @@ -851,15 +866,17 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) } array_motion_lastx = thisx; } - //fprintf(stderr, "%f %f\n", graph->gl_y1, graph->gl_y2); + //fprintf(stderr, "%f %f\n", graph->gl_y1, graph->gl_y2); if (array_motion_scalar) scalar_redraw(array_motion_scalar, array_motion_glist); if (array_motion_array) array_redraw(array_motion_array, array_motion_glist); - /* send a bang to the associated send to reflect the change via mouse click/drag */ - if (graph && array_garray->x_send->s_thing) pd_bang(array_garray->x_send->s_thing); + /* send a bang to the associated send to reflect the change + via mouse click/drag */ + if (graph && array_garray->x_send->s_thing) + pd_bang(array_garray->x_send->s_thing); } int scalar_doclick(t_word *data, t_template *template, t_scalar *sc, @@ -875,7 +892,7 @@ static int array_doclick_element(t_array *array, t_glist *glist, t_fielddesc *xfield, t_fielddesc *yfield, t_fielddesc *wfield, int xpix, int ypix, int shift, int alt, int dbl, int doit) { - //fprintf(stderr,"array_doclick_element linewidth%f xloc%f xinc%f yloc%f xpix%d ypix%d doit%d\n", linewidth, xloc, xinc, yloc, xpix, ypix, doit); + //fprintf(stderr,"array_doclick_element linewidth%f xloc%f xinc%f yloc%f xpix%d ypix%d doit%d\n", linewidth, xloc, xinc, yloc, xpix, ypix, doit); t_canvas *elemtemplatecanvas; t_template *elemtemplate; int elemsize, yonset, wonset, xonset, i, incr, hit; @@ -937,16 +954,16 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize, xonset, yonset, wonset, i, xloc, yloc, xinc, xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix); - //fprintf(stderr," array_getcoordinate %d: pxpix1:%f pxpix2:%f pypix:%f pwpix:%f dx:%f dy:%f elemsize:%d yonset:%d wonset:%d xonset:%d xloc:%f yloc:%f xinc:%f\n", i, pxpix1, pxpix2, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, xloc, yloc, xinc); + //fprintf(stderr," array_getcoordinate %d: pxpix1:%f pxpix2:%f pypix:%f pwpix:%f dx:%f dy:%f elemsize:%d yonset:%d wonset:%d xonset:%d xloc:%f yloc:%f xinc:%f\n", i, pxpix1, pxpix2, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, xloc, yloc, xinc); if (pwpix < 4) pwpix = 4; - if (xpix >= (int)pxpix1 && xpix <= (int)pxpix2 && - ((array_joc) || - (ypix >= pypix-pwpix && ypix <= pypix+pwpix))) - { - best = i; - break; - } + if (xpix >= (int)pxpix1 && xpix <= (int)pxpix2 && + ((array_joc) || + (ypix >= pypix-pwpix && ypix <= pypix+pwpix))) + { + best = i; + break; + } /* if (pwpix < 4) pwpix = 4; @@ -969,23 +986,25 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, if (dx + dy < best) best = dx + dy; } - //fprintf(stderr," 1st %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, i);*/ + //fprintf(stderr," 1st %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, i);*/ } - //fprintf(stderr," best = %f\n", best); + //fprintf(stderr," best = %f\n", best); if (best == -1 && (array_joc == 0)) //this is the arbitrary radius away from the actual object's center, originally 8 { - //fprintf(stderr," best > 8\n"); - if (scalarvis != 0) { - //fprintf(stderr," array_doclick_element\n"); + //fprintf(stderr," best > 8\n"); + if (scalarvis != 0) + { + //fprintf(stderr," array_doclick_element\n"); return (array_doclick_element(array, glist, sc, ap, elemtemplatesym, linewidth, xloc, xinc, yloc, xfield, yfield, wfield, xpix, ypix, shift, alt, dbl, doit)); - } - else { - //fprintf(stderr," return 0\n"); - return (0); - } + } + else + { + //fprintf(stderr," return 0\n"); + return (0); + } } //best += 0.001; /* add truncation error margin */ //for (i = 0; i < array->a_n; i += incr) @@ -1007,10 +1026,10 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, dy = 100; } else dy2 = dy3 = 100; - //fprintf(stderr," 2nd %f %f %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, dy2, dy3, elemsize, yonset, wonset, xonset, i); + //fprintf(stderr," 2nd %f %f %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, dy2, dy3, elemsize, yonset, wonset, xonset, i); //if (dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best) //{ - //fprintf(stderr, "dy=%f dy2=%f dy3=%f\n", dy, dy2, dy3); + //fprintf(stderr, "dy=%f dy2=%f dy3=%f\n", dy, dy2, dy3); /* from array-rev */ @@ -1021,22 +1040,23 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, } else hit = dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best; - - /* end array-rev */ - if (dy < dy2 && dy < dy3) { + if (dy < dy2 && dy < dy3) + { array_motion_fatten = 0; - //fprintf(stderr,"A\n"); - } - else if (dy2 < dy3) { + //fprintf(stderr,"A\n"); + } + else if (dy2 < dy3) + { array_motion_fatten = -1; - //fprintf(stderr,"B\n"); - } - else if (!array_joc) { - array_motion_fatten = 1; - //fprintf(stderr,"C\n"); - } + //fprintf(stderr,"B\n"); + } + else if (!array_joc) + { + array_motion_fatten = 1; + //fprintf(stderr,"C\n"); + } if (doit || (glob_lmclick && array_joc)) { char *elem = (char *)array->a_vec; @@ -1055,22 +1075,22 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, (char *)(array->a_vec) + elemsize * (i+1), (array->a_n - 1 - i) * elemsize); //array_resize_and_redraw(array, glist, array->a_n - 1); - garray_resize(array_garray, array->a_n - 1); - canvas_setcursor(glist_getcanvas(glist), 0); + garray_resize(array_garray, array->a_n - 1); + canvas_setcursor(glist_getcanvas(glist), 0); return (0); } else if (shift) { /* add a point (after the clicked-on one) */ - //fprintf(stderr,"add a point\n"); + //fprintf(stderr,"add a point\n"); //array_resize_and_redraw(array, glist, array->a_n + 1); elem = (char *)array->a_vec; memmove(elem + elemsize * (i+1), elem + elemsize * i, (array->a_n - i - 1) * elemsize); i++; - garray_resize(array_garray, array->a_n + 1); - canvas_setcursor(glist_getcanvas(glist), 0); + garray_resize(array_garray, array->a_n + 1); + canvas_setcursor(glist_getcanvas(glist), 0); } if (xonset >= 0) { @@ -1146,9 +1166,10 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, { return (CURSOR_EDITMODE_DISCONNECT); } - else if (shift) { - return (CURSOR_RUNMODE_ADDPOINT); - } + else if (shift) + { + return (CURSOR_RUNMODE_ADDPOINT); + } else return (array_motion_fatten ? CURSOR_RUNMODE_THICKEN : CURSOR_RUNMODE_CLICKME); //} @@ -1194,7 +1215,7 @@ static void array_getrect(t_array *array, t_glist *glist, y2 = pypix + pwpix; } } - //fprintf(stderr,"array_getrect %f %f %f %f\n", x1, y1, x2, y2); + //fprintf(stderr,"array_getrect %f %f %f %f\n", x1, y1, x2, y2); *xp1 = x1; *yp1 = y1; *xp2 = x2; @@ -1218,8 +1239,9 @@ static void garray_displace(t_gobj *z, t_glist *glist, int dx, int dy) static void garray_select(t_gobj *z, t_glist *glist, int state) { - t_garray *x = (t_garray *)z; - sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n", glist_getcanvas(glist), x->x_glist, state); + t_garray *x = (t_garray *)z; + sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n", + glist_getcanvas(glist), x->x_glist, state); /* fill in later */ } @@ -1234,19 +1256,19 @@ static void garray_delete(t_gobj *z, t_glist *glist) static void garray_vis(t_gobj *z, t_glist *glist, int vis) { - //fprintf(stderr,"garray_vis %d\n", vis); + //fprintf(stderr,"garray_vis %d\n", vis); t_garray *x = (t_garray *)z; - gobj_vis(&x->x_scalar->sc_gobj, glist, vis); - //if (((t_glist *)z)->gl_isgraph) - // fprintf(stderr,"garray_vis am_graph\n"); + gobj_vis(&x->x_scalar->sc_gobj, glist, vis); + //if (((t_glist *)z)->gl_isgraph) + // fprintf(stderr,"garray_vis am_graph\n"); } static int garray_click(t_gobj *z, t_glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { - //fprintf(stderr,"garray_click\n"); + //fprintf(stderr,"garray_click\n"); t_garray *x = (t_garray *)z; - array_garray = x; + array_garray = x; return (gobj_click(&x->x_scalar->sc_gobj, glist, xpix, ypix, shift, alt, dbl, doit)); } @@ -1309,7 +1331,7 @@ t_widgetbehavior garray_widgetbehavior = garray_delete, garray_vis, garray_click, - NULL, + NULL, }; /* ----------------------- public functions -------------------- */ @@ -1321,37 +1343,41 @@ void garray_usedindsp(t_garray *x) static void garray_doredraw(t_gobj *client, t_glist *glist) { - //fprintf(stderr,"garray_doredraw\n"); + //fprintf(stderr,"garray_doredraw\n"); t_garray *x = (t_garray *)client; if (glist_isvisible(x->x_glist)) { garray_vis(&x->x_gobj, x->x_glist, 0); garray_vis(&x->x_gobj, x->x_glist, 1); } - /* we do this to reposition objects back where they belong */ - if (!glist_istoplevel(glist)) { - canvas_restore_original_position(glist_getcanvas(glist), (t_gobj *)glist, 0, -1); - } - if (glist_isselected(glist_getcanvas(glist), (t_gobj *)glist)) { - //fprintf(stderr,"garray_doredraw isselected\n"); - sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n", glist_getcanvas(glist), glist, 1); - } + /* we do this to reposition objects back where they belong */ + if (!glist_istoplevel(glist)) + { + canvas_restore_original_position(glist_getcanvas(glist), + (t_gobj *)glist, 0, -1); + } + if (glist_isselected(glist_getcanvas(glist), (t_gobj *)glist)) + { + //fprintf(stderr,"garray_doredraw isselected\n"); + sys_vgui("pdtk_select_all_gop_widgets .x%lx %lx %d\n", + glist_getcanvas(glist), glist, 1); + } } void garray_redraw(t_garray *x) { - //fprintf(stderr,"garray_redraw\n"); + //fprintf(stderr,"garray_redraw\n"); if (glist_isvisible(x->x_glist)) sys_queuegui(&x->x_gobj, x->x_glist, garray_doredraw); - //garray_doredraw(&x->x_gobj, x->x_glist); + //garray_doredraw(&x->x_gobj, x->x_glist); /* jsarlo { */ /* this happens in garray_vis() when array is visible for performance reasons */ else { - //fprintf(stderr,"garray_redraw_listviewing\n"); - if (x->x_listviewing) - sys_vgui("pdtk_array_listview_fillpage %s\n", + //fprintf(stderr,"garray_redraw_listviewing\n"); + if (x->x_listviewing) + sys_vgui("pdtk_array_listview_fillpage %s\n", x->x_realname->s_name); } /* } jsarlo */ @@ -1632,17 +1658,17 @@ static void garray_rename(t_garray *x, t_symbol *s) /* } jsarlo */ pd_unbind(&x->x_gobj.g_pd, x->x_realname); - x->x_name = s; - x->x_realname = canvas_realizedollar(x->x_glist, x->x_name); + x->x_name = s; + x->x_realname = canvas_realizedollar(x->x_glist, x->x_name); pd_bind(&x->x_gobj.g_pd, x->x_realname); - char buf[MAXPDSTRING]; - sprintf(buf, "%s_changed", x->x_realname->s_name); - x->x_send = gensym(buf); + char buf[MAXPDSTRING]; + sprintf(buf, "%s_changed", x->x_realname->s_name); + x->x_send = gensym(buf); //garray_redraw(x); - glist_redraw(x->x_glist); + glist_redraw(x->x_glist); } static void garray_read(t_garray *x, t_symbol *filename) diff --git a/pd/src/g_bang.c b/pd/src/g_bang.c index b32be38bc7f6faa81fd7a1a72388a07d080ca6d5..2a403a0d403a2c9ae3d2f8be9ff4614de1e3ee5a 100644 --- a/pd/src/g_bang.c +++ b/pd/src/g_bang.c @@ -37,15 +37,17 @@ static t_class *bng_class; void bng_draw_update(t_gobj *xgobj, t_glist *glist) { - t_bng *x = (t_bng *)xgobj; - if (x->x_gui.x_changed != x->x_flashed) { - if(glist_isvisible(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); - } - x->x_gui.x_changed = x->x_flashed; - } + t_bng *x = (t_bng *)xgobj; + if (x->x_gui.x_changed != x->x_flashed) + { + if(glist_isvisible(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); + } + x->x_gui.x_changed = x->x_flashed; + } } void bng_draw_new(t_bng *x, t_glist *glist) @@ -54,45 +56,55 @@ void bng_draw_new(t_bng *x, t_glist *glist) int ypos=text_ypix(&x->x_gui.x_obj, glist); 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 %lxBNG text iemgui border %s}\n", - canvas, xpos, ypos, - xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, - x->x_gui.x_bcol, x, x, nlet_tag); - t_float cr = (x->x_gui.x_w-2)/2.0; - t_float cx = xpos+cr+1.5; - t_float cy = ypos+cr+1.5; - sys_vgui(".x%lx.c create circle %f %f -r %f -stroke $pd_colors(iemgui_border) -fill #%6.6x -tags {%lxBUT %lxBNG text iemgui border %s}\n", - canvas, cx, cy, cr, - x->x_flashed?x->x_gui.x_fcol: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 %lxBNG text iemgui %s}\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 {%lxBNG%so%d %so%d %lxBNG outlet iemgui %s}\n", - canvas, xpos, - ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h, 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 {%lxBNG%si%d %si%d %lxBNG inlet iemgui %s}\n", - canvas, xpos, ypos, - xpos + IOWIDTH, 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 %lxBNG text iemgui border %s}\n", + canvas, xpos, ypos, xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, + x->x_gui.x_bcol, x, x, nlet_tag); + t_float cr = (x->x_gui.x_w-2)/2.0; + t_float cx = xpos+cr+1.5; + t_float cy = ypos+cr+1.5; + sys_vgui(".x%lx.c create circle %f %f -r %f " + "-stroke $pd_colors(iemgui_border) -fill #%6.6x " + "-tags {%lxBUT %lxBNG text iemgui border %s}\n", + canvas, cx, cy, cr, x->x_flashed?x->x_gui.x_fcol: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 %lxBNG text iemgui %s}\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 {%lxBNG%so%d %so%d %lxBNG outlet iemgui %s}\n", + canvas, xpos, + ypos + x->x_gui.x_h-1, xpos + IOWIDTH, + ypos + x->x_gui.x_h, 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 {%lxBNG%si%d %si%d %lxBNG inlet iemgui %s}\n", + canvas, xpos, ypos, + xpos + IOWIDTH, ypos+1, x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + } +//} } void bng_draw_move(t_bng *x, t_glist *glist) @@ -101,52 +113,58 @@ void bng_draw_move(t_bng *x, t_glist *glist) int ypos=text_ypix(&x->x_gui.x_obj, glist); 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); - t_float cr = (x->x_gui.x_w-2)/2.0; - t_float cx = xpos+cr+1.5; - t_float cy = ypos+cr+1.5; - /*sys_vgui(".x%lx.c create circle %d %d -r %d -stroke #%6.6x -tags {%lxBUT %lxBNG %lx text iemgui}\n", - canvas, cx, cy, cr,*/ - sys_vgui(".x%lx.c coords %lxBUT %f %f\n", - canvas, x, cx, cy); - sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n", canvas, x, - x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr); - 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 %lxBNG%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xpos, - ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxBNG%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xpos, ypos, - xpos + IOWIDTH, ypos+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) - bng_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); + t_float cr = (x->x_gui.x_w-2)/2.0; + t_float cx = xpos+cr+1.5; + t_float cy = ypos+cr+1.5; + + /*sys_vgui(".x%lx.c create circle %d %d -r %d " + "-stroke #%6.6x " + "-tags {%lxBUT %lxBNG %lx text iemgui}\n", + canvas, cx, cy, cr,*/ + + sys_vgui(".x%lx.c coords %lxBUT %f %f\n", + canvas, x, cx, cy); + sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x -r %f\n", + canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, cr); + 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 %lxBNG%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, + ypos + x->x_gui.x_h-1, xpos + IOWIDTH, + ypos + x->x_gui.x_h); + if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c coords %lxBNG%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xpos, ypos, + xpos + IOWIDTH, ypos+1); + /* redraw scale handle rectangle if selected */ + if (x->x_gui.x_fsf.x_selected) + bng_draw_select(x, x->x_gui.x_glist); + } } 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); - } + 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); + } /* sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x); sys_vgui(".x%lx.c delete %lxBUT\n", canvas, x); @@ -162,26 +180,29 @@ void bng_draw_config(t_bng* 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); - */ + /* + 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", + 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", + 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 %lxBASE -fill #%6.6x\n .x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", - canvas, x, x->x_gui.x_bcol, canvas, x, - x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); + sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n " + ".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", + canvas, x, x->x_gui.x_bcol, canvas, x, + x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); /*sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x, x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);*/ } @@ -192,318 +213,372 @@ void bng_draw_io(t_bng* 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 {%lxBNG%so%d %so%d %lxBNG outlet iemgui %s}\n", - canvas, xpos, - ypos + x->x_gui.x_h-1, xpos + IOWIDTH, - ypos + x->x_gui.x_h, 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 %lxBNG%so%d\n", canvas, x, nlet_tag, 0); - if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxBNG%si%d %si%d %lxBNG inlet iemgui %s}\n", - canvas, xpos, ypos, - xpos + IOWIDTH, 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 %lxBNG%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 {%lxBNG%so%d %so%d %lxBNG outlet iemgui %s}\n", + canvas, xpos, + ypos + x->x_gui.x_h-1, xpos + IOWIDTH, + ypos + x->x_gui.x_h, 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 %lxBNG%so%d\n", canvas, x, nlet_tag, 0); + if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && + !x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxBNG%si%d %si%d %lxBNG inlet iemgui %s}\n", + canvas, xpos, ypos, xpos + IOWIDTH, 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 %lxBNG%si%d\n", canvas, x, nlet_tag, 0); + } } void bng_draw_select(t_bng* 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 %lxBUT -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 %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; - - 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; - } - } - - sys_vgui(".x%lx.c addtag selected withtag %lxBNG\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 %lxBUT -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 %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; - } - //} -} - -static void bng__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) -{ - - t_bng *x = (t_bng *)(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; - } + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); - int newstate = (int)f; - if (sh->h_dragon && newstate == 0 && sh->h_scale) + //if (glist_isvisible(canvas)) { + + if(x->x_gui.x_fsf.x_selected) { - /* 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) { - - if (sh->h_dragx > sh->h_dragy) - sh->h_dragx = sh->h_dragy; - else sh->h_dragy = sh->h_dragx; - - 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); - bng_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); - } + /* 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 %lxBUT " + "-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 %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; + + 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; + } + } + sys_vgui(".x%lx.c addtag selected withtag %lxBNG\n", canvas, x); } - else if (!sh->h_dragon && newstate && sh->h_scale) + else { - /* 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 + x->x_gui.x_h, sh->h_outlinetag); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + sys_vgui(".x%lx.c itemconfigure %lxBASE -stroke %s\n", + canvas, x, IEM_GUI_COLOR_NORMAL); + sys_vgui(".x%lx.c itemconfigure %lxBUT -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 %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; } - else 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_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); - } +static void bng__clickhook(t_scalehandle *sh, t_floatarg f, + t_floatarg xxx, t_floatarg yyy) +{ - int properties = gfxstub_haveproperties((void *)x); + t_bng *x = (t_bng *)(sh->h_master); - 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 (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 (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - bng_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); - } + 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) + { + if (sh->h_dragx > sh->h_dragy) + sh->h_dragx = sh->h_dragy; + else sh->h_dragy = sh->h_dragx; + + 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); + bng_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 + 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) + { + /* 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_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); + } + + 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); + bng_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 bng__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { 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; - - if (dx > dy) { - dx = dy; - x->x_gui.scale_offset_x = x->x_gui.scale_offset_y; - } - else { - dy = dx; - x->x_gui.scale_offset_y = x->x_gui.scale_offset_x; - } - - 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_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, newy); - } - 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_bng *x = (t_bng *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + + if (dx > dy) + { + dx = dy; + x->x_gui.scale_offset_x = x->x_gui.scale_offset_y; + } + else + { + dy = dx; + x->x_gui.scale_offset_y = x->x_gui.scale_offset_x; + } + + 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_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, newy); + } + 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 bng_draw(t_bng *x, t_glist *glist, int mode) { if(mode == IEM_GUI_DRAW_MODE_UPDATE) - sys_queuegui((t_gobj*)x, x->x_gui.x_glist, bng_draw_update); + sys_queuegui((t_gobj*)x, x->x_gui.x_glist, bng_draw_update); //bng_draw_update(x, glist); else if(mode == IEM_GUI_DRAW_MODE_MOVE) bng_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { bng_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) bng_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -516,7 +591,8 @@ void bng_draw(t_bng *x, t_glist *glist, int mode) /* ------------------------ bng widgetbehaviour----------------------------- */ -static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) +static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, + int *xp2, int *yp2) { t_bng *x = (t_bng *)z; @@ -525,7 +601,7 @@ static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h; - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void bng_save(t_gobj *z, t_binbuf *b) @@ -615,7 +691,8 @@ static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ clock_delay(x->x_clock_lck, 2); } outlet_bang(x->x_gui.x_obj.ob_outlet); - if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out) + if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && + x->x_gui.x_fsf.x_put_in2out) pd_bang(x->x_gui.x_snd->s_thing); } @@ -651,7 +728,7 @@ static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/ static void bng_dialog(t_bng *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 a = (int)atom_getintarg(0, argc, argv); @@ -666,28 +743,33 @@ static void bng_dialog(t_bng *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) { - bng_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + bng_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 bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { bng_set(x); bng_bout2(x); } -static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) +static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, + int shift, int alt, int dbl, int doit) { if(doit) - bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); + bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, + (t_floatarg)shift, 0, (t_floatarg)alt); return (1); } @@ -825,10 +907,15 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) x->x_gui.x_fsf.x_snd_able = 0; 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_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); @@ -849,7 +936,7 @@ static void *bng_new(t_symbol *s, int argc, t_atom *argv) x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck); outlet_new(&x->x_gui.x_obj, &s_bang); - /* scale handle init */ + /* scale handle init */ t_scalehandle *sh; char buf[64]; x->x_gui.x_handle = pd_new(scalehandle_class); @@ -859,28 +946,28 @@ static void *bng_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); } @@ -894,19 +981,21 @@ static void bng_ff(t_bng *x) clock_free(x->x_clock_hld); 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_bang_setup(void) @@ -925,23 +1014,30 @@ void g_bang_setup(void) A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0); class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0); + class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), + A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0); + class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), + A_GIMME, 0); + class_addmethod(bng_class, (t_method)bng_color, gensym("color"), + A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0); - class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0); - class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0); + class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), + A_DEFSYM, 0); + class_addmethod(bng_class, (t_method)bng_label, gensym("label"), + A_DEFSYM, 0); + class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), + A_GIMME, 0); + class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), + A_GIMME, 0); class_addmethod(bng_class, (t_method)bng_init, gensym("init"), 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)bng__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)bng__motionhook, - gensym("_motion"), A_FLOAT, A_FLOAT, 0); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); bng_widgetbehavior.w_getrectfn = bng_getrect; bng_widgetbehavior.w_displacefn = iemgui_displace;