From 527cf4c944331950d372e109ec0c0817cf1d91c0 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 14 Nov 2023 15:18:44 +0100 Subject: [PATCH 01/12] Presents watches in a simple grid per permutation (does not handle overflow yet) --- .../Sandblocks-Babylonian/SBCluster.class.st | 147 ++++++++++++++++++ .../SBExampleCluster.class.st | 12 ++ .../SBExampleValueDisplay.class.st | 12 ++ .../SBExampleWatch.class.st | 14 +- .../Sandblocks-Babylonian/SBGrid.class.st | 62 ++++++++ .../SBPermutationCluster.class.st | 32 ++++ .../SBResultsView.class.st | 7 +- .../Sandblocks-Watch/SBWatchView.class.st | 2 +- 8 files changed, 284 insertions(+), 4 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBCluster.class.st create mode 100644 packages/Sandblocks-Babylonian/SBExampleCluster.class.st create mode 100644 packages/Sandblocks-Babylonian/SBGrid.class.st create mode 100644 packages/Sandblocks-Babylonian/SBPermutationCluster.class.st diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st new file mode 100644 index 00000000..67893ea4 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -0,0 +1,147 @@ +Class { + #name : #SBCluster, + #superclass : #Morph, + #instVars : [ + 'morphResizer' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'initialize-release' } +SBCluster class >> newFromWatches: aCollectionOfSBExampleWatches havingSize: aSBMorphResizer [ + + ^ self new + morphResizer: aSBMorphResizer; + buildFromWatches: aCollectionOfSBExampleWatches; + yourself + +] + +{ #category : #visualisation } +SBCluster >> buildFromWatches: aCollectionOfSBExampleWatches [ + + | matrix | + matrix := self watchesAsMatrix: aCollectionOfSBExampleWatches. + (matrix rowCount < 2 or: [matrix columnCount < 2]) ifTrue: [ ^ self]. + + self addAllMorphsBack: { + self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" + self newContainerMorph + listDirection: #leftToRight; + cellInset: 0; + addAllMorphsBack: { + self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph" + SBGrid newDisplaying: + ((matrix atRows: 2 to: matrix rowCount columns: 2 to: matrix columnCount) + collect: [:aMorph | self wrapInCell: aMorph])}} +] + +{ #category : #initialization } +SBCluster >> initialize [ + + super initialize. + + self + color: Color white; + changeTableLayout; + listDirection: #topToBottom; + vResizing: #shrinkWrap; + hResizing: #shrinkWrap +] + +{ #category : #accessing } +SBCluster >> morphResizer [ + + ^ morphResizer +] + +{ #category : #accessing } +SBCluster >> morphResizer: aSBMorphResizer [ + + morphResizer := aSBMorphResizer +] + +{ #category : #helper } +SBCluster >> newCellMorph [ + + ^ self morphResizer applyOn: ( + Morph new + color: Color blue; + changeTableLayout; + listDirection: #topToBottom; + listCentering: #center; + wrapCentering: #center; + hResizing: #rigid; + vResizing: #rigid) +] + +{ #category : #helper } +SBCluster >> newContainerMorph [ + + ^ Morph new + color: Color banana; + changeTableLayout; + listDirection: #topToBottom; + hResizing: #shrinkWrap; + vResizing: #shrinkWrap; + cellInset: SBGrid cellInsetValue +] + +{ #category : #visualisation } +SBCluster >> newLeftColumnFrom: aCollectionOfMorphs [ + + "Height should be set, but width can vary" + ^ self newContainerMorph + cellPositioning: #rightCenter; + addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph | + (self wrapInCell: aMorph flexVertically: false flexHorizontally: true) + listDirection: #rightToLeft]) +] + +{ #category : #visualisation } +SBCluster >> newTopLeftCornerPlaceholder [ + + ^ self newCellMorph +] + +{ #category : #visualisation } +SBCluster >> newTopRowFrom: aCollectionOfMorphs [ + + "Width should be set, but height can vary" + ^ self newContainerMorph + listDirection: #leftToRight; + listCentering: #bottomRight; + cellPositioning: #bottomCenter; + hResizing: #spaceFill; + addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph | + aMorph rotationDegrees: 90. + self wrapInCell: aMorph owner flexVertically: true flexHorizontally: false]) +] + +{ #category : #converting } +SBCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ + + "Determine how watches are dissected to create a grid. We assume inclusion of headings per default" + ^ self subclassResponsibility. +] + +{ #category : #helper } +SBCluster >> wrapInCell: aMorph [ + + ^ self wrapInCell: aMorph flexVertically: false flexHorizontally: false + +] + +{ #category : #helper } +SBCluster >> wrapInCell: aMorph flexVertically: aVBoolean flexHorizontally: aHBoolean [ + + | cell | + cell := self newCellMorph. + + aVBoolean ifTrue: [cell vResizing: #shrinkWrap]. + aHBoolean ifTrue: [cell hResizing: #shrinkWrap]. + + cell addMorph: aMorph. + + ^ cell +] diff --git a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st new file mode 100644 index 00000000..73c077a5 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st @@ -0,0 +1,12 @@ +Class { + #name : #SBExampleCluster, + #superclass : #SBCluster, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'as yet unclassified' } +SBExampleCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ + + "Determine how watches are dissected to create a grid" + ^ self subclassResponsibility. +] diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 0a93f4f6..2325bc00 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -21,6 +21,12 @@ SBExampleValueDisplay >> clear [ hadValue := false ] +{ #category : #accessing } +SBExampleValueDisplay >> display [ + + ^ display +] + { #category : #accessing } SBExampleValueDisplay >> displayedWatchValueBlocks [ @@ -91,6 +97,12 @@ SBExampleValueDisplay >> label: aString [ label contents: aString ] +{ #category : #accessing } +SBExampleValueDisplay >> labelMorph [ + + ^ label +] + { #category : #layout } SBExampleValueDisplay >> layoutCommands [ diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index 3be95f48..2a86e85a 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -188,6 +188,12 @@ SBExampleWatch >> exampleStopped: anExample [ exampleToDisplay removeKey: anExample] ] +{ #category : #accessing } +SBExampleWatch >> exampleToDisplay [ + + ^ exampleToDisplay +] + { #category : #accessing } SBExampleWatch >> exampleToDisplay: anExampleToDisplayDict [ @@ -200,6 +206,12 @@ SBExampleWatch >> exampleToValues: anExampleToCollectionOfObjectsDict [ exampleToValues := anExampleToCollectionOfObjectsDict ] +{ #category : #accessing } +SBExampleWatch >> examples [ + + ^ exampleToDisplay keys +] + { #category : #accessing } SBExampleWatch >> expression [ @@ -244,7 +256,7 @@ SBExampleWatch >> initialize [ exampleToValues := Dictionary new. watchedExpression := SBStMessageSend new. dimensionOptions := SBComboBox new - prefix: 'Dimensions: '; + prefix: 'Morph Dimensions: '; labels: (options collect: #label); values: options; object: options third; diff --git a/packages/Sandblocks-Babylonian/SBGrid.class.st b/packages/Sandblocks-Babylonian/SBGrid.class.st new file mode 100644 index 00000000..d8fd6cd9 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBGrid.class.st @@ -0,0 +1,62 @@ +Class { + #name : #SBGrid, + #superclass : #Morph, + #instVars : [ + 'columnCount' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #constants } +SBGrid class >> cellInsetValue [ + + ^ 5 +] + +{ #category : #'initialize-release' } +SBGrid class >> newDisplaying: aMatrixOfMorphs [ + + ^ self new + buildFromMatrix: aMatrixOfMorphs; + yourself +] + +{ #category : #visualisation } +SBGrid >> buildFromMatrix: aMatrixOfMorphs [ + + self submorphs copy do: #abandon. + columnCount := aMatrixOfMorphs columnCount. + + aMatrixOfMorphs do: [:aMorph | self addMorphBack: aMorph]. + self updateWidthToPersistColumns. +] + +{ #category : #initialization } +SBGrid >> initialize [ + + super initialize. + columnCount := 5. + + self + color: Color transparent; + layoutPolicy: TableLayout new; + listDirection: #leftToRight; + wrapDirection: #topToBottom; + wrapCentering: #topLeft; + cellInset: self class cellInsetValue; + width: 500; + vResizing: #shrinkWrap. +] + +{ #category : #'as yet unclassified' } +SBGrid >> resizeContents: aSBMorphResizer [ + + self submorphsDo: [:aSubmorph | aSBMorphResizer applyOn: aSubmorph]. + self updateWidthToPersistColumns. +] + +{ #category : #visualisation } +SBGrid >> updateWidthToPersistColumns [ + + self width: (columnCount * (self submorphs first width + (2 * self class cellInsetValue))) +] diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st new file mode 100644 index 00000000..c916d836 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -0,0 +1,32 @@ +Class { + #name : #SBPermutationCluster, + #superclass : #SBCluster, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #visualisation } +SBPermutationCluster >> extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches [ + + ^ (aCollectionOfSBExampleWatches collect: [:aWatch | aWatch expression]) +] + +{ #category : #visualisation } +SBPermutationCluster >> extractedTopHeadingsFrom: aCollectionOfSBExampleWatches [ + + ^ (aCollectionOfSBExampleWatches first exampleToDisplay values collect: [:aDisplay | aDisplay labelMorph]) +] + +{ #category : #visualisation } +SBPermutationCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ + + | matrix | + matrix := Matrix + rows: aCollectionOfSBExampleWatches size + 1 + columns: (aCollectionOfSBExampleWatches first examples size) + 1. + matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, (self extractedTopHeadingsFrom: aCollectionOfSBExampleWatches)). + matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, (self extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches)). + aCollectionOfSBExampleWatches withIndexDo: [:aWatch :row | + aWatch exampleToDisplay withIndexDo: [:exampleDisplayAssc :column | . + matrix at: row+1 at: column+1 put: (exampleDisplayAssc display)]]. + ^ matrix +] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index ff4ec18f..ceb0768e 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -85,8 +85,11 @@ SBResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aColle self block addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. self applyButtonFor: aPermutation. - (self containerRow listDirection: #leftToRight) - addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks). + (self containerRow listDirection: #leftToRight) + addMorph: (( + SBPermutationCluster + newFromWatches: (self allWatchesIn: aCollectionOfMethodBlocks) + havingSize: (SBMorphResizer newSmall))). LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index f7fb96ea..97ad503f 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -216,7 +216,7 @@ SBWatchView >> layoutCommands [ { #category : #layout } SBWatchView >> maxWidth [ - ^ 350 + ^ 10 ] { #category : #accessing } From fddf8ded3ee1416a800ab54495eb7a9ded464e37 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 14 Nov 2023 19:38:12 +0100 Subject: [PATCH 02/12] Resolves overflow of grid results view by squeezing morphs into imagemorph --- .../Sandblocks-Babylonian/SBCluster.class.st | 4 +-- .../SBExploriantsView.class.st | 8 ++++- .../Sandblocks-Babylonian/SBGrid.class.st | 4 +-- .../SBGridResultsView.class.st | 26 +++++++++++++++ .../SBPermutationCluster.class.st | 33 +++++++++++++++---- .../SBResultsView.class.st | 9 ++--- .../Sandblocks-Watch/SBLineChart.class.st | 4 +-- .../Sandblocks-Watch/SBWatchView.class.st | 2 +- 8 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBGridResultsView.class.st diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index 67893ea4..cd0c8841 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -66,7 +66,7 @@ SBCluster >> newCellMorph [ ^ self morphResizer applyOn: ( Morph new - color: Color blue; + color: Color transparent ; changeTableLayout; listDirection: #topToBottom; listCentering: #center; @@ -79,7 +79,7 @@ SBCluster >> newCellMorph [ SBCluster >> newContainerMorph [ ^ Morph new - color: Color banana; + color: Color transparent ; changeTableLayout; listDirection: #topToBottom; hResizing: #shrinkWrap; diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 103d9f5b..b0214dcf 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -15,10 +15,16 @@ SBExploriantsView class >> block: aSBBlock named: aString [ self shouldNotImplement ] +{ #category : #util } +SBExploriantsView class >> deepSubclasses: aClass [ + + ^ {aClass}, ((aClass subclasses collect: [:aSubclass | self deepSubclasses: aSubclass]) flatten) +] + { #category : #'instance creation' } SBExploriantsView class >> getTabs [ - ^ self subclasses collect: #new + ^ (self subclasses collect: [:mySubClass | self deepSubclasses: mySubClass]) flatten collect: #new ] { #category : #accessing } diff --git a/packages/Sandblocks-Babylonian/SBGrid.class.st b/packages/Sandblocks-Babylonian/SBGrid.class.st index d8fd6cd9..792d84e2 100644 --- a/packages/Sandblocks-Babylonian/SBGrid.class.st +++ b/packages/Sandblocks-Babylonian/SBGrid.class.st @@ -10,7 +10,7 @@ Class { { #category : #constants } SBGrid class >> cellInsetValue [ - ^ 5 + ^ 2 ] { #category : #'initialize-release' } @@ -58,5 +58,5 @@ SBGrid >> resizeContents: aSBMorphResizer [ { #category : #visualisation } SBGrid >> updateWidthToPersistColumns [ - self width: (columnCount * (self submorphs first width + (2 * self class cellInsetValue))) + self width: (columnCount * (self submorphs first width + (2 * self cellInset))) ] diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st new file mode 100644 index 00000000..5bebec02 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -0,0 +1,26 @@ +Class { + #name : #SBGridResultsView, + #superclass : #SBResultsView, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #building } +SBGridResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aCollectionOfMethodBlocks [ + + self block addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. + self applyButtonFor: aPermutation. + (self containerRow listDirection: #leftToRight) + addMorph: (( + SBPermutationCluster + newFromWatches: (self allWatchesIn: aCollectionOfMethodBlocks) + havingSize: (SBMorphResizer newSmall))). + LineMorph from: 0@0 to: 50@0 color: Color black width: 2} +] + +{ #category : #initialization } +SBGridResultsView >> initialize [ + + super initialize. + + self name: 'Grid View' +] diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index c916d836..6588cfce 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -4,16 +4,32 @@ Class { #category : #'Sandblocks-Babylonian' } +{ #category : #visualisation } +SBPermutationCluster >> extractColumnsFrom: anExampleWatch [ + + ^ anExampleWatch exampleToDisplay collect: [:anExampleValueDisplay | | watchview | + watchview := anExampleValueDisplay display copy. + self flag: #todo. "Another way besides turning into an image to keep interactions.-jb" + ImageMorph new + on: #click send: #exploreValues to: watchview; + newForm: ( + self newCellMorph + listDirection: #leftToRight; + wrapDirection: #topToBottom; + addAllMorphsBack: watchview displayedMorphs; + iconOrThumbnailOfSize: self newCellMorph extent)]. +] + { #category : #visualisation } SBPermutationCluster >> extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches [ - ^ (aCollectionOfSBExampleWatches collect: [:aWatch | aWatch expression]) + ^ (aCollectionOfSBExampleWatches collect: [:aWatch | aWatch expression copy]) ] { #category : #visualisation } SBPermutationCluster >> extractedTopHeadingsFrom: aCollectionOfSBExampleWatches [ - ^ (aCollectionOfSBExampleWatches first exampleToDisplay values collect: [:aDisplay | aDisplay labelMorph]) + ^ (aCollectionOfSBExampleWatches first exampleToDisplay values collect: [:aDisplay | aDisplay labelMorph copy]) ] { #category : #visualisation } @@ -23,10 +39,15 @@ SBPermutationCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ matrix := Matrix rows: aCollectionOfSBExampleWatches size + 1 columns: (aCollectionOfSBExampleWatches first examples size) + 1. - matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, (self extractedTopHeadingsFrom: aCollectionOfSBExampleWatches)). - matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, (self extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches)). + + matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedTopHeadingsFrom: aCollectionOfSBExampleWatches)). + matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches)). + aCollectionOfSBExampleWatches withIndexDo: [:aWatch :row | - aWatch exampleToDisplay withIndexDo: [:exampleDisplayAssc :column | . - matrix at: row+1 at: column+1 put: (exampleDisplayAssc display)]]. + (self extractColumnsFrom: aWatch) withIndexDo: [:aCellMorph :column| + matrix at: row+1 at: column+1 put: aCellMorph]]. + ^ matrix ] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index ceb0768e..bd221626 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -85,11 +85,8 @@ SBResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aColle self block addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. self applyButtonFor: aPermutation. - (self containerRow listDirection: #leftToRight) - addMorph: (( - SBPermutationCluster - newFromWatches: (self allWatchesIn: aCollectionOfMethodBlocks) - havingSize: (SBMorphResizer newSmall))). + (self containerRow listDirection: #leftToRight) + addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks). LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] @@ -98,7 +95,7 @@ SBResultsView >> initialize [ super initialize. - self name: 'Possible Results' + self name: 'Simple View' ] { #category : #building } diff --git a/packages/Sandblocks-Watch/SBLineChart.class.st b/packages/Sandblocks-Watch/SBLineChart.class.st index c3429539..e52501c7 100644 --- a/packages/Sandblocks-Watch/SBLineChart.class.st +++ b/packages/Sandblocks-Watch/SBLineChart.class.st @@ -34,7 +34,7 @@ SBLineChart >> datapointDefaultColor [ { #category : #'visualization - constants' } SBLineChart >> datapointExtent [ - ^ 5@5 + ^ 4@4 ] { #category : #visualization } @@ -164,7 +164,7 @@ SBLineChart >> scaleYOffset [ { #category : #'visualization - constants' } SBLineChart >> spaceBetweenPoints [ - ^ 15 + ^ 10 ] { #category : #visualization } diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index 97ad503f..f7fb96ea 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -216,7 +216,7 @@ SBWatchView >> layoutCommands [ { #category : #layout } SBWatchView >> maxWidth [ - ^ 10 + ^ 350 ] { #category : #accessing } From b374de3575242adbeba5b95cdd2b8f374ad6f4f8 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Wed, 15 Nov 2023 13:55:00 +0100 Subject: [PATCH 03/12] watchvalues in grid view have uniform size --- .../Sandblocks-Babylonian/Form.extension.st | 1 - .../Sandblocks-Babylonian/Morph.extension.st | 1 - .../SBGridResultsView.class.st | 2 +- .../SBPermutationCluster.class.st | 22 ++++++++++--------- .../SBWatchValue.class.st | 3 ++- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/Sandblocks-Babylonian/Form.extension.st b/packages/Sandblocks-Babylonian/Form.extension.st index a4ac5825..097d1265 100644 --- a/packages/Sandblocks-Babylonian/Form.extension.st +++ b/packages/Sandblocks-Babylonian/Form.extension.st @@ -10,7 +10,6 @@ Form >> sbSnapshot [ Form >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ ^ (SBWatchValue newContainerMorphFor: aSBWatchValue) - addMorphBack: (SBIcon iconFor: aSBWatchValue watchedValueIdentityHash) asMorph; addMorphBack: (aSBMorphResizer applyOn: self asMorph); yourself ] diff --git a/packages/Sandblocks-Babylonian/Morph.extension.st b/packages/Sandblocks-Babylonian/Morph.extension.st index cc0ef7c4..f5f02ecb 100644 --- a/packages/Sandblocks-Babylonian/Morph.extension.st +++ b/packages/Sandblocks-Babylonian/Morph.extension.st @@ -4,7 +4,6 @@ Extension { #name : #Morph } Morph >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ ^ (SBWatchValue newContainerMorphFor: aSBWatchValue) - addMorphBack: (SBIcon iconFor: aSBWatchValue watchedValueIdentityHash) asMorph; addMorphBack: (aSBMorphResizer applyOn: self sbSnapshot asMorph); yourself ] diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 5bebec02..e861ed00 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -13,7 +13,7 @@ SBGridResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aC addMorph: (( SBPermutationCluster newFromWatches: (self allWatchesIn: aCollectionOfMethodBlocks) - havingSize: (SBMorphResizer newSmall))). + havingSize: (SBMorphResizer newMedium))). LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index 6588cfce..95b4c849 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -7,17 +7,19 @@ Class { { #category : #visualisation } SBPermutationCluster >> extractColumnsFrom: anExampleWatch [ - ^ anExampleWatch exampleToDisplay collect: [:anExampleValueDisplay | | watchview | - watchview := anExampleValueDisplay display copy. + ^ anExampleWatch exampleToDisplay collect: [:anExampleValueDisplay | | displayedMorphs | + displayedMorphs := anExampleValueDisplay display displayedMorphs + collect: [:aMorph | aMorph watchValue morphResizer: self morphResizer. aMorph watchValue asValueMorph]. self flag: #todo. "Another way besides turning into an image to keep interactions.-jb" - ImageMorph new - on: #click send: #exploreValues to: watchview; - newForm: ( - self newCellMorph - listDirection: #leftToRight; - wrapDirection: #topToBottom; - addAllMorphsBack: watchview displayedMorphs; - iconOrThumbnailOfSize: self newCellMorph extent)]. + (displayedMorphs size = 1) + ifTrue: [displayedMorphs first] + ifFalse: [ + ImageMorph new newForm: ( + self newCellMorph + listDirection: #leftToRight; + wrapDirection: #topToBottom; + addAllMorphsBack: displayedMorphs; + iconOrThumbnailOfSize: self newCellMorph extent)]]. ] { #category : #visualisation } diff --git a/packages/Sandblocks-Babylonian/SBWatchValue.class.st b/packages/Sandblocks-Babylonian/SBWatchValue.class.st index 96a3a8d8..635516f3 100644 --- a/packages/Sandblocks-Babylonian/SBWatchValue.class.st +++ b/packages/Sandblocks-Babylonian/SBWatchValue.class.st @@ -70,7 +70,8 @@ SBWatchValue >> morphResizer [ { #category : #accessing } SBWatchValue >> morphResizer: aSBMorphResizer [ - morphResizer := aSBMorphResizer + morphResizer := aSBMorphResizer. + ] { #category : #printing } From fedbf579dc7e30bbee588fb8cdfd1b6dfc1653f7 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Thu, 16 Nov 2023 13:53:46 +0100 Subject: [PATCH 04/12] Adds SBUniverse / SBMultiverse to save objects in a permutation (makes things faster) --- .../SBExploriants.class.st | 8 +- .../SBExploriantsView.class.st | 51 +++--- .../SBGridResultsView.class.st | 8 +- .../SBMultiverse.class.st | 159 ++++++++++++++++++ .../SBResultsView.class.st | 71 ++------ .../Sandblocks-Babylonian/SBUniverse.class.st | 45 +++++ .../SBVariantsView.class.st | 2 +- 7 files changed, 245 insertions(+), 99 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBMultiverse.class.st create mode 100644 packages/Sandblocks-Babylonian/SBUniverse.class.st diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 37008cae..11619e7d 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -75,7 +75,7 @@ SBExploriants >> saveTryFixing: aFixBoolean quick: aQuickBoolean [ ^ true ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SBExploriants >> selector [ " if this node represents any selector, return it here " @@ -85,11 +85,9 @@ SBExploriants >> selector [ { #category : #actions } SBExploriants >> visualize [ - "The Views need a parent to visualize themselves. We also want to avoid double-calculations" | tabs | - tabs := SBExploriantsView getTabs. - tabs do: [:aTab | self addMorph: aTab block. aTab visualize.]. - self removeAllMorphs. + tabs := SBExploriantsView getTabsInMultiverse: (SBMultiverse newInEditor: self sandblockEditor). + tabs do: #visualize. self namedBlocks: tabs activeIndex: 1. diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index b0214dcf..c1d3d22d 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -1,10 +1,9 @@ -" -Caution: -The Views need a parent who in in the editor to visualize themselves -" Class { #name : #SBExploriantsView, #superclass : #SBNamedBlock, + #instVars : [ + 'multiverse' + ], #category : #'Sandblocks-Babylonian' } @@ -22,34 +21,18 @@ SBExploriantsView class >> deepSubclasses: aClass [ ] { #category : #'instance creation' } -SBExploriantsView class >> getTabs [ +SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [ - ^ (self subclasses collect: [:mySubClass | self deepSubclasses: mySubClass]) flatten collect: #new + ^ (self subclasses collect: [:mySubClass | self deepSubclasses: mySubClass]) flatten + collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] -{ #category : #accessing } -SBExploriantsView >> allCompiledMethodsContainingClass: aClass [ - - "aClass should have #matchingSelectors implemented" - ^ (((aClass matchingSelectors collect: [:aSelector | self systemNavigation allCallsOn: aSelector]) flatten) - reject: [:aMethodReference | aMethodReference actualClass = aClass class]) - collect: #compiledMethod -] - -{ #category : #accessing } -SBExploriantsView >> allCompiledMethodsContainingVariants [ - - ^ self allCompiledMethodsContainingClass: SBVariant -] - -{ #category : #accessing } -SBExploriantsView >> allMethodBlocksContainingVariants [ - - "We are looking for already opened methods so that we can assign the - variant there as the original in SBVariantProxy. That way, we immediately - have consistency between changes." - ^ self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants +{ #category : #'instance creation' } +SBExploriantsView class >> newMultiverse: aSBMultiverse [ + ^ self new + multiverse: aSBMultiverse; + yourself ] { #category : #actions } @@ -100,6 +83,18 @@ SBExploriantsView >> initialize [ vResizing: #shrinkWrap) ] +{ #category : #accessing } +SBExploriantsView >> multiverse [ + + ^ multiverse ifNil: [multiverse := SBMultiverse newInEditor: SBEditor current] +] + +{ #category : #accessing } +SBExploriantsView >> multiverse: aSBMultiverse [ + + multiverse := aSBMultiverse +] + { #category : #actions } SBExploriantsView >> visualize [ diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index e861ed00..feb7fe26 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -5,14 +5,14 @@ Class { } { #category : #building } -SBGridResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aCollectionOfMethodBlocks [ +SBGridResultsView >> buildPermutationFor: aSBUniverse [ - self block addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. - self applyButtonFor: aPermutation. + self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. + self applyButtonFor: aSBUniverse activePermutation. (self containerRow listDirection: #leftToRight) addMorph: (( SBPermutationCluster - newFromWatches: (self allWatchesIn: aCollectionOfMethodBlocks) + newFromWatches: aSBUniverse watches havingSize: (SBMorphResizer newMedium))). LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st new file mode 100644 index 00000000..49103977 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -0,0 +1,159 @@ +Class { + #name : #SBMultiverse, + #superclass : #Object, + #instVars : [ + 'universes', + 'variants', + 'watches', + 'activeExamples', + 'allMethodBlocksContainingVariants', + 'allMethodBlocksContainingWatches', + 'sandblockEditor' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'instance creation' } +SBMultiverse class >> new [ + + "Use constructor with editor instead" + self shouldNotImplement +] + +{ #category : #'instance creation' } +SBMultiverse class >> newInEditor: aSandblockEditor [ + + ^ self basicNew + sandblockEditor: aSandblockEditor; + initialize; + yourself +] + +{ #category : #accessing } +SBMultiverse >> activeExamples [ + + ^ activeExamples +] + +{ #category : #collecting } +SBMultiverse >> allActiveExamples [ + + ^ (self allCompiledMethodsContainingExamples + collect: [:aCompiledMethod | + "Only examples which are open in the editor can actually be active." + self sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) + ifOpen: [:existingMethodBlock | existingMethodBlock containedExamples select: #active] + ifClosed: [#()]]) flatten +] + +{ #category : #collecting } +SBMultiverse >> allCompiledMethodsContainingClass: aClass [ + + "aClass should have #matchingSelectors implemented" + ^ (((aClass matchingSelectors collect: [:aSelector | self systemNavigation allCallsOn: aSelector]) flatten) + reject: [:aMethodReference | aMethodReference actualClass = aClass class]) + collect: #compiledMethod +] + +{ #category : #collecting } +SBMultiverse >> allCompiledMethodsContainingExampleWatches [ + + ^ self allCompiledMethodsContainingClass: SBExampleWatch +] + +{ #category : #collecting } +SBMultiverse >> allCompiledMethodsContainingExamples [ + + ^ self allCompiledMethodsContainingClass: SBExample +] + +{ #category : #collecting } +SBMultiverse >> allCompiledMethodsContainingVariants [ + + ^ self allCompiledMethodsContainingClass: SBVariant +] + +{ #category : #accessing } +SBMultiverse >> allMethodBlocksContainingVariants [ + + ^ allMethodBlocksContainingVariants + +] + +{ #category : #accessing } +SBMultiverse >> allMethodBlocksContainingWatches [ + + ^ allMethodBlocksContainingWatches + +] + +{ #category : #collecting } +SBMultiverse >> copyWatchesIn: aCollectionOfMethodBlocks [ + + ^ (aCollectionOfMethodBlocks collect: [:aMethodBlock | + aMethodBlock containedExampleWatches collect: #asInactiveCopy]) flatten +] + +{ #category : #converting } +SBMultiverse >> createUniverseFomPermutation: aSBPermutation [ + + ^ SBUniverse + newActive: aSBPermutation + watches: (self copyWatchesIn: self allMethodBlocksContainingWatches) +] + +{ #category : #collecting } +SBMultiverse >> findExistingOrConvertToBlocks: aCollectionOfCompiledMethods [ + + ^ aCollectionOfCompiledMethods + collect: [:aCompiledMethod | + self sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) + ifOpen: [:existingMethodBlock | existingMethodBlock] + ifClosed: [aCompiledMethod asSandblock]] +] + +{ #category : #'initialize-release' } +SBMultiverse >> initialize [ + + super initialize. + + "We are looking for already opened methods so that we can assign the + variant there as the original in SBVariantProxy. That way, we immediately + have consistency between changes." + allMethodBlocksContainingVariants := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingVariants. + + "We need existing originals to be noticed of changes." + allMethodBlocksContainingWatches := self findExistingOrConvertToBlocks: self allCompiledMethodsContainingExampleWatches. + + variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. + activeExamples := self allActiveExamples. + + universes := (SBPermutation allPermutationsOf: variants) collect: [:aPermutation | + self createUniverseFomPermutation: aPermutation]. + + +] + +{ #category : #accessing } +SBMultiverse >> sandblockEditor [ + + ^ sandblockEditor +] + +{ #category : #accessing } +SBMultiverse >> sandblockEditor: aSandblockEditor [ + + sandblockEditor := aSandblockEditor +] + +{ #category : #accessing } +SBMultiverse >> universes [ + + ^ universes +] + +{ #category : #accessing } +SBMultiverse >> variants [ + + ^ variants +] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index bd221626..6d159981 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -4,50 +4,6 @@ Class { #category : #'Sandblocks-Babylonian' } -{ #category : #building } -SBResultsView >> addAllWatchesFrom: aCollectionOfMethodBlocks [ - - self block addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks) -] - -{ #category : #accessing } -SBResultsView >> allActiveExamples [ - - ^ (self allCompiledMethodsContainingExamples - collect: [:aCompiledMethod | - "Only examples which are open in the editor can actually be active." - self block sandblockEditor blockFor: aCompiledMethod withInterfaces: #(#isMethod) - ifOpen: [:existingMethodBlock | existingMethodBlock containedExamples select: #active] - ifClosed: [#()]]) flatten -] - -{ #category : #accessing } -SBResultsView >> allCompiledMethodsContainingExampleWatches [ - - ^ self allCompiledMethodsContainingClass: SBExampleWatch -] - -{ #category : #accessing } -SBResultsView >> allCompiledMethodsContainingExamples [ - - ^ self allCompiledMethodsContainingClass: SBExample -] - -{ #category : #accessing } -SBResultsView >> allMethodBlocksContainingWatches [ - - "We need existing originals to be noticed of changes." - ^ self findExistingOrConvertToBlocks: self allCompiledMethodsContainingExampleWatches - -] - -{ #category : #accessing } -SBResultsView >> allWatchesIn: aCollectionOfMethodBlocks [ - - ^ (aCollectionOfMethodBlocks collect: [:aMethodBlock | - aMethodBlock containedExampleWatches collect: #asInactiveCopy]) flatten -] - { #category : #building } SBResultsView >> applyButtonFor: aPermutation [ @@ -63,30 +19,23 @@ SBResultsView >> applyButtonFor: aPermutation [ { #category : #building } SBResultsView >> buildAllPossibleResults [ - - | permutations activeExamples watchMethodBlocks variants | - self flag: #todo. "don't calculate all variants a second time (first time being the variants view) -jb" - variants := (self allMethodBlocksContainingVariants collect: #containedVariants) flatten. - watchMethodBlocks := self allMethodBlocksContainingWatches. - activeExamples := self allActiveExamples. - permutations := SBPermutation allPermutationsOf: variants. - permutations ifEmpty: [self addAllWatchesFrom: watchMethodBlocks]. + self multiverse universes ifEmpty: [self block addAllMorphsBack: self mutliverse watches]. - [ permutations do: [:aPermutation | - SBActiveVariantPermutation value: aPermutation. - activeExamples do: #runSynchronouslyIgnoreReturn. - self buildPermutationFor: aPermutation collectingWatchesFrom: watchMethodBlocks]. - self resetWatchesToOriginalPermutationRunning: activeExamples] forkAt: Processor userSchedulingPriority + [ self multiverse universes do: [:aUniverse | + SBActiveVariantPermutation value: aUniverse activePermutation. + self multiverse activeExamples do: #runSynchronouslyIgnoreReturn. + self buildPermutationFor: aUniverse]. + self resetWatchesToOriginalPermutationRunning: self multiverse activeExamples] forkAt: Processor userSchedulingPriority ] { #category : #building } -SBResultsView >> buildPermutationFor: aPermutation collectingWatchesFrom: aCollectionOfMethodBlocks [ +SBResultsView >> buildPermutationFor: aSBUniverse [ - self block addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. - self applyButtonFor: aPermutation. + self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. + self applyButtonFor: aSBUniverse activePermutation. (self containerRow listDirection: #leftToRight) - addAllMorphsBack: (self allWatchesIn: aCollectionOfMethodBlocks). + addAllMorphsBack: aSBUniverse watches. LineMorph from: 0@0 to: 50@0 color: Color black width: 2} ] diff --git a/packages/Sandblocks-Babylonian/SBUniverse.class.st b/packages/Sandblocks-Babylonian/SBUniverse.class.st new file mode 100644 index 00000000..a7c0483d --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBUniverse.class.st @@ -0,0 +1,45 @@ +" +A codeflow state caused by a particular permutation, resulting in varying watches +" +Class { + #name : #SBUniverse, + #superclass : #Object, + #instVars : [ + 'activePermutation', + 'watches' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'instance creation' } +SBUniverse class >> newActive: aSBPermutation watches: aCollectionOfSBExampleWatches [ + + ^ self new + activePermutation: aSBPermutation; + watches: aCollectionOfSBExampleWatches; + yourself +] + +{ #category : #accessing } +SBUniverse >> activePermutation [ + + ^ activePermutation +] + +{ #category : #accessing } +SBUniverse >> activePermutation: aSBPermutation [ + + activePermutation := aSBPermutation +] + +{ #category : #accessing } +SBUniverse >> watches [ + + ^ watches +] + +{ #category : #accessing } +SBUniverse >> watches: aCollectionOfSBExampleWatches [ + + watches := aCollectionOfSBExampleWatches +] diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index 034e9d63..2cd6c0ed 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -32,7 +32,7 @@ SBVariantsView >> visualize [ self clean. - self allMethodBlocksContainingVariants + self multiverse allMethodBlocksContainingVariants ifNotEmptyDo: [:theMethods | theMethods do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]] ifEmpty: [self buildNoVariantsText] ] From 04ee20cc2b64ec10b33829a55933718ae2b0d1f8 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 17 Nov 2023 15:50:25 +0100 Subject: [PATCH 05/12] Splits ResultView and commits to a grid layout in one results view --- .../Sandblocks-Babylonian/Point.extension.st | 9 ++++ .../Sandblocks-Babylonian/SBCluster.class.st | 2 +- .../SBExampleCluster.class.st | 12 ----- .../SBExploriantsView.class.st | 8 +-- .../SBGridResultsView.class.st | 52 +++++++++++++++---- .../SBMultiverse.class.st | 3 ++ .../SBPermutationCluster.class.st | 2 +- .../SBPlainResultsView.class.st | 23 ++++++++ .../SBResultsView.class.st | 18 ++----- 9 files changed, 84 insertions(+), 45 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/Point.extension.st delete mode 100644 packages/Sandblocks-Babylonian/SBExampleCluster.class.st create mode 100644 packages/Sandblocks-Babylonian/SBPlainResultsView.class.st diff --git a/packages/Sandblocks-Babylonian/Point.extension.st b/packages/Sandblocks-Babylonian/Point.extension.st new file mode 100644 index 00000000..2450f04a --- /dev/null +++ b/packages/Sandblocks-Babylonian/Point.extension.st @@ -0,0 +1,9 @@ +Extension { #name : #Point } + +{ #category : #'*Sandblocks-Babylonian' } +Point >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ + + ^ (SBWatchValue newContainerMorphFor: aSBWatchValue) + addMorphBack: self asMorph; + yourself +] diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index cd0c8841..e507b746 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -42,7 +42,7 @@ SBCluster >> initialize [ super initialize. self - color: Color white; + color: Color transparent; changeTableLayout; listDirection: #topToBottom; vResizing: #shrinkWrap; diff --git a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st deleted file mode 100644 index 73c077a5..00000000 --- a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st +++ /dev/null @@ -1,12 +0,0 @@ -Class { - #name : #SBExampleCluster, - #superclass : #SBCluster, - #category : #'Sandblocks-Babylonian' -} - -{ #category : #'as yet unclassified' } -SBExampleCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ - - "Determine how watches are dissected to create a grid" - ^ self subclassResponsibility. -] diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index c1d3d22d..9342b946 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -14,16 +14,10 @@ SBExploriantsView class >> block: aSBBlock named: aString [ self shouldNotImplement ] -{ #category : #util } -SBExploriantsView class >> deepSubclasses: aClass [ - - ^ {aClass}, ((aClass subclasses collect: [:aSubclass | self deepSubclasses: aSubclass]) flatten) -] - { #category : #'instance creation' } SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [ - ^ (self subclasses collect: [:mySubClass | self deepSubclasses: mySubClass]) flatten + ^ {SBGridResultsView. SBPlainResultsView. SBVariantsView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index feb7fe26..33cb2750 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -1,20 +1,36 @@ Class { #name : #SBGridResultsView, #superclass : #SBResultsView, + #instVars : [ + 'gridContainer' + ], #category : #'Sandblocks-Babylonian' } { #category : #building } SBGridResultsView >> buildPermutationFor: aSBUniverse [ + + gridContainer addMorphBack: (self containerRow cellPositioning: #center; + addAllMorphsBack: { + self containerRow listDirection: #topToBottom; + addAllMorphsBack: { + SBOwnTextMorph new contents: aSBUniverse activePermutation asString. + self applyButtonFor: aSBUniverse activePermutation. + SBPermutationCluster + newFromWatches: aSBUniverse watches + havingSize: SBMorphResizer newSmall}. + LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). + + gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap)) . +] + +{ #category : #actions } +SBGridResultsView >> clean [ - self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. - self applyButtonFor: aSBUniverse activePermutation. - (self containerRow listDirection: #leftToRight) - addMorph: (( - SBPermutationCluster - newFromWatches: aSBUniverse watches - havingSize: (SBMorphResizer newMedium))). - LineMorph from: 0@0 to: 50@0 color: Color black width: 2} + super clean. + + self block addMorphBack: (gridContainer := self newGridContainer) + ] { #category : #initialization } @@ -22,5 +38,23 @@ SBGridResultsView >> initialize [ super initialize. - self name: 'Grid View' + self name: 'Grid View'. + + self block addMorphBack: (gridContainer := self newGridContainer). +] + +{ #category : #building } +SBGridResultsView >> newGridContainer [ + + ^ SBBlock new + changeTableLayout; + color: Color white; + listDirection: #leftToRight; + wrapDirection: #topToBottom; + wrapCentering: #topLeft; + hResizing: #rigid; + width: 10; + cellInset: 0; + vResizing: #shrinkWrap; + yourself ] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 49103977..a6941921 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -1,3 +1,6 @@ +" +A mostly data class for collecting and caching watches, variants, methods found in a point of time +" Class { #name : #SBMultiverse, #superclass : #Object, diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index 95b4c849..5b8cdbfc 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -34,7 +34,7 @@ SBPermutationCluster >> extractedTopHeadingsFrom: aCollectionOfSBExampleWatches ^ (aCollectionOfSBExampleWatches first exampleToDisplay values collect: [:aDisplay | aDisplay labelMorph copy]) ] -{ #category : #visualisation } +{ #category : #converting } SBPermutationCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ | matrix | diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st new file mode 100644 index 00000000..97a33c37 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -0,0 +1,23 @@ +Class { + #name : #SBPlainResultsView, + #superclass : #SBResultsView, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #building } +SBPlainResultsView >> buildPermutationFor: aSBUniverse [ + + self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. + self applyButtonFor: aSBUniverse activePermutation. + (self containerRow listDirection: #leftToRight) + addAllMorphsBack: aSBUniverse watches. + LineMorph from: 0@0 to: 50@0 color: Color black width: 2} +] + +{ #category : #initialization } +SBPlainResultsView >> initialize [ + + super initialize. + + self name: 'Plain View' +] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index 6d159981..6f7478e0 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -32,19 +32,7 @@ SBResultsView >> buildAllPossibleResults [ { #category : #building } SBResultsView >> buildPermutationFor: aSBUniverse [ - self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. - self applyButtonFor: aSBUniverse activePermutation. - (self containerRow listDirection: #leftToRight) - addAllMorphsBack: aSBUniverse watches. - LineMorph from: 0@0 to: 50@0 color: Color black width: 2} -] - -{ #category : #initialization } -SBResultsView >> initialize [ - - super initialize. - - self name: 'Simple View' + self subclassResponsibility ] { #category : #building } @@ -60,7 +48,7 @@ SBResultsView >> updateButton [ ^ SBButton new icon: SBIcon iconRotateLeft label: 'Re-Generate' - do: [self visualize]; + do: [self multiverse initialize. self visualize]; cornerStyle: #squared ] @@ -69,6 +57,6 @@ SBResultsView >> visualize [ self clean. - self block addMorphBack: self updateButton. + self block addMorphFront: self updateButton. self buildAllPossibleResults ] From 91d8b18686a593a8f97a84f81b7171b0b5c24d8c Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 20 Nov 2023 12:08:59 +0100 Subject: [PATCH 06/12] New width formula --- packages/Sandblocks-Babylonian/SBGridResultsView.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 33cb2750..1e6c070f 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -21,7 +21,7 @@ SBGridResultsView >> buildPermutationFor: aSBUniverse [ havingSize: SBMorphResizer newSmall}. LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). - gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap)) . + gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap) + (2 * self block layoutInset x)). ] { #category : #actions } From 9e2f0724997bc1f0dbf5a2855c3d61ee748d706e Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 20 Nov 2023 14:48:36 +0100 Subject: [PATCH 07/12] Moves size wrapping to wrapInCell and add borders --- .../Sandblocks-Babylonian/SBCluster.class.st | 23 +++++++++++++++---- .../SBExploriants.class.st | 2 +- .../SBGridResultsView.class.st | 2 +- .../SBPermutationCluster.class.st | 10 ++++---- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index e507b746..8e435f3b 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -68,6 +68,8 @@ SBCluster >> newCellMorph [ Morph new color: Color transparent ; changeTableLayout; + borderWidth: 1; + borderStyle: (BorderStyle width: 1 color: (Color gray alpha: 0.3)); listDirection: #topToBottom; listCentering: #center; wrapCentering: #center; @@ -95,7 +97,8 @@ SBCluster >> newLeftColumnFrom: aCollectionOfMorphs [ cellPositioning: #rightCenter; addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph | (self wrapInCell: aMorph flexVertically: false flexHorizontally: true) - listDirection: #rightToLeft]) + listDirection: #rightToLeft; + borderWidth: 0]) ] { #category : #visualisation } @@ -115,7 +118,7 @@ SBCluster >> newTopRowFrom: aCollectionOfMorphs [ hResizing: #spaceFill; addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph | aMorph rotationDegrees: 90. - self wrapInCell: aMorph owner flexVertically: true flexHorizontally: false]) + (self wrapInCell: aMorph owner flexVertically: true flexHorizontally: false) borderWidth: 0]) ] { #category : #converting } @@ -135,13 +138,25 @@ SBCluster >> wrapInCell: aMorph [ { #category : #helper } SBCluster >> wrapInCell: aMorph flexVertically: aVBoolean flexHorizontally: aHBoolean [ - | cell | + | cell targetExtent| cell := self newCellMorph. aVBoolean ifTrue: [cell vResizing: #shrinkWrap]. aHBoolean ifTrue: [cell hResizing: #shrinkWrap]. - cell addMorph: aMorph. + (((aMorph fullBounds extent <= cell extent) + or: [aVBoolean and: (aMorph fullBounds width <= cell width)]) + or: [aHBoolean and: (aMorph fullBounds height <= cell height)]) + ifTrue: [cell addMorph: aMorph. ^ cell]. + targetExtent := cell extent - (cell borderWidth@cell borderWidth). + aVBoolean ifTrue: [targetExtent setX: targetExtent x setY: aMorph fullBounds height]. + aHBoolean ifTrue: [targetExtent setX: aMorph fullBounds width setY: targetExtent height]. + + self flag: #todo. "Another way besides turning into an image to keep interactions.-jb" + cell addMorph: (ImageMorph new + newForm: (aMorph iconOrThumbnailOfSize: targetExtent); + when: #clicked send: #triggerEvent: to: aMorph with: #clicked). + cell on: #click send: #value to: [cell submorphs first triggerEvent: #clicked]. ^ cell ] diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 11619e7d..3ea92a18 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -52,7 +52,6 @@ SBExploriants >> initialize [ self attachDecorator: SBMoveDecorator new; - changeTableLayout; hResizing: #shrinkWrap; vResizing: #shrinkWrap ] @@ -86,6 +85,7 @@ SBExploriants >> selector [ SBExploriants >> visualize [ | tabs | + self width: 0. tabs := SBExploriantsView getTabsInMultiverse: (SBMultiverse newInEditor: self sandblockEditor). tabs do: #visualize. diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 1e6c070f..50eca6f2 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -53,7 +53,7 @@ SBGridResultsView >> newGridContainer [ wrapDirection: #topToBottom; wrapCentering: #topLeft; hResizing: #rigid; - width: 10; + width: 50; cellInset: 0; vResizing: #shrinkWrap; yourself diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index 5b8cdbfc..8fa10e75 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -10,16 +10,14 @@ SBPermutationCluster >> extractColumnsFrom: anExampleWatch [ ^ anExampleWatch exampleToDisplay collect: [:anExampleValueDisplay | | displayedMorphs | displayedMorphs := anExampleValueDisplay display displayedMorphs collect: [:aMorph | aMorph watchValue morphResizer: self morphResizer. aMorph watchValue asValueMorph]. - self flag: #todo. "Another way besides turning into an image to keep interactions.-jb" (displayedMorphs size = 1) ifTrue: [displayedMorphs first] - ifFalse: [ - ImageMorph new newForm: ( - self newCellMorph + ifFalse: [self newCellMorph + borderWidth: 0; + when: #clicked send: #exploreValues to: anExampleValueDisplay display; listDirection: #leftToRight; wrapDirection: #topToBottom; - addAllMorphsBack: displayedMorphs; - iconOrThumbnailOfSize: self newCellMorph extent)]]. + addAllMorphsBack: displayedMorphs]]. ] { #category : #visualisation } From a2e03399b2b525efc7e06b7303276dd00aa78fc6 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 20 Nov 2023 14:54:13 +0100 Subject: [PATCH 08/12] Exploriants Regenerate through multiple windows consistent --- packages/Sandblocks-Babylonian/SBExploriantsView.class.st | 3 ++- packages/Sandblocks-Babylonian/SBMultiverse.class.st | 2 ++ packages/Sandblocks-Babylonian/SBResultsView.class.st | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 9342b946..11ebce72 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -86,7 +86,8 @@ SBExploriantsView >> multiverse [ { #category : #accessing } SBExploriantsView >> multiverse: aSBMultiverse [ - multiverse := aSBMultiverse + multiverse := aSBMultiverse. + multiverse when: #initialized send: #visualize to: self. ] { #category : #actions } diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index a6941921..6bcfdb8d 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -134,6 +134,8 @@ SBMultiverse >> initialize [ universes := (SBPermutation allPermutationsOf: variants) collect: [:aPermutation | self createUniverseFomPermutation: aPermutation]. + self triggerEvent: #initialized. + ] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index 6f7478e0..083bbfc7 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -48,7 +48,7 @@ SBResultsView >> updateButton [ ^ SBButton new icon: SBIcon iconRotateLeft label: 'Re-Generate' - do: [self multiverse initialize. self visualize]; + do: [self multiverse initialize]; cornerStyle: #squared ] From 0a91b133ec649d2d7a1853eccfac18a79c40b42b Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 20 Nov 2023 16:26:58 +0100 Subject: [PATCH 09/12] Display grid even when no variants --- .../Sandblocks-Babylonian/SBCluster.class.st | 2 +- .../SBExploriantsView.class.st | 2 +- .../SBGridResultsView.class.st | 19 -------- .../SBMultiverse.class.st | 7 ++- .../SBPermutationGridsView.class.st | 45 +++++++++++++++++++ .../SBResultsView.class.st | 15 ++++++- 6 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index 8e435f3b..0da27326 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -22,7 +22,7 @@ SBCluster >> buildFromWatches: aCollectionOfSBExampleWatches [ | matrix | matrix := self watchesAsMatrix: aCollectionOfSBExampleWatches. - (matrix rowCount < 2 or: [matrix columnCount < 2]) ifTrue: [ ^ self]. + matrix ifEmpty: [ ^ self]. self addAllMorphsBack: { self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 11ebce72..d31f0033 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -17,7 +17,7 @@ SBExploriantsView class >> block: aSBBlock named: aString [ { #category : #'instance creation' } SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [ - ^ {SBGridResultsView. SBPlainResultsView. SBVariantsView} + ^ {SBPermutationGridsView. SBPlainResultsView. SBVariantsView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 50eca6f2..9337a5e7 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -7,23 +7,6 @@ Class { #category : #'Sandblocks-Babylonian' } -{ #category : #building } -SBGridResultsView >> buildPermutationFor: aSBUniverse [ - - gridContainer addMorphBack: (self containerRow cellPositioning: #center; - addAllMorphsBack: { - self containerRow listDirection: #topToBottom; - addAllMorphsBack: { - SBOwnTextMorph new contents: aSBUniverse activePermutation asString. - self applyButtonFor: aSBUniverse activePermutation. - SBPermutationCluster - newFromWatches: aSBUniverse watches - havingSize: SBMorphResizer newSmall}. - LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). - - gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap) + (2 * self block layoutInset x)). -] - { #category : #actions } SBGridResultsView >> clean [ @@ -38,8 +21,6 @@ SBGridResultsView >> initialize [ super initialize. - self name: 'Grid View'. - self block addMorphBack: (gridContainer := self newGridContainer). ] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 6bcfdb8d..85031c10 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -7,7 +7,6 @@ Class { #instVars : [ 'universes', 'variants', - 'watches', 'activeExamples', 'allMethodBlocksContainingVariants', 'allMethodBlocksContainingWatches', @@ -91,9 +90,9 @@ SBMultiverse >> allMethodBlocksContainingWatches [ ] { #category : #collecting } -SBMultiverse >> copyWatchesIn: aCollectionOfMethodBlocks [ +SBMultiverse >> copyWatches [ - ^ (aCollectionOfMethodBlocks collect: [:aMethodBlock | + ^ (self allMethodBlocksContainingWatches collect: [:aMethodBlock | aMethodBlock containedExampleWatches collect: #asInactiveCopy]) flatten ] @@ -102,7 +101,7 @@ SBMultiverse >> createUniverseFomPermutation: aSBPermutation [ ^ SBUniverse newActive: aSBPermutation - watches: (self copyWatchesIn: self allMethodBlocksContainingWatches) + watches: self copyWatches ] { #category : #collecting } diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st new file mode 100644 index 00000000..fe512024 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -0,0 +1,45 @@ +Class { + #name : #SBPermutationGridsView, + #superclass : #SBGridResultsView, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #building } +SBPermutationGridsView >> backUpWhenNoVariants [ + + gridContainer addMorphBack: (self containerRow cellPositioning: #center; + addAllMorphsBack: { + self containerRow listDirection: #topToBottom; + addAllMorphsBack: { + self noVariantsHeader. + SBPermutationCluster + newFromWatches: self multiverse copyWatches + havingSize: SBMorphResizer newSmall}}). + + gridContainer width: gridContainer lastSubmorph fullBounds width. +] + +{ #category : #building } +SBPermutationGridsView >> buildPermutationFor: aSBUniverse [ + + gridContainer addMorphBack: (self containerRow cellPositioning: #center; + addAllMorphsBack: { + self containerRow listDirection: #topToBottom; + addAllMorphsBack: { + SBOwnTextMorph new contents: aSBUniverse activePermutation asString. + self applyButtonFor: aSBUniverse activePermutation. + SBPermutationCluster + newFromWatches: aSBUniverse watches + havingSize: SBMorphResizer newSmall}. + LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). + + gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph fullBounds width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap) + (2 * self block layoutInset x)). +] + +{ #category : #initialization } +SBPermutationGridsView >> initialize [ + + super initialize. + + self name: 'Permutation Grid View'. +] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index 083bbfc7..5d457201 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -17,10 +17,17 @@ SBResultsView >> applyButtonFor: aPermutation [ cornerStyle: #squared ] +{ #category : #building } +SBResultsView >> backUpWhenNoVariants [ + + self block addMorphBack: self noVariantsHeader. + self block addAllMorphsBack: self multiverse copyWatches +] + { #category : #building } SBResultsView >> buildAllPossibleResults [ - self multiverse universes ifEmpty: [self block addAllMorphsBack: self mutliverse watches]. + self multiverse universes ifEmpty: [self backUpWhenNoVariants. ^ self]. [ self multiverse universes do: [:aUniverse | SBActiveVariantPermutation value: aUniverse activePermutation. @@ -35,6 +42,12 @@ SBResultsView >> buildPermutationFor: aSBUniverse [ self subclassResponsibility ] +{ #category : #building } +SBResultsView >> noVariantsHeader [ + + ^ SBOwnTextMorph new contents: 'No variants found - displaying current' +] + { #category : #building } SBResultsView >> resetWatchesToOriginalPermutationRunning: activeExamples [ From 5b2daa1f48f7c04634cf3fd252f1b0b2452b2eb7 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 15:13:33 +0100 Subject: [PATCH 10/12] Adds NilPermutation --- .../Sandblocks-Utils/SBNilPermutation.class.st | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 packages/Sandblocks-Utils/SBNilPermutation.class.st diff --git a/packages/Sandblocks-Utils/SBNilPermutation.class.st b/packages/Sandblocks-Utils/SBNilPermutation.class.st new file mode 100644 index 00000000..cae6fe46 --- /dev/null +++ b/packages/Sandblocks-Utils/SBNilPermutation.class.st @@ -0,0 +1,18 @@ +Class { + #name : #SBNilPermutation, + #superclass : #SBPermutation, + #type : #variable, + #category : #'Sandblocks-Utils' +} + +{ #category : #actions } +SBNilPermutation >> apply [ + + "Do nothing" +] + +{ #category : #converting } +SBNilPermutation >> asString [ + + ^ 'Current setting without any variants' +] From dadb435e2a128ea1e7db6471322107ec52b89b58 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 15:14:51 +0100 Subject: [PATCH 11/12] Refactors clusters and views --- .../Sandblocks-Babylonian/SBCluster.class.st | 49 ++++----- .../SBExampleCluster.class.st | 99 +++++++++++++++++++ .../SBExampleGridsView.class.st | 47 +++++++++ .../SBExploriants.class.st | 2 +- .../SBExploriantsView.class.st | 2 +- .../SBGridResultsView.class.st | 11 +++ .../SBMultiverse.class.st | 25 +++-- .../SBPermutationCluster.class.st | 63 ++++++++---- .../SBPermutationGridsView.class.st | 25 ++--- .../SBPlainResultsView.class.st | 8 +- .../SBResultsView.class.st | 38 ------- packages/Sandblocks-Morphs/SBButton.class.st | 13 +++ .../Sandblocks-Utils/SBPermutation.class.st | 2 +- 13 files changed, 272 insertions(+), 112 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBExampleCluster.class.st create mode 100644 packages/Sandblocks-Babylonian/SBExampleGridsView.class.st diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index 0da27326..a1f8078f 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -7,33 +7,10 @@ Class { #category : #'Sandblocks-Babylonian' } -{ #category : #'initialize-release' } -SBCluster class >> newFromWatches: aCollectionOfSBExampleWatches havingSize: aSBMorphResizer [ - - ^ self new - morphResizer: aSBMorphResizer; - buildFromWatches: aCollectionOfSBExampleWatches; - yourself - -] - { #category : #visualisation } -SBCluster >> buildFromWatches: aCollectionOfSBExampleWatches [ +SBCluster >> buildDisplayMatrix [ - | matrix | - matrix := self watchesAsMatrix: aCollectionOfSBExampleWatches. - matrix ifEmpty: [ ^ self]. - - self addAllMorphsBack: { - self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" - self newContainerMorph - listDirection: #leftToRight; - cellInset: 0; - addAllMorphsBack: { - self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph" - SBGrid newDisplaying: - ((matrix atRows: 2 to: matrix rowCount columns: 2 to: matrix columnCount) - collect: [:aMorph | self wrapInCell: aMorph])}} + self subclassResponsibility ] { #category : #initialization } @@ -121,11 +98,25 @@ SBCluster >> newTopRowFrom: aCollectionOfMorphs [ (self wrapInCell: aMorph owner flexVertically: true flexHorizontally: false) borderWidth: 0]) ] -{ #category : #converting } -SBCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ +{ #category : #visualisation } +SBCluster >> visualize [ - "Determine how watches are dissected to create a grid. We assume inclusion of headings per default" - ^ self subclassResponsibility. + | matrix | + self submorphs copy do: #delete. + + matrix := self buildDisplayMatrix. + matrix ifEmpty: [ ^ self]. + + self addAllMorphsBack: { + self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" + self newContainerMorph + listDirection: #leftToRight; + cellInset: 0; + addAllMorphsBack: { + self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph" + SBGrid newDisplaying: + ((matrix atRows: 2 to: matrix rowCount columns: 2 to: matrix columnCount) + collect: [:aMorph | self wrapInCell: aMorph])}} ] { #category : #helper } diff --git a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st new file mode 100644 index 00000000..0f6210b6 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st @@ -0,0 +1,99 @@ +Class { + #name : #SBExampleCluster, + #superclass : #SBCluster, + #instVars : [ + 'displayedIndex', + 'multiverse' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'initialize-release' } +SBExampleCluster class >> newForSize: aSBMorphResizer multiverse: aSBMultiverse displaying: aNumber [ + + ^ self new + morphResizer: aSBMorphResizer; + multiverse: aSBMultiverse; + displayedIndex: aNumber; + visualize; + yourself + +] + +{ #category : #visualisation } +SBExampleCluster >> buildDisplayMatrix [ + + | matrix | + matrix := Matrix + rows: (self multiverse universes first watches size) + 1 + columns: self multiverse universes size + 1. + + matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedTopHeadingsFrom: self multiverse)). + matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedLeftHeadingsFrom: self multiverse)). + + self multiverse universes withIndexDo: [:aUniverse :column | + (self extractRowsFrom: aUniverse) withIndexDo: [:aCellMorph :row| + matrix at: row+1 at: column+1 put: aCellMorph]]. + + ^ matrix +] + +{ #category : #accessing } +SBExampleCluster >> displayedIndex [ + + ^ displayedIndex +] + +{ #category : #accessing } +SBExampleCluster >> displayedIndex: aNumber [ + + displayedIndex := aNumber +] + +{ #category : #visualisation } +SBExampleCluster >> extractRowsFrom: aUniverse [ + + ^ aUniverse watches collect: [:anExample | | display displayedMorphs | + display := (anExample exampleToDisplay associations at: self displayedIndex) value display. + displayedMorphs := display displayedMorphs collect: [:aMorph | + aMorph watchValue morphResizer: self morphResizer. + aMorph watchValue asValueMorph]. + (displayedMorphs size = 1) + ifTrue: [displayedMorphs first] + ifFalse: [self newCellMorph + borderWidth: 0; + when: #clicked send: #exploreValues to: display; + listDirection: #leftToRight; + wrapDirection: #topToBottom; + addAllMorphsBack: displayedMorphs]] +] + +{ #category : #visualisation } +SBExampleCluster >> extractedLeftHeadingsFrom: aSBMultiverse [ + + ^ (aSBMultiverse universes first watches collect: [:aWatch | aWatch expression copy]) +] + +{ #category : #visualisation } +SBExampleCluster >> extractedTopHeadingsFrom: aSBMultiverse [ + + ^ (aSBMultiverse universes collect: [:aUniverse | + self newContainerMorph + addAllMorphsBack: { + SBStringMorph new contents: aUniverse activePermutation asString. + SBButton newApplyPermutationFor: aUniverse activePermutation}]) +] + +{ #category : #accessing } +SBExampleCluster >> multiverse [ + + ^ multiverse +] + +{ #category : #accessing } +SBExampleCluster >> multiverse: aSBMultiverse [ + + multiverse := aSBMultiverse +] diff --git a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st new file mode 100644 index 00000000..a5621160 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st @@ -0,0 +1,47 @@ +Class { + #name : #SBExampleGridsView, + #superclass : #SBGridResultsView, + #category : #'Sandblocks-Babylonian' +} + +{ #category : #building } +SBExampleGridsView >> buildAllPossibleResults [ + + self multiverse activeExamples withIndexDo: [:anExample :anIndex | self buildExampleFor: anIndex] +] + +{ #category : #building } +SBExampleGridsView >> buildExampleFor: aNumber [ + + gridContainer addMorphBack: (self containerRow cellPositioning: #center; + addAllMorphsBack: { + self containerRow listDirection: #topToBottom; + addAllMorphsBack: { + SBOwnTextMorph new contents: 'example: ', (self multiverse activeExamples at: aNumber) label. + SBExampleCluster + newForSize: SBMorphResizer newMedium + multiverse: self multiverse + displaying: aNumber}. + LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). + + self updateContainerWidth. +] + +{ #category : #initialization } +SBExampleGridsView >> initialize [ + + super initialize. + + self name: 'Example Grid View'. +] + +{ #category : #updating } +SBExampleGridsView >> updateContainerWidth [ + + gridContainer width: + (self multiverse activeExamples size safeSquareRoot ceiling) + * (gridContainer lastSubmorph fullBounds width + + (2 * gridContainer cellInset) + + (2 * gridContainer cellGap) + + 10) +] diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 3ea92a18..14f65139 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -86,8 +86,8 @@ SBExploriants >> visualize [ | tabs | self width: 0. + "tabs will visualize as soon as multiverse is finished" tabs := SBExploriantsView getTabsInMultiverse: (SBMultiverse newInEditor: self sandblockEditor). - tabs do: #visualize. self namedBlocks: tabs activeIndex: 1. diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index d31f0033..03e0f576 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -17,7 +17,7 @@ SBExploriantsView class >> block: aSBBlock named: aString [ { #category : #'instance creation' } SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [ - ^ {SBPermutationGridsView. SBPlainResultsView. SBVariantsView} + ^ {SBPermutationGridsView. SBExampleGridsView. SBPlainResultsView. SBVariantsView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 9337a5e7..145197d2 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -39,3 +39,14 @@ SBGridResultsView >> newGridContainer [ vResizing: #shrinkWrap; yourself ] + +{ #category : #updating } +SBGridResultsView >> updateContainerWidth [ + + gridContainer width: + (self multiverse universes size safeSquareRoot ceiling) + * (gridContainer lastSubmorph fullBounds width + + (2 * gridContainer cellInset) + + (2 * gridContainer cellGap) + + 10) +] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 85031c10..fe05c059 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -115,10 +115,11 @@ SBMultiverse >> findExistingOrConvertToBlocks: aCollectionOfCompiledMethods [ ] { #category : #'initialize-release' } -SBMultiverse >> initialize [ +SBMultiverse >> initialize [ + | permutations | super initialize. - + "We are looking for already opened methods so that we can assign the variant there as the original in SBVariantProxy. That way, we immediately have consistency between changes." @@ -130,14 +131,26 @@ SBMultiverse >> initialize [ variants := (allMethodBlocksContainingVariants collect: #containedVariants) flatten. activeExamples := self allActiveExamples. - universes := (SBPermutation allPermutationsOf: variants) collect: [:aPermutation | - self createUniverseFomPermutation: aPermutation]. - - self triggerEvent: #initialized. + permutations := SBPermutation allPermutationsOf: variants. + universes := OrderedCollection new. + "sicher dass wir das so machen wollen?" + [permutations do: [:aPermutation | + SBActiveVariantPermutation value: aPermutation. + activeExamples do: #runSynchronouslyIgnoreReturn. + universes add: (self createUniverseFomPermutation: aPermutation)]. + self resetWatchesToOriginalPermutationRunning: activeExamples. + self triggerEvent: #initialized] forkAt: Processor userSchedulingPriority. ] +{ #category : #state } +SBMultiverse >> resetWatchesToOriginalPermutationRunning: activeExamples [ + + SBActiveVariantPermutation value: nil. + activeExamples do: #runSynchronouslyIgnoreReturn +] + { #category : #accessing } SBMultiverse >> sandblockEditor [ diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index 8fa10e75..0f495885 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -1,13 +1,48 @@ Class { #name : #SBPermutationCluster, #superclass : #SBCluster, + #instVars : [ + 'watches' + ], #category : #'Sandblocks-Babylonian' } +{ #category : #'initialize-release' } +SBPermutationCluster class >> newForSize: aSBMorphResizer havingWatches: aCollectionOfSBExampleWatches [ + + ^ self new + morphResizer: aSBMorphResizer; + watches: aCollectionOfSBExampleWatches; + visualize; + yourself + +] + +{ #category : #converting } +SBPermutationCluster >> buildDisplayMatrix [ + + | matrix | + self watches ifEmpty: [^ Matrix new]. + matrix := Matrix + rows: self watches size + 1 + columns: (self watches first examples size) + 1. + + matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedTopHeadingsFrom: self watches)). + matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, + (self extractedLeftHeadingsFrom: self watches)). + + self watches withIndexDo: [:aWatch :row | + (self extractColumnsFrom: aWatch) withIndexDo: [:aCellMorph :column| + matrix at: row+1 at: column+1 put: aCellMorph]]. + + ^ matrix +] + { #category : #visualisation } -SBPermutationCluster >> extractColumnsFrom: anExampleWatch [ +SBPermutationCluster >> extractColumnsFrom: aCollectionOfSBExampleWatches [ - ^ anExampleWatch exampleToDisplay collect: [:anExampleValueDisplay | | displayedMorphs | + ^ aCollectionOfSBExampleWatches exampleToDisplay collect: [:anExampleValueDisplay | | displayedMorphs | displayedMorphs := anExampleValueDisplay display displayedMorphs collect: [:aMorph | aMorph watchValue morphResizer: self morphResizer. aMorph watchValue asValueMorph]. (displayedMorphs size = 1) @@ -32,22 +67,14 @@ SBPermutationCluster >> extractedTopHeadingsFrom: aCollectionOfSBExampleWatches ^ (aCollectionOfSBExampleWatches first exampleToDisplay values collect: [:aDisplay | aDisplay labelMorph copy]) ] -{ #category : #converting } -SBPermutationCluster >> watchesAsMatrix: aCollectionOfSBExampleWatches [ +{ #category : #accessing } +SBPermutationCluster >> watches [ - | matrix | - matrix := Matrix - rows: aCollectionOfSBExampleWatches size + 1 - columns: (aCollectionOfSBExampleWatches first examples size) + 1. - - matrix atRow: 1 put: ({self newTopLeftCornerPlaceholder}, - (self extractedTopHeadingsFrom: aCollectionOfSBExampleWatches)). - matrix atColumn: 1 put: ({self newTopLeftCornerPlaceholder}, - (self extractedLeftHeadingsFrom: aCollectionOfSBExampleWatches)). - - aCollectionOfSBExampleWatches withIndexDo: [:aWatch :row | - (self extractColumnsFrom: aWatch) withIndexDo: [:aCellMorph :column| - matrix at: row+1 at: column+1 put: aCellMorph]]. + ^ watches +] - ^ matrix +{ #category : #accessing } +SBPermutationCluster >> watches: aCollectionOfSBExampleWatches [ + + watches := aCollectionOfSBExampleWatches ] diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st index fe512024..c15d2aa9 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -5,18 +5,9 @@ Class { } { #category : #building } -SBPermutationGridsView >> backUpWhenNoVariants [ - - gridContainer addMorphBack: (self containerRow cellPositioning: #center; - addAllMorphsBack: { - self containerRow listDirection: #topToBottom; - addAllMorphsBack: { - self noVariantsHeader. - SBPermutationCluster - newFromWatches: self multiverse copyWatches - havingSize: SBMorphResizer newSmall}}). - - gridContainer width: gridContainer lastSubmorph fullBounds width. +SBPermutationGridsView >> buildAllPossibleResults [ + + self multiverse universes do: [:aUniverse | self buildPermutationFor: aUniverse] ] { #category : #building } @@ -27,13 +18,13 @@ SBPermutationGridsView >> buildPermutationFor: aSBUniverse [ self containerRow listDirection: #topToBottom; addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. - self applyButtonFor: aSBUniverse activePermutation. - SBPermutationCluster - newFromWatches: aSBUniverse watches - havingSize: SBMorphResizer newSmall}. + SBButton newApplyPermutationFor: aSBUniverse activePermutation. + (SBPermutationCluster + newForSize: SBMorphResizer newMedium + havingWatches: aSBUniverse watches)}. LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). - gridContainer width: (self multiverse universes size safeSquareRoot ceiling) * (gridContainer lastSubmorph fullBounds width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap) + (2 * self block layoutInset x)). + self updateContainerWidth. ] { #category : #initialization } diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index 97a33c37..f75bfa31 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -4,11 +4,17 @@ Class { #category : #'Sandblocks-Babylonian' } +{ #category : #building } +SBPlainResultsView >> buildAllPossibleResults [ + + self multiverse universes do: [:aUniverse | self buildPermutationFor: aUniverse] +] + { #category : #building } SBPlainResultsView >> buildPermutationFor: aSBUniverse [ self block addAllMorphsBack: { SBOwnTextMorph new contents: aSBUniverse activePermutation asString. - self applyButtonFor: aSBUniverse activePermutation. + SBButton newApplyPermutationFor: aSBUniverse activePermutation. (self containerRow listDirection: #leftToRight) addAllMorphsBack: aSBUniverse watches. LineMorph from: 0@0 to: 50@0 color: Color black width: 2} diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index 5d457201..4074d06d 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -4,50 +4,12 @@ Class { #category : #'Sandblocks-Babylonian' } -{ #category : #building } -SBResultsView >> applyButtonFor: aPermutation [ - - ^ SBButton new - icon: (SBIcon iconCheck - size: 6.0 sbScaled; - color: (Color r: 0.0 g: 1 b: 0.0)) - label: 'Apply Permutation' - do: [aPermutation apply]; - makeSmall; - cornerStyle: #squared -] - -{ #category : #building } -SBResultsView >> backUpWhenNoVariants [ - - self block addMorphBack: self noVariantsHeader. - self block addAllMorphsBack: self multiverse copyWatches -] - { #category : #building } SBResultsView >> buildAllPossibleResults [ - self multiverse universes ifEmpty: [self backUpWhenNoVariants. ^ self]. - - [ self multiverse universes do: [:aUniverse | - SBActiveVariantPermutation value: aUniverse activePermutation. - self multiverse activeExamples do: #runSynchronouslyIgnoreReturn. - self buildPermutationFor: aUniverse]. - self resetWatchesToOriginalPermutationRunning: self multiverse activeExamples] forkAt: Processor userSchedulingPriority -] - -{ #category : #building } -SBResultsView >> buildPermutationFor: aSBUniverse [ - self subclassResponsibility ] -{ #category : #building } -SBResultsView >> noVariantsHeader [ - - ^ SBOwnTextMorph new contents: 'No variants found - displaying current' -] - { #category : #building } SBResultsView >> resetWatchesToOriginalPermutationRunning: activeExamples [ diff --git a/packages/Sandblocks-Morphs/SBButton.class.st b/packages/Sandblocks-Morphs/SBButton.class.st index a6e704e1..bdad3f64 100644 --- a/packages/Sandblocks-Morphs/SBButton.class.st +++ b/packages/Sandblocks-Morphs/SBButton.class.st @@ -10,6 +10,19 @@ Class { #category : #'Sandblocks-Morphs' } +{ #category : #'instance creation' } +SBButton class >> newApplyPermutationFor: aPermutation [ + + ^ self new + icon: (SBIcon iconArrowDown + size: 8.0 sbScaled; + color: (Color r: 0.0 g: 1 b: 0.0)) + label: 'Apply' + do: [aPermutation apply]; + makeSmall; + cornerStyle: #squared +] + { #category : #accessing } SBButton >> active [ diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 12bbc6c1..89a6b07c 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -15,7 +15,7 @@ Class { SBPermutation class >> allPermutationsOf: aCollectionOfVariants [ | permutations | - aCollectionOfVariants ifEmpty:[^#()]. + aCollectionOfVariants ifEmpty:[^{SBNilPermutation new referencedVariants: {}}]. permutations := (1 to: aCollectionOfVariants first alternativesCount) collect: #asArray. (2 to: aCollectionOfVariants size) do: [:i | | alternatives | From 86abccc55482a82dc30e06af1320f17bb89d787d Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 21 Nov 2023 15:44:18 +0100 Subject: [PATCH 12/12] Refactor --- .../Sandblocks-Babylonian/SBCluster.class.st | 17 ++++++++++++++--- .../SBExampleCluster.class.st | 14 ++------------ .../SBExampleGridsView.class.st | 19 +++++++------------ .../SBExploriantsView.class.st | 2 +- .../SBGridResultsView.class.st | 8 +++++++- .../SBMultiverse.class.st | 1 - .../SBPermutationCluster.class.st | 13 ++----------- .../SBPermutationGridsView.class.st | 8 +++++++- .../SBResultsView.class.st | 11 +++++++++++ 9 files changed, 51 insertions(+), 42 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index a1f8078f..db1e4b6e 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -8,9 +8,20 @@ Class { } { #category : #visualisation } -SBCluster >> buildDisplayMatrix [ - - self subclassResponsibility +SBCluster >> compressedMorphsForDisplay: aSBWatchView [ + + | displayedMorphs | + displayedMorphs := aSBWatchView displayedMorphs collect: [:aMorph | + aMorph watchValue morphResizer: self morphResizer. + aMorph watchValue asValueMorph]. + ^ (displayedMorphs size = 1) + ifTrue: [displayedMorphs first] + ifFalse: [self newCellMorph + borderWidth: 0; + when: #clicked send: #exploreValues to: aSBWatchView; + listDirection: #leftToRight; + wrapDirection: #topToBottom; + addAllMorphsBack: displayedMorphs] ] { #category : #initialization } diff --git a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st index 0f6210b6..a1684a24 100644 --- a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st @@ -55,19 +55,9 @@ SBExampleCluster >> displayedIndex: aNumber [ { #category : #visualisation } SBExampleCluster >> extractRowsFrom: aUniverse [ - ^ aUniverse watches collect: [:anExample | | display displayedMorphs | + ^ aUniverse watches collect: [:anExample | | display | display := (anExample exampleToDisplay associations at: self displayedIndex) value display. - displayedMorphs := display displayedMorphs collect: [:aMorph | - aMorph watchValue morphResizer: self morphResizer. - aMorph watchValue asValueMorph]. - (displayedMorphs size = 1) - ifTrue: [displayedMorphs first] - ifFalse: [self newCellMorph - borderWidth: 0; - when: #clicked send: #exploreValues to: display; - listDirection: #leftToRight; - wrapDirection: #topToBottom; - addAllMorphsBack: displayedMorphs]] + self compressedMorphsForDisplay: display] ] { #category : #visualisation } diff --git a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st index a5621160..573c9ff9 100644 --- a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st @@ -19,7 +19,7 @@ SBExampleGridsView >> buildExampleFor: aNumber [ addAllMorphsBack: { SBOwnTextMorph new contents: 'example: ', (self multiverse activeExamples at: aNumber) label. SBExampleCluster - newForSize: SBMorphResizer newMedium + newForSize: morphResizer multiverse: self multiverse displaying: aNumber}. LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). @@ -27,6 +27,12 @@ SBExampleGridsView >> buildExampleFor: aNumber [ self updateContainerWidth. ] +{ #category : #updating } +SBExampleGridsView >> gridObjects [ + + ^ self multiverse activeExamples +] + { #category : #initialization } SBExampleGridsView >> initialize [ @@ -34,14 +40,3 @@ SBExampleGridsView >> initialize [ self name: 'Example Grid View'. ] - -{ #category : #updating } -SBExampleGridsView >> updateContainerWidth [ - - gridContainer width: - (self multiverse activeExamples size safeSquareRoot ceiling) - * (gridContainer lastSubmorph fullBounds width - + (2 * gridContainer cellInset) - + (2 * gridContainer cellGap) - + 10) -] diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 03e0f576..6b87edc1 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -80,7 +80,7 @@ SBExploriantsView >> initialize [ { #category : #accessing } SBExploriantsView >> multiverse [ - ^ multiverse ifNil: [multiverse := SBMultiverse newInEditor: SBEditor current] + ^ multiverse ifNil: [self multiverse: (SBMultiverse newInEditor: SBEditor current)] ] { #category : #accessing } diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 145197d2..ab2c8af9 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -16,6 +16,12 @@ SBGridResultsView >> clean [ ] +{ #category : #updating } +SBGridResultsView >> gridObjects [ + + self subclassResponsibility +] + { #category : #initialization } SBGridResultsView >> initialize [ @@ -44,7 +50,7 @@ SBGridResultsView >> newGridContainer [ SBGridResultsView >> updateContainerWidth [ gridContainer width: - (self multiverse universes size safeSquareRoot ceiling) + self gridObjects size safeSquareRoot ceiling * (gridContainer lastSubmorph fullBounds width + (2 * gridContainer cellInset) + (2 * gridContainer cellGap) diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index fe05c059..d9ff4887 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -133,7 +133,6 @@ SBMultiverse >> initialize [ permutations := SBPermutation allPermutationsOf: variants. universes := OrderedCollection new. - "sicher dass wir das so machen wollen?" [permutations do: [:aPermutation | SBActiveVariantPermutation value: aPermutation. activeExamples do: #runSynchronouslyIgnoreReturn. diff --git a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st index 0f495885..4f34cae4 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationCluster.class.st @@ -42,17 +42,8 @@ SBPermutationCluster >> buildDisplayMatrix [ { #category : #visualisation } SBPermutationCluster >> extractColumnsFrom: aCollectionOfSBExampleWatches [ - ^ aCollectionOfSBExampleWatches exampleToDisplay collect: [:anExampleValueDisplay | | displayedMorphs | - displayedMorphs := anExampleValueDisplay display displayedMorphs - collect: [:aMorph | aMorph watchValue morphResizer: self morphResizer. aMorph watchValue asValueMorph]. - (displayedMorphs size = 1) - ifTrue: [displayedMorphs first] - ifFalse: [self newCellMorph - borderWidth: 0; - when: #clicked send: #exploreValues to: anExampleValueDisplay display; - listDirection: #leftToRight; - wrapDirection: #topToBottom; - addAllMorphsBack: displayedMorphs]]. + ^ aCollectionOfSBExampleWatches exampleToDisplay collect: [:anExampleValueDisplay | + self compressedMorphsForDisplay: anExampleValueDisplay display] ] { #category : #visualisation } diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st index c15d2aa9..101b5d4a 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -20,13 +20,19 @@ SBPermutationGridsView >> buildPermutationFor: aSBUniverse [ SBOwnTextMorph new contents: aSBUniverse activePermutation asString. SBButton newApplyPermutationFor: aSBUniverse activePermutation. (SBPermutationCluster - newForSize: SBMorphResizer newMedium + newForSize: morphResizer havingWatches: aSBUniverse watches)}. LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). self updateContainerWidth. ] +{ #category : #updating } +SBPermutationGridsView >> gridObjects [ + + ^ self multiverse universes +] + { #category : #initialization } SBPermutationGridsView >> initialize [ diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index 4074d06d..d0b5d2cb 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -1,6 +1,9 @@ Class { #name : #SBResultsView, #superclass : #SBExploriantsView, + #instVars : [ + 'morphResizer' + ], #category : #'Sandblocks-Babylonian' } @@ -10,6 +13,14 @@ SBResultsView >> buildAllPossibleResults [ self subclassResponsibility ] +{ #category : #initialization } +SBResultsView >> initialize [ + + super initialize. + + morphResizer := SBMorphResizer newThumbmail. +] + { #category : #building } SBResultsView >> resetWatchesToOriginalPermutationRunning: activeExamples [