SimpleView.st
changeset 8385 6c5f27cee752
parent 8383 a6640460cb58
child 8389 e6f69dfc1f7a
--- a/SimpleView.st	Thu Jun 14 10:32:44 2018 +0200
+++ b/SimpleView.st	Thu Jun 14 11:28:22 2018 +0200
@@ -2407,13 +2407,14 @@
     A view showing a bitmap of height 1000 should return 1000.
     If not redefined, scrollbars have no way of knowing the actual size
     of the contents being shown. This is called by scrollBars to compute
-    the relative height of the document vs. the views actual size.
+    the relative height of the document vs. the view's actual size.
     The value returned here must be based on a scale of 1, since users
     of this will scale as appropriate."
 
     ^ (self innerHeight max:(self maxSubViewBottom)) max:self maxComponentBottom
 
-    "Modified: 26.5.1996 / 12:44:21 / cg"
+    "Modified: / 26-05-1996 / 12:44:21 / cg"
+    "Modified (comment): / 14-06-2018 / 10:19:54 / Claus Gittinger"
 !
 
 heightOfContentsDependsOnWidth
@@ -2779,7 +2780,7 @@
      accumulate. Better use origin/corner.
      Best: migrate to use layour objects.
 
-     Notice: this sets the views explicitExtent flag, which prevents it normally
+     Notice: this sets the view's explicitExtent flag, which prevents it normally
              from resizing itself to its preferredExtent.
              See initialExtent: for a variation."
 
@@ -2818,6 +2819,7 @@
     ]
 
     "Modified: / 07-07-2010 / 16:44:57 / cg"
+    "Modified (comment): / 14-06-2018 / 10:19:44 / Claus Gittinger"
 !
 
 extentRule
@@ -5279,46 +5281,76 @@
      otherwise false (used to restore the background).
      By default false is returned."
 
-    |point x y|
+    |point x y w h vOrg amountFraction didScroll|
     
+    didScroll := false.
+
     point := aDropContext targetPoint.
+    vOrg := self viewOrigin.
+
     x := point x.
     y := point y.
 
+    w := self width.
+    h := self height.
+
+Transcript show:'pnt: '; showCR:point.
+Transcript show:'ext: '; showCR:w@h.
+Transcript show:'cont: '; showCR:(self widthOfContents@self heightOfContents).
+Transcript show:'org: '; showCR:vOrg.
+
     "/ if at the left AND the view is scrolled horizontally,
-    "/ scroll to the left...
-    (x < (self width * 0.1)) ifTrue:[
-        self viewOrigin x > 0 ifTrue:[
-            self scrollLeft:((self width * 0.1) rounded max:1).
+    "/ scroll left...
+    (x < (w * 0.1)) ifTrue:[
+        vOrg x > 0 ifTrue:[
+            amountFraction := 0.1.
+            (x < (w * 0.05)) ifTrue:[ amountFraction := 0.2 ].
+            aDropContext contentsWillChange.
+            self scrollLeft:((w * amountFraction) rounded max:1).
+            didScroll := true.
         ].    
     ] ifFalse:[
         "/ if at the right AND the contents is wider,
-        "/ scroll to the right...
-        (x > (self width * 0.9)) ifTrue:[
-            (self viewOrigin x + self width) < (self widthOfContents) ifTrue:[
-                self scrollRight:((self width * 0.1) rounded max:1).
+        "/ scroll right...
+        (x > (w * 0.9)) ifTrue:[
+            (vOrg x + w) < (self widthOfContents) ifTrue:[
+                amountFraction := 0.1.
+                (x > (w * 0.95)) ifTrue:[ amountFraction := 0.2 ].
+                aDropContext contentsWillChange.
+                self scrollRight:((w * amountFraction) rounded max:1).
+                didScroll := true.
             ].    
         ].    
     ].    
 
     "/ if at the top AND the view is scrolled vertically,
-    "/ scroll to the top...
-    (y < (self height * 0.1)) ifTrue:[
-        self viewOrigin y > 0 ifTrue:[
-            self scrollUp:((self height * 0.1) rounded max:1).
+    "/ scroll up...
+    (y < (h * 0.1)) ifTrue:[
+        vOrg y > 0 ifTrue:[
+            amountFraction := 0.1.
+            (y < (h * 0.05)) ifTrue:[ amountFraction := 0.2 ].
+            didScroll ifFalse:[ aDropContext contentsWillChange ].
+Transcript show:'********* up: '; show:self; show:' '; showCR:((h * amountFraction) rounded max:1).
+            self scrollUp:((h * amountFraction) rounded max:1).
+            didScroll := true.
         ].    
     ] ifFalse:[
         "/ if at the bottom AND the contents is longer,
-        "/ scroll to the bottom...
-        (y > (self height * 0.9)) ifTrue:[
-            (self viewOrigin y + self height) < (self heightOfContents) ifTrue:[
-                self scrollDown:((self height * 0.1) rounded max:1).
+        "/ scroll down...
+        (y > (h * 0.9)) ifTrue:[
+            (vOrg y + h) < (self heightOfContents) ifTrue:[
+                amountFraction := 0.1.
+                (y > (h * 0.95)) ifTrue:[ amountFraction := 0.2 ].
+                didScroll ifFalse:[ aDropContext contentsWillChange ].
+Transcript show:'********* down: '; show:self; show:' '; showCR:((h * amountFraction) rounded max:1).
+                self scrollDown:((h * amountFraction) rounded max:1).
+                didScroll := true.
             ].    
         ].    
     ].    
-    ^ false
-
-    "Modified: / 13-06-2018 / 21:53:56 / Claus Gittinger"
+    ^ didScroll
+
+    "Modified: / 14-06-2018 / 11:16:01 / Claus Gittinger"
 !
 
 drop:aDropContext