Skip to content

Commit

Permalink
renames, improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Mar 29, 2024
1 parent 851f1d9 commit f40aba3
Show file tree
Hide file tree
Showing 20 changed files with 211 additions and 164 deletions.
30 changes: 17 additions & 13 deletions packages/Sandblocks-Babylonian/SBCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ SBCluster >> initialize [
changeTableLayout;
listDirection: #topToBottom;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap
hResizing: #shrinkWrap;
cellInset: 0@10
]

{ #category : #accessing }
Expand Down Expand Up @@ -113,8 +114,7 @@ SBCluster >> newTopRowFrom: aCollectionOfMorphs [
cellPositioning: #topCenter;
hResizing: #spaceFill;
addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph |
aMorph rotationDegrees: 90.
(self wrapInCell: aMorph owner flexVertically: true flexHorizontally: false) borderWidth: 0])
self morphResizer applyOn: aMorph])
]

{ #category : #visualisation }
Expand All @@ -138,16 +138,19 @@ SBCluster >> visualize [
(matrix rowCount < 2 or: [matrix columnCount < 2])
ifTrue:[self visualizeNothingToDisplay. ^ self].

self addAllMorphsBack: {
self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph"
self addMorphBack: (
self newContainerMorph
listDirection: #leftToRight;
cellInset: 0;
addAllMorphsBack: {
self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph"
SBGrid newDisplaying:
((matrix atRows: 2 to: matrix rowCount columns: 2 to: matrix columnCount)
collect: [:aMorph | self wrapInCell: aMorph])}}
cellInset: 0@0;
addAllMorphsBack: {
self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph"
self newContainerMorph
listDirection: #leftToRight;
cellInset: 5@(-10);
addAllMorphsBack: {
self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph"
SBGrid newDisplaying:
((matrix atRows: 2 to: matrix rowCount columns: 2 to: matrix columnCount)
collect: [:aMorph | self wrapInCell: aMorph])}})
]

{ #category : #visualisation }
Expand All @@ -171,6 +174,7 @@ SBCluster >> wrapInCell: aMorph flexVertically: aVBoolean flexHorizontally: aHBo

| cell targetExtent|
cell := self newCellMorph.
cell on: #click send: #value to: [aMorph triggerEvent: #clicked].

aVBoolean ifTrue: [cell vResizing: #shrinkWrap].
aHBoolean ifTrue: [cell hResizing: #shrinkWrap].
Expand All @@ -189,6 +193,6 @@ SBCluster >> wrapInCell: aMorph flexVertically: aVBoolean flexHorizontally: aHBo
cell addMorph: (ImageMorph new
newForm: (aMorph imageForm scaledIntoFormOfSize: targetExtent);
when: #clicked send: #triggerEvent: to: aMorph with: #clicked).
cell on: #click send: #value to: [cell submorphs first triggerEvent: #clicked].

^ cell
]
32 changes: 24 additions & 8 deletions packages/Sandblocks-Babylonian/SBCorrelationCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,37 @@ SBCorrelationCluster >> extractedTopHeadingsFrom: aCollectionOfCorrelatingUniver
referingTo: aCorrelatingUniverse]
]

{ #category : #visualisation }
SBCorrelationCluster >> newLeftColumnFrom: aCollectionOfMorphs [

"Height should be set, but width can vary"
^ self newContainerMorph
cellPositioning: #rightCenter;
addAllMorphsBack: (aCollectionOfMorphs collect: [:aMorph |
aMorph wrapFlag: false.
(self wrapInCell: aMorph flexVertically: false flexHorizontally: true)
listDirection: #rightToLeft;
borderWidth: 0])
]

{ #category : #visualisation }
SBCorrelationCluster >> newTopRowFrom: aCollectionOfPermutationLabels [

"Width should be set, but height can vary"
^ self newContainerMorph
listDirection: #leftToRight;
listCentering: #bottomRight;
cellPositioning: #topCenter;
cellPositioning: #bottomCenter;
hResizing: #spaceFill;
addAllMorphsBack: (aCollectionOfPermutationLabels collect: [:aLabel |
self newContainerMorph
addAllMorphsBack: {
(self
wrapInCell: aLabel
flexVertically: true
flexHorizontally: false) borderWidth: 0.
SBButton newApplyPermutationFor: (aLabel universe activePermutation).}])
self morphResizer applyOn: aLabel])
]

{ #category : #helper }
SBCorrelationCluster >> wrapInCell: aMorph [

^ self morphResizer label = SBMorphResizer newIdentity label
ifTrue: [self wrapInCell: aMorph flexVertically: true flexHorizontally: true]
ifFalse: [self wrapInCell: aMorph flexVertically: true flexHorizontally: false]

]
11 changes: 7 additions & 4 deletions packages/Sandblocks-Babylonian/SBCorrelationView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ SBCorrelationView >> buildForExample: anExample watching: aWatch [
self containerRow listDirection: #topToBottom;
addAllMorphsBack: {
SBOwnTextMorph new contents: (
'{1}, {2}' format: {anExample label.
'{1}{2}' format: {"anExample label" ''.
(aWatch cleanedExpression sourceString)}).
self buildGridsFor: anExample watching: aWatch} flatten})
self containerRow
listDirection: #topToBottom;
cellPositioning: #rightCenter;
addAllMorphsBack: ((self buildGridsFor: anExample watching: aWatch) flatten)}})
]

