[Pkg] The Trunk: Morphic-cmm.897.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Apr 18 20:35:47 UTC 2015


Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.897.mcz

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

Name: Morphic-cmm.897
Author: cmm
Time: 18 April 2015, 3:34:58.288 pm
UUID: 65340933-5514-4232-beb5-71d0f82ebcca
Ancestors: Morphic-kfr.896

- Don't color the background of filtered lists ink because we now have the new improved (yellow) filter-indication.
- Enhancements to the Smart Splitters algorithm:
	- Faster.  Sibling splitters now optimize simultaneously as a group, allowing them to sprint to the balanced position quickly.  This fixes the undesirable creeping behavior.
	- TextMorphs now request splitters to balance their number of visible lines which need to wrap against the opposing widgets occluded characters.

=============== Diff against Morphic-kfr.896 ===============

Item was changed:
  ----- Method: PluggableListMorph>>indicateFiltered (in category 'filtering') -----
  indicateFiltered
+ 	"Don't need this pink background anymore, since now the current filter is highlighted in every matching substring entry in the list."
+ 	"self color: Color red muchLighter muchLighter"!
- 	self color: Color red muchLighter muchLighter!

Item was changed:
  ----- Method: PluggableTextMorph>>charactersOccluded (in category 'geometry') -----
  charactersOccluded
+ 	"Let the receiver suggest to its neighboring vertical Splitter(s) that they try to optimize their position such that none of the receivers visible lines need to wrap."
+ 	| numberOfPhysicalLines lastPhysicalLine logicalLines physicalLines |
+ 	numberOfPhysicalLines := 0.
+ 	lastPhysicalLine := (physicalLines := textMorph paragraph lines)
+ 		detect:
+ 			[ : each | numberOfPhysicalLines := numberOfPhysicalLines + 1.
+ 			each bottom > self height ]
+ 		ifNone: [ physicalLines last ].
+ 	logicalLines := (self text
+ 		copyFrom: 1
+ 		to: lastPhysicalLine last) lineCount.
+ 	^ numberOfPhysicalLines - logicalLines!
- 	"Let the receiver  suggest to its neighboring vertical Splitter(s) that they try to optimize their position such that none of the receivers lines need to wrap."
- 	| numberOfLogicalLines numberOfPhysicalLines |
- 	numberOfLogicalLines := self text lineCount.
- 	numberOfPhysicalLines:= textMorph paragraph numberOfLines.
- 	^ numberOfPhysicalLines - numberOfLogicalLines!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>charactersOccludedIn: (in category 'layout') -----
  charactersOccludedIn: aCollection
  	^ aCollection
  		inject: 0
  		into:
+ 			[ : sum : each | sum +
- 			[ : max : each | max max:
  				(each isMorphicModel
  					ifTrue: [ each charactersOccluded ]
  					ifFalse: [ 0 ]) ]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>initializeMovements (in category 'initialization') -----
  initializeMovements
+ 	movements := OrderedCollection new: 3 withAll: 0!
- 	movements := OrderedCollection with: 0 with: 0 with: 0!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>mouseDown: (in category 'events') -----
  mouseDown: anEvent 
  	"If the user manually drags me, don't override him with auto positioning."
  	anEvent redButtonChanged
  		ifTrue: [ self stopStepping ]
  		ifFalse:
  			[ anEvent shiftPressed
  				ifTrue: [ self startStepping ]
  				ifFalse:
+ 					[ self startStepping.
+ 					self siblingSplittersDo: [ : each | each startStepping ] ] ].
- 					[ {self} , self siblingSplitters do:
- 						[ : each | each startStepping ] ] ].
  	(self class showSplitterHandles not and: [ self bounds containsPoint: anEvent cursorPoint ]) ifTrue:
  		[ oldColor := self color.
  		self color: Color black ].
  	^ super mouseDown: anEvent!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>reduceLeftRightImbalance (in category 'layout') -----
+ reduceLeftRightImbalance
+ 	| correction |
+ 	correction := self leftRightImbalance.
+ 	correction abs > 1
+ 		ifTrue:
+ 			[ (self proposedCorrectionWouldCauseFocusChange: correction) ifFalse:
+ 				[ self repositionBy:
+ 					(correction abs > 4
+ 						ifTrue: [ correction sign * 2 @ 0 ]
+ 						ifFalse: [ correction sign @ 0 ]) ] ]
+ 		ifFalse:
+ 			[ self class smartVerticalSplitters ifFalse: [ self stopStepping ] ].
+ 	^ correction!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>reduceTopBottomImbalance (in category 'layout') -----
+ reduceTopBottomImbalance
+ 	| correction |
+ 	(correction := self topBottomImbalance) isZero
+ 		ifTrue:
+ 			[ self class smartHorizontalSplitters ifFalse: [ self stopStepping ] ]
+ 		ifFalse:
+ 			[ (self proposedCorrectionWouldCauseFocusChange: correction) ifFalse: [ self repositionBy: 0 @ correction ] ].
+ 	^ correction!

