Skip to content

Commit

Permalink
Unify Grid Views
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Mar 25, 2024
1 parent 6bfbc44 commit b5fc834
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 29 deletions.
95 changes: 95 additions & 0 deletions packages/Sandblocks-Babylonian/SBCustomView.class.st
Original file line number Diff line number Diff line change
@@ -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
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleGridsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ SBExampleGridsView >> initialize [

super initialize.

self name: 'Example Focused'.
self name: 'Example Grouped'
]
2 changes: 2 additions & 0 deletions packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [

| multiverse |
multiverse := self active multiverse.
self active wantsReloadOnSaveWhenOpen ifFalse: [^self].

self ignoreUpdate
ifFalse: [self updateInBackgroundOnTimeoutRevertTo: multiverse]
ifTrue: [
Expand Down
22 changes: 14 additions & 8 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. SBLiveView. SBPlainResultsView. SBVariantsView. SBHistoryView}
^ {SBCustomView. SBPlainResultsView. SBVariantsView. SBHistoryView}
collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse]
]

Expand Down Expand Up @@ -93,6 +93,12 @@ SBExploriantsView >> initialize [
vResizing: #shrinkWrap).
]

{ #category : #accessing }
SBExploriantsView >> isOverview [

^false
]

{ #category : #accessing }
SBExploriantsView >> multiverse [

Expand All @@ -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
]
Expand All @@ -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
]
Expand All @@ -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
]
14 changes: 3 additions & 11 deletions packages/Sandblocks-Babylonian/SBHistoryView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SBHistoryView >> buildEpoche [
row := self containerRow.
^ row
cellGap: 0@10;
listDirection: #topToBottom;
listDirection: #topToBottom;
addAllMorphsBack: {self buildMetaUsageIn: row. self buildSnapshotTabView}


Expand All @@ -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

]

Expand Down Expand Up @@ -127,17 +125,11 @@ SBHistoryView >> saveButton [
{ #category : #accessing }
SBHistoryView >> tabsToSnapshot [

^ SBExploriants uniqueInstance namedBlocks select: #wantsHistory
^ (SBExploriants uniqueInstance namedBlocks detect: #isOverview) views
]

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

self addEpoche
]

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

^ false
]
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ SBPermutationGridsView >> initialize [

super initialize.

self name: 'Permutation Focused'.
self name: 'Permutation Grouped'
]
6 changes: 0 additions & 6 deletions packages/Sandblocks-Babylonian/SBPlainResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ SBPlainResultsView >> initialize [

self name: 'Watches'
]

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

^ false
]
10 changes: 8 additions & 2 deletions packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +59,7 @@ SBSwitchableResultsView >> selectedResizer [
^ dimensionOptions object
]

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

^ ImageMorph new newForm: gridContainer imageForm
Expand Down Expand Up @@ -103,3 +103,9 @@ SBSwitchableResultsView >> visualize [
self buildAllPossibleResults .
self concludeContainerWidth.
]

{ #category : #accessing }
SBSwitchableResultsView >> wantsReloadOnSaveWhenOpen [

^ true
]

0 comments on commit b5fc834

Please sign in to comment.