[Pkg] The Trunk: Graphics-pre.423.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 14 15:21:27 UTC 2019


Patrick Rein uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-pre.423.mcz

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

Name: Graphics-pre.423
Author: pre
Time: 14 November 2019, 4:20:44.164053 pm
UUID: a9abea50-6c2d-1645-83da-5204166dda73
Ancestors: Graphics-mt.422

Fixes a bug causing lines with several morphs to become to high.

=============== Diff against Graphics-mt.422 ===============

Item was changed:
  ----- Method: CompositionScanner>>lineHeightForMorphOfHeight:aligned:to:paddedWith:andOptionalMorphBaseline: (in category 'private') -----
  lineHeightForMorphOfHeight: aMorphHeight aligned: morphPosition to: linePosition paddedWith: verticalPadding andOptionalMorphBaseline: morphBaseline
  	"The idea here is to first compute the total height and then subtract the overlapping area."
  
  	| adjustedLineHeight morphHeight total |
  	morphHeight := aMorphHeight + verticalPadding.
  	total := font height + morphHeight.
  	adjustedLineHeight := 0.
  	
  	morphPosition = #top 		ifTrue: [
  			linePosition = #top			ifTrue: [adjustedLineHeight := total - font height].
  			linePosition = #center 		ifTrue: [adjustedLineHeight := total - (font descent + (font ascent / 2))].
  			linePosition = #baseline 	ifTrue: [adjustedLineHeight := total - font descent].
  			linePosition = #bottom 		ifTrue: [adjustedLineHeight := total].].
  	morphPosition = #center 	ifTrue: [ | upperMorphHalf lowerMorphHalf |
  			"The overlapping area of a morph aligned at the center position can be determined by splitting 
  			the morph into a top half which is aligned at the bottom and a lower half aligned at the top."
  			upperMorphHalf := self 
+ 				lineHeightForMorphOfHeight: aMorphHeight // 2 
- 				lineHeightForMorphOfHeight: aMorphHeight / 2 
  				aligned: #bottom to: linePosition. 
  			lowerMorphHalf := self 
+ 				lineHeightForMorphOfHeight: aMorphHeight // 2
- 				lineHeightForMorphOfHeight: aMorphHeight / 2 
  				aligned: #top to: linePosition.
  			adjustedLineHeight := upperMorphHalf + lowerMorphHalf - font height].
  	morphPosition = #baseline ifTrue: [ | upperMorphHalf lowerMorphHalf |
  			"We use the same trick as we used with the center position but with different proportions of the morph."
  			upperMorphHalf := self 
  				lineHeightForMorphOfHeight: morphBaseline 
  				aligned: #bottom to: linePosition. 
  			lowerMorphHalf := self 
  				lineHeightForMorphOfHeight: aMorphHeight - morphBaseline 
  				aligned: #top to: linePosition.
  			adjustedLineHeight := upperMorphHalf + lowerMorphHalf - font height].
  	morphPosition = #bottom 	ifTrue: [
  			linePosition = #top			ifTrue: [adjustedLineHeight := total].
  			linePosition = #center 		ifTrue: [adjustedLineHeight := total - (font ascent / 2)].
  			linePosition = #baseline 	ifTrue: [adjustedLineHeight := total - font ascent].
  			linePosition = #bottom 		ifTrue: [adjustedLineHeight := total - font height].].
  
+ 	^ adjustedLineHeight!
- 	^ lineHeight max: adjustedLineHeight	!

Item was changed:
  ----- Method: CompositionScanner>>placeEmbeddedObjectFrom: (in category 'private') -----
  placeEmbeddedObjectFrom: aTextAttribute
  
  	| width anchoredMorphOrForm textAnchorProperties |
  	anchoredMorphOrForm := aTextAttribute anchoredMorph.
  	textAnchorProperties := self textAnchorPropertiesFor: anchoredMorphOrForm.
  	
  	textAnchorProperties anchorLayout == #document ifTrue: [^ true].
  	"If it is not anchored at the document, we assume that it is inline."
  	width := anchoredMorphOrForm width + textAnchorProperties horizontalPadding.
  	(textAnchorProperties consumesHorizontalSpace and: [destX + width > rightMargin and: [(leftMargin + width) <= rightMargin or: [lastIndex > line first]]])
  		ifTrue: ["Won't fit, but would on next line"
  				^ false].
  	
  	"The width had to be set beforehand to determine line wrapping. 
  	We can now re-use and reset it as it might not be necessary anymore. --pre"
  	width := textAnchorProperties consumesHorizontalSpace 
  		ifTrue: [anchoredMorphOrForm width + textAnchorProperties horizontalPadding]
  		ifFalse: [0].
  	destX := destX + width + kern.
  	
  	baseline := baseline max: 
  		(self alignmentMorphOffsetFor: textAnchorProperties of: anchoredMorphOrForm) 
  			+ (self baselineAdjustmentFor: textAnchorProperties).
+ 	lineHeight := lineHeight max: (self 
- 	lineHeight := self 
  		lineHeightForMorphOfHeight: anchoredMorphOrForm height
  		aligned: textAnchorProperties verticalAlignmentMorph 
  		to: textAnchorProperties verticalAlignmentLine
  		paddedWith: textAnchorProperties verticalPadding
  		andOptionalMorphBaseline: (textAnchorProperties morphBaselineGetter 
+ 			ifNotNil: [:getter | anchoredMorphOrForm perform: getter] ifNil: [0])).
- 			ifNotNil: [:getter | anchoredMorphOrForm perform: getter] ifNil: [0]).
  	^ true!

Item was changed:
  ----- Method: DisplayScanner>>placeEmbeddedObjectFrom: (in category 'private') -----
  placeEmbeddedObjectFrom: aTextAttribute
  	
  	| width anchoredMorphOrForm textAnchorProperties |
  	anchoredMorphOrForm := aTextAttribute anchoredMorph.
  	textAnchorProperties := self textAnchorPropertiesFor: anchoredMorphOrForm.
  	
  	(self embeddedObject: anchoredMorphOrForm shouldBePlacedInDocumentGiven: textAnchorProperties) 
  			ifTrue: [^ self placeEmbeddedObjectInDocument: anchoredMorphOrForm].
+ 	self placeEmbeddedObject: anchoredMorphOrForm inlineGiven: textAnchorProperties.
- 	 .self placeEmbeddedObject: anchoredMorphOrForm inlineGiven: textAnchorProperties.
  	
  	width := textAnchorProperties consumesHorizontalSpace 
  				ifTrue: [anchoredMorphOrForm width + textAnchorProperties horizontalPadding]
  				ifFalse: [0].
  	destX := destX + width + kern.
  	
  	^ true!



More information about the Packages mailing list