Item was removed:
- ----- Method: ProportionalSplitterMorph>>siblingSplitters (in category 'adjacent splitters') -----
- siblingSplitters
- 
- 	^ self owner submorphsSatisfying: [:each | (each isKindOf: self class) and: [self splitsTopAndBottom = each splitsTopAndBottom and: [each ~= self]]]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>siblingSplittersDo: (in category 'adjacent splitters') -----
+ siblingSplittersDo: aBlock 
+ 	^ owner ifNotNil:
+ 		[ owner submorphsDo:
+ 			[ : each | ((each isKindOf: self class) and:
+ 				[ self splitsTopAndBottom = each splitsTopAndBottom and: [ each ~= self ] ]) ifTrue: [ aBlock value: each ] ] ]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>splitterAbove (in category 'adjacent splitters') -----
  splitterAbove
+ 	| immediatelyAbove |
+ 	immediatelyAbove := nil.
+ 	self siblingSplittersDo:
+ 		[ : each | "Splitter y's map 0 at the bottom."
+ 		each y > self y ifTrue:
+ 			[ immediatelyAbove
+ 				ifNil: [ immediatelyAbove := each ]
+ 				ifNotNil:
+ 					[ each y < immediatelyAbove y ifTrue: [ immediatelyAbove := each ] ] ] ].
+ 	^ immediatelyAbove!
- 
- 	| splitters |
- 	splitters := ((self siblingSplitters select: [:each | each y > self y]) asSortedCollection: [:a :b | a y < b y]).
- 	
- 	^ splitters ifEmpty: nil ifNotEmpty: [splitters first]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>splitterBelow (in category 'adjacent splitters') -----
  splitterBelow
+ 	| immediatelyBelow |
+ 	immediatelyBelow := nil.
+ 	self siblingSplittersDo:
+ 		[ : each | each y < self y ifTrue:
+ 			[ immediatelyBelow
+ 				ifNil: [ immediatelyBelow := each ]
+ 				ifNotNil:
+ 					[ each y > immediatelyBelow y ifTrue: [ immediatelyBelow := each ] ] ] ].
+ 	^ immediatelyBelow!
- 
- 	| splitters |
- 	splitters := ((self siblingSplitters select: [:each | each y < self y]) asSortedCollection: [:a :b | a y > b y]).
- 	
- 	^ splitters ifEmpty: nil ifNotEmpty: [splitters first]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>splitterLeft (in category 'adjacent splitters') -----
  splitterLeft
+ 	| immediateLeft |
+ 	immediateLeft := nil.
+ 	self siblingSplittersDo:
+ 		[ : each | each x < self x ifTrue:
+ 			[ immediateLeft
+ 				ifNil: [ immediateLeft := each ]
+ 				ifNotNil:
+ 					[ each x > immediateLeft x ifTrue: [ immediateLeft := each ] ] ] ].
+ 	^ immediateLeft!
- 
- 	| splitters |
- 	splitters := ((self siblingSplitters select: [:each | each x < self x]) asSortedCollection: [:a :b | a x > b x]).
- 	
- 	^ splitters ifEmpty: nil ifNotEmpty: [splitters first]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>splitterRight (in category 'adjacent splitters') -----
  splitterRight
+ 	| immediateRight |
+ 	immediateRight := nil.
+ 	self siblingSplittersDo:
+ 		[ : each | each x > self x ifTrue:
+ 			[ immediateRight
+ 				ifNil: [ immediateRight := each ]
+ 				ifNotNil:
+ 					[ each x < immediateRight x ifTrue: [ immediateRight := each ] ] ] ].
+ 	^ immediateRight!
- 
- 	| splitters |
- 	splitters := ((self siblingSplitters select: [:each | each x > self x]) asSortedCollection: [:a :b | a x < b x]).
- 	
- 	^ splitters ifEmpty: nil ifNotEmpty: [splitters first]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>splittersAboveDo: (in category 'adjacent splitters') -----
+ splittersAboveDo: aBlock 
+ 	self splitterAbove ifNotNil:
+ 		[ : splitter | aBlock value: splitter.
+ 		splitter splittersAboveDo: aBlock ]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>splittersBelowDo: (in category 'adjacent splitters') -----
+ splittersBelowDo: aBlock 
+ 	self splitterBelow ifNotNil:
+ 		[ : splitter | aBlock value: splitter.
+ 		splitter splittersBelowDo: aBlock ]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>splittersLeftDo: (in category 'adjacent splitters') -----
+ splittersLeftDo: aBlock 
+ 	self splitterLeft ifNotNil:
+ 		[ : splitter | aBlock value: splitter.
+ 		splitter splittersLeftDo: aBlock ]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>splittersRightDo: (in category 'adjacent splitters') -----
+ splittersRightDo: aBlock 
+ 	self splitterRight ifNotNil:
+ 		[ : splitter | aBlock value: splitter.
+ 		splitter splittersRightDo: aBlock ]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>step (in category 'events') -----
  step
- 	| correction |
  	splitsTopAndBottom
  		ifTrue:
