Skip to content

Commit

Permalink
Various fixes and adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Mar 7, 2024
1 parent 99a3486 commit 61f5533
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 45 deletions.
6 changes: 6 additions & 0 deletions packages/Sandblocks-Babylonian/Form.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #Form }

{ #category : #'*Sandblocks-Babylonian' }
Form >> applyResize: aPoint [

^ self scaledToSize: aPoint
]

{ #category : #'*Sandblocks-Babylonian' }
Form class >> exampleBlock [

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

{ #category : #'*Sandblocks-Babylonian' }
ImageMorph >> applyResize: aPoint [

| form |
form := self form.
form := form applyResize: aPoint.
^ form asMorph
]
21 changes: 21 additions & 0 deletions packages/Sandblocks-Babylonian/Morph.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #Morph }

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

^ self extent: aPoint
]

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

Expand All @@ -19,3 +25,18 @@ Morph >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [
addMorphBack: (aSBMorphResizer applyOn: self sbSnapshot asMorph);
yourself
]

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

^ Array streamContents: [:stream | self topLevelVariantsDo: [:block | stream nextPut: block]]
]

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

self submorphsDo: [:morph |
(morph isSandblock and: [morph isVariant])
ifTrue: [aBlock value: morph]
ifFalse: [morph topLevelVariantsDo: aBlock]]
]
6 changes: 6 additions & 0 deletions packages/Sandblocks-Babylonian/Object.extension.st
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Extension { #name : #Object }

{ #category : #'*Sandblocks-Babylonian' }
Object >> applyResize: aPoint [

"Nothing"
]

{ #category : #'*Sandblocks-Babylonian' }
Object >> asSBWatchValue [

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ SBCluster >> newTopRowFrom: aCollectionOfMorphs [
^ self newContainerMorph
listDirection: #leftToRight;
listCentering: #bottomRight;
cellPositioning: #bottomCenter;
cellPositioning: #topCenter;
hResizing: #spaceFill;
addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph |
aMorph rotationDegrees: 90.
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SBExampleCluster >> displayedIndex: aNumber [
SBExampleCluster >> extractRowsFrom: aUniverse [

^ aUniverse watches collect: [:aWatch | | display |
display := (aWatch exampleToDisplay associations at: self displayedIndex) value display.
display := (aWatch exampleToDisplay at: (self multiverse activeExamples at: self displayedIndex)) value display.
self compressedMorphsForDisplay: display]
]

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExampleTrace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SBExampleTrace >> buildDisplayMatrix [
matrix := Matrix
rows: 2
columns: self multiverse universes size.
displayedExample := self multiverse watches first examples at: self displayedIndex.
displayedExample := self multiverse activeExamples at: self displayedIndex.

matrix atRow: 1 put: (self extractedTopHeadingsFrom: self multiverse).
self multiverse universes withIndexDo: [:aUniverse :column |
Expand Down
65 changes: 37 additions & 28 deletions packages/Sandblocks-Smalltalk/SBVariant.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ SBVariant class >> named: aString associations: aCollectionOfAssociations active

| defaultBehavior requestor requiredPermutation |
aNumber <= 0 ifTrue: [^ nil].
defaultBehavior := (aCollectionOfAssociations at: aNumber) value value.
defaultBehavior := (aCollectionOfAssociations at: aNumber) value.
"Inactive variants ignore any active or dynamic permutation shenanigans"
aBoolean ifFalse: [^ defaultBehavior].
aBoolean ifFalse: [^ defaultBehavior value].

"Always prioritize the permutation which is marked as active"
SBActiveVariantPermutation value ifNotNil: [^ (aCollectionOfAssociations at: (SBActiveVariantPermutation value at: uuid)) value value].

"The requesting object does not require dynamic update behavior in which it needs to know a certain alternative"
SBExploriants objectToPermutation at: (requestor := thisContext sender receiver) ifAbsent: [^ defaultBehavior].
SBExploriants objectToPermutation at: (requestor := thisContext sender receiver) ifAbsent: [^ defaultBehavior value].
"The permutation is outdated and does not know this variant"
(requiredPermutation := SBExploriants objectToPermutation at: requestor) at: uuid ifAbsent: [^ defaultBehavior].
(requiredPermutation := SBExploriants objectToPermutation at: requestor) at: uuid ifAbsent: [^ defaultBehavior value].
"An outdated permutation in which an alternative with a higher index than current has been deleted"
aCollectionOfAssociations at: (requiredPermutation at: uuid) ifAbsent: [^ defaultBehavior].
aCollectionOfAssociations at: (requiredPermutation at: uuid) ifAbsent: [^ defaultBehavior value].

^ (aCollectionOfAssociations at: (requiredPermutation at: uuid)) value value
]
Expand Down Expand Up @@ -157,6 +157,38 @@ SBVariant >> activeMutateCommandWithNewValue: aBoolean [
oldValue: self isActive
]

{ #category : #converting }
SBVariant >> allPermutations [

| allPermutations |
allPermutations := OrderedCollection new.
self allPermutations: allPermutations currentPath: (SBPermutation new referencedVariants: OrderedCollection new).
^ allPermutations
]

{ #category : #converting }
SBVariant >> allPermutations: allPermutations currentPath: aPermutation [

"Private helper function"
self flag: #todo. "A bit of a mess. - jb"
^ self namedBlocks withIndexCollect: [:aNamedBlock :i |
| topLevelVariants currentPath |
topLevelVariants := aNamedBlock block topLevelVariants.
currentPath := aPermutation copyWith: (self id -> i).
currentPath referencedVariants: (aPermutation referencedVariants copyWith: self).
topLevelVariants
ifEmpty: [allPermutations add: currentPath]
ifNotEmpty: [:childVariants | | permutations nestedPermutations |
nestedPermutations := childVariants collect: [:child | child allPermutations: OrderedCollection new currentPath: currentPath].
permutations := nestedPermutations first.
(2 to: topLevelVariants size) do: [:index | | nestedPermutation |
nestedPermutation := nestedPermutations at: index.
permutations := permutations gather: [:aNestedPermutation |
nestedPermutation collect: [:aNestedNestedPermutation | SBPermutation newCombinedOf: aNestedPermutation and: aNestedNestedPermutation]]].
allPermutations addAll: permutations.
permutations ]]
]

{ #category : #accessing }
SBVariant >> alternatives [

Expand All @@ -182,29 +214,6 @@ SBVariant >> alternativesEqual: otherAlternatives [
areSame]
]

{ #category : #converting }
SBVariant >> asNestedPaths [

| allPaths |
allPaths := OrderedCollection new.
self asNestedPaths: allPaths currentPath: (SBPermutation new referencedVariants: OrderedCollection new).
^ allPaths
]

{ #category : #converting }
SBVariant >> asNestedPaths: allPaths currentPath: aPermutation [

"Private helper function"
self namedBlocks withIndexCollect: [:aNamedBlock :i | | nestedVariants currentPath |
nestedVariants := aNamedBlock block childSandblocks select: #isVariant.
currentPath := aPermutation copyWith: (self id -> i).
currentPath referencedVariants: (aPermutation referencedVariants copyWith: self).
nestedVariants
ifEmpty: [allPaths add: currentPath]
ifNotEmpty: [:children | children do: [:child |
child asNestedPaths: allPaths currentPath: currentPath]]]
]

{ #category : #converting }
SBVariant >> asProxy [

Expand Down
8 changes: 5 additions & 3 deletions packages/Sandblocks-Utils/SBPermutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SBPermutation class >> allPermutationsOf: aCollectionOfVariants [
| permutations topLevelVariants nestedPermutations |
aCollectionOfVariants ifEmpty:[^{SBNilPermutation new referencedVariants: {}}].
topLevelVariants := aCollectionOfVariants select: [:aVariant | aVariant parentVariant isNil].
nestedPermutations := topLevelVariants collect: #asNestedPaths.
nestedPermutations := topLevelVariants collect: #allPermutations.
permutations := nestedPermutations first.

(2 to: topLevelVariants size) do: [:i | | nestedPermutation |
Expand All @@ -33,7 +33,9 @@ SBPermutation class >> allPermutationsOf: aCollectionOfVariants [
SBPermutation class >> newCombinedOf: onePermutation and: anotherPermutation [

| result |
result := self new referencedVariants: (onePermutation referencedVariants, anotherPermutation referencedVariants).
result := self new referencedVariants:
((onePermutation referencedVariants, anotherPermutation referencedVariants) asSet
sorted: [:a :b | a name <= b name]).
result addAll: onePermutation.
result addAll: anotherPermutation.
^ result
Expand Down Expand Up @@ -64,7 +66,7 @@ SBPermutation >> asString [
as one variant only will not return a string but a variant"
^ (self referencedVariants collect: [:aVariant |
aVariant name, ': ', (aVariant blockAt: (self at: aVariant id)) name])
fold: [:a :b | a, ', ', b ]
fold: [:a :b | a, ', ', Character cr, b ]


]
Expand Down
6 changes: 3 additions & 3 deletions packages/Sandblocks-Watch/SBLineChart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ SBLineChart >> datapointDefaultColor [
{ #category : #'visualization - constants' }
SBLineChart >> datapointExtent [

^ 4@4
^ 2@2
]

{ #category : #geometry }
Expand Down Expand Up @@ -82,7 +82,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [
"There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area"
^ Morph new
height: self targetHeight;
left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded;
left: ((positionIndex - 0.5) * self spaceBetweenPoints ) rounded;
width: self spaceBetweenPoints;
color: Color transparent;
balloonText: aValue printString;
Expand Down Expand Up @@ -166,7 +166,7 @@ SBLineChart >> positiveGradientColor [
{ #category : #'visualization - constants' }
SBLineChart >> spaceBetweenPoints [

^ 10
^ 6
]

{ #category : #visualization }
Expand Down
16 changes: 8 additions & 8 deletions packages/Sandblocks-Watch/SBMorphResizer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Class {
{ #category : #'initialize-release' }
SBMorphResizer class >> newBig [

^ self newLabeled: 'big' transforming: [:aMorph | aMorph extent: 350@350]
^ self newLabeled: 'big' transforming: [:anObject | anObject applyResize: 350@350]
]

{ #category : #'initialize-release' }
SBMorphResizer class >> newIdentity [

^ self newLabeled: 'original' transforming: [:aMorph | "Do nothing"]
^ self newLabeled: 'original' transforming: [:anObject | "Do nothing"]
]

{ #category : #'initialize-release' }
Expand All @@ -35,25 +35,25 @@ SBMorphResizer class >> newLabeled: aName transforming: aBlockTakingASingleParam
{ #category : #'initialize-release' }
SBMorphResizer class >> newMedium [

^ self newLabeled: 'medium' transforming: [:aMorph | aMorph extent: 150@150]
^ self newLabeled: 'medium' transforming: [:anObject | anObject applyResize: 150@150]
]

{ #category : #'initialize-release' }
SBMorphResizer class >> newSmall [

^ self newLabeled: 'small' transforming: [:aMorph | aMorph extent: 100@100]
^ self newLabeled: 'small' transforming: [:anObject | anObject applyResize: 100@100]
]

{ #category : #'initialize-release' }
SBMorphResizer class >> newThumbmail [

^ self newLabeled: 'thumbmail' transforming: [:aMorph | aMorph extent: 40@40]
^ self newLabeled: 'thumbmail' transforming: [:anObject | anObject applyResize: 40@40]
]

{ #category : #'initialize-release' }
SBMorphResizer class >> newTiny [

^ self newLabeled: 'tiny' transforming: [:aMorph | aMorph extent: 15@15]
^ self newLabeled: 'tiny' transforming: [:anObject | anObject applyResize: 15@15]
]

{ #category : #'initialize-release' }
Expand All @@ -70,8 +70,8 @@ SBMorphResizer class >> standardOptions [
{ #category : #actions }
SBMorphResizer >> applyOn: aMorph [

self transformFunction value: aMorph.
^ aMorph
^ self transformFunction value: aMorph.

]

{ #category : #'initialize-release' }
Expand Down

0 comments on commit 61f5533

Please sign in to comment.