class: VariablePanel
authorClaus Gittinger <cg@exept.de>
Thu, 19 Feb 2015 18:40:39 +0100
changeset 5261 ef0c874b4053
parent 5260 d062a1aa6b99
child 5262 1f4b4b257010
class: VariablePanel added: #clearAndInvalidate changed: #resizeSubviewsFrom:to: avoid some flicker during resize, by doing the clear+invalidate delayed
VariablePanel.st
--- a/VariablePanel.st	Wed Feb 18 14:13:39 2015 +0100
+++ b/VariablePanel.st	Thu Feb 19 18:40:39 2015 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libwidg' }"
 
+"{ NameSpace: Smalltalk }"
+
 SimpleView subclass:#VariablePanel
 	instanceVariableNames:'barHeight barWidth barLevel separatingLine shadowForm lightForm
 		showHandle showHandleWhenEntered handlePosition handleColor
@@ -1353,6 +1355,11 @@
 
 !VariablePanel methodsFor:'drawing'!
 
+clearAndInvalidate
+    self clear.
+    self invalidate.
+!
+
 drawHandle:hIndex atX:hx y:hy
     "draw a single handle at hx/hy"
 
@@ -2175,55 +2182,56 @@
 
     |step nSubviews subViews|
 
-    (subViews := self subViews) size > 0 ifTrue:[
-        (start <= stop) ifTrue:[
-            step := 1
+    subViews := self subViews.
+    nSubviews := subViews size.
+    nSubviews == 0 ifTrue:[ ^ self ].
+
+    (start <= stop) ifTrue:[
+        step := 1
+    ] ifFalse:[
+        step := -1
+    ].
+    start to:stop by:step do:[:index |
+        |bw view o1 o2 newOrg newCorner newExt|
+
+        view := subViews at:index.
+        bw := view borderWidth.
+
+        index == 1 ifTrue:[
+            o1 := 0.
         ] ifFalse:[
-            step := -1
+            o1 := barHeight // 2 - bw
         ].
-        nSubviews := subViews size.
-        start to:stop by:step do:[:index |
-            |bw view o1 o2 newOrg newCorner newExt|
-
-            view := subViews at:index.
-            bw := view borderWidth.
-
-            index == 1 ifTrue:[
-                o1 := 0.
-            ] ifFalse:[
-                o1 := barHeight // 2 - bw
-            ].
-            index ==  nSubviews ifTrue:[
-                o2 := 0.
-            ] ifFalse:[
-                o2 := barHeight // 2 - bw
-            ].
-
-            newOrg := view computeOrigin.
-            newOrg notNil ifTrue:[
-                (index ~~ 1) ifTrue:[
-                    orientation == #vertical ifTrue:[
-                        newOrg y:(newOrg y + o1)
-                    ] ifFalse:[
-                        newOrg x:(newOrg x + o1)
-                    ]
-                ].
-            ].
-            newExt := view computeExtent.
-            newExt notNil ifTrue:[
+        index ==  nSubviews ifTrue:[
+            o2 := 0.
+        ] ifFalse:[
+            o2 := barHeight // 2 - bw
+        ].
+
+        newOrg := view computeOrigin.
+        newOrg notNil ifTrue:[
+            (index ~~ 1) ifTrue:[
                 orientation == #vertical ifTrue:[
-                    newExt y:(newExt y - o2 - o1)
+                    newOrg y:(newOrg y + o1)
                 ] ifFalse:[
-                    newExt x:(newExt x - o2 - o1)
+                    newOrg x:(newOrg x + o1)
                 ]
             ].
-            view pixelOrigin:newOrg extent:newExt.
         ].
-        shown ifTrue:[
-            "/ must clear, since handles are copied automatically (by bitGravity)
-            self clear.
-            self invalidate.
-        ]
+        newExt := view computeExtent.
+        newExt notNil ifTrue:[
+            orientation == #vertical ifTrue:[
+                newExt y:(newExt y - o2 - o1)
+            ] ifFalse:[
+                newExt x:(newExt x - o2 - o1)
+            ]
+        ].
+        view pixelOrigin:newOrg extent:newExt.
+    ].
+    shown ifTrue:[
+        "/ must clear, since handles are copied automatically (by bitGravity)
+        "/ self clearAndInvalidate.
+        self sensor pushUserEvent:#clearAndInvalidate for:self withArguments:#()
     ]
 
     "Modified: / 22.3.1997 / 01:02:21 / stefan"
@@ -2670,10 +2678,10 @@
 !VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.104 2014-06-06 07:30:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.105 2015-02-19 17:40:39 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.104 2014-06-06 07:30:22 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.105 2015-02-19 17:40:39 cg Exp $'
 ! !