[squeak-dev] The Trunk: Morphic-ct.1814.mcz

Marcel Taeumel marcel.taeumel at hpi.de
Mon Dec 6 18:09:59 UTC 2021


Wohoo! Thanks Christoph :-)

Best,
Marcel
Am 06.12.2021 18:57:52 schrieb commits at source.squeak.org <commits at source.squeak.org>:
Christoph Thiede uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-ct.1814.mcz

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

Name: Morphic-ct.1814
Author: ct
Time: 6 December 2021, 6:57:06.349702 pm
UUID: 453bfbb9-9fe7-1b49-b4b5-eddfc0754f8c
Ancestors: Morphic-mt.1813, Morphic-ct.1624, Morphic-ct.1627, Morphic-ct.1630, Morphic-ct.1712, Morphic-ct.1713, Morphic-ct.1716, Morphic-ct.1732, Morphic-ct.1760, Morphic-ct.1778, Morphic-ct.1782, Morphic-ct.1783, Morphic-ct.1787

Merges several minor slips and clean-ups. I have endeavored to review my own almost two-year old patches again and think they should work. :-)

Morphic-ct.1624:

Fixes a bug when undoing dismissal of a SelectionMorph. In the past, this only restored the SelectionMorph itself but not its items.

Please note this solution is not optimal because it abuses #intoWorld:. However, I don't see any unwanted side effects at the moment ... Maybe we would like to introduce an extra hook for this in #reintroduceIntoWorld:?

Morphic-ct.1627:

Removes #wantsHaloFromClick specialization for MenuItemMorph

This was an annoying restriction because it made it impossible to "browse button action" or "debug action invocation" of a menu with one item only.

Morphic-ct.1630:

Remove obsoleted instance variables from TransferMorph

Morphic-ct.1712:

Fix typos in MenuMorph.

Morphic-ct.1713:

Make sure that pressing the arrow-up key in a menu without selection selects the last item. Until now, this only worked for menus with a title.

Morphic-ct.1716:

Re-enables handling of #launchDrop events when the VM is configured as a singleton and has been invoked again, though currently only handled with a rudimentary fallback implementation.

See http://forum.world.st/Changeset-Enhanced-integration-of-drag-n-drop-from-host-tp5123857p5124332.html. Thanks to Jakob (jr) for the feedback!

Reuploaded as replacement for Morphic-ct.1715. Thanks also to Marcel for the feedback! :-)

Morphic-ct.1732:

Updates description of #sendMouseWheelToKeyboardFocus preference. Reason: Since Windows 10, the MouseWheelRouting setting is enabled by default.

Morphic-ct.1760:

Make editors' #spawn feature more robust against missing models. A short scan of all references to the model variable reveals that this was the only method that could not handle nil models correctly.

Morphic-ct.1778:

Fix zero selection bug

Morphic-ct.1782:

Fixes a bottleneck when opening a yellow button menu on a morph that contains a very large number of subsub*morphs. On not-so-fast systems, this can be reproduced using:

self systemNavigation browseAllSelect: #notNil

On faster systems, you might need to install Squeak Inbox Talk and download all messages to reproduce the bottleneck. In my case, this actually blocked the image for several seconds when I yellow-clicked the window.

Reuploaded to replace Morphic-ct.1771 as requested to favor existing patterns over modern convenience ... :-)

Morphic-ct.1783:

Moves part bin description for Connectors pin into the connectors package, supporting the intent of EToys-mt.444 & Co. I'm going to upload a patch for the Connectors package right now ...

Morphic-ct.1787:

Don't raise an error when pressing a key while focusing an empty scroll bar (such as the main panel in a freshly opened preference browser).

=============== Diff against Morphic-mt.1813 ===============

