From 79f9a1ed2fa32cf65303b7448ed454150720eb73 Mon Sep 17 00:00:00 2001 From: carmen rocco Date: Sun, 19 Jun 2005 02:21:14 +0000 Subject: ... svn path=/trunk/; revision=3211 --- extensions/gui/ix/mat-demo.pd | 51 +++++++++++++++++++++++-------------------- extensions/gui/ix/mat.wid | 50 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 25 deletions(-) diff --git a/extensions/gui/ix/mat-demo.pd b/extensions/gui/ix/mat-demo.pd index f96bfefd..eda61bc5 100755 --- a/extensions/gui/ix/mat-demo.pd +++ b/extensions/gui/ix/mat-demo.pd @@ -1,5 +1,5 @@ -#N canvas 1036 0 914 718 12; -#X obj 17 22 widget mat n1 #w 881 #bg gray83 #divX 8 #divY 5 #h 494 +#N canvas 80 85 910 775 12; +#X obj 15 29 widget mat n1 #w 881 #bg gray83 #divX 8 #divY 5 #h 494 #Yb 1 #Ya 88 #qYv 2 #qYa 8 #ln white; #X msg 1080 -13 -height 26 -width 26 -bg gray95; #X msg 184 648 redefine; @@ -7,13 +7,12 @@ #X obj 95 644 + 36; #X obj 587 565 rr ss; #X obj 587 546 rg; -#X obj 27 538 route note; -#X obj 19 603 unpack f f f; +#X obj 20 603 unpack f f f; #X obj 47 638 * 127; #X obj 26 668 pack f f f; #X obj 49 692 makenote 99 250; #X obj 102 728 noteout; -#X obj 108 584 rp ss kbd; +#X obj 77 559 rp ss kbd; #X obj 158 583 rp ss kb2; #X obj 138 537 widget kbd k1 #bg blue #fg green #ln gray50 -height 32; @@ -23,28 +22,32 @@ #X obj 108 603 Append 1; #X obj 158 602 Append 2; #X msg 74 575 1; -#X connect 0 0 7 0; +#X obj 3 533 widget dd dd1 -bg green -fg red; +#X obj 3 493 a2l; +#X obj 3 549 widget dd s2 #symbol 0; +#X connect 0 0 21 0; #X connect 2 0 0 0; -#X connect 3 0 12 1; -#X connect 4 0 12 0; +#X connect 3 0 11 1; +#X connect 4 0 11 0; #X connect 6 0 5 0; -#X connect 7 0 8 0; -#X connect 8 0 10 0; -#X connect 8 1 9 0; -#X connect 8 2 10 2; -#X connect 9 0 10 1; +#X connect 7 0 9 0; +#X connect 7 1 8 0; +#X connect 7 2 9 2; +#X connect 8 0 9 1; +#X connect 9 0 10 0; #X connect 10 0 11 0; -#X connect 11 0 12 0; -#X connect 11 1 12 1; +#X connect 10 1 11 1; +#X connect 12 0 17 0; #X connect 13 0 18 0; -#X connect 14 0 19 0; +#X connect 14 0 17 0; +#X connect 14 0 12 0; #X connect 15 0 18 0; #X connect 15 0 13 0; -#X connect 16 0 19 0; -#X connect 16 0 14 0; -#X connect 17 0 4 0; -#X connect 17 1 3 0; -#X connect 17 2 12 2; -#X connect 18 0 17 0; -#X connect 19 0 17 0; -#X connect 20 0 10 2; +#X connect 16 0 4 0; +#X connect 16 1 3 0; +#X connect 16 2 11 2; +#X connect 17 0 16 0; +#X connect 18 0 16 0; +#X connect 19 0 9 2; +#X connect 21 0 20 0; +#X connect 22 0 20 0; diff --git a/extensions/gui/ix/mat.wid b/extensions/gui/ix/mat.wid index d77b541d..f8246d6c 100755 --- a/extensions/gui/ix/mat.wid +++ b/extensions/gui/ix/mat.wid @@ -7,9 +7,19 @@ namespace eval ::ix { set len [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]] set vel [$p.m itemcget $item -fillopacity] pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len \;]} - + namespace eval actions { + proc action {p t o} {puts gah} + proc draw {p t o} {puts draw} + proc resize_canvas {p t o} {} + proc move_canvas {p t o} {puts cvda} + proc move_object {p t o} { + puts hiihect + } + } proc mat_click {m button action p t x y} { variable _ + set a [$p.m itemcget mode -text] + eval actions::$a $p $t o switch $m { control {mat_draw $action $p $t $x $y} "" { @@ -21,12 +31,19 @@ namespace eval ::ix { mat_note $p $t $item } } + if {$clicked ne "" && [lindex [$p.m itemcget $item -tags] 0] eq "item"} { + mat_mode $p $t {move_object} + } {mat_mode $p $t {move_canvas}} + set junk "" + foreach cfg [$p.m itemconfigure $clicked] {set junk "$junk\n$cfg"} + mat_info $p $t $junk } first { # if {$clicked ne ""} { set _($t:cl) $clicked # } foreach xy {x y} {set _($t:f$xy) [set $xy]} + switch $button {2 {mat_mode $p $t resize_canvas}} } motion { set mx [expr $x - $_($t:cx)] @@ -81,6 +98,11 @@ namespace eval ::ix { } } } + release { + switch $button { + 2 {mat_mode $p $t move_canvas} + } + } } foreach xy {x y} {set _($t:c$xy) [set $xy]} } @@ -121,6 +143,28 @@ namespace eval ::ix { set _($t:ya) $_($t:yao);set _($t:yb) $_($t:ybo);set _($t:xa) $_($t:xao);set _($t:xb) $_($t:xbo) mat_gridlines $p $t} + proc mat_key {p t k b} { + puts $k + switch $b { + 1 { + switch $k { + 37 {mat_mode $p $t draw} + } + } + 0 { + switch $k { + 37 {mat_mode $p $t {move_canvas}} + } + } + } + } + proc mat_mode {p t m} { + $p.m itemconfigure mode -text $m + } + proc mat_info {p t m} { + $p.m itemconfigure info -text $m + } + proc mat_new {path target w h bg ln xa xb ya yb qx qy} { variable _ set i 0 @@ -129,6 +173,8 @@ namespace eval ::ix { if {[winfo exists $path.m] != 1} { canvas $path.m -bg $bg -width $w -height $h pack $path.m -side left + bind $path.m "::ix::mat_key $path $target %k 1" + bind $path.m "::ix::mat_key $path $target %k 0" bind $path.m "::ix::mat_click {} 0 hover $path $target %x %y" foreach m {"Control-" "" "Shift-"} { foreach bn {1 2 3} { @@ -137,6 +183,8 @@ namespace eval ::ix { bind $path.m <$m[lindex [lindex $b $ba] 0]> "::ix::mat_click [list [string tolower [string trimright $m -1]]] $bn [lindex [lindex $b $ba] 1] $path $target %x %y"}}} set bd [expr {[$path cget -bd] * 2}] $path configure -bg gray -width [expr [winfo width $path.m] + $bd] -height [expr [winfo height $path.m] + $bd] + $path.m create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text action + $path.m create text {20 32} -fill gray49 -justify left -anchor nw -font {{bitstream vera sans} 12} -tags info mat_gridlines $path $target}} proc mat_gridlines {path target} { -- cgit v1.2.1