From 1b72557df4495abaf5c2b90d06d99a55429e59c5 Mon Sep 17 00:00:00 2001 From: Thomas O Fredericks Date: Mon, 11 Oct 2010 18:31:22 +0000 Subject: Updated paramGui with relative paths svn path=/trunk/externals/tof/; revision=14224 --- src/paramGui.h | 102 ++++++++++++++++++++++++++++++++++-------------------- tof/param-help.pd | 94 ++++++++++++++++++++++++++----------------------- 2 files changed, 114 insertions(+), 82 deletions(-) diff --git a/src/paramGui.h b/src/paramGui.h index be33f0a..fb9f7c4 100644 --- a/src/paramGui.h +++ b/src/paramGui.h @@ -19,35 +19,35 @@ static t_class *paramGui_class; typedef struct _paramGui { - t_object x_obj; - //t_outlet* outlet; - //t_symbol* canvasname; - t_canvas* childcanvas; - //t_symbol* fullpath; - t_symbol* path; - - - int path_l; - - t_symbol* subpath; - int subpath_l; - int build; - t_symbol* root; - - t_symbol* receive; - int waiting; - //t_symbol* target; - //t_class* empty_s; - //t_symbol* root; - + t_object x_obj; + //t_outlet* outlet; + //t_symbol* canvasname; + t_canvas* childcanvas; + //t_symbol* fullpath; + t_symbol* path; + int path_l; + t_symbol* subpath; + int subpath_l; + int build; + t_symbol* root; + t_symbol* receive; + int waiting; + int absolute; + t_symbol* current; + //t_symbol* target; + //t_class* empty_s; + //t_symbol* root; + } t_paramGui; static void paramGui_buildCanvas(t_paramGui* x,int x_position,int y_position) { - // Clear the canvas - pd_typedmess((t_pd*)x->childcanvas,s_clear,0,NULL); - + // Clear the canvas + pd_typedmess((t_pd*)x->childcanvas,s_clear,0,NULL); + + + int pos_x = 0; int pos_y = 0; @@ -63,7 +63,11 @@ static void paramGui_buildCanvas(t_paramGui* x,int x_position,int y_position) { SETFLOAT(&atoms[6],20); SETSYMBOL(&atoms[7],s_empty); SETSYMBOL(&atoms[8],s_empty); - SETSYMBOL(&atoms[9],x->path); + if ( x->subpath != NULL) { + SETSYMBOL(&atoms[9],x->subpath); + } else { + SETSYMBOL(&atoms[9],x->path); + } SETFLOAT(&atoms[10],2); SETFLOAT(&atoms[11],12); SETFLOAT(&atoms[12],0); @@ -95,15 +99,24 @@ static void paramGui_buildCanvas(t_paramGui* x,int x_position,int y_position) { t_param* p = get_param_list(x->root); - + int match; while (p) { gui_update = 0; - if (p->GUI && (strncmp(p->path->s_name,x->path->s_name,x->path_l)==0)) { + if (p->GUI ) { - if ( x->subpath==NULL || (x->path_l > 0 && strncmp((p->path->s_name)+(x->path_l-1),x->subpath->s_name,x->subpath_l)==0)) { + match = 0; + if ( x->absolute ) { + match = (strncmp(p->path->s_name,x->subpath->s_name,x->subpath_l)==0); + } else { // relative + match = (strncmp(p->path->s_name,x->path->s_name,x->path_l)==0); + if ( x->subpath != NULL ) match = match && ( strncmp((p->path->s_name)+(x->path_l),x->subpath->s_name,x->subpath_l)==0); + + } + + if ( match ) { p->GUI(p->x,&ac,&av,&send,&receive); @@ -188,7 +201,7 @@ static void paramGui_buildCanvas(t_paramGui* x,int x_position,int y_position) { SETFLOAT(&atoms[17],-1); pd_forwardmess((t_pd*)x->childcanvas, 18, atoms); pos_y = pos_y + GUI_Y_STEP; - + gui_update = 0; } else if ( (type == s_slider) || (type == s_knob) || (type == s_hsl) ) { SETSYMBOL(&atoms[0],s_obj); SETFLOAT(&atoms[1],pos_x); @@ -294,8 +307,17 @@ static void paramGui_buildCanvas(t_paramGui* x,int x_position,int y_position) { // Change the build flag x->build = 0; + if ( x->subpath != NULL) { + x->current = x->subpath; + } else { + x->current = NULL; + + } x->subpath=NULL; - + x->absolute = 0; + + + // Show canvas t_atom a; SETFLOAT(&a,1); @@ -318,6 +340,8 @@ static void paramGui_motion_callback(t_paramGui *x, t_float x_position, t_float static void paramGui_bang(t_paramGui *x) { + + if (x->childcanvas && !x->waiting) { if (x->build) { @@ -327,9 +351,6 @@ static void paramGui_bang(t_paramGui *x) { x->waiting = 1; sys_vgui("pd [concat %s motion [winfo pointerxy .] \\;]\n",x->receive->s_name); } else { - - - // Show canvas t_atom a; SETFLOAT(&a,1); @@ -344,9 +365,12 @@ static void paramGui_bang(t_paramGui *x) { } static void paramGui_symbol(t_paramGui *x, t_symbol* s) { - if ( x->subpath != NULL && x->subpath != s) x->build = 1; - x->subpath = s; - x->subpath_l = strlen(x->subpath->s_name); + if ( x->current != s || x->build==1) { + x->build = 1; + x->subpath = s; + x->subpath_l = strlen(x->subpath->s_name); + if (x->subpath_l && x->subpath->s_name[0] == '/') x->absolute = 1; + } paramGui_bang(x); } @@ -356,7 +380,9 @@ static void paramGui_reset(t_paramGui *x) { // Hide canvas t_atom a; SETFLOAT(&a,0); + x->current = NULL; pd_typedmess((t_pd*)x->childcanvas,s_vis,1,&a); + } @@ -389,8 +415,8 @@ static void *paramGui_new(t_symbol *s, int ac, t_atom *av) { x->build = 1; - - + x->absolute = 0; + x->current = NULL; char buf[MAXPDSTRING]; sprintf(buf, "#%lx", (long)x); diff --git a/tof/param-help.pd b/tof/param-help.pd index cd4cfff..07a06c4 100644 --- a/tof/param-help.pd +++ b/tof/param-help.pd @@ -1,4 +1,4 @@ -#N canvas 430 490 403 396 10; +#N canvas 279 400 403 396 10; #N canvas 429 334 525 231 /id 0; #X text 26 42 Abstraction /id:; #X text 63 67 If an abstraction's arguments contains the "/id" keyword @@ -312,68 +312,74 @@ of this abstraction.; #X connect 21 0 20 0; #X connect 22 0 19 0; #X restore -16 292 pd route; -#N canvas 8 378 991 450 gui 0; +#N canvas 324 321 1042 460 gui 0; #X obj 431 21 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 506 75 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 431 110 tof/param gui; -#X obj 5 219 cnv 15 300 20 empty empty empty 20 12 0 14 -4034 -66577 +#X obj 7 329 cnv 15 300 20 empty empty empty 20 12 0 14 -4034 -66577 0; -#X text 7 220 arguments; +#X text 9 330 arguments; #X obj 5 7 cnv 15 300 20 empty empty empty 20 12 0 14 -257985 -66577 0; -#X obj 5 81 cnv 15 300 20 empty empty empty 20 12 0 14 -260097 -66577 +#X obj 5 151 cnv 15 300 20 empty empty empty 20 12 0 14 -260097 -66577 0; -#X text 10 81 inlets/outlets; -#X text 7 244 none.; -#X obj 8 273 cnv 15 300 20 empty empty empty 20 12 0 14 -4032 -66577 -0; -#X text 10 274 targets; +#X text 10 151 inlets/outlets; +#X text 9 354 none.; #X text 7 7 param gui; -#X floatatom 383 238 5 0 0 0 - - -; -#X obj 375 365 dac~; -#X obj 423 284 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144 +#X floatatom 383 288 5 0 0 0 - - -; +#X obj 375 415 dac~; +#X obj 423 334 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144 -1 -1 0 1; -#X msg 383 260 /modulation/index \$1; -#X msg 420 305 /volume \$1; -#X obj 529 165 cnv 15 200 20 empty empty /FM_MOD/ 2 12 0 8 -258401 +#X msg 383 310 /modulation/index \$1; +#X msg 420 355 /volume \$1; +#X obj 594 260 cnv 15 200 20 empty empty /FM_MOD/ 2 12 0 8 -258401 -262144 0; -#X obj 529 188 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/freq /FM_MOD/modulation/freq_ +#X obj 594 283 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/freq /FM_MOD/modulation/freq_ modulation/freq 50 8 0 8 -1 -262144 -1 3 256; -#X obj 529 206 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/index /FM_MOD/modulation/index_ +#X obj 594 301 nbx 5 14 -1e+37 1e+37 0 0 /FM_MOD/modulation/index /FM_MOD/modulation/index_ modulation/index 50 8 0 8 -1 -262144 -1 20 256; -#X obj 529 224 hsl 100 15 0 1 0 0 /FM_MOD/volume /FM_MOD/volume_ volume +#X obj 594 319 hsl 100 15 0 1 0 0 /FM_MOD/volume /FM_MOD/volume_ volume 105 7 0 8 -1 -262144 -1 0 1; -#X obj 529 242 hsl 100 15 200 2000 0 0 /FM_MOD/carrier /FM_MOD/carrier_ +#X obj 594 337 hsl 100 15 200 2000 0 0 /FM_MOD/carrier /FM_MOD/carrier_ carrier 105 7 0 8 -1 -262144 -1 3300 1; -#X obj 383 330 ./test-param /id FM_MOD /carrier 600; -#X text 5 107 inlet 1 bang: creates the GUI once and then displays -the window. All further bangs only display the GUI window without recreating -its contents.; -#X text 453 10 Creates the GUI once and then displays the window. All -further bangs only display the GUI window without recreating its contents. -; -#X text 527 72 Creates and displays the window everytime it is banged. -The content is always up to date \, but this slightly slower.; -#X text 6 298 [param gui] will build a gui for all the params that -have GUI options (set with the "/g" keyword) and that are located in -the same patch or in any of its children.; +#X obj 383 380 ./test-param /id FM_MOD /carrier 600; #X text 8 32 Automatically builds a gui for params. The values of the GUI elements are always up to date.; -#X text 1 155 inlet 2 bang: creates and displays the window everytime -it is banged. This slightly slower \, but it takes into account params -that were created or destroyed since it was first created.; -#X text 618 328 <-Click this abstraction's properties menu. The [iemguts/propertybang] +#X text 618 378 <-Click this abstraction's properties menu. The [iemguts/propertybang] bangs the [param gui] that creates the GUI window.; +#X obj 430 209 tof/param gui; +#X msg 430 171 symbol FM_MOD; +#X text 425 152 Relative; +#X text 525 153 Absolute; +#X text 531 73 Destroy the created GUI (the only way to force its recreation). +; +#X text 453 10 Builds the gui for all params that are in the current +patch or in any children patches of this patch.; +#X text 9 65 GUIs will only be built for params that have GUI options +set with the /g keyword.; +#X text 521 191 Only display the guis for params in the indicated path. +; +#X msg 524 171 symbol /FM_MOD/modulation; +#X text 3 265 inlet 2 bang: destroy the previously created window (the +only way to force its recreation if the path does not change).; +#X text 5 177 inlet 1 bang: creates the GUIs one (or until the target +path changes) for all params in the current patch or lower and displays +the window.; +#X text 4 221 inlet 1 symbol: creates the GUIs one (or until the target +path changes) for all params that match the indicated path and displays +the window.; #X connect 0 0 2 0; #X connect 1 0 2 1; -#X connect 12 0 15 0; -#X connect 14 0 16 0; -#X connect 15 0 22 0; -#X connect 16 0 22 0; -#X connect 22 0 13 0; -#X connect 22 0 13 1; +#X connect 10 0 13 0; +#X connect 12 0 14 0; +#X connect 13 0 20 0; +#X connect 14 0 20 0; +#X connect 20 0 11 0; +#X connect 20 0 11 1; +#X connect 24 0 23 0; +#X connect 31 0 23 0; #X restore -16 313 pd gui; #X text 45 183 Defines a parameter to save/restore/route/display.; #X text 48 205 Can save/restore any number of things in a param file. @@ -426,7 +432,7 @@ by the value of the first argument.; #X obj 137 65 t b b b; #X obj 345 14 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; -#N canvas 0 0 680 639 hsvToRgb 0; +#N canvas 0 22 680 639 hsvToRgb 0; #X obj 197 94 route 0; #X msg 197 66 \$2 \$3 \$1; #X obj 241 121 unpack 0 0 0; @@ -636,7 +642,7 @@ by the value of the first argument.; #X connect 21 0 19 1; #X connect 22 0 19 2; #X restore 325 80 pd anim; -#X obj -23 2 cnv 15 400 100 empty \$0c empty 20 12 0 14 -54577 -262144 +#X obj -23 2 cnv 15 400 100 empty \$0c empty 20 12 0 14 -73501 -262144 0; #X text -18 54 author: mrtoftrash@gmail.com; #X text -19 33 tags: state routing; -- cgit v1.2.1