Skip to content

Commit

Permalink
Resolves overflow of grid results view by squeezing morphs into image…
Browse files Browse the repository at this point in the history
…morph
  • Loading branch information
JoeAtHPI committed Nov 14, 2023
1 parent 527cf4c commit fddf8de
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/Sandblocks-Babylonian/SBCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ SBCluster >> newCellMorph [

^ self morphResizer applyOn: (
Morph new
color: Color blue;
color: Color transparent ;
changeTableLayout;
listDirection: #topToBottom;
listCentering: #center;
Expand All @@ -79,7 +79,7 @@ SBCluster >> newCellMorph [
SBCluster >> newContainerMorph [

^ Morph new
color: Color banana;
color: Color transparent ;
changeTableLayout;
listDirection: #topToBottom;
hResizing: #shrinkWrap;
Expand Down
8 changes: 7 additions & 1 deletion packages/Sandblocks-Babylonian/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions packages/Sandblocks-Babylonian/SBGrid.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Class {
{ #category : #constants }
SBGrid class >> cellInsetValue [

^ 5
^ 2
]

{ #category : #'initialize-release' }
Expand Down Expand Up @@ -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)))
]
26 changes: 26 additions & 0 deletions packages/Sandblocks-Babylonian/SBGridResultsView.class.st
Original file line number Diff line number Diff line change
@@ -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'
]
33 changes: 27 additions & 6 deletions packages/Sandblocks-Babylonian/SBPermutationCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
]
9 changes: 3 additions & 6 deletions packages/Sandblocks-Babylonian/SBResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]

Expand All @@ -98,7 +95,7 @@ SBResultsView >> initialize [

super initialize.

self name: 'Possible Results'
self name: 'Simple View'
]

{ #category : #building }
Expand Down
4 changes: 2 additions & 2 deletions packages/Sandblocks-Watch/SBLineChart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SBLineChart >> datapointDefaultColor [
{ #category : #'visualization - constants' }
SBLineChart >> datapointExtent [

^ 5@5
^ 4@4
]

{ #category : #visualization }
Expand Down Expand Up @@ -164,7 +164,7 @@ SBLineChart >> scaleYOffset [
{ #category : #'visualization - constants' }
SBLineChart >> spaceBetweenPoints [

^ 15
^ 10
]

{ #category : #visualization }
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Watch/SBWatchView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ SBWatchView >> layoutCommands [
{ #category : #layout }
SBWatchView >> maxWidth [

^ 10
^ 350
]

{ #category : #accessing }
Expand Down

0 comments on commit fddf8de

Please sign in to comment.