aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-25 15:33:56 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-10-25 15:33:56 +0000
commitb8cef69c5bd27cddfa93dd273bdafbee43579f91 (patch)
treec1ba4c8f681271c77fb65e43c627cbdf632c748b
parente6d36d808bebfabbb4c11bf46f0c80acb5e35a6a (diff)
Made param gui display relative paths and removed unnecessary char buffers
svn path=/trunk/externals/tof/; revision=12674
-rw-r--r--help/param-abs.pd16
-rw-r--r--help/paramGui-help.pd18
-rw-r--r--src/paramGui.h64
-rw-r--r--src/path.c31
-rw-r--r--src/tof.h4
5 files changed, 82 insertions, 51 deletions
diff --git a/help/param-abs.pd b/help/param-abs.pd
index 90223e2..ec40bed 100644
--- a/help/param-abs.pd
+++ b/help/param-abs.pd
@@ -16,21 +16,21 @@
#X obj 317 325 loadbang;
#X obj 321 300 param2-abs /id modulation;
#X obj 317 349 tof/param /volume 0 /g slider 0 1;
-#X obj 223 202 tof/param /carrier 800 /g slider 200 2000;
-#X obj 55 66 tof/paramRoute;
#X obj 660 195 iemguts/propertybang;
-#X obj 660 223 tof/paramGui;
-#X connect 1 0 17 0;
+#X obj 660 223 tof/param gui;
+#X obj 55 66 tof/param route;
+#X obj 223 202 tof/param /carrier 800 /g slider 200 2000;
+#X connect 1 0 18 0;
#X connect 3 0 4 0;
#X connect 4 0 7 0;
#X connect 7 0 10 0;
-#X connect 9 0 16 0;
+#X connect 9 0 19 0;
#X connect 10 0 0 0;
#X connect 11 0 10 1;
#X connect 12 0 11 0;
#X connect 13 0 15 0;
#X connect 14 0 4 1;
#X connect 15 0 12 0;
-#X connect 16 0 3 0;
-#X connect 17 0 8 0;
-#X connect 18 0 19 0;
+#X connect 16 0 17 0;
+#X connect 18 0 8 0;
+#X connect 19 0 3 0;
diff --git a/help/paramGui-help.pd b/help/paramGui-help.pd
index a0e5ba9..bb33dc6 100644
--- a/help/paramGui-help.pd
+++ b/help/paramGui-help.pd
@@ -14,13 +14,8 @@ minimum and maximum;
#X text 546 291 tgl: creates a toggle;
#X text 548 309 symbolatom: creates a symbol box;
#X text 8 92 version: 2009-09-19 (localized version);
-#X obj 29 417 tof/param /numerical 100 /gui nbx;
-#X obj 258 416 tof/param /slip 100 /gui slider 0 127;
-#X obj 477 120 ./param-abs /id bob;
#X text 9 18 description: builds pd guis for params.;
#X obj 652 368 tof/param /maude 3 /g bob;
-#X obj 650 407 tof/param /tom yo /g sym;
-#X obj 21 219 tof/paramGui;
#X obj 21 130 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X text 538 203 /g options for params:;
@@ -33,7 +28,12 @@ only display the gui window.;
it is bang. It is always up to date \, but a bit slower.;
#X msg 506 74 /carrier \$1;
#X floatatom 512 46 5 0 0 0 - - -;
-#X connect 18 0 17 0;
-#X connect 21 0 17 1;
-#X connect 24 0 13 0;
-#X connect 25 0 24 0;
+#X obj 21 219 tof/param gui;
+#X obj 477 120 ./param-abs /id bob;
+#X obj 650 407 tof/param /tom yo /g 1 1 sym;
+#X obj 29 417 tof/param /numerical 100 /g nbx;
+#X obj 258 416 tof/param /slip 100 /g 0 1 slider 0 127;
+#X connect 13 0 21 0;
+#X connect 16 0 21 1;
+#X connect 19 0 22 0;
+#X connect 20 0 19 0;
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);
-
}
diff --git a/src/path.c b/src/path.c
index d44ab95..d75e6bd 100644
--- a/src/path.c
+++ b/src/path.c
@@ -2,6 +2,9 @@
#include "tof.h"
#define SLASH '/'
+static char path_buf_a[MAXPDSTRING];
+static char path_buf_b[MAXPDSTRING];
+
static t_class *path_class;
typedef struct _path {
@@ -143,8 +146,8 @@ static void path_bang(t_path *x)
static void path_symbol(t_path *x, t_symbol *s) {
- strcpy(tof_buf_temp_a,s->s_name);
- int length = strlen(tof_buf_temp_a);
+ strcpy(path_buf_a,s->s_name);
+ int length = strlen(path_buf_a);
t_symbol* result;
if ( x->mode == x->s_relative ) {
@@ -153,11 +156,11 @@ static void path_symbol(t_path *x, t_symbol *s) {
// Is this a relative path?
// Checks for a starting / or a : as second character
- if ( path_is_absolute(tof_buf_temp_a,length )) {
- getRelativeFilename(tof_buf_temp_b,x->dir->s_name,tof_buf_temp_a);
- result = gensym(tof_buf_temp_b);
+ if ( path_is_absolute(path_buf_a,length )) {
+ getRelativeFilename(path_buf_b,x->dir->s_name,path_buf_a);
+ result = gensym(path_buf_b);
} else {
- result = gensym(tof_buf_temp_a);
+ result = gensym(path_buf_a);
}
} else {
@@ -165,16 +168,16 @@ static void path_symbol(t_path *x, t_symbol *s) {
// TRANFORM RELATIVE PATHS TO ABSOLUTE PATHS
// Is this a relative path?
- if ( path_is_absolute(tof_buf_temp_a,length) ) {
- result = gensym(tof_buf_temp_a);
+ if ( path_is_absolute(path_buf_a,length) ) {
+ result = gensym(path_buf_a);
} else {
// remove extra ../
- strcpy(tof_buf_temp_b,x->dir->s_name);
- char* dir = tof_buf_temp_b;
+ strcpy(path_buf_b,x->dir->s_name);
+ char* dir = path_buf_b;
char* p;
int l = strlen(dir);
if (dir[l-1] == '/') dir[l-1] = '\0';
- char* file = tof_buf_temp_a;
+ char* file = path_buf_a;
while( strncmp(file,"../",3) == 0 ) {
file = file + 3;
p = strrchr(dir,'/');
@@ -226,10 +229,10 @@ void *path_new(t_symbol *s, int argc, t_atom *argv)
x->dir = tof_get_dir(tof_get_root_canvas(tof_get_canvas()));
}
- strcpy(tof_buf_temp_a,x->dir->s_name);
+ strcpy(path_buf_a,x->dir->s_name);
- //strcat(tof_buf_temp_a,"/");
- x->dir = gensym(tof_buf_temp_a);
+ //strcat(path_buf_a,"/");
+ x->dir = gensym(path_buf_a);
/*
inlet_new(&x->x_obj, &x->x_obj.ob_pd,
diff --git a/src/tof.h b/src/tof.h
index 48ed597..80c5e0a 100644
--- a/src/tof.h
+++ b/src/tof.h
@@ -11,8 +11,8 @@
-static char tof_buf_temp_a[MAXPDSTRING];
-static char tof_buf_temp_b[MAXPDSTRING];
+//static char tof_buf_temp_a[MAXPDSTRING];
+//static char tof_buf_temp_b[MAXPDSTRING];
/*