+ 			[ self reduceTopBottomImbalance isZero ifFalse:
+ 				[ self splittersAboveDo:
+ 					[ : splitter | splitter reduceTopBottomImbalance ].
+ 				self splittersBelowDo:
+ 					[ : splitter | splitter reduceTopBottomImbalance ] ] ]
- 			[ (correction := self topBottomCorrection) isZero
- 				ifTrue:
- 					[ self class smartHorizontalSplitters ifFalse: [ self stopStepping ] ]
- 				ifFalse:
- 					[ (self proposedCorrectionWouldCauseFocusChange: correction)
- 						ifFalse: [ self repositionBy: 0 @ correction ] ] ]
  		ifFalse:
+ 			[ self reduceLeftRightImbalance abs > 1 ifTrue:
+ 				[ self splittersLeftDo:
+ 					[ : splitter | splitter reduceLeftRightImbalance ].
+ 				self splittersRightDo:
+ 					[ : splitter | splitter reduceLeftRightImbalance ] ] ]!
- 			[ correction := self leftRightImbalance.
- 			correction abs > 1
- 				ifTrue:
- 					[ (self proposedCorrectionWouldCauseFocusChange: correction)
- 						ifFalse:
- 							[ self repositionBy:
- 								(correction abs > 4
- 									ifTrue: [ correction sign * 2 @ 0 ]
- 									ifFalse: [ correction sign @ 0 ]) ] ]
- 				ifFalse:
- 					[ self class smartVerticalSplitters ifFalse: [ self stopStepping ] ] ]!

Item was changed:
  ----- Method: ProportionalSplitterMorph>>stepTime (in category 'events') -----
  stepTime
  	"When a splitter finds itself in the right place, let it rest for about 3 seconds to avoid performance impacts of constant, rapid stepping."
  	| pause |
  	pause := 3000. "Frozen image when atRandom failed due to lock on its Mutex."
  	^ ({#(1 -1 1 ).  #(-1 1 -1 )} includes: self movements asArray)
  		ifTrue: [ pause "don't twitch" ]
  		ifFalse:
  			[ splitsTopAndBottom
  				ifTrue:
+ 					[ self topBottomImbalance isZero
- 					[ self topBottomCorrection isZero
  						ifTrue: [ pause ]
  						ifFalse: [ 0 ] ]
  				ifFalse:
  					[ self leftRightImbalance abs > 1
  						ifTrue: [ ">1 rather than 0 to discourage one-off twitching"
  							0 ]
  						ifFalse: [ pause ] ] ]!

Item was removed:
- ----- Method: ProportionalSplitterMorph>>topBottomCorrection (in category 'layout') -----
- topBottomCorrection
- 	"First check if I find myself out of range due to user having reduced size of parent."
- 	^ self bottom < self topBoundary "too high"
- 		ifTrue: [ 2 ]
- 		ifFalse:
- 			[ self top > self bottomBoundary "too low"
- 				ifTrue: [ -2 ]
- 				ifFalse:
- 					[ | wsAbove wsBelow |
- 					wsAbove := self canEncroachWhiteSpaceOf: leftOrTop.
- 					wsBelow := self canEncroachWhiteSpaceOf: rightOrBottom.
- 					wsAbove
- 						ifTrue:
- 							[ (wsBelow not and: [ self top > (self topBoundary + 25) ])
- 								ifTrue: [ -2 ]
- 								ifFalse: [ 0 ] ]
- 						ifFalse:
- 							[ wsBelow
- 								ifTrue:
- 									[ self bottom < (self bottomBoundary - 25)
- 										ifTrue: [ 2 ]
- 										ifFalse: [ 0 ] ]
- 								ifFalse: [ 0 ] ] ] ]!

Item was added:
+ ----- Method: ProportionalSplitterMorph>>topBottomImbalance (in category 'layout') -----
+ topBottomImbalance
+ 	"First check if I find myself out of range due to user having reduced size of parent."
+ 	^ self bottom < self topBoundary "too high"
+ 		ifTrue: [ 2 ]
+ 		ifFalse:
+ 			[ self top > self bottomBoundary "too low"
+ 				ifTrue: [ -2 ]
+ 				ifFalse:
+ 					[ | wsAbove wsBelow |
+ 					wsAbove := self canEncroachWhiteSpaceOf: leftOrTop.
+ 					wsBelow := self canEncroachWhiteSpaceOf: rightOrBottom.
+ 					wsAbove
+ 						ifTrue:
+ 							[ (wsBelow not and: [ self top > (self topBoundary + 25) ])
+ 								ifTrue: [ -2 ]
+ 								ifFalse: [ 0 ] ]
+ 						ifFalse:
+ 							[ wsBelow
+ 								ifTrue:
+ 									[ self bottom < (self bottomBoundary - 25)
+ 										ifTrue: [ 2 ]
+ 										ifFalse: [ 0 ] ]
+ 								ifFalse: [ 0 ] ] ] ]!



More information about the Packages mailing list