From b8cef69c5bd27cddfa93dd273bdafbee43579f91 Mon Sep 17 00:00:00 2001 From: Thomas O Fredericks Date: Sun, 25 Oct 2009 15:33:56 +0000 Subject: Made param gui display relative paths and removed unnecessary char buffers svn path=/trunk/externals/tof/; revision=12674 --- src/paramGui.h | 64 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 18 deletions(-) (limited to 'src/paramGui.h') diff --git a/src/paramGui.h b/src/paramGui.h index a825d62..0a6e918 100644 --- a/src/paramGui.h +++ b/src/paramGui.h @@ -1,6 +1,10 @@ static t_class *paramGui_class; +#define GUI_X_STEP 200 +#define GUI_Y_STEP 18 + + typedef struct _paramGui { @@ -56,9 +60,13 @@ static void paramGui_bang(t_paramGui *x) { t_symbol* send; t_symbol* receive; + int i; + t_symbol* shortpath; + int gui_built = 1; // ac & av for updating the values of the gui (p->get()) + // after it is created int ac_got = 0; t_atom* av_got; t_symbol* s_got; @@ -69,7 +77,32 @@ static void paramGui_bang(t_paramGui *x) { p->GUI(p->x,&ac,&av,&send,&receive); if ( send == NULL ) send = x->s_empty; if ( receive == NULL ) receive = x->s_empty; + + /* + // This code alows the positioning of the guis, but creates + // too many problems + if ( IS_A_FLOAT(av,0) ) { + pos_x = GUI_X_STEP * atom_getfloat(av); + av++; + ac--; + } + + if ( IS_A_FLOAT(av,0) ) { + pos_y = GUI_Y_STEP * atom_getfloat(av); + av++; + ac--; + } + */ if ( IS_A_SYMBOL(av,0)) { + + // Make shortpath (removes what is common between paths) + // Do not make shortpath if we are at the root (x->path_l==1) + if ( x->path_l < 2) { + shortpath = p->path; + } else { + shortpath = gensym(p->path->s_name + x->path_l); + } + type = atom_getsymbol(av); if ( type == x->s_nbx ) { SETSYMBOL(&atoms[0],x->s_obj); @@ -84,7 +117,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[9],0); SETSYMBOL(&atoms[10],send); SETSYMBOL(&atoms[11],receive); - SETSYMBOL(&atoms[12],p->path); + SETSYMBOL(&atoms[12],shortpath); SETFLOAT(&atoms[13],50); SETFLOAT(&atoms[14],8); SETFLOAT(&atoms[15],0); @@ -95,7 +128,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[20],0); SETFLOAT(&atoms[21],256); pd_forwardmess((t_pd*)x->childcanvas, 22, atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; } else if (type == x->s_bng) { SETSYMBOL(&atoms[0],x->s_obj); @@ -108,7 +141,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[7],0); SETSYMBOL(&atoms[8],send); SETSYMBOL(&atoms[9],receive); - SETSYMBOL(&atoms[10],p->path); + SETSYMBOL(&atoms[10],shortpath); SETFLOAT(&atoms[11],17); SETFLOAT(&atoms[12],7); SETFLOAT(&atoms[13],0); @@ -117,7 +150,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[16],-1); SETFLOAT(&atoms[17],-1); pd_forwardmess((t_pd*)x->childcanvas, 18, atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; } else if ( (type == x->s_slider) || (type == x->s_knob) || (type == x->s_hsl) ) { SETSYMBOL(&atoms[0],x->s_obj); SETFLOAT(&atoms[1],pos_x); @@ -139,7 +172,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[9],0); SETSYMBOL(&atoms[10],send); SETSYMBOL(&atoms[11],receive); - SETSYMBOL(&atoms[12],p->path); + SETSYMBOL(&atoms[12],shortpath); SETFLOAT(&atoms[13],105); SETFLOAT(&atoms[14],7); SETFLOAT(&atoms[15],0); @@ -150,7 +183,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[20],0); SETFLOAT(&atoms[21],1); pd_forwardmess((t_pd*)x->childcanvas, 22, atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; } else if (type == x->s_tgl) { SETSYMBOL(&atoms[0],x->s_obj); @@ -161,7 +194,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[5],0); SETSYMBOL(&atoms[6],send); SETSYMBOL(&atoms[7],receive); - SETSYMBOL(&atoms[8],p->path); + SETSYMBOL(&atoms[8],shortpath); SETFLOAT(&atoms[9],17); SETFLOAT(&atoms[10],7); SETFLOAT(&atoms[11],0); @@ -172,7 +205,7 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[16],0); SETFLOAT(&atoms[17],1); pd_forwardmess((t_pd*)x->childcanvas, 18, atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; } else if ( type == x->s_symbolatom || type == x->s_sym) { @@ -183,18 +216,18 @@ static void paramGui_bang(t_paramGui *x) { SETFLOAT(&atoms[4],0); SETFLOAT(&atoms[5],0); SETFLOAT(&atoms[6],1); - SETSYMBOL(&atoms[7],p->path); + SETSYMBOL(&atoms[7],shortpath); SETSYMBOL(&atoms[8],receive); SETSYMBOL(&atoms[9],send); pd_forwardmess((t_pd*)x->childcanvas, 10,atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; } else { SETSYMBOL(&atoms[0],x->s_text); SETFLOAT(&atoms[1],pos_x); SETFLOAT(&atoms[2],pos_y); - SETSYMBOL(&atoms[3],p->path); + SETSYMBOL(&atoms[3],shortpath); pd_forwardmess((t_pd*)x->childcanvas, 4,atoms); - pos_y = pos_y + 18; + pos_y = pos_y + GUI_Y_STEP; gui_built = 0; } @@ -308,7 +341,7 @@ static void *paramGui_new(t_symbol *s, int ac, t_atom *av) { } - inlet_new(&x->x_obj, &x->x_obj.ob_pd,gensym("bang"), gensym("reset")); + inlet_new(&x->x_obj, &x->x_obj.ob_pd,&s_bang, gensym("reset")); @@ -332,10 +365,5 @@ void paramGui_setup(void) { class_sethelpsymbol(paramGui_class,gensym("param")); - //class_addmethod(paramGui_class, (t_method) paramGui_guis, gensym("guis"), A_DEFSYMBOL,0); - //class_addmethod(paramGui_class, (t_method) paramGui_updateguis, gensym("updateguis"), A_DEFSYMBOL,0); - - //class_addmethod(paramGui_class, (t_method) paramGui_update_guis, gensym("update"), A_DEFSYMBOL,0); - } -- cgit v1.2.1