[PD-cvs] pd/src desire.tk,1.1.2.600.2.299,1.1.2.600.2.300
chunlee
chunlee at users.sourceforge.net
Tue Aug 7 07:51:26 CEST 2007
Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26078
Modified Files:
Tag: desiredata
desire.tk
Log Message:
Keyboard Macro part VI
Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.299
retrieving revision 1.1.2.600.2.300
diff -C2 -d -r1.1.2.600.2.299 -r1.1.2.600.2.300
*** desire.tk 7 Aug 2007 02:55:06 -0000 1.1.2.600.2.299
--- desire.tk 7 Aug 2007 05:51:22 -0000 1.1.2.600.2.300
***************
*** 2241,2244 ****
--- 2241,2265 ----
def Canvas popup_properties {} {CanvasPropertiesDialog new $self}
#-----------------------------------------------------------------------------------#
+ class_new Macro_Rect {View}
+
+ def Macro_Rect init {} {super; $self data= 0 0 0 0 blue}
+
+ def Macro_Rect data= {x1 y1 x2 y2 col} {
+ set @x1 $x1; set @y1 $y1
+ set @x2 $x2; set @y2 $y2
+ set @col $col
+ }
+
+ def Macro_Rect flash {x1 y1 x2 y2 col} {
+ $self data= $x1 $y1 $x2 $y2 $col
+ $self draw
+ after 500 $self erase
+ }
+
+ def Macro_Rect draw {} {
+ set @canvas [string range [focus] 1 [string first . [focus] 1]-1]
+ $self item MACRO rect [list $@x1 $@y1 $@x2 $@y2] -outline $@col
+ }
+
class_new Macro {EventHistory}
def Macro init {} {
***************
*** 2248,2251 ****
--- 2269,2275 ----
set @list {}
set @delay 200
+ set @offset_x 0
+ set @offset_y 0
+ set @rect [Macro_Rect new]
}
def Macro state= {val} {set @state $val; if {$val} {set @list {}; puts "start recording macro..."} {puts "end..."}}
***************
*** 2278,2283 ****
--- 2302,2329 ----
}
+ def Macro test_playable {x y} {
+ mset {macro_width macro_height} [$self calc_size]
+ set c [string range [focus] 0 [string first . [focus] 1]+1]
+ set cwidth [winfo width $c]; set cheight [winfo height $c]
+ set cx1 [$c canvasx 0]; set cy1 [$c canvasy 0]
+ set cx2 [$c canvasx $cwidth]; set cy2 [$c canvasy $cheight]
+ set new_x [expr $x+$macro_width]; set new_y [expr $y+$macro_height]
+ $@rect flash $x $y $new_x $new_y blue
+ if {$new_x > $cx2 || $new_x < $cx1 || $new_y > $cy2 || $new_y < $cy1} {
+ puts "Can't playback Macro:: outside of canvas area"
+ return
+ } else {$self idx= 0; $self offset $x $y; $self play [$self delay]}
+
+ }
+
+ def Macro offset {new_x new_y} {
+ mset {event widget X Y x y mode k kval} [lindex $@list 0]
+ set @offset_x [expr $new_x-$x]
+ set @offset_y [expr $new_y-$y]
+ }
+
def Macro play {delay} {
if {$@idx == [llength $@list]} {return}
+ $self test_canvas_size
set i 0
set focus [string range [focus] 1 [string first . [focus] 2]-1]
***************
*** 2292,2297 ****
}
if {$@idx < [llength $@list]} {
! after $delay [list $self run $event $name $X $Y $x $y]
}
}
--- 2338,2365 ----
}
if {$@idx < [llength $@list]} {
! after $delay [list $self run $event $name [expr $X+$@offset_x] [expr $Y+$@offset_y] \
! [expr $x+$@offset_x] [expr $y+$@offset_y]]
! }
! }
!
! def Macro calc_size {} {
! set x1 66666; set x2 0
! set y1 66666; set y2 0
! foreach step $@list {
! mset {event widget X Y x y mode k kval} $step
! set x1 [min $X $x1]; set x2 [max $x2 $X]
! set y1 [min $Y $y1]; set y2 [max $y2 $Y]
!
}
+ return [list [expr $x2-$x1] [expr $y2-$y1]]
+ }
+
+ def Macro test_canvas_size {} {
+ set c [string range [focus] 0 [string first . [focus] 1]+1]
+ set cwidth [winfo width $c]; set cheight [winfo height $c]
+ set cx1 [$c canvasx 0]; set cy1 [$c canvasy 0]
+ set cx2 [$c canvasx $cwidth]; set cy2 [$c canvasy $cheight]
+ mset {x1 y1 x2 y2} [$self calc_size]
+ puts "[winfo pointerxy $c]"
}
***************
*** 2309,2313 ****
def Canvas macro_toggle {} {if {![$::macro state]} {set ::macro_state 1} {$::macro state= 0; $::macro dump}}
! def Canvas macro_play {} {$::macro idx= 0; $::macro play [$::macro delay]}
def Canvas keyevent {} {
focus [$self widget]
--- 2377,2382 ----
def Canvas macro_toggle {} {if {![$::macro state]} {set ::macro_state 1} {$::macro state= 0; $::macro dump}}
! #def Canvas macro_play {} {puts ">> $@click_at <<"; $::macro idx= 0; $::macro play [$::macro delay]}
! def Canvas macro_play {} {mset {x y} $@click_at; $::macro test_playable $x $y}
def Canvas keyevent {} {
focus [$self widget]
More information about the Pd-cvs
mailing list