From f40aba38a6cc64f983926748969a6249976e3c42 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Fri, 29 Mar 2024 01:33:18 +0100 Subject: [PATCH 1/9] renames, improvements --- .../Sandblocks-Babylonian/SBCluster.class.st | 30 ++++--- .../SBCorrelationCluster.class.st | 32 +++++-- .../SBCorrelationView.class.st | 11 ++- .../SBCustomView.class.st | 2 +- .../SBDiffTabView.class.st | 22 +---- .../Sandblocks-Babylonian/SBExample.class.st | 85 +++++++++++++------ .../SBExampleCluster.class.st | 18 +--- .../SBExampleValueDisplay.class.st | 7 +- .../SBExampleWatch.class.st | 56 +++++------- .../Sandblocks-Babylonian/SBGrid.class.st | 2 +- .../SBPartialPermutationLabel.class.st | 23 ++--- .../SBPartialPermutationLabel.extension.st | 7 -- .../SBPermutationGridsView.class.st | 4 +- .../SBPermutationLabel.class.st | 50 +++++++++++ .../SBPermutationLabel.extension.st | 6 ++ .../SBResizableResultsView.class.st | 2 +- .../SBStMessageSend.extension.st | 2 +- .../Sandblocks-Core/SBNamedBlock.class.st | 4 +- packages/Sandblocks-Core/SBTabView.class.st | 10 +-- packages/Sandblocks-Morphs/SBButton.class.st | 2 +- 20 files changed, 211 insertions(+), 164 deletions(-) delete mode 100644 packages/Sandblocks-Babylonian/SBPartialPermutationLabel.extension.st diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index a454e812..a24004b4 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -42,7 +42,8 @@ SBCluster >> initialize [ changeTableLayout; listDirection: #topToBottom; vResizing: #shrinkWrap; - hResizing: #shrinkWrap + hResizing: #shrinkWrap; + cellInset: 0@10 ] { #category : #accessing } @@ -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 } @@ -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 } @@ -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]. @@ -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 ] diff --git a/packages/Sandblocks-Babylonian/SBCorrelationCluster.class.st b/packages/Sandblocks-Babylonian/SBCorrelationCluster.class.st index 43033d83..6e247006 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationCluster.class.st @@ -120,6 +120,19 @@ 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 [ @@ -127,14 +140,17 @@ SBCorrelationCluster >> newTopRowFrom: aCollectionOfPermutationLabels [ ^ 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] + ] diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index ee2666aa..143658ca 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -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 } @@ -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 ])]. @@ -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; diff --git a/packages/Sandblocks-Babylonian/SBCustomView.class.st b/packages/Sandblocks-Babylonian/SBCustomView.class.st index 13ec7048..86baef41 100644 --- a/packages/Sandblocks-Babylonian/SBCustomView.class.st +++ b/packages/Sandblocks-Babylonian/SBCustomView.class.st @@ -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; diff --git a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st index 2a968edf..7b49db85 100644 --- a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st +++ b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st @@ -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 [ @@ -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 } diff --git a/packages/Sandblocks-Babylonian/SBExample.class.st b/packages/Sandblocks-Babylonian/SBExample.class.st index 706cf44e..f5e75205 100644 --- a/packages/Sandblocks-Babylonian/SBExample.class.st +++ b/packages/Sandblocks-Babylonian/SBExample.class.st @@ -386,8 +386,7 @@ SBExample >> run [ self sendStartNotification. processRunning := true. - currentProcess := [ - | returned | + currentProcess := [ | returned | SBExecutionEnvironment value: self. [returned := self evaluate] on: Error do: [:e | @@ -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 ] @@ -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 } @@ -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 } @@ -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 } diff --git a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st index 16d268e3..c0520503 100644 --- a/packages/Sandblocks-Babylonian/SBExampleCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleCluster.class.st @@ -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]) ] diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 3d82a123..279ea71e 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -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 ] diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index b7a29069..e74639a8 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -325,43 +325,20 @@ SBExampleWatch >> identifier: aSymbol [ ] { #category : #initialization } -SBExampleWatch >> initialize [ +SBExampleWatch >> initialize [ | options | +(super initialize). +(options := (SBMorphResizer standardOptions)). + +(exampleToDisplay := (IdentityDictionary new)). +(exampleToValues := (IdentityDictionary new)). +(watchedExpression := (SBStMessageSend new)). +(dimensionOptions := ((SBComboBox new) prefix: 'Preview size: '; labels: (options collect: #'label'); values: options; object: (options third); when: #'selectionChanged' send: #'applyResizerOnValues' to: self)). +(modifyExpression := (SBStBlockBody identityNamed: 'each')). + +(SBVariant named: 'remove modify' associations: {'with' -> [(self changeTableLayout; cellGap: 4; layoutInset: 2; vResizing: #'shrinkWrap'; hResizing: #'shrinkWrap'; addAllMorphsBack: {watchedExpression. ((SBRow new) hResizing: #'spaceFill'; listCentering: #'bottomRight'; addMorphBack: dimensionOptions; yourself). modifyExpression}; yourself). +].'w/o' -> [(self changeTableLayout; cellGap: 4; layoutInset: 2; vResizing: #'shrinkWrap'; hResizing: #'shrinkWrap'; addAllMorphsBack: {watchedExpression. ((SBRow new) hResizing: #'spaceFill'; listCentering: #'bottomRight'; addMorphBack: dimensionOptions; yourself)}; yourself). +]} activeIndex: 2 id: 'f771db53-c26a-2c40-a3f6-5c31ec7aeb44' isActive: false). - | options | - super initialize. - options := SBMorphResizer standardOptions. - - exampleToDisplay := IdentityDictionary new. - exampleToValues := IdentityDictionary new. - watchedExpression := SBStMessageSend new. - dimensionOptions := SBComboBox new - prefix: 'Preview sizes: '; - labels: (options collect: #label); - values: options; - object: options third; - when: #selectionChanged send: #applyResizerOnValues to: self. - modifyExpression := SBStBlockBody identityNamed: 'each'. - - self - changeTableLayout; - cellGap: 4; - layoutInset: 2; - vResizing: #shrinkWrap; - hResizing: #shrinkWrap; - addAllMorphsBack: { - watchedExpression. - SBRow new - hResizing: #spaceFill; - listCentering: #bottomRight; - addMorphBack: dimensionOptions; - yourself. - SBVariant - named: 'modifyExpression' - associations: {'with' -> [modifyExpression]. 'without' -> []} - activeIndex: 2 - id: '90d7c718-89b8-7e48-8262-467d07d56880' - isActive: false}; - yourself ] { #category : #initialization } @@ -439,7 +416,12 @@ SBExampleWatch >> modifyExpression: aBlock [ modifyExpression ifNotNil: #delete. modifyExpression := aBlock. - self addMorphBack: modifyExpression. + SBVariant + named: 'addMorphBack:' + associations: {'with' -> [self addMorphBack: modifyExpression]. 'without' -> []} + activeIndex: 2 + id: 'c3b856eb-2899-cd44-b45c-3b099b02aad6' + isActive: false ] { #category : #accessing } diff --git a/packages/Sandblocks-Babylonian/SBGrid.class.st b/packages/Sandblocks-Babylonian/SBGrid.class.st index 9ae5f41e..b64dacc0 100644 --- a/packages/Sandblocks-Babylonian/SBGrid.class.st +++ b/packages/Sandblocks-Babylonian/SBGrid.class.st @@ -51,5 +51,5 @@ SBGrid >> initialize [ { #category : #visualisation } SBGrid >> updateWidthToPersistColumns [ - self width: (columnCount * (self submorphs first width + (2 * self cellInset))) + self width: (columnCount * (self submorphs first width + (2 * self cellInset))) ] diff --git a/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.class.st b/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.class.st index 4320f5dd..bede6ade 100644 --- a/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.class.st +++ b/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.class.st @@ -1,8 +1,7 @@ Class { #name : #SBPartialPermutationLabel, - #superclass : #TextMorph, + #superclass : #SBPermutationLabel, #instVars : [ - 'permutation', 'universe' ], #category : #'Sandblocks-Babylonian' @@ -18,22 +17,10 @@ SBPartialPermutationLabel class >> newDisplaying: aSBPermutation referingTo: aUn yourself ] -{ #category : #'*Sandblocks-Babylonian' } -SBPartialPermutationLabel >> listensToPermutations [ - - ^ true -] - -{ #category : #accessing } -SBPartialPermutationLabel >> permutation [ - - ^ permutation -] - -{ #category : #accessing } -SBPartialPermutationLabel >> permutation: aPermutation [ - - permutation := aPermutation +{ #category : #'event handling' } +SBPartialPermutationLabel >> mouseDown: evt [ + + self universe activePermutation apply ] { #category : #accessing } diff --git a/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.extension.st b/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.extension.st deleted file mode 100644 index a4e59e1e..00000000 --- a/packages/Sandblocks-Babylonian/SBPartialPermutationLabel.extension.st +++ /dev/null @@ -1,7 +0,0 @@ -Extension { #name : #SBPartialPermutationLabel } - -{ #category : #'*Sandblocks-Babylonian' } -SBPartialPermutationLabel >> listensToPermutations [ - - ^ true -] diff --git a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st index 74636836..9225d1c3 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationGridsView.class.st @@ -17,8 +17,8 @@ SBPermutationGridsView >> buildPermutationFor: aSBUniverse [ addAllMorphsBack: { self containerRow listDirection: #topToBottom; addAllMorphsBack: { - SBPermutationLabel newDisplaying: aSBUniverse activePermutation. - SBButton newApplyPermutationFor: aSBUniverse activePermutation. + (SBPermutationLabel newDisplaying: aSBUniverse activePermutation) + wrapFlag: false. (self currentClusterClass newForSize: self selectedResizer havingWatches: aSBUniverse watches)}}) diff --git a/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st b/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st index b1a45868..9db3090e 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st @@ -16,12 +16,62 @@ SBPermutationLabel class >> newDisplaying: aSBPermutation [ yourself ] +{ #category : #'*Sandblocks-Babylonian' } +SBPermutationLabel >> applyResize: aPoint [ + + ^ self extent: aPoint +] + +{ #category : #'event handling' } +SBPermutationLabel >> click: evt [ + + self permutation apply +] + +{ #category : #initialization } +SBPermutationLabel >> initialize [ + + super initialize. + + self wrapFlag: true. +] + { #category : #'*Sandblocks-Babylonian' } SBPermutationLabel >> listensToPermutations [ ^ true ] +{ #category : #'event handling' } +SBPermutationLabel >> mouseDown: evt [ + + self permutation apply +] + +{ #category : #'event handling' } +SBPermutationLabel >> mouseEnter: evt [ + + "nothing" +] + +{ #category : #'event handling' } +SBPermutationLabel >> mouseLeave: evt [ + + "nothing" +] + +{ #category : #'event handling' } +SBPermutationLabel >> mouseMove: evt [ + + ^ Cursor execute show +] + +{ #category : #'event handling' } +SBPermutationLabel >> mouseUp: evt [ + + "nothing" +] + { #category : #accessing } SBPermutationLabel >> permutation [ diff --git a/packages/Sandblocks-Babylonian/SBPermutationLabel.extension.st b/packages/Sandblocks-Babylonian/SBPermutationLabel.extension.st index ad89430d..b49ace75 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationLabel.extension.st +++ b/packages/Sandblocks-Babylonian/SBPermutationLabel.extension.st @@ -1,5 +1,11 @@ Extension { #name : #SBPermutationLabel } +{ #category : #'*Sandblocks-Babylonian' } +SBPermutationLabel >> applyResize: aPoint [ + + ^ self extent: aPoint +] + { #category : #'*Sandblocks-Babylonian' } SBPermutationLabel >> listensToPermutations [ diff --git a/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st b/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st index ab04b549..33d1f55a 100644 --- a/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st @@ -21,7 +21,7 @@ SBResizableResultsView >> buildDimensionOptions [ options := SBMorphResizer standardOptions. ^ SBComboBox new - prefix: 'Preview sizes: '; + prefix: 'Preview size: '; labels: (options collect: #label); values: options; object: options third; diff --git a/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st b/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st index a98bfc2a..2beeeb0b 100644 --- a/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st +++ b/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st @@ -4,7 +4,7 @@ Extension { #name : #SBStMessageSend } SBStMessageSend >> suggestedAlternationName [ ^ self isAssignment - ifTrue: ['{2}{1}' format: {self selector. self receiver suggestedAlternationName}] + ifTrue: [self receiver suggestedAlternationName] ifFalse: [ SBVariant named: 'format: to ''{1} to {2}''' diff --git a/packages/Sandblocks-Core/SBNamedBlock.class.st b/packages/Sandblocks-Core/SBNamedBlock.class.st index d86ca02d..0341c4fa 100644 --- a/packages/Sandblocks-Core/SBNamedBlock.class.st +++ b/packages/Sandblocks-Core/SBNamedBlock.class.st @@ -95,8 +95,8 @@ SBNamedBlock >> suggestedName [ String streamContents: [:aStream | aStream nextPutAll: ((self block statements collect: #suggestedAlternationName) fold: [:a :b | a, ' ', b])] - limitedTo: 20. - limitedString size < 20 ifTrue: [^ limitedString]. + limitedTo: 14. + limitedString size < 14 ifTrue: [^ limitedString]. ^ limitedString , '...' ] diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 4bee0880..22826748 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -113,15 +113,13 @@ SBTabView >> addButton [ ^ SBButton new icon: (SBIcon iconPlus - size: 7.0 sbScaled; + size: 10; color: (Color green)) do: [self addTab]; makeSmall; cornerStyle: #squared; vResizing: #spaceFill; - balloonText: 'Add'; - cellGap: -1.0 sbScaled; - layoutInset: (4.0 @ 4.0) sbScaled + balloonText: 'Add' ] { #category : #commands } @@ -395,6 +393,8 @@ SBTabView >> removeCurrentTab [ { #category : #tabs } SBTabView >> setActive: aNamedBlock [ + self containingArtefact ifNil: [^ self activeIndex: (self namedBlocks indexOf: aNamedBlock ifAbsent: 1)]. + self containingArtefact isMethod ifFalse: [self basicSetActive: aNamedBlock. ^ self]. self containingArtefact hasUnsavedChanges @@ -402,7 +402,7 @@ SBTabView >> setActive: aNamedBlock [ ifFalse: ["changing tabs is latest change" self basicSetActive: aNamedBlock. SBExploriants uniqueInstance ignoreUpdate: true. - self sandblockEditor save: self containingArtefact tryFixing: false quick: true.]. + self sandblockEditor save: self containingArtefact tryFixing: false quick: false.]. ] diff --git a/packages/Sandblocks-Morphs/SBButton.class.st b/packages/Sandblocks-Morphs/SBButton.class.st index fb411f14..fd959f20 100644 --- a/packages/Sandblocks-Morphs/SBButton.class.st +++ b/packages/Sandblocks-Morphs/SBButton.class.st @@ -15,7 +15,7 @@ SBButton class >> newApplyPermutationFor: aPermutation [ ^ self new icon: (SBIcon iconArrowDown - size: 10.0 sbScaled; + size: 10.0; color: (Color r: 0.0 g: 1 b: 0.0)) label: 'Apply' do: [aPermutation apply]; From 8469626cb81370cd9ba68944d20a68745c012263 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 2 Apr 2024 13:53:35 +0200 Subject: [PATCH 2/9] Move Selection UI elements to the button rows --- .../Sandblocks-Babylonian/Object.extension.st | 2 +- .../SBCorrelationView.class.st | 35 +++------ .../SBCustomView.class.st | 8 +- .../Sandblocks-Babylonian/SBExample.class.st | 77 ++++--------------- .../SBExampleValueDisplay.class.st | 7 +- .../SBExampleWatch.class.st | 51 +++++++----- .../SBInputBroadcaster.class.st | 1 + .../Sandblocks-Babylonian/SBLiveView.class.st | 2 +- .../SBResizableResultsView.class.st | 18 ++--- .../SBStMessageSend.extension.st | 10 +-- .../SBSwitchableResultsView.class.st | 2 +- packages/Sandblocks-Core/SBTabView.class.st | 1 + packages/Sandblocks-Morphs/SBButton.class.st | 4 +- .../Sandblocks-Utils/SBPermutation.class.st | 3 +- 14 files changed, 79 insertions(+), 142 deletions(-) diff --git a/packages/Sandblocks-Babylonian/Object.extension.st b/packages/Sandblocks-Babylonian/Object.extension.st index 52a49113..6fa8ddae 100644 --- a/packages/Sandblocks-Babylonian/Object.extension.st +++ b/packages/Sandblocks-Babylonian/Object.extension.st @@ -63,7 +63,7 @@ Object >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ "Objects can choose if they want to apply a changed extent" ^ (SBWatchValue newContainerMorphFor: aSBWatchValue) - addMorphBack: (SBIcon iconFor: aSBWatchValue watchedValueIdentityHash) asMorph; + "addMorphBack: (SBIcon iconFor: aSBWatchValue watchedValueIdentityHash) asMorph;" addMorphBack: self asMorph; yourself ] diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index 143658ca..6879ba54 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -13,10 +13,6 @@ Class { { #category : #building } SBCorrelationView >> buildAllPossibleResults [ - self multiverse activeExamples - ifEmpty: [gridContainer addMorph: (TextMorph new contents: 'No examples active'). - gridContainer width: gridContainer firstSubmorph width + 5 "a bit of margin"]. - groupedUniverses := self groupUniversesContainingAllVariantsIn: selectedVariants. basePermutations := self collectAllPermutationsOfSelectedVariants asOrderedCollection. @@ -61,17 +57,22 @@ SBCorrelationView >> buildGridsFor: anExample watching: aWatch [ ] { #category : #building } -SBCorrelationView >> buildSelectionRow [ +SBCorrelationView >> buildSelectionOptions [ | container selectedString | - container := self containerRow. + container := Morph new + color: Color transparent; + changeTableLayout; + vResizing: #shrinkWrap; + hResizing: #shrinkWrap; + listDirection: #leftToRight. self ensureVariantSelectionIn: container. selectedString := ''. selectedVariants ifEmpty: [ selectedString := selectedString, 'None' ] ifNotEmpty: [ selectedString := selectedString, ((selectedVariants collect: #name) fold: [:a :b | a, ', ', Character cr, b ])]. container addMorphBack: selectedString asMorph. - self block addMorph: container. + ^ container ] @@ -91,10 +92,10 @@ SBCorrelationView >> buildVariantSelection [ displayPrefixOnly ] -{ #category : #accessing } +{ #category : #'as yet unclassified' } SBCorrelationView >> buttons [ - - ^ {} + + ^ super buttons, {self buildSelectionOptions} ] { #category : #building } @@ -190,20 +191,6 @@ SBCorrelationView >> initialize [ ] -{ #category : #actions } -SBCorrelationView >> visualize [ - - self clean. - - self buildSelectionRow. - self block addMorph: dimensionOptions. - - self buildButtonRow. - - self buildAllPossibleResults . - self concludeContainerWidth. -] - { #category : #accessing } SBCorrelationView >> wantsReloadOnSaveWhenOpen [ diff --git a/packages/Sandblocks-Babylonian/SBCustomView.class.st b/packages/Sandblocks-Babylonian/SBCustomView.class.st index 86baef41..adc871ba 100644 --- a/packages/Sandblocks-Babylonian/SBCustomView.class.st +++ b/packages/Sandblocks-Babylonian/SBCustomView.class.st @@ -27,6 +27,12 @@ SBCustomView >> buildViewOptions [ when: #selectionChanged send: #switchView to: self ] +{ #category : #accessing } +SBCustomView >> buttons [ + + ^ {viewOptions}, super buttons +] + { #category : #initialization } SBCustomView >> initialize [ @@ -36,8 +42,6 @@ SBCustomView >> initialize [ self name: 'Results'. self buildButtonRow. - - self block addMorphBack: viewOptions. self block addMorphBack: self selectedView ] diff --git a/packages/Sandblocks-Babylonian/SBExample.class.st b/packages/Sandblocks-Babylonian/SBExample.class.st index f5e75205..b5ec7f49 100644 --- a/packages/Sandblocks-Babylonian/SBExample.class.st +++ b/packages/Sandblocks-Babylonian/SBExample.class.st @@ -320,12 +320,9 @@ SBExample >> lastError: anError [ anError ifNotNil: [ true ifTrue: [ - "ToolSet debugException: anError" ^ reportedError := self sandblockEditor reportError: anError - process: ((Process forContext: anError signal copyStack priority: Processor activeProcess priority) - shouldResumeFromDebugger: false; - yourself) + process: currentProcess source: self]. errorIndicator ifNil: [ @@ -396,18 +393,7 @@ SBExample >> run [ self scheduleLastError: nil. currentProcess := nil. processRunning := false. - 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. + Project current addDeferredUIMessage: [self sendFinishNotification]] forkAt: Processor userBackgroundPriority. ^ currentProcess ] @@ -429,13 +415,7 @@ SBExample >> runSetup [ errorDecorator ifNotNil: #detach. errorDecorator := nil. - traceSize := 0. - SBVariant - named: 'clear' - associations: {'with' -> [returnValue clear]. 'without' -> []} - activeIndex: 2 - id: '62643a5a-1d80-7f43-a32f-f23665e98f83' - isActive: false + traceSize := 0 ] { #category : #execution } @@ -460,39 +440,18 @@ SBExample >> scheduleLastError: anError [ { #category : #initialization } SBExample >> self: aBlock args: aCollectionBlock label: aString [ - 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 + 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 ] { #category : #initialization } @@ -558,12 +517,6 @@ SBExample >> stopRunning [ self stopSteppingSelector: #run. active := false. - 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]] diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 279ea71e..1bdc5fb2 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -136,12 +136,7 @@ SBExampleValueDisplay >> reportValues: aCollectionOfWatchValues name: aString si display reportValues: aCollectionOfWatchValues sized: aSBMorphResizer. label contents: aString. - label visible: (SBVariant - named: 'visible:' - associations: {'with' -> [aString notEmpty]. 'without' -> [false]} - activeIndex: 2 - id: '15acb8c3-94a2-9348-8d02-0c6fa11e9f7c' - isActive: false). + label visible: false. hadValue := true ] diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index e74639a8..a0b1f3b4 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -325,20 +325,37 @@ SBExampleWatch >> identifier: aSymbol [ ] { #category : #initialization } -SBExampleWatch >> initialize [ | options | -(super initialize). -(options := (SBMorphResizer standardOptions)). - -(exampleToDisplay := (IdentityDictionary new)). -(exampleToValues := (IdentityDictionary new)). -(watchedExpression := (SBStMessageSend new)). -(dimensionOptions := ((SBComboBox new) prefix: 'Preview size: '; labels: (options collect: #'label'); values: options; object: (options third); when: #'selectionChanged' send: #'applyResizerOnValues' to: self)). -(modifyExpression := (SBStBlockBody identityNamed: 'each')). - -(SBVariant named: 'remove modify' associations: {'with' -> [(self changeTableLayout; cellGap: 4; layoutInset: 2; vResizing: #'shrinkWrap'; hResizing: #'shrinkWrap'; addAllMorphsBack: {watchedExpression. ((SBRow new) hResizing: #'spaceFill'; listCentering: #'bottomRight'; addMorphBack: dimensionOptions; yourself). modifyExpression}; yourself). -].'w/o' -> [(self changeTableLayout; cellGap: 4; layoutInset: 2; vResizing: #'shrinkWrap'; hResizing: #'shrinkWrap'; addAllMorphsBack: {watchedExpression. ((SBRow new) hResizing: #'spaceFill'; listCentering: #'bottomRight'; addMorphBack: dimensionOptions; yourself)}; yourself). -]} activeIndex: 2 id: 'f771db53-c26a-2c40-a3f6-5c31ec7aeb44' isActive: false). +SBExampleWatch >> initialize [ + | options | + super initialize. + options := SBMorphResizer standardOptions. + + exampleToDisplay := IdentityDictionary new. + exampleToValues := IdentityDictionary new. + watchedExpression := SBStMessageSend new. + dimensionOptions := SBComboBox new + prefix: 'Preview size: '; + labels: (options collect: #label); + values: options; + object: options third; + when: #selectionChanged send: #applyResizerOnValues to: self. + modifyExpression := SBStBlockBody identityNamed: 'each'. + + self + changeTableLayout; + cellGap: 4; + layoutInset: 2; + vResizing: #shrinkWrap; + hResizing: #shrinkWrap; + addAllMorphsBack: { + watchedExpression. + SBRow new + hResizing: #spaceFill; + listCentering: #bottomRight; + addMorphBack: dimensionOptions; + yourself}; + yourself ] { #category : #initialization } @@ -415,13 +432,7 @@ SBExampleWatch >> modifyExpression [ SBExampleWatch >> modifyExpression: aBlock [ modifyExpression ifNotNil: #delete. - modifyExpression := aBlock. - SBVariant - named: 'addMorphBack:' - associations: {'with' -> [self addMorphBack: modifyExpression]. 'without' -> []} - activeIndex: 2 - id: 'c3b856eb-2899-cd44-b45c-3b099b02aad6' - isActive: false + modifyExpression := aBlock ] { #category : #accessing } diff --git a/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st index bc3f3c5a..da5890e2 100644 --- a/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st +++ b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st @@ -53,6 +53,7 @@ SBInputBroadcaster >> eventProcessMouse: aMouse goingTo: aPosition in: aMorph [ { #category : #events } SBInputBroadcaster >> filterEvent: anEvent for: aMorph [ + self listeners withIndexDo: [:aListener :i | | localTarget newEvent delta | localTarget := self translatedPositionOf: anEvent from: aMorph to: aListener. diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index 111fd12e..c0b5ddbb 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -39,7 +39,7 @@ SBLiveView >> buildPreviewFor: aPermutation [ addAllMorphsBack: { self containerRow listDirection: #topToBottom; addAllMorphsBack: { - SBPermutationLabel newDisplaying: aPermutation. + (SBPermutationLabel newDisplaying: aPermutation) wrapFlag: false. self newPermutationButtonRowFor: aPermutation showing: preview. preview}}). ] diff --git a/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st b/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st index 33d1f55a..51337ef7 100644 --- a/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBResizableResultsView.class.st @@ -28,6 +28,12 @@ SBResizableResultsView >> buildDimensionOptions [ when: #selectionChanged send: #applyResizer to: self ] +{ #category : #accessing } +SBResizableResultsView >> buttons [ + + ^ {dimensionOptions} +] + { #category : #initialization } SBResizableResultsView >> initialize [ @@ -41,15 +47,3 @@ SBResizableResultsView >> selectedResizer [ ^ dimensionOptions object ] - -{ #category : #'as yet unclassified' } -SBResizableResultsView >> visualize [ - - self clean. - - self block addMorph: dimensionOptions. - self buildButtonRow. - - self buildAllPossibleResults . - self concludeContainerWidth. -] diff --git a/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st b/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st index 2beeeb0b..0a7e0b7a 100644 --- a/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st +++ b/packages/Sandblocks-Babylonian/SBStMessageSend.extension.st @@ -5,13 +5,5 @@ SBStMessageSend >> suggestedAlternationName [ ^ self isAssignment ifTrue: [self receiver suggestedAlternationName] - ifFalse: [ - SBVariant - named: 'format: to ''{1} to {2}''' - associations: { - 'with sender' -> ['{1} to {2}' format: {self selector. self receiver suggestedAlternationName}]. - 'w/o sender' -> ['{1}' format: {self selector}]} - activeIndex: 2 - id: '1949332c-4768-ff4a-98ba-0356e4a3f2fa' - isActive: false] + ifFalse: ['{1}' format: {self selector}] ] diff --git a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st index f1482132..a186cf87 100644 --- a/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBSwitchableResultsView.class.st @@ -13,7 +13,7 @@ Class { { #category : #accessing } SBSwitchableResultsView >> buttons [ - ^ {self toggleViewButton} + ^ super buttons, {self toggleViewButton} ] { #category : #accessing } diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 22826748..5372d65c 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -117,6 +117,7 @@ SBTabView >> addButton [ color: (Color green)) do: [self addTab]; makeSmall; + cellPositioning: #center; cornerStyle: #squared; vResizing: #spaceFill; balloonText: 'Add' diff --git a/packages/Sandblocks-Morphs/SBButton.class.st b/packages/Sandblocks-Morphs/SBButton.class.st index fd959f20..e484cb83 100644 --- a/packages/Sandblocks-Morphs/SBButton.class.st +++ b/packages/Sandblocks-Morphs/SBButton.class.st @@ -14,9 +14,7 @@ Class { SBButton class >> newApplyPermutationFor: aPermutation [ ^ self new - icon: (SBIcon iconArrowDown - size: 10.0; - color: (Color r: 0.0 g: 1 b: 0.0)) + icon: (SBIcon iconArrowDown size: 8.0 sbScaled) label: 'Apply' do: [aPermutation apply]; makeSmall; diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 64cb68df..8f26fb6a 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -65,7 +65,8 @@ SBPermutation >> asString [ "collecting instead of calling (a active name), ', ', (b active name) in fold as one variant only will not return a string but a variant" ^ (self referencedVariants collect: [:aVariant | - aVariant name, ': ', (aVariant blockAt: (self at: aVariant id)) nameToDisplay ]) + ((aVariant name endsWith: ':') ifTrue: [aVariant name, ' '] ifFalse: [aVariant name, ': ']), + (aVariant blockAt: (self at: aVariant id)) nameToDisplay ]) fold: [:a :b | a, ', ', Character cr, b ] From 72ed5e85cdcc305af4bfcbeebeecc98b632fb5c3 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 2 Apr 2024 17:12:11 +0200 Subject: [PATCH 3/9] Empty From 9c4549d2d5b89811be1326fa622c9467d1fe14eb Mon Sep 17 00:00:00 2001 From: Tom Beckmann Date: Wed, 3 Apr 2024 14:11:03 +0200 Subject: [PATCH 4/9] include code changes in history view --- .../SBExploriants.class.st | 24 ++++++++++++++- .../SBHistoryView.class.st | 30 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 34e0a475..4a9607f0 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -120,7 +120,7 @@ SBExploriants >> evaluationReceiver [ { #category : #accessing } SBExploriants >> ignoreUpdate [ - ^ ignoreUpdate + ^ ignoreUpdate ifNil: [false] ] { #category : #accessing } @@ -143,18 +143,40 @@ SBExploriants >> initialize [ vResizing: #shrinkWrap ] +{ #category : #initialization } +SBExploriants >> intoWorld: aWorld [ + + super intoWorld: aWorld. + SystemChangeNotifier uniqueInstance + noMoreNotificationsFor: self; + notify: self ofSystemChangesOfItem: #method using: #methodChanged: +] + { #category : #testing } SBExploriants >> isArtefact [ ^ true ] +{ #category : #initialization } +SBExploriants >> methodChanged: anEvent [ + + anEvent isModified ifTrue: [namedBlocks last addCodeSnapshot: anEvent] +] + { #category : #accessing } SBExploriants >> objectToPermutation [ ^ objectToPermutation ] +{ #category : #initialization } +SBExploriants >> outOfWorld: aWorld [ + + SystemChangeNotifier uniqueInstance noMoreNotificationsFor: self. + super outOfWorld: aWorld +] + { #category : #'artefact protocol' } SBExploriants >> saveTryFixing: aFixBoolean quick: aQuickBoolean [ diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st index 3bc0216b..67d8a8b6 100644 --- a/packages/Sandblocks-Babylonian/SBHistoryView.class.st +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -4,6 +4,14 @@ Class { #category : #'Sandblocks-Babylonian' } +{ #category : #building } +SBHistoryView >> addCodeSnapshot: aChange [ + + self submorphs size - 1 "buttonRow" > self maxEpoches ifTrue: [self lastSubmorph delete]. + + self block addMorph: (self buildCodeSnapshot: aChange) atIndex: 2 +] + { #category : #building } SBHistoryView >> addEpoche [ @@ -12,6 +20,28 @@ SBHistoryView >> addEpoche [ self block addMorph: self buildEpoche atIndex: 2 ] +{ #category : #building } +SBHistoryView >> buildCodeSnapshot: aChange [ + + | row lastVersion | + row := self containerRow. + + lastVersion := (VersionsBrowser new + scanVersionsOf: aChange item class: aChange item methodClass meta: false + category: aChange item methodReference category selector: aChange item selector) changeList at: 2 ifAbsent: [nil]. + + ^ row + cellGap: 0@10; + listDirection: #topToBottom; + addAllMorphsBack: { + self buildMetaUsageIn: row. + (lastVersion ifNotNil: [ + (TextDiffBuilder buildDisplayPatchFrom: lastVersion text to: aChange item getSource inClass: aChange item methodClass prettyDiffs: false)] ifNil: [aChange item getSource]) asMorph + } + + +] + { #category : #building } SBHistoryView >> buildEpoche [ From 64e961a7f8d6b8b5ea3980d11ae954b2229e6e57 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 8 Apr 2024 15:56:20 +0200 Subject: [PATCH 5/9] All that was shown in the demo --- .../Sandblocks-Babylonian/SBCluster.class.st | 4 +- .../SBCorrelationView.class.st | 20 ++---- .../SBCustomView.class.st | 2 +- .../SBExampleValueDisplay.class.st | 2 +- .../SBExampleWatch.class.st | 31 +++++++-- .../SBExploriants.class.st | 16 +++-- .../SBExploriantsView.class.st | 10 ++- .../SBHistoryView.class.st | 65 +++++++++++++++++-- .../SBInactiveExampleWatch.class.st | 23 ++++++- .../SBInactiveExampleWatch.extension.st | 8 ++- .../Sandblocks-Babylonian/SBLiveView.class.st | 63 +++++++----------- .../SBMultiverse.class.st | 4 ++ .../SBPermutationLabel.class.st | 6 -- .../SBPlainResultsView.class.st | 2 +- packages/Sandblocks-Core/SBEditor.class.st | 5 ++ packages/Sandblocks-Core/SBTabView.class.st | 7 ++ .../SBTextInputMapping.class.st | 3 +- .../Sandblocks-Smalltalk/SBStASTNode.class.st | 12 +--- .../SBStGrammarHandler.class.st | 1 - .../Sandblocks-Smalltalk/SBVariant.class.st | 7 ++ .../Sandblocks-Utils/SBPermutation.class.st | 6 +- .../Sandblocks-Watch/SBMorphResizer.class.st | 10 +-- 22 files changed, 200 insertions(+), 107 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index a24004b4..9e7505a2 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -43,7 +43,7 @@ SBCluster >> initialize [ listDirection: #topToBottom; vResizing: #shrinkWrap; hResizing: #shrinkWrap; - cellInset: 0@10 + cellInset: 0@2 ] { #category : #accessing } @@ -145,7 +145,7 @@ SBCluster >> visualize [ self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" self newContainerMorph listDirection: #leftToRight; - cellInset: 5@(-10); + cellInset: 5@(-30); addAllMorphsBack: { self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph" SBGrid newDisplaying: diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index 6879ba54..b0862722 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -30,10 +30,11 @@ SBCorrelationView >> buildForExample: anExample watching: aWatch [ addAllMorphsBack: { SBOwnTextMorph new contents: ( '{1}{2}' format: {"anExample label" ''. - (aWatch cleanedExpression sourceString)}). + (aWatch cleanedExpression sourceString withoutLineEndings)}). self containerRow listDirection: #topToBottom; cellPositioning: #rightCenter; + cellInset: 0@10; addAllMorphsBack: ((self buildGridsFor: anExample watching: aWatch) flatten)}}) ] @@ -71,7 +72,7 @@ SBCorrelationView >> buildSelectionOptions [ selectedVariants ifEmpty: [ selectedString := selectedString, 'None' ] ifNotEmpty: [ selectedString := selectedString, ((selectedVariants collect: #name) fold: [:a :b | a, ', ', Character cr, b ])]. - container addMorphBack: selectedString asMorph. + container addMorphBack: selectedString withoutLineEndings asMorph. ^ container ] @@ -121,19 +122,6 @@ SBCorrelationView >> collectAllPermutationsOfSelectedVariants [ ^ allPermutations ] -{ #category : #building } -SBCorrelationView >> ensureVariantSelection [ - - self multiverse variants ifEmpty: [selectedVariants := OrderedCollection new. ^ self]. - variantSelection := self buildVariantSelection. - self block addMorph: variantSelection. - - selectedVariants - ifNil: [selectedVariants := {variantSelection object} asOrderedCollection] - ifNotNil: [selectedVariants := selectedVariants select: [:aVariant | self multiverse variants includes: aVariant]]. - -] - { #category : #building } SBCorrelationView >> ensureVariantSelectionIn: aMorph [ @@ -142,7 +130,7 @@ SBCorrelationView >> ensureVariantSelectionIn: aMorph [ aMorph addMorph: variantSelection. selectedVariants - ifNil: [selectedVariants := {variantSelection object} asOrderedCollection] + ifNil: [selectedVariants := {} asOrderedCollection] ifNotNil: [selectedVariants := selectedVariants select: [:aVariant | self multiverse variants includes: aVariant]]. ] diff --git a/packages/Sandblocks-Babylonian/SBCustomView.class.st b/packages/Sandblocks-Babylonian/SBCustomView.class.st index adc871ba..c88ed7f2 100644 --- a/packages/Sandblocks-Babylonian/SBCustomView.class.st +++ b/packages/Sandblocks-Babylonian/SBCustomView.class.st @@ -23,7 +23,7 @@ SBCustomView >> buildViewOptions [ prefix: 'Current Grid View: '; labels: (options collect: #name); values: options ; - object: options first; + object: options third; when: #selectionChanged send: #switchView to: self ] diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index 1bdc5fb2..f1633313 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -79,7 +79,7 @@ SBExampleValueDisplay >> initialize [ cellGap: 2; layoutInset: 2@3; addAllMorphsBack: { - label := SBStringMorph new. + label := SBStringMorph new visible: false. statusLabel := SBStringMorph new contents: ''. self newChangeVizButton}; yourself); diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index a0b1f3b4..63378fbb 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -10,7 +10,8 @@ Class { 'dimensionOptions', 'modifyExpression', 'exampleToDisplay', - 'exampleToValues' + 'exampleToValues', + 'ignoreReports' ], #classVars : [ 'Registry' @@ -79,9 +80,9 @@ SBExampleWatch class >> report: aValue for: aSymbol modifying: aBlock [ | watchers example | example := SBExecutionEnvironment value ifNil: [^ aValue]. - watchers := self registry select: [:watcher | watcher notNil and: [watcher identifier = aSymbol] + and: [watcher ignoreReports not] and: [watcher isActive]]. watchers do: [:watcher | watcher reportValue: aValue asSBWatchValue for: example]. @@ -130,7 +131,8 @@ SBExampleWatch >> asInactiveCopy [ originalIdentifier: self identifier; expression: (SBTextBubble new contents: self cleanedExpression sourceString); modifyExpression: self modifyExpression veryDeepCopy; - dimensionOptions: self dimensionOptions veryDeepCopy. + dimensionOptions: self dimensionOptions veryDeepCopy; + createdWithPermutation: SBActiveVariantPermutation value. exampleToValues keys do: [:anExample | copy exampleStarting: anExample; @@ -141,8 +143,7 @@ SBExampleWatch >> asInactiveCopy [ (copy exampleToDisplay at: anExample) display selectedDisplayIndex: (exampleToDisplay at: anExample) display selectedDisplayIndex]. - exampleToValues keys do: [:anExample | copy exampleFinished: anExample]. - + exampleToValues keys do: [:anExample | copy exampleFinished: anExample]. ^ copy saveObjectsActivePermutations; @@ -247,6 +248,7 @@ SBExampleWatch >> exampleFinished: anExample [ SBExampleWatch >> exampleStarting: anExample [ exampleToValues at: anExample put: OrderedCollection new. + self ignoreReports: false. (exampleToDisplay at: anExample ifAbsentPut: [self buildDefaultDisplayFor: anExample]) exampleStarting: anExample; @@ -324,6 +326,18 @@ SBExampleWatch >> identifier: aSymbol [ self world ifNotNil: [self class registerWatch: self] ] +{ #category : #accessing } +SBExampleWatch >> ignoreReports [ + + ^ ignoreReports +] + +{ #category : #accessing } +SBExampleWatch >> ignoreReports: aBoolean [ + + ignoreReports := aBoolean +] + { #category : #initialization } SBExampleWatch >> initialize [ @@ -334,6 +348,7 @@ SBExampleWatch >> initialize [ exampleToDisplay := IdentityDictionary new. exampleToValues := IdentityDictionary new. watchedExpression := SBStMessageSend new. + ignoreReports := false. dimensionOptions := SBComboBox new prefix: 'Preview size: '; labels: (options collect: #label); @@ -449,6 +464,12 @@ SBExampleWatch >> outOfWorld: aWorld [ self class unregisterWatch: self ] +{ #category : #'as yet unclassified' } +SBExampleWatch >> preventOcclusion [ + + ^ false +] + { #category : #printing } SBExampleWatch >> printOn: aStream [ diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 4a9607f0..1597397c 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -120,7 +120,7 @@ SBExploriants >> evaluationReceiver [ { #category : #accessing } SBExploriants >> ignoreUpdate [ - ^ ignoreUpdate ifNil: [false] + ^ ignoreUpdate ] { #category : #accessing } @@ -136,6 +136,8 @@ SBExploriants >> initialize [ objectToPermutation := WeakKeyDictionary new. updateProcessRunning := false. + ignoreUpdate := false. + namedBlocks := {SBExploriantsView new} asOrderedCollection. self attachDecorator: SBMoveDecorator new; @@ -161,7 +163,10 @@ SBExploriants >> isArtefact [ { #category : #initialization } SBExploriants >> methodChanged: anEvent [ - anEvent isModified ifTrue: [namedBlocks last addCodeSnapshot: anEvent] + anEvent isModified + ifTrue: [ + namedBlocks detect: #isHistory + ifFound: [:history | history addCodeSnapshot: anEvent]] ] { #category : #accessing } @@ -227,7 +232,7 @@ SBExploriants >> updateInBackgroundOnTimeoutRevertTo: theOldMultiverse [ newMultiverse := SBMultiverse bigbangInEditorWithoutKaboom: self sandblockEditor. self namedBlocks do: [:aTab | aTab multiverse: newMultiverse]. [newMultiverse kaboom] - valueWithin: 7 seconds + valueWithin: 20 seconds onTimeout: [newMultiverse cleanUp. self namedBlocks do: [:aTab | aTab multiverse: theOldMultiverse]]. updateProcess := nil. updateProcessRunning := false. @@ -236,9 +241,10 @@ SBExploriants >> updateInBackgroundOnTimeoutRevertTo: theOldMultiverse [ { #category : #actions } SBExploriants >> visualize [ - - | tabs | + + |tabs| self width: 0. + ignoreUpdate := false. "tabs will visualize as soon as multiverse is finished" tabs := SBExploriantsView getTabsInMultiverse: (SBMultiverse bigbangInEditor: self sandblockEditor). diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 403ae16c..39160a95 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -86,13 +86,19 @@ SBExploriantsView >> initialize [ changeTableLayout; color: Color white; listDirection: #topToBottom; - layoutInset: 3; - cellGap: 4; + layoutInset: 1; + cellGap: 2; cellInset: 2; hResizing: #shrinkWrap; vResizing: #shrinkWrap). ] +{ #category : #accessing } +SBExploriantsView >> isHistory [ + + ^ false +] + { #category : #accessing } SBExploriantsView >> isOverview [ diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st index 67d8a8b6..deb2eaa6 100644 --- a/packages/Sandblocks-Babylonian/SBHistoryView.class.st +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -1,23 +1,26 @@ Class { #name : #SBHistoryView, #superclass : #SBExploriantsView, + #instVars : [ + 'scrollPane' + ], #category : #'Sandblocks-Babylonian' } { #category : #building } SBHistoryView >> addCodeSnapshot: aChange [ - self submorphs size - 1 "buttonRow" > self maxEpoches ifTrue: [self lastSubmorph delete]. + self ensureStackSize. - self block addMorph: (self buildCodeSnapshot: aChange) atIndex: 2 + self scroller addMorphFront: (self buildCodeSnapshot: aChange) ] { #category : #building } SBHistoryView >> addEpoche [ - self submorphs size - 1 "buttonRow" > self maxEpoches ifTrue: [self lastSubmorph delete]. + self ensureStackSize. - self block addMorph: self buildEpoche atIndex: 2 + self scroller addMorphFront: self buildEpoche ] { #category : #building } @@ -67,6 +70,28 @@ SBHistoryView >> buildMetaUsageIn: aRow [ ] +{ #category : #building } +SBHistoryView >> buildScrollPane [ + + | scrollPane | + scrollPane := ScrollPane new + color: Color transparent; + borderWidth: 0; + hResizing: #spaceFill; + scrollBarThickness: 7 sbScaled; + showHScrollBarOnlyWhenNeeded; + showVScrollBarOnlyWhenNeeded; + height: 600 sbScaled. + scrollPane scroller + changeTableLayout; + listDirection: #topToBottom; + cellPositioning: #topLeft; + layoutInset: 1; + cellGap: 2; + cellInset: 2. + ^ scrollPane +] + { #category : #building } SBHistoryView >> buildSnapshotTabView [ @@ -93,13 +118,19 @@ SBHistoryView >> changeTabsButton [ cornerStyle: #squared ] +{ #category : #actions } +SBHistoryView >> clean [ + + self scroller submorphs copy do: #delete +] + { #category : #building } SBHistoryView >> clearButton [ ^ SBButton new icon: SBIcon iconClockO label: 'Clear History' - do: [self clean. self block addMorphBack: self buildButtonRow]; + do: [self clean]; cornerStyle: #squared ] @@ -116,6 +147,12 @@ SBHistoryView >> deleteEpocheButton: theRow [ ] +{ #category : #building } +SBHistoryView >> ensureStackSize [ + + self scroller submorphs size > self maxEpoches ifTrue: [self scroller lastSubmorph delete]. +] + { #category : #initialization } SBHistoryView >> initialize [ @@ -123,6 +160,14 @@ SBHistoryView >> initialize [ self name: 'History'. self buildButtonRow. + scrollPane := self buildScrollPane. + self block addMorphBack: scrollPane. +] + +{ #category : #accessing } +SBHistoryView >> isHistory [ + + ^ true ] { #category : #accessing } @@ -139,7 +184,7 @@ SBHistoryView >> offerChangeTabMenu [ index := UIManager default chooseFrom: options. index = 0 ifTrue: [^ self]. - self block submorphs allButFirst do: [:anEpoche | anEpoche lastSubmorph activeIndex: index]. + self scroller submorphs do: [:anEpoche | anEpoche lastSubmorph activeIndex: index]. ] { #category : #building } @@ -148,10 +193,16 @@ SBHistoryView >> saveButton [ ^ SBButton new icon: SBIcon iconSave label: 'Save As PNG' - do: [self block exportAsPNG]; + do: [self scroller exportAsPNG]; cornerStyle: #squared ] +{ #category : #accessing } +SBHistoryView >> scroller [ + + ^ scrollPane scroller +] + { #category : #accessing } SBHistoryView >> tabsToSnapshot [ diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st index 8199e643..8469b814 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st @@ -5,7 +5,8 @@ Class { #name : #SBInactiveExampleWatch, #superclass : #SBExampleWatch, #instVars : [ - 'originalIdentifier' + 'originalIdentifier', + 'createdWithPermutation' ], #category : #'Sandblocks-Babylonian' } @@ -31,6 +32,18 @@ SBInactiveExampleWatch >> artefactSaved: aBlock [ ifTrue: [self applyModifyExpressionOnValues. self saveObjectsActivePermutations.] ] +{ #category : #accessing } +SBInactiveExampleWatch >> createdWithPermutation [ + + ^ createdWithPermutation +] + +{ #category : #accessing } +SBInactiveExampleWatch >> createdWithPermutation: aPermutation [ + + createdWithPermutation := aPermutation +] + { #category : #'event handling' } SBInactiveExampleWatch >> doubleClick: evt [ @@ -72,10 +85,16 @@ SBInactiveExampleWatch >> originalIdentifier: aNumber [ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" + "exampleToValues associationsDo: [:anExampleValuesPair | + anExampleValuesPair value do: [:aWatchValue | + aWatchValue watchedValue allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation + at: aSubMorph + put: SBActiveVariantPermutation value]]]." exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | SBExploriants objectToPermutation at: aSubMorph - put: SBActiveVariantPermutation value]]]. + put: self createdWithPermutation]]]. ] diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st index 0b86b4f6..539f93ed 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st @@ -10,10 +10,16 @@ SBInactiveExampleWatch >> listensToExamples [ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" + "exampleToValues associationsDo: [:anExampleValuesPair | + anExampleValuesPair value do: [:aWatchValue | + aWatchValue watchedValue allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation + at: aSubMorph + put: SBActiveVariantPermutation value]]]." exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | SBExploriants objectToPermutation at: aSubMorph - put: SBActiveVariantPermutation value]]]. + put: self createdWithPermutation]]]. ] diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index c0b5ddbb..69265b13 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -14,7 +14,8 @@ Class { { #category : #building } SBLiveView >> buildAllPossibleResults [ - self multiverse universes do: [:aUniverse | self buildPreviewFor: aUniverse activePermutation] + self multiverse watches ifEmpty: [^ self]. + self multiverse universes do: [:aUniverse | self buildPreviewFor: aUniverse] ] { #category : #building } @@ -31,37 +32,19 @@ SBLiveView >> buildBrodcaster [ ] { #category : #building } -SBLiveView >> buildPreviewFor: aPermutation [ +SBLiveView >> buildPreviewFor: aUniverse [ | preview | - preview := self newRegisteredListenerFor: aPermutation. + preview := self newRegisteredListenerFor: aUniverse. gridContainer addMorphBack: (self containerRow cellPositioning: #center; addAllMorphsBack: { self containerRow listDirection: #topToBottom; addAllMorphsBack: { - (SBPermutationLabel newDisplaying: aPermutation) wrapFlag: false. - self newPermutationButtonRowFor: aPermutation showing: preview. + (SBPermutationLabel newDisplaying: aUniverse activePermutation) wrapFlag: false. + self newPermutationButtonRowFor: aUniverse showing: preview. preview}}). ] -{ #category : #building } -SBLiveView >> buildSetUpRow [ - - self block addMorphBack: (SBRow new - changeTableLayout; - hResizing: #spaceFill; - wrapCentering: #center; - listCentering: #center; - cellPositioning: #center; - name: #setup; - cellGap: 8 * self scalingFactor; - addMorphBack: (SBIcon iconSpinner - balloonText: 'Toggle stepping'; - on: #click send: #toggleStepping to: self); - addMorphBack: (SBStringMorph new contents: 'Setup:'); - addMorphBack: ([Morph new] asSandblock width: 200)) -] - { #category : #building } SBLiveView >> buttons [ @@ -94,7 +77,6 @@ SBLiveView >> initialize [ super initialize. self name: 'Playground'. - self buildSetUpRow. ] @@ -116,26 +98,29 @@ SBLiveView >> listeners [ ] { #category : #building } -SBLiveView >> newPermutationButtonRowFor: aPermutation showing: aPreview [ +SBLiveView >> newPermutationButtonRowFor: aUniverse showing: aPreview [ ^ self containerRow layoutInset: 0; cellInset: 0; addAllMorphsBack: { - SBButton newApplyPermutationFor: aPermutation. - self rebuildButtonIn: aPreview applying: aPermutation. + SBButton newApplyPermutationFor: aUniverse activePermutation. + self rebuildButtonIn: aPreview applying: aUniverse. self synchronizeButtonIn: aPreview} ] { #category : #initialization } -SBLiveView >> newRegisteredListenerFor: aPermutation [ +SBLiveView >> newRegisteredListenerFor: aUniverse [ - | listener container | - listener := self evaluateSetUp. + | listener value container watch | + self flag: #todo. "for multiple watch values" + watch := aUniverse watches first. + value := watch exampleToValues values first first watchedValue. + listener := value veryDeepCopy asMorph. container := broadcaster addListener: listener. listener allMorphsDo: [:aSubMorph | - SBExploriants objectToPermutation at: aSubMorph put: aPermutation]. + SBExploriants objectToPermutation at: aSubMorph put: watch createdWithPermutation]. ^ container @@ -166,20 +151,20 @@ SBLiveView >> rebuildButton [ ] { #category : #building } -SBLiveView >> rebuildButtonIn: aContainer applying: aPermutation [ +SBLiveView >> rebuildButtonIn: aContainer applying: aUniverse [ ^ SBButton new icon: (SBIcon iconRotateRight size: 8.0 sbScaled) label: 'Re-Build This' - do: [self rebuildRegisteredListenerFor: aPermutation in: aContainer]; + do: [self rebuildRegisteredListenerFor: aUniverse in: aContainer]; makeSmall; cornerStyle: #squared ] { #category : #initialization } -SBLiveView >> rebuildRegisteredListenerFor: aPermutation in: aContainer [ +SBLiveView >> rebuildRegisteredListenerFor: aUniverse in: aContainer [ - self privateRegisterListener: self evaluateSetUp for: aPermutation in: aContainer + self privateRegisterListener: (aUniverse watches first exampleToValues values first first watchedValue veryDeepCopy) for: aUniverse activePermutation in: aContainer ] @@ -224,7 +209,6 @@ SBLiveView >> snapshot [ ^ self containerRow listDirection: #topToBottom; addAllMorphsBack: { - ImageMorph new newForm: (self block submorphNamed: 'setup') imageForm. ImageMorph new newForm: gridContainer imageForm} ] @@ -262,13 +246,14 @@ SBLiveView >> toggleStepping [ { #category : #actions } SBLiveView >> visualize [ - self clean. + ^ self. + "self clean. self buildBrodcaster. self buildButtonRow. self block addMorphBack: gridContainer. self buildAllPossibleResults. - broadcaster extent: self listeners last extent. - self concludeContainerWidth. + self listeners ifNotEmpty: [broadcaster extent: self listeners last extent. ]. + self concludeContainerWidth. " ] diff --git a/packages/Sandblocks-Babylonian/SBMultiverse.class.st b/packages/Sandblocks-Babylonian/SBMultiverse.class.st index 8eff50fa..fbd8ca28 100644 --- a/packages/Sandblocks-Babylonian/SBMultiverse.class.st +++ b/packages/Sandblocks-Babylonian/SBMultiverse.class.st @@ -118,6 +118,8 @@ SBMultiverse >> cleanUp [ watches do: #resumeGraphicalUpdates. (watches select: [:anOpenWatch | anOpenWatch containingArtefact isNil]) copy do: #delete. watches select: #isInEditor thenDo: [:aWatch | aWatch exampleToDisplay values do: #updateDisplay]. + allMethodBlocksContainingWatches do: [:aMethodBlock | + (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: true]]. ] { #category : #collecting } @@ -162,6 +164,8 @@ SBMultiverse >> gatherElements [ watches := (allMethodBlocksContainingWatches collect: [:aMethodBlock | | copies | copies := aMethodBlock containedExampleWatches. + "Because the watches share the id, values would be reported to original too. Stop that" + (aMethodBlock valueOfProperty: #originals) do: [:aWatch| aWatch ignoreReports: true]. (aMethodBlock valueOfProperty: #originals) withIndexDo: [:original :i | (copies at: i) copySelectedDisplayIndicesFrom: original]. copies ]) flatten. watches do: [:aWatch | activeExamples do: [:anExample | aWatch exampleStarting: anExample]]. diff --git a/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st b/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st index 9db3090e..cf86ad65 100644 --- a/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st +++ b/packages/Sandblocks-Babylonian/SBPermutationLabel.class.st @@ -22,12 +22,6 @@ SBPermutationLabel >> applyResize: aPoint [ ^ self extent: aPoint ] -{ #category : #'event handling' } -SBPermutationLabel >> click: evt [ - - self permutation apply -] - { #category : #initialization } SBPermutationLabel >> initialize [ diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index a530636f..614ac664 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -13,7 +13,7 @@ SBPlainResultsView >> buildAllPossibleResults [ { #category : #building } SBPlainResultsView >> buildPermutationFor: aSBUniverse [ - self block addAllMorphsBack: {SBPermutationLabel newDisplaying: aSBUniverse activePermutation. + self block addAllMorphsBack: {(SBPermutationLabel newDisplaying: aSBUniverse activePermutation) wrapFlag: false. SBButton newApplyPermutationFor: aSBUniverse activePermutation. (self containerRow listDirection: #leftToRight) addAllMorphsBack: aSBUniverse watches. diff --git a/packages/Sandblocks-Core/SBEditor.class.st b/packages/Sandblocks-Core/SBEditor.class.st index c74bd492..560a69eb 100644 --- a/packages/Sandblocks-Core/SBEditor.class.st +++ b/packages/Sandblocks-Core/SBEditor.class.st @@ -294,6 +294,11 @@ SBEditor >> buildCommandBar [ shortcut: (self class anyShortcutForAction: #openRepl) do: [self openRepl]; balloonText: 'Add artifact...'); + addMorphBack: (SBButton new + icon: SBIcon iconObjectGroup + shortcut: (self class anyShortcutForAction: #openExploriants) + do: [self openExploriants]; + balloonText: 'Open Exploriants'); addMorphBack: (Morph new height: 0; color: Color transparent; diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 5372d65c..3b09f847 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -320,6 +320,13 @@ SBTabView >> jumpToTab: anIndex [ ] +{ #category : #tabs } +SBTabView >> jumpToTabWithoutSaving: anIndex [ + + self namedBlocks at: anIndex ifPresent: [:block | self basicSetActive: block] + +] + { #category : #'shortcut-utility' } SBTabView >> jumpToThirdTab [ diff --git a/packages/Sandblocks-Core/SBTextInputMapping.class.st b/packages/Sandblocks-Core/SBTextInputMapping.class.st index 663330aa..39089d5a 100644 --- a/packages/Sandblocks-Core/SBTextInputMapping.class.st +++ b/packages/Sandblocks-Core/SBTextInputMapping.class.st @@ -97,7 +97,8 @@ SBTextInputMapping >> registerDefaultShortcuts [ registerShortcut: $f command do: #startSearch; registerShortcut: $g command do: #nextSearchResult; registerShortcut: $t command do: #promptAddArtifact; - registerShortcut: $J command do: #activateForces. + registerShortcut: $J command do: #activateForces; + registerShortcut: $e command do: #openExploriants. " navigation " self diff --git a/packages/Sandblocks-Smalltalk/SBStASTNode.class.st b/packages/Sandblocks-Smalltalk/SBStASTNode.class.st index 54ab6963..50a73b3d 100644 --- a/packages/Sandblocks-Smalltalk/SBStASTNode.class.st +++ b/packages/Sandblocks-Smalltalk/SBStASTNode.class.st @@ -166,17 +166,7 @@ SBStASTNode >> guessClassExpensive [ ^ self guessedClass ifNil: [ self valueOfProperty: #guessedClassExpensive ifAbsentPut: [ - Smalltalk at: #Sandbox ifPresent: [:sandboxClass | - [ - sandboxClass new - stepLimit: 100000; - evaluate: [ - self evaluate ifNotNil: [:result | - [result class] on: MessageNotUnderstood do: ["might be ProtoObject" - thisContext objectClass: result]]] - ifFailed: [nil]] - on: (Smalltalk at: #SandboxError) - do: [:err | nil]]]] + nil]] ] { #category : #accessing } diff --git a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st index 48655465..b95a9e50 100644 --- a/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st +++ b/packages/Sandblocks-Smalltalk/SBStGrammarHandler.class.st @@ -712,7 +712,6 @@ SBStGrammarHandler >> wrapInVariant [ callingAlternativesBuilder: #defaultAlternativesForBlocks:]. variant sandblockEditor select: variant nameBlock. - variant sandblockEditor save: variant containingArtefact tryFixing: true quick: false. ] { #category : #actions } diff --git a/packages/Sandblocks-Smalltalk/SBVariant.class.st b/packages/Sandblocks-Smalltalk/SBVariant.class.st index cf98b2cf..9d247b1b 100644 --- a/packages/Sandblocks-Smalltalk/SBVariant.class.st +++ b/packages/Sandblocks-Smalltalk/SBVariant.class.st @@ -88,6 +88,7 @@ SBVariant class >> named: aString associations: aCollectionOfAssociations active "Always prioritize the permutation which is marked as active" SBActiveVariantPermutation value ifNotNil: [^ (aCollectionOfAssociations at: (SBActiveVariantPermutation value at: uuid) ifAbsent: [^ defaultBehavior value]) value value]. + requestor := thisContext sender receiver. "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 value]. "The permutation is outdated and does not know this variant" @@ -469,6 +470,12 @@ SBVariant >> switchToAlternative: anIndex [ self widget jumpToTab: anIndex ] +{ #category : #actions } +SBVariant >> switchToAlternativeWithoutSaving: anIndex [ + + self widget jumpToTabWithoutSaving: anIndex +] + { #category : #accessing } SBVariant >> toggleActive [ diff --git a/packages/Sandblocks-Utils/SBPermutation.class.st b/packages/Sandblocks-Utils/SBPermutation.class.st index 8f26fb6a..5e7a01e7 100644 --- a/packages/Sandblocks-Utils/SBPermutation.class.st +++ b/packages/Sandblocks-Utils/SBPermutation.class.st @@ -53,7 +53,11 @@ SBPermutation >> activeScore [ { #category : #actions } SBPermutation >> apply [ - self referencedVariants do: [:aVariant | aVariant switchToAlternative: (self at: aVariant id)]. + self referencedVariants do: [:aVariant | aVariant switchToAlternativeWithoutSaving: (self at: aVariant id)]. + SBExploriants uniqueInstance ignoreUpdate: true. + ((self referencedVariants collect: #containingArtefact) asSet) do: [:aMethod | + self referencedVariants first sandblockEditor save: aMethod tryFixing: false quick: false]. + ((Set newFrom: (referencedVariants collect: #sandblockEditor)) reject: #isNil) do: #sendNewPermutationNotification diff --git a/packages/Sandblocks-Watch/SBMorphResizer.class.st b/packages/Sandblocks-Watch/SBMorphResizer.class.st index d68bcd71..22263d8b 100644 --- a/packages/Sandblocks-Watch/SBMorphResizer.class.st +++ b/packages/Sandblocks-Watch/SBMorphResizer.class.st @@ -14,7 +14,7 @@ Class { { #category : #'initialize-release' } SBMorphResizer class >> newBig [ - ^ self newLabeled: 'big' transforming: [:anObject | anObject applyResize: 350@350] + ^ self newLabeled: 'big' transforming: [:anObject | anObject applyResize: (350@350) sbScaled] ] { #category : #'initialize-release' } @@ -35,25 +35,25 @@ SBMorphResizer class >> newLabeled: aName transforming: aBlockTakingASingleParam { #category : #'initialize-release' } SBMorphResizer class >> newMedium [ - ^ self newLabeled: 'medium' transforming: [:anObject | anObject applyResize: 150@150] + ^ self newLabeled: 'medium' transforming: [:anObject | anObject applyResize: (200@200) sbScaled] ] { #category : #'initialize-release' } SBMorphResizer class >> newSmall [ - ^ self newLabeled: 'small' transforming: [:anObject | anObject applyResize: 100@100] + ^ self newLabeled: 'small' transforming: [:anObject | anObject applyResize: (100@100) sbScaled] ] { #category : #'initialize-release' } SBMorphResizer class >> newThumbmail [ - ^ self newLabeled: 'thumbmail' transforming: [:anObject | anObject applyResize: 40@40] + ^ self newLabeled: 'thumbmail' transforming: [:anObject | anObject applyResize: (40@40) sbScaled] ] { #category : #'initialize-release' } SBMorphResizer class >> newTiny [ - ^ self newLabeled: 'tiny' transforming: [:anObject | anObject applyResize: 15@15] + ^ self newLabeled: 'tiny' transforming: [:anObject | anObject applyResize: (15@15) sbScaled] ] { #category : #'initialize-release' } From 4325e668023d459156312ab48ec2a0392a1350e8 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 8 Apr 2024 18:42:39 +0200 Subject: [PATCH 6/9] cleanup --- .../Sandblocks-Babylonian/Object.extension.st | 1 - .../Sandblocks-Babylonian/SBCluster.class.st | 2 +- .../SBCorrelationView.class.st | 4 +- .../SBDiffTabView.class.st | 1 + .../Sandblocks-Babylonian/SBExample.class.st | 13 ++++- .../SBExampleValueDisplay.class.st | 4 +- .../SBExampleWatch.class.st | 6 +- .../SBExploriants.class.st | 32 +++-------- .../SBInactiveExampleWatch.class.st | 6 -- .../SBInactiveExampleWatch.extension.st | 6 -- .../Sandblocks-Babylonian/SBLiveView.class.st | 56 ++++++++++++------- .../SBPlainResultsView.class.st | 1 - packages/Sandblocks-Core/SBTabView.class.st | 43 +++++++++++--- packages/Sandblocks-Morphs/SBButton.class.st | 11 ---- .../Sandblocks-Smalltalk/SBStASTNode.class.st | 1 + 15 files changed, 98 insertions(+), 89 deletions(-) diff --git a/packages/Sandblocks-Babylonian/Object.extension.st b/packages/Sandblocks-Babylonian/Object.extension.st index 6fa8ddae..a72a1043 100644 --- a/packages/Sandblocks-Babylonian/Object.extension.st +++ b/packages/Sandblocks-Babylonian/Object.extension.st @@ -63,7 +63,6 @@ Object >> sbWatchValueMorphFor: aSBWatchValue sized: aSBMorphResizer [ "Objects can choose if they want to apply a changed extent" ^ (SBWatchValue newContainerMorphFor: aSBWatchValue) - "addMorphBack: (SBIcon iconFor: aSBWatchValue watchedValueIdentityHash) asMorph;" addMorphBack: self asMorph; yourself ] diff --git a/packages/Sandblocks-Babylonian/SBCluster.class.st b/packages/Sandblocks-Babylonian/SBCluster.class.st index 9e7505a2..f71746d7 100644 --- a/packages/Sandblocks-Babylonian/SBCluster.class.st +++ b/packages/Sandblocks-Babylonian/SBCluster.class.st @@ -145,7 +145,7 @@ SBCluster >> visualize [ self newTopRowFrom: (matrix atRow: 1) allButFirst. "ignore placeholder morph" self newContainerMorph listDirection: #leftToRight; - cellInset: 5@(-30); + cellInset: 3@3; addAllMorphsBack: { self newLeftColumnFrom: (matrix atColumn: 1) allButFirst. "ignore placeholder morph" SBGrid newDisplaying: diff --git a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st index b0862722..47937be3 100644 --- a/packages/Sandblocks-Babylonian/SBCorrelationView.class.st +++ b/packages/Sandblocks-Babylonian/SBCorrelationView.class.st @@ -93,7 +93,7 @@ SBCorrelationView >> buildVariantSelection [ displayPrefixOnly ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } SBCorrelationView >> buttons [ ^ super buttons, {self buildSelectionOptions} @@ -130,7 +130,7 @@ SBCorrelationView >> ensureVariantSelectionIn: aMorph [ aMorph addMorph: variantSelection. selectedVariants - ifNil: [selectedVariants := {} asOrderedCollection] + ifNil: [selectedVariants := {variantSelection object} asOrderedCollection] ifNotNil: [selectedVariants := selectedVariants select: [:aVariant | self multiverse variants includes: aVariant]]. ] diff --git a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st index 7b49db85..3f05cf69 100644 --- a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st +++ b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st @@ -86,6 +86,7 @@ SBDiffTabView >> initialize [ super initialize. + wantsTabCountChanges := true. isShowingDiff := false. self hResizing: #spaceFill. ] diff --git a/packages/Sandblocks-Babylonian/SBExample.class.st b/packages/Sandblocks-Babylonian/SBExample.class.st index b5ec7f49..c6112b76 100644 --- a/packages/Sandblocks-Babylonian/SBExample.class.st +++ b/packages/Sandblocks-Babylonian/SBExample.class.st @@ -393,7 +393,11 @@ SBExample >> run [ self scheduleLastError: nil. currentProcess := nil. processRunning := false. - Project current addDeferredUIMessage: [self sendFinishNotification]] forkAt: Processor userBackgroundPriority. + Project current addDeferredUIMessage: [ + returnValue reportValues: {returned asSBWatchValue} sized: SBMorphResizer newThumbmail. + returnValue updateDisplay. + self sendFinishNotification] + ] forkAt: Processor userBackgroundPriority. ^ currentProcess ] @@ -415,7 +419,8 @@ SBExample >> runSetup [ errorDecorator ifNotNil: #detach. errorDecorator := nil. - traceSize := 0 + traceSize := 0. + returnValue clear. ] { #category : #execution } @@ -444,13 +449,14 @@ SBExample >> self: aBlock args: aCollectionBlock label: aString [ removeAllMorphs; addMorphBack: (icon := SBIcon iconPause small; - color: (Color r: 1 g: 1 b: 1); + 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 ] @@ -517,6 +523,7 @@ SBExample >> stopRunning [ self stopSteppingSelector: #run. active := false. + returnValue clear. self updateIcon. self sandblockEditor allMorphsDo: [:morph | (morph isSandblock and: [morph listensToExamples]) ifTrue: [morph exampleStopped: self]] diff --git a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st index f1633313..3d82a123 100644 --- a/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st @@ -79,7 +79,7 @@ SBExampleValueDisplay >> initialize [ cellGap: 2; layoutInset: 2@3; addAllMorphsBack: { - label := SBStringMorph new visible: false. + label := SBStringMorph new. statusLabel := SBStringMorph new contents: ''. self newChangeVizButton}; yourself); @@ -136,7 +136,7 @@ SBExampleValueDisplay >> reportValues: aCollectionOfWatchValues name: aString si display reportValues: aCollectionOfWatchValues sized: aSBMorphResizer. label contents: aString. - label visible: false. + label visible: aString notEmpty. hadValue := true ] diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index 63378fbb..3b717343 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -369,6 +369,7 @@ SBExampleWatch >> initialize [ hResizing: #spaceFill; listCentering: #bottomRight; addMorphBack: dimensionOptions; + addMorphBack: modifyExpression yourself}; yourself ] @@ -447,7 +448,8 @@ SBExampleWatch >> modifyExpression [ SBExampleWatch >> modifyExpression: aBlock [ modifyExpression ifNotNil: #delete. - modifyExpression := aBlock + modifyExpression := aBlock. + self addMorphBack: modifyExpression. ] { #category : #accessing } @@ -464,7 +466,7 @@ SBExampleWatch >> outOfWorld: aWorld [ self class unregisterWatch: self ] -{ #category : #'as yet unclassified' } +{ #category : #testing } SBExampleWatch >> preventOcclusion [ ^ false diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 1597397c..0a9674c7 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -56,15 +56,8 @@ SBExploriants >> artefactSaved: aMethodBlock [ SBExploriants >> asTabButton: aNamedBlock [ | button | - button := SBButton new - label: aNamedBlock nameToDisplay do: [self setActive: aNamedBlock]; - cornerStyle: #squared; - hResizing: #spaceFill; - changeTableLayout; - makeSmall; - listDirection: #leftToRight. - - aNamedBlock = self active ifTrue: [button makeBold]. + button := super asTabButton: aNamedBlock. + button when: #doubleClicked send: #value to: []. ^ button ] @@ -85,20 +78,15 @@ SBExploriants >> binding: aString for: block class: aClass ifPresent: aBlock [ ] { #category : #ui } -SBExploriants >> buildTabs [ +SBExploriants >> buildView [ - self addMorphBack: (SBRow new - addAllMorphsBack: (self namedBlocks collect: [:block | self asTabButton: block]); - name: #tabs; - changeTableLayout; - listDirection: #leftToRight; - hResizing: #shrinkWrap) + self addMorphBack: (self activeBlock hResizing: #shrinkWrap) ] -{ #category : #ui } -SBExploriants >> buildView [ +{ #category : #accessing } +SBExploriants >> buttonClass [ - self addMorphBack: (self activeBlock hResizing: #shrinkWrap) + ^ SBButton ] { #category : #testing } @@ -195,12 +183,6 @@ SBExploriants >> selector [ ^ nil ] -{ #category : #accessing } -SBExploriants >> tabs [ - - ^ (self submorphNamed: #tabs) submorphs -] - { #category : #actions } SBExploriants >> tryToUpdateInBackgroundAfterChangeIn: aMethodBlock [ diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st index 8469b814..ae03051e 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st @@ -85,12 +85,6 @@ SBInactiveExampleWatch >> originalIdentifier: aNumber [ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" - "exampleToValues associationsDo: [:anExampleValuesPair | - anExampleValuesPair value do: [:aWatchValue | - aWatchValue watchedValue allMorphsDo: [:aSubMorph | - SBExploriants objectToPermutation - at: aSubMorph - put: SBActiveVariantPermutation value]]]." exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st index 539f93ed..877f59f5 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st @@ -10,12 +10,6 @@ SBInactiveExampleWatch >> listensToExamples [ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" - "exampleToValues associationsDo: [:anExampleValuesPair | - anExampleValuesPair value do: [:aWatchValue | - aWatchValue watchedValue allMorphsDo: [:aSubMorph | - SBExploriants objectToPermutation - at: aSubMorph - put: SBActiveVariantPermutation value]]]." exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index 69265b13..1fdf3dd0 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -14,8 +14,7 @@ Class { { #category : #building } SBLiveView >> buildAllPossibleResults [ - self multiverse watches ifEmpty: [^ self]. - self multiverse universes do: [:aUniverse | self buildPreviewFor: aUniverse] + self multiverse universes do: [:aUniverse | self buildPreviewFor: aUniverse activePermutation] ] { #category : #building } @@ -32,19 +31,37 @@ SBLiveView >> buildBrodcaster [ ] { #category : #building } -SBLiveView >> buildPreviewFor: aUniverse [ +SBLiveView >> buildPreviewFor: aPermutation [ | preview | - preview := self newRegisteredListenerFor: aUniverse. + preview := self newRegisteredListenerFor: aPermutation. gridContainer addMorphBack: (self containerRow cellPositioning: #center; addAllMorphsBack: { self containerRow listDirection: #topToBottom; addAllMorphsBack: { - (SBPermutationLabel newDisplaying: aUniverse activePermutation) wrapFlag: false. - self newPermutationButtonRowFor: aUniverse showing: preview. + (SBPermutationLabel newDisplaying: aPermutation) wrapFlag: false. + self newPermutationButtonRowFor: aPermutation showing: preview. preview}}). ] +{ #category : #building } +SBLiveView >> buildSetUpRow [ + + self block addMorphBack: (SBRow new + changeTableLayout; + hResizing: #spaceFill; + wrapCentering: #center; + listCentering: #center; + cellPositioning: #center; + name: #setup; + cellGap: 8 * self scalingFactor; + addMorphBack: (SBIcon iconSpinner + balloonText: 'Toggle stepping'; + on: #click send: #toggleStepping to: self); + addMorphBack: (SBStringMorph new contents: 'Setup:'); + addMorphBack: ([Morph new] asSandblock width: 200)) +] + { #category : #building } SBLiveView >> buttons [ @@ -77,6 +94,7 @@ SBLiveView >> initialize [ super initialize. self name: 'Playground'. + self buildSetUpRow. ] @@ -98,30 +116,28 @@ SBLiveView >> listeners [ ] { #category : #building } -SBLiveView >> newPermutationButtonRowFor: aUniverse showing: aPreview [ +SBLiveView >> newPermutationButtonRowFor: aPermutation showing: aPreview [ ^ self containerRow layoutInset: 0; cellInset: 0; addAllMorphsBack: { - SBButton newApplyPermutationFor: aUniverse activePermutation. - self rebuildButtonIn: aPreview applying: aUniverse. + self rebuildButtonIn: aPreview applying: aPermutation. self synchronizeButtonIn: aPreview} ] { #category : #initialization } -SBLiveView >> newRegisteredListenerFor: aUniverse [ +SBLiveView >> newRegisteredListenerFor: aPermutation [ - | listener value container watch | - self flag: #todo. "for multiple watch values" - watch := aUniverse watches first. - value := watch exampleToValues values first first watchedValue. - listener := value veryDeepCopy asMorph. + | listener container | + SBActiveVariantPermutation value: aPermutation. + listener := self evaluateSetUp. container := broadcaster addListener: listener. listener allMorphsDo: [:aSubMorph | - SBExploriants objectToPermutation at: aSubMorph put: watch createdWithPermutation]. + SBExploriants objectToPermutation at: aSubMorph put: aPermutation]. + SBActiveVariantPermutation value: nil. ^ container ] @@ -209,6 +225,7 @@ SBLiveView >> snapshot [ ^ self containerRow listDirection: #topToBottom; addAllMorphsBack: { + ImageMorph new newForm: (self block submorphNamed: 'setup') imageForm. ImageMorph new newForm: gridContainer imageForm} ] @@ -246,14 +263,13 @@ SBLiveView >> toggleStepping [ { #category : #actions } SBLiveView >> visualize [ - ^ self. - "self clean. + self clean. self buildBrodcaster. self buildButtonRow. self block addMorphBack: gridContainer. self buildAllPossibleResults. - self listeners ifNotEmpty: [broadcaster extent: self listeners last extent. ]. - self concludeContainerWidth. " + broadcaster extent: self listeners last extent. + self concludeContainerWidth. ] diff --git a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st index 614ac664..d22ff1b5 100644 --- a/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st +++ b/packages/Sandblocks-Babylonian/SBPlainResultsView.class.st @@ -14,7 +14,6 @@ SBPlainResultsView >> buildAllPossibleResults [ SBPlainResultsView >> buildPermutationFor: aSBUniverse [ self block addAllMorphsBack: {(SBPermutationLabel newDisplaying: aSBUniverse activePermutation) wrapFlag: false. - SBButton newApplyPermutationFor: aSBUniverse activePermutation. (self containerRow listDirection: #leftToRight) addAllMorphsBack: aSBUniverse watches. LineMorph from: 0@0 to: 50@0 color: Color black width: 2} diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index 3b09f847..01d450ea 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -3,7 +3,8 @@ Class { #superclass : #SBBlock, #instVars : [ 'namedBlocks', - 'activeIndex' + 'activeIndex', + 'wantsTabCountChanges' ], #category : #'Sandblocks-Core' } @@ -153,15 +154,16 @@ SBTabView >> allMorphsDepthFirstDo: aBlock [ SBTabView >> asTabButton: aNamedBlock [ | button | - button := SBEditableButton new + button := self buttonClass new label: aNamedBlock nameToDisplay do: [self setActive: aNamedBlock]; cornerStyle: #squared; makeSmall; hResizing: #spaceFill; changeTableLayout; - listDirection: #leftToRight; - addMorphBack: (self deleteButtonFor: aNamedBlock). - + listDirection: #leftToRight. + + self wantsTabCountChanges ifTrue: [button addMorphBack: (self deleteButtonFor: aNamedBlock)]. + aNamedBlock = self active ifTrue: [button makeBold]. button when: #contentsChanged send: #updateNameFor:on: to: self withArguments: {aNamedBlock. button}. button when: #doubleClicked send: #triggerEvent: to: self with: #doubleClicked. @@ -186,13 +188,15 @@ SBTabView >> blockAt: anIndex [ { #category : #ui } SBTabView >> buildTabs [ - self addMorphBack: (SBRow new + | tabs | + tabs := SBRow new addAllMorphsBack: (self namedBlocks collect: [:block | self asTabButton: block]); name: #tabs; - addMorphBack: self addButton; changeTableLayout; listDirection: #leftToRight; - hResizing: #shrinkWrap) + hResizing: #shrinkWrap. + self wantsTabCountChanges ifTrue: [tabs addMorphBack: self addButton]. + self addMorphBack: tabs. ] { #category : #ui } @@ -201,6 +205,12 @@ SBTabView >> buildView [ self addMorphBack: (self activeBlock hResizing: #spaceFill) ] +{ #category : #accessing } +SBTabView >> buttonClass [ + + ^ SBEditableButton +] + { #category : #ui } SBTabView >> deleteButtonFor: aNamedBlock [ @@ -225,6 +235,7 @@ SBTabView >> initialize [ namedBlocks := {SBNamedBlock new} asOrderedCollection. activeIndex := 1. + wantsTabCountChanges := false. self changeTableLayout; @@ -450,7 +461,9 @@ SBTabView >> tabCount [ { #category : #accessing } SBTabView >> tabs [ - ^ (self submorphNamed: #tabs) submorphs allButLast + ^ self wantsTabCountChanges + ifTrue: [(self submorphNamed: #tabs) submorphs allButLast] + ifFalse: [(self submorphNamed: #tabs) submorphs] ] { #category : #ui } @@ -488,3 +501,15 @@ SBTabView >> view [ ^ self lastSubmorph ] + +{ #category : #accessing } +SBTabView >> wantsTabCountChanges [ + + ^ wantsTabCountChanges +] + +{ #category : #accessing } +SBTabView >> wantsTabCountChanges: aBoolean [ + + wantsTabCountChanges := aBoolean +] diff --git a/packages/Sandblocks-Morphs/SBButton.class.st b/packages/Sandblocks-Morphs/SBButton.class.st index e484cb83..41d7403d 100644 --- a/packages/Sandblocks-Morphs/SBButton.class.st +++ b/packages/Sandblocks-Morphs/SBButton.class.st @@ -10,17 +10,6 @@ Class { #category : #'Sandblocks-Morphs' } -{ #category : #'instance creation' } -SBButton class >> newApplyPermutationFor: aPermutation [ - - ^ self new - icon: (SBIcon iconArrowDown size: 8.0 sbScaled) - label: 'Apply' - do: [aPermutation apply]; - makeSmall; - cornerStyle: #squared -] - { #category : #accessing } SBButton >> active [ diff --git a/packages/Sandblocks-Smalltalk/SBStASTNode.class.st b/packages/Sandblocks-Smalltalk/SBStASTNode.class.st index 50a73b3d..14e1c846 100644 --- a/packages/Sandblocks-Smalltalk/SBStASTNode.class.st +++ b/packages/Sandblocks-Smalltalk/SBStASTNode.class.st @@ -164,6 +164,7 @@ SBStASTNode >> grammarHandler [ { #category : #accessing } SBStASTNode >> guessClassExpensive [ + self flag: #fixme. "new sandbox interface, tobe" ^ self guessedClass ifNil: [ self valueOfProperty: #guessedClassExpensive ifAbsentPut: [ nil]] From 3dd455295fa41cfb2961f0f58e813ccd77d2b56b Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 8 Apr 2024 18:48:13 +0200 Subject: [PATCH 7/9] more cleanup --- packages/Sandblocks-Babylonian/SBLiveView.class.st | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st index 1fdf3dd0..cfcc491a 100644 --- a/packages/Sandblocks-Babylonian/SBLiveView.class.st +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -167,20 +167,20 @@ SBLiveView >> rebuildButton [ ] { #category : #building } -SBLiveView >> rebuildButtonIn: aContainer applying: aUniverse [ +SBLiveView >> rebuildButtonIn: aContainer applying: aPermutation [ ^ SBButton new icon: (SBIcon iconRotateRight size: 8.0 sbScaled) label: 'Re-Build This' - do: [self rebuildRegisteredListenerFor: aUniverse in: aContainer]; + do: [self rebuildRegisteredListenerFor: aPermutation in: aContainer]; makeSmall; cornerStyle: #squared ] { #category : #initialization } -SBLiveView >> rebuildRegisteredListenerFor: aUniverse in: aContainer [ +SBLiveView >> rebuildRegisteredListenerFor: aPermutation in: aContainer [ - self privateRegisterListener: (aUniverse watches first exampleToValues values first first watchedValue veryDeepCopy) for: aUniverse activePermutation in: aContainer + self privateRegisterListener: self evaluateSetUp for: aPermutation in: aContainer ] From 2b0b53785a6fa3c13bb234a494d3ad13588a69c4 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 8 Apr 2024 18:52:46 +0200 Subject: [PATCH 8/9] fix modify expression line up --- packages/Sandblocks-Babylonian/SBExampleWatch.class.st | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st index 3b717343..7856135e 100644 --- a/packages/Sandblocks-Babylonian/SBExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBExampleWatch.class.st @@ -369,8 +369,8 @@ SBExampleWatch >> initialize [ hResizing: #spaceFill; listCentering: #bottomRight; addMorphBack: dimensionOptions; - addMorphBack: modifyExpression - yourself}; + yourself. + modifyExpression}; yourself ] From 4d6b8a25d93f3a53fbdb90df3952bea48c75299e Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Mon, 8 Apr 2024 18:55:14 +0200 Subject: [PATCH 9/9] Fix change of all tabs in history view --- packages/Sandblocks-Babylonian/SBHistoryView.class.st | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/Sandblocks-Babylonian/SBHistoryView.class.st b/packages/Sandblocks-Babylonian/SBHistoryView.class.st index deb2eaa6..e0252565 100644 --- a/packages/Sandblocks-Babylonian/SBHistoryView.class.st +++ b/packages/Sandblocks-Babylonian/SBHistoryView.class.st @@ -184,7 +184,8 @@ SBHistoryView >> offerChangeTabMenu [ index := UIManager default chooseFrom: options. index = 0 ifTrue: [^ self]. - self scroller submorphs do: [:anEpoche | anEpoche lastSubmorph activeIndex: index]. + self scroller submorphs do: [:anEpoche | + (anEpoche lastSubmorph isKindOf: SBTabView) ifTrue: [anEpoche lastSubmorph activeIndex: index]]. ] { #category : #building }