Skip to content

Commit

Permalink
Adds a synchronisation to live view
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Dec 13, 2023
1 parent 27014ac commit 5a05c67
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ SBLiveView >> newPermutationButtonRowFor: aPermutation showing: aPreview [
cellGap: 8 * self scalingFactor;
addAllMorphsBack: {
SBButton newApplyPermutationFor: aPermutation.
self rebuildButtonIn: aPreview applying: aPermutation. }
self rebuildButtonIn: aPreview applying: aPermutation.
self synchronizeButtonIn: aPreview}
]

{ #category : #initialization }
Expand All @@ -138,16 +139,15 @@ SBLiveView >> newRegisteredListenerFor: aPermutation [
]

{ #category : #initialization }
SBLiveView >> newRegisteredListenerFor: aPermutation in: aContainer [
SBLiveView >> privateRegisterListener: aNewListener for: aPermutation in: aContainer [

| listener oldListener |
listener := self evaluateSetUp.
| oldListener |
oldListener := aContainer valueOfProperty: #sbListener.
oldListener owner
ifNil: [broadcaster insertListener: listener into: aContainer]
ifNotNil: [broadcaster replaceListener: oldListener with: listener].
ifNil: [broadcaster insertListener: aNewListener into: aContainer]
ifNotNil: [broadcaster replaceListener: oldListener with: aNewListener].

listener allMorphsDo: [:aSubMorph |
aNewListener allMorphsDo: [:aSubMorph |
SBExploriants objectToPermutation at: aSubMorph put: aPermutation].

]
Expand All @@ -168,11 +168,18 @@ SBLiveView >> rebuildButtonIn: aContainer applying: aPermutation [
^ SBButton new
icon: (SBIcon iconRotateRight size: 8.0 sbScaled)
label: 'Re-Build This'
do: [self newRegisteredListenerFor: aPermutation in: aContainer];
do: [self rebuildRegisteredListenerFor: aPermutation in: aContainer];
makeSmall;
cornerStyle: #squared
]

{ #category : #initialization }
SBLiveView >> rebuildRegisteredListenerFor: aPermutation in: aContainer [

self privateRegisterListener: self evaluateSetUp for: aPermutation in: aContainer

]

{ #category : #actions }
SBLiveView >> reportError: anError [

Expand All @@ -198,6 +205,29 @@ SBLiveView >> setUpMorph [
^ self block firstSubmorph "setup row" lastSubmorph
]

{ #category : #building }
SBLiveView >> synchronizeButtonIn: aContainer [

^ SBButton new
icon: (SBIcon iconRecycle size: 8.0 sbScaled)
label: 'Synchronize others'
do: [self synchronizePreviewsWith: aContainer];
makeSmall;
cornerStyle: #squared
]

{ #category : #building }
SBLiveView >> synchronizePreviewsWith: aContainer [

| replacingListener |
replacingListener := (aContainer valueOfProperty: #sbListener).
(broadcaster containers reject: [:someContainer | aContainer == someContainer])
do: [:otherContainer |
self privateRegisterListener: replacingListener veryDeepCopy
for: (SBExploriants objectToPermutation at: (otherContainer valueOfProperty: #sbListener))
in: otherContainer ]
]

{ #category : #actions }
SBLiveView >> toggleStepping [

Expand Down

0 comments on commit 5a05c67

Please sign in to comment.