[PD-cvs] pd/src desire.tk,1.1.2.312,1.1.2.313

Mathieu Bouchard matju at users.sourceforge.net
Fri Aug 11 04:08:23 CEST 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14539

Modified Files:
      Tag: devel_0_39
	desire.tk 
Log Message:
new Ctrl+D duplicate


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.312
retrieving revision 1.1.2.313
diff -C2 -d -r1.1.2.312 -r1.1.2.313
*** desire.tk	11 Aug 2006 01:58:01 -0000	1.1.2.312
--- desire.tk	11 Aug 2006 02:08:21 -0000	1.1.2.313
***************
*** 195,198 ****
--- 195,199 ----
  # we might also use "man 3tk clipboard" in this specific case.
  
+ # uses system clipboard
  class_new Clipboard {Observable Thing}
  def Clipboard init   {{value ""}} {super; $self value= $value}
***************
*** 202,205 ****
--- 203,213 ----
  set clipboard [Clipboard new]
  
+ # uses string buffer (not system clipboard)
+ class_new Clipboard2 {Observable Thing}
+ def Clipboard2 init   {{value ""}} {super; $self value= $value}
+ def Clipboard2 value= {value} {set    @value $value; $self changed}
+ def Clipboard2 << {value}     {append @value $value; $self changed}
+ def Clipboard2 value {} {return $@value}
+ 
  #-----------------------------------------------------------------------------------#
  # adapted from matju's MetaRuby (UndoQueue.rb)
***************
*** 2068,2111 ****
  }
  
- #-----------------------------------------------------------------------------------#
- # duplication turns out to be somehow similar to file loading, where the duplicates
- # got added as children before they were born.... so be aware
- def* Canvas duplicate {} {
- 	global _ canvas
- 	set canvas(dup_wire_num) 0
- 	if {$@selection != ""} {
- 		# store the selected objects in canvas(dup_orig), which later will
- 		# be linked to the cuplicated object 
- 		set canvas(dup_orig) $@selection
- 		set dups $@selection
- 		set @selection {}
- 		foreach item $dups {
- 			$item selected?= 0
- 			mset {x1 y1} [$item xy]
- 			set x1 [expr $x1+15]
- 			set y1 [expr $y1+15]
- 			puts "dup class :::: $_($item:_class) :::: $_($item:class)"
- 			
- 			if {$_($item:_class) == "ObjectBox"} { 
- 			set name $_($item:text) 
- 			} else {
- 			set name $_($item:class)
- 			}
- 			set @duplicating 1 
- 			# not quite pretty, will rewrite when something better comes up
- 			switch $_($item:_class) {
- 			FloatAtom  {pd .$self  floatatom $x1 $y1 $_($item:text)}
- 			SymbolAtom {pd .$self symbolatom $x1 $y1}
- 			MessageBox {pd .$self        msg $x1 $y1 $item:text)}
- 			default    {pd .$self        obj $x1 $y1 $name}
- 			}
- 			
- 			#set dup_wires $_($item:wires)
- 		}
- 	
- 	}
- 
- }
- 
  def* Canvas duplicate_wire {} {
  	global _ canvas 
--- 2076,2079 ----
***************
*** 2138,2142 ****
  }
  
! def* Canvas copy {} {
  	global clipboard obj_index_sel
  	if {$@selection == ""} {return}
--- 2106,2110 ----
  }
  
