Marcel Taeumel uploaded a new version of Morphic to project The Trunk: http://source.squeak.org/trunk/Morphic-mt.2073.mcz
==================== Summary ====================
Name: Morphic-mt.2073 Author: mt Time: 24 January 2023, 12:12:52.41521 pm UUID: 92a7b762-9375-1043-9963-0c362137ce72 Ancestors: Morphic-mt.2072
Minor refactoring of label drawing in tree widgets. Also fixes that "trailing TAB" issue where label content got cut off.
=============== Diff against Morphic-mt.2072 ===============
Item was added: + ----- Method: IndentingListItemMorph>>drawLabelInColumnsOn:in: (in category 'drawing') ----- + drawLabelInColumnsOn: aCanvas in: drawBounds + "Draw the receiver appearing in multiple columns. Use TAB character to move between columns." + + | columnScanner columnLeft columnRect columnData | + self assert: [container columns size > 1]. + columnScanner := ReadStream on: contents asString. + container columns withIndexDo: [ :widthSpec :column | + | columnWidth | + "Compute first/next column offset." + column = 1 + ifTrue: [columnLeft := drawBounds left] + ifFalse: [columnLeft := columnRect right + 5 px]. + "Draw icon." + column = self class iconColumnIndex ifTrue: [ + icon ifNotNil: [ + aCanvas + translucentImage: icon + at: columnLeft @ (self top + (self height - icon height // 2)). + columnLeft := columnLeft + icon width + 2]]. + "Compute drawing bounds for label portion." + columnWidth := self widthOfColumn: column. + column = 1 ifTrue: [ "Reduce width by indentation present in first column only" + columnWidth := columnWidth - (drawBounds left - self left) + self hMargin]. + columnRect := columnLeft @ drawBounds top extent: columnWidth @ drawBounds height. + columnData := columnScanner upTo: Character tab. + "Draw label portion." + columnData ifNotEmpty: [ + aCanvas drawString: columnData in: columnRect font: self fontToUse color: self colorToUse] ]. + + "Handle trailing TAB issue in string representation." + columnScanner upToEnd ifNotEmpty: [:rest | + columnRect := columnLeft + (self fontToUse widthOfString: columnData) @ drawBounds top extent: columnRect extent. + aCanvas drawString: String tab, rest in: columnRect font: self fontToUse color: self colorToUse].!
Item was added: + ----- Method: IndentingListItemMorph>>drawLabelOn:in: (in category 'drawing') ----- + drawLabelOn: aCanvas in: drawBounds + + | labelBounds | + icon + ifNil: [labelBounds := drawBounds] + ifNotNil: [ + aCanvas + translucentImage: icon + at: drawBounds left @ (self top + (self height - icon height // 2)). + labelBounds := drawBounds left: drawBounds left + icon width + 2]. + + aCanvas + drawString: contents asString "i.e., the label" + in: labelBounds + font: self fontToUse + color: self colorToUse.!
Item was changed: ----- Method: IndentingListItemMorph>>drawOn: (in category 'drawing') ----- drawOn: aCanvas + | tRect sRect | - | tRect sRect columnScanner columnLeft | self backgroundColor ifNotNil: [:c | aCanvas fillRectangle: self innerBounds color: c].
tRect := self toggleRectangle. self drawToggleOn: aCanvas in: tRect.
sRect := bounds withLeft: tRect right + self hMargin. sRect := sRect top: sRect top + sRect bottom - self fontToUse height // 2. + (container columns isNil or: [(contents asString indexOf: Character tab) = 0]) + ifTrue: [self drawLabelOn: aCanvas in: sRect] + ifFalse: [self drawLabelInColumnsOn: aCanvas in: sRect].! - (container columns isNil or: [(contents asString indexOf: Character tab) = 0]) ifTrue: [ - icon ifNotNil: [ - aCanvas - translucentImage: icon - at: sRect left @ (self top + (self height - icon height // 2)). - sRect := sRect left: sRect left + icon width + 2. - ]. - - aCanvas drawString: contents asString in: sRect font: self fontToUse color: self colorToUse. - - ] ifFalse: [ - columnLeft := sRect left. - columnScanner := ReadStream on: contents asString. - container columns withIndexDo: [ :widthSpec :column | | columnRect columnData columnWidth | - "Draw icon." - column = self class iconColumnIndex ifTrue: [ - icon ifNotNil: [ - aCanvas - translucentImage: icon - at: columnLeft @ (self top + (self height - icon height // 2)). - columnLeft := columnLeft + icon width + 2]]. - - columnWidth := self widthOfColumn: column. - columnRect := columnLeft @ sRect top extent: columnWidth @ sRect height. - columnData := columnScanner upTo: Character tab. - - "Draw string." - columnData ifNotEmpty: [ - aCanvas drawString: columnData in: columnRect font: self fontToUse color: self colorToUse]. - - "Compute next column offset." - columnLeft := columnRect right + 5. - column = 1 ifTrue: [columnLeft := columnLeft - tRect right + self left]. - - ]. - ]!
packages@lists.squeakfoundation.org