aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tracker/CHANGELOG9
-rw-r--r--tracker/makefile84
-rw-r--r--tracker/tracker-help.pd163
-rw-r--r--tracker/tracker.c222
-rw-r--r--tracker/tracker.h1
-rw-r--r--tracker/tracker.tk2
6 files changed, 293 insertions, 188 deletions
diff --git a/tracker/CHANGELOG b/tracker/CHANGELOG
index 17a7f99..f7bac4a 100644
--- a/tracker/CHANGELOG
+++ b/tracker/CHANGELOG
@@ -15,3 +15,12 @@
0.2.2 --------------------------------------------------------------------
added send/receive symbols support
+
+0.2.3 --------------------------------------------------------------------
+ numbers are now aligned to right
+ notification messages are sent from user interaction
+ mouse behavior improved. now dragging faster changes more.
+ added nice makefile for target:
+ Linux
+ MacOS (thanks Steffen)
+ Win32 (thanks tof)
diff --git a/tracker/makefile b/tracker/makefile
index 64512a8..2a25050 100644
--- a/tracker/makefile
+++ b/tracker/makefile
@@ -1,37 +1,63 @@
all: pd_linux
+#all: pd_win
+#all: pd_darwin
-SUFFIX=pd_linux
-#SUFFIX=pd_darwin
+.SUFFIXES: .pd_linux .pd_darwin .dll .tk .tk2c
-$(SUFFIX): tracker.$(SUFFIX)
-tracker.$(SUFFIX): tracker.c tracker.h tracker.tk2c
+PDPATH = /home/pat/pd
+
+
+
+# ----------------------- WINDOWS -------------------------
+pd_win: tracker.dll
+tracker.dll: tracker.c tracker.h tracker.tk2c
+
+WINCFLAGS = -Wall -W -Wshadow -Wstrict-prototypes -DPD -DNT -W3 -WX -Werror -Wno-unused -mms-bitfields -Wno-parentheses -Wno-switch -O6 -funroll-loops -fomit-frame-pointer
+WININCLUDE = -I.. -I../include -I$(PDPATH)/src
+
+WINLDFLAGS = -shared
+
+.c.dll:
+ gcc -mms-bitfields $(WINCFLAGS) $(WININCLUDE) -o $*.o -c $*.c
+ gcc $(WINLDFLAGS) -o $*.dll $*.o $(PDPATH)/bin/pd.dll
+ strip --strip-unneeded $*.dll
+ rm -f $*.o
+
+# ----------------------- LINUX i386 ----------------------
+pd_linux: tracker.pd_linux
+tracker.pd_linux: tracker.c tracker.h tracker.tk2c
+
+LINUXCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wno-shadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+LINUXINCLUDE = -I/usr/include -I$(PDPATH)/src
+LINUXLDFLAGS = -export_dynamic -shared
+
+.c.pd_linux:
+ $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ $(LD) $(LINUXLDFLAGS) -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+
+# ----------------------- Darwin (OSX) --------------------
pd_darwin: tracker.pd_darwin
-tracker.pd_: tracker.c tracker.h tracker.tk2c
-
-STRIP = strip
-CFLAGS = -DPD -O2 \
- -Wall -W -Wno-shadow -Wstrict-prototypes \
- -Wno-unused -Wno-parentheses -Wno-switch
-INCLUDE = -I/usr/include -I../pd/src
-LDFLAGS =
-
-ifeq ($(SUFFIX),pd_linux)
- CFLAGS += -DUNIX -funroll-loops -fomit-frame-pointer
- LDFLAGS += -export_dynamic -shared -lc -lm
-endif
-ifeq ($(SUFFIX),pd_darwin)
- LDFLAGS += -bundle -undefined suppress -flat_namespace
- STRIP = false
-endif
-
-.SUFFIXES: .$(SUFFIX) .tk .tk2c
+tracker.pd_darwin: tracker.c tracker.h tracker.tk2c
+
+DARWINCFLAGS = -DPD -DUNIX -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wno-shadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+DARWININCLUDE = -I/usr/include -I$(PDPATH)/src
+DARWINLDFLAGS = -bundle -undefined suppress -flat_namespace
+
+.c.pd_darwin:
+ $(CC) $(CFLAGS) -o $*.o -c $*.c
+ $(LD) $(DARWINLDFLAGS) -o $*.pd_darwin $*.o -lc -lm
+# ----------------------- Miscellaneous -------------------
.tk.tk2c:
- ./tk2c.bash < $*.tk > $*.tk2c
-.c.$(SUFFIX):
- $(CC) $(CFLAGS) $(INCLUDE) -o $*.o -c $*.c
- $(LD) $(LDFLAGS) -o $*.pd_linux $*.o
- $(STRIP) --strip-unneeded $*.pd_linux
+ sh tk2c.bash < $*.tk > $*.tk2c
+
clean:
- $(RM) -f *.o *.pd_* so_locations *.tk2c
+ rm -f *.o *.pd_linux *.pd_darwin *.pd_win *.dll so_locations *.tk2c
+
+
diff --git a/tracker/tracker-help.pd b/tracker/tracker-help.pd
index c617b89..ba47291 100644
--- a/tracker/tracker-help.pd
+++ b/tracker/tracker-help.pd
@@ -1,73 +1,106 @@
-#N canvas 525 183 653 599 10;
-#X obj 65 282 tracker -data 10 10 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5
+#N canvas 355 23 810 615 10;
+#X obj 56 370 tracker -data 10 10 9 8 7 6 5 4 3 2 1 0 10 9 8 7 6 5
4 3 2 1 11 10 9 8 7 6 5 4 3 2 12 11 10 9 8 7 6 5 4 3 13 12 11 10 9
8 7 6 5 4 14 13 12 11 10 9 8 7 6 5 15 14 13 12 11 10 9 8 7 6 16 15
14 13 12 11 10 9 8 7 17 16 15 14 13 12 11 10 9 8 18 17 16 15 14 13
-12 11 10 9;
-#X msg 65 29 setrow 0 10 11 12 13 14 15 16 17 18 19;
-#X msg 79 51 setrow 0 999 999 999 999 999 999 999 999 999 999;
-#X msg 123 147 set 2 3 \$1;
-#X floatatom 123 130 5 0 0 0 - - -;
+12 11 10 9 -send trk-out -recv trk;
+#X msg 54 128 setrow 0 10 11 12 13 14 15 16 17 18 19;
+#X msg 68 150 setrow 0 999 999 999 999 999 999 999 999 999 999;
+#X msg 85 197 set 2 3 \$1;
+#X floatatom 85 180 5 0 0 0 - - -;
#N canvas 0 0 450 300 display_output 0;
-#X obj 60 51 inlet;
-#X obj 60 147 outlet;
-#X obj 60 85 list prepend set;
-#X obj 60 113 list trim;
-#X connect 0 0 2 0;
-#X connect 2 0 3 0;
-#X connect 3 0 1 0;
-#X restore 65 436 pd display_output;
-#X msg 65 467 16 15 14 13 12 11 10 9 8 7 16 15 14 13 12 11 10 9 8 7
-;
-#X msg 99 100 getrow \$1;
-#X obj 99 80 r \$0-row;
-#X obj 477 555 s \$0-row;
-#X obj 477 504 f;
-#X obj 504 504 + 1;
-#X obj 477 528 % 10;
-#X obj 477 473 metro 100;
-#X obj 477 445 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 60 186 outlet;
+#X obj 60 132 list prepend set;
+#X obj 60 159 list trim;
+#X obj 60 51 r trk-out;
+#X obj 60 105 route output;
+#X obj 60 78 list trim;
+#X text 145 77 strip list selector;
+#X text 163 107 filter by output selector;
+#X text 192 136 prepend with set just to display in a msg;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 3 0 5 0;
+#X connect 4 0 1 0;
+#X connect 5 0 4 0;
+#X restore 55 278 pd display_output;
+#X msg 55 309 12 11 10 9 8 7 6 5 4 3;
+#X obj 276 244 f;
+#X obj 303 244 + 1;
+#X obj 276 268 % 10;
+#X obj 276 219 metro 100;
+#X obj 276 191 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X floatatom 549 528 5 0 0 0 - - -;
-#X text 210 146 <- set single value;
-#X text 172 100 <- output one row;
-#X msg 146 180 get 2 3;
-#X text 212 182 <- output single value;
-#X obj 261 265 r \$0-trk;
-#X obj 419 235 s \$0-trk;
-#X text 59 530 tracker external - by Federico Ferri <mescalinum[at]gmail[dot]com>
-;
-#X msg 419 94 resize 10 10;
-#X text 419 72 resize grid \, as in properties:;
-#X msg 433 119 resize 10 20;
-#X msg 467 168 load test.trk;
-#X msg 165 235 trackrow \$1;
-#X obj 165 217 tgl 15 0 empty \$0-tgl-trk empty 17 7 0 10 -262144 -1
+#X msg 446 150 resize 10 10;
+#X msg 460 175 resize 10 20;
+#X text 577 150 load/save:;
+#X obj 444 272 tgl 15 0 empty \$0-tgl-trk empty 17 7 0 10 -262144 -1
-1 0 1;
-#X text 234 214 <- toggle row tracking;
-#X text 319 26 <- set whole row;
-#X msg 483 194 save test.trk;
-#X text 475 146 load/save:;
-#X connect 0 0 5 0;
-#X connect 1 0 0 0;
-#X connect 2 0 0 0;
-#X connect 3 0 0 0;
+#X text 470 268 <- toggle row tracking;
+#X obj 54 244 s trk;
+#X obj 446 213 s trk;
+#X msg 444 297 \; trk trackrow \$1;
+#X msg 276 295 \; trk getrow \$1;
+#X msg 570 179 load test.trk;
+#X msg 586 205 save test.trk;
+#X obj 570 234 s trk;
+#X text 313 184 <- playback;
+#X text 51 93 MANY WAYS TO GET OR SET DATA: ----------------------------
+;
+#X msg 168 197 getrow \$1;
+#X msg 193 234 get 2 3;
+#X floatatom 168 178 5 0 0 0 - - -;
+#X obj 168 278 s trk;
+#X obj 31 22 cnv 15 650 35 empty empty tracker 20 12 0 14 -62784 -262144
+0;
+#X text 226 25 tracker external - by Federico Ferri <mescalinum[at]gmail[dot]com>
+;
+#N canvas 0 0 450 300 known_bugs 0;
+#X text 63 47 * GOP doesn't work;
+#X text 63 79 * dollarZero in send/recv doesn't work;
+#X restore 521 31 pd known_bugs;
+#N canvas 0 0 450 300 license 0;
+#X text 60 51 licensed under the terms of GNU/GPL license;
+#X text 60 79 see COPYING for details;
+#X restore 610 31 pd license;
+#N canvas 569 336 450 300 keyboard_control 0;
+#X text 41 44 first \, give focus with mouse. the focused item becomes
+red.;
+#X text 42 69 you can change value by mouse dragging \, or by keyboard.
+;
+#X text 42 97 to change the selected value with keyboard \, type digits
+and press return. if you typed some digits you can cancel editing by
+pressing esc. you can increase decrease value with keys +/-. you can
+move selected item (cursor) with HJKL keys.;
+#X restore 556 71 pd keyboard_control;
+#X obj 31 542 cnv 15 650 35 empty empty v0.2.3 20 12 0 14 -62784 -262144
+0;
+#N canvas 212 405 361 431 notify_and_synchronization 0;
+#X obj 42 43 tracker -rows 10 -cols 10;
+#X obj 42 213 route changenotify;
+#X obj 42 246 tracker -rows 10 -cols 10;
+#X obj 42 190 route list;
+#X connect 0 0 3 0;
+#X connect 1 0 2 0;
+#X connect 3 0 1 0;
+#X restore 496 95 pd notify_and_synchronization;
+#X text 446 127 resize:;
+#X connect 1 0 17 0;
+#X connect 2 0 17 0;
+#X connect 3 0 17 0;
#X connect 4 0 3 0;
#X connect 5 0 6 0;
-#X connect 7 0 0 0;
-#X connect 8 0 7 0;
-#X connect 10 0 11 0;
-#X connect 10 0 12 0;
-#X connect 11 0 10 1;
-#X connect 12 0 9 0;
-#X connect 13 0 10 0;
-#X connect 14 0 13 0;
-#X connect 15 0 9 0;
-#X connect 18 0 0 0;
-#X connect 20 0 0 0;
-#X connect 23 0 21 0;
-#X connect 25 0 21 0;
-#X connect 26 0 21 0;
-#X connect 27 0 0 0;
-#X connect 28 0 27 0;
-#X connect 31 0 21 0;
+#X connect 7 0 8 0;
+#X connect 7 0 9 0;
+#X connect 8 0 7 1;
+#X connect 9 0 20 0;
+#X connect 10 0 7 0;
+#X connect 11 0 10 0;
+#X connect 12 0 18 0;
+#X connect 13 0 18 0;
+#X connect 15 0 19 0;
+#X connect 21 0 23 0;
+#X connect 22 0 23 0;
+#X connect 26 0 29 0;
+#X connect 27 0 29 0;
+#X connect 28 0 26 0;
diff --git a/tracker/tracker.c b/tracker/tracker.c
index f768290..b5a4b94 100644
--- a/tracker/tracker.c
+++ b/tracker/tracker.c
@@ -35,19 +35,50 @@ static t_symbol* keyname_sym;
#define MARGIN_X 3
#define MARGIN_Y 2
+#define CHR_EDIT "<"
+#define CHR_NORM " "
+#define DIGITS_MIN 1
+#define DIGITS_MAX 10
+
+static void tracker_clip_row_col(t_tracker* x, t_int* pr, t_int* pc) {
+ if((*pr) < 0) {
+ (*pr) = x->x_rows - (((-(*pr) - 1) % x->x_rows) + 1);
+ } else {
+ (*pr) = (*pr) % x->x_rows;
+ }
+ if((*pc) < 0) {
+ (*pc) = x->x_columns - (((-(*pc) - 1) % x->x_columns) + 1);
+ } else {
+ (*pc) = (*pc) % x->x_columns;
+ }
+}
+
+static t_float tracker_data_get(t_tracker* x, t_floatarg r, t_floatarg c) {
+ t_int ir = (t_int)r;
+ t_int ic = (t_int)c;
+ tracker_clip_row_col(x, &ir, &ic);
+ return x->x_data[(int)ir][(int)ic];
+}
+
+static void tracker_data_set(t_tracker* x, t_floatarg r, t_floatarg c, t_floatarg d) {
+ t_int ir = (t_int)r;
+ t_int ic = (t_int)c;
+ tracker_clip_row_col(x, &ir, &ic);
+ x->x_data[(int)ir][(int)ic] = d;
+}
static const char* tracker_isedititem(t_tracker* x, int r, int c) {
if(x->x_active_row == r && x->x_active_row >= 0 &&
x->x_active_column == c && x->x_active_column >= 0 &&
- x->x_buf[0]) return ">";
- else return "";
+ x->x_buf[0]) return CHR_EDIT;
+ else return CHR_NORM;
}
static int tracker_getdisplayval(t_tracker* x, int r, int c) {
- if(tracker_isedititem(x, r, c) == ">") {
+ if(tracker_isedititem(x, r, c) == CHR_EDIT) {
return atoi(x->x_buf);
} else {
- return x->x_data[r][c];
+ return tracker_data_get(x, r, c);
}
}
@@ -60,7 +91,7 @@ static void tracker_draw_new(t_tracker* x, t_glist* glist) {
sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #dddddd -outline {} -tags {%xCURSOR}\n", canvas, 0, 0, 0, 0, x);
for(r = 0; r < x->x_rows; r++) {
for(c = 0; c < x->x_columns; c++) {
- sys_vgui(".x%x.c create text %d %d -text %d%s -font -*-courier-bold--normal--%d-* -anchor nw -tags {%xTEXT %xTEXT.%d.%d} -fill black\n", canvas, text_xpix(&x->x_obj, glist)+c*x->x_cell_width+MARGIN_X, text_ypix(&x->x_obj, glist)+r*x->x_cell_height+MARGIN_Y, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c), glist_getfont(glist), x, x, r, c);
+ sys_vgui(".x%x.c create text %d %d -text {%d%s} -font -*-courier-bold--normal--%d-* -anchor ne -tags {%xTEXT %xTEXT.%d.%d} -fill black\n", canvas, text_xpix(&x->x_obj, glist)+(c+1)*x->x_cell_width+MARGIN_X, text_ypix(&x->x_obj, glist)+r*x->x_cell_height+MARGIN_Y, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c), glist_getfont(glist), x, x, r, c);
}
}
//canvas_fixlinesfor(canvas, (t_text*)x);
@@ -72,24 +103,30 @@ static void tracker_draw_update(t_tracker* x) {
t_canvas* canvas = glist_getcanvas(x->x_glist);
for(r = 0; r < x->x_rows; r++) {
for(c = 0; c < x->x_columns; c++) {
- sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text %d%s\n", canvas, x, r, c, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c));
+ sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text {%d%s}\n", canvas, x, r, c, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c));
}
}
canvas_fixlinesfor(canvas, (t_text*)x);
}
-static void tracker_draw_update_row(t_tracker* x, int r) {
+static void tracker_draw_update_row(t_tracker* x, t_floatarg r) {
+ t_int ir = (t_int)r;
+ t_int ic = 0;
+ tracker_clip_row_col(x, &ir, &ic);
int c;
t_canvas* canvas = glist_getcanvas(x->x_glist);
for(c = 0; c < x->x_columns; c++) {
- sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text %d%s\n", canvas, x, r, c, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c));
+ sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text {%d%s}\n", canvas, x, ir, c, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c));
}
canvas_fixlinesfor(canvas, (t_text*)x);
}
-static void tracker_draw_update_single(t_tracker* x, int r, int c) {
+static void tracker_draw_update_single(t_tracker* x, t_floatarg r, t_floatarg c) {
+ t_int ir = (t_int)r;
+ t_int ic = (t_int)c;
+ tracker_clip_row_col(x, &ir, &ic);
t_canvas* canvas = glist_getcanvas(x->x_glist);
- sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text %d%s\n", canvas, x, r, c, tracker_getdisplayval(x, r, c), tracker_isedititem(x, r, c));
+ sys_vgui(".x%x.c itemconfigure %xTEXT.%d.%d -text {%d%s}\n", canvas, x, ir, ic, tracker_getdisplayval(x, ir, ic), tracker_isedititem(x, ir, ic));
canvas_fixlinesfor(canvas, (t_text*)x);
}
@@ -114,7 +151,7 @@ static void tracker_draw_move(t_tracker* x, t_glist* glist) {
}
for(r = 0; r < x->x_rows; r++) {
for(c = 0; c < x->x_columns; c++) {
- sys_vgui(".x%x.c coords %xTEXT.%d.%d %d %d\n", canvas, x, r, c, text_xpix(&x->x_obj, glist)+c*x->x_cell_width+MARGIN_X, text_ypix(&x->x_obj, glist)+r*x->x_cell_height+MARGIN_Y);
+ sys_vgui(".x%x.c coords %xTEXT.%d.%d %d %d\n", canvas, x, r, c, text_xpix(&x->x_obj, glist)+(c+1)*x->x_cell_width+MARGIN_X, text_ypix(&x->x_obj, glist)+r*x->x_cell_height+MARGIN_Y);
}
}
canvas_fixlinesfor(canvas, (t_text*)x);
@@ -166,7 +203,7 @@ static void tracker_save(t_gobj* z, t_binbuf* b) {
/* save data: */
for (ei = 0; ei < x->x_rows; ei++) {
for (gi = 0; gi < x->x_columns; gi++) {
- binbuf_addv(b, "i", (int)x->x_data[ei][gi]);
+ binbuf_addv(b, "i", (int)tracker_data_get(x, ei, gi));
}
}
} else {
@@ -189,9 +226,9 @@ static void tracker_properties(t_gobj* z, t_glist* owner) {
char buf[800];
t_tracker* x = (t_tracker*)z;
- sprintf(buf, "pdtk_tracker_dialog %%s %d %d %d {%s} {%s}\n",
+ sprintf(buf, "pdtk_tracker_dialog %%s %d %d %d %d {%s} {%s}\n",
(int)x->x_columns, (int)x->x_rows,
- (int)x->b_save_data,
+ (int)x->b_save_data, (int)x->x_ndigits,
x->s_send->s_name, x->s_recv->s_name
);
//post("buf=%s", buf);
@@ -260,6 +297,7 @@ static void tracker_key(void* z, t_floatarg fkey) {
if(x->x_active_row >= 0 && x->x_active_column >= 0) {
int oldr,oldc;
tracker_setitem(x, x->x_active_row, x->x_active_column, n);
+ tracker_changenotify(x, x->x_active_row, x->x_active_column);
tracker_reset_buffer(x);
tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
//tracker_select_item(x, -1, -1);
@@ -290,14 +328,12 @@ static void tracker_key(void* z, t_floatarg fkey) {
}
static void tracker_motion(t_tracker* x, t_floatarg dx, t_floatarg dy) {
- if(x->x_active_row >= 0 && x->x_active_column >= 0) {
- if(dy == 1) {
- x->x_data[x->x_active_row][x->x_active_column]--;
- tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
- } else if(dy == -1) {
- x->x_data[x->x_active_row][x->x_active_column]++;
- tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
- }
+ if(x->x_active_row >= 0 && x->x_active_column >= 0 && dy != 0) {
+ t_float d = tracker_data_get(x, x->x_active_row, x->x_active_column);
+ d -= dy;
+ tracker_data_set(x, x->x_active_row, x->x_active_column, d);
+ tracker_changenotify(x, x->x_active_row, x->x_active_column);
+ tracker_draw_update_single(x, x->x_active_row, x->x_active_column);
}
}
@@ -395,6 +431,14 @@ static void tracker_gresize(t_tracker* x, t_floatarg newrows, t_floatarg newcols
canvas_fixlinesfor(canvas, (t_text*)x);
}
+static void tracker_gdigits(t_tracker* x, t_floatarg d) {
+ x->x_ndigits = (int)d;
+ if(x->x_ndigits < DIGITS_MIN) x->x_ndigits = DIGITS_MIN;
+ if(x->x_ndigits > DIGITS_MAX) x->x_ndigits = DIGITS_MAX;
+ tracker_vis((t_gobj*)x, x->x_glist, 0);
+ tracker_vis((t_gobj*)x, x->x_glist, 1);
+}
+
static void tracker_free(t_tracker* x) {
int ei;
for(ei = 0; ei < x->x_rows; ei++) {
@@ -416,6 +460,7 @@ static void tracker_set_recv(t_tracker* x, t_symbol *s) {
pd_unbind(&x->x_obj.ob_pd, x->s_recv);
x->s_recv = s;
+ //x->s_recv_r = canvas_realizedollar(glist_getcanvas(x->x_glist), s);
pd_bind(&x->x_obj.ob_pd, s);
}
@@ -442,20 +487,14 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
x->x_ndigits = 3;
x->x_cursor_pos = -1;
x->b_cursor = 0;
- x->b_save_data = 0;
+ x->b_save_data = 1;
x->s_send = gensym("");
x->s_recv = gensym("");
- int cols = 0, rows = 0;
+ int cols = 10, rows = 10;
int got_data = 0;
- if(argc == 0) {
- // set default values
- cols = 10;
- rows = 10;
- tracker_resize(x, rows, cols);
- x->b_save_data = 1;
- } else {
+ if(argc > 0) {
#define ARG_CHECK_LOOP_BEGIN while(ei < argc) { if(0) {}
#define ARG_CHECK_LOOP_END }
#define MATCH_ARG(sz) else if(argv[ei].a_type == A_SYMBOL && \
@@ -474,6 +513,12 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
ei++;
cols = (int)argv[ei++].a_w.w_float;
}
+ MATCH_ARG_T("-digits", A_FLOAT) {
+ ei++;
+ x->x_ndigits = (int)argv[ei++].a_w.w_float;
+ if(x->x_ndigits < DIGITS_MIN) x->x_ndigits = DIGITS_MIN;
+ if(x->x_ndigits > DIGITS_MAX) x->x_ndigits = DIGITS_MAX;
+ }
MATCH_ARG_T("-bg", A_FLOAT) { ei++; ei++; }
MATCH_ARG_T("-bg", A_SYMBOL) { ei++; ei++; }
MATCH_ARG_T("-fg", A_FLOAT) { ei++; ei++; }
@@ -510,10 +555,9 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
tracker_resize(x, rows, cols);
int j;
for(j = 0; j < (rows * cols); j++) {
- x->x_data[j / cols][j % cols] = argv[ei++].a_w.w_float;
+ tracker_data_set(x, j / cols, j % cols, argv[ei++].a_w.w_float);
}
got_data = 1;
- //x->b_save_data = 1;
tracker_set_saveflag(x, 1);
}
MATCH_FAILED {
@@ -523,14 +567,11 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
}
/*----------------*/ARG_CHECK_LOOP_END
}
- if(!got_data) tracker_resize(x, rows, cols);
+ if(!got_data) {
+ tracker_set_saveflag(x, 0);
+ tracker_resize(x, rows, cols);
+ }
- /*if(argc == (2+cols*rows)) {
- // restore saved data
- for(ei = 2; ei < argc; ei++) {
- x->x_data[(ei-2)/cols][(ei-2)%cols] = argv[ei].a_w.w_float;
- }
- }*/
x->x_glist = (t_glist*)canvas_getcurrent();
/* calculate font metrics */
@@ -546,8 +587,10 @@ static t_tracker* tracker_new(t_symbol* s, int argc, t_atom* argv) {
static void tracker_file_load(t_tracker* x, t_symbol* f) {
void* binbuf = binbuf_new();
t_canvas* canvas = glist_getcanvas(x->x_glist);
- if(binbuf_read_via_canvas(binbuf, f->s_name, canvas, 0))
- error("tracker: %s: read failed", f->s_name);
+ if(binbuf_read_via_canvas(binbuf, f->s_name, canvas, 0)) {
+ //error("tracker: %s: read failed", f->s_name);
+ return;
+ }
int argc = binbuf_getnatom(binbuf);
t_atom* argv = binbuf_getvec(binbuf);
@@ -564,8 +607,7 @@ static void tracker_file_load(t_tracker* x, t_symbol* f) {
int r,c;
for(r = 0; r < x->x_rows; r++) {
for(c = 0; c < x->x_columns; c++) {
- //x->x_data[r][c] = argv[2+r*cols+c].a_w.w_float;
- x->x_data[r][c] = argv[j++].a_w.w_float;
+ tracker_data_set(x, r, c, argv[j++].a_w.w_float);
}
}
tracker_gresize(x, rows, cols);
@@ -583,7 +625,7 @@ static void tracker_file_save(t_tracker* x, t_symbol* f) {
binbuf_addv(binbuf, "ii", x->x_rows, x->x_columns);
for(r = 0; r < x->x_rows; r++) {
for(c = 0; c < x->x_columns; c++) {
- binbuf_addv(binbuf, "i", (int)x->x_data[r][c]);
+ binbuf_addv(binbuf, "i", (int)tracker_data_get(x, r, c));
}
}
@@ -593,30 +635,49 @@ static void tracker_file_save(t_tracker* x, t_symbol* f) {
}
static void tracker_getrow(t_tracker* x, t_floatarg row) {
- int ei,introw;
+ int ei;
+ int argc = x->x_columns + 1;
+
+ t_atom *atombuf = (t_atom*)getbytes(sizeof(t_atom)*argc);
- introw = (int)row;
- introw = introw % x->x_rows;
- if(introw < 0) introw = 0;
+ SETSYMBOL(&atombuf[0], gensym("output"));
- t_atom *atombuf = (t_atom*)getbytes(sizeof(t_atom)*x->x_columns);
for(ei = 0; ei < x->x_columns; ei++) {
- SETFLOAT(&atombuf[ei], x->x_data[introw][ei]);
+ SETFLOAT(&atombuf[ei+1], tracker_data_get(x, row, ei));
}
- outlet_list(x->outlet0, &s_list, x->x_columns, atombuf);
+ outlet_list(x->outlet0, &s_list, argc, atombuf);
if(x->s_send != gensym(""))
- pd_list(x->s_send->s_thing, &s_list, x->x_columns, atombuf);
+ pd_list(x->s_send->s_thing, &s_list, argc, atombuf);
- freebytes(atombuf, sizeof(t_atom)*x->x_columns);
+ freebytes(atombuf, sizeof(t_atom)*(x->x_columns+1));
if(x->b_cursor) {
- x->x_cursor_pos = ((t_int)row) % x->x_rows;
- if(x->x_cursor_pos < 0) x->x_cursor_pos = 0;
+ t_int ir = (t_int)row;
+ t_int ic = 0;
+ tracker_clip_row_col(x, &ir, &ic);
+ x->x_cursor_pos = ir;
tracker_draw_update_cursor_pos(x);
}
}
+static void tracker_changenotify(t_tracker* x, t_floatarg row, t_floatarg col) {
+ int ei = 0;
+ t_atom *atombuf = (t_atom*)getbytes(sizeof(t_atom)*5);
+
+ SETSYMBOL(&atombuf[ei], gensym("changenotify")); ei++;
+ SETSYMBOL(&atombuf[ei], gensym("set")); ei++;
+ SETFLOAT(&atombuf[ei], row); ei++;
+ SETFLOAT(&atombuf[ei], col); ei++;
+ SETFLOAT(&atombuf[ei], tracker_data_get(x, row, col)); ei++;
+
+ outlet_list(x->outlet0, &s_list, ei, atombuf);
+ if(x->s_send != gensym(""))
+ pd_list(x->s_send->s_thing, &s_list, ei, atombuf);
+
+ freebytes(atombuf, sizeof(t_atom)*ei);
+}
+
static void tracker_toggle_cursor(t_tracker* x, t_floatarg b) {
x->b_cursor = (int)(b == 0 ? 0 : 1);
tracker_draw_update_cursor_pos(x);
@@ -627,57 +688,32 @@ static void tracker_setrow(t_tracker* x, t_symbol* s, int argc, t_atom* argv) {
post("tracker: setrow: too few arguments");
return;
}
- int ei,introw;
-
- introw = (int)argv[0].a_w.w_float;
- introw = introw % x->x_rows;
- if(introw < 0) introw = 0;
-
+ int ei;
for(ei = 1; ei < argc; ei++) {
- if((ei-1) >= x->x_columns) break;
+ if((ei - 1) >= x->x_columns) break;
if(argv[ei].a_type == A_FLOAT) {
- x->x_data[introw][ei-1] = argv[ei].a_w.w_float;
+ tracker_data_set(x, argv[0].a_w.w_float, ei - 1, argv[ei].a_w.w_float);
} else {
post("tracker: warning: non-float atom converted to zero-value");
- x->x_data[introw][ei-1] = 0;
+ tracker_data_set(x, argv[0].a_w.w_float, ei - 1, 0);
}
}
-
- tracker_draw_update_row(x, introw);
+ tracker_draw_update_row(x, argv[0].a_w.w_float);
}
static void tracker_getitem(t_tracker* x, t_float row, t_float col) {
- t_atom a;
- int introw,intcol;
-
- introw = (int)row;
- introw = introw % x->x_rows;
- if(introw < 0) introw = 0;
- intcol = (int)col;
- intcol = intcol % x->x_columns;
- if(intcol < 0) intcol = 0;
-
- SETFLOAT(&a, x->x_data[introw][intcol]);
-
- outlet_list(x->outlet0, &s_list, 1, &a);
+ t_atom a[2];
+ SETSYMBOL(&a[0], gensym("output"));
+ SETFLOAT(&a[1], tracker_data_get(x, row, col));
+ outlet_list(x->outlet0, &s_list, 2, &a[0]);
if(x->s_send != gensym(""))
- pd_list(x->s_send->s_thing, &s_list, 1, &a);
+ pd_list(x->s_send->s_thing, &s_list, 2, &a[0]);
}
static void tracker_setitem(t_tracker* x, t_float row, t_float col, t_float val) {
- int introw,intcol;
-
- introw = (int)row;
- introw = introw % x->x_rows;
- if(introw < 0) introw = 0;
- intcol = (int)col;
- intcol = intcol % x->x_columns;
- if(intcol < 0) intcol = 0;
-
- x->x_data[introw][intcol] = val;
-
- tracker_draw_update_single(x, introw, intcol);
+ tracker_data_set(x, row, col, val);
+ tracker_draw_update_single(x, row, col);
}
static void tracker_list(t_tracker* x, t_symbol* s, int ac, t_atom* av) {
diff --git a/tracker/tracker.h b/tracker/tracker.h
index f32603d..98dad7e 100644
--- a/tracker/tracker.h
+++ b/tracker/tracker.h
@@ -60,6 +60,7 @@ static void tracker_setitem(t_tracker* x, t_float row, t_float col, t_float val)
static void tracker_motion(t_tracker* x, t_floatarg dx, t_floatarg dy);
static void tracker_select_item(t_tracker* x, int r, int c);
static void tracker_select_movecur(t_tracker* x, int dx, int dy);
+static void tracker_changenotify(t_tracker* x, t_floatarg row, t_floatarg col);
void tracker_setup(void);
#endif // __G_GRID_H
diff --git a/tracker/tracker.tk b/tracker/tracker.tk
index fcd226b..0c0ef52 100644
--- a/tracker/tracker.tk
+++ b/tracker/tracker.tk
@@ -42,7 +42,7 @@ proc tracker_ok {id} {
tracker_cancel $id
}
-proc pdtk_tracker_dialog {id width height saveflag ss rs} {
+proc pdtk_tracker_dialog {id width height saveflag digitw ss rs} {
set vid [string trimleft $id .]
set var_graph_width [concat graph_width_$vid]