Skip to content

Commit

Permalink
Merge pull request #1429 from Rinzwind/pharo11-display-scale-factor
Browse files Browse the repository at this point in the history
Backport display scale factor improvements to Pharo 11
  • Loading branch information
tesonep authored Aug 7, 2023
2 parents 83be13e + 426f9df commit 353388f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
37 changes: 33 additions & 4 deletions src/Spec2-Adapters-Morphic/SpFontStyle.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Class {
'color'
],
#classVars : [
'ApplyDisplayScaleFactor',
'FontCache'
],
#category : #'Spec2-Adapters-Morphic-StyleSheet'
Expand All @@ -65,6 +66,18 @@ SpFontStyle class >> addFontToCache: aFont [
self fontCache add: aFont
]

{ #category : #accessing }
SpFontStyle class >> applyDisplayScaleFactor [

^ ApplyDisplayScaleFactor ifNil: [ true ]
]

{ #category : #accessing }
SpFontStyle class >> applyDisplayScaleFactor: aBoolean [

ApplyDisplayScaleFactor := aBoolean
]

{ #category : #private }
SpFontStyle class >> fontCache [

Expand Down Expand Up @@ -92,6 +105,12 @@ SpFontStyle >> anyFontDecorator [
or: [ italic notNil ] ] ]
]

{ #category : #private }
SpFontStyle >> applyDisplayScaleFactor [

^ self class applyDisplayScaleFactor
]

{ #category : #operations }
SpFontStyle >> applyTo: aMorph [

Expand Down Expand Up @@ -155,11 +174,11 @@ SpFontStyle >> calculateFontSize [

self sizeVariable ifNotNil: [ :aVariable |
aVariable value ifNotNil: [
^ self sizeVariable scaledValue ] ].
^ self scaledSize ] ].
self nameVariable isEnvironmentVariable ifTrue: [
^ self nameVariable pointSize * self currentWorld displayScaleFactor ].
^ self nameVariable pointSize * self displayScaleFactor ].
self hasPredefinedFont ifTrue: [
^ self obtainPredefinedFont pointSize * self currentWorld displayScaleFactor ].
^ self obtainPredefinedFont pointSize * self displayScaleFactor ].

^ nil
]
Expand Down Expand Up @@ -206,6 +225,14 @@ SpFontStyle >> definedFont [
^ definedFont
]

{ #category : #private }
SpFontStyle >> displayScaleFactor [

^ self applyDisplayScaleFactor
ifTrue: [ self currentWorld displayScaleFactor ]
ifFalse: [ 1 ]
]

{ #category : #private }
SpFontStyle >> hasPredefinedFont [

Expand Down Expand Up @@ -305,7 +332,9 @@ SpFontStyle >> predefinedFont: aSymbol [
{ #category : #accessing }
SpFontStyle >> scaledSize [

^ self sizeVariable scaledValue
^ self applyDisplayScaleFactor
ifTrue: [ self sizeVariable scaledValue ]
ifFalse: [ self sizeVariable nonscaledValue ]
]

{ #category : #accessing }
Expand Down
8 changes: 7 additions & 1 deletion src/Spec2-Adapters-Morphic/SpStyleAbstractVariable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ SpStyleAbstractVariable >> isResetVariable [
^ false
]

{ #category : #evaluating }
SpStyleAbstractVariable >> nonscaledValue [

^ self value
]

{ #category : #evaluating }
SpStyleAbstractVariable >> preferredScaledValueWith: anObject [

Expand All @@ -40,7 +46,7 @@ SpStyleAbstractVariable >> preferredValueWith: anObject [
{ #category : #evaluating }
SpStyleAbstractVariable >> scaledValue [

^ self value
^ self nonscaledValue
]

{ #category : #evaluating }
Expand Down
8 changes: 7 additions & 1 deletion src/Spec2-Adapters-Morphic/SpStyleVariable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ SpStyleVariable class >> stonName [
^ 'Variable'
]

{ #category : #evaluating }
SpStyleVariable >> nonscaledValue [

^ self value ifNil: [ 0 ]
]

{ #category : #evaluating }
SpStyleVariable >> preferredScaledValueWith: anObject [

Expand All @@ -44,7 +50,7 @@ SpStyleVariable >> preferredValueWith: anObject [
{ #category : #evaluating }
SpStyleVariable >> scaledValue [

^ (self value ifNil: [ 0 ]) * self currentWorld displayScaleFactor
^ self nonscaledValue * self currentWorld displayScaleFactor
]

{ #category : #private }
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpIconAndLabelToolbarDisplayMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SpIconAndLabelToolbarDisplayMode >> configureButton: aButton item: aToolbarItem

{ #category : #accessing }
SpIconAndLabelToolbarDisplayMode >> extent [
^ 45@45
^ (45@45) scaledByDisplayScaleFactor
]

{ #category : #printing }
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpIconToolbarDisplayMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SpIconToolbarDisplayMode >> configureButton: aButton item: aToolbarItem [
{ #category : #accessing }
SpIconToolbarDisplayMode >> extent [

^ 30@30
^ (30@30) scaledByDisplayScaleFactor
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Spec2-Core/SpLabelToolbarDisplayMode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SpLabelToolbarDisplayMode >> configureButton: aButton item: aToolbarItem [

{ #category : #accessing }
SpLabelToolbarDisplayMode >> extent [
^ 45@25
^ (45@25) scaledByDisplayScaleFactor
]

{ #category : #accessing }
Expand Down

0 comments on commit 353388f

Please sign in to comment.