Skip to content

Add setting to set the world renderer canvas scale factor automatically #16479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/OSWindow-Core/OSNullFormRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Class {
OSNullFormRenderer >> newExtent: anExtent [
]

{ #category : 'accessing' }
OSNullFormRenderer >> outputExtent [

^ 0@0
]

{ #category : 'updating screen' }
OSNullFormRenderer >> updateAll [
"Do nothing"
Expand Down
6 changes: 6 additions & 0 deletions src/OSWindow-Core/OSWindowFormRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ OSWindowFormRenderer >> newExtent: newExtent [
form setExtent: newExtent depth: form depth
]

{ #category : 'accessing' }
OSWindowFormRenderer >> outputExtent [

self subclassResponsibility
]

{ #category : 'accessing' }
OSWindowFormRenderer >> pixelExtent [
^ form ifNotNil: [ form extent ] ifNil: [ 1@1 ]
Expand Down
35 changes: 29 additions & 6 deletions src/OSWindow-Core/OSWorldRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@ Class {
'previousFrameRenderingTime'
],
#classInstVars : [
'canvasScaleFactor'
'canvasScaleFactor',
'autoSetCanvasScaleFactor'
],
#category : 'OSWindow-Core-Morphic',
#package : 'OSWindow-Core',
#tag : 'Morphic'
}

{ #category : 'accessing' }
OSWorldRenderer class >> autoSetCanvasScaleFactor [

^ autoSetCanvasScaleFactor ifNil: [ autoSetCanvasScaleFactor := false ]
]

{ #category : 'accessing' }
OSWorldRenderer class >> autoSetCanvasScaleFactor: boolean [

autoSetCanvasScaleFactor := boolean
]

{ #category : 'accessing' }
OSWorldRenderer class >> canvasScaleFactor [

Expand Down Expand Up @@ -54,12 +67,19 @@ OSWorldRenderer class >> settingsOn: aBuilder [

<systemsettings>

(aBuilder pickOne: #canvasScaleFactor)
(aBuilder group: #canvasScaleFactorGroup)
parent: #appearance;
label: 'Canvas scale factor for OSWorldRenderer';
target: self;
domainValues: (1 to: 5);
default: 1
label: 'World renderer canvas scaling';
with: [
(aBuilder pickOne: #canvasScaleFactor)
label: 'Canvas scale factor';
target: self;
domainValues: (1 to: 5);
default: 1.
(aBuilder setting: #autoSetCanvasScaleFactor)
label: 'Set canvas scale factor automatically';
target: self;
default: false ]
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -99,6 +119,9 @@ OSWorldRenderer >> checkForNewScreenSize [
windowRenderer := self osWindowRenderer.
windowRenderer ifNil: [ ^ self ].

(world == World and: [ self class autoSetCanvasScaleFactor ]) ifTrue: [
self class canvasScaleFactor: (windowRenderer outputExtent / self windowExtent) min * self screenScaleFactor ].

(display isNil or: [ display extent = self actualDisplaySize and: [ world worldState realWindowExtent = self actualScreenSize ] ])
ifTrue: [ ^ self ].

Expand Down
6 changes: 6 additions & 0 deletions src/OSWindow-SDL2/OSSDL2FormRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ OSSDL2FormRenderer >> initialize [
mutex := Mutex new
]

{ #category : 'accessing' }
OSSDL2FormRenderer >> outputExtent [

^ renderer outputExtent
]

{ #category : 'private' }
OSSDL2FormRenderer >> primitiveUpdateRectangle: rectangle externalForm: externalForm [

Expand Down