Item was changed:
SystemOrganization addCategory: #'Morphic-Balloon'!
SystemOrganization addCategory: #'Morphic-Basic'!
SystemOrganization addCategory: #'Morphic-Basic-NewCurve'!
SystemOrganization addCategory: #'Morphic-Borders'!
SystemOrganization addCategory: #'Morphic-Collections-Arrayed'!
SystemOrganization addCategory: #'Morphic-Demo'!
SystemOrganization addCategory: #'Morphic-Events'!
SystemOrganization addCategory: #'Morphic-Explorer'!
SystemOrganization addCategory: #'Morphic-Kernel'!
SystemOrganization addCategory: #'Morphic-Layouts'!
SystemOrganization addCategory: #'Morphic-Menus'!
SystemOrganization addCategory: #'Morphic-Menus-DockingBar'!
SystemOrganization addCategory: #'Morphic-Pluggable Widgets'!
SystemOrganization addCategory: #'Morphic-Sound-Synthesis'!
SystemOrganization addCategory: #'Morphic-Support'!
SystemOrganization addCategory: #'Morphic-Text Support'!
SystemOrganization addCategory: #'Morphic-TrueType'!
SystemOrganization addCategory: #'Morphic-Widgets'!
SystemOrganization addCategory: #'Morphic-Windows'!
SystemOrganization addCategory: #'Morphic-Worlds'!
- SystemOrganization addCategory: #Morphic!

Item was changed:
----- Method: CircleMorph class>>supplementaryPartsDescriptions (in category 'parts bin') -----
supplementaryPartsDescriptions
"Extra items for parts bins"

^ {DescriptionForPartsBin
formalName: 'Circle' translatedNoop
categoryList: {'Graphics' translatedNoop}
documentation: 'A circular shape' translatedNoop
globalReceiverSymbol: #CircleMorph
+ nativitySelector: #newStandAlone}!
- nativitySelector: #newStandAlone.
-
- DescriptionForPartsBin
- formalName: 'Pin' translatedNoop
- categoryList: {'Connectors' translatedNoop}
- documentation: 'An attachment point for Connectors that you can embed in another Morph.' translatedNoop
- globalReceiverSymbol: #NCPinMorph
- nativitySelector: #newPin.
- }!

Item was changed:
----- Method: DockingBarMorph>>moveSelectionDown:event: (in category 'control') -----
moveSelectionDown: direction event: evt
"Move the current selection up or down by one, presumably under keyboard control.
direction = +/-1"

| index |
+ index := (submorphs
+ indexOf: selectedItem
+ ifAbsent: [direction positive ifTrue: [0] ifFalse: [1]]
+ ) + direction.
- index := (submorphs indexOf: selectedItem ifAbsent: [1-direction]) + direction.
submorphs do: "Ensure finite"
[:unused | | m |
m := submorphs atWrap: index.
(m isMenuItemMorph and: [m isEnabled]) ifTrue:
[^ self selectItem: m event: evt].
"Keep looking for an enabled item"
index := index + direction sign].
^ self selectItem: nil event: evt!

Item was changed:
----- Method: HandMorph class>>sendMouseWheelToKeyboardFocus (in category 'preferences') -----
sendMouseWheelToKeyboardFocus

categoryList: #(Morphic keyboard mouse)
+ description: 'If enabled, follow the behavior known from older versions of Microsoft Windows, where the mouse wheel works for the widget that has the keyboard focus. If disabled, follow the Mac OS style, where the mouse wheel is send to the widget under the mouse position.'
- description: 'If enabled, follow the behavior known from Microsoft Windows, where the mouse wheel works for the widget that has the keyboard focus. If disabled, follow the Mac OS style, where the mouse wheel is send to the widget under the mouse position'
type: #Boolean>
^ SendMouseWheelToKeyboardFocus ifNil: [true]!

Item was changed:
----- Method: HandMorph>>generateDropFilesEvent: (in category 'private events') -----
generateDropFilesEvent: evtBuf
"Generate the appropriate mouse event for the given raw event buffer."

| position buttons modifiers stamp numFiles dragType |
stamp := evtBuf second.
stamp = 0 ifTrue: [stamp := Time eventMillisecondClock].
dragType := evtBuf third.
position := evtBuf fourth @ evtBuf fifth.
buttons := MouseEvent redButton. "hacked because necessary for correct mouseMoveDragging handling"
modifiers := evtBuf sixth.
buttons := buttons bitOr: (modifiers bitShift: MouseEvent numButtons).
numFiles := evtBuf seventh.

