#BUGFIX by ca
authorca
Wed, 11 Dec 2019 13:16:08 +0100
changeset 6748 9669c3f0bc4b
parent 6747 121b6e62d393
child 6749 1ba3302417a6
#BUGFIX by ca class: VerticalPanelView class definition added: #storePreferredHeight:for: changed: #beVisiblePostUpdate
VerticalPanelView.st
--- a/VerticalPanelView.st	Tue Dec 10 16:45:14 2019 +0100
+++ b/VerticalPanelView.st	Wed Dec 11 13:16:08 2019 +0100
@@ -16,7 +16,7 @@
 "{ NameSpace: Smalltalk }"
 
 PanelView subclass:#VerticalPanelView
-	instanceVariableNames:'rowHeight'
+	instanceVariableNames:'rowHeight storedPreferredHeight'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Layout'
@@ -781,6 +781,18 @@
 
    | sviews |
 
+    storedPreferredHeight isNil ifTrue:[ storedPreferredHeight := IdentityDictionary new ].
+    
+    storedPreferredHeight keysDo:[: eachView |
+        (subViews includes: eachView) ifFalse:[
+            sviews isNil ifTrue:[ sviews := OrderedCollection new ].
+            sviews add: eachView
+        ]
+    ].
+    sviews size > 0 ifTrue:[
+        sviews do:[: eachView | storedPreferredHeight removeKey: eachView ifAbsent:nil ].
+    ].
+    
     self isVisible ifFalse:[ ^ self ].
     sviews := self subViewsToConsider.
     sviews size > 1 ifFalse:[ ^ self].
@@ -788,11 +800,25 @@
     mustRearrange := true.
     sviews do:[: eachChild |
         eachChild height: 0.
-        eachChild height: (eachChild computePreferredExtent y).
+        eachChild height: (storedPreferredHeight at: eachChild ifAbsent:[ eachChild computePreferredExtent y ]).
     ].
     mustRearrange := true.
     self setChildPositions.
     mustRearrange := false.
+!
+
+storePreferredHeight: aHeight for: aView
+    (aView isView and:[aView superView == self])
+       ifFalse:[ ^ self ].
+
+    "/ only used for windows
+    OperatingSystem isMSWINDOWSlike ifFalse:[ ^ self ].
+
+    storedPreferredHeight isNil ifTrue:[storedPreferredHeight := IdentityDictionary new ].
+    
+    (aHeight isInteger and:[aHeight > 0 ])
+        ifTrue: [ storedPreferredHeight at: aView put: aHeight ]
+        ifFalse:[ storedPreferredHeight removeKey: aView ifAbsent: nil ].
 ! !
 
 !VerticalPanelView methodsFor:'layout'!