diff --git a/pd/src/d_delay.c b/pd/src/d_delay.c index 05511c158e39b8c6670d50eab5b257b39ea9c922..ee621fbde2ed76901ee48aa1ce024c9dda7ef8ad 100644 --- a/pd/src/d_delay.c +++ b/pd/src/d_delay.c @@ -62,7 +62,7 @@ static void *sigdelwrite_new(t_symbol *s, t_floatarg msec) if (!*s->s_name) s = gensym("delwrite~"); pd_bind(&x->x_obj.ob_pd, s); x->x_sym = s; - if (msec == 0) msec = 1000; + if (msec == 0) msec = 1000; nsamps = msec * sys_getsr() * (t_float)(0.001f); if (nsamps < 1) nsamps = 1; nsamps += ((- nsamps) & (SAMPBLK - 1)); diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 83391e2960a3849d9ed63609af76a179bfacced9..67cd1ed73525320588ac05f671e807e6820f370c 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -481,16 +481,16 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, if (!gop_redraw) { //fprintf(stderr,"ignoring label\n"); - return; + return; } t_float width_multiplier; - int label_length; + 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_fontsize; //seems tk does its own thing when rendering int actual_height; if (x->gl_isgraph && !glist_istoplevel(x)) @@ -520,7 +520,7 @@ void iemgui_label_getrect(t_iemgui x_gui, t_glist *x, actual_fontsize = x_gui.x_fontsize; } actual_height = actual_fontsize; - //exceptions + //exceptions if (x_gui.x_fsf.x_font_style == 0 && (actual_fontsize == 8 || actual_fontsize == 13 || actual_fontsize % 10 == 1 || actual_fontsize % 10 == 6 || @@ -618,7 +618,7 @@ void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) 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 @@ -654,7 +654,7 @@ void iemgui_shouldvis(void *x, t_iemgui *iemgui, int mode) 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) diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index 6b13155eaf66246556d96df0e194deb0cb7c450b..f8cb173209708720bfda6f8d3f095a2928fdf8db 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -126,8 +126,8 @@ #define SCALEHANDLE_WIDTH 5 #define SCALEHANDLE_HEIGHT 5 -#define LABELHANDLE_WIDTH 5 -#define LABELHANDLE_HEIGHT 5 +#define LABELHANDLE_WIDTH 5 +#define LABELHANDLE_HEIGHT 5 typedef struct _iem_fstyle_flags { @@ -171,7 +171,7 @@ typedef struct _scalehandle t_pd h_pd; t_gobj *h_master; t_symbol *h_bindsym; - int h_scale; + int h_scale; char h_pathname[64]; char h_outlinetag[64]; int h_dragon; @@ -206,15 +206,15 @@ typedef struct _iemgui t_symbol *x_lab_unexpanded; int x_binbufindex; /* where in binbuf to find these */ int x_labelbindex; /* where in binbuf to find label */ - t_pd *x_handle; - int scale_offset_x; - int scale_offset_y; - int scale_vis; - t_pd *x_lhandle; - int label_offset_x; - int label_offset_y; - int label_vis; - int x_vis; /* is the object drawn? */ + t_pd *x_handle; + int scale_offset_x; + int scale_offset_y; + int scale_vis; + t_pd *x_lhandle; + int label_offset_x; + int label_offset_y; + int label_vis; + int x_vis; /* is the object drawn? */ int x_changed; /* has the value changed so that we need to do graphic update */ } t_iemgui; @@ -322,11 +322,11 @@ typedef struct _my_numbox int x_lin0_log1; char x_buf[IEMGUI_MAX_NUM_LEN]; int x_numwidth; - int x_scalewidth; /* temporary value when resizing */ - int x_scaleheight; /* temporary value when resizing */ - int x_tmpfontsize; /* temporary value when resizing */ + int x_scalewidth; /* temporary value when resizing */ + int x_scaleheight; /* temporary value when resizing */ + int x_tmpfontsize; /* temporary value when resizing */ int x_log_height; - int x_hide_frame; /* 0 default, 1 just arrow, 2, just frame, 3 both */ + int x_hide_frame; /* 0 default, 1 just arrow, 2, just frame, 3 both */ } t_my_numbox; typedef struct _vdial diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index ccc6ac41928590ec704ce54063ef4a1171ed6850..05eccc20f26d1217a626f5545c8939907d90ff43 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -44,7 +44,7 @@ static int canvas_isgroup(t_canvas *x) if (!b) { bug("canvas_isgroup"); - return 0; + return 0; } t_atom *argv = binbuf_getvec(x->gl_obj.te_binbuf); if (argv[0].a_type == A_SYMBOL && @@ -64,27 +64,28 @@ extern t_canvas *canvas_templatecanvas_forgroup(t_canvas *c); void glist_add(t_glist *x, t_gobj *y) { - //fprintf(stderr,"glist_add %lx %d\n", (t_int)x, (x->gl_editor ? 1 : 0)); - t_object *ob; + //fprintf(stderr,"glist_add %lx %d\n", (t_int)x, (x->gl_editor ? 1 : 0)); + t_object *ob; y->g_next = 0; - int index = 0; + int index = 0; if (!x->gl_list) x->gl_list = y; else { t_gobj *y2; for (y2 = x->gl_list; y2->g_next; y2 = y2->g_next) - index++; + index++; y2->g_next = y; } - if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) { + if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) + { rtext_new(x, ob); - //let's now set up create undo - //glist_select(x, y); - //canvas_setundo(x, canvas_undo_create, canvas_undo_set_create(x, index), - // "create"); - //glist_noselect(x); - } + //let's now set up create undo + //glist_select(x, y); + //canvas_setundo(x, canvas_undo_create, + // canvas_undo_set_create(x, index), "create"); + //glist_noselect(x); + } if (x->gl_editor && x->gl_isgraph && !x->gl_goprect && pd_checkobject(&y->g_pd)) { @@ -102,9 +103,9 @@ void glist_add(t_glist *x, t_gobj *y) canvas_isgroup((t_canvas *)y)) { t_canvas *templatecanvas = - canvas_templatecanvas_forgroup((t_canvas *)y); - t_template *tmpl = canvas_findtemplate(templatecanvas); - canvas_redrawallfortemplate(tmpl, 0); + canvas_templatecanvas_forgroup((t_canvas *)y); + t_template *tmpl = canvas_findtemplate(templatecanvas); + canvas_redrawallfortemplate(tmpl, 0); } } @@ -120,10 +121,12 @@ int canvas_setdeleting(t_canvas *x, int flag) /* check if canvas has an array and return 1, otherwise return 0 this is used to prevent creation of new objects in an array window */ -int canvas_hasarray(t_canvas *x) { +int canvas_hasarray(t_canvas *x) +{ t_gobj *g = x->gl_list; int hasarray = 0; - while (g) { + while (g) + { if (pd_class(&g->g_pd) == garray_class) hasarray = 1; g = g->g_next; } @@ -140,100 +143,106 @@ extern t_rtext *glist_tryfindrtext(t_glist *gl, t_text *who); /* delete an object from a glist and free it */ void glist_delete(t_glist *x, t_gobj *y) { - //fprintf(stderr,"glist_delete?\n"); - if (x->gl_list) { - //fprintf(stderr,"glist_delete YES\n"); - t_gobj *g; - t_object *ob; + //fprintf(stderr,"glist_delete?\n"); + if (x->gl_list) + { + //fprintf(stderr,"glist_delete YES\n"); + t_gobj *g; + t_object *ob; t_template *tmpl; - t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp")); - t_canvas *canvas = glist_getcanvas(x); - int drawcommand = class_isdrawcommand(y->g_pd); - int wasdeleting; - t_rtext *rt = NULL; - int late_rtext_free = 0; - - if (pd_class(&y->g_pd) == canvas_class) { - /* JMZ: send a closebang to the canvas */ - canvas_closebang((t_canvas *)y); - } - - wasdeleting = canvas_setdeleting(canvas, 1); - if (x->gl_editor) - { - if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0; - if (glist_isselected(x, y)) glist_deselect(x, y); - - /* HACK -- we had phantom outlets not getting erased on the - screen because the canvas_setdeleting() mechanism is too - crude. LATER carefully set up rules for when the rtexts - should exist, so that they stay around until all the - steps of becoming invisible are done. In the meantime, just - zap the inlets and outlets here... */ - if (pd_class(&y->g_pd) == canvas_class) - { - t_glist *gl = (t_glist *)y; - if (gl->gl_isgraph) - { - char tag[80]; - //sprintf(tag, "graph%lx", (t_int)gl); - //t_glist *yy = (t_glist *)y; - sprintf(tag, "%s", rtext_gettag(glist_findrtext(x, &gl->gl_obj))); - glist_eraseiofor(x, &gl->gl_obj, tag); - text_eraseborder(&gl->gl_obj, x, - rtext_gettag(glist_findrtext(x, &gl->gl_obj))); - } - else - { - text_eraseborder(&gl->gl_obj, x, - rtext_gettag(glist_findrtext(x, &gl->gl_obj))); - } - } - } - /* if we're a drawing command, erase all scalars that + t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp")); + t_canvas *canvas = glist_getcanvas(x); + int drawcommand = class_isdrawcommand(y->g_pd); + int wasdeleting; + t_rtext *rt = NULL; + int late_rtext_free = 0; + + if (pd_class(&y->g_pd) == canvas_class) + { + /* JMZ: send a closebang to the canvas */ + canvas_closebang((t_canvas *)y); + } + + wasdeleting = canvas_setdeleting(canvas, 1); + if (x->gl_editor) + { + if (x->gl_editor->e_grab == y) x->gl_editor->e_grab = 0; + if (glist_isselected(x, y)) glist_deselect(x, y); + + /* HACK -- we had phantom outlets not getting erased on the + screen because the canvas_setdeleting() mechanism is too + crude. LATER carefully set up rules for when the rtexts + should exist, so that they stay around until all the + steps of becoming invisible are done. In the meantime, just + zap the inlets and outlets here... */ + if (pd_class(&y->g_pd) == canvas_class) + { + t_glist *gl = (t_glist *)y; + if (gl->gl_isgraph) + { + char tag[80]; + //sprintf(tag, "graph%lx", (t_int)gl); + //t_glist *yy = (t_glist *)y; + sprintf(tag, "%s", + rtext_gettag(glist_findrtext(x, &gl->gl_obj))); + glist_eraseiofor(x, &gl->gl_obj, tag); + text_eraseborder(&gl->gl_obj, x, + rtext_gettag(glist_findrtext(x, &gl->gl_obj))); + } + else + { + text_eraseborder(&gl->gl_obj, x, + rtext_gettag(glist_findrtext(x, &gl->gl_obj))); + } + } + } + /* if we're a drawing command, erase all scalars that belong to our template, before deleting - it; we'll redraw them once it's deleted below. */ - if (drawcommand) + it; we'll redraw them once it's deleted below. */ + if (drawcommand) { tmpl = template_findbydrawcommand(y); canvas_redrawallfortemplate(tmpl, 2); } - if (glist_isvisible(canvas)) - gobj_vis(y, x, 0); - if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) { - //rtext_new(x, ob); - rt = glist_findrtext(x, ob); - if (rt) - late_rtext_free = 1; - } - if (x->gl_list == y) { - if (y->g_next) - x->gl_list = y->g_next; - else - x->gl_list = NULL; - } - else for (g = x->gl_list; g; g = g->g_next) - { - if (g->g_next == y) - { - if (y->g_next) - g->g_next = y->g_next; - else g->g_next = NULL; - break; - } - } - gobj_delete(y, x); - pd_free(&y->g_pd); - if (chkdsp) canvas_update_dsp(); - if (drawcommand) + if (glist_isvisible(canvas)) + gobj_vis(y, x, 0); + if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) + { + //rtext_new(x, ob); + rt = glist_findrtext(x, ob); + if (rt) + late_rtext_free = 1; + } + if (x->gl_list == y) + { + if (y->g_next) + x->gl_list = y->g_next; + else + x->gl_list = NULL; + } + else for (g = x->gl_list; g; g = g->g_next) + { + if (g->g_next == y) + { + if (y->g_next) + g->g_next = y->g_next; + else g->g_next = NULL; + break; + } + } + gobj_delete(y, x); + pd_free(&y->g_pd); + if (chkdsp) canvas_update_dsp(); + if (drawcommand) canvas_redrawallfortemplate(tmpl, 1); - canvas_setdeleting(canvas, wasdeleting); - x->gl_valid = ++glist_valid; - if (late_rtext_free) { - //fprintf(stderr,"glist_delete late_rtext_free\n"); - rtext_free(rt); - } - } + canvas_setdeleting(canvas, wasdeleting); + x->gl_valid = ++glist_valid; + if (late_rtext_free) + { + //fprintf(stderr,"glist_delete late_rtext_free\n"); + rtext_free(rt); + } + } } /* remove every object from a glist. Experimental. */ @@ -273,7 +282,7 @@ void glist_retext(t_glist *glist, t_text *y) void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_glistkeyfn keyfn, int xpos, int ypos) { - //fprintf(stderr,"glist_grab\n"); + //fprintf(stderr,"glist_grab\n"); t_glist *x2 = glist_getcanvas(x); if (motionfn) x2->gl_editor->e_onmotion = MA_PASSOUT; @@ -287,12 +296,13 @@ void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn, t_canvas *glist_getcanvas(t_glist *x) { - //fprintf(stderr,"glist_getcanvas\n"); + //fprintf(stderr,"glist_getcanvas\n"); while (x->gl_owner && !x->gl_havewindow && x->gl_isgraph && - gobj_shouldvis(&x->gl_gobj, x->gl_owner)) { + gobj_shouldvis(&x->gl_gobj, x->gl_owner)) + { x = x->gl_owner; - //fprintf(stderr,"+\n"); - } + //fprintf(stderr,"+\n"); + } return((t_canvas *)x); } @@ -388,23 +398,25 @@ void glist_sort(t_glist *x) void glist_cleanup(t_glist *x) { - //fprintf(stderr,"glist_cleanup =============\n"); + //fprintf(stderr,"glist_cleanup =============\n"); freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel))); freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel))); - if (x->x_handle) { - pd_unbind(x->x_handle, ((t_scalehandle *)x->x_handle)->h_bindsym); - pd_free(x->x_handle); - } - if (x->x_mhandle) { - pd_unbind(x->x_mhandle, ((t_scalehandle *)x->x_mhandle)->h_bindsym); - pd_free(x->x_mhandle); - } + if (x->x_handle) + { + pd_unbind(x->x_handle, ((t_scalehandle *)x->x_handle)->h_bindsym); + pd_free(x->x_handle); + } + if (x->x_mhandle) + { + pd_unbind(x->x_mhandle, ((t_scalehandle *)x->x_mhandle)->h_bindsym); + pd_free(x->x_mhandle); + } gstub_cutoff(x->gl_stub); } void glist_free(t_glist *x) { - //fprintf(stderr,"glist_free =============\n"); + //fprintf(stderr,"glist_free =============\n"); glist_cleanup(x); freebytes(x, sizeof(*x)); } @@ -414,7 +426,7 @@ void glist_free(t_glist *x) t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s) { - //fprintf(stderr,"canvas_addinlet %d %lx %d\n", x->gl_loading, x->gl_owner, glist_isvisible(x->gl_owner)); + //fprintf(stderr,"canvas_addinlet %d %lx %d\n", x->gl_loading, x->gl_owner, glist_isvisible(x->gl_owner)); t_inlet *ip = inlet_new(&x->gl_obj, who, s, 0); if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) { @@ -480,21 +492,31 @@ void canvas_resortinlets(t_canvas *x) obj_moveinletfirst(&x->gl_obj, ip); } freebytes(vec, ninlets * sizeof(*vec)); - if (x->gl_owner && glist_isvisible(x->gl_owner) && glist_isvisible(x) && !x->gl_owner->gl_loading && !x->gl_loading) { + if (x->gl_owner && + glist_isvisible(x->gl_owner) && glist_isvisible(x) && + !x->gl_owner->gl_loading && !x->gl_loading) + { canvas_fixlinesfor(x->gl_owner, &x->gl_obj); - //fprintf(stderr,"good place to fix redrawing of inlets .x%lx owner=.x%lx %d (parent)%d\n", x, x->gl_owner, x->gl_loading, x->gl_owner->gl_loading); -/* t_object *ob = pd_checkobject(&y->g_pd); - t_rtext *rt = glist_findrtext(x->gl_owner, (t_text *)&ob->ob_g); - for (i = 0; i < ninlets; i++) { + //fprintf(stderr,"good place to fix redrawing of inlets " + // ".x%lx owner=.x%lx %d (parent)%d\n", + // x, x->gl_owner, x->gl_loading, x->gl_owner->gl_loading); + + /* + t_object *ob = pd_checkobject(&y->g_pd); + t_rtext *rt = glist_findrtext(x->gl_owner, (t_text *)&ob->ob_g); + for (i = 0; i < ninlets; i++) + { sys_vgui(".x%x.c itemconfigure %si%d -fill %s -width 1\n", - x, rtext_gettag(rt), i, - (obj_issignalinlet(ob, i) ? "$signal_nlet" : "$pd_colors_control_nlet)")); - } -*/ - //glist_redraw(x); - graph_vis(&x->gl_gobj, x->gl_owner, 0); - graph_vis(&x->gl_gobj, x->gl_owner, 1); - } + x, rtext_gettag(rt), i, + (obj_issignalinlet(ob, i) ? + "$signal_nlet" : "$pd_colors_control_nlet)")); + } + */ + + //glist_redraw(x); + graph_vis(&x->gl_gobj, x->gl_owner, 0); + graph_vis(&x->gl_gobj, x->gl_owner, 1); + } } t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) @@ -566,14 +588,17 @@ void canvas_resortoutlets(t_canvas *x) obj_moveoutletfirst(&x->gl_obj, ip); } freebytes(vec, noutlets * sizeof(*vec)); - if (x->gl_owner && glist_isvisible(x->gl_owner) && glist_isvisible(x) && !x->gl_owner->gl_loading && !x->gl_loading) { + if (x->gl_owner && + glist_isvisible(x->gl_owner) && glist_isvisible(x) && + !x->gl_owner->gl_loading && !x->gl_loading) + { canvas_fixlinesfor(x->gl_owner, &x->gl_obj); - //fprintf(stderr,"good place to fix redrawing of outlets\n"); - //fprintf(stderr,"found it\n"); - //glist_redraw(x); + //fprintf(stderr,"good place to fix redrawing of outlets\n"); + //fprintf(stderr,"found it\n"); + //glist_redraw(x); graph_vis(&x->gl_gobj, x->gl_owner, 0); graph_vis(&x->gl_gobj, x->gl_owner, 1); - } + } } /* ----------calculating coordinates and controlling appearance --------- */ @@ -802,14 +827,14 @@ void glist_redraw(t_glist *x) if (x->gl_goprect) { //post("draw it"); - /* update gop rect size on toplevel in case font has - changed and we are showing text */ - /*if (!x->gl_hidetext) { - int x1, y1, x2, y2; - graph_getrect((t_gobj *)x, x, &x1, &y1, &x2, &y2); - if (x2-x1 > x->gl_pixwidth) x->gl_pixwidth = x2-x1; - if (y2-y1 > x->gl_pixheight) x->gl_pixheight = y2-y1; - }*/ + /* update gop rect size on toplevel in case font has + changed and we are showing text */ + /*if (!x->gl_hidetext) { + int x1, y1, x2, y2; + graph_getrect((t_gobj *)x, x, &x1, &y1, &x2, &y2); + if (x2-x1 > x->gl_pixwidth) x->gl_pixwidth = x2-x1; + if (y2-y1 > x->gl_pixheight) x->gl_pixheight = y2-y1; + }*/ canvas_drawredrect(x, 1); } } @@ -831,9 +856,13 @@ int garray_getname(t_garray *x, t_symbol **namep); static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) { t_glist *x = (t_glist *)gr; - //fprintf(stderr,"graph vis canvas=%lx gobj=%lx %d\n", (t_int)parent_glist, (t_int)gr, vis); - //fprintf(stderr,"graph_vis gr=.x%lx parent_glist=.x%lx glist_getcanvas(x->gl_owner)=.x%lx vis=%d\n", (t_int)gr, (t_int)parent_glist, (t_int)glist_getcanvas(x->gl_owner), vis); - char tag[50]; + //fprintf(stderr,"graph vis canvas=%lx gobj=%lx %d\n", + // (t_int)parent_glist, (t_int)gr, vis); + //fprintf(stderr, "graph_vis gr=.x%lx parent_glist=.x%lx " + // "glist_getcanvas(x->gl_owner)=.x%lx vis=%d\n", + // (t_int)gr, (t_int)parent_glist, + // (t_int)glist_getcanvas(x->gl_owner), vis); + char tag[50]; t_gobj *g; int x1, y1, x2, y2; /* ordinary subpatches: just act like a text object */ @@ -843,45 +872,47 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) return; } - // weird exception - //int exception = 0; - //t_canvas* tgt = glist_getcanvas(x->gl_owner); - //if (parent_glist->gl_owner && !parent_glist->gl_mapped && - // parent_glist->gl_owner->gl_mapped) { - // tgt = parent_glist; - // exception = 1; - //} - //fprintf(stderr,"tgt=.x%lx %d\n", (t_int)tgt, exception); - - if (vis && canvas_showtext(x) && gobj_shouldvis(gr, parent_glist)) - rtext_draw(glist_findrtext(parent_glist, &x->gl_obj)); + // weird exception + //int exception = 0; + //t_canvas* tgt = glist_getcanvas(x->gl_owner); + //if (parent_glist->gl_owner && !parent_glist->gl_mapped && + // parent_glist->gl_owner->gl_mapped) { + // tgt = parent_glist; + // exception = 1; + //} + //fprintf(stderr,"tgt=.x%lx %d\n", (t_int)tgt, exception); + + if (vis && canvas_showtext(x) && gobj_shouldvis(gr, parent_glist)) + rtext_draw(glist_findrtext(parent_glist, &x->gl_obj)); graph_getrect(gr, parent_glist, &x1, &y1, &x2, &y2); - //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); + //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); if (!vis) rtext_erase(glist_findrtext(parent_glist, &x->gl_obj)); sprintf(tag, "%s", rtext_gettag(glist_findrtext(parent_glist, &x->gl_obj))); //sprintf(tag, "graph%lx", (t_int)x); - //fprintf(stderr, "gettag=%s, tag=graph%lx\n", rtext_gettag(glist_findrtext(parent_glist, &x->gl_obj)),(t_int)x); - /* if we look like a graph but have been moved to a toplevel, - just show the bounding rectangle */ + //fprintf(stderr, "gettag=%s, tag=graph%lx\n", + // rtext_gettag(glist_findrtext(parent_glist, &x->gl_obj)),(t_int)x); + /* if we look like a graph but have been moved to a toplevel, + just show the bounding rectangle */ if (x->gl_havewindow) { - if (vis && gobj_shouldvis(gr, parent_glist)) - { - sys_vgui(".x%lx.c create ppolygon\ - %d %d %d %d %d %d %d %d %d %d -tags {%sfill graph} -fill $pd_colors(graph_border) -stroke $pd_colors(graph_border)\n", - glist_getcanvas(x->gl_owner), - //parent_glist, - x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag); + if (vis && gobj_shouldvis(gr, parent_glist)) + { + sys_vgui(".x%lx.c create ppolygon %d %d %d %d %d %d %d %d %d %d " + "-tags {%sfill graph} -fill $pd_colors(graph_border) " + "-stroke $pd_colors(graph_border)\n", + glist_getcanvas(x->gl_owner), + //parent_glist, + x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag); glist_noselect(x->gl_owner); - } - else if (gobj_shouldvis(gr, parent_glist)) - { - sys_vgui(".x%lx.c delete %sfill\n", - glist_getcanvas(x->gl_owner), tag); - //parent_glist, tag); - } + } + else if (gobj_shouldvis(gr, parent_glist)) + { + sys_vgui(".x%lx.c delete %sfill\n", + glist_getcanvas(x->gl_owner), tag); + //parent_glist, tag); + } return; } /* otherwise draw (or erase) us as a graph inside another glist. */ @@ -893,12 +924,13 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) t_symbol *arrayname; t_garray *ga; /* draw a rectangle around the graph */ - /*sys_vgui(".x%lx.c create polyline\ - %d %d %d %d %d %d %d %d %d %d -stroke $pd_colors(graph_border) -tags {%sR %s graph}\n", + /*sys_vgui(".x%lx.c create polyline %d %d %d %d %d %d %d %d %d %d " + "-stroke $pd_colors(graph_border) -tags {%sR %s graph}\n", glist_getcanvas(x->gl_owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag, tag);*/ - sys_vgui(".x%lx.c create prect\ - %d %d %d %d -stroke $pd_colors(graph_border) -tags {%sR graph}\n", //REMOVED: -fill $pd_colors(graph) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(graph_border) -tags {%sR graph}\n", + //REMOVED: -fill $pd_colors(graph) glist_getcanvas(x->gl_owner), x1, y1, x2, y2, tag); // -fill $pd_colors(graph) @@ -908,12 +940,14 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) if (g->g_pd == garray_class && !garray_getname((t_garray *)g, &arrayname)) { - //i++; - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor nw\ - -font {{%s} -%d %s} -tags {%s label graph} -fill %s\n", - (long)glist_getcanvas(x), x1+2, i, arrayname->s_name, sys_font, - sys_hostfontsize(glist_getfont(x)), sys_fontweight, tag, - (glist_isselected(x, gr) ? "$pd_colors(selection)" : "$pd_colors(graph_border)")); + //i++; + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor nw " + "-font {{%s} -%d %s} -tags {%s label graph} -fill %s\n", + (long)glist_getcanvas(x), x1+2, i, arrayname->s_name, + sys_font, sys_hostfontsize(glist_getfont(x)), sys_fontweight, + tag, + (glist_isselected(x, gr) ? + "$pd_colors(selection)" : "$pd_colors(graph_border)")); i += sys_fontheight(glist_getfont(x)); } @@ -1012,18 +1046,19 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) glist_getfont(x), sys_fontweight, tag); /* draw contents of graph as glist */ - for (g = x->gl_list; g; g = g->g_next) { - gop_redraw = 1; - //fprintf(stderr,"drawing gop objects\n"); + for (g = x->gl_list; g; g = g->g_next) + { + gop_redraw = 1; + //fprintf(stderr,"drawing gop objects\n"); gobj_vis(g, x, 1); - //fprintf(stderr,"done\n"); - gop_redraw = 0; - } - /* reselect it upon redrawing if it was selected before */ + //fprintf(stderr,"done\n"); + gop_redraw = 0; + } + /* reselect it upon redrawing if it was selected before */ glist_drawiofor(parent_glist, &x->gl_obj, 1, tag, x1, y1, x2, y2); - if (glist_isselected(parent_glist, gr)) - gobj_select(gr, parent_glist, 1); + if (glist_isselected(parent_glist, gr)) + gobj_select(gr, parent_glist, 1); } else { @@ -1031,7 +1066,7 @@ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) glist_getcanvas(x->gl_owner), tag); sys_vgui(".x%lx.c delete %sR\n", glist_getcanvas(x->gl_owner), tag); - glist_eraseiofor(parent_glist, &x->gl_obj, tag); + glist_eraseiofor(parent_glist, &x->gl_obj, tag); for (g = x->gl_list; g; g = g->g_next) gobj_vis(g, x, 0); } @@ -1056,64 +1091,74 @@ void graph_graphrect(t_gobj *z, t_glist *glist, *yp2 = y2; } - /* check if the gop size needs to change due to gop's text - in case hidetext is not enabled */ + /* check if the gop size needs to change due to gop's text + in case hidetext is not enabled */ void graph_checkgop_rect(t_gobj *z, t_glist *glist, - int *xp1, int *yp1, int *xp2, int *yp2) { + int *xp1, int *yp1, int *xp2, int *yp2) +{ - //fprintf(stderr,"graph_checkgop_rect\n"); - t_glist *x = (t_glist *)z; + //fprintf(stderr,"graph_checkgop_rect\n"); + t_glist *x = (t_glist *)z; t_gobj *g; int fw = sys_fontwidth(x->gl_font); int fh = sys_fontheight(x->gl_font); - if (!x->gl_hidetext) { - int x21, y21, x22, y22; - text_widgetbehavior.w_getrectfn(z, glist, &x21, &y21, &x22, &y22); - if (x22 > *xp2) - *xp2 = x22; - if (y22 > *yp2) - *yp2 = y22; - // WARNING: ugly hack trying to replicate rtext_senditup if we have no parent - // later consider fixing hardwired values - int tcols = strlen(x->gl_name->s_name) - 3; - int th = fh + fh * (tcols/60) + 4; - if (tcols > 60) tcols = 60; - int tw = fw * tcols + 4; - if (tw + *xp1 > *xp2) - *xp2 = tw + *xp1; - if (th + *yp1 > *yp2) - *yp2 = th + *yp1; - } - - // check if the gop has array members and if so, make its minimum size based on array names size + if (!x->gl_hidetext) + { + int x21, y21, x22, y22; + text_widgetbehavior.w_getrectfn(z, glist, &x21, &y21, &x22, &y22); + if (x22 > *xp2) + *xp2 = x22; + if (y22 > *yp2) + *yp2 = y22; + // WARNING: ugly hack trying to replicate rtext_senditup + // if we have no parent. Later consider fixing hardwired values + int tcols = strlen(x->gl_name->s_name) - 3; + int th = fh + fh * (tcols/60) + 4; + if (tcols > 60) tcols = 60; + int tw = fw * tcols + 4; + if (tw + *xp1 > *xp2) + *xp2 = tw + *xp1; + if (th + *yp1 > *yp2) + *yp2 = th + *yp1; + } + + // check if the gop has array members and if so, + // make its minimum size based on array names size t_symbol *arrayname; int cols_tmp = 0; int arrayname_cols = 0; int arrayname_rows = 0; - for (g = x->gl_list; g; g = g->g_next) { - if (pd_class(&g->g_pd) == garray_class && !garray_getname((t_garray *)g, &arrayname)) { + for (g = x->gl_list; g; g = g->g_next) + { + if (pd_class(&g->g_pd) == garray_class && + !garray_getname((t_garray *)g, &arrayname)) + { arrayname_rows += 1; cols_tmp = strlen(arrayname->s_name); if(cols_tmp > arrayname_cols) arrayname_cols = cols_tmp; } } - if (arrayname_rows) { + if (arrayname_rows) + { int fontwidth = sys_fontwidth(x->gl_font); int fontheight = sys_fontheight(x->gl_font); - if ((arrayname_rows * fontheight - 1) > (*yp2 - *yp1)) *yp2 = *yp1 + (arrayname_rows * fontheight - 1); - if ((arrayname_cols * fontwidth + 2) > (*xp2 - *xp1)) *xp2 = *xp1 + (arrayname_cols * fontwidth + 2); + if ((arrayname_rows * fontheight - 1) > (*yp2 - *yp1)) + *yp2 = *yp1 + (arrayname_rows * fontheight - 1); + if ((arrayname_cols * fontwidth + 2) > (*xp2 - *xp1)) + *xp2 = *xp1 + (arrayname_cols * fontwidth + 2); } - // failsafe where we cannot have a gop that is smaller than 1x1 pixels - // regardless whether the text is hidden - int in = obj_ninlets(pd_checkobject(&z->g_pd)) * IOWIDTH; - int out = obj_noutlets(pd_checkobject(&z->g_pd)) * IOWIDTH; - int minhsize = (in >= out ? in : out) + SCALE_GOP_MINWIDTH; - int minvsize = ((in > 0 ? 1 : 0) + (out > 0 ? 1 : 0)) * 2 + SCALE_GOP_MINHEIGHT; - if (*xp2 < *xp1+minhsize) *xp2 = *xp1+minhsize; - if (*yp2 < *yp1+minvsize) *yp2 = *yp1+minvsize; - + // failsafe where we cannot have a gop that is smaller than 1x1 pixels + // regardless whether the text is hidden + int in = obj_ninlets(pd_checkobject(&z->g_pd)) * IOWIDTH; + int out = obj_noutlets(pd_checkobject(&z->g_pd)) * IOWIDTH; + int minhsize = (in >= out ? in : out) + SCALE_GOP_MINWIDTH; + int minvsize = ((in > 0 ? 1 : 0) + (out > 0 ? 1 : 0)) * 2 + + SCALE_GOP_MINHEIGHT; + if (*xp2 < *xp1+minhsize) *xp2 = *xp1+minhsize; + if (*yp2 < *yp1+minvsize) *yp2 = *yp1+minvsize; + } /* get the rectangle, enlarged to contain all the "contents" -- @@ -1122,9 +1167,10 @@ static void graph_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { int x1 = 0x7fffffff, y1 = 0x7fffffff, x2 = -0x7fffffff, y2 = -0x7fffffff; - int tx1 = 0x7fffffff, ty1 = 0x7fffffff, tx2 = -0x7fffffff, ty2 = -0x7fffffff; + int tx1 = 0x7fffffff, ty1 = 0x7fffffff, + tx2 = -0x7fffffff, ty2 = -0x7fffffff; t_glist *x = (t_glist *)z; - //fprintf(stderr,"graph_getrect %d\n", x->gl_isgraph); + //fprintf(stderr,"graph_getrect %d\n", x->gl_isgraph); if (x->gl_isgraph) { int hadwindow; @@ -1133,7 +1179,7 @@ static void graph_getrect(t_gobj *z, t_glist *glist, int x21, y21, x22, y22; graph_graphrect(z, glist, &x1, &y1, &x2, &y2); - //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); + //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); if (canvas_showtext(x)) { @@ -1142,7 +1188,7 @@ static void graph_getrect(t_gobj *z, t_glist *glist, x2 = x22; if (y22 > y2) y2 = y22; - //fprintf(stderr,"canvas_showtext %d %d %d %d\n", x1, y1, x2, y2); + //fprintf(stderr,"canvas_showtext %d %d %d %d\n", x1, y1, x2, y2); } if (!x->gl_goprect) { @@ -1157,7 +1203,8 @@ static void graph_getrect(t_gobj *z, t_glist *glist, { /* don't do this for arrays, just let them hang outside the box. */ - if (pd_class(&g->g_pd) == garray_class || pd_class(&g->g_pd) == scalar_class) + if (pd_class(&g->g_pd) == garray_class || + pd_class(&g->g_pd) == scalar_class) continue; gobj_getrect(g, x, &x21, &y21, &x22, &y22); if (x22 > x2) @@ -1168,24 +1215,27 @@ static void graph_getrect(t_gobj *z, t_glist *glist, x->gl_havewindow = hadwindow; } - //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); - - // check if the text is not hidden and if so use that as the limit of the gop's size - graph_checkgop_rect(z, glist, &x1, &y1, &x2, &y2); - - /* fix visibility of edge items for garrays */ - int has_garray = 0; - for (g = x->gl_list; g; g = g->g_next) { - if (pd_class(&g->g_pd) == garray_class) { - has_garray = 1; - } - } - /*if (has_garray) { - x1 -= 1; - y1 -= 2; - //x2 += 1; - y2 += 1; - }*/ + //fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2); + + // check if the text is not hidden and if so use that as the + // limit of the gop's size + graph_checkgop_rect(z, glist, &x1, &y1, &x2, &y2); + + /* fix visibility of edge items for garrays */ + int has_garray = 0; + for (g = x->gl_list; g; g = g->g_next) + { + if (pd_class(&g->g_pd) == garray_class) + { + has_garray = 1; + } + } + /*if (has_garray) { + x1 -= 1; + y1 -= 2; + //x2 += 1; + y2 += 1; + }*/ } else text_widgetbehavior.w_getrectfn(z, glist, &x1, &y1, &x2, &y2); *xp1 = x1; @@ -1196,7 +1246,7 @@ static void graph_getrect(t_gobj *z, t_glist *glist, static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy) { - //fprintf(stderr,"graph_displace %d %d\n", dx, dy); + //fprintf(stderr,"graph_displace %d %d\n", dx, dy); t_glist *x = (t_glist *)z; if (!x->gl_isgraph) text_widgetbehavior.w_displacefn(z, glist, dx, dy); @@ -1204,18 +1254,21 @@ static void graph_displace(t_gobj *z, t_glist *glist, int dx, int dy) { x->gl_obj.te_xpix += dx; x->gl_obj.te_ypix += dy; - /*char tag[80]; - sprintf(tag, "%s", rtext_gettag(glist_findrtext((x->gl_owner ? x->gl_owner: x), &x->gl_obj))); + /*char tag[80]; + sprintf(tag, "%s", + rtext_gettag( + glist_findrtext((x->gl_owner ? x->gl_owner: x), &x->gl_obj))); sys_vgui(".x%lx.c move %s %d %d\n", glist_getcanvas(x->gl_owner), tag, dx, dy); sys_vgui(".x%lx.c move %sR %d %d\n", glist_getcanvas(x->gl_owner), tag, dx, dy);*/ - if (!do_not_redraw) { - //fprintf(stderr,"graph_displace redraw\n"); - glist_redraw(glist_getcanvas(glist)); - //gobj_select(z, glist, 1); - canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj); - } + if (!do_not_redraw) + { + //fprintf(stderr,"graph_displace redraw\n"); + glist_redraw(glist_getcanvas(glist)); + //gobj_select(z, glist, 1); + canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj); + } } } @@ -1241,7 +1294,7 @@ static void graph_displace_scalars(t_glist *x, t_glist *glist, int dx, int dy) static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) { - //fprintf(stderr,"graph_displace_withtag %d %d\n", dx, dy); + //fprintf(stderr,"graph_displace_withtag %d %d\n", dx, dy); t_glist *x = (t_glist *)z; if (!x->gl_isgraph) text_widgetbehavior.w_displacefnwtag(z, glist, dx, dy); @@ -1253,19 +1306,24 @@ static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) /* special case for scalars, which have a group for the transform matrix */ graph_displace_scalars(x, glist, dx, dy); - for (g = x->gl_list; g; g = g->g_next) { - //fprintf(stderr,"shouldvis %d %d\n", gobj_shouldvis(g, glist), gobj_shouldvis(g, x)); - if (g && gobj_shouldvis(g, x) && g->g_pd->c_wb->w_displacefnwtag == NULL && pd_class((t_pd *)g) != garray_class) { - //fprintf(stderr,"old way\n"); - old_displace = 1; - graph_displace(z, glist, dx, dy); - return; + for (g = x->gl_list; g; g = g->g_next) + { + //fprintf(stderr,"shouldvis %d %d\n", + // gobj_shouldvis(g, glist), gobj_shouldvis(g, x)); + if (g && gobj_shouldvis(g, x) && + g->g_pd->c_wb->w_displacefnwtag == NULL && + pd_class((t_pd *)g) != garray_class) + { + //fprintf(stderr,"old way\n"); + old_displace = 1; + graph_displace(z, glist, dx, dy); + return; } } // else we do things the new and more elegant way //fprintf(stderr,"new way\n"); - + x->gl_obj.te_xpix += dx; x->gl_obj.te_ypix += dy; canvas_fixlinesfor(glist_getcanvas(glist), &x->gl_obj); @@ -1274,49 +1332,67 @@ static void graph_displace_withtag(t_gobj *z, t_glist *glist, int dx, int dy) static void graph_select(t_gobj *z, t_glist *glist, int state) { - //fprintf(stderr,"graph_select .x%lx .x%lx %d...\n", (t_int)z, (t_int)glist, state); + //fprintf(stderr,"graph_select .x%lx .x%lx %d...\n", + // (t_int)z, (t_int)glist, state); t_glist *x = (t_glist *)z; if (!x->gl_isgraph) text_widgetbehavior.w_selectfn(z, glist, state); else //if(glist_istoplevel(glist)) { - //fprintf(stderr,"...yes\n"); - //fprintf(stderr,"%lx %lx %lx\n", glist_getcanvas(glist), glist, x); + //fprintf(stderr,"...yes\n"); + //fprintf(stderr,"%lx %lx %lx\n", glist_getcanvas(glist), glist, x); t_rtext *y = glist_findrtext(glist, &x->gl_obj); if (canvas_showtext(x)) + { rtext_select(y, state); - t_glist *canvas; - if (!glist_istoplevel(glist)) { - canvas = glist_getcanvas(glist); - } else { - canvas = glist; - } - if(glist_istoplevel(glist)) { - sys_vgui(".x%lx.c itemconfigure %sR -stroke %s\n", canvas, - rtext_gettag(y), (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); -/* - sys_vgui(".x%lx.c itemconfigure graph%lx -fill %s\n", + } + + t_glist *canvas; + if (!glist_istoplevel(glist)) + { + canvas = glist_getcanvas(glist); + } + else + { + canvas = glist; + } + if(glist_istoplevel(glist)) + { + sys_vgui(".x%lx.c itemconfigure %sR -stroke %s\n", canvas, + rtext_gettag(y), + (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); + /* + sys_vgui(".x%lx.c itemconfigure graph%lx -fill %s\n", glist_getcanvas(glist), z, (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); -*/ - sys_vgui(".x%lx.c itemconfigure %sT -fill %s\n", + */ + sys_vgui(".x%lx.c itemconfigure %sT -fill %s\n", canvas, rtext_gettag(y), (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); - sys_vgui(".x%lx.c itemconfigure %sfill -stroke %s -fill %s\n", + sys_vgui(".x%lx.c itemconfigure %sfill -stroke %s -fill %s\n", canvas, rtext_gettag(y), - (state? "$pd_colors(selection)" : "$pd_colors(graph_border)"), (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); - } - - t_gobj *g; - //fprintf(stderr,"graph_select\n"); - if (x->gl_list && !glist_istoplevel(x)) - for (g = x->gl_list; g; g = g->g_next) { - //fprintf(stderr,"shouldvis %d\n",gobj_shouldvis(g, x)); - if ((g && gobj_shouldvis(g, x) && (g->g_pd->c_wb->w_displacefnwtag != NULL) || (g && pd_class((t_pd *)g) == garray_class))) - gobj_select(g, x, state); - } - sys_vgui("pdtk_select_all_gop_widgets .x%lx %s %d\n", canvas, rtext_gettag(glist_findrtext(glist, &x->gl_obj)), state); + (state? "$pd_colors(selection)" : "$pd_colors(graph_border)"), + (state? "$pd_colors(selection)" : "$pd_colors(graph_border)")); + } + + t_gobj *g; + //fprintf(stderr,"graph_select\n"); + if (x->gl_list && !glist_istoplevel(x)) + { + for (g = x->gl_list; g; g = g->g_next) + { + //fprintf(stderr,"shouldvis %d\n",gobj_shouldvis(g, x)); + if ((g && gobj_shouldvis(g, x) && + (g->g_pd->c_wb->w_displacefnwtag != NULL) || + (g && pd_class((t_pd *)g) == garray_class))) + { + gobj_select(g, x, state); + } + } + } + sys_vgui("pdtk_select_all_gop_widgets .x%lx %s %d\n", + canvas, rtext_gettag(glist_findrtext(glist, &x->gl_obj)), state); } } @@ -1347,15 +1423,16 @@ static void graph_delete(t_gobj *z, t_glist *glist) static void graph_delete(t_gobj *z, t_glist *glist) { - //fprintf(stderr,"graph_delete\n"); + //fprintf(stderr,"graph_delete\n"); t_glist *x = (t_glist *)z; t_gobj *y; text_widgetbehavior.w_deletefn(z, glist); - while (y = x->gl_list) { + while (y = x->gl_list) + { glist_delete(x, y); - } - if (glist_istoplevel(glist) && glist_isvisible(glist)) - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", glist); + } + if (glist_istoplevel(glist) && glist_isvisible(glist)) + sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", glist); } static t_float graph_lastxpix, graph_lastypix; @@ -1420,34 +1497,44 @@ static int graph_click(t_gobj *z, struct _glist *glist, if(pd_class(&y->g_pd) == garray_class && !y->g_next && (array_joc = garray_joc((t_garray *)y)) && - (clickreturned = gobj_click(y, x, xpix, ypix, shift, alt, 0, doit))) - break; + (clickreturned = + gobj_click(y, x, xpix, ypix, shift, alt, 0, doit))) + { + break; + } else { int x1, y1, x2, y2; t_object *ob; - /* check if the object wants to be clicked and pick the topmost with the exception of the text (comment)*/ - if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2)) { + /* check if the object wants to be clicked and pick + the topmost with the exception of the text (comment)*/ + if (canvas_hitbox(x, y, xpix, ypix, &x1, &y1, &x2, &y2)) + { ob = pd_checkobject(&y->g_pd); - if (!ob || ob->te_type != T_TEXT) // do not give clicks to comments during runtime + /* do not give clicks to comments during runtime */ + if (!ob || ob->te_type != T_TEXT) clickme = y; //fprintf(stderr," found clickable %d\n", clickreturned); } } } - if (clickme) { + if (clickme) + { //fprintf(stderr," clicking\n"); clickreturned = gobj_click(clickme, x, xpix, ypix, shift, alt, 0, doit); } if (!doit) { - //fprintf(stderr," not clicking %lx %d\n", (t_int)clickme, clickreturned); - if (clickme != NULL) { + //fprintf(stderr," not clicking %lx %d\n", + // (t_int)clickme, clickreturned); + if (clickme != NULL) + { //fprintf(stderr," cursor %d\n", clickreturned); canvas_setcursor(glist_getcanvas(x), clickreturned); } - else if (!array_joc) { + else if (!array_joc) + { //fprintf(stderr," cursor 0\n"); canvas_setcursor(glist_getcanvas(x), CURSOR_RUNMODE_NOTHING); } @@ -1465,7 +1552,7 @@ t_widgetbehavior graph_widgetbehavior = graph_delete, graph_vis, graph_click, - graph_displace_withtag, + graph_displace_withtag, }; /* find the graph most recently added to this glist; diff --git a/pd/src/g_hdial.c b/pd/src/g_hdial.c index 27765959f32a6dfc80f4a21a332550ba77ab881e..c2b8ee919233057f0eab649b442ae1a6d0a83010 100644 --- a/pd/src/g_hdial.c +++ b/pd/src/g_hdial.c @@ -64,42 +64,53 @@ void hradio_draw_new(t_hradio *x, t_glist *glist) int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4; int xx22=xx11b+dx-s4; - 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); - - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_border) -fill #%6.6x -tags {%lxBASE%d %lxHRDO %s text iemgui border}\n", - canvas, xx11, yy11, xx11+dx, yy12, - x->x_gui.x_bcol, x, i, x, nlet_tag); - sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x -stroke #%6.6x -tags {%lxBUT%d %lxHRDO %s text iemgui}\n", - canvas, xx21, yy21, xx22, yy22, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, - (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i, x, nlet_tag); - xx11 += dx; - xx21 += dx; - xx22 += dx; - x->x_drawn = x->x_on; - } - sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ - -font {{%s} -%d %s} -fill #%6.6x -tags {%lxLABEL %lxHRDO %s text iemgui}\n", - canvas, xx11b+x->x_gui.x_ldx, yy11+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 {%lxHRDO%so%d %so%d %lxHRDO %s outlet iemgui}\n", - canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, 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 {%lxHRDO%si%d %si%d %lxHRDO %s inlet iemgui}\n", - canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+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); + + for(i=0; i<n; i++) + { + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_border) -fill #%6.6x " + "-tags {%lxBASE%d %lxHRDO %s text iemgui border}\n", + canvas, xx11, yy11, xx11+dx, yy12, + x->x_gui.x_bcol, x, i, x, nlet_tag); + sys_vgui(".x%lx.c create prect %d %d %d %d -fill #%6.6x " + "-stroke #%6.6x -tags {%lxBUT%d %lxHRDO %s text iemgui}\n", + canvas, xx21, yy21, xx22, yy22, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, + x, i, x, nlet_tag); + xx11 += dx; + xx21 += dx; + xx22 += dx; + x->x_drawn = x->x_on; + } + sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w " + "-font {{%s} -%d %s} -fill #%6.6x " + "-tags {%lxLABEL %lxHRDO %s text iemgui}\n", + canvas, xx11b+x->x_gui.x_ldx, yy11+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 {%lxHRDO%so%d %so%d %lxHRDO %s outlet iemgui}\n", + canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, + 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 {%lxHRDO%si%d %si%d %lxHRDO %s inlet iemgui}\n", + canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, + x, nlet_tag, 0, nlet_tag, 0, x, nlet_tag); + //} } void hradio_draw_move(t_hradio *x, t_glist *glist) @@ -111,35 +122,36 @@ void hradio_draw_move(t_hradio *x, t_glist *glist) int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4; int xx22=xx11b+dx-s4; - if (glist_isvisible(canvas)) { - - char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); - - xx11 = xx11b; - xx21=xx11b+s4; - xx22=xx11b+dx-s4; - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", - canvas, x, i, xx11, yy11, xx11+dx, yy12); - sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", - canvas, x, i, xx21, yy21, xx22, yy22); - xx11 += dx; - xx21 += dx; - xx22 += dx; - } - sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", - canvas, x, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy); - if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHRDO%so%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); - if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) - sys_vgui(".x%lx.c coords %lxHRDO%si%d %d %d %d %d\n", - canvas, x, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); - /* redraw scale handle rectangle if selected */ - if (x->x_gui.x_fsf.x_selected) - hradio_draw_select(x, x->x_gui.x_glist); - } + if (glist_isvisible(canvas)) + { + + char *nlet_tag = iem_get_tag(glist, (t_iemgui *)x); + + xx11 = xx11b; + xx21=xx11b+s4; + xx22=xx11b+dx-s4; + for(i=0; i<n; i++) + { + sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n", + canvas, x, i, xx11, yy11, xx11+dx, yy12); + sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n", + canvas, x, i, xx21, yy21, xx22, yy22); + xx11 += dx; + xx21 += dx; + xx22 += dx; + } + sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", + canvas, x, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy); + if(!x->x_gui.x_fsf.x_snd_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c coords %lxHRDO%so%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12); + if(!x->x_gui.x_fsf.x_rcv_able && canvas == x->x_gui.x_glist) + sys_vgui(".x%lx.c coords %lxHRDO%si%d %d %d %d %d\n", + canvas, x, nlet_tag, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1); + /* redraw scale handle rectangle if selected */ + if (x->x_gui.x_fsf.x_selected) + hradio_draw_select(x, x->x_gui.x_glist); + } } void hradio_draw_erase(t_hradio* x, t_glist* glist) @@ -147,16 +159,17 @@ void hradio_draw_erase(t_hradio* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; - 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); - } + 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); + } /* for(i=0; i<n; i++) { @@ -176,30 +189,35 @@ void hradio_draw_config(t_hradio* x, t_glist* glist) t_canvas *canvas=glist_getcanvas(glist); int n=x->x_number, i; - /* - 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:""); + strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); for(i=0; i<n; i++) { - sys_vgui(".x%lx.c itemconfigure %lxBASE%d -fill #%6.6x\n .x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", - canvas, x, i, x->x_gui.x_bcol, canvas, x, i, + sys_vgui(".x%lx.c itemconfigure %lxBASE%d " + "-fill #%6.6x\n " + ".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -stroke #%6.6x\n", + canvas, x, i, x->x_gui.x_bcol, canvas, x, i, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol); - /*sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i, + /*sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x " + "-outline #%6.6x\n", canvas, x, i, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);*/ } @@ -211,303 +229,364 @@ void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags) int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, 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 {%lxHRDO%so%d %so%d %lxHRDO %s outlet iemgui}\n", - canvas, - xpos, ypos + x->x_gui.x_w-1, - xpos + IOWIDTH, ypos + x->x_gui.x_w, - 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 %lxHRDO%so%d\n", canvas, x, nlet_tag, 0); - if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) - sys_vgui(".x%lx.c create prect %d %d %d %d -stroke $pd_colors(iemgui_nlet) -tags {%lxHRDO%si%d %si%d %lxHRDO %s inlet iemgui}\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 %lxHRDO%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 {%lxHRDO%so%d %so%d %lxHRDO %s outlet iemgui}\n", + canvas, + xpos, ypos + x->x_gui.x_w-1, + xpos + IOWIDTH, ypos + x->x_gui.x_w, + 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 %lxHRDO%so%d\n", canvas, x, nlet_tag, 0); + if ((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && + !x->x_gui.x_fsf.x_rcv_able) + sys_vgui(".x%lx.c create prect %d %d %d %d " + "-stroke $pd_colors(iemgui_nlet) " + "-tags {%lxHRDO%si%d %si%d %lxHRDO %s inlet iemgui}\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 %lxHRDO%si%d\n", canvas, x, nlet_tag, 0); + } } void hradio_draw_select(t_hradio* 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); + t_scalehandle *sh = (t_scalehandle *)(x->x_gui.x_handle); + t_scalehandle *lh = (t_scalehandle *)(x->x_gui.x_lhandle); int n=x->x_number, i; - //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); - - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c itemconfigure %lxBASE%d -stroke $pd_colors(selection)\n", canvas, x, i); - } - sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill $pd_colors(selection)\n", canvas, x); - - if (x->x_gui.scale_vis) { - sys_vgui("destroy %s\n", sh->h_pathname); - sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); - } - - sys_vgui("canvas %s -width %d -height %d -bg $pd_colors(selection) -bd 0 -cursor bottom_right_corner\n", - sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT); - sys_vgui(".x%x.c create window %d %d -anchor nw -width %d -height %d -window %s -tags {%lxSCALE %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; - 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; - } - } - - sys_vgui(".x%lx.c addtag selected withtag %lxHRDO\n", canvas, x); - } - else - { - sys_vgui(".x%lx.c dtag %lxHRDO selected\n", canvas, x); - for(i=0; i<n; i++) - { - sys_vgui(".x%lx.c itemconfigure %lxBASE%d -stroke %s\n", canvas, x, i, - IEM_GUI_COLOR_NORMAL); - } - 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; - } - //} + //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); + + for(i=0; i<n; i++) + { + sys_vgui(".x%lx.c itemconfigure %lxBASE%d " + "-stroke $pd_colors(selection)\n", + canvas, x, i); + } + sys_vgui(".x%lx.c itemconfigure %lxLABEL " + "-fill $pd_colors(selection)\n", + canvas, x); + + if (x->x_gui.scale_vis) + { + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + } + + sys_vgui("canvas %s -width %d -height %d " + "-bg $pd_colors(selection) -bd 0 " + "-cursor bottom_right_corner\n", + sh->h_pathname, SCALEHANDLE_WIDTH, SCALEHANDLE_HEIGHT); + sys_vgui(".x%x.c create window %d %d -anchor nw " + "-width %d -height %d -window %s " + "-tags {%lxSCALE %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; + 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; + } + } + + sys_vgui(".x%lx.c addtag selected withtag %lxHRDO\n", canvas, x); + } + else + { + sys_vgui(".x%lx.c dtag %lxHRDO selected\n", canvas, x); + for(i=0; i<n; i++) + { + sys_vgui(".x%lx.c itemconfigure %lxBASE%d -stroke %s\n", + canvas, x, i, IEM_GUI_COLOR_NORMAL); + } + sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", + canvas, x, x->x_gui.x_lcol); + sys_vgui("destroy %s\n", sh->h_pathname); + sys_vgui(".x%lx.c delete %lxSCALE\n", canvas, x); + x->x_gui.scale_vis = 0; + sys_vgui("destroy %s\n", lh->h_pathname); + sys_vgui(".x%lx.c delete %lxLABELH\n", canvas, x); + x->x_gui.label_vis = 0; + } + //} } -static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, t_floatarg yyy) +static void hradio__clickhook(t_scalehandle *sh, t_floatarg f, t_floatarg xxx, + t_floatarg yyy) { - t_hradio *x = (t_hradio *)(sh->h_master); + t_hradio *x = (t_hradio *)(sh->h_master); - if (xxx) { - x->x_gui.scale_offset_x = xxx; - x->x_gui.label_offset_x = xxx; - } - if (yyy) { - x->x_gui.scale_offset_y = yyy; - x->x_gui.label_offset_y = yyy; - } + if (xxx) + { + x->x_gui.scale_offset_x = xxx; + x->x_gui.label_offset_x = xxx; + } + if (yyy) + { + x->x_gui.scale_offset_y = yyy; + x->x_gui.label_offset_y = yyy; + } int newstate = (int)f; if (sh->h_dragon && newstate == 0 && sh->h_scale) { - /* done dragging */ - - /* first set up the undo apply */ - canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); - - if (sh->h_dragx || sh->h_dragy) { - - sh->h_dragx = sh->h_dragy; - - x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_y; - if (x->x_gui.x_w < SCALE_HRDO_MINWIDTH) - x->x_gui.x_w = SCALE_HRDO_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_HRDO_MINHEIGHT) - x->x_gui.x_h = SCALE_HRDO_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); - hradio_draw_move(x, x->x_gui.x_glist); - iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); - canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); - } + /* done dragging */ + + /* first set up the undo apply */ + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); + + if (sh->h_dragx || sh->h_dragy) + { + + sh->h_dragx = sh->h_dragy; + + x->x_gui.x_w = x->x_gui.x_w + sh->h_dragx - x->x_gui.scale_offset_y; + if (x->x_gui.x_w < SCALE_HRDO_MINWIDTH) + x->x_gui.x_w = SCALE_HRDO_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_HRDO_MINHEIGHT) + x->x_gui.x_h = SCALE_HRDO_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); + hradio_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_number), - x->x_gui.x_obj.te_ypix + x->x_gui.x_h, sh->h_outlinetag); - } - - sh->h_dragx = 0; - sh->h_dragy = 0; + /* dragging */ + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui("lower %s\n", sh->h_pathname); + sys_vgui(".x%x.c create prect %d %d %d %d " + "-stroke $pd_colors(selection) -strokewidth 1 -tags %s\n", + x->x_gui.x_glist, x->x_gui.x_obj.te_xpix, + x->x_gui.x_obj.te_ypix, + x->x_gui.x_obj.te_xpix + (x->x_gui.x_w * x->x_number), + 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) + 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); + /* done dragging */ - if (sh->h_dragx || sh->h_dragy) { + /* first set up the undo apply */ + canvas_apply_setundo(x->x_gui.x_glist, (t_gobj *)x); - 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; + 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); - } + canvas_dirty(x->x_gui.x_glist, 1); + } - int properties = gfxstub_haveproperties((void *)x); + int properties = gfxstub_haveproperties((void *)x); - if (properties) { - sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); - sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", properties, x->x_gui.x_w); - //sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); - //sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", properties, x->x_gui.x_h); - } + if (properties) + { + sys_vgui(".gfxstub%lx.dim.w_ent delete 0 end\n", properties); + sys_vgui(".gfxstub%lx.dim.w_ent insert 0 %d\n", + properties, x->x_gui.x_w); + //sys_vgui(".gfxstub%lx.dim.h_ent delete 0 end\n", properties); + //sys_vgui(".gfxstub%lx.dim.h_ent insert 0 %d\n", + // properties, x->x_gui.x_h); + } - if (glist_isvisible(x->x_gui.x_glist)) - { - sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); - hradio_draw_move(x, x->x_gui.x_glist); - iemgui_select((t_gobj *)x, x->x_gui.x_glist, 1); - canvas_fixlinesfor(x->x_gui.x_glist, (t_text *)x); - sys_vgui("pdtk_canvas_getscroll .x%lx.c\n", x->x_gui.x_glist); - } + if (glist_isvisible(x->x_gui.x_glist)) + { + sys_vgui(".x%x.c delete %s\n", x->x_gui.x_glist, sh->h_outlinetag); + hradio_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) { - /* started dragging label */ - 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; + /* started dragging label */ + 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 hradio__motionhook(t_scalehandle *sh, - t_floatarg f1, t_floatarg f2) + t_floatarg f1, t_floatarg f2) { if (sh->h_dragon && sh->h_scale) { - t_hradio *x = (t_hradio *)(sh->h_master); - int dx = (int)f1, dy = (int)f2; - int newx, newy; - - dx = dy; - - newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w*x->x_number + (dx - x->x_gui.scale_offset_y) * x->x_number; - newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h + (dy - x->x_gui.scale_offset_y); - - if (newx < x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number) - newx = x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number; - if (newy < x->x_gui.x_obj.te_ypix + SCALE_HRDO_MINHEIGHT) - newy = x->x_gui.x_obj.te_ypix + SCALE_HRDO_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_hradio *x = (t_hradio *)(sh->h_master); + int dx = (int)f1, dy = (int)f2; + int newx, newy; + + dx = dy; + + newx = x->x_gui.x_obj.te_xpix + x->x_gui.x_w*x->x_number + + (dx - x->x_gui.scale_offset_y) * x->x_number; + newy = x->x_gui.x_obj.te_ypix + x->x_gui.x_h + + (dy - x->x_gui.scale_offset_y); + + if (newx < x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number) + newx = x->x_gui.x_obj.te_xpix + SCALE_HRDO_MINWIDTH*x->x_number; + if (newy < x->x_gui.x_obj.te_ypix + SCALE_HRDO_MINHEIGHT) + newy = x->x_gui.x_obj.te_ypix + SCALE_HRDO_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); + } } - else if (sh->h_dragon && !sh->h_scale) + else 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); + } } } @@ -517,10 +596,11 @@ void hradio_draw(t_hradio *x, t_glist *glist, int mode) sys_queuegui(x, glist, hradio_draw_update); else if(mode == IEM_GUI_DRAW_MODE_MOVE) hradio_draw_move(x, glist); - else if(mode == IEM_GUI_DRAW_MODE_NEW) { + else if(mode == IEM_GUI_DRAW_MODE_NEW) + { hradio_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) hradio_draw_select(x, glist); else if(mode == IEM_GUI_DRAW_MODE_ERASE) @@ -533,7 +613,8 @@ void hradio_draw(t_hradio *x, t_glist *glist, int mode) /* ------------------------ hdl widgetbehaviour----------------------------- */ -static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) +static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, + int *xp2, int *yp2) { t_hradio *x = (t_hradio *)z; @@ -542,7 +623,7 @@ static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *x *xp2 = *xp1 + x->x_gui.x_w*x->x_number; *yp2 = *yp1 + x->x_gui.x_h; - iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); + iemgui_label_getrect(x->x_gui, glist, xp1, yp1, xp2, yp2); } static void hradio_save(t_gobj *z, t_binbuf *b) @@ -589,13 +670,14 @@ static void hradio_properties(t_gobj *z, t_glist *owner) srl[0]->s_name, srl[1]->s_name, srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, - 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); + 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, + 0xffffff & x->x_gui.x_lcol); gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); } static void hradio_dialog(t_hradio *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); @@ -625,17 +707,19 @@ static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv) (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_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) { - hradio_draw_select(x, x->x_gui.x_glist); - } + /* forcing redraw of the scale handle */ + if (x->x_gui.x_fsf.x_selected) + { + hradio_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 hradio_set(t_hradio *x, t_floatarg f) @@ -653,14 +737,14 @@ static void hradio_set(t_hradio *x, t_floatarg f) x->x_on_old = x->x_on; x->x_on = i; if (x->x_on != x->x_on_old) - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); x->x_on_old = old; } else { x->x_on = i; if (x->x_on != x->x_on_old) - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); } } @@ -727,7 +811,7 @@ static void hradio_fout(t_hradio *x, t_floatarg f) x->x_on_old = x->x_on; x->x_on = i; if (i != x->x_on_old) - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) pd_float(x->x_gui.x_snd->s_thing, x->x_on); @@ -745,7 +829,7 @@ static void hradio_float(t_hradio *x, t_floatarg f) if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class) { - /* compatibility with earlier "vdial" behavior */ + /* compatibility with earlier "vdial" behavior */ if((x->x_change)&&(i != x->x_on_old)) { if(x->x_gui.x_fsf.x_put_in2out) @@ -776,7 +860,7 @@ static void hradio_float(t_hradio *x, t_floatarg f) x->x_on_old = x->x_on; x->x_on = i; if (i != x->x_on_old) - (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); + (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); if (x->x_gui.x_fsf.x_put_in2out) { outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); @@ -786,17 +870,22 @@ static void hradio_float(t_hradio *x, t_floatarg f) } } -static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) +static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, + t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist); hradio_fout(x, (t_float)(xx / x->x_gui.x_w)); } -static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) +static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, + int shift, int alt, int dbl, int doit) { if(doit) - hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); + { + hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, + (t_floatarg)shift, 0, (t_floatarg)alt); + } return (1); } @@ -874,7 +963,8 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) int a=IEM_GUI_DEFAULTSIZE, on=0, f=0; int ldx=0, ldy=-8, chg=1, num=8; int fs=10; - int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; + int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, + fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; char str[144]; iem_inttosymargs(&x->x_gui.x_isa, 0); @@ -912,10 +1002,15 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) 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(num < 1) num = 1; if(num > IEM_RADIO_MAX) @@ -944,7 +1039,7 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) iemgui_all_colfromload(&x->x_gui, bflcol); outlet_new(&x->x_gui.x_obj, &s_list); - /* scale handle init */ + /* scale handle init */ t_scalehandle *sh; char buf[64]; x->x_gui.x_handle = pd_new(scalehandle_class); @@ -954,27 +1049,27 @@ static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old) pd_bind(x->x_gui.x_handle, sh->h_bindsym = gensym(buf)); sprintf(sh->h_outlinetag, "h%lx", (t_int)sh); sh->h_dragon = 0; - sh->h_scale = 1; - x->x_gui.scale_offset_x = 0; - x->x_gui.scale_offset_y = 0; - x->x_gui.scale_vis = 0; - - /* label handle init */ - t_scalehandle *lh; - char lhbuf[64]; - x->x_gui.x_lhandle = pd_new(scalehandle_class); - lh = (t_scalehandle *)x->x_gui.x_lhandle; - lh->h_master = (t_gobj*)x; - sprintf(lhbuf, "_h%lx", (t_int)lh); - pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf)); - sprintf(lh->h_outlinetag, "h%lx", (t_int)lh); - lh->h_dragon = 0; - lh->h_scale = 0; - x->x_gui.label_offset_x = 0; - x->x_gui.label_offset_y = 0; - x->x_gui.label_vis = 0; - - x->x_gui.x_obj.te_iemgui = 1; + sh->h_scale = 1; + x->x_gui.scale_offset_x = 0; + x->x_gui.scale_offset_y = 0; + x->x_gui.scale_vis = 0; + + /* label handle init */ + t_scalehandle *lh; + char lhbuf[64]; + x->x_gui.x_lhandle = pd_new(scalehandle_class); + lh = (t_scalehandle *)x->x_gui.x_lhandle; + lh->h_master = (t_gobj*)x; + sprintf(lhbuf, "_h%lx", (t_int)lh); + pd_bind(x->x_gui.x_lhandle, lh->h_bindsym = gensym(lhbuf)); + sprintf(lh->h_outlinetag, "h%lx", (t_int)lh); + lh->h_dragon = 0; + lh->h_scale = 0; + x->x_gui.label_offset_x = 0; + x->x_gui.label_offset_y = 0; + x->x_gui.label_vis = 0; + + x->x_gui.x_obj.te_iemgui = 1; return (x); } @@ -995,19 +1090,21 @@ static void hradio_ff(t_hradio *x) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); gfxstub_deleteforkey(x); - /* scale handle deconstructor */ + /* scale handle deconstructor */ if (x->x_gui.x_handle) { - pd_unbind(x->x_gui.x_handle, ((t_scalehandle *)x->x_gui.x_handle)->h_bindsym); - pd_free(x->x_gui.x_handle); + pd_unbind(x->x_gui.x_handle, + ((t_scalehandle *)x->x_gui.x_handle)->h_bindsym); + pd_free(x->x_gui.x_handle); } - /* label handle deconstructor */ - if (x->x_gui.x_lhandle) - { - pd_unbind(x->x_gui.x_lhandle, ((t_scalehandle *)x->x_gui.x_lhandle)->h_bindsym); - pd_free(x->x_gui.x_lhandle); - } + /* label handle deconstructor */ + if (x->x_gui.x_lhandle) + { + pd_unbind(x->x_gui.x_lhandle, + ((t_scalehandle *)x->x_gui.x_lhandle)->h_bindsym); + pd_free(x->x_gui.x_lhandle); + } } void g_hradio_setup(void) @@ -1052,11 +1149,11 @@ void g_hradio_setup(void) gensym("double_change"), 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)hradio__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)hradio__motionhook, - gensym("_motion"), A_FLOAT, A_FLOAT, 0); + gensym("_motion"), A_FLOAT, A_FLOAT, 0); hradio_widgetbehavior.w_getrectfn = hradio_getrect; hradio_widgetbehavior.w_displacefn = iemgui_displace; diff --git a/pd/src/s_utf8.c b/pd/src/s_utf8.c index a4179e7aad95dbb6bc48e1ba738188a523f0ae83..fd3081b6b62bf495f77d77b1508810f70b3ccdf5 100644 --- a/pd/src/s_utf8.c +++ b/pd/src/s_utf8.c @@ -299,12 +299,12 @@ void u8_dec(char *s, int *i) void u8_inc_ptr(char **sp) { (void)(isutf(*(++(*sp))) || isutf(*(++(*sp))) || - isutf(*(++(*sp))) || ++(*sp)); + isutf(*(++(*sp))) || ++(*sp)); } /*-- moo --*/ void u8_dec_ptr(char **sp) { (void)(isutf(*(--(*sp))) || isutf(*(--(*sp))) || - isutf(*(--(*sp))) || --(*sp)); + isutf(*(--(*sp))) || --(*sp)); }