Skip to content

Commit

Permalink
Adds a history tab and compacts down views
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Feb 16, 2024
1 parent aa0bf21 commit 4e5c0d8
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 45 deletions.
10 changes: 4 additions & 6 deletions packages/Sandblocks-Babylonian/SBExampleGridsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
SBExampleGridsView >> buildAllPossibleResults [

self multiverse activeExamples
ifEmpty: [gridContainer addMorph: (SBOwnTextMorph new contents: 'No examples active')].
ifEmpty: [gridContainer addMorph: (TextMorph new contents: 'No examples active').
gridContainer width: gridContainer firstSubmorph width + 5 "a bit of margin"].

self multiverse activeExamples withIndexDo: [:anExample :anIndex | self buildExampleFor: anIndex]
]
Expand All @@ -24,10 +25,7 @@ SBExampleGridsView >> buildExampleFor: aNumber [
self currentClusterClass
newForSize: self selectedResizer
multiverse: self multiverse
displaying: aNumber}.
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}).

self updateContainerWidth.
displaying: aNumber}})
]

{ #category : #accessing }
Expand All @@ -49,5 +47,5 @@ SBExampleGridsView >> initialize [

super initialize.

self name: 'Example Grid View'.
self name: 'Example Focused'.
]
15 changes: 11 additions & 4 deletions packages/Sandblocks-Babylonian/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SBExploriantsView class >> block: aSBBlock named: aString [
{ #category : #'instance creation' }
SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [

^ {SBPermutationGridsView. SBExampleGridsView. SBPlainResultsView. SBLiveView. SBVariantsView}
^ {SBPermutationGridsView. SBExampleGridsView. SBLiveView. SBPlainResultsView. SBVariantsView. SBHistoryView}
collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse]
]

Expand Down Expand Up @@ -60,9 +60,9 @@ SBExploriantsView >> containerRow [
cellPositioning: #topLeft;
changeTableLayout;
listDirection: #leftToRight;
layoutInset: 8;
cellGap: 3;
cellInset: 3;
layoutInset: 2;
cellGap: 1;
cellInset: 2;
borderWidth: 0
]

Expand Down Expand Up @@ -115,6 +115,13 @@ SBExploriantsView >> resolveButton [
cornerStyle: #squared
]

{ #category : #copying }
SBExploriantsView >> snapshot [

"Return a collection of morphs which capture the current state of this view"
^ self subclassResponsibility
]

{ #category : #building }
SBExploriantsView >> updateButton [

Expand Down
2 changes: 1 addition & 1 deletion 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 [

^ 2
^ 0
]

{ #category : #'initialize-release' }
Expand Down
56 changes: 44 additions & 12 deletions packages/Sandblocks-Babylonian/SBGridResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,44 @@ SBGridResultsView >> clean [

]

{ #category : #updating }
SBGridResultsView >> concludeContainerWidth [

| widthTillWrap |
widthTillWrap := self multiverse sandblockEditor width * 0.9.
gridContainer fullBounds width < widthTillWrap ifTrue: [^ self].

self descentToScreenRatioMaxWidth: widthTillWrap.

gridContainer hResizing: #shrinkWrap.
]

{ #category : #updating }
SBGridResultsView >> descentToScreenRatioMaxWidth: maxWidth [

| editorRatio submorphIndex |
gridContainer hResizing: #rigid; wrapDirection: #topToBottom.
editorRatio := DisplayScreen boundingBox width / DisplayScreen boundingBox height.
submorphIndex := gridContainer submorphs size.

[gridContainer fullBounds width / gridContainer height > editorRatio
and: [submorphIndex > 1]]
whileTrue: [ | isBelowMax |
isBelowMax := gridContainer width < maxWidth.
gridContainer width: gridContainer width
- (gridContainer submorphs atWrap: submorphIndex) width.

(editorRatio > 1
and: [gridContainer fullBounds height >= gridContainer width]
and: [isBelowMax])
ifTrue: [ gridContainer width: gridContainer width
+(gridContainer submorphs atWrap: submorphIndex) width.
submorphIndex := -1]
ifFalse: [submorphIndex := submorphIndex - 1]].

gridContainer width > maxWidth ifTrue: [gridContainer width: maxWidth]
]

{ #category : #updating }
SBGridResultsView >> gridSize [

Expand All @@ -37,22 +75,16 @@ SBGridResultsView >> newGridContainer [
changeTableLayout;
color: Color white;
listDirection: #leftToRight;
wrapDirection: #topToBottom;
wrapCentering: #topLeft;
hResizing: #rigid;
width: 50;
cellInset: 0;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
yourself
]

{ #category : #updating }
SBGridResultsView >> updateContainerWidth [

gridContainer width:
(self gridSize safeSquareRoot ceiling + 1)
* (gridContainer lastSubmorph fullBounds width
+ (2 * gridContainer cellInset)
+ (2 * gridContainer cellGap)
+ 10)
{ #category : #actions }
SBGridResultsView >> visualize [

super visualize.
self concludeContainerWidth
]
96 changes: 96 additions & 0 deletions packages/Sandblocks-Babylonian/SBHistoryView.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Class {
#name : #SBHistoryView,
#superclass : #SBExploriantsView,
#category : #'Sandblocks-Babylonian'
}

{ #category : #building }
SBHistoryView >> addEpoche [

self submorphs size - 1 "buttonRow" > self maxEpoches ifTrue: [self lastSubmorph delete].

self block addMorph: self buildEpoche atIndex: 2
]

{ #category : #building }
SBHistoryView >> buildEpoche [

| row |
row := self containerRow.
^ row
cellGap: 0@10;
listDirection: #topToBottom;
addMorphBack: (self containerRow
cellGap: 5@0;
addMorphBack: (self deleteEpocheButton: row);
addMorphBack: TimeStamp current asMorph);
addMorphBack: (self containerRow
layoutInset: 0;
cellGap: 0;
cellInset: 0;
addAllMorphsBack: self collectSnapshots)


]

{ #category : #building }
SBHistoryView >> buttons [

^ super buttons, {self clearButton}
]

{ #category : #building }
SBHistoryView >> clearButton [

^ SBButton new
icon: SBIcon iconClockO
label: 'Clear History'
do: [self clean. self block addMorphBack: self buildButtonRow];
cornerStyle: #squared
]

{ #category : #building }
SBHistoryView >> collectSnapshots [

^ (SBExploriants uniqueInstance namedBlocks collect: [:aView | aView snapshot]) flatten
]

{ #category : #building }
SBHistoryView >> deleteEpocheButton: theRow [

^ SBButton new
icon: SBIcon iconTrash
do: [theRow delete];
balloonText: 'Delete this row';
cornerStyle: #squared;
makeSmall


]

{ #category : #initialization }
SBHistoryView >> initialize [

super initialize.

self name: 'History'.
self buildButtonRow.
]

{ #category : #accessing }
SBHistoryView >> maxEpoches [

^ 100
]

{ #category : #copying }
SBHistoryView >> snapshot [

^ {}
]

{ #category : #actions }
SBHistoryView >> visualize [

self addEpoche
]
28 changes: 16 additions & 12 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ SBLiveView >> buildBrodcaster [
addAllMorphsBack: {
self containerRow listDirection: #topToBottom;
addAllMorphsBack: {
SBOwnTextMorph new contents: 'Event Broadcaster'.
SBOwnTextMorph new contents: 'Interact to send events'.
broadcaster := SBInputBroadcaster new}.
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}).
TextMorph new contents: 'Event Broadcaster'.
TextMorph new contents: 'Interact with to send events to all others'.
broadcaster := SBInputBroadcaster new}}).

]

Expand All @@ -41,8 +40,7 @@ SBLiveView >> buildPreviewFor: aPermutation [
addAllMorphsBack: {
SBPermutationLabel newDisplaying: aPermutation.
self newPermutationButtonRowFor: aPermutation showing: preview.
preview}.
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}).
preview}}).
]

{ #category : #building }
Expand All @@ -66,7 +64,7 @@ SBLiveView >> buildSetUpRow [
{ #category : #building }
SBLiveView >> buttons [

^ super buttons, {self resolveButton}
^ super buttons, {self rebuildButton}
]

{ #category : #actions }
Expand Down Expand Up @@ -100,7 +98,7 @@ SBLiveView >> initialize [

super initialize.

self name: 'Live View'.
self name: 'Playground'.
self buildSetUpRow.


Expand All @@ -115,9 +113,9 @@ SBLiveView >> listeners [
{ #category : #building }
SBLiveView >> newPermutationButtonRowFor: aPermutation showing: aPreview [

^ SBRow new
changeTableLayout;
cellGap: 8 * self scalingFactor;
^ self containerRow
layoutInset: 0;
cellInset: 0;
addAllMorphsBack: {
SBButton newApplyPermutationFor: aPermutation.
self rebuildButtonIn: aPreview applying: aPermutation.
Expand Down Expand Up @@ -205,6 +203,12 @@ SBLiveView >> setUpMorph [
^ (self block submorphNamed: 'setup') lastSubmorph
]

{ #category : #copying }
SBLiveView >> snapshot [

^ {ImageMorph new newForm: gridContainer imageForm}
]

{ #category : #building }
SBLiveView >> synchronizeButtonIn: aContainer [

Expand Down Expand Up @@ -246,5 +250,5 @@ SBLiveView >> visualize [
self buildAllPossibleResults.

broadcaster extent: self listeners last extent.
self updateContainerWidth.
self concludeContainerWidth.
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ SBPermutationGridsView >> buildPermutationFor: aSBUniverse [
SBButton newApplyPermutationFor: aSBUniverse activePermutation.
(self currentClusterClass
newForSize: self selectedResizer
havingWatches: aSBUniverse watches)}.
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}).

self updateContainerWidth.
havingWatches: aSBUniverse watches)}})
]

{ #category : #building }
Expand All @@ -46,5 +43,5 @@ SBPermutationGridsView >> initialize [

super initialize.

self name: 'Permutation Grid View'.
self name: 'Permutation Focused'.
]
8 changes: 7 additions & 1 deletion packages/Sandblocks-Babylonian/SBPlainResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,11 @@ SBPlainResultsView >> initialize [

super initialize.

self name: 'Plain View'
self name: 'Watches'
]

{ #category : #copying }
SBPlainResultsView >> snapshot [

^ {}
]
10 changes: 9 additions & 1 deletion packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ SBSwitchableResultsView >> selectedResizer [
^ dimensionOptions object
]

{ #category : #'as yet unclassified' }
SBSwitchableResultsView >> snapshot [

^ {ImageMorph new newForm: gridContainer imageForm}

]

{ #category : #building }
SBSwitchableResultsView >> toggleIcon [

Expand Down Expand Up @@ -93,5 +100,6 @@ SBSwitchableResultsView >> visualize [
self block addMorph: dimensionOptions.
self buildButtonRow.

self buildAllPossibleResults
self buildAllPossibleResults .
self concludeContainerWidth.
]
Loading

0 comments on commit 4e5c0d8

Please sign in to comment.