From 12b99d2c2ef9af5af9ff176ccffc5d09a9fe7561 Mon Sep 17 00:00:00 2001 From: Koen De Hondt Date: Sun, 16 Nov 2025 16:45:26 +0100 Subject: [PATCH] Fix mistake in SpMorphicBoxAdapter>>#verifyBoxExtentOf:withChild: in conditions to determine whether a Morph has a fixed width or height. --- .../SpMorphicBoxAdapter.class.st | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st b/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st index f3ec2e8b..baa338c2 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicBoxAdapter.class.st @@ -54,8 +54,8 @@ SpMorphicBoxAdapter >> addConstraints: constraints toChild: childMorph [ ifFalse: [ "Set morph to stay rigid" layout direction setRigidityOfNonExpandedMorph: theMorph. - constraints width ifNotNil: [ :w | theMorph width: w ]. - constraints height ifNotNil: [ :h | theMorph height: h ] ]. + constraints width ifNotNil: [ :w | self setFixedWidth: w toMorph: theMorph]. + constraints height ifNotNil: [ :h | self setFixedHeight: h toMorph: theMorph ] ]. ^ theMorph ] @@ -169,6 +169,17 @@ SpMorphicBoxAdapter >> childrenWidgets [ ^ self children ] +{ #category : 'private' } +SpMorphicBoxAdapter >> hasFixedSize: aPanel [ + + | props minCellSize | + props := aPanel layoutProperties. + props ifNil: [ ^ false ]. + minCellSize := props minCellSize. + minCellSize ifNil: [ ^ false ]. + ^ minCellSize = props maxCellSize +] + { #category : 'factory' } SpMorphicBoxAdapter >> layout: aLayout [ @@ -307,6 +318,24 @@ SpMorphicBoxAdapter >> replace: aPresenter with: otherPresenter withConstraints: panel replaceSubmorph: oldMorph by: newMorph ] +{ #category : 'private' } +SpMorphicBoxAdapter >> setFixedHeight: aNumber toMorph: aMorph [ + + aMorph + minCellSize: aNumber; + maxCellSize: aNumber; + height: aNumber +] + +{ #category : 'private' } +SpMorphicBoxAdapter >> setFixedWidth: aNumber toMorph: aMorph [ + + aMorph + minCellSize: aNumber; + maxCellSize: aNumber; + width: aNumber +] + { #category : 'updating' } SpMorphicBoxAdapter >> updateSpacing [ @@ -347,10 +376,10 @@ SpMorphicBoxAdapter >> verifyBoxExtentOf: aPanel withChild: childMorph [ ifTrue: [ height := height + aPanel height + spacing ] ifFalse: [ width := width + aPanel width + spacing ]. - newPanelWidth := aPanel hResizing = #rigid + newPanelWidth := (layout isHorizontal and: [ self hasFixedSize: aPanel ]) ifTrue: [ aPanel width ] ifFalse: [ aPanel width max: width ]. - newPanelHeight := aPanel vResizing = #rigid + newPanelHeight := (layout isVertical and: [ self hasFixedSize: aPanel ]) ifTrue: [ aPanel height ] ifFalse: [ aPanel height max: height ]. aPanel extent: newPanelWidth @ newPanelHeight