From e6ae28fc503c4cb6f653ff5e5e3f0f0b91550b7e Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Fri, 6 Sep 2019 16:45:43 +0200 Subject: [PATCH 1/5] fixed deprecations --- src/Spec2-Core/SpPresenter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spec2-Core/SpPresenter.class.st b/src/Spec2-Core/SpPresenter.class.st index e966ee6ed..b42aba281 100644 --- a/src/Spec2-Core/SpPresenter.class.st +++ b/src/Spec2-Core/SpPresenter.class.st @@ -484,7 +484,7 @@ SpPresenter >> giveFocusToPreviousFrom: aModel [ { #category : #'api-focus' } SpPresenter >> gtInspectorPreviewIn: composite [ - self widget ifNotNil: [ :w | w gtInspectorPreviewIn: composite ] + self adapter ifNotNil: [ :w | w gtInspectorPreviewIn: composite ] ] { #category : #'api-focus' } From e22ce511789ee8d8e1e9c09e2439233d41e3e0a1 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Mon, 9 Sep 2019 16:38:53 +0200 Subject: [PATCH 2/5] fix SpGridLayout>>borderWidth for homogeneous rows/columns --- .../SpMorphicGridLayoutComputation.class.st | 16 +++++- .../SpMorphicGridLayoutTest.class.st | 57 ++++++++++++++++--- .../SpTransmissionExample.class.st | 40 ++++++------- 3 files changed, 82 insertions(+), 31 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st b/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st index 16d653f32..237b276a6 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st @@ -79,7 +79,7 @@ SpMorphicGridLayoutComputation >> calculateHomogeneousColumnWidths [ columnWidth := 0. morphs do: [ :each | - columnWidth := columnWidth max: (self styleOf: each) width ]. + columnWidth := columnWidth max: (self minWidthOf: each) ]. ^ Array new: numColumns withAll: (self baseColumnWidth max: columnWidth) ] @@ -95,7 +95,7 @@ SpMorphicGridLayoutComputation >> calculateHomogeneousRowHeights [ rowHeight := 0. morphs do: [ :each | - rowHeight := rowHeight max: (self styleOf: each) height ]. + rowHeight := rowHeight max: (self minHeightOf: each) ]. ^ Array new: numRows withAll: (self baseRowHeight max: rowHeight) ] @@ -290,6 +290,18 @@ SpMorphicGridLayoutComputation >> maxWidthOf: aCollection [ ^ (aCollection collect: [ :each | (each valueOfProperty: #style) width ]) max ] +{ #category : #'private computation' } +SpMorphicGridLayoutComputation >> minHeightOf: aMorph [ + + ^ (self styleOf: aMorph) minHeight ifNil: [ 0 ] +] + +{ #category : #'private computation' } +SpMorphicGridLayoutComputation >> minWidthOf: aMorph [ + + ^ (self styleOf: aMorph) minWidth ifNil: [ 0 ] +] + { #category : #private } SpMorphicGridLayoutComputation >> numColumns [ diff --git a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st index d42310ad8..3f6427b0d 100644 --- a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st +++ b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st @@ -103,14 +103,53 @@ SpMorphicGridLayoutTest >> testBasicLayout [ { #category : #tests } SpMorphicGridLayoutTest >> testBorderWidth [ + + self testBorderWidthHomogeneous. + self testBorderWidthNotHomogeneous +] + +{ #category : #tests } +SpMorphicGridLayoutTest >> testBorderWidthHomogeneous [ " - --------------- + +---+----+----+---+ + | 5 | 5 | 5 | 5 | + +---+----+----+---+ + | 5 | 45 | 45 | 5 | + +---+----+----+---+ + | 5 | 45 | 45 | 5 | + +---+----+----+---+ + | 5 | 5 | 5 | 5 | + +---+----+----+---+ + " + | layout | + + self place: label1 at: 1@1. + self place: morph1 at: 2@1. + self place: label2 at: 1@2. + self place: morph2 at: 2@2. + + (layout := self newLayout) layout + beColumnHomogeneous; + beRowHomogeneous; + borderWidth: 5. + layout layout: panel in: (0@0 corner: 100@100). + + self assert: label1 bounds equals: (5@5 corner: 50@50). + self assert: morph1 bounds equals: (50@5 corner: 95@50). + self assert: label2 bounds equals: (5@50 corner: 50@95). + self assert: morph2 bounds equals: (50@50 corner: 95@95) +] + +{ #category : #tests } +SpMorphicGridLayoutTest >> testBorderWidthNotHomogeneous [ + " + +---+----+----+ | 5 | 5 | 5 | - --------------- + +---+----+----+ | 5 | 50 | 50 | - --------------- - | 5 | 50 | 50 | - --------------- + +---+----+----+ + | 5 | 50 | 50 | + +---+----+----+ " | layout | @@ -122,10 +161,10 @@ SpMorphicGridLayoutTest >> testBorderWidth [ (layout := self newLayout) layout borderWidth: 5. layout layout: panel in: (0@0 corner: 100@100). - self assert: label1 bounds equals: (5@5 corner: 55@25). - self assert: morph1 bounds equals: (55@5 corner: 105@25). - self assert: label2 bounds equals: (5@25 corner: 55@45). - self assert: morph2 bounds equals: (55@25 corner: 105@45) + self assert: label1 bounds equals: (5@5 corner: 50@25). + self assert: morph1 bounds equals: (50@5 corner: 95@25). + self assert: label2 bounds equals: (5@25 corner: 50@45). + self assert: morph2 bounds equals: (50@25 corner: 95@45) ] { #category : #tests } diff --git a/src/Spec2-Transmission/SpTransmissionExample.class.st b/src/Spec2-Transmission/SpTransmissionExample.class.st index 68eed63e8..4b155008f 100644 --- a/src/Spec2-Transmission/SpTransmissionExample.class.st +++ b/src/Spec2-Transmission/SpTransmissionExample.class.st @@ -43,35 +43,35 @@ SpTransmissionExample >> classTemplateFor: aPackage [ { #category : #initialization } SpTransmissionExample >> initializeWidgets [ - - packages := self newList displayBlock: #name. - classes := self newList displayBlock: #name. - protocols := self newList displayBlock: [ :aPair | aPair value name ]. - methods := self newList displayBlock: #selector. + packages := self newList display: #name. + classes := self newList display: #name. + protocols := self newList display: [ :aPair | aPair value name ]. + methods := self newList display: #selector. code := self newCode. - - packages transmitTo: classes transform: [ :aPackage | aPackage definedClasses asArray ]. - packages transmitTo: code transform: [ :aPackage | self classTemplateFor: aPackage ]. - - classes - transmitTo: protocols - transform: [ :aClass | - aClass organization allProtocols + packages + transmitTo: classes + transform: [ :aPackage | aPackage definedClasses asArray ]. + packages + transmitTo: code + transform: [ :aPackage | self classTemplateFor: aPackage ]. + classes + transmitTo: protocols + transform: [ :aClass | + aClass organization allProtocols collect: [ :each | aClass -> each ] as: OrderedCollection ] postTransmission: [ :destination :origin | destination selectIndex: 1 ]. classes transmitTo: code transform: #definitionWithSlots. - - protocols - transmitTo: methods + protocols + transmitTo: methods transform: [ :aPair | - aPair value methods + aPair value methods collect: [ :each | aPair key >> each ] as: OrderedCollection ]. - protocols transmitTo: code transform: [ :aPair | aPair key sourceCodeTemplate ]. - + protocols + transmitTo: code + transform: [ :aPair | aPair key sourceCodeTemplate ]. methods transmitTo: code transform: #sourceCode. - packages items: RPackageOrganizer default packages ] From 5a8345c215c004f84795fda28ee53aa36590eeb7 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 10 Sep 2019 11:37:05 +0200 Subject: [PATCH 3/5] fix borderWidth test --- .../SpMorphicGridLayoutComputation.class.st | 19 ++++++++++++------ .../SpMorphicGridLayoutTest.class.st | 20 ++++++++----------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st b/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st index 237b276a6..e7381a29f 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicGridLayoutComputation.class.st @@ -113,7 +113,7 @@ SpMorphicGridLayoutComputation >> calculateNotHomogeneousColumnWidths [ "Assign non expandable values" morphs do: [ :each | | column | column := (each valueOfProperty: #gridConstraints) column. - (self isColumnExpandable: column) ifTrue: [ + (self isColumnExpandable: column) ifFalse: [ newColumnWidths at: column put: ((newColumnWidths at: column) max: ((self styleOf: each) width)) ] ]. @@ -135,12 +135,11 @@ SpMorphicGridLayoutComputation >> calculateNotHomogeneousColumnWidths [ ] { #category : #'private computation' } -SpMorphicGridLayoutComputation >> calculateRowHeights [ +SpMorphicGridLayoutComputation >> calculateNotHomogeneousRowHeights [ + "column heights are + - the max height of cells of that row" | newRowHeights | - - layout isRowHomogeneous - ifTrue: [ ^ self calculateHomogeneousRowHeights ]. - + newRowHeights := Array new: numRows withAll: 0. morphs do: [ :each | | row | row := (each valueOfProperty: #gridConstraints) row. @@ -151,6 +150,14 @@ SpMorphicGridLayoutComputation >> calculateRowHeights [ ^ newRowHeights ] +{ #category : #'private computation' } +SpMorphicGridLayoutComputation >> calculateRowHeights [ + + ^ layout isRowHomogeneous + ifTrue: [ self calculateHomogeneousRowHeights ] + ifFalse: [ self calculateNotHomogeneousRowHeights ] +] + { #category : #accessing } SpMorphicGridLayoutComputation >> cellExtentAt: aPoint [ diff --git a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st index 3f6427b0d..91ae63c74 100644 --- a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st +++ b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st @@ -101,13 +101,6 @@ SpMorphicGridLayoutTest >> testBasicLayout [ self assert: morph2 bounds equals: (50@20 corner: 100@40) ] -{ #category : #tests } -SpMorphicGridLayoutTest >> testBorderWidth [ - - self testBorderWidthHomogeneous. - self testBorderWidthNotHomogeneous -] - { #category : #tests } SpMorphicGridLayoutTest >> testBorderWidthHomogeneous [ " @@ -158,13 +151,16 @@ SpMorphicGridLayoutTest >> testBorderWidthNotHomogeneous [ self place: label2 at: 1@2. self place: morph2 at: 2@2. - (layout := self newLayout) layout borderWidth: 5. + (layout := self newLayout) layout + beRowNotHomogeneous; + beColumnNotHomogeneous; + borderWidth: 5. layout layout: panel in: (0@0 corner: 100@100). - self assert: label1 bounds equals: (5@5 corner: 50@25). - self assert: morph1 bounds equals: (50@5 corner: 95@25). - self assert: label2 bounds equals: (5@25 corner: 50@45). - self assert: morph2 bounds equals: (50@25 corner: 95@45) + self assert: label1 bounds equals: (5@5 corner: 55@25). + self assert: morph1 bounds equals: (55@5 corner: 105@25). + self assert: label2 bounds equals: (5@25 corner: 55@45). + self assert: morph2 bounds equals: (55@25 corner: 105@45) ] { #category : #tests } From 124e6500ba37980346e9e2ea27f8f6ca0d965f45 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 10 Sep 2019 11:51:05 +0200 Subject: [PATCH 4/5] fix testColumnHomogeneousDiferentRowsAndColumns --- .../SpStyleGeometry.class.st | 36 +++++++++++++++++++ .../SpMorphicGridLayoutTest.class.st | 17 +++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpStyleGeometry.class.st b/src/Spec2-Adapters-Morphic/SpStyleGeometry.class.st index cee53f3f9..cb9ea649a 100644 --- a/src/Spec2-Adapters-Morphic/SpStyleGeometry.class.st +++ b/src/Spec2-Adapters-Morphic/SpStyleGeometry.class.st @@ -107,18 +107,36 @@ SpStyleGeometry >> maxExtent: anObject [ maxExtent := anObject ] +{ #category : #private } +SpStyleGeometry >> maxExtentOrDefault [ + + ^ maxExtent ifNil: [ 0@0 ] +] + { #category : #accessing } SpStyleGeometry >> maxHeight [ ^ self maxExtent ifNotNil: [ :aPoint | aPoint y ] ] +{ #category : #accessing } +SpStyleGeometry >> maxHeight: aNumber [ + + self maxExtent: (self maxExtentOrDefault x@aNumber) +] + { #category : #accessing } SpStyleGeometry >> maxWidth [ ^ self maxExtent ifNotNil: [ :aPoint | aPoint x ] ] +{ #category : #accessing } +SpStyleGeometry >> maxWidth: aNumber [ + + self maxExtent: (aNumber @ self maxExtentOrDefault y) +] + { #category : #accessing } SpStyleGeometry >> minExtent [ ^ minExtent @@ -129,18 +147,36 @@ SpStyleGeometry >> minExtent: anObject [ minExtent := anObject ] +{ #category : #private } +SpStyleGeometry >> minExtentOrDefault [ + + ^ minExtent ifNil: [ 0@0 ] +] + { #category : #accessing } SpStyleGeometry >> minHeight [ ^ self minExtent ifNotNil: [ :aPoint | aPoint y ] ] +{ #category : #accessing } +SpStyleGeometry >> minHeight: aNumber [ + + self minExtent: (self minExtentOrDefault x@aNumber) +] + { #category : #accessing } SpStyleGeometry >> minWidth [ ^ self minExtent ifNotNil: [ :aPoint | aPoint x ] ] +{ #category : #accessing } +SpStyleGeometry >> minWidth: aNumber [ + + self minExtent: (aNumber @ self minExtentOrDefault y) +] + { #category : #private } SpStyleGeometry >> resizingStringFor: expand [ diff --git a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st index 91ae63c74..e86ca1cd9 100644 --- a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st +++ b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st @@ -76,6 +76,17 @@ SpMorphicGridLayoutTest >> styleExtent: aPoint [ ^ SpMorphStyle newStyles: rootStyle flattenClasses ] +{ #category : #private } +SpMorphicGridLayoutTest >> styleMinExtent: aPoint [ + | rootStyle | + + rootStyle := (SpStyleSTONReader fromString: (' +.application [ Geometry \{ #minWidth: {1}, #minHeight: {2} \} ]' + format: { aPoint x. aPoint y })). + + ^ SpMorphStyle newStyles: rootStyle flattenClasses +] + { #category : #tests } SpMorphicGridLayoutTest >> testBasicLayout [ " @@ -185,9 +196,9 @@ SpMorphicGridLayoutTest >> testColumnHomogeneousDiferentRowsAndColumns [ self place: morph2 at: 4@4. layout := self newLayout. - layout layout columnHomogeneous: true. - "make one column width to 100 (it should force all columns to 100, instead 50)" - (self styleExtent: 100@20) applyTo: label2. + layout layout beColumnHomogeneous. + "make one column width to 100 (it should force all columns to 100, instead 25)" + (self styleMinExtent: 100@20) applyTo: label2. layout layout: panel in: (0@0 corner: 100@100). From 55ce0c8e42118e68628132cd0f82410aa1c0c560 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 10 Sep 2019 15:42:32 +0200 Subject: [PATCH 5/5] all tests are green now (that does not means everything work, just that we need more tests) --- .../SpMorphicGridLayout.class.st | 12 ++++---- .../SpMorphicGridLayoutTest.class.st | 30 +++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/Spec2-Adapters-Morphic/SpMorphicGridLayout.class.st b/src/Spec2-Adapters-Morphic/SpMorphicGridLayout.class.st index 75f62f17c..13f85d6b9 100644 --- a/src/Spec2-Adapters-Morphic/SpMorphicGridLayout.class.st +++ b/src/Spec2-Adapters-Morphic/SpMorphicGridLayout.class.st @@ -55,20 +55,22 @@ SpMorphicGridLayout >> calculateExtentFor: aMorph constraint: constraint computa { #category : #private } SpMorphicGridLayout >> calculateHeightFor: aMorph base: aNumber [ - self isRowHomogeneous ifTrue: [ ^ aNumber ]. + "self isRowHomogeneous ifTrue: [ ^ aNumber ]. aMorph vResizing = #spaceFill ifTrue: [ ^ aNumber ]. - ^ aMorph height + ^ aMorph height" + ^ aNumber ] { #category : #private } SpMorphicGridLayout >> calculateWidthFor: aMorph base: aNumber [ - self isColumnHomogeneous ifTrue: [ ^ aNumber ]. + "self isColumnHomogeneous ifTrue: [ ^ aNumber ]. aMorph hResizing = #spaceFill ifTrue: [ ^ aNumber ]. - ^ aMorph width + ^ aMorph width" + ^ aNumber ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SpMorphicGridLayout >> columnConstraintsAt: aNumber [ ^ layout columnConstraintsAt: aNumber diff --git a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st index e86ca1cd9..9addc5c84 100644 --- a/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st +++ b/src/Spec2-Morphic-Backend-Tests/SpMorphicGridLayoutTest.class.st @@ -231,12 +231,12 @@ SpMorphicGridLayoutTest >> testColumnNotHomogeneousDiferentRowsAndColumns [ self place: morph2 at: 4@4. layout := self newLayout. - layout layout columnHomogeneous: false. + layout layout beColumnNotHomogeneous. "make columns differ, to make each column different" - label1 width: 30. - morph1 width: 40. - label2 width: 50. - morph2 width: 60. + (self styleExtent: 30@20) applyTo: label1. + (self styleExtent: 40@20) applyTo: morph1. + (self styleExtent: 50@20) applyTo: label2. + (self styleExtent: 60@20) applyTo: morph2. layout layout: panel in: (0@0 corner: 100@100). @@ -249,7 +249,7 @@ SpMorphicGridLayoutTest >> testColumnNotHomogeneousDiferentRowsAndColumns [ { #category : #tests } SpMorphicGridLayoutTest >> testColumnNotHomogeneousPairedRowsAndColumns [ - "Paired elements in a rows and columns + "Paired elements in rows and columns ----------- | 50 | 60 | @@ -266,19 +266,19 @@ SpMorphicGridLayoutTest >> testColumnNotHomogeneousPairedRowsAndColumns [ self place: morph2 at: 2@2. layout := self newLayout. - layout layout columnHomogeneous: false. + layout layout beColumnNotHomogeneous. "make columns differ, to make each column different" - label1 width: 30. - morph1 width: 40. - label2 width: 50. - morph2 width: 60. + (self styleExtent: 30@20) applyTo: label1. + (self styleExtent: 50@20) applyTo: morph1. + (self styleExtent: 40@20) applyTo: label2. + (self styleExtent: 60@20) applyTo: morph2. layout layout: panel in: (0@0 corner: 100@100). - self assert: label1 bounds equals: (0@0 corner: 50@20). - self assert: morph1 bounds equals: (50@0 corner: 110@20). - self assert: label2 bounds equals: (0@20 corner: 50@40). - self assert: morph2 bounds equals: (50@20 corner: 110@40) + self assert: label1 bounds equals: (0@0 corner: 40@20). + self assert: morph1 bounds equals: (40@0 corner: 100@20). + self assert: label2 bounds equals: (0@20 corner: 40@40). + self assert: morph2 bounds equals: (40@20 corner: 100@40) ]