From 4e5c0d8175ccbeacba30edb5eacf721f9510e66b Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 16 Feb 2024 21:14:10 +0100 Subject: [PATCH] Adds a history tab and compacts down views --- .../SBExampleGridsView.class.st | 10 +- .../SBExploriantsView.class.st | 15 ++- .../Sandblocks-Babylonian/SBGrid.class.st | 2 +- .../SBGridResultsView.class.st | 56 ++++++++--- .../SBHistoryView.class.st | 96 +++++++++++++++++++ .../Sandblocks-Babylonian/SBLiveView.class.st | 28 +++--- .../SBPermutationGridsView.class.st | 7 +- .../SBPlainResultsView.class.st | 8 +- .../SBSwitchableResultsView.class.st | 10 +- .../SBVariantsView.class.st | 27 +++++- .../Sandblocks-Watch/SBWatchView.class.st | 1 + 11 files changed, 215 insertions(+), 45 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBHistoryView.class.st diff --git a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st index 4b8ba62b..392d020a 100644 --- a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st @@ -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] ] @@ -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 } @@ -49,5 +47,5 @@ SBExampleGridsView >> initialize [ super initialize. - self name: 'Example Grid View'. + self name: 'Example Focused'. ] diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index fb6f8a9e..5da6ebf9 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. SBExampleGridsView. SBPlainResultsView. SBLiveView. SBVariantsView} + ^ {SBPermutationGridsView. SBExampleGridsView. SBLiveView. SBPlainResultsView. SBVariantsView. SBHistoryView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] @@ -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 ] @@ -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 [ diff --git a/packages/Sandblocks-Babylonian/SBGrid.class.st b/packages/Sandblocks-Babylonian/SBGrid.class.st index 792d84e2..3d3298c0 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 [ - ^ 2 + ^ 0 ] { #category : #'initialize-release' } diff --git a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st index 1c288d1b..47601812 100644 --- a/packages/Sandblocks-Babylonian/SBGridResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBGridResultsView.class.st @@ -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 [ @@ -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 ] diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st new file mode 100644 index 00000000..309e7532 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -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 +] diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index d599ca09..24aca7bf 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -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}}). ] @@ -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 } @@ -66,7 +64,7 @@ SBLiveView >> buildSetUpRow [ { #category : #building } SBLiveView >> buttons [ - ^ super buttons, {self resolveButton} + ^ super buttons, {self rebuildButton} ] { #category : #actions } @@ -100,7 +98,7 @@ SBLiveView >> initialize [ super initialize. - self name: 'Live View'. + self name: 'Playground'. self buildSetUpRow. @@ -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. @@ -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 [ @@ -246,5 +250,5 @@ SBLiveView >> visualize [ self buildAllPossibleResults. broadcaster extent: self listeners last extent. - self updateContainerWidth. + self concludeContainerWidth. ] diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st index 232118d8..635f6550 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -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 } @@ -46,5 +43,5 @@ SBPermutationGridsView >> initialize [ super initialize. - self name: 'Permutation Grid View'. + self name: 'Permutation Focused'. ] diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index 4e675315..522df23a 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -25,5 +25,11 @@ SBPlainResultsView >> initialize [ super initialize. - self name: 'Plain View' + self name: 'Watches' +] + +{ #category : #copying } +SBPlainResultsView >> snapshot [ + + ^ {} ] diff --git a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st index 569bf136..c5bd3aea 100644 --- a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st @@ -59,6 +59,13 @@ SBSwitchableResultsView >> selectedResizer [ ^ dimensionOptions object ] +{ #category : #'as yet unclassified' } +SBSwitchableResultsView >> snapshot [ + + ^ {ImageMorph new newForm: gridContainer imageForm} + +] + { #category : #building } SBSwitchableResultsView >> toggleIcon [ @@ -93,5 +100,6 @@ SBSwitchableResultsView >> visualize [ self block addMorph: dimensionOptions. self buildButtonRow. - self buildAllPossibleResults + self buildAllPossibleResults . + self concludeContainerWidth. ] diff --git a/packages/Sandblocks-Babylonian/SBVariantsView.class.st b/packages/Sandblocks-Babylonian/SBVariantsView.class.st index 42ff6767..33f87486 100644 --- a/packages/Sandblocks-Babylonian/SBVariantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBVariantsView.class.st @@ -1,13 +1,16 @@ Class { #name : #SBVariantsView, #superclass : #SBExploriantsView, + #instVars : [ + 'contents' + ], #category : #'Sandblocks-Babylonian' } { #category : #building } SBVariantsView >> buildMethodSectionFor: aSBStMethod [ - self block addAllMorphsBack: {aSBStMethod methodDefinition. + contents addAllMorphsBack: {aSBStMethod methodDefinition. self containerRow addAllMorphsBack: (aSBStMethod containedVariants collect: #asProxy). LineMorph from: 0@0 to: 50@0 color: Color black width: 2} @@ -16,7 +19,16 @@ SBVariantsView >> buildMethodSectionFor: aSBStMethod [ { #category : #building } SBVariantsView >> buildNoVariantsText [ - self block addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.') + contents addMorphBack: (SBOwnTextMorph new contents: 'No variants exist.') +] + +{ #category : #actions } +SBVariantsView >> clean [ + + super clean. + + contents submorphs copy do: #delete + ] { #category : #initialization } @@ -24,13 +36,22 @@ SBVariantsView >> initialize [ super initialize. - self name: 'Variant Manager'. + contents := self containerRow listDirection: #topToBottom. + + self name: 'Variants'. +] + +{ #category : #copying } +SBVariantsView >> snapshot [ + + ^ {ImageMorph new newForm: contents imageForm} ] { #category : #actions } SBVariantsView >> visualize [ super visualize. + self block addMorphBack: contents. self multiverse allMethodBlocksContainingVariants ifNotEmptyDo: [:theMethods | theMethods do: [:aSBStMethod | self buildMethodSectionFor: aSBStMethod]] ifEmpty: [self buildNoVariantsText] diff --git a/packages/Sandblocks-Watch/SBWatchView.class.st b/packages/Sandblocks-Watch/SBWatchView.class.st index 47fe9b0b..4d302c50 100644 --- a/packages/Sandblocks-Watch/SBWatchView.class.st +++ b/packages/Sandblocks-Watch/SBWatchView.class.st @@ -289,6 +289,7 @@ SBWatchView >> resetOnlyValues [ count contents: '0'. watchValues := LinkedList new. + ] { #category : #actions }