Skip to content

Commit

Permalink
Adds basic live view
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Nov 28, 2023
1 parent cf996a7 commit 0adb935
Show file tree
Hide file tree
Showing 8 changed files with 243 additions and 11 deletions.
21 changes: 19 additions & 2 deletions packages/Sandblocks-Babylonian/SBDiffTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down Expand Up @@ -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 }
Expand Down
16 changes: 16 additions & 0 deletions packages/Sandblocks-Babylonian/SBExploriants.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBExploriantsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]]].
]
Original file line number Diff line number Diff line change
Expand Up @@ -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]]].
]
66 changes: 66 additions & 0 deletions packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st
Original file line number Diff line number Diff line change
@@ -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.
]
131 changes: 131 additions & 0 deletions packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
@@ -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.
]
4 changes: 2 additions & 2 deletions packages/Sandblocks-Core/SBTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ SBTabView >> addButton [

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

{ #category : #commands }
Expand Down

0 comments on commit 0adb935

Please sign in to comment.