static void iem_vu_scale(t_iem_vu *x, t_floatarg fscale) { int i, scale = (int)fscale; if(scale != 0) scale = 1; if(x->x_scale && !scale) { x->x_scale = scale; if(glist_isvisible(x->x_gui.x_glist)) { t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist); sys_vgui(".x%x.c delete %xSCALEPHOTO\n", canvas, x); } } if(!x->x_scale && scale) { x->x_scale = scale; if(glist_isvisible(x->x_gui.x_glist)) { t_canvas *canvas=glist_getcanvas(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); sys_vgui(".x%x.c create image %d %d -image %xSCALEIMAGE -tags %xSCALEPHOTO\n", canvas, xpos+x->x_gui.x_w+x->x_scale_w/2+3, ypos+x->x_gui.x_h/2+2, x, x); my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol); sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif); } } }
/* redraw all the items in a glist. We construe this to mean redrawing in its own window and on parent, as needed in each case. This is too conservative -- for instance, when you draw an "open" rectangle on the parent, you shouldn't have to redraw the window! */ void glist_redraw(t_glist *x) { if (glist_isvisible(x)) { /* LATER fix the graph_vis() code to handle both cases */ if (glist_istoplevel(x)) { t_gobj *g; t_linetraverser t; t_outconnect *oc; for (g = x->gl_list; g; g = g->g_next) { gobj_vis(g, x, 0); gobj_vis(g, x, 1); } /* redraw all the lines */ linetraverser_start(&t, x); while (oc = linetraverser_next(&t)) sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n", glist_getcanvas(x), oc, t.tr_lx1, t.tr_ly1, t.tr_lx2, t.tr_ly2); canvas_drawredrect(x, 0); if (x->gl_goprect) { canvas_drawredrect(x, 1); } } if (x->gl_owner && glist_isvisible(x->gl_owner)) { graph_vis(&x->gl_gobj, x->gl_owner, 0); graph_vis(&x->gl_gobj, x->gl_owner, 1); } } }
t_undo_action *canvas_undo_add(t_canvas *x, t_undo_type type, const char *name, void *data) { t_undo_action *a = 0; t_undo * udo = canvas_undo_get(x); DEBUG_UNDO(post("%s: %d %s %p!", __FUNCTION__, type, name, data)); if(UNDO_SEQUENCE_END == type && udo && udo->u_last && UNDO_SEQUENCE_START == udo->u_last->type) { /* empty undo sequence...get rid of it */ udo->u_last = udo->u_last->prev; canvas_undo_rebranch(x); udo->u_last->next = 0; canvas_undo_set_name(udo->u_last->name); if (glist_isvisible(x) && glist_istoplevel(x)) sys_vgui("pdtk_undomenu .x%lx %s no\n", x, udo->u_last->name); return 0; } a = canvas_undo_init(x); if(!a)return a; a->type = type; a->data = (void *)data; a->name = (char *)name; canvas_undo_set_name(name); if (glist_isvisible(x) && glist_istoplevel(x)) sys_vgui("pdtk_undomenu .x%lx %s no\n", x, a->name); DEBUG_UNDO(post("%s: done!", __FUNCTION__)); return(a); }
void canvas_undo_redo(t_canvas *x) { int dspwas; t_undo *udo = canvas_undo_get(x); if (!udo) return; dspwas = canvas_suspend_dsp(); if (udo->u_queue && udo->u_last->next) { char *undo_action, *redo_action; udo->u_doing = 1; udo->u_last = udo->u_last->next; canvas_editmode(x, 1); glist_noselect(x); canvas_undo_set_name(udo->u_last->name); if(UNDO_SEQUENCE_START == udo->u_last->type) { int sequence_depth = 1; while(udo->u_last->next && (udo->u_last = udo->u_last->next)) { DEBUG_UNDO(post("%s:sequence[%d] %d", __FUNCTION__, sequence_depth, udo->u_last->type)); switch(udo->u_last->type) { case UNDO_SEQUENCE_END: sequence_depth--; break; case UNDO_SEQUENCE_START: sequence_depth++; break; default: canvas_undo_doit(x, udo->u_last, UNDO_REDO, __FUNCTION__); } if (sequence_depth < 1) break; } if (sequence_depth < 0) bug("undo sequence end without start"); else if (sequence_depth > 0) bug("undo sequence start without end"); } canvas_undo_doit(x, udo->u_last, UNDO_REDO, __FUNCTION__); undo_action = udo->u_last->name; redo_action = (udo->u_last->next ? udo->u_last->next->name : "no"); udo->u_doing = 0; /* here we call updating of all unpaired hubs and nodes since their regular call will fail in case their position needed to be updated by undo/redo first to reflect the old one */ if (glist_isvisible(x) && glist_istoplevel(x)) { if (glist_isvisible(x) && glist_istoplevel(x)) sys_vgui("pdtk_undomenu .x%lx %s %s\n", x, undo_action, redo_action); } canvas_dirty(x, canvas_undo_isdirty(x)); } canvas_resume_dsp(dspwas); }
static void knob_draw_update(t_knob *x, t_glist *glist) { if (glist_isvisible(glist) && (x->x_gui.x_h != x->x_prev_h || x->x_val != x->x_prev_val)) { /* compute dial:*/ x->x_prev_h = x->x_gui.x_h; x->x_prev_val = x->x_val; float radius = 0.5*(float)x->x_gui.x_h; double angle = 7.0/36.0 + 34.0/36.0*2.0*M_PI*( (double)x->x_val*0.01/(double)x->x_gui.x_h ); int start = -80; int extent = 350 - (int)(360.0*angle/(2.0*M_PI)); /* center point: */ int x1 = text_xpix(&x->x_gui.x_obj, glist) + radius; int y1 = text_ypix(&x->x_gui.x_obj, glist) + radius; int x2 = text_xpix(&x->x_gui.x_obj, glist) + radius + radius * sin( -angle); int y2 = text_ypix(&x->x_gui.x_obj, glist) + radius + radius * cos( angle); sys_vgui(".x%lx.c coords %xKNOB %d %d %d %d\n", glist_getcanvas(glist), x, x1, /* x1 */ y1, /* y1 */ x2, /* x2 */ y2 /* y2 */ ); /* post("knob: (%d, %d) (%d, %d)", x1,y1,x2,y2); */ sys_vgui(".x%lx.c itemconfigure %xBASE -start %d -extent %d \n", glist_getcanvas(glist), x, start, extent); } }
static void iem_vu_update_peak(t_iem_vu *x, t_glist *glist) { t_canvas *canvas=glist_getcanvas(glist); if(glist_isvisible(glist)) { int xpos=text_xpix(&x->x_gui.x_obj, glist); int ypos=text_ypix(&x->x_gui.x_obj, glist); if(x->x_peak) { int i=iem_vu_col[x->x_peak]; int j=ypos + 3*(IEM_VU_STEPS+1-x->x_peak) - 1; sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x, xpos, j, xpos+x->x_gui.x_w, j); sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x, my_iemgui_color_hex[i]); } else { int mid=xpos+x->x_gui.x_w/2; sys_vgui(".x%x.c itemconfigure %xPLED -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); sys_vgui(".x%x.c coords %xPLED %d %d %d %d\n", canvas, x, mid, ypos+20, mid, ypos+20); } } }
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); }
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 iem_vu_draw_config(t_iem_vu* x, t_glist* glist) { int i, zoom = x->x_gui.x_w / 4; t_canvas *canvas=glist_getcanvas(glist); if(glist_isvisible(glist)) { iem_vu_change_bkgd_col(x, glist, 0); if(x->x_gui.x_w != x->x_old_width) { x->x_old_width = x->x_gui.x_w; sys_vgui("%xBKGDIMAGE blank\n", x); sys_vgui("%xBKGDIMAGE configure -width %d -height %d\n", x, x->x_gui.x_w, x->x_gui.x_h+3); } sys_vgui("%xBKGDIMAGE copy %xBKGDIMAGE_PROTO -zoom %d 1\n", x, x, zoom); my_iemgui_change_scale_col(x->x_scale_gif, x->x_gui.x_lcol); sys_vgui("%xSCALEIMAGE configure -data {%s}\n", x, x->x_scale_gif); sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); sys_vgui(".x%x.c itemconfigure %xRCOVER -fill #%6.6x -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol, x->x_gui.x_bcol); sys_vgui(".x%x.c itemconfigure %xPLED -width %d\n", canvas, x, 2); } }
void iemgui_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { x->x_obj.te_xpix = atom_getintarg(0, ac, av); x->x_obj.te_ypix = atom_getintarg(1, ac, av); if(glist_isvisible(x->x_glist)) iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_MOVE); }
static void breakpoints_list(t_breakpoints *x,t_symbol* s, int argc,t_atom* argv) { breakpoints_init(x,argc,argv); if (glist_isvisible(x->w.glist)) { breakpoints_drawme(x, x->w.glist, 0); } }
static void oggamp_child_dographics(t_oggamp *x) { /* do graphics stuff :: create rectangle */ if ( x->x_graphic && glist_isvisible( x->x_canvas ) ) { sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill lightblue -tags %xPBAR\n", x->x_canvas, x->x_obj.te_xpix, x->x_obj.te_ypix-OBJHEIGHT-1, x->x_obj.te_xpix + OBJWIDTH, x->x_obj.te_ypix - 1, x ); } }
static void pddplink_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_text *t = (t_text *)z; t->te_xpix += dx; t->te_ypix += dy; if (glist_isvisible(glist)) { t_rtext *y = glist_findrtext(glist, t); rtext_displace(y, dx, dy); } }
void stgl_draw_update(t_stgl *x, t_glist *glist) { if(glist_isvisible(glist)) { t_canvas *canvas=glist_getcanvas(glist); sys_vgui(".x%lx.c itemconfigure %lxTGL -fill #%6.6x\n", canvas, x, (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); } }
static void iem_vu_size(t_iem_vu *x, t_symbol *s, int ac, t_atom *av) { x->x_gui.x_w = iem_vu_clip_width((int)atom_getintarg(0, ac, av)+1); x->x_gui.x_h = 120; if(glist_isvisible(x->x_gui.x_glist)) { (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); } }
t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *s) { t_outlet *op = outlet_new(&x->gl_obj, s); if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) { gobj_vis(&x->gl_gobj, x->gl_owner, 0); gobj_vis(&x->gl_gobj, x->gl_owner, 1); canvas_fixlinesfor(x->gl_owner, &x->gl_obj); } if (!x->gl_loading) canvas_resortoutlets(x); return (op); }
static void iem_vu_update_rms(t_iem_vu *x, t_glist *glist) { if(glist_isvisible(glist)) { int ypos1=text_ypix(&x->x_gui.x_obj, glist)-1; int xpos=text_xpix(&x->x_gui.x_obj, glist); sys_vgui(".x%x.c coords %xRCOVER %d %d %d %d\n", glist_getcanvas(glist), x, xpos, ypos1, xpos+x->x_gui.x_w-1, ypos1 + 3*(IEM_VU_STEPS-x->x_rms)+1); } }
void iemgui_label_font(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { int f = atom_getintarg(0, ac, av); if (f<0 || f>2) f=0; x->x_font_style = f; x->x_fontsize = maxi(atom_getintarg(1, ac, av),4); if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -font %s\n", glist_getcanvas(x->x_glist), x, iemgui_font(x)); iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } }
void iemgui_label_pos(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { x->x_ldx = atom_getintarg(0, ac, av); x->x_ldy = atom_getintarg(1, ac, av); if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", glist_getcanvas(x->x_glist), x, text_xpix((t_object *)x,x->x_glist)+x->x_ldx, text_ypix((t_object *)x,x->x_glist)+x->x_ldy); iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } }
void toddle_drawbang(t_toddle *x,t_glist *glist,int on) { if (glist_isvisible(glist)) { if (on) sys_vgui(".x%lx.c create oval %d %d %d %d -fill %s -tags %xB\n",glist_getcanvas(glist), x->x_obj.te_xpos+1,x->x_obj.te_ypos+1, x->x_obj.te_xpos + x->x_width -1, x->x_obj.te_ypos + x->x_height -1,x->x_color->s_name,x); else sys_vgui(".x%lx.c delete %xB\n", glist_getcanvas(glist), x); } }
static void scope_displace(t_gobj *z, t_glist *glist, int dx, int dy) { t_scope *x = (t_scope *)z; t_text *t = (t_text *)z; t->te_xpix += dx; t->te_ypix += dy; if (glist_isvisible(glist)) { t_canvas *cv = scope_getcanvas(x, glist); sys_vgui(".x%lx.c move %s %d %d\n", cv, x->x_tag, dx, dy); canvas_fixlinesfor(cv, t); } }
static void scratcher_draw_select(t_scratcher* x,t_glist* glist) { t_canvas *canvas=glist_getcanvas(glist); if ( glist_isvisible( x->x_glist ) ) { if(x->x_selected) { } else { } } }
void iemgui_label(t_iemgui *x, t_symbol *s) { if (s == &s_) s = s_empty; //tb: fix for empty label t_symbol *lab = iemgui_raute2dollar(s); x->x_lab_unexpanded = lab; x->x_lab = lab = canvas_realizedollar(x->x_glist, lab); if(glist_isvisible(x->x_glist)) { sys_vgui(".x%lx.c itemconfigure %lxLABEL -text {%s} \n", glist_getcanvas(x->x_glist), x, s!=s_empty?x->x_lab->s_name:""); iemgui_shouldvis(x, IEM_GUI_DRAW_MODE_CONFIG); } }
static void collcommon_modified(t_collcommon *cc, int relinked) { if (cc->c_increation) return; if (relinked) { cc->c_volatile = 1; } if (cc->c_embedflag) { t_coll *x; for (x = cc->c_refs; x; x = x->x_next) if (x->x_canvas && glist_isvisible(x->x_canvas)) canvas_dirty(x->x_canvas, 1); } }
void canvas_rminlet(t_canvas *x, t_inlet *ip) { t_canvas *owner = x->gl_owner; int redraw = (owner && glist_isvisible(owner) && (!owner->gl_isdeleting) && glist_istoplevel(owner)); if (owner) canvas_deletelinesforio(owner, &x->gl_obj, ip, 0); if (redraw) gobj_vis(&x->gl_gobj, x->gl_owner, 0); inlet_free(ip); if (redraw) { gobj_vis(&x->gl_gobj, x->gl_owner, 1); canvas_fixlinesfor(x->gl_owner, &x->gl_obj); } }
static void odisplay_select(t_gobj *z, t_glist *glist, int state) { //post("%s %d", __func__, state); t_odisplay *x = (t_odisplay *)z; t_canvas *canvas = glist_getcanvas(glist); opd_textbox_select(x->textbox, glist, state); if (glist_isvisible(glist) && gobj_shouldvis(&x->ob.te_g, glist)){ sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->tk_tag, (state? "#006699" : "#0066CC")); // sys_vgui(".x%lx.c itemconfigure %s -outline %s\n", canvas, x->corner_tag, (state? "#006699" : "#0066CC")); sys_vgui(".x%lx.c itemconfigure %sUPDATE -fill %s\n", canvas, x->tk_tag, (x->draw_new_data_indicator? (state? "#006699" : "#0066CC") : x->background_color->hex)); } }
static void scratcher_draw_delete(t_scratcher *x, t_glist *glist) { t_int ci; t_canvas *canvas=glist_getcanvas(glist); if ( glist_isvisible( glist ) ) { SYS_VGUI3( ".x%lx.c delete %xSCRATCHER\n", canvas, x ); SYS_VGUI3( ".x%lx.c delete %xFSCRATCHER\n", canvas, x ); SYS_VGUI3( ".x%lx.c delete %xSPEEDBAR\n", canvas, x ); for ( ci=0; ci<SCRATCHER_NB_GROOVES; ci ++) { SYS_VGUI4( ".x%lx.c delete %xGROOVE%d\n", canvas, x, ci ); } } }
void iemgui_color(t_iemgui *x, t_symbol *s, int ac, t_atom *av) { x->x_bcol = iemgui_compatible_col(atom_getintarg(0, ac, av)); if(ac > 2) { x->x_fcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); x->x_lcol = iemgui_compatible_col(atom_getintarg(2, ac, av)); } else x->x_lcol = iemgui_compatible_col(atom_getintarg(1, ac, av)); if(glist_isvisible(x->x_glist)) { x->x_draw(x, x->x_glist, IEM_GUI_DRAW_MODE_CONFIG); iemgui_label_draw_config(x); } }
t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *s) { t_inlet *ip = inlet_new(&x->gl_obj, who, s, 0); // if (!x->gl_owner) //check for root canvas... // { //don't really need this, we need to search // printf("Awesome!\n"); // for where the canvas is created instead // } // then we can determine if its the root if (!x->gl_loading && x->gl_owner && glist_isvisible(x->gl_owner)) { gobj_vis(&x->gl_gobj, x->gl_owner, 0); gobj_vis(&x->gl_gobj, x->gl_owner, 1); canvas_fixlinesfor(x->gl_owner, &x->gl_obj); } if (!x->gl_loading) canvas_resortinlets(x); return (ip); }
static void canvas_deletelines_for_io(t_canvas *x, t_text *text, t_inlet *inp, t_outlet *outp) { t_linetraverser t; t_outconnect *oc; linetraverser_start(&t, x); while((oc = linetraverser_next(&t))) { if ((t.tr_ob == text && t.tr_outlet == outp) || (t.tr_ob2 == text && t.tr_inlet == inp)) { if(glist_isvisible(x)) { sys_vgui(".x%lx.c delete l%lx\n", glist_getcanvas(x), oc); } obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); } } }