! def Canvas copy {} {
  	global clipboard obj_index_sel
  	if {$@selection == ""} {return}
***************
*** 2145,2149 ****
  	#$clipboard canvas= $self
  	#$clipboard copy_times= 0
- 	#$self deconstruct_to $clipboard
  	array unset obj_index_sel $self:*
  	foreach child $@selection {
--- 2113,2116 ----
***************
*** 2160,2164 ****
  }
  
! def* Canvas paste {} {
  	global clipboard
  	set n [llength $@children] ;# is a racecondition
--- 2127,2132 ----
  }
  
! # todo: reimplement copy-count with 15px offset
! def Canvas paste {} {
  	global clipboard
  	set n [llength $@children] ;# is a racecondition
***************
*** 2185,2238 ****
  }
  # part two
! def* Canvas paste2 {n} {$self selection= [lrange [$self children] $n end]}
! 
! def* Canvas paste_OLD {} {
! 	global clipboard
! 	puts "***************************************"
! 	set windowx [winfo width .$self.c]
! 	set windowy [winfo height .$self.c]
! 	mset {x1off x2off } [.$self.c xview]
! 	mset {y1off y2off } [.$self.c yview]
! 	set offx [expr ($windowx * $x1off) / [expr $x2off - $x1off]]
! 	set offy [expr ($windowy * $y1off) / [expr $y2off - $y1off]]
! 	$self deselect_all
! 	set clipboard(copied_obj) ""
! 	if {$clipboard(orig_cpcanvas) != $self} { set clipboard(copy_times) 0 } else {incr clipboard(copy_times)}
! 	set notvisiblex 0
! 	set notvisibley 0
! 	set n 0
! 	
! 	foreach item $clipboard(objs) {
! 	mset {x1 y1} [$item xy]
! 	if {$x1 < $offx | $x1 > [expr $offx+$windowx]} {set notvisiblex 1}
! 	if {$y1 < $offx | $y1 > [expr $offx+$windowy]} {set notvisibley 1}
! 	if {$notvisiblex && $notvisibley} {incr n}
! 	}
! 	
! 	foreach item $clipboard(objs) {
! 	mset {x1 y1} [$item xy]
! 	if {$clipboard(orig_cpcanvas) != $self} {
! 		if {$n == [llength $clipboard(objs)]} {
! 		set x1 [expr $x1 + $offx +($clipboard(copy_times)*15)]
! 		set y1 [expr $y1 + $offy +($clipboard(copy_times)*15)]
! 		}
! 	
! 	} else {
! 		if {$n == [llength $clipboard(objs)]} {
! 			set x1 [expr $x1 + $offx +($clipboard(copy_times)*15)]
! 			set y1 [expr $y1 + $offy +($clipboard(copy_times)*15)]
! 		} else {
! 			set x1 [expr $x1+($clipboard(copy_times)*15)]
! 			set y1 [expr $y1+($clipboard(copy_times)*15)]
! 		}
! 	}
! 	if {$_($item:_class) == "Objectbox"} { 
! 	set name $_($item:text) } else {
! 	set name $_($item:class)
! 	}
! 	set clipboard(copying) 1
! 	pd .$self obj $x1 $y1 $name
! 	}
! }
  
  def* Canvas paste_wires {} {
--- 2153,2157 ----
  }
  # part two
! def Canvas paste2 {n} {$self selection= [lrange [$self children] $n end]}
  
  def* Canvas paste_wires {} {
***************
*** 2263,2268 ****
  }
  
! def* Canvas cut {} {
! 	puts "history::: $@history"
  	$@history atomically {
  		$self copy
--- 2182,2186 ----
  }
  
! def Canvas cut {} {
  	$@history atomically {
  		$self copy
***************
*** 2271,2275 ****
  }
  
! def* Canvas select_all {} {
  	foreach o $@children {$o selected?= 1}
  	foreach w $@wires {$w selected?= 1}
--- 2189,2202 ----
  }
  
! def Canvas duplicate {} {
! 	global clipboard
! 	set backup $clipboard
! 	set clipboard [Clipboard2 new]
! 	$self copy
! 	$self paste
! 	set clipboard $backup
! }
! 
! def Canvas select_all {} {
  	foreach o $@children {$o selected?= 1}
  	foreach w $@wires {$w selected?= 1}
***************
*** 2279,2283 ****
  }
  
! def* Canvas deselect_all {} {
  	foreach o $@selection {$o selected?= 0; puts "----------- deselecte $o"}
  	foreach w $@selection_wire {$w selected?= 0}
--- 2206,2210 ----
  }
  
! def Canvas deselect_all {} {
  	foreach o $@selection {$o selected?= 0; puts "----------- deselecte $o"}
  	foreach w $@selection_wire {$w selected?= 0}





More information about the Pd-cvs mailing list