> I have been trying what you have been posting, but I haven't found a  
> clean patch or pd.tk..  The standard format for submitting code to  
> most open source projects is a "diff -uw" patch.  That's the best way  
> to submit them if you want people to be able to read them, try them,  
> make sense of them, etc.  Check the patches in the patch tracker for  
> examples.  I find the easiest way to generate patches is to use "svn  
> diff"

please see attached patch. it applies cleanly against 0.41.4 extended as
well as 0.42.5 extended.

ico
--- pd.tk.old	2009-05-22 21:30:00.000000000 -0400
+++ pd.tk	2009-11-28 23:07:13.000000000 -0500
@@ -2122,29 +2122,76 @@
     global pdtk_canvas_mouseup_yminval
     global pdtk_canvas_mouseup_ymaxval
 
-    set size [$name bbox all]
-    if {$size != ""} {
+	#bbox all is not accurate enough
+	#particularly when using large iemlib objects
+	#so we calculate canvas size manually
+    #set size [$name bbox all]
+
+	#borrowed from http://wiki.tcl.tk/4844
+	set x1 1.0e30; set x2 -1.0e30 ;
+	set y1 1.0e30; set y2 -1.0e30 ;
+	foreach item [$name find all] {
+	    switch -exact [$name type $item] {
+			"arc" -
+			"line" -
+			"oval" -
+			"polygon" -
+			"rectangle" {
+				set coords [$name coords $item]
+				foreach {x y} $coords {
+					if { $x < $x1 } {set x1 $x}
+					if { $x > $x2 } {set x2 $x}
+					if { $y < $y1 } {set y1 $y}
+					if { $y > $y2 } {set y2 $y}
+				}
+			}
+	    }
+	}
+	
+	if {$x1 != 1.0e30} {
+
         set xminval 0
         set yminval 0
         set xmaxval 100
-        set ymaxval 100
-        set x1 [lindex $size 0]
-        set x2 [lindex $size 2]
-        set y1 [lindex $size 1]
-        set y2 [lindex $size 3]
+		set ymaxval 20
+		#set x1 [lindex $size 0]
+		#set x2 [lindex $size 2]
+		#set y1 [lindex $size 1]
+		#set y2 [lindex $size 3]
+
+		#pdtk_post "bbox all: $x1 $x2 $y1 $y2\n"
+		#pdtk_post "new bbox all: $xbox1 $xbox2 $ybox1 $ybox2\n"
+
+		#these work much better than the ones below
+		#they allow for intelligent translation of the canvas
+		#rather than introducing redundant scrollbars
+		set xminval $x1
+		set yminval $y1
+
+		set xmaxval [expr $x1+($x2-$x1)]
+		set ymaxval [expr $y1+($y2-$y1)]
         
-        if {$x1 < 0} {set xminval $x1}
-        if {$y1 < 0} {set yminval $y1}
+		#if {$x1 < $xminval} {set xminval $x1}
+		#if {$y1 < $yminval} {set yminval $y1}
 
-        if {$x2 > 100} {set xmaxval $x2}
-        if {$y2 > 100} {set ymaxval $y2}
+		#if {$x2 > $xmaxval} {set xmaxval $x2}
+		#if {$y2 > $ymaxval} {set ymaxval $y2}
+
+		#pdtk_post "$xminval $xmaxval $yminval $ymaxval\n"
 
         set parentname [winfo parent $name]
         set winwidth [winfo width $parentname]
         set winheight [winfo height $parentname]
-        set canvaswidth [ expr {abs($xminval)+$xmaxval} ]
-        set canvasheight [ expr {abs($yminval)+$ymaxval} ]
 
+		set canvaswidth [ expr {abs($xmaxval-$xminval)} ]
+		set canvasheight [ expr {abs($ymaxval-$yminval)} ]
+		#set canvaswidth [ expr {abs($xminval)+$xmaxval} ]
+		#set canvasheight [ expr {abs($yminval)+$ymaxval} ]
+
+		#pdtk_post "$canvaswidth $canvasheight\n"
+
+		#pdtk_post "$parentname [$parentname.scroll cget -state]\n"
+		#pdtk_post "scroll=yes $winwidth $canvaswidth\n"
         if {$winwidth > $canvaswidth} {pack forget $parentname.scrollhort}
         if {$winheight > $canvasheight} {pack forget $parentname.scrollvert}
         if {$winwidth < $canvaswidth} {pack $parentname.scrollhort -fill x \
@@ -2152,6 +2199,7 @@
         if {$winheight < $canvasheight} {pack $parentname.scrollvert -fill y \
                                              -side right -before $parentname.c}
         
+	
         if {$pdtk_canvas_mouseup_name != $name || \
                 $pdtk_canvas_mouseup_xminval != $xminval || \
                 $pdtk_canvas_mouseup_xmaxval != $xmaxval || \
@@ -2166,7 +2214,6 @@
             set pdtk_canvas_mouseup_yminval $yminval
             set pdtk_canvas_mouseup_ymaxval $ymaxval
         }
-
     }
     pdtk_canvas_checkgeometry [canvastosym $name]
 }
_______________________________________________
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev

Reply via email to