Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13366
Modified Files: Tag: devel_0_39 desire.tk Log Message: Canvas subpatcherize
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.543 retrieving revision 1.1.2.544 diff -C2 -d -r1.1.2.543 -r1.1.2.544 *** desire.tk 2 Nov 2006 00:41:41 -0000 1.1.2.543 --- desire.tk 2 Nov 2006 18:20:59 -0000 1.1.2.544 *************** *** 234,238 ****
set clipboard [Clipboard1 new] ! #-----------------------------------------------------------------------------------# # adapted from matju's MetaRuby (UndoQueue.rb) --- 234,242 ----
set clipboard [Clipboard1 new] ! #-----------------------------------------------------------------------------------# ! #used during subpatcherize ! set subpatcherize(pack) 0 ! set subpatcherize(paste) 0 ! set subpatcherize(parent) 0 #-----------------------------------------------------------------------------------# # adapted from matju's MetaRuby (UndoQueue.rb) *************** *** 1456,1459 **** --- 1460,1464 ---- if {![winfo exists .$self.c]} {$self init_window} } + $self subpatcherize_copy_objs } coords { *************** *** 1932,1935 **** --- 1937,1941 ---- if {$@edit} {return} set c [$@canvas widget] + if {[lsearch [$@canvas selection] $self] < 0} {$@canvas selection+= $self} set t $c.${self}text if {[info exists @isnew]} {set @isnew 0} *************** *** 1957,1962 **** -bg [$c itemcget ${self}BASE -fill] -borderwidth 0 -highlightthickness 0\ -font $font_str -fg [$self look fg] -insertbackground [$self look fg] ! bind $t <Key> "$self resize %K; $self key %W %x %y %K %A 0" ! bind $t <Control-Return> "$self key %W %x %y 10 %A 0" bind $t <Return> "$self unedit" bind $t <Escape> "$self unedit 0" --- 1963,1968 ---- -bg [$c itemcget ${self}BASE -fill] -borderwidth 0 -highlightthickness 0\ -font $font_str -fg [$self look fg] -insertbackground [$self look fg] ! bind $t <Key> "$self resize %K; $self key_input %W %x %y %K %A 0" ! bind $t <Control-Return> "$self key_input %W %x %y 10 %A 0" bind $t <Return> "$self unedit" bind $t <Escape> "$self unedit 0" *************** *** 1979,1983 **** }
! def TextBox key {widget x y key iso shift} { after 0 "$self after_key $widget" set c [$@canvas widget] --- 1985,1989 ---- }
! def TextBox key_input {widget x y key iso shift} { after 0 "$self after_key $widget" set c [$@canvas widget] *************** *** 2327,2336 **** $x delete } ! set $@selection_wire {} # before obj is deleted, it will be selected, therefore # $@obj_in_edit != {}, so don't forget to set it to {}. # needs to handle obj_in_edit and selection!!! set @obj_in_edit {} ! set @selection {} }
--- 2333,2344 ---- $x delete } ! #set $@selection_wire {} # before obj is deleted, it will be selected, therefore # $@obj_in_edit != {}, so don't forget to set it to {}. # needs to handle obj_in_edit and selection!!! set @obj_in_edit {} ! #set @selection {} ! $self selection= {} ! $self selection_wire= {} }
*************** *** 2721,2728 ****
def Canvas do_paste {offset} { ! global clipboard set n [llength $@children] ;# is a racecondition set m [llength $@wires] ;#let's race!! ! foreach line [split [$clipboard value] ";"] { if {[llength $line] == 0} {continue} switch -- [lindex $line 0] { --- 2729,2739 ----
def Canvas do_paste {offset} { ! global clipboard subpatcherize set n [llength $@children] ;# is a racecondition set m [llength $@wires] ;#let's race!! ! set clips [split [$clipboard value] ";"] ! set clips_len [llength $clips] ! set i 0; ! foreach line $clips { if {[llength $line] == 0} {continue} switch -- [lindex $line 0] { *************** *** 2747,2755 **** } } ! #after 1 "$self paste2 $n" ! after 300 "$self do_paste2 $n $m" ;# racecondition } # part two def Canvas do_paste2 {n m} { $self selection= [lrange [$self children] $n end] $self selection_wire= [lrange [$self wires] $m end] --- 2758,2770 ---- } } ! if {!$subpatcherize(paste)} { ! after 300 "$self do_paste2 $n $m" ;# racecondition ! } else { ! set subpatcherize(paste) 0 ! } } # part two def Canvas do_paste2 {n m} { + global subpatcherize $self selection= [lrange [$self children] $n end] $self selection_wire= [lrange [$self wires] $m end] *************** *** 2896,2899 **** --- 2911,2947 ---- }
+ def Canvas subpatcherize {} { + global subpatcherize + if {![llength $@selection]} {return} + set x 0; set y 0 + foreach obj $@selection { + mset {x1 y1} [$obj xy] + set x [expr $x + $x1] + set y [expr $y + $y1] + } + set x [expr $x / [llength $@selection]] + set y [expr $y / [llength $@selection]] + set construct "#X obj $x $y pd foo" + set subpatcherize(pack) 1 + set subpatcherize(parent) $self + $self cut + pd .$self object_insert [expr [llength $@children] - 1] $construct + + } + + def Canvas subpatcherize_copy_objs {} { + global subpatcherize + if {$self == $subpatcherize(parent)} {return} + if {$subpatcherize(pack)} { + puts " ------------ ------------- ----------E" + set subpatcherize(paste) 1 + $self paste + after 200 $self edit + set c $@canvas + set subpatcherize(pack) 0 + } + + } + def Canvas end_action {} { switch -- $@action { *************** *** 5751,5758 ****
def Completion cancel {} { ! bind $@textbox <Key> "$@textself key %W %x %y %K %A 0" ! bind $@textbox <Control-Return> "$@textself key %W %x %y 10 %A 0" bind $@textbox <Return> "$@textself unedit" ! bind $@textbox <Tab> "$@textself key %W %x %y %K %A 0" focus $@textbox; $self delete } --- 5799,5806 ----
def Completion cancel {} { ! bind $@textbox <Key> "$@textself resize %K; $@textself key_input %W %x %y %K %A 0" ! bind $@textbox <Control-Return> "$@textself key_input %W %x %y 10 %A 0" bind $@textbox <Return> "$@textself unedit" ! bind $@textbox <Tab> "$@textself key_input %W %x %y %K %A 0" focus $@textbox; $self delete } *************** *** 7293,7301 ****
def Canvas deconstruct {} { ! ##N canvas 0 0 450 300 qwer 0; ! #.x82a9d10 object_insert 0 #X obj 193 85 t ! #error "Canvas deconstruct: that's a feature request" ! puts " <><> [concat [list #X obj $@x1 $@y1] $@text] <><>" ! return [concat [list #X obj $@x1 $@y1] $@text] } --- 7341,7346 ----
def Canvas deconstruct {} { ! error "Canvas deconstruct: that's a feature request" ! #return [concat [list #X obj $@x1 $@y1] $@text] }