Skip to content

Commit

Permalink
Inspectable Blocks through enter, scrollpane in watch view
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Aug 15, 2023
1 parent ddf9978 commit 853ebfd
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Collection.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Collection }
{ #category : #'*Sandblocks-Babylonian' }
Collection >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorph: (SBStringMorph new contents: self printString)
yourself
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Color.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Color }
{ #category : #'*Sandblocks-Babylonian' }
Color >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorph: self asMorph;
yourself
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Form.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Form >> sbSnapshot [
{ #category : #'*Sandblocks-Babylonian' }
Form >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: self asMorph;
yourself
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Morph.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Morph }
{ #category : #'*Sandblocks-Babylonian' }
Morph >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: self asMorph;
yourself
Expand Down
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Number.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Number }
{ #category : #'*Sandblocks-Babylonian' }
Number >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBStringMorph new contents: self printString);
yourself
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Object >> sbWatchValueMorphFor: traceValue [

"This has to return a container block"

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBIcon iconFor: traceValue watchedValueIdentityHash) asMorph;
addMorphBack: (SBStringMorph new contents: (' ' , self printString));
yourself
Expand Down
20 changes: 18 additions & 2 deletions packages/Sandblocks-Babylonian/SBWatchValue.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Class {
}

{ #category : #utility }
SBWatchValue class >> newContainerMorph [
SBWatchValue class >> newContainerMorphFor: aWatchValue [

^ SBBlock new
^ SBWatchValueBlock new
watchValue: aWatchValue;
layoutPolicy: SBHorizontalLayout new;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
Expand All @@ -33,6 +34,21 @@ SBWatchValue >> asValueMorph [
^ self watchedValue sbWatchValueMorphFor: self
]

{ #category : #accessing }
SBWatchValue >> explore [

self watchedValue explore
]

{ #category : #'initialize-release' }
SBWatchValue >> initialize [

super initialize.

watchedValue := 0.
watchedValueIdentityHash := 0 identityHash.
]

{ #category : #printing }
SBWatchValue >> printOn: aSteam [

Expand Down
36 changes: 36 additions & 0 deletions packages/Sandblocks-Babylonian/SBWatchValueBlock.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Class {
#name : #SBWatchValueBlock,
#superclass : #SBBlock,
#instVars : [
'watchValue'
],
#category : #'Sandblocks-Babylonian'
}

{ #category : #'as yet unclassified' }
SBWatchValueBlock class >> registerShortcuts: aProvider [

aProvider registerShortcut: Character cr do: #exploreValue.
aProvider cmdShortcut: $i do: #exploreValue.


]

{ #category : #accessing }
SBWatchValueBlock >> exploreValue [
<action>

self watchValue watchedValue explore
]

{ #category : #accessing }
SBWatchValueBlock >> watchValue [

^ watchValue ifNil: [watchValue := SBWatchValue new]
]

{ #category : #accessing }
SBWatchValueBlock >> watchValue: aSBWatchValue [

watchValue := aSBWatchValue
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/String.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #String }
{ #category : #'*Sandblocks-Babylonian' }
String >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBStringMorph new contents: self asText)
yourself
]
2 changes: 1 addition & 1 deletion packages/Sandblocks-Babylonian/Text.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Extension { #name : #Text }
{ #category : #'*Sandblocks-Babylonian' }
Text >> sbWatchValueMorphFor: traceValue [

^ SBWatchValue newContainerMorph
^ (SBWatchValue newContainerMorphFor: traceValue)
addMorphBack: (SBStringMorph new contents: self)
yourself
]
8 changes: 0 additions & 8 deletions packages/Sandblocks-Watch/SBExampleWatchView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ Class {
#category : #'Sandblocks-Watch'
}

{ #category : #accessing }
SBExampleWatchView >> display [

(self submorphCount >= 2)
ifFalse: [self addMorph: (self defaultDisplay) atIndex: 2].
^self submorphs second
]

{ #category : #'event handling' }
SBExampleWatchView >> exampleFinished: anExample [

Expand Down
85 changes: 70 additions & 15 deletions packages/Sandblocks-Watch/SBWatchView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SBWatchView >> clear [
count contents: '0'.
watchValues := LinkedList new.

self display replaceBy: (self placeholder: 0 @ 0).
self scroller removeAllMorphs.
clear
disableLayout: true;
visible: false
Expand All @@ -60,28 +60,42 @@ SBWatchView >> count [
]

{ #category : #display }
SBWatchView >> defaultDisplay [
SBWatchView >> defaultDisplay [

^ SBBlock new
layoutPolicy: SBHorizontalLayout new;
^ SBBlock new
changeTableLayout;
listDirection: #topToBottom;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap
addMorphBack: (ScrollPane new
color: Color transparent;
borderWidth: 0;
vScrollBarPolicy: #never;
showHScrollBarOnlyWhenNeeded;
scrollBarThickness: self scrollBarHeight;
width: 20;
height: 20)
]

{ #category : #accessing }
SBWatchView >> display [

(self submorphCount >= 3)
ifFalse: [self addMorph: (self defaultDisplay) atIndex: 2].
^self submorphs second
]

{ #category : #display }
SBWatchView >> displayWatchValues [

self display delete.

watchValues do: [:v | self display addMorphBack: (self valueMorphFor: v)]

| valuesMorph |
self scroller removeAllMorphs.
valuesMorph := self watchValuesContainer.
watchValues do: [:v | valuesMorph addMorphBack: (self valueMorphFor: v)].

self scroller addMorph: valuesMorph.
self scrollPane height: valuesMorph height + self scrollBarHeight.
self scrollPane width: (valuesMorph width <= self maxWidth
ifTrue: [valuesMorph width]
ifFalse: [self maxWidth]).
]

{ #category : #'colors and color policies' }
Expand Down Expand Up @@ -118,7 +132,7 @@ SBWatchView >> initialize [
contents: '0';
balloonText: 'Number of reported values';
yourself);
addMorphBack: (self placeholder: 0 @ 0);
addMorphBack: self defaultDisplay;
addMorphBack: (clear := SBIcon iconTrash
on: #click send: #clear to: self;
disableLayout: true;
Expand All @@ -139,10 +153,16 @@ SBWatchView >> layoutCommands [
data: (self submorphs collect: #layoutCommands separatedBy: [SBAlgebraCommand gap])
]

{ #category : #accessing }
SBWatchView >> maxWidth [

^ 450
]

{ #category : #'event handling' }
SBWatchView >> noValue [

self display ifNotNil: [self display replaceBy: (self placeholder: self display fullBounds extent)]
self scroller removeAllMorphs
]

{ #category : #accessing }
Expand All @@ -159,9 +179,9 @@ SBWatchView >> object [
]

{ #category : #'event handling' }
SBWatchView >> placeholder: aPoint [
SBWatchView >> placeholder [

^ Morph new color: Color transparent; extent: aPoint
^ Morph new color: Color transparent; extent: (0@0)
]

{ #category : #printing }
Expand All @@ -182,6 +202,24 @@ SBWatchView >> reportValue: anObject [
Project current addDeferredUIMessage: [self updateDisplay]]
]

{ #category : #accessing }
SBWatchView >> scrollBarHeight [

^ 5 sbScaled
]

{ #category : #accessing }
SBWatchView >> scrollPane [

^ self display lastSubmorph
]

{ #category : #accessing }
SBWatchView >> scroller [

^ self scrollPane scroller
]

{ #category : #'object interface' }
SBWatchView >> storeAsExample [

Expand Down Expand Up @@ -211,6 +249,7 @@ SBWatchView >> updateDisplay [
{ #category : #display }
SBWatchView >> useDisplay: aDisplay [

self flag:#todo.
self display delete.
self addMorph: aDisplay atIndex: 2.
]
Expand All @@ -221,12 +260,14 @@ SBWatchView >> valueMorphFor: traceValue [
| morph |
morph := traceValue asValueMorph.
morph on: #doubleClick send: #value to: [traceValue watchedValue explore].
morph on: #keyStroke send: #keyStroke to: traceValue.
^ morph
]

{ #category : #accessing }
SBWatchView >> values [

watchValues ifEmpty: [^{}].
^ numSavedValues = 1 ifTrue: [watchValues last watchedValue] ifFalse: [^ watchValues collect: [:value | value watchedValue]]
]

Expand Down Expand Up @@ -256,3 +297,17 @@ SBWatchView >> watchValues: aLinkedList [

watchValues := aLinkedList
]

{ #category : #display }
SBWatchView >> watchValuesContainer [

^ SBRow new
color: Color transparent;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
cellPositioning: #topLeft;
changeTableLayout;
listDirection: #leftToRight;
layoutInset: 1;
borderWidth: 0
]

0 comments on commit 853ebfd

Please sign in to comment.