-
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.
Merge pull request #129 from hpi-swa/feature/multiverse-grid
Grid views
- Loading branch information
Showing
24 changed files
with
883 additions
and
126 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
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,9 @@ | ||
Extension { #name : #Point } | ||
|
||
{ #category : #'*Sandblocks-Babylonian' } | ||
Point >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ | ||
|
||
^ (SBWatchValue newContainerMorphFor: aSBWatchValue) | ||
addMorphBack: self asMorph; | ||
yourself | ||
] |
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,164 @@ | ||
Class { | ||
#name : #SBCluster, | ||
#superclass : #Morph, | ||
#instVars : [ | ||
'morphResizer' | ||
], | ||
#category : #'Sandblocks-Babylonian' | ||
} | ||
|
||
{ #category : #visualisation } | ||
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 } | ||
SBCluster >> initialize [ | ||
|
||
super initialize. | ||
|
||
self | ||
color: Color transparent; | ||
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 transparent ; | ||
changeTableLayout; | ||
borderWidth: 1; | ||
borderStyle: (BorderStyle width: 1 color: (Color gray alpha: 0.3)); | ||
listDirection: #topToBottom; | ||
listCentering: #center; | ||
wrapCentering: #center; | ||
hResizing: #rigid; | ||
vResizing: #rigid) | ||
] | ||
|
||
{ #category : #helper } | ||
SBCluster >> newContainerMorph [ | ||
|
||
^ Morph new | ||
color: Color transparent ; | ||
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; | ||
borderWidth: 0]) | ||
] | ||
|
||
{ #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) borderWidth: 0]) | ||
] | ||
|
||
{ #category : #visualisation } | ||
SBCluster >> visualize [ | ||
|
||
| 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 } | ||
SBCluster >> wrapInCell: aMorph [ | ||
|
||
^ self wrapInCell: aMorph flexVertically: false flexHorizontally: false | ||
|
||
] | ||
|
||
{ #category : #helper } | ||
SBCluster >> wrapInCell: aMorph flexVertically: aVBoolean flexHorizontally: aHBoolean [ | ||
|
||
| cell targetExtent| | ||
cell := self newCellMorph. | ||
|
||
aVBoolean ifTrue: [cell vResizing: #shrinkWrap]. | ||
aHBoolean ifTrue: [cell hResizing: #shrinkWrap]. | ||
|
||
(((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 | ||
] |
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,89 @@ | ||
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 | | ||
display := (anExample exampleToDisplay associations at: self displayedIndex) value display. | ||
self compressedMorphsForDisplay: display] | ||
] | ||
|
||
{ #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 | ||
] |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
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: morphResizer | ||
multiverse: self multiverse | ||
displaying: aNumber}. | ||
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). | ||
|
||
self updateContainerWidth. | ||
] | ||
|
||
{ #category : #updating } | ||
SBExampleGridsView >> gridObjects [ | ||
|
||
^ self multiverse activeExamples | ||
] | ||
|
||
{ #category : #initialization } | ||
SBExampleGridsView >> initialize [ | ||
|
||
super initialize. | ||
|
||
self name: 'Example Grid View'. | ||
] |
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.