Skip to content

Commit

Permalink
Rebuild this button
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Dec 4, 2023
1 parent 07e07d9 commit dd97bea
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 20 deletions.
21 changes: 18 additions & 3 deletions packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down
77 changes: 61 additions & 16 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 [

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

Expand All @@ -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.
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SBResultsView >> updateButton [

^ SBButton new
icon: SBIcon iconRotateLeft
label: 'Re-Generate'
label: 'Re-Generate Multiverse'
do: [self multiverse initialize];
cornerStyle: #squared
]
Expand Down

0 comments on commit dd97bea

Please sign in to comment.