[squeak-dev] The Trunk: Graphics-mt.524.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Wed Jun 22 10:04:41 UTC 2022


Ah, finally! :D I think that Kent Beck at some point recommended not to define too many conversion messages, especially for very short and potentially misunderstandable selectors like these, but on the other hand, I am just happy about the improved convenience.


Note that once we use this protocol consistently, the dependency browser and the dependency tests will no longer inform us about all dependencies to the Graphics package. Or am I wrong?


Best,

Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von commits at source.squeak.org <commits at source.squeak.org>
Gesendet: Mittwoch, 22. Juni 2022 11:47:43
An: squeak-dev at lists.squeakfoundation.org; packages at lists.squeakfoundation.org
Betreff: [squeak-dev] The Trunk: Graphics-mt.524.mcz

Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.524.mcz

==================== Summary ====================

Name: Graphics-mt.524
Author: mt
Time: 22 June 2022, 11:47:35.985723 am
UUID: fc41bc62-0b72-a14f-999b-12d64a0a0cff
Ancestors: Graphics-mt.523

Document programming model for scale-factor-aware applications.

Note that this is not yet used throughout the system. However, applications written for Squeak 6.0 should be able to look as elegant as possible.

=============== Diff against Graphics-mt.523 ===============

Item was added:
+ ----- Method: Number>>em (in category '*Graphics-scale factor') -----
+ em
+        "Convert the receiver from multiples of width-of-capital-letter-M to pixels using the system's default font. Works also with pre-rendered fonts."
+
+        ^ (self * (TextStyle defaultFont widthOf: $M)) rounded!

Item was added:
+ ----- Method: Number>>ex (in category '*Graphics-scale factor') -----
+ ex
+        "Convert the receiver from multiples of x-height-of-font to pixels using the system's default TrueType font."
+
+        | tt |
+        tt := TextStyle defaultTTFont ttcDescription.
+        ^ (self asFloat
+                * (tt xHeight asFloat / tt unitsPerEm)
+                * (TextStyle defaultFont widthOf: $M)) rounded!

Item was added:
+ ----- Method: Number>>pt (in category '*Graphics-scale factor') -----
+ pt
+        "Convert the receiver from points to pixels. Note that this will not work correctly for 'faked' scale factors where larger (pre-rendered) fonts are used instead of adjusting the system's current ppi value."
+
+        ^ (TextStyle pointsToPixels: self) rounded
+
+ "
+ (TextStyle pixelsPerInch = 96.0 ifTrue: [
+        | extra |
+        extra := TextStyle defaultFont pointSize / TTCFont referencePointSize.
+        ^ (TextStyle pointsToPixels: self * extra) rounded]
+ "!

Item was added:
+ ----- Method: Number>>px (in category '*Graphics-scale factor') -----
+ px
+        "Convert the receiver representing raw pixels at 100% (96ppi) to the current scale factor. Note that you currently have to do this manually for all graphics-related properties and layout-specific measures such as #borderWidth: and #layoutInset:. Only for model windows (see #initialExtent) that are no dialogs, that scaling will happen automatically in ToolBuilder."
+
+        self flag: #discuss. "mt: For self > 4, I would recommend #rounded instead of #truncated. For smaller values, however, rounding makes no sense because we have no sub-pixel access and things would look too big too soon."
+        ^ (self * RealEstateAgent scaleFactor) truncated!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220622/ebd47c1e/attachment.html>


More information about the Squeak-dev mailing list