Skip to content

Commit

Permalink
Updates permutation label stylings on switched alternatives
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Jan 25, 2024
1 parent 273ace2 commit ec3fba3
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/Sandblocks-Babylonian/Morph.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Morph class >> exampleObject [
^ self new
]

{ #category : #'*Sandblocks-Babylonian' }
Morph >> listensToPermutations [

^ false
]

{ #category : #'*Sandblocks-Babylonian' }
Morph >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [

Expand Down
9 changes: 9 additions & 0 deletions packages/Sandblocks-Babylonian/SBEditor.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Extension { #name : #SBEditor }

{ #category : #'*Sandblocks-Babylonian' }
SBEditor >> sendNewPermutationNotification [

self allMorphsDo: [:morph | morph listensToPermutations ifTrue: [morph updateStyling]]


]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ SBExampleCluster >> extractedTopHeadingsFrom: aSBMultiverse [
^ (aSBMultiverse universes collect: [:aUniverse |
self newContainerMorph
addAllMorphsBack: {
TextMorph new contents: aUniverse activePermutation asStylizedText.
SBPermutationLabel newDisplaying: aUniverse activePermutation.
SBButton newApplyPermutationFor: aUniverse activePermutation}])
]

Expand Down
4 changes: 3 additions & 1 deletion packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [

| multiverse |
multiverse := self active multiverse.
(self onlySwitchedTabsIn: aMethodBlock multiverse: multiverse) ifTrue: [^ self].
(self onlySwitchedTabsIn: aMethodBlock multiverse: multiverse)
ifTrue: [ [self sandblockEditor sendNewPermutationNotification] forkAt: Processor userBackgroundPriority.
^ self].

self updateInBackgroundOnTimeoutRevertTo: multiverse

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SBLiveView >> buildPreviewFor: aPermutation [
addAllMorphsBack: {
self containerRow listDirection: #topToBottom;
addAllMorphsBack: {
TextMorph new contents: aPermutation asStylizedText.
SBPermutationLabel newDisplaying: aPermutation.
self newPermutationButtonRowFor: aPermutation showing: preview.
preview}.
LineMorph from: 0@0 to: 0@50 color: Color black width: 2}).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SBPermutationGridsView >> buildPermutationFor: aSBUniverse [
addAllMorphsBack: {
self containerRow listDirection: #topToBottom;
addAllMorphsBack: {
TextMorph new contents: aSBUniverse activePermutation asStylizedText.
SBPermutationLabel newDisplaying: aSBUniverse activePermutation.
SBButton newApplyPermutationFor: aSBUniverse activePermutation.
(SBPermutationCluster
newForSize: morphResizer
Expand Down
43 changes: 43 additions & 0 deletions packages/Sandblocks-Babylonian/SBPermutationLabel.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Class {
#name : #SBPermutationLabel,
#superclass : #TextMorph,
#instVars : [
'permutation'
],
#category : #'Sandblocks-Babylonian'
}

{ #category : #'as yet unclassified' }
SBPermutationLabel class >> newDisplaying: aSBPermutation [

^ self new
permutation: aSBPermutation;
updateStyling;
yourself
]

{ #category : #'*Sandblocks-Babylonian' }
SBPermutationLabel >> listensToPermutations [

^ true
]

{ #category : #accessing }
SBPermutationLabel >> permutation [

^ permutation
]

{ #category : #accessing }
SBPermutationLabel >> permutation: aSBPermutation [

permutation := aSBPermutation.

self updateStyling
]

{ #category : #accessing }
SBPermutationLabel >> updateStyling [

self contents: self permutation asStylizedText
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #SBPermutationLabel }

{ #category : #'*Sandblocks-Babylonian' }
SBPermutationLabel >> listensToPermutations [

^ true
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBPlainResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SBPlainResultsView >> buildAllPossibleResults [
{ #category : #building }
SBPlainResultsView >> buildPermutationFor: aSBUniverse [

self block addAllMorphsBack: { TextMorph new contents: aSBUniverse activePermutation asStylizedText .
self block addAllMorphsBack: {SBPermutationLabel newDisplaying: aSBUniverse activePermutation.
SBButton newApplyPermutationFor: aSBUniverse activePermutation.
(self containerRow listDirection: #leftToRight)
addAllMorphsBack: aSBUniverse watches.
Expand Down
3 changes: 2 additions & 1 deletion packages/Sandblocks-Morphs/SBButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ SBButton class >> newApplyPermutationFor: aPermutation [
size: 8.0 sbScaled;
color: (Color r: 0.0 g: 1 b: 0.0))
label: 'Apply'
do: [aPermutation apply];
do: [aPermutation apply.
self sandblockEditor sendNewPermutationNotification];
makeSmall;
cornerStyle: #squared
]
Expand Down

0 comments on commit ec3fba3

Please sign in to comment.