SimpleView.st
branchjv
changeset 7400 b583f17b4b39
parent 7380 62f0b3e4fa9c
parent 7397 11bd586c3a73
child 7489 07c626716aed
--- a/SimpleView.st	Thu Jun 30 22:07:40 2016 +0100
+++ b/SimpleView.st	Mon Jul 04 21:17:06 2016 +0100
@@ -21,16 +21,16 @@
 		lightColor bitGravity viewGravity controller windowGroup
 		preferredExtent explicitExtent dependents layoutManager
 		visibilityChannel helpKey dropTarget'
-	classVariableNames:'Grey CentPoint ViewSpacing DefaultStyle StyleSheet
-		DefaultViewBackgroundColor DefaultBorderColor DefaultLightColor
-		DefaultShadowColor DefaultBorderWidth DefaultFocusColor
-		DefaultFocusBorderWidth ReturnFocusWhenClosingModalBoxes
-		FlagOriginChanged FlagExtentChanged FlagCornerChanged
-		FlagExtentChangedBeforeCreated FlagCanTab
-		FlagRequestFocusOnPointerEnter
-		FlagDoNotRequestFocusOnPointerEnter FlagNativeWidget
-		FlagIsUnmappedModalBox FlagIsMDIChild FlagHiddenOnRealize
-		FlagHasExplicitExtent FlagTakeFocusWhenMapped FlagBeingDestroyed'
+	classVariableNames:'CentPoint DefaultBorderColor DefaultBorderWidth
+		DefaultFocusBorderWidth DefaultFocusColor DefaultLightColor
+		DefaultShadowColor DefaultStyle DefaultViewBackgroundColor
+		FlagBeingDestroyed FlagCanTab FlagCornerChanged
+		FlagDoNotRequestFocusOnPointerEnter FlagExtentChanged
+		FlagExtentChangedBeforeCreated FlagHasExplicitExtent
+		FlagHiddenOnRealize FlagIsMDIChild FlagIsUnmappedModalBox
+		FlagNativeWidget FlagOriginChanged FlagRequestFocusOnPointerEnter
+		FlagTakeFocusWhenMapped Grey ReturnFocusWhenClosingModalBoxes
+		StyleSheet ViewSpacing'
 	poolDictionaries:''
 	category:'Views-Basic'
 !
@@ -4885,7 +4885,7 @@
      Interface is provided mostly provided for ST80 compatibility;
      here, translate into ST/X's mechanism for telling others about this."
 
-    ^ self changed:#preferredExtent
+    dependents notNil ifTrue:[ self changed:#preferredExtent ]
 
     "Modified: 6.3.1997 / 16:12:02 / cg"
 !
@@ -5019,11 +5019,12 @@
 !
 
 dependents
-    "return a Collection of dependents"
+    "return a Collection of dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     dependents isNil ifTrue:[^ #()].
     dependents isCollection ifTrue:[
-	^ dependents
+        ^ dependents
     ].
     ^ IdentitySet with:dependents
 
@@ -5032,16 +5033,17 @@
 !
 
 dependents:aCollection
-    "set the collection of dependents"
+    "set the collection of dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     |dep|
 
     aCollection size == 1 ifTrue:[
-	dep := aCollection first.
-	dep isCollection ifFalse:[
-	    dependents := aCollection first.
-	    ^ self
-	]
+        dep := aCollection first.
+        dep isCollection ifFalse:[
+            dependents := aCollection first.
+            ^ self
+        ]
     ].
     dependents := aCollection
 
@@ -5050,17 +5052,18 @@
 !
 
 dependentsDo:aBlock
-    "evaluate aBlock for all of my dependents"
+    "evaluate aBlock for all of my dependents.
+     Views keep them in an instance variable to avoid overhead."
 
     |deps|
 
     deps := dependents.
     deps notNil ifTrue:[
-	deps isCollection ifTrue:[
-	    deps do:aBlock
-	] ifFalse:[
-	    aBlock value:deps
-	]
+        deps isCollection ifTrue:[
+            deps do:aBlock
+        ] ifFalse:[
+            aBlock value:deps
+        ]
     ]
 
     "Created: 11.6.1997 / 13:10:51 / cg"
@@ -5943,7 +5946,7 @@
     ].
 
     originChanged ifTrue:[
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
     ].
 
     "Modified: / 10.10.2001 / 14:14:19 / cg"
