UIGalleryView.st
changeset 2502 c27a926cbe67
parent 2495 ead2b25a2c63
child 2504 8746b7a4d215
--- a/UIGalleryView.st	Sun May 10 13:00:09 2009 +0200
+++ b/UIGalleryView.st	Sun May 10 13:00:24 2009 +0200
@@ -384,6 +384,7 @@
 
     specification buildViewFor:builder in:self.
 
+    "/ components notEmptyOrNil ifTrue:[ self halt ].
     subViews size ~~ 0 ifTrue:[
         showBorders ifTrue:[
             subViews do:[:v|
@@ -398,8 +399,8 @@
 
 !UIGalleryView::Canvas methodsFor:'building'!
 
-buildSpecFrom:aSpec
-    "build spec out of spec"
+recursiveBuildSpecFromSpecPrototype:aSpec
+    "build spec out of spec prototype"
 
     |spec comp coll|
 
@@ -408,7 +409,6 @@
     ].
 
     spec := aSpec copy.
-
     (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
         ^ spec
     ].
@@ -420,8 +420,10 @@
     ].
     coll := OrderedCollection new.
 
-    comp do:[:anEntry||spc|
-        (spc := self buildSpecFrom:anEntry) notNil ifTrue:[
+    comp do:[:anEntry|
+        |spc|
+
+        (spc := self recursiveBuildSpecFromSpecPrototype:anEntry) notNil ifTrue:[
             coll add:spc
         ]
     ].
@@ -449,7 +451,7 @@
     spec isNil ifTrue:[^ self].
 
     self withSelectionHiddenDo:[
-        spec := self buildSpecFrom:spec.
+        spec := self recursiveBuildSpecFromSpecPrototype:spec.
         spec name:nil.
 
         dragObj := DropSpec for:selection specification:spec.
@@ -605,8 +607,8 @@
 
         specification do:[:aSpec|
             (aSpec notNil and:[aSpec name = name]) ifTrue:[
-                aSpec canUIDrag ifTrue:[^ aSpec ].
-                ^ nil
+                aSpec canUIDrag ifFalse:[^ nil ].
+                ^ aSpec
             ]
         ]
     ].
@@ -641,6 +643,7 @@
     (shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[
         self clippedByChildren:false.
 
+        self paint:Color black.
         self handlesOf:selection do:[:aRectangle|
             self fillRectangle:aRectangle
         ].
@@ -657,15 +660,16 @@
 
     self withSelectionHiddenDo:[
         spec := self findSpecFor:aView.
+
         selection := (spec isNil) ifTrue:[nil] ifFalse:[aView].
         clientSpecHolder value:spec.
     ].
 !
 
 withSelectionHiddenDo:aOneArgBlock
-    |r|
-
-    [   
+    [ 
+        |r forceExpose|
+        
         hiddenCounter :=  hiddenCounter + 1.
         hiddenCounter == 1 ifTrue:[
             (shown and:[selection notNil]) ifTrue:[
@@ -678,25 +682,33 @@
                 self clippedByChildren:true.
 
                 r := selection bounds.
-                subViews notNil ifTrue:[
-                    subViews do:[:sv|
+
+                forceExpose := 
+                    [:sv|
                         |absOrg absFrame|
 
-                        (sv bounds intersects:r) ifTrue:[
-                            sv borderColor:(Color white).           "/ to force a redraw
-                            sv borderColor:(Color black).
+                        (sv bounds intersects:r) ifTrue:[   
+                            sv isView ifTrue:[
+                                sv borderColor:(Color white).           "/ kludge to force a redraw
+                                sv borderColor:(Color black).
 
-                            sv withAllSubViewsDo:[:v|
-                                v realized ifTrue:[
-                                    v fill:v viewBackground.
-                                    v exposeX:0 y:0 width:v width height:v height.
+                                sv withAllSubViewsDo:[:v|
+                                    v realized ifTrue:[
+                                        v fill:v viewBackground.
+                                        v exposeX:0 y:0 width:v width height:v height.
+                                    ]
                                 ]
-                            ]
+                            ] ifFalse:[
+                                sv invalidate.
+                            ].
                         ]
-                    ]
-                ].
+                    ].
+
+                (subViews ? #()) do:forceExpose.
+                (components ? #()) do:forceExpose.
             ].
         ].
+        self repairDamage.  "/ ensure that any outstanding clear/redraw of the unselect are done before
         aOneArgBlock value.
     ] ensure:[
         self repairDamage.  "/ ensure that any outstanding clear/redraw of the unselect are done before