[squeak-dev] The Trunk: Morphic-mt.1799.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Nov 23 09:43:13 UTC 2021


Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1799.mcz

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

Name: Morphic-mt.1799
Author: mt
Time: 23 November 2021, 10:43:07.591922 am
UUID: a630dee6-3900-7546-871f-05a1658dd72b
Ancestors: Morphic-ct.1798

Allow specifying a sort order for breadth-first morph enumeration. Use it to sort row-first and left-to-right when looking for a default focus morph (unless specified explicitely via #defaultFocus(Morph):).

Note that this heuristic works only in a Western left-to-right orientation of texts and layouts etc.

=============== Diff against Morphic-ct.1798 ===============

Item was changed:
  ----- Method: Morph>>allMorphsBreadthFirstDo: (in category 'submorphs - enumerating') -----
  allMorphsBreadthFirstDo: aBlock 
  
+ 	self
+ 		allMorphsBreadthFirstDo: aBlock
+ 		sorted: nil.!
- 	| remaining |
- 	remaining := OrderedCollection with: self.
- 	[remaining notEmpty] whileTrue: [
- 		| next |
- 		next := remaining removeFirst.
- 		aBlock value: next.
- 		remaining addAll: next submorphs].!

Item was added:
+ ----- Method: Morph>>allMorphsBreadthFirstDo:sorted: (in category 'submorphs - enumerating') -----
+ allMorphsBreadthFirstDo: aBlock sorted: aSortBlockOrNil
+ 
+ 	| remaining |
+ 	remaining := OrderedCollection with: self.
+ 	[remaining notEmpty] whileTrue: [
+ 		| next |
+ 		next := remaining removeFirst.
+ 		aBlock value: next.
+ 		remaining addAll: (aSortBlockOrNil
+ 			ifNil: [next submorphs "Avoid extra copy. See #sorted:."]
+ 			ifNotNil: [next submorphs sorted: aSortBlockOrNil])].!

Item was changed:
  ----- Method: SystemWindow>>defaultFocusMorph (in category 'focus') -----
  defaultFocusMorph
  
  	| predicate |
  	predicate := (self hasProperty: #defaultFocusMorph)
  		ifFalse: [ [:morph | morph wantsKeyboardFocus] ]
  		ifTrue: [ | anObject |
  			anObject := (self valueOfProperty: #defaultFocusMorph) value.
  			anObject isMorph ifTrue: [^ anObject].
  			[:morph | morph knownName = anObject] ].
  
+ 	self
+ 		allMorphsBreadthFirstDo: [:morph | (predicate value: morph) ifTrue: [^ morph]]
+ 		sorted: [:a :b | a top < b top or: [a top = b top and: [a left <= b left]]].
- 	self allMorphsBreadthFirstDo: [:morph |
- 		(predicate value: morph) ifTrue: [^ morph]].
  
  	^ nil!



More information about the Squeak-dev mailing list