[PD-cvs] pd/src desire.tk,1.1.2.600.2.107,1.1.2.600.2.108

Mathieu Bouchard matju at users.sourceforge.net
Tue Dec 19 03:57:01 CET 2006


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

Modified Files:
      Tag: desiredata
	desire.tk 
Log Message:
class_new Tooltip


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.107
retrieving revision 1.1.2.600.2.108
diff -C2 -d -r1.1.2.600.2.107 -r1.1.2.600.2.108
*** desire.tk	19 Dec 2006 01:55:54 -0000	1.1.2.600.2.107
--- desire.tk	19 Dec 2006 02:56:57 -0000	1.1.2.600.2.108
***************
*** 2703,2706 ****
--- 2703,2707 ----
  
  def Canvas motion_checkhairtip {target x y} {
+ 	global tooltip
  	if {[$self look hairstate] && $@editmode} {
  		$@crosshair data= $x $y $target
***************
*** 2710,2714 ****
  	}
  	if {[$self look tooltip]} {
! 		if {!$::tooltip(stay) && [expr [distance $::tooltip(curpos) [list $x $y]] > 10]} {$self hide_tooltip}
  	}
  }
--- 2711,2718 ----
  	}
  	if {[$self look tooltip]} {
! 		if {$tooltip ne "" && ![$tooltip iserror] && [expr [distance [$tooltip curpos] [list $x $y]] > 10]} {
! 			$tooltip delete
! 			set tooltip ""
! 		}
  	}
  }
***************
*** 3810,3814 ****
  
  def Canvas key {x y key iso shift} {
! 	$self hide_tooltip
  	if {[$self focus] != ""} {
  		[$self focus] key $key $shift
--- 3814,3818 ----
  
  def Canvas key {x y key iso shift} {
! 	global tooltip; if {$tooltip ne ""} {$tooltip delete; set tooltip ""}
  	if {[$self focus] != ""} {
  		[$self focus] key $key $shift
***************
*** 5646,5687 ****
  #def Crosshair erase {} {$self item_delete VHAIR1; $self item_delete HHAIR1}
  
! ############ tooltips
  
! set tooltip(curpos) {-1000 -1000}
! set tooltip(canvas) ""
! set tooltip(visible) 0
! set tooltip(text) ""
! set tooltip(stay) 0
  
! def Canvas show_tooltip {x y text type {stay 0}} {
! 	global tooltip
! 	if {$tooltip(visible) && [string compare $text $tooltip(text)]==0} {return}
! 	$self hide_tooltip
! 	set x [expr $x+4]
! 	set c [$self widget]
! 	mset {x y} [lmap * [list $x $y] $@zoom]
! 	# it's wrong to hardcode "20" here
! 	switch $type { i {set y [expr $y - 20]} o {set y [expr $y + 20]} }
! 	if {$stay} {
  		set fg "#ffffff"; set bg "#dd0000"
  	} else {
  		set fg "#000000"; set bg "#ffffcc"
  	}
! 	$c create text $x $y -fill $fg -text $text -anchor w -tags tooltip_fg
! 	mset {x1 y1 x2 y2} [l+ [$c bbox tooltip_fg] [list -4 -4 +4 +4]]
! 	$c create rectangle $x1 $y1 $x2 $y2 -fill $bg -outline $fg -tags tooltip_bg
! 	$c lower tooltip_bg tooltip_fg
! 	set tooltip(curpos) $@curpos
! 	set tooltip(canvas) $self
! 	set tooltip(visible) 1
! 	set tooltip(text) $text
! 	set tooltip(stay) $stay
  }
  
! def Canvas hide_tooltip {} {
  	global tooltip
! 	set c [$self widget]
! 	$c delete tooltip_bg tooltip_fg
! 	set tooltip(visible) 0
  }
  
--- 5650,5703 ----
  #def Crosshair erase {} {$self item_delete VHAIR1; $self item_delete HHAIR1}
  
! ############ tooltips (only those that are drawn as canvas items)
  
! class_new Tooltip {View}
  
! def Tooltip init {canvas pos curpos text type iserror} {
! 	set @canvas $canvas
! 	set @pos $pos
! 	set @curpos $curpos
! 	set @text $text
! 	set @type $type
! 	set @iserror $iserror
! }
! 
! def Tooltip iserror {} {return $@iserror}
! def Tooltip curpos  {} {return $@curpos}
! def Tooltip text    {} {return $@text}
! 
! def Tooltip draw {} {
! 	set c [$@canvas widget]
! 	if {$@iserror} {
  		set fg "#ffffff"; set bg "#dd0000"
  	} else {
  		set fg "#000000"; set bg "#ffffcc"
  	}
! 	mset {x y} $@pos
! 	switch -- $@type {
! 		o {set ny [expr {$y+24}]}
! 		i {set ny [expr {$y-24}]}
! 	}
! 	$self item TEXT text [list [expr $x+12] $ny] -fill $fg -text $@text -anchor w
! 	mset {x1 y1 x2 y2} [l+ [$c bbox ${self}TEXT] [list -4 -4 +4 +4]]
! 	logvar x1 y1 x2 y2
! 	switch -- $@type {
! 	  o {set coords [list $x1 $y1 [expr $x1+8] $y1 $x $y [expr $x1+16] $y1 $x2 $y1 $x2 $y2 $x1 $y2 $x1 $y1]}
! 	  i {set coords [list $x1 $y1 $x2 $y1 $x2 $y2 [expr $x1+16] $y2 $x $y [expr $x1+8] $y2 $x1 $y2 $x1 $y1]}
! 	}
! 	$self item RECT polygon $coords -fill $bg -outline $fg
! 	$c lower ${self}RECT ${self}TEXT
  }
  
! # $c delete tooltip_bg tooltip_fg
! 
! set tooltip ""
! 
! def Canvas show_tooltip {x y text type {iserror 0}} {
  	global tooltip
! 	if {$tooltip ne "" && [$tooltip text] eq $text} {return}
! 	if {$tooltip ne ""} {$tooltip delete}
! 	set tooltip [Tooltip new $self [list $x $y] $@curpos $text $type $iserror]
! 	$tooltip draw
  }
  





More information about the Pd-cvs mailing list