[Pkg] The Trunk: Graphics-mt.524.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed Jun 22 09:47:43 UTC 2022
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!
More information about the Packages
mailing list