do not scroll when expanding
authorClaus Gittinger <cg@exept.de>
Thu, 28 Oct 2004 14:38:05 +0200
changeset 2769 1315a31fa1e8
parent 2768 9c79a348a443
child 2770 d46f94ddabef
do not scroll when expanding
HierarchicalListView.st
--- a/HierarchicalListView.st	Tue Oct 26 14:06:31 2004 +0200
+++ b/HierarchicalListView.st	Thu Oct 28 14:38:05 2004 +0200
@@ -627,7 +627,7 @@
      if the item changed expanded, we try to show all
      new visible children
     "
-    |item expanded availY usedY vwOrgX vwOrgY idx|
+    |item expanded availY usedY vwOrgX vwOrgY numChildren idx dl|
 
     showIndicators ifFalse:[^ self].
 
@@ -651,25 +651,30 @@
 
     (expanded or:[item isExpanded not]) ifTrue:[^ self].
 
-    "/ compute the index of last child assigned to item
+    (self yVisibleOfLine:aLnNr+1) > self height ifTrue:[
+        dl := (self yVisibleOfLine:aLnNr+1) - (self yVisibleOfLine:aLnNr).
+        self scrollTo:(viewOrigin x @ (viewOrigin y + dl)).
+    ].
 
-    idx := item numberOfVisibleChildren.        "/ no visible children
-    idx == 0 ifTrue:[^ self].
-
-    idx    := aLnNr + idx.
-    vwOrgY := viewOrigin y.
-    availY := (self yVisibleOfLine:aLnNr) - (self yVisibleOfLine:1).
+"/    numChildren := item numberOfVisibleChildren.      
+"/    numChildren == 0 ifTrue:[
+"/        ^ self
+"/    ].
+    ^ self
 
-    availY > margin ifTrue:[
-        usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin).
-
-        usedY > 1 ifTrue:[
-            vwOrgY := vwOrgY + (usedY min:availY).
-        ].
-    ].
-    vwOrgX := self computeViewOriginXat:aLnNr.
-
-    self scrollTo:(vwOrgX @ vwOrgY).
+"/    idx    := aLnNr + numChildren.
+"/    vwOrgY := viewOrigin y.
+"/    availY := (self yVisibleOfLine:aLnNr) - (self yVisibleOfLine:1).
+"/
+"/    availY > margin ifTrue:[
+"/        usedY := (self yVisibleOfLine:(idx + 1)) - (height - margin - margin).
+"/
+"/        usedY > 1 ifTrue:[
+"/            vwOrgY := vwOrgY + (usedY min:availY).
+"/        ].
+"/    ].
+"/    vwOrgX := self computeViewOriginXat:aLnNr.
+"/    self scrollTo:(vwOrgX @ vwOrgY).
 !
 
 lineChangedAt:aLnNr with:arg
@@ -1628,5 +1633,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.92 2004-06-23 09:33:07 martin Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.93 2004-10-28 12:38:05 cg Exp $'
 ! !