From b5fc83423ea76c3eeb5ba72cf30252bf5771f711 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 25 Mar 2024 17:28:19 +0100 Subject: [PATCH] Unify Grid Views --- .../SBCustomView.class.st | 95 +++++++++++++++++++ .../SBExampleGridsView.class.st | 2 +- .../SBExploriants.class.st | 2 + .../SBExploriantsView.class.st | 22 +++-- .../SBHistoryView.class.st | 14 +-- .../SBPermutationGridsView.class.st | 2 +- .../SBPlainResultsView.class.st | 6 -- .../SBSwitchableResultsView.class.st | 10 +- 8 files changed, 124 insertions(+), 29 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBCustomView.class.st diff --git a/packages/Sandblocks-Babylonian/SBCustomView.class.st b/packages/Sandblocks-Babylonian/SBCustomView.class.st new file mode 100644 index 00000000..45f7c303 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBCustomView.class.st @@ -0,0 +1,95 @@ +Class { + #name : #SBCustomView, + #superclass : #SBExploriantsView, + #instVars : [ + 'viewOptions' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #accessing } +SBCustomView >> activeIndex [ + + ^ self viewClasses indexOf: self selectedView class +] + +{ #category : #building } +SBCustomView >> buildViewOptions [ + + | options | + options := self viewClasses collect: [:aClass | aClass new hasBeenRenamed: true]. + + ^ SBComboBox new + prefix: 'Current View: '; + labels: (options collect: #name); + values: options ; + object: options first; + when: #selectionChanged send: #switchView to: self +] + +{ #category : #initialization } +SBCustomView >> initialize [ + + super initialize. + + viewOptions := self buildViewOptions. + self name: 'Results'. + + self block addMorphFront: viewOptions. + self block addMorphBack: self selectedView + +] + +{ #category : #accessing } +SBCustomView >> isOverview [ + + ^ true +] + +{ #category : #accessing } +SBCustomView >> multiverse: aSBMultiverse [ + + super multiverse: aSBMultiverse. + viewOptions values do: [:aSBNamedBlock | aSBNamedBlock multiverse: aSBMultiverse] +] + +{ #category : #accessing } +SBCustomView >> selectedView [ + + ^ viewOptions object +] + +{ #category : #updating } +SBCustomView >> switchView [ + + self selectedView block = self block lastSubmorph ifTrue: [^ self]. + + self block lastSubmorph delete. + self block addMorphBack: self selectedView block. +] + +{ #category : #accessing } +SBCustomView >> viewClasses [ + + ^ {SBPermutationGridsView. + SBExampleGridsView. + SBLiveView.} +] + +{ #category : #accessing } +SBCustomView >> views [ + + ^ viewOptions values +] + +{ #category : #updating } +SBCustomView >> visualize [ + + self block addMorphBack: self selectedView block. +] + +{ #category : #accessing } +SBCustomView >> wantsReloadOnSaveWhenOpen [ + + ^ self selectedView wantsReloadOnSaveWhenOpen +] diff --git a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st index ba829294..466a12e5 100644 --- a/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleGridsView.class.st @@ -41,5 +41,5 @@ SBExampleGridsView >> initialize [ super initialize. - self name: 'Example Focused'. + self name: 'Example Grouped' ] diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index daa7db2c..34e0a475 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -179,6 +179,8 @@ SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [ | multiverse | multiverse := self active multiverse. + self active wantsReloadOnSaveWhenOpen ifFalse: [^self]. + self ignoreUpdate ifFalse: [self updateInBackgroundOnTimeoutRevertTo: multiverse] ifTrue: [ diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index b943a3fe..b164ef63 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. SBLiveView. SBPlainResultsView. SBVariantsView. SBHistoryView} + ^ {SBCustomView. SBPlainResultsView. SBVariantsView. SBHistoryView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] @@ -93,6 +93,12 @@ SBExploriantsView >> initialize [ vResizing: #shrinkWrap). ] +{ #category : #accessing } +SBExploriantsView >> isOverview [ + + ^false +] + { #category : #accessing } SBExploriantsView >> multiverse [ @@ -111,7 +117,7 @@ SBExploriantsView >> resolveButton [ ^ SBButton new icon: SBIcon iconTrash - label: 'Resolve All From Code' + label: 'Clean in Code' do: [self multiverse resolve]; cornerStyle: #squared ] @@ -127,7 +133,7 @@ SBExploriantsView >> updateButton [ ^ SBButton new icon: SBIcon iconRotateLeft - label: 'Re-Generate Multiverse' + label: 'Re-Generate' do: [self multiverse gatherElements; asyncKaboom]; cornerStyle: #squared ] @@ -140,9 +146,9 @@ SBExploriantsView >> visualize [ self buildButtonRow ] -{ #category : #copying } -SBExploriantsView >> wantsHistory [ - - "If returning true, will be automatically collected for an epoche in the history view" - ^ true +{ #category : #accessing } +SBExploriantsView >> wantsReloadOnSaveWhenOpen [ + + "If true, reload contents on a method save" + ^ false ] diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st index 0781adfa..7d857e08 100644 --- a/packages/Sandblocks-Babylonian/SBHistoryView.class.st +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -19,7 +19,7 @@ SBHistoryView >> buildEpoche [ row := self containerRow. ^ row cellGap: 0@10; - listDirection: #topToBottom; + listDirection: #topToBottom; addAllMorphsBack: {self buildMetaUsageIn: row. self buildSnapshotTabView} @@ -43,9 +43,7 @@ SBHistoryView >> buildSnapshotTabView [ ^ SBTabView namedBlocks: (self tabsToSnapshot collect: [:aTab | SBNamedBlock block: aTab snapshot named: aTab name]) - activeIndex: (SBExploriants uniqueInstance active wantsHistory - ifTrue: [SBExploriants uniqueInstance activeIndex] - ifFalse: [1]) + activeIndex: (SBExploriants uniqueInstance namedBlocks detect: #isOverview) activeIndex ] @@ -127,7 +125,7 @@ SBHistoryView >> saveButton [ { #category : #accessing } SBHistoryView >> tabsToSnapshot [ - ^ SBExploriants uniqueInstance namedBlocks select: #wantsHistory + ^ (SBExploriants uniqueInstance namedBlocks detect: #isOverview) views ] { #category : #actions } @@ -135,9 +133,3 @@ SBHistoryView >> visualize [ self addEpoche ] - -{ #category : #copying } -SBHistoryView >> wantsHistory [ - - ^ false -] diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st index 40d22be9..74636836 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -37,5 +37,5 @@ SBPermutationGridsView >> initialize [ super initialize. - self name: 'Permutation Focused'. + self name: 'Permutation Grouped' ] diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index 6360f55f..a530636f 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -27,9 +27,3 @@ SBPlainResultsView >> initialize [ self name: 'Watches' ] - -{ #category : #copying } -SBPlainResultsView >> wantsHistory [ - - ^ false -] diff --git a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st index 44a38b30..3f416cc9 100644 --- a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st @@ -25,7 +25,7 @@ SBSwitchableResultsView >> buildDimensionOptions [ options := SBMorphResizer standardOptions. ^ SBComboBox new - prefix: 'Morph Dimensions: '; + prefix: 'Image Dimensions: '; labels: (options collect: #label); values: options; object: options third; @@ -59,7 +59,7 @@ SBSwitchableResultsView >> selectedResizer [ ^ dimensionOptions object ] -{ #category : #'as yet unclassified' } +{ #category : #copying } SBSwitchableResultsView >> snapshot [ ^ ImageMorph new newForm: gridContainer imageForm @@ -103,3 +103,9 @@ SBSwitchableResultsView >> visualize [ self buildAllPossibleResults . self concludeContainerWidth. ] + +{ #category : #accessing } +SBSwitchableResultsView >> wantsReloadOnSaveWhenOpen [ + + ^ true +]