/* Note that some code in here would also be useful for drawing graph decorations in toplevels... */ static void graph_vis(t_gobj *gr, t_glist *parent_glist, int vis) { t_glist *x = (t_glist *)gr; char tag[50]; t_gobj *g; int x1, y1, x2, y2; /* ordinary subpatches: just act like a text object */ if (!x->gl_isgraph) { text_widgetbehavior.w_visfn(gr, parent_glist, vis); return; } if (vis && canvas_showtext(x)) rtext_draw(glist_findrtext(parent_glist, &x->gl_obj)); graph_getrect(gr, parent_glist, &x1, &y1, &x2, &y2); if (!vis) rtext_erase(glist_findrtext(parent_glist, &x->gl_obj)); sprintf(tag, "graph%lx", (t_int)x); if (vis) glist_drawiofor(parent_glist, &x->gl_obj, 1, tag, x1, y1, x2, y2); else glist_eraseiofor(parent_glist, &x->gl_obj, tag); /* if we look like a graph but have been moved to a toplevel, just show the bounding rectangle */ if (x->gl_havewindow) { if (vis) { sys_vgui(".x%lx.c create polygon\ %d %d %d %d %d %d %d %d %d %d -tags [list %s graph] -fill #c0c0c0\n", glist_getcanvas(x->gl_owner), x1, y1, x1, y2, x2, y2, x2, y1, x1, y1, tag); sys_vgui(".x%lx.c raise cord\n", glist_getcanvas(x->gl_owner)); } else { sys_vgui(".x%lx.c delete %s\n", glist_getcanvas(x->gl_owner), tag); } return; }
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)); } }