catch expose events when unselecting
authorca
Wed, 08 Apr 1998 13:16:21 +0200
changeset 768 2ef5b8bed914
parent 767 ed96f735dab1
child 769 bb413a70f479
catch expose events when unselecting
UIObjectView.st
UIPainterView.st
--- a/UIObjectView.st	Wed Apr 08 01:25:23 1998 +0200
+++ b/UIObjectView.st	Wed Apr 08 13:16:21 1998 +0200
@@ -877,6 +877,24 @@
 
 !UIObjectView methodsFor:'private handles'!
 
+handleAffectedViews:aViewOrSeqOfViews
+    "update affected views
+    "
+    |bw|
+
+    self forEach:aViewOrSeqOfViews do:[:v|
+        v shown ifTrue:[
+            v fill:v viewBackground.
+            bw := v borderWidth.
+            bw ~~ 0 ifTrue:[
+                v borderWidth:(bw - 1).
+                v borderWidth:bw.
+            ].
+            v exposeX:0 y:0 width:9999 height:9999
+        ]
+    ]
+!
+
 handlesOf:aComponent do:aTwoArgAction
     "perform action on each handle of a component
     "
@@ -917,6 +935,14 @@
 showUnselected:aComponent
     "show object unselected
     "
+    self showUnselected:aComponent addAffectedViewsTo:nil
+!
+
+showUnselected:aComponent addAffectedViewsTo:aSet
+    "show object unselected. If the set, an IdentitySet, is not nil, the
+     affected subviews are added into the set, otherwise an expose event
+     to each affected cpomponent is raised.
+    "
     |wasClipped r|
 
     selectionHiddenLevel ~~ 0 ifTrue:[^ self].
@@ -932,7 +958,6 @@
     ].
 
     "/ must redraw all components which are affected b the handles
-
     r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)).
 
     subViews do:[:anotherComponent |
@@ -944,15 +969,17 @@
             (absFrame intersects:r) ifTrue:[
                 anotherComponent withAllSubViewsDo:[:v |
                     v shown ifTrue:[
-                        v fill:v viewBackground.
-                        v exposeX:0 y:0 width:9999 height:9999.
+                        aSet notNil ifTrue:[
+                            aSet add:v
+                        ] ifFalse:[
+                            self handleAffectedViews:v
+                        ]
                     ]
                 ]
             ]
         ]
-    ]
-
-    "Modified: 8.4.1997 / 00:32:26 / cg"
+    ].
+
 !
 
 whichHandleOf:aComponent isHitBy:aPoint
@@ -1158,6 +1185,22 @@
 
 !UIObjectView methodsFor:'selections'!
 
+hideSelection
+    "hide the selection - undraw hilights - whatever that is"
+
+    |aSet|
+
+    self selectionDo:[:object|
+        aSet isNil ifTrue:[
+            aSet := IdentitySet new
+        ].
+        self showUnselected:object addAffectedViewsTo:aSet.
+    ].
+    self handleAffectedViews:aSet.
+
+
+!
+
 moveableSelection
     "checks whether the selection is not empty and all selected instances
      can be moved. If true the selection is returned otherwise nil
@@ -1243,7 +1286,7 @@
     |coll|
 
     selectionHiddenLevel == 0 ifTrue:[
-        self selectionDo:[:aView| self showUnselected:aView].
+        self hideSelection.
         device flush.
     ].
     selectionHiddenLevel := selectionHiddenLevel + 1.
--- a/UIPainterView.st	Wed Apr 08 01:25:23 1998 +0200
+++ b/UIPainterView.st	Wed Apr 08 13:16:21 1998 +0200
@@ -1247,11 +1247,21 @@
 updateSelectionFromModel:aSelOrNil
     "update selection from a new selection
     "
+    |aSet|
+
     selectionHiddenLevel == 0 ifTrue:[
         aSelOrNil size ~~ 0 ifTrue:[
-            self selectionDo:[:el| (aSelOrNil includes:el) ifFalse:[self showUnselected:el] ]
+            self selectionDo:[:el|
+                (aSelOrNil includes:el) ifFalse:[
+                    aSet isNil ifTrue:[
+                        aSet := IdentitySet new
+                    ].
+                    self showUnselected:el addAffectedViewsTo:aSet.
+                ] 
+            ].
+            self handleAffectedViews:aSet.
         ] ifFalse:[
-            self selectionDo:[:el| self showUnselected:el ]
+            self hideSelection.
         ]
     ].
     self setSelection:aSelOrNil withRedraw:false.