diff --git a/Jenkinsfile b/Jenkinsfile index f47e0ba17fe..8d37bd90e81 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -183,6 +183,7 @@ def bootstrapImage(){ isoTesters['SUnit'] = { defineIsoTestStage("SUnit", "SUnit", "Tests", "\'SUnit-Tests\' \'SUnit-Visitor-Tests\' \'SUnit-MockObjects-Tests\'") } isoTesters['Kernel'] = { defineIsoTestStage("Kernel", "Kernel", "Tests", "\'Kernel-Tests\' \'Kernel-CodeModel-Tests\'") } isoTesters['Compiler'] = { defineIsoTestStage("Compiler", "Compiler", "Tests", "\'OpalCompiler-Tests\' \'DebugInfo-Tests\' \'Kernel-Extended-Tests\' \'Kernel-Tests-WithCompiler\'") } + isoTesters['OSWindow'] = { defineIsoTestStage("OSWindow", "OSWindow", "Tests", "\'OSWindow-Tests\'") } parallel isoTesters stage ("Full Image") { diff --git a/src/BaselineOfOSWindow/BaselineOfOSWindow.class.st b/src/BaselineOfOSWindow/BaselineOfOSWindow.class.st index d3221d082f4..b25fc30a228 100644 --- a/src/BaselineOfOSWindow/BaselineOfOSWindow.class.st +++ b/src/BaselineOfOSWindow/BaselineOfOSWindow.class.st @@ -11,11 +11,12 @@ BaselineOfOSWindow >> baseline: spec [ spec for: #'common' do: [ spec package: 'OSWindow-Core'; - package: 'OSWindow-SDL2'; - package: 'OSWindow-SDL2-Examples'; - package: 'OSWindow-Tests'. + package: 'OSWindow-Morphic' with: [ spec requires: #( 'OSWindow-Core' ) ]; + package: 'OSWindow-SDL2' with: [ spec requires: #( 'OSWindow-Core' ) ]; + package: 'OSWindow-SDL2-Examples' with: [ spec requires: #( 'OSWindow-Core' 'OSWindow-SDL2' ) ]; + package: 'OSWindow-Tests' with: [ spec requires: #( 'OSWindow-Core' 'OSWindow-SDL2' ) ]. spec group: 'Core' with: #('OSWindow-Core' 'OSWindow-SDL2' 'OSWindow-SDL2-Examples'); group: 'Tests' with: #('OSWindow-Tests'); - group: 'default' with: #('Core' 'Tests') ] + group: 'default' with: #('Core' 'OSWindow-Morphic' 'Tests') ] ] diff --git a/src/OSWindow-Core/ScalingCanvas.class.st b/src/Graphics-Canvas/ScalingCanvas.class.st similarity index 92% rename from src/OSWindow-Core/ScalingCanvas.class.st rename to src/Graphics-Canvas/ScalingCanvas.class.st index 526db3c2c14..d01266895d6 100644 --- a/src/OSWindow-Core/ScalingCanvas.class.st +++ b/src/Graphics-Canvas/ScalingCanvas.class.st @@ -13,27 +13,10 @@ Class { #classVars : [ 'FormMapping' ], - #category : 'OSWindow-Core-Utilities', - #package : 'OSWindow-Core', - #tag : 'Utilities' + #category : 'Graphics-Canvas', + #package : 'Graphics-Canvas' } -{ #category : 'examples' } -ScalingCanvas class >> example [ - - | morph | - - (morph := MenuMorph new) - addTitle: 'Lorem ipsum'. - (morph add: 'Dolor sit amet' target: nil selector: #yourself) keyText: 'x'; - icon: (self iconNamed: #smallConfiguration). - (morph add: 'Consectetur adipiscing elit' target: nil selector: #yourself) keyText: 'y'. - morph addLine. - (morph add: 'Sed do eiusmod' target: nil selector: #yourself) keyText: 'z'. - - ^ self privateExampleWithMorph: morph -] - { #category : 'examples' } ScalingCanvas class >> exampleDrawPolygon [ @@ -157,49 +140,6 @@ ScalingCanvas class >> exampleFrameAndFillRectangle2 [ borderWidth: 1.9 borderColor: Color green translucent ] ] ] -{ #category : 'examples' } -ScalingCanvas class >> exampleImageMorph1 [ - - ^ self privateExampleWithMorph: (Morph new - color: Color veryVeryLightGray; - addMorph: ((ImageMorph withForm: (self iconNamed: #search)) - position: 4@4; - yourself); - addMorph: ((ImageMorph withForm: (self iconNamed: #search) copy) - position: 24@4; - yourself); - extent: 44@24; - yourself) -] - -{ #category : 'examples' } -ScalingCanvas class >> exampleImageMorph2 [ - - | forms imageMorph | - - forms := (1 to: 2) collect: [ :scale | - (FormCanvas extent: 100 asPoint * scale depth: 1) - fillOval: ((0 asPoint extent: 100 asPoint * scale) insetBy: 5 * scale) fillStyle: Color green; - form ]. - (imageMorph := ImageMorph withFormSet: (FormSet forms: forms)) - color: Color blue. - ^ self privateExampleWithMorph: imageMorph -] - -{ #category : 'examples' } -ScalingCanvas class >> exampleImageMorph3 [ - - | forms imageMorph | - - forms := (1 to: 2) collect: [ :scale | - (FormCanvas extent: 10 asPoint * scale) - fillOval: ((0 asPoint extent: 10 asPoint * scale) insetBy: 1 * scale) fillStyle: Color black; - form ]. - (imageMorph := ImageMorph withFormSet: (FormSet forms: forms)) - resize: 200@100. - ^ self privateExampleWithMorph: imageMorph -] - { #category : 'examples' } ScalingCanvas class >> exampleLine1 [ diff --git a/src/Morphic-Core/ScalingCanvasSavedPatch.class.st b/src/Graphics-Canvas/ScalingCanvasSavedPatch.class.st similarity index 91% rename from src/Morphic-Core/ScalingCanvasSavedPatch.class.st rename to src/Graphics-Canvas/ScalingCanvasSavedPatch.class.st index b1c282062cb..d7290d92863 100644 --- a/src/Morphic-Core/ScalingCanvasSavedPatch.class.st +++ b/src/Graphics-Canvas/ScalingCanvasSavedPatch.class.st @@ -8,9 +8,8 @@ Class { 'form', 'scale' ], - #category : 'Morphic-Core-Kernel', - #package : 'Morphic-Core', - #tag : 'Kernel' + #category : 'Graphics-Canvas', + #package : 'Graphics-Canvas' } { #category : 'instance creation' } diff --git a/src/Morphic-Core/Morph.class.st b/src/Morphic-Core/Morph.class.st index c6d44946b06..fefc244c546 100644 --- a/src/Morphic-Core/Morph.class.st +++ b/src/Morphic-Core/Morph.class.st @@ -856,7 +856,6 @@ Morph >> addYellowButtonMenuItemsTo: aMenu event: evt [ aMenu addLine. self isWorldMorph ifFalse: [aMenu add: 'copy to paste buffer' selector: #copyToPasteBuffer:]. - (self allStringsAfter: nil) isEmpty ifFalse: [aMenu add: 'copy text' selector: #clipText]. self addExportMenuItems: aMenu hand: evt hand. aMenu addLine. aMenu add: 'adhere to edge...' selector: #adhereToEdge. @@ -1481,8 +1480,6 @@ Morph >> buildMetaMenu: evt [ self maybeAddCollapseItemTo: menu. menu add: 'delete' selector: #dismissMorph:. menu addLine. - menu add: 'copy text' selector: #clipText. - menu addLine. menu add: 'go behind' selector: #goBehind. menu add: 'add halo' selector: #addHalo:. menu add: 'duplicate' selector: #maybeDuplicateMorph:. @@ -1861,25 +1858,6 @@ Morph >> clipSubmorphs: aBool [ self invalidRect: self fullBounds] ] -{ #category : 'printing' } -Morph >> clipText [ - "Copy the text in the receiver or in its submorphs to the clipboard" - | content | - "My own text" - content := self userString. - "Or in my submorphs" - content ifNil: [ - | list | - list := self allStringsAfter: nil. - list notEmpty ifTrue: [ - content := String streamContents: [:stream | - list do: [:each | stream nextPutAll: each; cr]]]]. - "Did we find something?" - content - ifNil: [self flash "provide feedback"] - ifNotNil: [Clipboard clipboardText: content] -] - { #category : 'drawing' } Morph >> clippingBounds [ "Return the bounds to which any submorphs should be clipped if the property is set" diff --git a/src/Morphic-Widgets-Pluggable/PluggableListMorph.class.st b/src/Morphic-Widgets-Pluggable/PluggableListMorph.class.st index c8a27985812..2164651c812 100644 --- a/src/Morphic-Widgets-Pluggable/PluggableListMorph.class.st +++ b/src/Morphic-Widgets-Pluggable/PluggableListMorph.class.st @@ -288,23 +288,6 @@ PluggableListMorph >> commandKeyTypedIntoMenu: evt [ ^ self modifierKeyPressed: evt ] -{ #category : 'menus' } -PluggableListMorph >> copyListToClipboard [ - "Copy my items to the clipboard as a multi-line string" - - | stream | - stream := (String new: self getList size * 40) writeStream. - list do: [:ea | stream nextPutAll: ea asString] separatedBy: [stream nextPut: Character cr]. - Clipboard clipboardText: stream contents -] - -{ #category : 'menus' } -PluggableListMorph >> copySelectionToClipboard [ - "Copy my selected item to the clipboard as a string" - - self selection ifNotNil: [ Clipboard clipboardText: self selection asString ] ifNil: [ self flash ] -] - { #category : 'multi-selection' } PluggableListMorph >> defaultMultipleSelectionValue [ diff --git a/src/Morphic-Widgets-Windows/SystemWindow.class.st b/src/Morphic-Widgets-Windows/SystemWindow.class.st index d7f5f81377a..6fdf09acfc1 100644 --- a/src/Morphic-Widgets-Windows/SystemWindow.class.st +++ b/src/Morphic-Widgets-Windows/SystemWindow.class.st @@ -509,9 +509,6 @@ SystemWindow class >> windowMenuOn: aBuilder [ iconName: #smallHelp; withSeparatorAfter. (aBuilder item: #'Change title') action: [ aBuilder model relabel ]. - (aBuilder item: #'Copy title') - action: [ aBuilder model copyTitle ]; - withSeparatorAfter. (aBuilder item: #'Send to back') action: [ aBuilder model sendToBack ]. (aBuilder item: #'Make next-to-topmost') action: [ aBuilder model makeSecondTopmost ]; @@ -1281,13 +1278,6 @@ SystemWindow >> configureForUnembedding [ self attachKeymapCategory: #WindowShortcuts. ] -{ #category : 'accessing' } -SystemWindow >> copyTitle [ - - Clipboard clipboardText: self label. - InformativeNotification signal: 'Window title copied.' -] - { #category : 'initialization' } SystemWindow >> createBox [ "create a button with default to be used in the label area" diff --git a/src/OSWindow-Core/ManifestOSWindowCore.class.st b/src/OSWindow-Core/ManifestOSWindowCore.class.st index 9db31d0783a..da1b7002007 100644 --- a/src/OSWindow-Core/ManifestOSWindowCore.class.st +++ b/src/OSWindow-Core/ManifestOSWindowCore.class.st @@ -8,10 +8,3 @@ Class { #package : 'OSWindow-Core', #tag : 'Manifest' } - -{ #category : 'meta-data - dependency analyser' } -ManifestOSWindowCore class >> manuallyResolvedDependencies [ - - - ^ #(#'Tool-Profilers') -] diff --git a/src/OSWindow-Core/OSKeyboardEvent.class.st b/src/OSWindow-Core/OSKeyboardEvent.class.st index 0e8338fca2f..3b4aade1324 100644 --- a/src/OSWindow-Core/OSKeyboardEvent.class.st +++ b/src/OSWindow-Core/OSKeyboardEvent.class.st @@ -28,28 +28,6 @@ Class { #tag : 'Events' } -{ #category : 'keymapping' } -OSKeyboardEvent >> asKeyCombination [ - | modifier control command shift alt char | - - control := self modifiers ctrl. - command := self modifiers cmd. - shift := self modifiers shift. - alt := self modifiers alt. - char := self modifiedCharacter. - - (shift | command | control | alt) - ifFalse: [^ KMSingleKeyCombination from: char ]. - - modifier := KMNoShortcut new. - control ifTrue: [ modifier := modifier + KMModifier ctrl ]. - command ifTrue: [ modifier := modifier + KMModifier command ]. - shift ifTrue: [ modifier := modifier + KMModifier shift ]. - alt ifTrue: [ modifier := modifier + KMModifier alt ]. - - ^ modifier + char -] - { #category : 'accessing' } OSKeyboardEvent >> character [ diff --git a/src/OSWindow-Core/OSWindow.class.st b/src/OSWindow-Core/OSWindow.class.st index f92894205ce..61c4a11e2ec 100644 --- a/src/OSWindow-Core/OSWindow.class.st +++ b/src/OSWindow-Core/OSWindow.class.st @@ -186,11 +186,10 @@ OSWindow >> deliverGlobalEvent: aGlobalEvent [ { #category : 'private' } OSWindow >> destroy [ - announcer announce: DeleteWindowByCrossAnnouncement . + self validHandle destroy. backendWindow := nil. - eventHandler := nil. - + eventHandler := nil ] { #category : 'accessing' } diff --git a/src/OSWindow-Core/OSWindowDriver.class.st b/src/OSWindow-Core/OSWindowDriver.class.st index 0276a874f32..17b6dcbacc6 100644 --- a/src/OSWindow-Core/OSWindowDriver.class.st +++ b/src/OSWindow-Core/OSWindowDriver.class.st @@ -118,38 +118,10 @@ You will need to restart the image to make this changes take effect.'; domainValues: (self allSubclasses select: [ :each | each isSuitable ]) ] ] -{ #category : 'system startup' } -OSWindowDriver class >> shutDown: quitting [ - - quitting ifFalse: [ ^ self ]. - - Current ifNil: [ ^ self ]. - - "Clean driver" - Current shutDown: quitting. - Current := nil. - - "clean OSWindow worlds" - WorldMorph extraWorldList copy - select: [ :each | each isKindOf: OSWindowWorldMorph ] - thenDo: [ :each | WorldMorph removeExtraWorld: each ]. - "Clean also active world" - (ActiveWorld isKindOf: OSWindowWorldMorph) - ifTrue: [ ActiveWorld := nil ] -] - -{ #category : 'events' } -OSWindowDriver >> afterMainPharoWindowCreated: aWindow [ -] - { #category : 'events' } OSWindowDriver >> afterSetWindowTitle: windowTitle onWindow: osWindow [ ] -{ #category : 'events' } -OSWindowDriver >> beforeMainPharoWindowClosed: aWindow [ -] - { #category : 'window creation' } OSWindowDriver >> createWindowWithAttributes: anOSWindowAttributes osWindow: osWindow [ self subclassResponsibility diff --git a/src/OSWindow-Core/OSWindowFormRenderer.class.st b/src/OSWindow-Core/OSWindowFormRenderer.class.st index 7a5a0467885..ed3aecefbc1 100644 --- a/src/OSWindow-Core/OSWindowFormRenderer.class.st +++ b/src/OSWindow-Core/OSWindowFormRenderer.class.st @@ -10,15 +10,63 @@ Class { #instVars : [ 'form' ], + #classInstVars : [ + 'canvasScaleFactor', + 'autoSetCanvasScaleFactor' + ], #category : 'OSWindow-Core-Renderer', #package : 'OSWindow-Core', #tag : 'Renderer' } +{ #category : 'accessing' } +OSWindowFormRenderer class >> autoSetCanvasScaleFactor [ + + ^ autoSetCanvasScaleFactor ifNil: [ autoSetCanvasScaleFactor := true ] +] + +{ #category : 'accessing' } +OSWindowFormRenderer class >> autoSetCanvasScaleFactor: boolean [ + + autoSetCanvasScaleFactor := boolean +] + +{ #category : 'accessing' } +OSWindowFormRenderer class >> canvasScaleFactor [ + + ^ canvasScaleFactor ifNil: [ canvasScaleFactor := 1 ] +] + +{ #category : 'accessing' } +OSWindowFormRenderer class >> canvasScaleFactor: newScale [ + + canvasScaleFactor := 1 max: newScale asInteger +] + +{ #category : 'accessing' } +OSWindowFormRenderer class >> settingsOn: aBuilder [ + + + + (aBuilder group: #canvasScaleFactorGroup) + parent: #appearance; + 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: true ] +] + { #category : 'private' } OSWindowFormRenderer >> canvasScaleFactor [ - ^ OSWorldRenderer canvasScaleFactor + ^ self class canvasScaleFactor ] { #category : 'morphic integration' } diff --git a/src/OSWindow-Core/Morph.extension.st b/src/OSWindow-Morphic/Morph.extension.st similarity index 92% rename from src/OSWindow-Core/Morph.extension.st rename to src/OSWindow-Morphic/Morph.extension.st index b40aceadbfb..2dbc8c060b6 100644 --- a/src/OSWindow-Core/Morph.extension.st +++ b/src/OSWindow-Morphic/Morph.extension.st @@ -1,6 +1,6 @@ Extension { #name : 'Morph' } -{ #category : '*OSWindow-Core' } +{ #category : '*OSWindow-Morphic' } Morph >> openInExternalWindow [ | world | world := OSWindowWorldMorph new extent: self fullBounds extent. @@ -19,7 +19,7 @@ Morph >> openInExternalWindow [ ^ world open ] -{ #category : '*OSWindow-Core' } +{ #category : '*OSWindow-Morphic' } Morph >> openInExternalWindowModalCallback: aBlock [ | world | world := OSWindowWorldMorph new extent: self extent. diff --git a/src/OSWindow-Morphic/OSKeyboardEvent.extension.st b/src/OSWindow-Morphic/OSKeyboardEvent.extension.st new file mode 100644 index 00000000000..586f96fa840 --- /dev/null +++ b/src/OSWindow-Morphic/OSKeyboardEvent.extension.st @@ -0,0 +1,23 @@ +Extension { #name : 'OSKeyboardEvent' } + +{ #category : '*OSWindow-Morphic' } +OSKeyboardEvent >> asKeyCombination [ + | modifier control command shift alt char | + + control := self modifiers ctrl. + command := self modifiers cmd. + shift := self modifiers shift. + alt := self modifiers alt. + char := self modifiedCharacter. + + (shift | command | control | alt) + ifFalse: [^ KMSingleKeyCombination from: char ]. + + modifier := KMNoShortcut new. + control ifTrue: [ modifier := modifier + KMModifier ctrl ]. + command ifTrue: [ modifier := modifier + KMModifier command ]. + shift ifTrue: [ modifier := modifier + KMModifier shift ]. + alt ifTrue: [ modifier := modifier + KMModifier alt ]. + + ^ modifier + char +] diff --git a/src/OSWindow-Morphic/OSSDL2Driver.extension.st b/src/OSWindow-Morphic/OSSDL2Driver.extension.st new file mode 100644 index 00000000000..2a81b9a7f78 --- /dev/null +++ b/src/OSWindow-Morphic/OSSDL2Driver.extension.st @@ -0,0 +1,15 @@ +Extension { #name : 'OSSDL2Driver' } + +{ #category : '*OSWindow-Morphic' } +OSSDL2Driver >> afterMainPharoWindowCreated: osWindow [ + + OSPlatform current sdlPlatform + afterMainPharoWindowCreated: osWindow +] + +{ #category : '*OSWindow-Morphic' } +OSSDL2Driver >> beforeMainPharoWindowClosed: osWindow [ + + OSPlatform current sdlPlatform + beforeMainPharoWindowClosed: osWindow +] diff --git a/src/OSWindow-Core/OSWindowClipboard.class.st b/src/OSWindow-Morphic/OSWindowClipboard.class.st similarity index 90% rename from src/OSWindow-Core/OSWindowClipboard.class.st rename to src/OSWindow-Morphic/OSWindowClipboard.class.st index 2a8d7c53a3c..098b90b20b7 100644 --- a/src/OSWindow-Core/OSWindowClipboard.class.st +++ b/src/OSWindow-Morphic/OSWindowClipboard.class.st @@ -5,9 +5,8 @@ For setting/retrieving clipboard text, use clipboardText/clipboardText: accessor Class { #name : 'OSWindowClipboard', #superclass : 'Clipboard', - #category : 'OSWindow-Core-Base', - #package : 'OSWindow-Core', - #tag : 'Base' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } { #category : 'configurations' } diff --git a/src/OSWindow-Morphic/OSWindowDriver.extension.st b/src/OSWindow-Morphic/OSWindowDriver.extension.st new file mode 100644 index 00000000000..81c793fc1e5 --- /dev/null +++ b/src/OSWindow-Morphic/OSWindowDriver.extension.st @@ -0,0 +1,29 @@ +Extension { #name : 'OSWindowDriver' } + +{ #category : '*OSWindow-Morphic' } +OSWindowDriver >> afterMainPharoWindowCreated: aWindow [ +] + +{ #category : '*OSWindow-Morphic' } +OSWindowDriver >> beforeMainPharoWindowClosed: aWindow [ +] + +{ #category : '*OSWindow-Morphic' } +OSWindowDriver class >> shutDown: quitting [ + + quitting ifFalse: [ ^ self ]. + + Current ifNil: [ ^ self ]. + + "Clean driver" + Current shutDown: quitting. + Current := nil. + + "clean OSWindow worlds" + WorldMorph extraWorldList copy + select: [ :each | each isKindOf: OSWindowWorldMorph ] + thenDo: [ :each | WorldMorph removeExtraWorld: each ]. + "Clean also active world" + (ActiveWorld isKindOf: OSWindowWorldMorph) + ifTrue: [ ActiveWorld := nil ] +] diff --git a/src/OSWindow-Core/OSWindowMorphicEventHandler.class.st b/src/OSWindow-Morphic/OSWindowMorphicEventHandler.class.st similarity index 99% rename from src/OSWindow-Core/OSWindowMorphicEventHandler.class.st rename to src/OSWindow-Morphic/OSWindowMorphicEventHandler.class.st index fab4cf428e9..8b04a71ef4c 100644 --- a/src/OSWindow-Core/OSWindowMorphicEventHandler.class.st +++ b/src/OSWindow-Morphic/OSWindowMorphicEventHandler.class.st @@ -18,9 +18,8 @@ Class { #pools : [ 'OSKeySymbols' ], - #category : 'OSWindow-Core-Morphic', - #package : 'OSWindow-Core', - #tag : 'Morphic' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } { #category : 'instance creation' } diff --git a/src/OSWindow-Core/OSWindowWorldMorph.class.st b/src/OSWindow-Morphic/OSWindowWorldMorph.class.st similarity index 95% rename from src/OSWindow-Core/OSWindowWorldMorph.class.st rename to src/OSWindow-Morphic/OSWindowWorldMorph.class.st index cfdc9e68b23..f1c884ba94d 100644 --- a/src/OSWindow-Core/OSWindowWorldMorph.class.st +++ b/src/OSWindow-Morphic/OSWindowWorldMorph.class.st @@ -14,9 +14,8 @@ Class { 'closeCallback', 'isResizeable' ], - #category : 'OSWindow-Core-Morphic', - #package : 'OSWindow-Core', - #tag : 'Morphic' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } { #category : 'adding' } diff --git a/src/OSWindow-Core/OSWindowWorldMorphWithModel.class.st b/src/OSWindow-Morphic/OSWindowWorldMorphWithModel.class.st similarity index 86% rename from src/OSWindow-Core/OSWindowWorldMorphWithModel.class.st rename to src/OSWindow-Morphic/OSWindowWorldMorphWithModel.class.st index c54e4947ea2..d6b1859a87b 100644 --- a/src/OSWindow-Core/OSWindowWorldMorphWithModel.class.st +++ b/src/OSWindow-Morphic/OSWindowWorldMorphWithModel.class.st @@ -7,9 +7,8 @@ Class { #instVars : [ 'model' ], - #category : 'OSWindow-Core-Morphic', - #package : 'OSWindow-Core', - #tag : 'Morphic' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } { #category : 'accessing' } diff --git a/src/OSWindow-Core/OSWorldRenderer.class.st b/src/OSWindow-Morphic/OSWorldRenderer.class.st similarity index 86% rename from src/OSWindow-Core/OSWorldRenderer.class.st rename to src/OSWindow-Morphic/OSWorldRenderer.class.st index 6049841131c..4c09768c5fd 100644 --- a/src/OSWindow-Core/OSWorldRenderer.class.st +++ b/src/OSWindow-Morphic/OSWorldRenderer.class.st @@ -11,39 +11,10 @@ Class { 'windowCloseAction', 'previousFrameRenderingTime' ], - #classInstVars : [ - 'canvasScaleFactor', - 'autoSetCanvasScaleFactor' - ], - #category : 'OSWindow-Core-Morphic', - #package : 'OSWindow-Core', - #tag : 'Morphic' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } -{ #category : 'accessing' } -OSWorldRenderer class >> autoSetCanvasScaleFactor [ - - ^ autoSetCanvasScaleFactor ifNil: [ autoSetCanvasScaleFactor := true ] -] - -{ #category : 'accessing' } -OSWorldRenderer class >> autoSetCanvasScaleFactor: boolean [ - - autoSetCanvasScaleFactor := boolean -] - -{ #category : 'accessing' } -OSWorldRenderer class >> canvasScaleFactor [ - - ^ canvasScaleFactor ifNil: [ canvasScaleFactor := 1 ] -] - -{ #category : 'accessing' } -OSWorldRenderer class >> canvasScaleFactor: newScale [ - - canvasScaleFactor := 1 max: newScale asInteger -] - { #category : 'accessing' } OSWorldRenderer class >> defaultExtent [ @@ -62,7 +33,7 @@ OSWorldRenderer class >> priority [ ^ 2 ] -{ #category : 'start' } +{ #category : 'startup - shutdown' } OSWorldRenderer class >> restart [ | oldWindows | @@ -84,26 +55,6 @@ OSWorldRenderer class >> restart [ InformativeNotification signal: self class name , ' restarted' ] -{ #category : 'settings' } -OSWorldRenderer class >> settingsOn: aBuilder [ - - - - (aBuilder group: #canvasScaleFactorGroup) - parent: #appearance; - 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: true ] -] - { #category : 'accessing' } OSWorldRenderer >> activateCursor: aCursor withMask: maskForm [ @@ -125,10 +76,22 @@ OSWorldRenderer >> actualScreenSize [ ^ (self windowExtent / self screenScaleFactor) ceiling max: 1@1 ] +{ #category : 'private' } +OSWorldRenderer >> autoSetCanvasScaleFactor [ + + ^ self osWindowRenderer class autoSetCanvasScaleFactor +] + { #category : 'private' } OSWorldRenderer >> canvasScaleFactor [ - ^ self class canvasScaleFactor + ^ self osWindowRenderer class canvasScaleFactor +] + +{ #category : 'private' } +OSWorldRenderer >> canvasScaleFactor: scaleFactor [ + + ^ self osWindowRenderer class canvasScaleFactor: scaleFactor ] { #category : 'events' } @@ -141,8 +104,8 @@ 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 ]. + (world == World and: [ self autoSetCanvasScaleFactor ]) ifTrue: [ + self canvasScaleFactor: (windowRenderer outputExtent / self windowExtent) min * self screenScaleFactor ]. (display isNil or: [ display extent = self actualDisplaySize and: [ world worldState realWindowExtent = self actualScreenSize ] ]) ifTrue: [ ^ self ]. @@ -245,11 +208,12 @@ OSWorldRenderer >> doActivate [ windowCentered: true; icon: self defaultWindowIcon. - display := Form extent: initialExtent * self canvasScaleFactor depth: 32. world extent: initialExtent. driver := self pickMostSuitableWindowDriver. attributes preferableDriver: driver. + + display := Form extent: initialExtent * self canvasScaleFactor depth: 32. osWindow := OSWindow createWithAttributes: attributes eventHandler: (OSWindowMorphicEventHandler for: world). diff --git a/src/OSWindow-Morphic/SDLAbstractPlatform.extension.st b/src/OSWindow-Morphic/SDLAbstractPlatform.extension.st new file mode 100644 index 00000000000..17b2fbcc9cd --- /dev/null +++ b/src/OSWindow-Morphic/SDLAbstractPlatform.extension.st @@ -0,0 +1,13 @@ +Extension { #name : 'SDLAbstractPlatform' } + +{ #category : '*OSWindow-Morphic' } +SDLAbstractPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ + + self subclassResponsibility +] + +{ #category : '*OSWindow-Morphic' } +SDLAbstractPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ + + self subclassResponsibility +] diff --git a/src/OSWindow-Morphic/SDLNullPlatform.extension.st b/src/OSWindow-Morphic/SDLNullPlatform.extension.st new file mode 100644 index 00000000000..691e27c4797 --- /dev/null +++ b/src/OSWindow-Morphic/SDLNullPlatform.extension.st @@ -0,0 +1,9 @@ +Extension { #name : 'SDLNullPlatform' } + +{ #category : '*OSWindow-Morphic' } +SDLNullPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ +] + +{ #category : '*OSWindow-Morphic' } +SDLNullPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ +] diff --git a/src/OSWindow-SDL2/SDLOSXPharoMenu.class.st b/src/OSWindow-Morphic/SDLOSXPharoMenu.class.st similarity index 98% rename from src/OSWindow-SDL2/SDLOSXPharoMenu.class.st rename to src/OSWindow-Morphic/SDLOSXPharoMenu.class.st index ffc9fb58a46..6b6b5288421 100644 --- a/src/OSWindow-SDL2/SDLOSXPharoMenu.class.st +++ b/src/OSWindow-Morphic/SDLOSXPharoMenu.class.st @@ -17,9 +17,8 @@ Class { #classVars : [ 'UniqueInstance' ], - #category : 'OSWindow-SDL2-Pharo-Specific', - #package : 'OSWindow-SDL2', - #tag : 'Pharo-Specific' + #category : 'OSWindow-Morphic', + #package : 'OSWindow-Morphic' } { #category : 'instance creation' } diff --git a/src/OSWindow-Morphic/SDLOSXPlatform.extension.st b/src/OSWindow-Morphic/SDLOSXPlatform.extension.st new file mode 100644 index 00000000000..eaac4552131 --- /dev/null +++ b/src/OSWindow-Morphic/SDLOSXPlatform.extension.st @@ -0,0 +1,23 @@ +Extension { #name : 'SDLOSXPlatform' } + +{ #category : '*OSWindow-Morphic' } +SDLOSXPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ +] + +{ #category : '*OSWindow-Morphic' } +SDLOSXPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ +] + +{ #category : '*OSWindow-Morphic' } +SDLOSXPlatform >> initPlatformSpecific [ + + | sharedApplication | + sharedApplication := ObjCLibrary uniqueInstance sharedApplication. + + ObjCLibrary uniqueInstance sendMessage: (ObjCLibrary uniqueInstance lookupSelector: 'finishLaunching') to: sharedApplication. + + SDLOSXPharoMenu uniqueInstance installInOSXWindow. + + self allowTouchpadInertia. + +] diff --git a/src/OSWindow-Morphic/SDLUnixPlatform.extension.st b/src/OSWindow-Morphic/SDLUnixPlatform.extension.st new file mode 100644 index 00000000000..dd95f530fd9 --- /dev/null +++ b/src/OSWindow-Morphic/SDLUnixPlatform.extension.st @@ -0,0 +1,9 @@ +Extension { #name : 'SDLUnixPlatform' } + +{ #category : '*OSWindow-Morphic' } +SDLUnixPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ +] + +{ #category : '*OSWindow-Morphic' } +SDLUnixPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ +] diff --git a/src/OSWindow-Morphic/SDLWindowsPlatform.extension.st b/src/OSWindow-Morphic/SDLWindowsPlatform.extension.st new file mode 100644 index 00000000000..8b7e1d37a4e --- /dev/null +++ b/src/OSWindow-Morphic/SDLWindowsPlatform.extension.st @@ -0,0 +1,48 @@ +Extension { #name : 'SDLWindowsPlatform' } + +{ #category : '*OSWindow-Morphic' } +SDLWindowsPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ + + | sdlWindowInfo handle | + sdlWindowInfo := aOSSDLWindow backendWindow getWMInfo. + handle := sdlWindowInfo info win window. + self enableDebugWindowMenu: handle. + + self addRestartUIManagerOption: handle. + + "I want to receive the System Windows events" + SDL2 eventType: SDL_SYSWMEVENT state: 1. + + self wtsRegisterSessionNotification: handle. + +] + +{ #category : '*OSWindow-Morphic' } +SDLWindowsPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ + + | sdlWindowInfo handle | + sdlWindowInfo := aOSSDLWindow backendWindow getWMInfo. + handle := sdlWindowInfo info win window. + + self wtsUnRegisterSessionNotification: handle. + +] + +{ #category : '*OSWindow-Morphic' } +SDLWindowsPlatform >> handleSystemCommand: aWindowMessage [ + + aWindowMessage wParam = self restartUIManagerMenuID ifTrue: [ + UIManager default defer: [ OSWorldRenderer restart ] ]. + + ^ nil +] + +{ #category : '*OSWindow-Morphic' } +SDLWindowsPlatform >> handleWTSessionChange: aWindowMessage [ + + "WTS_SESSION_UNLOCK" + aWindowMessage wParam = 8 ifTrue: [ + UIManager default defer: [ OSWorldRenderer restart ] ]. + + ^ nil +] diff --git a/src/OSWindow-Morphic/ScalingCanvas.extension.st b/src/OSWindow-Morphic/ScalingCanvas.extension.st new file mode 100644 index 00000000000..4cf44d4dc5c --- /dev/null +++ b/src/OSWindow-Morphic/ScalingCanvas.extension.st @@ -0,0 +1,60 @@ +Extension { #name : 'ScalingCanvas' } + +{ #category : '*OSWindow-Morphic' } +ScalingCanvas class >> example [ + + | morph | + + (morph := MenuMorph new) + addTitle: 'Lorem ipsum'. + (morph add: 'Dolor sit amet' target: nil selector: #yourself) keyText: 'x'; + icon: (self iconNamed: #smallConfiguration). + (morph add: 'Consectetur adipiscing elit' target: nil selector: #yourself) keyText: 'y'. + morph addLine. + (morph add: 'Sed do eiusmod' target: nil selector: #yourself) keyText: 'z'. + + ^ self privateExampleWithMorph: morph +] + +{ #category : '*OSWindow-Morphic' } +ScalingCanvas class >> exampleImageMorph1 [ + + ^ self privateExampleWithMorph: (Morph new + color: Color veryVeryLightGray; + addMorph: ((ImageMorph withForm: (self iconNamed: #search)) + position: 4@4; + yourself); + addMorph: ((ImageMorph withForm: (self iconNamed: #search) copy) + position: 24@4; + yourself); + extent: 44@24; + yourself) +] + +{ #category : '*OSWindow-Morphic' } +ScalingCanvas class >> exampleImageMorph2 [ + + | forms imageMorph | + + forms := (1 to: 2) collect: [ :scale | + (FormCanvas extent: 100 asPoint * scale depth: 1) + fillOval: ((0 asPoint extent: 100 asPoint * scale) insetBy: 5 * scale) fillStyle: Color green; + form ]. + (imageMorph := ImageMorph withFormSet: (FormSet forms: forms)) + color: Color blue. + ^ self privateExampleWithMorph: imageMorph +] + +{ #category : '*OSWindow-Morphic' } +ScalingCanvas class >> exampleImageMorph3 [ + + | forms imageMorph | + + forms := (1 to: 2) collect: [ :scale | + (FormCanvas extent: 10 asPoint * scale) + fillOval: ((0 asPoint extent: 10 asPoint * scale) insetBy: 1 * scale) fillStyle: Color black; + form ]. + (imageMorph := ImageMorph withFormSet: (FormSet forms: forms)) + resize: 200@100. + ^ self privateExampleWithMorph: imageMorph +] diff --git a/src/OSWindow-Core/WorldMorph.extension.st b/src/OSWindow-Morphic/WorldMorph.extension.st similarity index 71% rename from src/OSWindow-Core/WorldMorph.extension.st rename to src/OSWindow-Morphic/WorldMorph.extension.st index 65f66d2c6c3..b4dc8b7cece 100644 --- a/src/OSWindow-Core/WorldMorph.extension.st +++ b/src/OSWindow-Morphic/WorldMorph.extension.st @@ -1,11 +1,11 @@ Extension { #name : 'WorldMorph' } -{ #category : '*OSWindow-Core' } +{ #category : '*OSWindow-Morphic' } WorldMorph >> clipboardText [ ^ self osWindow clipboardText ] -{ #category : '*OSWindow-Core' } +{ #category : '*OSWindow-Morphic' } WorldMorph >> clipboardText: aString [ ^ self osWindow clipboardText: aString ] diff --git a/src/OSWindow-Morphic/package.st b/src/OSWindow-Morphic/package.st new file mode 100644 index 00000000000..6e9b495e3ca --- /dev/null +++ b/src/OSWindow-Morphic/package.st @@ -0,0 +1 @@ +Package { #name : 'OSWindow-Morphic' } diff --git a/src/OSWindow-SDL2-Examples/SDL2Example.class.st b/src/OSWindow-SDL2-Examples/SDL2Example.class.st index 4db6c21c200..4da18204faf 100644 --- a/src/OSWindow-SDL2-Examples/SDL2Example.class.st +++ b/src/OSWindow-SDL2-Examples/SDL2Example.class.st @@ -13,26 +13,6 @@ Class { #tag : 'Examples' } -{ #category : 'examples' } -SDL2Example >> osWindow [ - " - self new osWindow - " - - | attrs window extent form | - extent := 800 @ 600. - form := Form extent: extent depth: 32. - attrs := OSWindowAttributes new. - attrs - preferableDriver: OSSDL2Driver new; - extent: extent. - window := OSWindow createWithAttributes: attrs. - window eventHandler: - (OSWindowMorphicEventHandler for: self currentWorld). - window newFormRenderer: form. - ^ window -] - { #category : 'examples' } SDL2Example >> simpleBlackWindow [ " diff --git a/src/OSWindow-SDL2/OSSDL2Driver.class.st b/src/OSWindow-SDL2/OSSDL2Driver.class.st index c562b4ac394..2aad513e2e3 100644 --- a/src/OSWindow-SDL2/OSSDL2Driver.class.st +++ b/src/OSWindow-SDL2/OSSDL2Driver.class.st @@ -41,13 +41,6 @@ OSSDL2Driver class >> isSuitable [ ^ SDL2 isAvailable ] -{ #category : 'events' } -OSSDL2Driver >> afterMainPharoWindowCreated: osWindow [ - - OSPlatform current sdlPlatform - afterMainPharoWindowCreated: osWindow -] - { #category : 'events' } OSSDL2Driver >> afterSetWindowTitle: windowTitle onWindow: osWindow [ @@ -55,13 +48,6 @@ OSSDL2Driver >> afterSetWindowTitle: windowTitle onWindow: osWindow [ afterSetWindowTitle: windowTitle onWindow: osWindow ] -{ #category : 'events' } -OSSDL2Driver >> beforeMainPharoWindowClosed: osWindow [ - - OSPlatform current sdlPlatform - beforeMainPharoWindowClosed: osWindow -] - { #category : 'private' } OSSDL2Driver >> closeRemovedController: index [ "TODO: What should I do here?" diff --git a/src/OSWindow-SDL2/SDLAbstractPlatform.class.st b/src/OSWindow-SDL2/SDLAbstractPlatform.class.st index ad37787dc62..cb6f3fa8693 100644 --- a/src/OSWindow-SDL2/SDLAbstractPlatform.class.st +++ b/src/OSWindow-SDL2/SDLAbstractPlatform.class.st @@ -16,24 +16,12 @@ Class { #tag : 'Platforms' } -{ #category : 'operations' } -SDLAbstractPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ - - self subclassResponsibility -] - { #category : 'operations' } SDLAbstractPlatform >> afterSetWindowTitle: aString onWindow: aOSSDLWindow [ self subclassResponsibility ] -{ #category : 'operations' } -SDLAbstractPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ - - self subclassResponsibility -] - { #category : 'configuration' } SDLAbstractPlatform >> defaultRendererFlags [ "We have no special flags for the renderer. diff --git a/src/OSWindow-SDL2/SDLNullPlatform.class.st b/src/OSWindow-SDL2/SDLNullPlatform.class.st index 7253e0fcb76..8267b03b8d3 100644 --- a/src/OSWindow-SDL2/SDLNullPlatform.class.st +++ b/src/OSWindow-SDL2/SDLNullPlatform.class.st @@ -9,18 +9,10 @@ Class { #tag : 'Platforms' } -{ #category : 'operations' } -SDLNullPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ -] - { #category : 'operations' } SDLNullPlatform >> afterSetWindowTitle: aString onWindow: aOSSDLWindow [ ] -{ #category : 'operations' } -SDLNullPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ -] - { #category : 'initialization' } SDLNullPlatform >> initPlatformSpecific [ diff --git a/src/OSWindow-SDL2/SDLOSXPlatform.class.st b/src/OSWindow-SDL2/SDLOSXPlatform.class.st index cb7171512e3..9284ed9c45d 100644 --- a/src/OSWindow-SDL2/SDLOSXPlatform.class.st +++ b/src/OSWindow-SDL2/SDLOSXPlatform.class.st @@ -9,10 +9,6 @@ Class { #tag : 'Platforms' } -{ #category : 'operations' } -SDLOSXPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ -] - { #category : 'operations' } SDLOSXPlatform >> afterSetWindowTitle: aString onWindow: aOSSDLWindow [ @@ -56,27 +52,9 @@ SDLOSXPlatform >> allowTouchpadInertia [ ObjCLibrary uniqueInstance release: key. ] -{ #category : 'operations' } -SDLOSXPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ -] - { #category : 'configuration' } SDLOSXPlatform >> defaultRendererFlags [ "SDL_RENDERER_PRESENTVSYNC is required on MacOS for certain screens to avoid rendering issues" ^ super defaultRendererFlags | SDL_RENDERER_PRESENTVSYNC ] - -{ #category : 'initialization' } -SDLOSXPlatform >> initPlatformSpecific [ - - | sharedApplication | - sharedApplication := ObjCLibrary uniqueInstance sharedApplication. - - ObjCLibrary uniqueInstance sendMessage: (ObjCLibrary uniqueInstance lookupSelector: 'finishLaunching') to: sharedApplication. - - SDLOSXPharoMenu uniqueInstance installInOSXWindow. - - self allowTouchpadInertia. - -] diff --git a/src/OSWindow-SDL2/SDLUnixPlatform.class.st b/src/OSWindow-SDL2/SDLUnixPlatform.class.st index 3b7adf63ec2..3c8114b8a83 100644 --- a/src/OSWindow-SDL2/SDLUnixPlatform.class.st +++ b/src/OSWindow-SDL2/SDLUnixPlatform.class.st @@ -10,18 +10,10 @@ Class { #tag : 'Platforms' } -{ #category : 'operations' } -SDLUnixPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ -] - { #category : 'operations' } SDLUnixPlatform >> afterSetWindowTitle: aString onWindow: aOSSDLWindow [ ] -{ #category : 'operations' } -SDLUnixPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ -] - { #category : 'initialization' } SDLUnixPlatform >> initPlatformSpecific [ diff --git a/src/OSWindow-SDL2/SDLWindowsPlatform.class.st b/src/OSWindow-SDL2/SDLWindowsPlatform.class.st index b469a00fd6d..1aadf3ff521 100644 --- a/src/OSWindow-SDL2/SDLWindowsPlatform.class.st +++ b/src/OSWindow-SDL2/SDLWindowsPlatform.class.st @@ -29,23 +29,6 @@ SDLWindowsPlatform >> addRestartUIManagerOption: handle [ ] -{ #category : 'operations' } -SDLWindowsPlatform >> afterMainPharoWindowCreated: aOSSDLWindow [ - - | sdlWindowInfo handle | - sdlWindowInfo := aOSSDLWindow backendWindow getWMInfo. - handle := sdlWindowInfo info win window. - self enableDebugWindowMenu: handle. - - self addRestartUIManagerOption: handle. - - "I want to receive the System Windows events" - SDL2 eventType: SDL_SYSWMEVENT state: 1. - - self wtsRegisterSessionNotification: handle. - -] - { #category : 'operations' } SDLWindowsPlatform >> afterSetWindowTitle: aString onWindow: aOSSDLWindow [ ] @@ -59,17 +42,6 @@ SDLWindowsPlatform >> appendMenu: hMenu flags: uFlags idNewItem: uIDNewItem newI ] -{ #category : 'operations' } -SDLWindowsPlatform >> beforeMainPharoWindowClosed: aOSSDLWindow [ - - | sdlWindowInfo handle | - sdlWindowInfo := aOSSDLWindow backendWindow getWMInfo. - handle := sdlWindowInfo info win window. - - self wtsUnRegisterSessionNotification: handle. - -] - { #category : 'initialization' } SDLWindowsPlatform >> enableDebugWindowMenu: handle [ @@ -107,25 +79,6 @@ SDLWindowsPlatform >> getSystemMetrics: nIndex [ module: 'User32.dll' ] -{ #category : 'event handling' } -SDLWindowsPlatform >> handleSystemCommand: aWindowMessage [ - - aWindowMessage wParam = self restartUIManagerMenuID ifTrue: [ - UIManager default defer: [ OSWorldRenderer restart ] ]. - - ^ nil -] - -{ #category : 'event handling' } -SDLWindowsPlatform >> handleWTSessionChange: aWindowMessage [ - - "WTS_SESSION_UNLOCK" - aWindowMessage wParam = 8 ifTrue: [ - UIManager default defer: [ OSWorldRenderer restart ] ]. - - ^ nil -] - { #category : 'initialization' } SDLWindowsPlatform >> initPlatformSpecific [