void glist_add(t_glist *x, t_gobj *y) { t_object *ob; y->g_next = 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); y2->g_next = y; } if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) rtext_new(x, ob); if (x->gl_editor && x->gl_isgraph && !x->gl_goprect && pd_checkobject(&y->g_pd)) { x->gl_goprect = 1; canvas_drawredrect(x, 1); } if (glist_isvisible(x)) gobj_vis(y, x, 1); if (class_isdrawcommand(y->g_pd)) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym( glist_getcanvas(x)->gl_name)), 0); }
static void grab_start(t_grab *x) { x->x_tograbbed = 0; x->x_bindelem = 0; if (x->x_target) { t_pd *proxy = x->x_target->s_thing; t_object *ob; if (proxy && bindlist_class) { if (*proxy == bindlist_class) { x->x_bindelem = ((t_bindlist *)proxy)->b_list; while (x->x_bindelem) { if (ob = pd_checkobject(x->x_bindelem->e_who)) { x->x_tograbbed = fragile_outlet_connections(ob->ob_outlet); return; } x->x_bindelem = x->x_bindelem->e_next; } } else if (ob = pd_checkobject(proxy)) x->x_tograbbed = fragile_outlet_connections(ob->ob_outlet); } } else x->x_tograbbed = fragile_outlet_connections(x->x_rightout); }
static void odisplay_delete(t_gobj *z, t_glist *glist) { //post("%s", __func__); t_odisplay *x = (t_odisplay *)z; t_opd_textbox *t = x->textbox; t_canvas *canvas = glist_getcanvas(glist); t_object *ob = pd_checkobject(&x->ob.te_pd); //post("%x %s %d", x, __func__, canvas->gl_editor); if(!t->firsttime && canvas->gl_editor) { // opd_textbox_nofocus_callback(t); sys_vgui(".x%lx.c delete %s\n", canvas, x->tk_tag); sys_vgui(".x%lx.c delete %sUPDATE\n", canvas, x->tk_tag); sys_vgui(".x%lx.c delete %sBOTTOM\n", canvas, x->tk_tag); opd_textbox_delete(t, glist); } if(ob && !t->firsttime && glist_isvisible(glist)) { glist_eraseiofor(glist, ob, t->iolets_tag); } canvas_deletelinesfor(glist, (t_text *)z); }
static t_pd *grab_next(t_grab *x) { nextremote: if (x->x_tograbbed) { int inno; x->x_tograbbed = fragile_outlet_nextconnection(x->x_tograbbed, &x->x_grabbed, &inno); if (x->x_grabbed) { if (inno) { if (x->x_target) loud_error((t_pd *)x, "right outlet must feed leftmost inlet"); else loud_error((t_pd *)x, "remote proxy must feed leftmost inlet"); } else { t_outlet *op; t_outlet *goutp; int goutno = x->x_noutlets; x->x_ngrabout = obj_noutlets(x->x_grabbed); if (goutno > x->x_ngrabout) goutno = x->x_ngrabout; while (goutno--) { x->x_grabcons[goutno] = obj_starttraverseoutlet(x->x_grabbed, &goutp, goutno); goutp->o_connections = obj_starttraverseoutlet((t_object *)x, &op, goutno); } return ((t_pd *)x->x_grabbed); } } } if (x->x_bindelem) while (x->x_bindelem = x->x_bindelem->e_next) { t_object *ob; if (ob = pd_checkobject(x->x_bindelem->e_who)) { x->x_tograbbed = fragile_outlet_connections(ob->ob_outlet); goto nextremote; } } return (0); }
/* remove every object from a glist. Experimental. */ void glist_clear(t_glist *x) { t_gobj *y, *y2; int dspstate = 0, suspended = 0; t_symbol *dspsym = gensym("dsp"); while (y = x->gl_list) { /* to avoid unnecessary DSP resorting, we suspend DSP only if we hit a patchable object. */ if (!suspended && pd_checkobject(&y->g_pd) && zgetfn(&y->g_pd, dspsym)) { dspstate = canvas_suspend_dsp(); suspended = 1; } /* here's the real deletion. */ glist_delete(x, y); } if (suspended) canvas_resume_dsp(dspstate); }
static void mknob_draw_new(t_mknob *x, t_glist *glist) { int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); int r = xpos + (x->x_val + 50)/100; t_float xc=xpos+x->x_gui.x_w/2.0; t_float yc=ypos+x->x_gui.x_w/2.0; t_float rc=x->x_gui.x_w/2.0; t_canvas *canvas=glist_getcanvas(glist); t_gobj *y = (t_gobj *)x; 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(canvas, (t_text *)&ob->ob_g); /* on GOP we cause segfault as apparently text_gettag() returns bogus data */ char *nlet_tag; if (yyyy) nlet_tag = rtext_gettag(yyyy); else nlet_tag = "bogus"; sys_vgui(".x%lx.c create circle %f %f -r %f -fill #%6.6x -tags {%xBASE %xMKNOB %s}\n", canvas,xc,yc,rc, x->x_gui.x_bcol, x, x, nlet_tag); /*sys_vgui(".x%lx.c create circle %f %f -r %f -stroke \"\" -fill #%6.6x -tags {%xCENTER %xMKNOB}\n", canvas,xc,yc,3.5, x->x_gui.x_fcol, x, x);*/ /*sys_vgui(".x%lx.c create ppolygon %d %d %d %d %d %d -fill #%6.6x -tags {%xKNOB %xMKNOB}\n", glist_getcanvas(glist), (int)xc,ypos,(int)xc-4,(int)yc,(int)xc+4,(int)yc,x->x_gui.x_fcol,x,x);*/ sys_vgui(".x%lx.c create ppolygon %f %d %f %f -strokewidth 2 -stroke #%6.6x -tags {%xKNOB %xMKNOB %s}\n", canvas,xc,ypos,xc,yc,x->x_gui.x_fcol,x,x,nlet_tag); mknob_update_knob(x,glist); sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \ -font {{%s} %d bold} -fill #%6.6x -tags {%xLABEL %xMKNOB %s}\n",
static t_object*g2o(t_gobj*gobj) { return pd_checkobject(&gobj->g_pd); }
/* delete an object from a glist and free it */ void glist_delete(t_glist *x, t_gobj *y) { t_gobj *g; t_object *ob; t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp")); t_canvas *canvas = glist_getcanvas(x); int drawcommand = class_isdrawcommand(y->g_pd); int wasdeleting; 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 && glist_isvisible(x)) { char tag[80]; sprintf(tag, "graph%lx", (t_int)gl); glist_eraseiofor(x, &gl->gl_obj, tag); } else { if (glist_isvisible(x)) text_eraseborder(&gl->gl_obj, x, rtext_gettag(glist_findrtext(x, &gl->gl_obj))); } } } /* if we're a drawing command, erase all scalars now, before deleting it; we'll redraw them once it's deleted below. */ if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym( glist_getcanvas(x)->gl_name)), 2); gobj_delete(y, x); if (glist_isvisible(canvas)) { gobj_vis(y, x, 0); } if (x->gl_editor && (ob = pd_checkobject(&y->g_pd))) rtext_new(x, ob); if (x->gl_list == y) x->gl_list = y->g_next; else for (g = x->gl_list; g; g = g->g_next) if (g->g_next == y) { g->g_next = y->g_next; break; } pd_free(&y->g_pd); if (chkdsp) canvas_update_dsp(); if (drawcommand) canvas_redrawallfortemplate(template_findbyname(canvas_makebindsym( glist_getcanvas(x)->gl_name)), 1); canvas_setdeleting(canvas, wasdeleting); x->gl_valid = ++glist_valid; }
void odisplay_drawElements(t_object *ob, int firsttime) { t_odisplay *x = (t_odisplay *)ob; t_opd_textbox *t = x->textbox; if(!opd_textbox_shouldDraw(t)) return; int have_new_data = 0; int draw_new_data_indicator = 0; critical_enter(x->lock); have_new_data = x->have_new_data; draw_new_data_indicator = x->draw_new_data_indicator; critical_exit(x->lock); if(have_new_data){ odisplay_bundle2text(x); } // odisplay_bundle2text(x); int x1, y1, x2, y2; odisplay_getrect((t_gobj *)x, t->glist, &x1, &y1, &x2, &y2); int rpix = x->roundpix; int rmargin = rpix; int mx1 = x1 - rmargin; int mx2 = x2; int x1a = mx1; int y1a = y1 + rpix; int x1b = mx1 + rpix; int y1b = y1; int x2a = mx2 - rpix; int y2a = y1; int x2b = mx2; int y2b = y1 + rpix; int x3a = mx2; int y3a = y2 - rpix; int x3b = mx2 - rpix; int y3b = y2; int x4a = mx1 + rpix; int y4a = y2; int x4b = mx1; int y4b = y2 - rpix; int rx1 = x1 + t->margin_l; int ry1 = y1 + t->margin_t; int rx2 = x2 - t->margin_r; int ry2 = y2 - t->margin_b; t_glist *glist = t->glist; t_canvas *canvas = glist_getcanvas(glist); // post("%x %s %d %d\n", x, __func__, firsttime, t->firsttime); if (glist_isvisible(glist) && canvas->gl_editor) { if (firsttime) { // post("%x %s FIRST VIS height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2); //box sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d -outline %s -width 2 -fill %s -tags %s\n", canvas, x1a, y1a, x1b, y1b, x2a, y2a, x2b, y2b, x3a, y3a, x3b, y3b, x4a, y4a, x4b, y4b, x->frame_color->hex, x->background_color->hex, x->tk_tag); sys_vgui(".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d %d %d -outline \"\" -fill %s -tags %sBOTTOM \n", canvas, mx1, ry2, mx2, ry2, x3a, y3a, x3b, y3b, x4a, y4a, x4b, y4b, x->frame_color->hex, x->tk_tag); //update dot sys_vgui(".x%lx.c create oval %d %d %d %d -fill %s -outline \"\" -tags %sUPDATE \n", canvas, x2-10, y1+5, x2-5, y1+10, x->background_color->hex, x->tk_tag); } else { // post("%x %s REDRAW height %d y1 %d y2 %d \n", x, __func__, t->height, y1, y2); sys_vgui(".x%lx.c coords %s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d \n", canvas, x->tk_tag, x1a, y1a, x1b, y1b, x2a, y2a, x2b, y2b, x3a, y3a, x3b, y3b, x4a, y4a, x4b, y4b); sys_vgui(".x%lx.c coords %sBOTTOM %d %d %d %d %d %d %d %d %d %d %d %d \n", canvas, x->tk_tag, mx1, ry2, mx2, ry2, x3a, y3a, x3b, y3b, x4a, y4a, x4b, y4b); //sys_vgui(".x%lx.c coords %s %d %d %d %d %d %d %d %d %d %d %d %d \n",canvas, x->tk_tag, x1, y1, x2, y1, x2, ry2, rx2, ry2, rx2, y2, x1, y2); } opd_textbox_drawElements(x->textbox, x1, y1, x2, y2, firsttime); sys_vgui(".x%lx.c itemconfigure %sUPDATE -fill %s \n", canvas, x->tk_tag, (draw_new_data_indicator? x->flash_color->hex : x->background_color->hex )); if(draw_new_data_indicator) clock_delay(x->new_data_indicator_clock, 100); /* draw inlets/outlets */ t_object *ob = pd_checkobject(&x->ob.te_pd); if (ob){ glist_drawiofor(glist, ob, firsttime, t->iolets_tag, x1, y1, x2, y2); canvas_fixlinesfor(glist, ob); } if (firsttime) /* raise cords over everything else */ sys_vgui(".x%lx.c raise cord\n", glist_getcanvas(glist)); } }