aboutsummaryrefslogtreecommitdiff
path: root/composer/editor.tk
diff options
context:
space:
mode:
Diffstat (limited to 'composer/editor.tk')
-rw-r--r--composer/editor.tk46
1 files changed, 44 insertions, 2 deletions
diff --git a/composer/editor.tk b/composer/editor.tk
index 95c5731..4f816f0 100644
--- a/composer/editor.tk
+++ b/composer/editor.tk
@@ -257,6 +257,18 @@ namespace eval pd::composer {
return $n
}
+ proc checkColumnSizes {id} {
+ variable w
+ variable columnsizes
+ set newsz {}
+ # tktable width returns a list of pairs (!)
+ foreach pair [$w($id).t width] {lappend newsz {*}$pair}
+ if {$columnsizes($id) != $newsz} {
+ set columnsizes($id) $newsz
+ sendGui [editCommand meta track set colw {*}$newsz]
+ }
+ }
+
proc createMainWindow {id} {
debugPrint [info level 0]
variable currentpattern;
@@ -266,6 +278,7 @@ namespace eval pd::composer {
variable patterns
variable startup
variable showpattern
+ variable columnsizes
variable [getDataVar $id]
catch {destroy $w($id)}
@@ -322,6 +335,16 @@ namespace eval pd::composer {
-rowtagcommand "[namespace current]::rowTag $id"
#grid $w($id).t -row 10 -column 0 -sticky news
+ if {![llength [info procs ::tk::table::ChangeWidth_]]} {
+ rename ::tk::table::ChangeWidth ::tk::table::ChangeWidth_
+ proc ::tk::table::ChangeWidth {w i a} "
+ ::pd::composer::checkColumnSizes $id
+ uplevel ::tk::table::ChangeWidth_ \$w \$i \$a
+ "
+ }
+
+ set columnsizes($id) {}
+
debugPrint "scrollbars"
grid [ttk::scrollbar $w($id).vscroll -orient vertical -command "$w($id).t yview"] -row 10 -column 1 -sticky ns
grid [ttk::scrollbar $w($id).hscroll -orient horizontal -command "$w($id).t xview"] -row 15 -column 0 -sticky ew
@@ -345,7 +368,7 @@ namespace eval pd::composer {
debugPrint "wm"
wm minsize $w($id) 300 150
- wm protocol $w($id) WM_DELETE_WINDOW [list [namespace current]::sendGui [editCommand editor 0]]
+ wm protocol $w($id) WM_DELETE_WINDOW [list [namespace current]::sendGui [editCommand editor hide]]
debugPrint "menu"
menu $w($id).m -tearoff 0
@@ -369,12 +392,12 @@ namespace eval pd::composer {
debugPrint "more-bind-events"
bind $w($id).t <ButtonPress-3> "$w($id).t activate @%x,%y; tk_popup $w($id).m %X %Y"
bind $w($id).t <Control-t> "switchColumnType $id"
+ bind $w($id).t <ButtonRelease-1> "[namespace current]::checkColumnSizes $id"
set startup($id) 1
set showpattern($id) 0
debugPrint "request-patterns"
sendGui [editCommand getpatterns]
- #sendGui [editCommand gettracks]
return $w($id)
}
@@ -583,10 +606,15 @@ namespace eval pd::composer {
set new_size [list $pat_rows $pat_cols]
debugPrint "got patternsize: '$pat_name' (size = $pat_rows x $pat_cols)"
if {![dict exists $size($id) $pat_name] || [dict get $size($id) $pat_name] != $new_size || $showpattern($id)} {
+ # TODO: uhm, does this really need to be inside the if???
dict set size($id) $pat_name $new_size
+
+ # request rows
for {set i 0} {$i < $pat_rows} {incr i} {
sendGui [editCommand getrow $pat_name $i]
}
+ # ...and column width
+ sendGui [editCommand meta track get colw none]
}
}
patternrow {
@@ -624,6 +652,20 @@ namespace eval pd::composer {
debugPrint "dataVar = [getDataVar $id $pat_name]"
setCellValueUI $id $pat_name $row_num $col_num $cell
}
+ meta {
+ switch -exact [lindex $args 1] {
+ track {
+ switch -exact [lindex $args 2] {
+ colw {
+ set a [lrange $args 3 end]
+ puts stderr "meta.track.colw a='$a'"
+ if {$a == {none}} return
+ $w($id).t width {*}$a
+ }
+ }
+ }
+ }
+ }
}
}
}