aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2009-08-18 20:28:08 +0000
committermescalinum <mescalinum@users.sourceforge.net>2009-08-18 20:28:08 +0000
commit770632a4507eea0a6c7ba6f8b9381dd7dc6e2588 (patch)
tree783ddf27a08d3280fb9fc3e56661817d354351b7
parent9a6ab3b333e64c24ee86d929d9387ef367c76ce0 (diff)
small fixes:
- Switch to sendGui proc to support also desiredata and pd-devel - Handle null values correctly svn path=/trunk/externals/ffext/; revision=11950
-rw-r--r--composer/common.h1
-rw-r--r--composer/composer.c2
-rw-r--r--composer/pattern.c5
-rw-r--r--composer/track_proxy.c8
-rw-r--r--composer/window.tk53
5 files changed, 35 insertions, 34 deletions
diff --git a/composer/common.h b/composer/common.h
index b149265..bdfb99b 100644
--- a/composer/common.h
+++ b/composer/common.h
@@ -56,6 +56,7 @@
#define SONG_SELECTOR "#SONG"
extern t_symbol s_list;
+extern t_symbol s_empty;
struct _track;
struct _pattern;
diff --git a/composer/composer.c b/composer/composer.c
index 493ae37..b267137 100644
--- a/composer/composer.c
+++ b/composer/composer.c
@@ -35,10 +35,10 @@
ArrayListDeclare(songs, t_song*, int);
t_symbol s_list = {"list", 0, 0};
+t_symbol s_empty = {"empty", 0, 0};
void composer_setup(void) {
debugprint("loading composer library for pd");
-/* #include "window.tk2c" */
sys_vgui("source {window.tk}\n");
song_proxy_setup();
track_proxy_setup();
diff --git a/composer/pattern.c b/composer/pattern.c
index 134b802..cf1940b 100644
--- a/composer/pattern.c
+++ b/composer/pattern.c
@@ -88,10 +88,9 @@ static void pattern_resize(t_pattern *x, t_int newsize) {
static void pattern_new_empty_row(t_pattern* x) {
t_atom* rowdata = (t_atom*)getbytes(sizeof(t_atom) * x->x_track->x_ncolumns);
- SETSYMBOL(&(rowdata[0]), gensym("test"));
int j;
- for(j = 1; j < x->x_track->x_ncolumns; j++)
- SETFLOAT(&(rowdata[j]), j);
+ for(j = 0; j < x->x_track->x_ncolumns; j++)
+ SETSYMBOL(&(rowdata[j]), &s_empty);
ArrayListAdd(x->x_rows, t_atom*, rowdata);
}
diff --git a/composer/track_proxy.c b/composer/track_proxy.c
index 1f1d769..53fcb12 100644
--- a/composer/track_proxy.c
+++ b/composer/track_proxy.c
@@ -156,6 +156,7 @@ static void track_proxy_save(t_gobj* z, t_binbuf* b) {
switch(pat->x_rows[j][k].a_type) {
case A_FLOAT: binbuf_addv(b, "i", pat->x_rows[j][k].a_w.w_float); break;
case A_SYMBOL: binbuf_addv(b, "s", pat->x_rows[j][k].a_w.w_symbol); break;
+ case A_NULL: binbuf_addv(b, "s", gensym("empty")); break;
default: binbuf_addv(b, "s", gensym("?")); break;
}
}
@@ -297,9 +298,6 @@ static void track_proxy_editcmd(t_track_proxy* x, t_symbol* s_, int argc, t_atom
} else if(s == gensym("addpattern")) {
p = track_proxy_addpattern(x, s1, f2);
if(p) {
- debugprint("BAMBOLOOOOOO");
- //for(i = 0; i < p->x_rows_count; i++)
- // track_proxy_sendgui(x, gensym("row"), x->x_track->x_ncolumns + 2, track_proxy_getrow_with_header(x, p->x_name, i));
track_proxy_sendgui_pattern_names(x);
}
} else if(s == gensym("removepattern")) {
@@ -320,8 +318,6 @@ static void track_proxy_editcmd(t_track_proxy* x, t_symbol* s_, int argc, t_atom
} else if(s == gensym("copypattern")) {
p = track_proxy_copypattern(x, s1, s2);
if(p) {
- //for(i = 0; i < p->x_rows_count; i++)
- // track_proxy_sendgui(x, gensym("row"), x->x_track->x_ncolumns + 2, track_proxy_getrow_with_header(x, p->x_name, i));
track_proxy_sendgui_pattern_names(x);
}
} else {
@@ -354,9 +350,11 @@ static void track_proxy_sendgui(t_track_proxy* x, t_symbol* s, int argc, t_atom*
}
}
if(strlen(buf) >= bufsz) {
+ debugprint("track: sendgui: message too long");
bug("track: sendgui: message too long");
return;
}
+ debugprint("pd::composer::dispatch %s %s", x->rcv->s_name, buf);
sys_vgui("pd::composer::dispatch %s %s\n", x->rcv->s_name, buf);
}
diff --git a/composer/window.tk b/composer/window.tk
index 7e6b3eb..ddda6ae 100644
--- a/composer/window.tk
+++ b/composer/window.tk
@@ -28,12 +28,6 @@ package require Tcl 8.5
package require Tk 8.5
package require Tktable 2.9
-if {1 || ![info exists pd] && [info exists netsend]} {
- set ::sendgui "netsend"
-} else {
- set ::sendgui "pd"
-}
-
namespace eval pd::composer {
variable debug
variable w
@@ -59,6 +53,14 @@ namespace eval pd::composer {
if {$debug} {puts stderr "composer-TCL: $args"}
}
+ proc sendGui {what} {
+ debugPrint "sendGui $what"
+ catch {netsend $what}
+ lappend what \;\n
+ catch {pdsend $what}
+ catch {pd {*}$what}
+ }
+
proc createPattern {id name len} {
debugPrint [info level 0]
variable length
@@ -72,7 +74,7 @@ namespace eval pd::composer {
return -code error "Length must be positive integer"
}
- $::sendgui [concat $id EDIT addpattern $name $len \;]
+ sendGui [concat $id EDIT addpattern $name $len]
#lappend patterns($id) $name
#dict set length($id) $name $len
#$w($id).f.p configure -values $patterns($id)
@@ -83,7 +85,7 @@ namespace eval pd::composer {
variable length;
variable patterns;
- $::sendgui [concat $id EDIT removepattern $name \;]
+ sendGui [concat $id EDIT removepattern $name]
#set oldidx [lsearch -exact $patterns($id) $name]
#set length($id) [dict remove $length($id) $name]
@@ -99,7 +101,7 @@ namespace eval pd::composer {
#upvar 0 $::datavar($w)_$src SRC
#upvar 0 $::datavar($w)_$dst DST
- $::sendgui [concat $id EDIT copypattern $src $dst \;]
+ sendGui [concat $id EDIT copypattern $src $dst]
#createPattern $w $dst [dict get $length($id) $src]
#array set DST [array get SRC]
@@ -117,7 +119,7 @@ namespace eval pd::composer {
return -code error "Length must pe positive integer"
}
- $::sendgui [concat $id EDIT resizepattern $name $len \;]
+ sendGui [concat $id EDIT resizepattern $name $len]
#dict set length($id) $name $len
#if {$name == $currentpattern($id)} {
@@ -142,7 +144,7 @@ namespace eval pd::composer {
return -code error "No such pattern: '$name'"
}
- $::sendgui [concat $id EDIT renamepattern $name $newName \;]
+ sendGui [concat $id EDIT renamepattern $name $newName]
#lset patterns($id) $idx $newName
#array set DST [array get SRC]
@@ -166,7 +168,7 @@ namespace eval pd::composer {
proc displayPattern {id name} {
debugPrint "request-pattern-length"
- $::sendgui [concat $id EDIT getpatternlength $name \;]
+ sendGui [concat $id EDIT getpatternlength $name]
}
proc displayPattern_async {id name} {
@@ -212,7 +214,7 @@ namespace eval pd::composer {
}
proc rowTag {id r} {
- debugPrint [info level 0]
+ #debugPrint [info level 0]
if {$r % $::div1 == 0} {return "alt0"}
if {$r % $::div2 == 0} {return "alt1"}
}
@@ -228,7 +230,7 @@ namespace eval pd::composer {
proc edit {id r c bwrite value} {
# NOT USED
#if {$bwrite} {
- # $::sendgui [concat $id EDIT setcell $currentpattern($id) $r $c $value \;]
+ # sendGui [concat $id EDIT setcell $currentpattern($id) $r $c $value]
#} else {
#}
}
@@ -284,7 +286,7 @@ namespace eval pd::composer {
#$w($id).f.p configure -values $patterns($id)
debugPrint "request-patterns"
- $::sendgui [concat $id EDIT getpatterns \;]
+ sendGui [concat $id EDIT getpatterns]
debugPrint "bindevent"
bind $w($id).f.p <<ComboboxSelected>> "[namespace current]::displayCurrentPattern $id"
@@ -337,7 +339,7 @@ namespace eval pd::composer {
debugPrint "wm"
wm minsize $w($id) 300 150
- wm protocol $w($id) WM_DELETE_WINDOW "$::sendgui $id EDIT editor-close \\;"
+ wm protocol $w($id) WM_DELETE_WINDOW "[namespace current]::sendGui {$id EDIT editor-close}"
debugPrint "menu"
menu $w($id).m -tearoff 0
@@ -392,7 +394,7 @@ namespace eval pd::composer {
debugPrint [info level 0]
variable currentpattern
- $::sendgui [concat $id EDIT setcell $currentpattern($id) $row $col $newVal \;]
+ sendGui [concat $id EDIT setcell $currentpattern($id) $row $col $newVal]
return 1
}
@@ -529,6 +531,11 @@ namespace eval pd::composer {
destroy $w($id)
}
+ proc setCellValueUI {id pat r c v} {
+ upvar 0 [getDataVar $id $pat] data
+ set data($r,$c) [string map {empty {}} $v]
+ }
+
proc dispatch {id args} {
debugPrint [info level 0]
variable w
@@ -554,7 +561,7 @@ namespace eval pd::composer {
if {![dict exists $length($id) $pat_name] || [dict get $length($id) $pat_name] != $pat_length} {
dict set length($id) $pat_name $pat_length
for {set i 0} {$i < $pat_length} {incr i} {
- $::sendgui [concat $id EDIT getrow $pat_name $i \;]
+ sendGui [concat $id EDIT getrow $pat_name $i]
}
}
displayPattern_async $id $pat_name
@@ -568,12 +575,9 @@ namespace eval pd::composer {
}
set row [lrange $args 3 end]
debugPrint "got row: '$pat_name' ($row_num) {$row}"
- debugPrint "dataVar = [getDataVar $id $pat_name]"
- upvar 0 [getDataVar $id $pat_name] data
- set data($row_num,-1) [expr {1+$row_num}]
+ setCellValueUI $id $pat_name $row_num -1 [expr {1+$row_num}]
for {set i 0} {$i < [llength $row]} {incr i} {
- debugPrint "set data($row_num,$i) [lindex $row $i]"
- set data($row_num,$i) [lindex $row $i]
+ setCellValueUI $id $pat_name $row_num $i [lindex $row $i]
}
if {$row_num + 1 == [dict get $length($id) $pat_name]} {
#refreshGrid $id
@@ -591,8 +595,7 @@ namespace eval pd::composer {
set cell [lindex $args 4]
debugPrint "got cell: '$pat_name' ($row_num,$col_num) {$cell}"
debugPrint "dataVar = [getDataVar $id $pat_name]"
- upvar 0 [getDataVar $id $pat_name] data
- set data($row_num,$col_num) $cell
+ setCellValueUI $id $pat_name $row_num $col_num $cell
}
}
}