{ #category : #building }
Expand Down Expand Up @@ -63,7 +66,7 @@ SBCorrelationView >> buildSelectionRow [
| container selectedString |
container := self containerRow.
self ensureVariantSelectionIn: container.
selectedString := 'Selected: '.
selectedString := ''.
selectedVariants
ifEmpty: [ selectedString := selectedString, 'None' ]
ifNotEmpty: [ selectedString := selectedString, ((selectedVariants collect: #name) fold: [:a :b | a, ', ', Character cr, b ])].
Expand All @@ -80,7 +83,7 @@ SBCorrelationView >> buildVariantSelection [
topLevelVariant := options detect: [:aVariant | aVariant parentVariant isNil] ifNone: [options first].

^ SBComboBox new
prefix: 'Add or Remove';
prefix: 'Configure Y Axis';
labels: (options collect: #name);
values: options;
object: topLevelVariant;
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBCustomView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SBCustomView >> buildViewOptions [
options := self viewClasses collect: [:aClass | aClass new hasBeenRenamed: true].

^ SBComboBox new
prefix: 'Current View: ';
prefix: 'Current Grid View: ';
labels: (options collect: #name);
values: options ;
object: options first;
Expand Down
22 changes: 2 additions & 20 deletions packages/Sandblocks-Babylonian/SBDiffTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ Class {
#category : #'Sandblocks-Babylonian'
}

{ #category : #nil }
SBDiffTabView >> addButton [

^ SBButton new
icon: (SBIcon iconPlus
size: 7.0 sbScaled;
color: (Color green))
do: [self addTab];
makeSmall;
cornerStyle: #squared;
vResizing: #spaceFill;
balloonText: 'Add';
cellGap: -1.0 sbScaled;
layoutInset: (4.0 @ 4.0) sbScaled
]

{ #category : #callbacks }
SBDiffTabView >> artefactSaved: aMethodBlock [

Expand Down Expand Up @@ -72,14 +56,12 @@ SBDiffTabView >> buildView [
SBDiffTabView >> diffButton [

^ SBButton new
icon: (SBIcon iconCodeFork size: 12.0)
icon: (SBIcon iconCodeFork size: 10)
do: [self toggleDiffView];
makeSmall;
balloonText: 'Toggle diff to others';
vResizing: #spaceFill;
cornerStyle: #squared;
cellGap: -1.0 sbScaled;
layoutInset: (4.0 @ 3.0)
cornerStyle: #squared
]

{ #category : #diffing }
Expand Down
85 changes: 60 additions & 25 deletions packages/Sandblocks-Babylonian/SBExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ SBExample >> run [
self sendStartNotification.

processRunning := true.
currentProcess := [
| returned |
currentProcess := [ | returned |
SBExecutionEnvironment value: self.

[returned := self evaluate] on: Error do: [:e |
Expand All @@ -397,12 +396,19 @@ SBExample >> run [
self scheduleLastError: nil.
currentProcess := nil.
processRunning := false.
Project current addDeferredUIMessage: [
returnValue reportValues: {returned asSBWatchValue} sized: SBMorphResizer newThumbmail.
returnValue updateDisplay.
self sendFinishNotification]
] forkAt: Processor userBackgroundPriority.

SBVariant
named: 'addDeferredUIMessage:'
associations: {
'with' -> [
Project current addDeferredUIMessage: [
returnValue reportValues: {returned asSBWatchValue} sized: SBMorphResizer newThumbmail.
returnValue updateDisplay.
self sendFinishNotification]].
'without' -> [Project current addDeferredUIMessage: [self sendFinishNotification]]}
activeIndex: 2
id: '60c08640-321a-fb4c-90f8-8d2bd5ab0bcc'
isActive: false] forkAt: Processor userBackgroundPriority.

^ currentProcess
]

Expand All @@ -424,7 +430,12 @@ SBExample >> runSetup [
errorDecorator ifNotNil: #detach.
errorDecorator := nil.
traceSize := 0.
returnValue clear.
SBVariant
named: 'clear'
associations: {'with' -> [returnValue clear]. 'without' -> []}
activeIndex: 2
id: '62643a5a-1d80-7f43-a32f-f23665e98f83'
isActive: false
]

{ #category : #execution }
Expand All @@ -449,19 +460,39 @@ SBExample >> scheduleLastError: anError [
{ #category : #initialization }
SBExample >> self: aBlock args: aCollectionBlock label: aString [

self
removeAllMorphs;
addMorphBack: (icon := SBIcon iconPause
small;
color: Color white;
on: #click send: #toggleRunning to: self);
addMorphBack: (nameInput := SBTextBubble new contents: aString);
addMorphBack: (SBStringMorph new contents: 'self:');
addMorphBack: aBlock;
addMorphBack: (SBStringMorph new contents: 'args:');
addMorphBack: aCollectionBlock;
addMorphBack: (returnValue := SBExampleWatchView new);
updateIcon
SBVariant
named: 'remove returnValue'
associations: {
'with' -> [
self
removeAllMorphs;
addMorphBack: (icon := SBIcon iconPause
small;
color: (Color r: 1 g: 1 b: 1);
on: #click send: #toggleRunning to: self);
addMorphBack: (nameInput := SBTextBubble new contents: aString);
addMorphBack: (SBStringMorph new contents: 'self:');
addMorphBack: aBlock;
addMorphBack: (SBStringMorph new contents: 'args:');
addMorphBack: aCollectionBlock;
addMorphBack: (returnValue := SBExampleWatchView new);
updateIcon].
'w/o' -> [
self
removeAllMorphs;
addMorphBack: (icon := SBIcon iconPause
small;
color: (Color r: 1 g: 1 b: 1);
on: #click send: #toggleRunning to: self);
addMorphBack: (nameInput := SBTextBubble new contents: aString);
addMorphBack: (SBStringMorph new contents: 'self:');
addMorphBack: aBlock;
addMorphBack: (SBStringMorph new contents: 'args:');
addMorphBack: aCollectionBlock;
updateIcon]}
activeIndex: 2
id: '769c6446-2026-6547-a0ff-101e54bf3665'
isActive: false
]

{ #category : #initialization }
Expand Down Expand Up @@ -527,11 +558,15 @@ SBExample >> stopRunning [

self stopSteppingSelector: #run.
active := false.
returnValue clear.
SBVariant
named: 'clear'
associations: {'with' -> [returnValue clear]. 'without' -> []}
activeIndex: 2
id: 'f319a83a-f7aa-9a40-b959-f56ad3c4cfbc'
isActive: false.
self updateIcon.

self sandblockEditor allMorphsDo: [:morph |
(morph isSandblock and: [morph listensToExamples]) ifTrue: [morph exampleStopped: self]]
self sandblockEditor allMorphsDo: [:morph | (morph isSandblock and: [morph listensToExamples]) ifTrue: [morph exampleStopped: self]]
]

{ #category : #actions }
Expand Down
18 changes: 1 addition & 17 deletions packages/Sandblocks-Babylonian/SBExampleCluster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,5 @@ SBExampleCluster >> newTopRowFrom: aCollectionOfPermutationLabels [
cellPositioning: #topCenter;
hResizing: #spaceFill;
addAllMorphsBack: (aCollectionOfPermutationLabels collect: [:aLabel |
| wrappedLabel button |
aLabel rotationDegrees: 90.
wrappedLabel := (self wrapInCell: aLabel owner
flexVertically: true
flexHorizontally: false) borderWidth: 0.
"Rotating morphs somehow clips their right border, so dirty hack so container gets clipped 1px"
button := self newContainerMorph
cellInset: 1;
addMorphBack: (SBButton newApplyPermutationFor: aLabel permutation);
rotationDegrees: 90.
button owner width > wrappedLabel width ifTrue: [button firstSubmorph makeTiny].

self newContainerMorph
cellPositioning: #bottomToTop;
cellPositioning: #topCenter;
cellInset: 0@2;
addAllMorphsBack: {button owner. wrappedLabel}])
self morphResizer applyOn: aLabel])
]
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ SBExampleValueDisplay >> reportValues: aCollectionOfWatchValues name: aString si

display reportValues: aCollectionOfWatchValues sized: aSBMorphResizer.
label contents: aString.
label visible: aString notEmpty.
label visible: (SBVariant
named: 'visible:'
associations: {'with' -> [aString notEmpty]. 'without' -> [false]}
activeIndex: 2
id: '15acb8c3-94a2-9348-8d02-0c6fa11e9f7c'
isActive: false).
hadValue := true
]

Expand Down
Loading

0 comments on commit f40aba3

Please sign in to comment.