From 0adb9352e914779ea1a5e759799a6c5baa95e478 Mon Sep 17 00:00:00 2001 From: Joana Bergsiek Date: Tue, 28 Nov 2023 23:54:37 +0100 Subject: [PATCH] Adds basic live view --- .../SBDiffTabView.class.st | 21 ++- .../SBExploriants.class.st | 16 +++ .../SBExploriantsView.class.st | 2 +- .../SBInactiveExampleWatch.class.st | 7 +- .../SBInactiveExampleWatch.extension.st | 7 +- .../SBInputBroadcaster.class.st | 66 +++++++++ .../Sandblocks-Babylonian/SBLiveView.class.st | 131 ++++++++++++++++++ packages/Sandblocks-Core/SBTabView.class.st | 4 +- 8 files changed, 243 insertions(+), 11 deletions(-) create mode 100644 packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st create mode 100644 packages/Sandblocks-Babylonian/SBLiveView.class.st diff --git a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st index 2b6e70f5..6119ecbf 100644 --- a/packages/Sandblocks-Babylonian/SBDiffTabView.class.st +++ b/packages/Sandblocks-Babylonian/SBDiffTabView.class.st @@ -7,6 +7,22 @@ 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 [ @@ -54,13 +70,14 @@ SBDiffTabView >> buildView [ SBDiffTabView >> diffButton [ ^ SBButton new - icon: (SBIcon iconCodeFork size: 12.0 sbScaled) + icon: (SBIcon iconCodeFork size: 12.0) do: [self toggleDiffView]; makeSmall; balloonText: 'Toggle diff to others'; + vResizing: #spaceFill; cornerStyle: #squared; cellGap: -1.0 sbScaled; - layoutInset: (4.0 @ 3.0) sbScaled + layoutInset: (4.0 @ 3.0) ] { #category : #diffing } diff --git a/packages/Sandblocks-Babylonian/SBExploriants.class.st b/packages/Sandblocks-Babylonian/SBExploriants.class.st index 14f65139..0f1a04c5 100644 --- a/packages/Sandblocks-Babylonian/SBExploriants.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriants.class.st @@ -43,6 +43,22 @@ SBExploriants >> = other [ ^ self class = other class ] +{ #category : #'as yet unclassified' } +SBExploriants >> cacheType: aClass for: aBlock [ +] + +{ #category : #'as yet unclassified' } +SBExploriants >> evaluationContext [ + + ^ nil +] + +{ #category : #'as yet unclassified' } +SBExploriants >> evaluationReceiver [ + + ^ self object +] + { #category : #initialization } SBExploriants >> initialize [ diff --git a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st index 6b87edc1..3add0d53 100644 --- a/packages/Sandblocks-Babylonian/SBExploriantsView.class.st +++ b/packages/Sandblocks-Babylonian/SBExploriantsView.class.st @@ -17,7 +17,7 @@ SBExploriantsView class >> block: aSBBlock named: aString [ { #category : #'instance creation' } SBExploriantsView class >> getTabsInMultiverse: aSBMultiverse [ - ^ {SBPermutationGridsView. SBExampleGridsView. SBPlainResultsView. SBVariantsView} + ^ {SBPermutationGridsView. SBExampleGridsView. SBPlainResultsView. SBLiveView. SBVariantsView} collect: [:mySubclass | mySubclass newMultiverse: aSBMultiverse] ] diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st index 308117de..91c075be 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.class.st @@ -57,7 +57,8 @@ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | - SBExploriants objectToPermutation - at: aValueMorph lastSubmorph - put: SBActiveVariantPermutation value]]. + aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation + at: aSubMorph + put: SBActiveVariantPermutation value]]]. ] diff --git a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st index 50276e55..0b86b4f6 100644 --- a/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st +++ b/packages/Sandblocks-Babylonian/SBInactiveExampleWatch.extension.st @@ -12,7 +12,8 @@ SBInactiveExampleWatch >> saveObjectsActivePermutations [ "Force morphs to persist their permutation even when on the UI process" exampleToDisplay associationsDo: [:anExampleDisplayPair | anExampleDisplayPair value displayedWatchValueBlocks do: [:aValueMorph | - SBExploriants objectToPermutation - at: aValueMorph lastSubmorph - put: SBActiveVariantPermutation value]]. + aValueMorph lastSubmorph allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation + at: aSubMorph + put: SBActiveVariantPermutation value]]]. ] diff --git a/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st new file mode 100644 index 00000000..8d1eb2e4 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st @@ -0,0 +1,66 @@ +Class { + #name : #SBInputBroadcaster, + #superclass : #Morph, + #instVars : [ + 'listeners' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #events } +SBInputBroadcaster >> filterEvent: anEvent for: aMorph [ + + self flag: #todo. "Die Position im Morph in den listener transformieren" + self listeners do: [:aListener | aListener processEvent: (anEvent copy position: aListener position)]. + ^ anEvent +] + +{ #category : #'events-processing' } +SBInputBroadcaster >> handleMouseOver: anEvent [ + + super handleMouseOver: anEvent. + anEvent hand newKeyboardFocus: self. + +] + +{ #category : #'event handling' } +SBInputBroadcaster >> handlesKeyboard: evt [ + + ^ true + +] + +{ #category : #initialization } +SBInputBroadcaster >> initialize [ + + super initialize. + + listeners := OrderedCollection new. + + self + addKeyboardCaptureFilter: self; + "addMouseCaptureFilter: self;" + extent: 300@200; + color: Color veryLightGray; + changeTableLayout; + listDirection: #topToBottom; + wrapCentering: #center; + listCentering: #center; + addMorph: (StringMorph new + contents: 'Enter Input here'; + color: Color white; + yourself) + +] + +{ #category : #accessing } +SBInputBroadcaster >> listeners [ + + ^ listeners +] + +{ #category : #accessing } +SBInputBroadcaster >> listeners: aCollectionOfMorphs [ + + listeners := aCollectionOfMorphs. +] diff --git a/packages/Sandblocks-Babylonian/SBLiveView.class.st b/packages/Sandblocks-Babylonian/SBLiveView.class.st new file mode 100644 index 00000000..00bd7a74 --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBLiveView.class.st @@ -0,0 +1,131 @@ +Class { + #name : #SBLiveView, + #superclass : #SBGridResultsView, + #instVars : [ + 'broadcaster' + ], + #category : #'Sandblocks-Babylonian' +} + +{ #category : #'as yet unclassified' } +SBLiveView >> buildAllPossibleResults [ + + self multiverse universes do: [:aUniverse | self buildPreviewFor: aUniverse activePermutation] +] + +{ #category : #'as yet unclassified' } +SBLiveView >> buildBrodcaster [ + + self block addMorphBack: (SBRow new + changeTableLayout; + hResizing: #spaceFill; + wrapCentering: #center; + listCentering: #center; + cellPositioning: #center; + addMorph: (broadcaster := SBInputBroadcaster new)) +] + +{ #category : #'as yet unclassified' } +SBLiveView >> buildPreviewFor: aPermutation [ + + gridContainer addMorphBack: (self containerRow cellPositioning: #center; + addAllMorphsBack: { + self containerRow listDirection: #topToBottom; + addAllMorphsBack: { + SBOwnTextMorph new contents: aPermutation asString. + SBButton newApplyPermutationFor: aPermutation. + self newRegisteredListenerFor: aPermutation}. + LineMorph from: 0@0 to: 0@50 color: Color black width: 2}). + + self updateContainerWidth. +] + +{ #category : #'as yet unclassified' } +SBLiveView >> buildSetUpRow [ + + self block addMorph: (SBRow new + changeTableLayout; + hResizing: #spaceFill; + wrapCentering: #center; + listCentering: #center; + cellPositioning: #center; + 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 statements first) width: 200)) +] + +{ #category : #'as yet unclassified' } +SBLiveView >> clean [ + + self block submorphs allButFirst copy do: #delete. + + gridContainer := self newGridContainer. +] + +{ #category : #'as yet unclassified' } +SBLiveView >> evaluateSetUp [ + + ^ self setUpMorph evaluate +] + +{ #category : #'as yet unclassified' } +SBLiveView >> gridObjects [ + + ^ self multiverse universes +] + +{ #category : #initialization } +SBLiveView >> initialize [ + + super initialize. + + self name: 'Live View'. + self buildSetUpRow. +] + +{ #category : #'as yet unclassified' } +SBLiveView >> listeners [ + + ^ broadcaster listeners +] + +{ #category : #'as yet unclassified' } +SBLiveView >> newRegisteredListenerFor: aPermutation [ + + | listener | + listener := self evaluateSetUp. + broadcaster listeners add: listener. + + listener allMorphsDo: [:aSubMorph | + SBExploriants objectToPermutation at: aSubMorph put: aPermutation]. + + ^ listener + +] + +{ #category : #'as yet unclassified' } +SBLiveView >> setUpMorph [ + + ^ self block firstSubmorph "setup row" lastSubmorph +] + +{ #category : #'as yet unclassified' } +SBLiveView >> toggleStepping [ + + self listeners do: [:aMorph | + aMorph isStepping ifFalse: [aMorph startStepping] ifTrue: [aMorph stopStepping]] +] + +{ #category : #'as yet unclassified' } +SBLiveView >> visualize [ + + self clean. + + self buildBrodcaster. + self block addMorphBack: self updateButton. + self block addMorphBack: gridContainer. + self buildAllPossibleResults. +] diff --git a/packages/Sandblocks-Core/SBTabView.class.st b/packages/Sandblocks-Core/SBTabView.class.st index a299ca6f..68d361ed 100644 --- a/packages/Sandblocks-Core/SBTabView.class.st +++ b/packages/Sandblocks-Core/SBTabView.class.st @@ -113,7 +113,7 @@ SBTabView >> addButton [ ^ SBButton new icon: (SBIcon iconPlus - size: 8.0 sbScaled; + size: 7.0 sbScaled; color: (Color green)) do: [self addTab]; makeSmall; @@ -121,7 +121,7 @@ SBTabView >> addButton [ vResizing: #spaceFill; balloonText: 'Add'; cellGap: -1.0 sbScaled; - layoutInset: (4.0 @ 5.0) sbScaled + layoutInset: (4.0 @ 4.0) sbScaled ] { #category : #commands }