The Trunk: System-mt.1102.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: System-mt.1102.mcz

commits-2
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1102.mcz

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

Name: System-mt.1102
Author: mt
Time: 29 September 2019, 6:09:57.735524 pm
UUID: 47e87e3c-e6c2-894e-941e-4d60407bf49b
Ancestors: System-mt.1101

Adds a simple, yet convenient, way to scale icons for demo/hi-dpi mode.

A no-scale takes about 150 nanoseconds on my machine, which should be okay --- performance-wise --- for existing tools. Maybe we can improve the code a little bit more for the default scale.

Note that one could also use icons with s higher resolution, which would then be down-scaled to the reference extent...

=============== Diff against System-mt.1101 ===============

Item was added:
+ ----- Method: Form>>scaleIconToDisplay (in category '*System-icon scaling') -----
+ scaleIconToDisplay
+ "Convenient way to scale icons up or down to match the current display scale factor. For performance reasons, does not return a copy if there is no scaling of the receiver necessary."
+
+ | scaleFactor referenceExtent |
+ scaleFactor := RealEstateAgent scaleFactor.
+ referenceExtent := RealEstateAgent defaultIconExtent.
+
+ "Scale down bigger icons to match the (scaled) reference extent. So you can use high-resolution icons that do not appear blurry."
+ self extent > referenceExtent ifTrue: [
+ ^ scaleFactor > 1.0
+ ifFalse: [self scaledToSize: referenceExtent]
+ ifTrue: [self scaledToSize: (((referenceExtent * scaleFactor) roundTo: 8) min: self extent)]].
+
+ "Scale up smaller icons."
+ ^ scaleFactor = 1.0
+ ifTrue: [self "Smaller than the default is okay if no scaling."]
+ ifFalse: [self scaledToSize: self extent * scaleFactor]!

Item was added:
+ ----- Method: RealEstateAgent class>>defaultIconExtent (in category 'display scale') -----
+ defaultIconExtent
+ "Scaling. Like in #scaleFactor, we need a reference extent for scaling icons."
+
+ ^ 16@16!

Item was changed:
+ ----- Method: RealEstateAgent class>>scaleFactor (in category 'display scale') -----
- ----- Method: RealEstateAgent class>>scaleFactor (in category 'framing') -----
  scaleFactor
  "Use the default font height to calculate some factor. Better than nothing..."
 
  ^ (TextStyle defaultFont height / 14 "reference value") * (Preferences bigDisplay ifTrue: [1.75] ifFalse: [1.0])!