[squeak-dev] The Trunk: MorphicExtras-mt.301.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Dec 3 17:55:46 UTC 2021
Marcel Taeumel uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-mt.301.mcz
==================== Summary ====================
Name: MorphicExtras-mt.301
Author: mt
Time: 3 December 2021, 6:55:43.28976 pm
UUID: 21c1ec08-2286-9044-995d-b6ec56c1903c
Ancestors: MorphicExtras-mt.300
Fixes the pointer rotation in all kinds of RotaryDialMorph.
Well, it rather is a workaround. The culprit is ThermometerDialMorph >> #adjustAfter:. I think it is an interference between the relative position of the ImageMorph within the TransformationMorph and the #rotationCenter of that ImageMorph, which was always 0.5 at 0.5 before this change.
=============== Diff against MorphicExtras-mt.300 ===============
Item was changed:
----- Method: BarometerMorph>>initialize (in category 'initialize-release') -----
initialize
"assemble a nice barometer morph. The background is an ImageMorph with scale/dial drawn with code adapted from a generous donation of time and effort by Bob Arning; similarly for the needle"
| pointerMorph |
super initialize.
"set up as a barometer type display; running clockwise with increasing values.
A decent range for a barometer is 950mB to 1050mB; it covers most plausible weather and matches decently with an additional inches-of-Hg scale going from 28 to 31.
28in. -> 948mB and 31in. -> 1050 (to enough accuracy for a screen based widget) so we need a small tweak at the lower end of the dial. If we aim initially for 150deg each side of north we have 3deg per milliBar; to accomodate the extra 2mB we can add 6deg at the low end, which makes 1000mB sit nicely at due north.
So we will use angles of -156 to 150 and values of 948 to 1050 as our limits."
self startAngle: -156 stopAngle: 150;
startValue: 948 stopValue: 1050.
+ self extent: self initialExtent; color: Color transparent; borderWidth: 0.
- self extent: 200 at 200; color: Color transparent; borderWidth: 0.
dialCenter := self center.
"build the dial background. This is amazingly complex to think about programmatically; this example is fairly hard-coded by hand but somebody out there almost certainly has ideas about parameterizing this to amke a nice general utility"
self buildDial.
"build our fancy needle as an ImageMorph, set the position to horizontal centre and about 2/3 down so that it rotates about that point when inside the TransformationMorph"
pointerMorph := self fancyNeedleOfLength: (self height * 0.65) rounded.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -0.65);
+ rotationCenter: 0.5 @ 0.65.
- pointerMorph position: pointerMorph extent * ( -0.5@ -0.65).
"we keep track of the TransformationMorph since that is what we have to rotate as the incoming pressure values change"
needleMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: needleMorph.
"Add the simpler needle used to indicate the prior 'remembered' reading; we will make a click update it to the current value"
pointerMorph := self simpleNeedleOfLength: (self height * 0.35) rounded color: (Color r: 16rFF g: 16rD7 b: 16r0 range: 512).
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -1);
+ rotationCenter: 0.5 @ 1.
- pointerMorph position: pointerMorph extent * ( -0.5@ -1).
priorPressureIndicator := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: priorPressureIndicator.
"add a central near-to-gold colored dot. Because we just do."
self addMorph: (CircleMorph new extent: 20 at 20; color: (Color r: 16rFF g: 16rD7 b: 16r0 range: 256); center: dialCenter)
!
Item was changed:
----- Method: ClockDialMorph>>initialize (in category 'initialization') -----
initialize
"assemble a nice clock morph. The background is an ImageMorph with scale/dial drawn with code adapted from a generous donation of time and effort by Bob Arning; the minute needle is the inherited needleMorph and we added a new hourHandMorph. Both are simple rectangleMorphs"
| pointerMorph |
super initialize.
self startAngle: 0 stopAngle: 360;
startValue: 0 stopValue: 360.
+ self extent: self initialExtent; color: Color transparent; borderWidth: 0.
- self extent: 200 at 200; color: Color transparent; borderWidth: 0.
dialCenter := self center.
"build the dial background; basic clock with miute ticks and hour long-ticks + arabic numerals"
self buildDial.
pointerMorph := self basicNeedleOfLength: (self height * 0.45) rounded width: 4 color: Color red.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -1);
+ rotationCenter: 0.5 @ 1.
- pointerMorph position: pointerMorph extent * ( -0.5@ -1).
"we keep track of the TransformationMorph since that is what we have to rotate"
needleMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: needleMorph.
"additional neelde for the hours"
pointerMorph := self basicNeedleOfLength: (self height * 0.35) rounded width: 6 color: Color black.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -1);
+ rotationCenter: 0.5 @ 1.
- pointerMorph position: pointerMorph extent * ( -0.5@ -1).
"we keep track of the TransformationMorph since that is what we have to rotate"
hourHandMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: hourHandMorph.
"add a central colored dot. Because we just do."
self addMorph: (CircleMorph new extent: 8 at 8; color: Color red twiceDarker; center: dialCenter)
!
Item was changed:
----- Method: CompassDialMorph>>initialize (in category 'initialize-release') -----
initialize
"assemble a nice compass morph. The background is an ImageMorph with scale/dial drawn with code adapted from a generous donation of time and effort by Bob Arning; similarly for the needle"
| pointerMorph |
super initialize.
"A compass runs from 0 deg to 360, clockwise. Traditional compass roses can be very ornate."
self startAngle: 0 stopAngle: 360;
startValue: 0 stopValue: 360.
+ self extent: self initialExtent; color: Color transparent; borderWidth: 0.
- self extent: 200 at 200; color: Color transparent; borderWidth: 0.
dialCenter := self center.
"build the dial background. This is amazingly complex to think about programmatically; this example is fairly hard-coded by hand but somebody out there almost certainly has ideas about parameterizing this to amke a nice general utility"
self buildDial.
"build our fancy needle as an ImageMorph, set the position to horizontal centre and about 2/3 down so that it rotates about that point when inside the TransformationMorph"
pointerMorph := self basicNeedleOfLength: (self height * 0.65) rounded width: 10 color: Color red.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -0.5);
+ rotationCenter: 0.5 @ 0.5.
- pointerMorph position: pointerMorph extent * ( -0.5@ -0.5).
"we keep track of the TransformationMorph since that is what we have to rotate as the incoming pressure values change"
needleMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: needleMorph.
"add a central colored dot. Because we just do."
self addMorph: (CircleMorph new extent: 20 at 20; color: Color red twiceDarker; center: dialCenter)
!
Item was changed:
----- Method: HygrometerDialMorph>>initialize (in category 'initialize-release') -----
initialize
"Build a hygrometer. The background is an ImageMorph showing a dial derived from the same general principles as the BarometerMorph. "
| pointerMorph |
super initialize.
self startAngle: -140 stopAngle: 140;
startValue: 0 stopValue: 100.
+ self extent: self initialExtent; color: Color transparent; borderWidth: 0.
- self extent: 200 at 200; color: Color transparent; borderWidth: 0.
dialCenter := self center.
self buildDial.
"build our fancy needle as an ImageMorph, set the position to horizontal centre and about 2/3 down so that it rotates about that point when inside the TransformationMorph"
pointerMorph := self fancyNeedleOfLength: (self height * 0.65) rounded.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -0.65);
+ rotationCenter: 0.5 @ 0.65.
- pointerMorph position: pointerMorph extent * ( -0.5@ -0.65).
"we keep track of the TransformationMorph since that is what we have to rotate as the incoming pressure values change"
needleMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: needleMorph.
"add a central colored dot. Because we just do."
self addMorph: (CircleMorph new extent: 20 at 20; color: Color black; center: dialCenter)
!
Item was added:
+ ----- Method: RotaryDialMorph>>initialExtent (in category 'initialize-release') -----
+ initialExtent
+
+ ^ ((200 at 200) * RealEstateAgent scaleFactor) rounded!
Item was changed:
----- Method: ThermometerDialMorph>>initialize (in category 'initialize-release') -----
initialize
"Build a thermometer. The background is an ImageMorph showing a dial derived from the same general principles as the BarometerMorph.
The temperature scale is fixed for now at -5C to 30C but ought to be parameterised someday. We'll have the Celcius scale as the inner and a conversion to Fahrenheit as the outer"
| pointerMorph |
super initialize.
self startAngle: -140 stopAngle: 140;
startValue: -10 stopValue: 35.
+ self extent: self initialExtent; color: Color transparent; borderWidth: 0.
- self extent: 200 at 200; color: Color transparent; borderWidth: 0.
dialCenter := self center.
self buildDial.
"build our fancy needle as an ImageMorph, set the position to horizontal centre and about 2/3 down so that it rotates about that point when inside the TransformationMorph"
pointerMorph := self fancyNeedleOfLength: (self height * 0.65) rounded.
+ pointerMorph
+ position: pointerMorph extent * ( -0.5@ -0.65);
+ rotationCenter: 0.5 @ 0.65.
- pointerMorph position: pointerMorph extent * ( -0.5@ -0.65).
"we keep track of the TransformationMorph since that is what we have to rotate as the incoming pressure values change"
needleMorph := TransformationMorph new position: dialCenter; addMorph: pointerMorph.
self addMorph: needleMorph.
"add a central colored dot. Because we just do."
self addMorph: (CircleMorph new extent: 20 at 20; color: Color black; center: dialCenter)
!
More information about the Squeak-dev
mailing list
|