@@ -6081,8 +6084,11 @@
     "view has been destroyed by someone else (usually window system)"
 
     shown ifTrue:[
-	shown := false.
-	self changed:#visibility.
+        shown := false.
+        dependents notNil ifTrue:[
+            self changed:#visibility.
+            self changed:#destroyed 
+        ].
     ].
     super destroyed
 
@@ -6412,7 +6418,7 @@
             ]
         ].
         shownBefore ~~ true ifTrue:[
-            self changed:#visibility.
+            dependents notNil ifTrue:[ self changed:#visibility ].
         ].
         self takeFocusWhenMapped ifTrue:[
             "/ this is a one-shot!!
@@ -6504,7 +6510,7 @@
     doRequestFocus ifTrue:[
         self requestFocus.
     ].
-    self changed:#pointerInView
+    dependents notNil ifTrue:[ self changed:#pointerInView ]
     
     "Modified: / 01-08-2012 / 17:06:41 / cg"
 !
@@ -6513,7 +6519,7 @@
     "mouse pointer left"
 
     super pointerLeave:buttonState.
-    self changed:#pointerInView
+    dependents notNil ifTrue:[ self changed:#pointerInView ]
 !
 
 propertyChange:propertyId state: state
@@ -6680,20 +6686,20 @@
     |wdgr|
 
     shown ifTrue:[
-	shown := false.
-	self changed:#visibility.
+        shown := false.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
     (wdgr := self windowGroup) notNil ifTrue:[
-	wdgr focusView == self ifTrue:[
-	    wdgr focusViewUnmapped.
-	].
+        wdgr focusView == self ifTrue:[
+            wdgr focusViewUnmapped.
+        ].
     ].
 
     subViews notNil ifTrue:[
-	subViews do:[:v |
-	    v containerUnmapped
-	].
-	self changed:#visibility.
+        subViews do:[:v |
+            v containerUnmapped
+        ].
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ]
 
     "Modified: 25.2.1997 / 22:40:52 / cg"
@@ -6709,7 +6715,7 @@
     newShown := how ~~ #fullyObscured.
     newShown ~~ shown ifTrue:[
         shown := newShown.
-        self changed:#visibility.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
 !
 
@@ -7592,14 +7598,14 @@
     "this one is sent, whenever contents changes its size -
      tell dependents about the change (i.e. scrollers)."
 
-    self changed:#sizeOfContents
+    dependents notNil ifTrue:[ self changed:#sizeOfContents ]
 !
 
 noticeOfWindowClose
     |app|
 
     (app := self application) notNil ifTrue:[
-	app noticeOfWindowClose:self
+        app noticeOfWindowClose:self
     ].
 !
 
@@ -7607,8 +7613,9 @@
     |app|
 
     (app := self application) notNil ifTrue:[
-	app noticeOfWindowOpen:self
-    ].
+        app noticeOfWindowOpen:self
+    ].
+    dependents notNil ifTrue:[ self changed:#opened ] 
 !
 
 originChanged:delta
@@ -7616,7 +7623,7 @@
      tell dependents (i.e. scrollers) about this"
 
     (delta = (0@0)) ifTrue:[^ self].
-    self changed:#originOfContents with:delta.
+    dependents notNil ifTrue:[ self changed:#originOfContents with:delta ].
 "/   subViews notNil ifTrue:[
 "/        subViews do:[:aSubView |
 "/            aSubView pixelOrigin:((aSubView left @ aSubView top) - delta)
@@ -7661,7 +7668,7 @@
     ].
     shown ifTrue:[
         shown := false.
-        self changed:#visibility.
+        dependents notNil ifTrue:[ self changed:#visibility ].
     ].
 
 "/    controller notNil ifTrue:[
@@ -7678,6 +7685,7 @@
     ].
     super destroy.
 
+    dependents notNil ifTrue:[ self changed:#destroyed ]. "/ must do before release, which clears the dependents
     self release.
 
 "/    superView isNil ifTrue:[
@@ -8608,7 +8616,7 @@
 
     ((newWidth == width) and:[newHeight == height]) ifTrue:[
         sameOrigin ifTrue:[^ self].
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
         ^ self pixelOrigin:origin
     ].
 
@@ -8755,7 +8763,7 @@
         ].
     ].
     sameOrigin ifFalse:[
-        self changed:#origin.
+        dependents notNil ifTrue:[ self changed:#origin ].
     ].
 
     "Modified: / 25-05-1999 / 14:49:56 / cg"
@@ -10208,7 +10216,7 @@
 
         shown ifTrue:[
             shown := false.
-            self changed:#visibility.
+            dependents notNil ifTrue:[ self changed:#visibility ].
         ]
     ].