Skip to content

Commit

Permalink
Revert "Resizing on watches now applies on any display, instead of th…
Browse files Browse the repository at this point in the history
…e default watchview"

This reverts commit 037bb60 "Resizing on watches now applies on any display, instead of the default watchview"
  • Loading branch information
JoeAtHPI committed Nov 21, 2023
1 parent ffb0e13 commit c88d522
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 121 deletions.
12 changes: 0 additions & 12 deletions packages/Sandblocks-Babylonian/SBExampleValueDisplay.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ SBExampleValueDisplay >> clear [
hadValue := false
]

{ #category : #'as yet unclassified' }
SBExampleValueDisplay >> display [

^ display
]

{ #category : #accessing }
SBExampleValueDisplay >> displayedWatchValueBlocks [

Expand Down Expand Up @@ -133,12 +127,6 @@ SBExampleValueDisplay >> reportValues: aCollectionOfObjects name: aString sized:
hadValue := true
]

{ #category : #actions }
SBExampleValueDisplay >> resizeThrough: aMorphResizer [

display resizeThrough: aMorphResizer
]

{ #category : #actions }
SBExampleValueDisplay >> updateDisplay [

Expand Down
13 changes: 6 additions & 7 deletions packages/Sandblocks-Babylonian/SBExampleWatch.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ SBExampleWatch >> applyModifyExpressionOnValues [
{ #category : #'event handling' }
SBExampleWatch >> applyResizerOnValues [

exampleToDisplay associationsDo: [:anExampleDisplayPair |
anExampleDisplayPair value resizeThrough: self selectedMorphResizer]
"Clearing everything here as Morphs get distorted when resized multiple times."
self applyModifyExpressionOnValues.

]

Expand Down Expand Up @@ -171,12 +171,11 @@ SBExampleWatch >> exampleStarting: anExample [

exampleToValues at: anExample put: OrderedCollection new.

(exampleToDisplay at: anExample ifAbsentPut: [ | watchview |
watchview := SBExampleValueDisplay new.
watchview display fallbackResizer: self selectedMorphResizer.
self addMorph: (exampleToDisplay at: anExample put: watchview) atIndex: 2.
(exampleToDisplay at: anExample ifAbsentPut: [ | display |
display := SBExampleValueDisplay new.
self addMorph: (exampleToDisplay at: anExample put: display) atIndex: 2.
anExample when: #outOfWorld send: #exampleStopped: to: self with: anExample.
watchview])
display])
exampleStarting: anExample;
name: anExample label
]
Expand Down
9 changes: 4 additions & 5 deletions packages/Sandblocks-Watch/SBBarChart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ Class {
}

{ #category : #'initialize-release' }
SBBarChart class >> newWithValues: traceValues havingHeight: aNumber [
SBBarChart class >> newWithValues: traceValues [

| valuesToVisualize |
valuesToVisualize := traceValues
ifEmpty: [#(0)]
ifNotEmpty: [traceValues].
^ self new
targetHeight: aNumber;
traceValues: valuesToVisualize;
scaleY: (SBScale
newLinearScaleWithDomain: (({valuesToVisualize min. 0} min) to: valuesToVisualize max)
forRange: (0 to: aNumber));
forRange: (0 to: self canvasHeight));
yourself
]

Expand All @@ -31,7 +30,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [

"There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area"
^ Morph new
height: self targetHeight;
height: self class preferredHeight;
left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded;
width: self spaceBetweenPoints;
color: Color transparent;
Expand All @@ -40,7 +39,7 @@ SBBarChart >> newBarFor: aValue at: positionIndex [
color: self datapointDefaultColor;
width: self barWidth;
height: {(self scaleY scaledValueOf: aValue). 1} max;
bottom: self canvasHeight + self class heightMargin;
bottom: self class canvasHeight + self class heightMargin;
left: positionIndex * self spaceBetweenPoints;
setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue);
yourself);
Expand Down
11 changes: 5 additions & 6 deletions packages/Sandblocks-Watch/SBLineChart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ Class {
}

{ #category : #'initialize-release' }
SBLineChart class >> newWithValues: traceValues havingHeight: aNumber [
SBLineChart class >> newWithValues: traceValues [

| valuesToVisualize |
valuesToVisualize := traceValues
ifEmpty: [#(0)]
ifNotEmpty: [traceValues].
^ self new
targetHeight: aNumber;
traceValues: valuesToVisualize;
scaleY: (SBScale
newLinearScaleWithDomain: (valuesToVisualize min to: valuesToVisualize max)
forRange: (0 to: aNumber));
forRange: (0 to: self canvasHeight));
yourself
]

Expand Down Expand Up @@ -72,7 +71,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [

"There is an extra Morph containing the datapoint itself so the tooltip is far easier to activate through more area"
^ Morph new
height: self targetHeight;
height: self class preferredHeight;
left: ((positionIndex - 0.5) * self spaceBetweenPoints) rounded;
width: self spaceBetweenPoints;
color: Color transparent;
Expand All @@ -82,7 +81,7 @@ SBLineChart >> newDatapointFor: aValue at: positionIndex [
color: self datapointDefaultColor;
borderWidth: 0;
left: positionIndex * self spaceBetweenPoints;
top: self canvasHeight - (self scaleY scaledValueOf: aValue);
top: self class canvasHeight - (self scaleY scaledValueOf: aValue);
setProperty: #chartValue toValue: (self scaleY scaledValueOf: aValue);
yourself);
yourself
Expand Down Expand Up @@ -136,7 +135,7 @@ SBLineChart >> newScaleLineHeight: height length: length [
SBLineChart >> newScaleLinesOn: aMorph [

| section |
section := self canvasHeight / (self numberScaleLines - 1).
section := self class canvasHeight / (self numberScaleLines - 1).

^ (0 to: (self numberScaleLines - 1)) collect: [:i |
self newScaleLineHeight: (section * i) + self scaleYOffset length: aMorph width]
Expand Down
40 changes: 22 additions & 18 deletions packages/Sandblocks-Watch/SBRectangleChart.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,35 @@ Class {
#category : #'Sandblocks-Watch'
}

{ #category : #constants }
SBRectangleChart class >> coordinateSystemSize [

^ self canvasHeight @ self canvasHeight
]

{ #category : #'initialize-release' }
SBRectangleChart class >> newWithValues: traceValues havingHeight: aNumber [
SBRectangleChart class >> newWithValues: traceValues [

| biggestCoordinate absolutePoints coordinateSystemSize |
| biggestCoordinate absolutePoints |
absolutePoints := traceValues collect: [:aPoint | aPoint abs].
biggestCoordinate := {absolutePoints max x. absolutePoints max y} max.
coordinateSystemSize := aNumber - self heightMargin.
^ self new
targetHeight: aNumber;
traceValues: traceValues;
scaleY: (SBScale
newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate)
forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2))
forRange: (self coordinateSystemSize y / 2 negated to: self coordinateSystemSize y / 2))
scaleX: (SBScale
newLinearScaleWithDomain: (biggestCoordinate negated to: biggestCoordinate)
forRange: (coordinateSystemSize / 2 negated to: coordinateSystemSize / 2));
forRange: (self coordinateSystemSize x / 2 negated to: self coordinateSystemSize x / 2));
yourself
]

{ #category : #constants }
SBRectangleChart class >> preferredHeight [

^ 40
]

{ #category : #conversion }
SBRectangleChart class >> supportedInterface [

Expand All @@ -52,12 +62,6 @@ SBRectangleChart >> borderStyleFor: scaledValues [
^ BorderStyle width: borderWidth color: color
]

{ #category : #'visualization - constants' }
SBRectangleChart >> coordinateSystemSize [

^ self canvasHeight @ self canvasHeight
]

{ #category : #visualization }
SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [

Expand All @@ -66,19 +70,19 @@ SBRectangleChart >> newCoordinateSystemFor: aValue at: positionIndex [
left := ((positionIndex - 1) * self spaceBetweenPoints) rounded.
center := ((positionIndex - 0.5) * self spaceBetweenPoints) rounded.
^ Morph new
extent: self coordinateSystemSize;
extent: self class coordinateSystemSize;
left: left;
width: self spaceBetweenPoints;
color: Color transparent;
balloonText: aValue printString;
addAllMorphs:
{LineMorph
from: center@0
to: center@(self coordinateSystemSize y)
to: center@(self class coordinateSystemSize y)
color: self lineColor width: self scaleLineWidth.
LineMorph
from: left@(self coordinateSystemSize y / 2)
to: (left + self spaceBetweenPoints)@(self coordinateSystemSize y / 2)
from: left@(self class coordinateSystemSize y / 2)
to: (left + self spaceBetweenPoints)@(self class coordinateSystemSize y / 2)
color: self lineColor width: self scaleLineWidth.};
yourself
]
Expand All @@ -103,7 +107,7 @@ SBRectangleChart >> newRectangleFor: aValue at: positionIndex [
color: (self rectangleColorForValue: aValue);
borderStyle: (self borderStyleFor: (scaledWidth @ scaledHeight));
left: (scaledWidth / 2) + left;
top: (self coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ;
top: (self class coordinateSystemSize y / 2) - (scaledHeight abs / 2) - (scaledHeight/2) ;
yourself

]
Expand Down Expand Up @@ -174,7 +178,7 @@ SBRectangleChart >> scaleY: aYSBScale scaleX: aXSBScale [
{ #category : #'visualization - constants' }
SBRectangleChart >> spaceBetweenPoints [

^ self coordinateSystemSize x
^ self class coordinateSystemSize x
]

{ #category : #'visualization - constants' }
Expand Down
54 changes: 14 additions & 40 deletions packages/Sandblocks-Watch/SBVisualization.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ Class {
#superclass : #SBBlock,
#instVars : [
'scaleY',
'traceValues',
'targetHeight'
'traceValues'
],
#category : #'Sandblocks-Watch'
}

{ #category : #constants }
SBVisualization class >> defaultHeight [
SBVisualization class >> canvasHeight [

^ 100 sbScaled
^ self preferredHeight - self heightMargin
]

{ #category : #constants }
SBVisualization class >> heightMargin [

^ 5 sbScaled
SBVisualization class >> heightMargin [
^ 5 sbScaled
]

{ #category : #constants }
Expand All @@ -47,13 +46,13 @@ SBVisualization class >> highlightedDataPercentage [
{ #category : #'initialize-release' }
SBVisualization class >> newWithValues: traceValues [

^ self newWithValues: traceValues havingHeight: self defaultHeight
^ self subclassResponsibility
]

{ #category : #'initialize-release' }
SBVisualization class >> newWithValues: traceValues havingHeight: aNumber [
{ #category : #constants }
SBVisualization class >> preferredHeight [

^ self subclassResponsibility
^ 100 sbScaled
]

{ #category : #conversion }
Expand Down Expand Up @@ -94,20 +93,6 @@ SBVisualization >> axisYNotation [
^ SBAxisNotation newFromScale: self scaleY ticking: 5
]

{ #category : #'visualization - constants' }
SBVisualization >> canvasHeight [

^ self targetHeight - self class heightMargin
]

{ #category : #nil }
SBVisualization >> extent: aPoint [

super extent: aPoint.
self targetHeight: aPoint.
self visualize
]

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

Expand All @@ -133,16 +118,17 @@ SBVisualization >> isTopLevel [
{ #category : #'visualization - constants' }
SBVisualization >> lineColor [

^ self foregroundColor
^ self drawnColor
]

{ #category : #visualization }
SBVisualization >> newBackground [



^ Morph new
color: self drawnColor;
width: (self traceValues size + 2 "to have some margin") * self spaceBetweenPoints;
height: self targetHeight;
height: self class preferredHeight;
borderWidth: 0;
yourself
]
Expand Down Expand Up @@ -179,18 +165,6 @@ SBVisualization >> spaceBetweenPoints [
^ 10 sbScaled
]

{ #category : #accessing }
SBVisualization >> targetHeight [

^ targetHeight ifNil: [targetHeight:= self class defaultHeight]
]

{ #category : #accessing }
SBVisualization >> targetHeight: aNumber [

targetHeight := aNumber
]

{ #category : #accessing }
SBVisualization >> traceValues [

Expand Down
Loading

0 comments on commit c88d522

Please sign in to comment.