dragType caseOf: {
[1] -> [ "dragEnter"
externalDropMorph := TransferMorph new
dragTransferType: #filesAndDirectories;
source: self;
passenger: (numFiles = 0 "Usually, numFiles and drop paths are delivered on dragDrop only. Still reserving this possibility for able host implementations."
ifTrue: [self flag: #vmCapabilityMissing. 'Unknown host content' translated]
ifFalse: [FileDirectory dropFilesAndDirectories: numFiles]);
yourself.

"During the drag operation, the host system is responsible for displaying the cursor."
self grabMorph: externalDropMorph.
self showTemporaryCursor: Cursor blank.
externalDropMorph bottomRight: self topLeft. "Southeast area of the cursor is blocked by drawings from the source application. Display our drop morph at the opposite corner of the cursor." ].
[2] -> [ "dragMove"
^ MouseMoveEvent new
setType: #mouseMove
startPoint: self position
endPoint: position
trail: "{self position. position}"(self mouseDragTrailFrom: evtBuf)
buttons: buttons
hand: self
stamp: stamp ].
[3] -> [ "dragLeave"
externalDropMorph ifNotNil: #abandon.
externalDropMorph := nil.
self showTemporaryCursor: nil ].
[4] -> [ "dragDrop"
+ | oldButtons event |
+ oldButtons := lastEventBuffer fifth
+ bitOr: (lastEventBuffer sixth bitShift: MouseEvent numButtons).
+ event := MouseButtonEvent new
+ setType: #mouseUp
+ position: position
+ which: (oldButtons bitXor: buttons)
+ buttons: buttons
+ nClicks: 0
+ hand: self
+ stamp: stamp.
+
- | oldButtons |
externalDropMorph ifNil: [
+ "dragDrop has been sent without prior dragging. This happens when the VM is configured as singleton application and has been invoked again with a new image file (aka #launchDrop, runAsSingleInstance on Unix, or RunSingleApp on Windows)."
+ self flag: #forLater. "ct: When we decouple event generation from Morphic, we will probably need to introduce a separate SystemLaunchEvent class for this event. See http://forum.world.st/Changeset-Enhanced-integration-of-drag-n-drop-from-host-tp5123857p5124332.html."
+ Project current
+ launchSystemFiles: (FileDirectory dropFilesAndDirectories: numFiles)
+ event: event.
+ ^ nil].
- "dragDrop has been sent without prior dragging. This happens when the VM is configured as singleton application and has been called again (aka #launchDrop)."
- ^ self error: 'Launch drop for singleton Squeak not yet implemented.'].

self showTemporaryCursor: nil.
externalDropMorph passenger isString ifTrue: [
self flag: #vmCapabilityMissing. "See above."
externalDropMorph passenger: (FileDirectory dropFilesAndDirectories: numFiles)].
externalDropMorph := nil.

(Smalltalk classNamed: #DropFilesEvent) ifNotNil: [:eventClass |
| classicEvent |
"Generate classic DropFilesEvent, providing backward compatibility."
classicEvent := eventClass new
setPosition: position
contents: numFiles
hand: self.
self processEvent: classicEvent.
classicEvent wasHandled ifTrue: [^ nil]].

+ ^ event ].
- oldButtons := lastEventBuffer fifth
- bitOr: (lastEventBuffer sixth bitShift: MouseEvent numButtons).
- ^ MouseButtonEvent new
- setType: #mouseUp
- position: position
- which: (oldButtons bitXor: buttons)
- buttons: buttons
- nClicks: 0
- hand: self
- stamp: stamp ].
[5] -> [ "drag request"
"For dnd out. Not properly implemented at the moment."
self shouldBeImplemented] }.
^ nil!

Item was removed:
- ----- Method: MenuItemMorph>>wantsHaloFromClick (in category 'meta actions') -----
- wantsHaloFromClick
- "Only if I'm not a lonely submenu"
- ^owner notNil and:[owner submorphs size > 1]!

Item was removed:
- ----- Method: MenuMorph>>handlePageDownStorke: (in category 'keystroke helpers') -----
- handlePageDownStorke: evt
-
- evt keyValue = 12 ifFalse: [ ^false ].
- self moveSelectionDown: 5 event: evt.
- ^true!

Item was removed:
- ----- Method: MenuMorph>>handleUpStorke: (in category 'keystroke helpers') -----
- handleUpStorke: evt
-
- evt keyValue = 30 ifFalse: [ ^false ].
- self moveSelectionDown: -1 event: evt.
- ^true!

Item was added:
+ ----- Method: MenuMorph>>handleUpStroke: (in category 'keystroke helpers') -----
+ handleUpStroke: evt
+
+ evt keyValue = 30 ifFalse: [ ^false ].
+ self moveSelectionDown: -1 event: evt.
+ ^true!

