Skip to content

Commit

Permalink
Move Selection UI elements to the button rows
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Apr 2, 2024
1 parent f40aba3 commit 8469626
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 142 deletions.
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
35 changes: 11 additions & 24 deletions packages/Sandblocks-Babylonian/SBCorrelationView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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

]

Expand All @@ -91,10 +92,10 @@ SBCorrelationView >> buildVariantSelection [
displayPrefixOnly
]

{ #category : #accessing }
{ #category : #'as yet unclassified' }
SBCorrelationView >> buttons [

^ {}
^ super buttons, {self buildSelectionOptions}
]

{ #category : #building }
Expand Down Expand Up @@ -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 [

Expand Down
8 changes: 6 additions & 2 deletions packages/Sandblocks-Babylonian/SBCustomView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ SBCustomView >> buildViewOptions [
when: #selectionChanged send: #switchView to: self
]

{ #category : #accessing }
SBCustomView >> buttons [

^ {viewOptions}, super buttons
]

{ #category : #initialization }
SBCustomView >> initialize [

Expand All @@ -36,8 +42,6 @@ SBCustomView >> initialize [
self name: 'Results'.

self buildButtonRow.

self block addMorphBack: viewOptions.
self block addMorphBack: self selectedView

]
Expand Down
77 changes: 15 additions & 62 deletions packages/Sandblocks-Babylonian/SBExample.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -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
]
Expand All @@ -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 }
Expand All @@ -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 }
Expand Down Expand Up @@ -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]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
]

Expand Down
51 changes: 31 additions & 20 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions packages/Sandblocks-Babylonian/SBInputBroadcaster.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/SBLiveView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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}}).
]
Expand Down
18 changes: 6 additions & 12 deletions packages/Sandblocks-Babylonian/SBResizableResultsView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ SBResizableResultsView >> buildDimensionOptions [
when: #selectionChanged send: #applyResizer to: self
]

{ #category : #accessing }
SBResizableResultsView >> buttons [

^ {dimensionOptions}
]

{ #category : #initialization }
SBResizableResultsView >> initialize [

Expand All @@ -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.
]
10 changes: 1 addition & 9 deletions packages/Sandblocks-Babylonian/SBStMessageSend.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
{ #category : #accessing }
SBSwitchableResultsView >> buttons [

^ {self toggleViewButton}
^ super buttons, {self toggleViewButton}
]

{ #category : #accessing }
Expand Down
1 change: 1 addition & 0 deletions packages/Sandblocks-Core/SBTabView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ SBTabView >> addButton [
color: (Color green))
do: [self addTab];
makeSmall;
cellPositioning: #center;
cornerStyle: #squared;
vResizing: #spaceFill;
balloonText: 'Add'
Expand Down
4 changes: 1 addition & 3 deletions packages/Sandblocks-Morphs/SBButton.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/Sandblocks-Utils/SBPermutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]


Expand Down

0 comments on commit 8469626

Please sign in to comment.