[squeak-dev] The Trunk: Graphics-mt.473.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Feb 5 15:17:00 UTC 2022


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

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

Name: Graphics-mt.473
Author: mt
Time: 5 February 2022, 4:16:53.295491 pm
UUID: f805f812-8548-5f4f-9f21-74d779cc5426
Ancestors: Graphics-mt.472

Layout text lines using #leadingSlice instead of #leading so that one-liners look centered while multi-line paragraphs are unchanged as a whole. Note that if the very top of a text morphs looks too compact, there is #margins: depending on your use case.

=============== Diff against Graphics-mt.472 ===============

Item was changed:
  ----- Method: CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide: (in category 'scanning') -----
  composeFrom: startIndex inRectangle: lineRectangle
  	firstLine: firstLine leftSide: leftSide rightSide: rightSide
  	"Answer an instance of TextLineInterval that represents the next line in the paragraph."
  	| runLength stopCondition |
  	"Set up margins"
  	leftMargin := lineRectangle left.
  	leftSide ifTrue: [leftMargin := leftMargin +
  						(firstLine ifTrue: [textStyle firstIndent]
  								ifFalse: [textStyle restIndent])].
  	destX := spaceX := leftMargin.
  	rightMargin := lineRectangle right.
  	rightSide ifTrue: [rightMargin := rightMargin - textStyle rightIndent].
  	lastIndex := startIndex.	"scanning sets last index"
  	destY := lineRectangle top.
  	lineHeight := baseline := 0.  "Will be increased by setFont"
  	line := (TextLine start: lastIndex stop: 0 internalSpaces: 0 paddingWidth: 0)
  				rectangle: lineRectangle.
  	self setStopConditions.	"also sets font"
  	runLength := text runLengthFor: startIndex.
  	runStopIndex := (lastIndex := startIndex) + (runLength - 1).
  	nextIndexAfterLineBreak := spaceCount := 0.
  	lastBreakIsNotASpace := false.
  	self handleIndentation.
  	leftMargin := destX.
  	line leftMargin: leftMargin.
  
  	[stopCondition := self scanCharactersFrom: lastIndex to: runStopIndex
  		in: text string rightX: rightMargin.
  	"See setStopConditions for stopping conditions for composing."
  	self perform: stopCondition] whileFalse.
  
  	^ line
  		lineHeight: lineHeight + textStyle leading
+ 		baseline: baseline + textStyle leadingSlice!
- 		baseline: baseline + textStyle leading!



More information about the Squeak-dev mailing list