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

Marcel Taeumel marcel.taeumel at hpi.de
Wed Jun 22 10:44:35 UTC 2022


Hi Christoph --

> 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 [...]

Well, the next step for *you* would be to actually apply those best practices to any particular domain to then reason about possible next steps. Without proper application to concrete domains/scenarios, you are omitting to verify that you actually found a fitting best practice.

Personally, I do not think that the one you quoted fits here. Neither "too many conversion messages" nor "potentially misunderstandable selectors". #px, #pt, #em, and #ex sitting in "*Graphics-scale factor" have a clear relationship to Web development and CSS. I am confident that many if not most users will understand.

I will add an extra note to only use #ex and #em if really necessary. Yet, it makes sense to connect those concepts to the underlying system. At least from a documentation perspective.

 > 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?

I am sure that you know other ways to track usage of such rather uncommon selectors... ;-P Not sure in which kind of scenarios you want to unload "Graphics". This is clearly a different topic.

Best,
Marcel
Am 22.06.2022 12:04:52 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
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 [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/31e012e6/attachment.html>


More information about the Squeak-dev mailing list