Item was changed:
----- Method: MenuMorph>>keyStrokeHandlers (in category 'keystroke helpers') -----
keyStrokeHandlers

^#(
handleCommandKeyPress:
handleCRStroke:
handleEscStroke:
handleLeftStroke:
handleRightStroke:
+ handleUpStroke:
- handleUpStorke:
handleDownStroke:
handlePageUpStroke:
handlePageDownStroke:)!

Item was changed:
----- Method: MenuMorph>>moveSelectionDown:event: (in category 'keyboard control') -----
moveSelectionDown: direction event: evt
"Move the current selection up or down by one, presumably under keyboard control.
direction = +/-1"

| index |
+ index := (submorphs
+ indexOf: selectedItem
+ ifAbsent: [direction positive ifTrue: [0] ifFalse: [1]]
+ ) + direction.
- index := (submorphs indexOf: selectedItem ifAbsent: [1-direction]) + direction.
submorphs do: "Ensure finite"
[:unused | | m |
m := submorphs atWrap: index.
((m isKindOf: MenuItemMorph) and: [m isEnabled]) ifTrue:
[^ self selectItem: m event: evt].
"Keep looking for an enabled item"
index := index + direction sign].
^ self selectItem: nil event: evt!

Item was changed:
----- Method: Morph>>addYellowButtonMenuItemsTo:event: (in category 'menu') -----
addYellowButtonMenuItemsTo: aMenu event: evt
"Populate aMenu with appropriate menu items for a
yellow-button (context menu) click."
aMenu defaultTarget: self.
""
Preferences noviceMode
ifFalse: [aMenu addStayUpItem].
""
self addModelYellowButtonItemsTo: aMenu event: evt.
""
Preferences generalizedYellowButtonMenu
ifFalse: [^ self].
""
aMenu addLine.
aMenu add: 'inspect' translated action: #inspect.
""
aMenu addLine.
self world selectedObject == self
ifTrue: [aMenu add: 'deselect' translated action: #removeHalo]
ifFalse: [aMenu add: 'select' translated action: #addHalo].
""
(self isWorldMorph
or: [self mustBeBackmost
or: [self wantsToBeTopmost]])
ifFalse: [""
aMenu addLine.
aMenu add: 'send to back' translated action: #goBehind.
aMenu add: 'bring to front' translated action: #comeToFront.
self addEmbeddingMenuItemsTo: aMenu hand: evt hand].
""
self isWorldMorph
ifFalse: [""
Smalltalk
at: #NCAAConnectorMorph
ifPresent: [:connectorClass |
aMenu addLine.
aMenu add: 'connect to' translated action: #startWiring.
aMenu addLine].
""

self isFullOnScreen
ifFalse: [aMenu add: 'move onscreen' translated action: #goHome]].
""
Preferences noviceMode
ifFalse: [""
self addLayoutMenuItems: aMenu hand: evt hand.
(owner notNil
and: [owner isTextMorph])
ifTrue: [self addTextAnchorMenuItems: aMenu hand: evt hand]].
""
self isWorldMorph
ifFalse: [""
aMenu addLine.
self addToggleItemsToHaloMenu: aMenu].
""
aMenu addLine.
self isWorldMorph
ifFalse: [aMenu add: 'copy to paste buffer' translated action: #copyToPasteBuffer:].
+ self hasStrings ifTrue: [
+ aMenu add: 'copy text' translated action: #clipText].
- (self allStringsAfter: nil) isEmpty
- ifFalse: [aMenu add: 'copy text' translated action: #clipText].
""
self addExportMenuItems: aMenu hand: evt hand.
""
(Preferences noviceMode not
and: [self isWorldMorph not])
ifTrue: [""
aMenu addLine.
aMenu add: 'adhere to edge...' translated action: #adhereToEdge].
""
self addCustomMenuItems: aMenu hand: evt hand!

Item was changed:
----- Method: Morph>>allStringsAfter: (in category 'debug and other') -----
+ allStringsAfter: submorph
- allStringsAfter: aSubmorph
- "return an OrderedCollection of strings of text in my submorphs. If aSubmorph is non-nil, begin with that container."

+ ^ OrderedCollection streamContents: [:stream |
+ self allStringsAfter: submorph do: [:string |
+ stream nextPut: string]]!
- | list ok |
- list := OrderedCollection new.
- ok := aSubmorph isNil.
- self allMorphsDo:
- [:sub | | string |
- ok ifFalse: [ok := sub == aSubmorph]. "and do this one too"
- ok
- ifTrue:
- [(string := sub userString) ifNotNil:
- [string isString ifTrue: [list add: string] ifFalse: [list addAll: string]]]].
- ^list!

Item was added:
+ ----- Method: Morph>>allStringsAfter:do: (in category 'debug and other') -----
+ allStringsAfter: submorph do: aBlock
+ "Evaluate aBlock for each text in any of my submorphs. If the specified submorph is non-nil, begin with that container."
+
+ | ok |
+ ok := submorph isNil.
+ self allMorphsDo: [:sub | | string |
+ ok ifFalse: [ok := sub == submorph].
+ "and do this one too"
+ ok ifTrue: [
+ (string := sub userString)
+ ifNotNil: [string isString
+ ifTrue: [aBlock value: string]
+ ifFalse: [string do: aBlock]]]].!

Item was added:
+ ----- Method: Morph>>hasStrings (in category 'debug and other') -----
+ hasStrings
+
+ self allStringsAfter: nil do: [:string | ^ true].
+ ^ false!

Item was added:
+ ----- Method: MorphicProject>>launchSystemFiles:event: (in category 'utilities') -----
+ launchSystemFiles: fileStreams event: genericMorphicEvent
+ "Handle a number of files the singleton VM was invoked with again."
+
+ self flag: #todo. "Do something more useful with the image here, e. g. tell the VM to load it."
+ self inform: ('Cannot start a second instance of Squeak\with the image "{1}"\because the VM is configured as singleton application.' withCRs translated format: {fileStreams first localName}).!

Item was changed:
----- Method: PluggableListMorphOfMany>>specialKeyPressed: (in category 'model access') -----
specialKeyPressed: asciiValue
"Toggle the selection on [space]."

asciiValue = Character space asciiValue
ifTrue: [ | index |
+ index := self getCurrentSelectionIndex.
+ index = 0 ifTrue: [^ self].
- index := self getCurrentSelectionIndex.
self
listSelectionAt: index
put: ((self listSelectionAt: index) not).
^ self].

super specialKeyPressed: asciiValue.!

Item was changed:
----- Method: ScrollPane>>keyStroke: (in category 'event handling') -----
keyStroke: evt
"If pane is not empty, pass the event to the last submorph,
 assuming it is the most appropriate recipient (!!)"

+ scroller hasSubmorphs ifTrue:
+ [scroller lastSubmorph keyStroke: evt].!
- scroller submorphs last keyStroke: evt!

Item was added:
+ ----- Method: SelectionMorph>>intoWorld: (in category 'initialization') -----
+ intoWorld: aWorld
+
+ selectedItems ifNotEmpty: [
+ "Restore selected items for #reintroduceIntoWorld:"
+ self flag: #ct. "Introduce separate hook for this - #reintroducedIntoWorld:?"
+ selectedItems do: [:morph |
+ aWorld reintroduceIntoWorld: morph].
+ ^ self delete].
+ super intoWorld: aWorld.!

Item was changed:
----- Method: TextEditor>>spawn (in category 'menu messages') -----
spawn
"Create and schedule a message browser for the code of the model's
selected message. Retain any edits that have not yet been accepted."
| code |
code := paragraph text string.
self cancel.
+ model
+ ifNotNil: [model spawn: code]
+ ifNil: [Project uiManager edit: code].!
- model spawn: code.!

Item was changed:
Morph subclass: #TransferMorph
+ instanceVariableNames: 'transferType passenger draggedMorph source copy'
- instanceVariableNames: 'transferType passenger draggedMorph source dropNotifyRecipient resultRecipient copy'
classVariableNames: 'CopyPlusIcon'
poolDictionaries: ''
category: 'Morphic-Support'!

!TransferMorph commentStamp: 'nk 6/16/2003 16:52' prior: 0!
This is a Morph that is used to visually indicate the progress of a drag operation, and also as a container for various bits of drag state information.

It polls the shift state in its step method to update its copy state (shift pressed = should copy).

And if you hit the Escape key while dragging, it aborts the drag operation.!


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211206/fc7b6143/attachment-0001.html>


More information about the Squeak-dev mailing list