diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 0f1a04c5..99f652ce 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -43,17 +43,32 @@ SBExploriants >> = other [ ^ self class = other class ] -{ #category : #'as yet unclassified' } +{ #category : #'ast helpers' } +SBExploriants >> binding: aString for: block class: aClass ifPresent: aBlock [ + + "See SBStContainer >> binding: for: class: ifPresent: " + | outer | + Symbol hasInterned: aString ifTrue: [:sym | | binding | + binding := aClass bindingOf: sym environment: UndefinedObject environment. + binding ifNotNil: [^ aBlock value: ((SBStName poolDeclaration: aString binding: binding) binding: binding)]]. + + outer := self outerArtefact. + (outer notNil and: [outer isSmalltalk]) ifTrue: [^ self outerArtefact binding: aString for: block class: aClass ifPresent: aBlock]. + + ^ nil +] + +{ #category : #testing } SBExploriants >> cacheType: aClass for: aBlock [ ] -{ #category : #'as yet unclassified' } +{ #category : #testing } SBExploriants >> evaluationContext [ ^ nil ] -{ #category : #'as yet unclassified' } +{ #category : #testing } SBExploriants >> evaluationReceiver [ ^ self object diff --git a/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st index 4924d268..81b2fa48 100644 --- a/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st +++ b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st @@ -111,6 +111,18 @@ SBInputBroadcaster >> mouseEnter: anEvent [ anEvent hand newKeyboardFocus: self. ] +{ #category : #accessing } +SBInputBroadcaster >> replaceListener: oldListener with: newListener [ + + | index | + index := self listeners indexOf: oldListener ifAbsent: [^ self]. + + (self containers at: index) replaceSubmorph: (self listeners at: index) by: newListener. + self listeners at: index put: newListener. + (self containers at: index) extent: newListener extent. + +] + { #category : #events } SBInputBroadcaster >> translatedPositionOf: anEvent from: anOriginMorph to: aTargetMorph [ diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index 06f6043d..9fcf216e 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -21,34 +21,34 @@ SBLiveView >> buildBrodcaster [ 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}). - "gridContainer addMorphBack: (SBRow new - changeTableLayout; - hResizing: #spaceFill; - wrapCentering: #center; - listCentering: #center; - cellPositioning: #center; - addMorph: (broadcaster := SBInputBroadcaster new))" - - self updateContainerWidth. +] + +{ #category : #building } +SBLiveView >> buildButtonRow [ + self block addMorphBack: (SBRow new + changeTableLayout; + cellGap: 8 * self scalingFactor; + addAllMorphsBack: {self updateButton. self rebuildButton}) ] { #category : #building } SBLiveView >> buildPreviewFor: aPermutation [ - + + | preview | + preview := self newRegisteredListenerFor: aPermutation. gridContainer addMorphBack: (self containerRow cellPositioning: #center; addAllMorphsBack: { self containerRow listDirection: #topToBottom; - addAllMorphsBack: { + addAllMorphsBack: { SBOwnTextMorph new contents: aPermutation asString. - SBButton newApplyPermutationFor: aPermutation. - self newRegisteredListenerFor: aPermutation}. + self newPermutationButtonRowFor: aPermutation showing: preview. + preview}. LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). - - self updateContainerWidth. ] { #category : #building } @@ -103,6 +103,17 @@ SBLiveView >> listeners [ ^ broadcaster listeners ] +{ #category : #building } +SBLiveView >> newPermutationButtonRowFor: aPermutation showing: aPreview [ + + ^ SBRow new + changeTableLayout; + cellGap: 8 * self scalingFactor; + addAllMorphsBack: { + SBButton newApplyPermutationFor: aPermutation. + self rebuildButtonIn: aPreview applying: aPermutation. } +] + { #category : #initialization } SBLiveView >> newRegisteredListenerFor: aPermutation [ @@ -117,6 +128,39 @@ SBLiveView >> newRegisteredListenerFor: aPermutation [ ] +{ #category : #initialization } +SBLiveView >> newRegisteredListenerFor: aPermutation replacing: anOldListener [ + + | listener | + listener := self evaluateSetUp. + broadcaster replaceListener: anOldListener with: listener. + + listener allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation at: aSubMorph put: aPermutation]. + +] + +{ #category : #building } +SBLiveView >> rebuildButton [ + + ^ SBButton new + icon: SBIcon iconRotateRight + label: 'Re-Build Setup' + do: [self visualize]; + cornerStyle: #squared +] + +{ #category : #building } +SBLiveView >> rebuildButtonIn: aContainer applying: aPermutation [ + + ^ SBButton new + icon: (SBIcon iconRotateRight size: 8.0 sbScaled) + label: 'Re-Build This' + do: [self newRegisteredListenerFor: aPermutation replacing: aContainer lastSubmorph]; + makeSmall; + cornerStyle: #squared +] + { #category : #accessing } SBLiveView >> setUpMorph [ @@ -136,9 +180,10 @@ SBLiveView >> visualize [ self clean. self buildBrodcaster. - self block addMorphBack: self updateButton. + self buildButtonRow. self block addMorphBack: gridContainer. self buildAllPossibleResults. broadcaster extent: self listeners last extent. + self updateContainerWidth. ] diff --git a/packages/Sandblocks-Babylonian/SBResultsView.class.st b/packages/Sandblocks-Babylonian/SBResultsView.class.st index d0b5d2cb..b43d72b4 100644 --- a/packages/Sandblocks-Babylonian/SBResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResultsView.class.st @@ -33,7 +33,7 @@ SBResultsView >> updateButton [ ^ SBButton new icon: SBIcon iconRotateLeft - label: 'Re-Generate' + label: 'Re-Generate Multiverse' do: [self multiverse initialize]; cornerStyle: #squared ]