-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
272 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
] |
47 changes: 47 additions & 0 deletions
47
packages/Sandblocks-Babylonian/SBExampleGridsView.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.