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

commits at source.squeak.org commits at source.squeak.org
Wed Dec 1 17:21:30 UTC 2021


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

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

Name: Morphic-mt.1806
Author: mt
Time: 1 December 2021, 6:21:24.587194 pm
UUID: e086ee00-0503-c441-ab61-f2a5128330d7
Ancestors: Morphic-mt.1805, Morphic-ct.1681

Merges/treats Morphic-ct.1681, but emphasize the need to use text attributes properly. We must style the text contents via text attributes, both color and font. We must not rely on TextMorph internals such as how #textColor: is used by default. For example, TextMorph >> #font: behaves very differently in this regard.

***

Morphic-ct.1681:
	Fixes use of custom attributes in DialogWindows

Things like the following did NOT work properly before this patch:

	self inform: 'normal ' asText
		, ('red ' asText addAttribute: TextColor red; yourself)
		, ('font ' asText addAttribute: (TextFontReference toFont: ((TextStyle named: 'BitstreamVeraSansMono') fontOfSize: 20)); yourself)
		, ('url ' asText addAttribute: TextURL new; yourself)

This was because DialogWindow added its own styling attributes on top of all existing attributes. For color, this is not necessary because #textColor: is sufficient. For font size, in theory, TextFontChange should be sufficient, but currently it does not support relative changes to the font size.

=============== Diff against Morphic-mt.1805 ===============

Item was changed:
  ----- Method: DialogWindow>>setMessageParameters (in category 'initialization') -----
  setMessageParameters
+ 
+ 	| fontToUse colorToUse fontAttr offset |
+ 	messageMorph ifNil: [^ self].
+ 
+ 	fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
+ 	colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
  	
+ 	messageMorph
+ 		hResizing: #shrinkWrap;
+ 		vResizing: #shrinkWrap;
+ 		textColor: colorToUse.
+ 	
+ 	"Only set text attributes for ranges that have none."
+ 	self flag: #todo. "mt: Add interface to Text?"
+ 	self flag: #todo. "mt: Do the same for TextColor. We must not know that #textColor: above does all the magic already."
+ 	fontAttr := TextFontReference toFont: fontToUse.
+ 	offset := nil.
+ 	messageMorph contents runs withIndexDo: [:attrs :index |
+ 		(attrs anySatisfy: [:each | each isKindOf: TextFontChange])
+ 			ifFalse: [offset ifNil: [offset := index]]
+ 			ifTrue: [offset ifNotNil: [
+ 				messageMorph contents
+ 					addAttribute: fontAttr
+ 					from: offset to: index - 1.
+ 				offset := nil]]].
+ 	offset ifNotNil: [
- 	messageMorph ifNotNil: [
- 		| fontToUse colorToUse |
- 		fontToUse := self userInterfaceTheme font ifNil: [TextStyle defaultFont].
- 		colorToUse := self userInterfaceTheme textColor ifNil: [Color black].
- 		
- 		messageMorph
- 			hResizing: #shrinkWrap;
- 			vResizing: #shrinkWrap.
- 		
  		messageMorph contents
+ 			addAttribute: fontAttr
+ 			from: offset to: messageMorph contents size].
+ !
- 			addAttribute: (TextFontReference toFont: fontToUse);
- 			addAttribute: (TextColor color: colorToUse).
- 		messageMorph textColor: colorToUse].!



More information about the Squeak-dev mailing list