Skip to content

Commit

Permalink
introduce World displayScaleFactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed May 29, 2018
1 parent dcd5ce9 commit 0b3ddf1
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/Glamour-Morphic-Brick-Tests/GLMBrickTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ GLMBrickTests >> staticExtent [
{ #category : #defaults }
GLMBrickTests >> staticHeight [

^ 100
^ 100 * World displayScaleFactor
]

{ #category : #defaults }
Expand All @@ -150,19 +150,19 @@ GLMBrickTests >> staticSmallExtent [
{ #category : #defaults }
GLMBrickTests >> staticSmallHeight [

^ 50
^ 50 * World displayScaleFactor
]

{ #category : #defaults }
GLMBrickTests >> staticSmallWidth [

^ 50
^ 50 * World displayScaleFactor
]

{ #category : #defaults }
GLMBrickTests >> staticWidth [

^ 100
^ 100 * World displayScaleFactor
]

{ #category : #'tests-layouter' }
Expand Down
2 changes: 1 addition & 1 deletion src/Glamour-Morphic-Brick/GLMBrickButtonStyle.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GLMBrickButtonStyle >> buttonBorderWidth [
{ #category : #'brick-button' }
GLMBrickButtonStyle >> buttonMinHeight [

^ 26
^ 26 * World displayScaleFactor
]

{ #category : #'brick-button' }
Expand Down
2 changes: 1 addition & 1 deletion src/Glamour-Morphic-Brick/GLMBrickStructureTrait.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ GLMBrickStructureTrait >> openInBrickWindowLabeled: aLabel [
hSpaceFill;
addBrickBack: self;
yourself);
extent: 400@400;
extent: (400@400) * World displayScaleFactor;
openCenteredInWorld ]
ifAbsent: [ self asMorph openInWindow ]

Expand Down
7 changes: 7 additions & 0 deletions src/Graphics-Display Objects/Form.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2293,6 +2293,13 @@ f display
"
]

{ #category : #'scaling, rotation' }
Form >> scaledByDisplayScaleFactor [

^ self scaledToSize: self extent * World displayScaleFactor.

]

{ #category : #'scaling, rotation' }
Form >> scaledToSize: newExtent [

Expand Down
2 changes: 1 addition & 1 deletion src/Morphic-Base/MenuLineMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ MenuLineMorph >> minHeight [
{ #category : #layout }
MenuLineMorph >> minWidth [
"Answer the receiver's minWidth"
^ 10
^ 10 * self displayScaleFactor
]
4 changes: 2 additions & 2 deletions src/Morphic-Base/MenuTitleMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MenuTitleMorph >> bigTitle: aTitle [
{ #category : #'private-creation' }
MenuTitleMorph >> boxExtent [

^18 @ 18
^ (18 @ 18) * self displayScaleFactor
]

{ #category : #'event handling' }
Expand Down Expand Up @@ -207,7 +207,7 @@ MenuTitleMorph >> withPinBox [

pinBox := self
iconButtonCalling: #pinBoxClicked
withForm: self pinForm
withForm: self pinForm scaledByDisplayScaleFactor
helpText: 'Keep this menu up'.

self addMorph: pinBox asElementNumber: 4
Expand Down
10 changes: 5 additions & 5 deletions src/Morphic-Base/ToggleMenuItemMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ ToggleMenuItemMorph >> basicDrawOn: aCanvas [
self hasIcon ifTrue: [ |iconForm|
iconForm := self icon.
self drawIcon: iconForm on: aCanvas in: stringBounds.
stringBounds := stringBounds left: stringBounds left + iconForm width + 2].
stringBounds := stringBounds left: stringBounds left + (iconForm width) + (2*self displayScaleFactor)].
self hasMarker ifTrue: [
stringBounds := stringBounds left: stringBounds left + self submorphBounds width + 8].
stringBounds := stringBounds left: stringBounds left + self submorphBounds width + (8 * self displayScaleFactor)].
stringBounds := stringBounds top: stringBounds top + stringBounds bottom - self fontToUse height // 2.
stringBounds := stringBounds bottom: stringBounds top + self fontToUse height.
self drawText: contents on: aCanvas in: stringBounds.
Expand All @@ -71,7 +71,7 @@ ToggleMenuItemMorph >> drawIcon: aForm on: aCanvas in: aRectangle [

|iconForm|
self isEnabled
ifTrue: [iconForm := aForm]
ifTrue: [iconForm := aForm.]
ifFalse: [iconForm := Form extent: aForm extent depth: 32.
iconForm fillColor: (Color white alpha: 0.003922).
(iconForm getCanvas asAlphaBlendingCanvas: 0.5)
Expand Down Expand Up @@ -105,8 +105,8 @@ ToggleMenuItemMorph >> drawSubMenuMarker: aForm on: aCanvas in: aRectangle [
"Draw the submenu marker on the canvas within the given bounds."

|markerRect|
markerRect := aRectangle topRight + (aForm width negated @ (aRectangle height - aForm height // 2)) extent: aForm extent.
self drawIcon: aForm on: aCanvas in: markerRect
markerRect := aRectangle topRight + ((aForm width * self displayScaleFactor) negated @ (aRectangle height - (aForm height * self displayScaleFactor) // 2)) extent: aForm extent * self displayScaleFactor.
self drawIcon: aForm scaledByDisplayScaleFactor on: aCanvas in: markerRect
]

{ #category : #'drawing-private' }
Expand Down
6 changes: 6 additions & 0 deletions src/Morphic-Core/Morph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2178,6 +2178,12 @@ Morph >> displayExtentChanged [
"
]

{ #category : #settings }
Morph >> displayScaleFactor [

^ World displayScaleFactor
]

{ #category : #announcements }
Morph >> doAnnounce: anAnnouncement [
"Take care of not creating the announcer when announcing. If the announcer doesn't exist then this means nobody has expressed an interest in the message."
Expand Down
7 changes: 7 additions & 0 deletions src/Morphic-Core/Point.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : #Point }

{ #category : #'*Morphic-Core' }
Point >> scaledByDisplayScaleFactor [

^ self * World displayScaleFactor.
]
6 changes: 6 additions & 0 deletions src/Morphic-Core/WorldMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ WorldMorph >> discoveredWorldMenu [
^ worldState discoveredWorldMenu
]

{ #category : #geometry }
WorldMorph >> displayScaleFactor [

^ 1
]

{ #category : #'world state' }
WorldMorph >> displayWorld [
worldState displayWorld: self submorphs: submorphs
Expand Down
2 changes: 1 addition & 1 deletion src/Morphic-Widgets-Taskbar/TaskListMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TaskListMorph >> addMorphs [
TaskListMorph >> defaultPreviewExtent [
"Answer the default extent of the preview holder."

^320@320
^(320@320)scaledByDisplayScaleFactor
]

{ #category : #running }
Expand Down
6 changes: 3 additions & 3 deletions src/Morphic-Widgets-Windows/SystemWindow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ SystemWindow >> boxExtent [
"answer the extent to use in all the buttons.
The label height is used to be proportional to the standard window label font"

label ifNil: [^14 @ 14].
^ (14 @ 14) max: label height @ label height
label ifNil: [^(14 @ 14) * self displayScaleFactor].
^ (((14 @ 14) * self displayScaleFactor) max: label height @ label height)
]

{ #category : #testing }
Expand Down Expand Up @@ -882,7 +882,7 @@ SystemWindow >> initialize [
self cellPositioning: #topLeft. "make the offsets easy to calculate!"
self addGripsIfWanted.

self extent: 300 @ 200.
self extent: (300 @ 200) scaledByDisplayScaleFactor.
mustNotClose := false.
updatablePanes := Array new
]
Expand Down
2 changes: 1 addition & 1 deletion src/NautilusCommon/NautilusWindow.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ NautilusWindow >> hasFocus [

{ #category : #'open/close' }
NautilusWindow >> initialExtent [
^ 850@620
^ (850@620) * self displayScaleFactor
]
2 changes: 1 addition & 1 deletion src/Pharo-Help/PharoWelcomePage.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PharoWelcomePage class >> openForRelease [
detect: [ :each | (each isKindOf: SystemWindow) and: [ each label = self title ] ]
ifFound: [ :oldWindow | oldWindow delete ].
window := self open.
window extent: 750@400.
window extent: (750@400) scaledByDisplayScaleFactor.
window center: Display extent / 2
]

Expand Down
2 changes: 1 addition & 1 deletion src/Polymorph-Widgets/PharoDarkTheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ PharoDarkTheme >> menuBorderColor [

{ #category : #'accessing colors' }
PharoDarkTheme >> menuBorderWidth [
^ self borderWidth
^ self borderWidth * World displayScaleFactor
]

{ #category : #defaults }
Expand Down
4 changes: 2 additions & 2 deletions src/Polymorph-Widgets/ThemeIcons.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ ThemeIcons >> hasIcons [

{ #category : #accessing }
ThemeIcons >> iconNamed: aSymbol [
^ self
^ (self
iconNamed: aSymbol
ifNone: [
self isReportingNotFound
ifTrue: [
self crLog: (aSymbol, ' icon not found!').
self notFoundIcon ]
ifFalse: [ self blankIcon ]]
ifFalse: [ self blankIcon ]]) scaledByDisplayScaleFactor
]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Polymorph-Widgets/ThemeSettings.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ ThemeSettings >> menuBorderColor [
ThemeSettings >> menuBorderWidth [
"Answer the value of menuColor"

^ 2
^ 2 * World displayScaleFactor
]

{ #category : #menu }
Expand Down
36 changes: 18 additions & 18 deletions src/Polymorph-Widgets/UITheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ UITheme >> borderColor [

{ #category : #accessing }
UITheme >> borderWidth [
^ 1
^ 1 * World displayScaleFactor
]

{ #category : #accessing }
Expand Down Expand Up @@ -502,7 +502,7 @@ UITheme >> buttonMiddleRightForm [
UITheme >> buttonMinHeight [
"Answer the minumum height of a button for this theme."

^24
^24 * World displayScaleFactor
]

{ #category : #defaults }
Expand Down Expand Up @@ -4793,7 +4793,7 @@ UITheme >> radioButtonForm [
UITheme >> radioButtonMarkerForm [
"Answer the form to use for a radio button marker."

^self forms at: #radioButtonMarker ifAbsent: [Form extent: 12@12 depth: Display depth]
^(self forms at: #radioButtonMarker ifAbsent: [Form extent: 12@12 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'border-styles-buttons' }
Expand Down Expand Up @@ -5673,7 +5673,7 @@ UITheme >> textFont [
UITheme >> treeExpandedForm [
"Answer the form to use for an expanded tree item."

^self forms at: #treeExpanded ifAbsent: [Form extent: 10@9 depth: Display depth]
^(self forms at: #treeExpanded ifAbsent: [Form extent: 10@9 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'basic-colors' }
Expand Down Expand Up @@ -5702,7 +5702,7 @@ UITheme >> treeLineWidth [
UITheme >> treeUnexpandedForm [
"Answer the form to use for an unexpanded tree item."

^self forms at: #treeUnexpanded ifAbsent: [Form extent: 10@9 depth: Display depth]
^(self forms at: #treeUnexpanded ifAbsent: [Form extent: 10@9 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'accessing colors' }
Expand Down Expand Up @@ -5806,28 +5806,28 @@ UITheme >> watcherWindowInactiveFillStyleFor: aWindow [
UITheme >> whiteTreeExpandedForm [
"Answer the form to use for an expanded tree item when a contrasting one is needed."

^self forms
^(self forms
at: #whiteTreeExpanded
ifAbsent: [ | f |
f := self treeExpandedForm deepCopy.
f replaceColor: Color white withColor: Color transparent.
(f colorsUsed reject: [:c | c isTransparent]) do: [:c | f replaceColor: c withColor: c whiter whiter whiter whiter whiter whiter].
self forms at: #whiteTreeExpanded put: f.
self whiteTreeExpandedForm]
self whiteTreeExpandedForm]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
UITheme >> whiteTreeUnexpandedForm [
"Answer the form to use for an unexpanded tree item when a contrasting one is needed."

^self forms
^(self forms
at: #whiteTreeUnexpanded
ifAbsent: [ | f |
f := self treeUnexpandedForm deepCopy.
f replaceColor: Color white withColor: Color transparent.
(f colorsUsed reject: [:c | c isTransparent]) do: [:c | f replaceColor: c withColor: c whiter whiter whiter whiter whiter whiter].
self forms at: #whiteTreeUnexpanded put: f.
self whiteTreeUnexpandedForm]
self whiteTreeUnexpandedForm]) scaledByDisplayScaleFactor
]

{ #category : #'border-styles' }
Expand Down Expand Up @@ -5875,7 +5875,7 @@ UITheme >> windowActiveTitleFillStyleFor: aWindow [
{ #category : #defaults }
UITheme >> windowBorderWidthFor: aWindow [

^ 4
^ 4 * World displayScaleFactor
]

{ #category : #defaults }
Expand All @@ -5888,14 +5888,14 @@ UITheme >> windowBottomOffset [
UITheme >> windowCloseForm [
"Answer the form to use for the close button of a window."

^self forms at: #windowClose ifAbsent: [Form extent: 10@10 depth: Display depth]
^(self forms at: #windowClose ifAbsent: [Form extent: 10@10 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
UITheme >> windowCloseOverForm [
"Answer the form to use for mouse over window close buttons"

^self forms at: #windowCloseOver ifAbsent: [Form extent: 16@16 depth: Display depth]
^(self forms at: #windowCloseOver ifAbsent: [Form extent: 16@16 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
Expand Down Expand Up @@ -6018,14 +6018,14 @@ UITheme >> windowLeftOffset [
UITheme >> windowMaximizeForm [
"Answer the form to use for the maximize button of a window."

^self forms at: #windowMaximize ifAbsent: [Form extent: 10@10 depth: Display depth]
^(self forms at: #windowMaximize ifAbsent: [Form extent: 10@10 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
UITheme >> windowMaximizeOverForm [
"Answer the form to use for mouse over window maximize buttons"

^self forms at: #windowMaximizeOver ifAbsent: [Form extent: 16@16 depth: Display depth]
^(self forms at: #windowMaximizeOver ifAbsent: [Form extent: 16@16 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
Expand All @@ -6046,7 +6046,7 @@ UITheme >> windowMaximizeSound [
UITheme >> windowMenuForm [
"Answer the form to use for the menu button of a window."

^self forms at: #windowMenu ifAbsent: [Form extent: 10@10 depth: Display depth]
^(self forms at: #windowMenu ifAbsent: [Form extent: 10@10 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
Expand All @@ -6060,7 +6060,7 @@ UITheme >> windowMenuIconFor: aWindow [
UITheme >> windowMenuOverForm [
"Answer the form to use for mouse over window menu buttons"

^self forms at: #windowMenuOver ifAbsent: [Form extent: 16@16 depth: Display depth]
^(self forms at: #windowMenuOver ifAbsent: [Form extent: 16@16 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
Expand All @@ -6074,14 +6074,14 @@ UITheme >> windowMenuPassiveForm [
UITheme >> windowMinimizeForm [
"Answer the form to use for the minimize button of a window."

^self forms at: #windowMinimize ifAbsent: [Form extent: 10@10 depth: Display depth]
^(self forms at: #windowMinimize ifAbsent: [Form extent: 10@10 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
UITheme >> windowMinimizeOverForm [
"Answer the form to use for mouse over window minimize buttons"

^self forms at: #windowMinimizeOver ifAbsent: [Form extent: 16@16 depth: Display depth]
^(self forms at: #windowMinimizeOver ifAbsent: [Form extent: 16@16 depth: Display depth]) scaledByDisplayScaleFactor
]

{ #category : #'label-styles' }
Expand Down

0 comments on commit 0b3ddf1

Please sign in to comment.