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

commits at source.squeak.org commits at source.squeak.org
Mon Sep 2 06:00:11 UTC 2019


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

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

Name: Morphic-mt.1512
Author: mt
Time: 2 September 2019, 7:59:55.139688 am
UUID: 1feb80dc-74d2-2948-a7a1-0192335930f0
Ancestors: Morphic-mt.1511

Clean up StringMorph-related code which also moves some methods from MorphicExtras and Etoys back to Morphic such as #fullPrintOn:

- Clean up font+emphasis behavior in StringMorph; not that StringMorphs keep existing emphasis when a new font is set.
- MenuItemMorph did strange overrides of #hResizing and #vResizing -- I suppose a performance hack from the old days
- No need for UpdatingStringMorph to duplicate implementation for #contents: anymore
- Adds StringMorph >> #contentsFitted: (default) besides #contentsClipped: to make these options more clear

=============== Diff against Morphic-mt.1511 ===============

Item was added:
+ ----- Method: BorderedMorph>>fullPrintOn: (in category 'printing') -----
+ fullPrintOn: aStream
+ 	aStream nextPutAll: '('.
+ 	super fullPrintOn: aStream.
+ 	aStream nextPutAll: ') setBorderWidth: '; print: self borderWidth;
+ 		nextPutAll: ' borderColor: ' , (self colorString: self borderColor)!

Item was changed:
  ----- Method: MenuItemMorph>>drawLabelOn: (in category 'drawing') -----
  drawLabelOn: aCanvas 
  
  	| stringBounds |	
+ 	stringBounds := self bounds.
- 	stringBounds := bounds.
  	
  	self hasIcon ifTrue: [
  		stringBounds := stringBounds left: stringBounds left + self iconForm width + 2 ].
  	self hasMarker ifTrue: [
  		stringBounds := stringBounds left: stringBounds left + self submorphBounds width + 8 ].
  	
  	stringBounds := stringBounds top: stringBounds top + stringBounds bottom - self fontToUse height // 2.
  
  	aCanvas
+ 		drawString: self contents
- 		drawString: contents
  		in: stringBounds
  		font: self fontToUse
  		color: self colorToUse.!

Item was removed:
- ----- Method: MenuItemMorph>>hResizing (in category 'layout-properties') -----
- hResizing
- 	"Default to #spaceFill"
- 	| props |
- 	props := self layoutProperties.
- 	^props ifNil:[#spaceFill] ifNotNil:[props hResizing].!

Item was removed:
- ----- Method: MenuItemMorph>>triangle:containsPoint: (in category 'geometry-testing') -----
- triangle: points containsPoint: p
- 	" Computes if p is in the triangle defined by points.
- 	p should be a Point, and points should be an array with three Points.
- 	I took the algorithm from the bottom of this page: 
- 		http://www.blackpawn.com/texts/pointinpoly/default.html "
- 
- 	| a b c v0 v1 v2 dot00 dot01 dot02 dot11 dot12 denom invDenom u v |
- 	a := points first.
- 	b := points second.
- 	c := points third.
- 	" Compute vectors "
- 	v0 := c - a.
- 	v1 := b - a.
- 	v2 := p - a.
- 	" Compute dot products "
- 	dot00 := v0 dotProduct: v0.
- 	dot01 := v0 dotProduct: v1.
- 	dot02 := v0 dotProduct: v2.
- 	dot11 := v1 dotProduct: v1.
- 	dot12 := v1 dotProduct: v2.
- 	" Compute barycentric coordinates "
- 	denom := dot00 * dot11 - (dot01 * dot01).
- 	denom = 0 ifTrue: [ ^false ].
- 	invDenom := 1 / denom.
- 	u := (dot11 * dot02 - (dot01 * dot12)) * invDenom.
- 	v := (dot00 * dot12 - (dot01 * dot02)) * invDenom.
- 	" Check if point is in triangle "
- 	^u >= 0 and: [ v >= 0 and: [ u + v <= 1 ] ]!

Item was removed:
- ----- Method: MenuItemMorph>>vResizing (in category 'layout-properties') -----
- vResizing
- 	"Default to #shrinkWrap"
- 	| props |
- 	props := self layoutProperties.
- 	^props ifNil:[#shrinkWrap] ifNotNil:[props vResizing].!

Item was changed:
  ----- Method: StringMorph>>contents (in category 'accessing') -----
  contents
  
+ 	^ contents	ifNil: [ self contents: 'String Morph'. contents ]
+ !
- 	^ contents!

Item was changed:
  ----- Method: StringMorph>>contents: (in category 'accessing') -----
  contents: newContents 
+ 
+ 	newContents isText
+ 		ifTrue: [^ self initializeFromText: newContents].
+ 
+ 	contents = newContents
+ 		ifTrue: [^ self "no substantive change"].
+ 
+ 	contents := newContents.
+ 	
+ 	self fitContents.!
- 	| scanner |
- 	contents := newContents isText
- 				ifTrue: [scanner := StringMorphAttributeScanner new initializeFromStringMorph: self.
- 					(newContents attributesAt: 1 forStyle: self font textStyle)
- 						do: [:attr | attr emphasizeScanner: scanner].
- 					emphasis := scanner emphasis.
- 					font := scanner font.
- 					color := scanner textColor.
- 					newContents string]
- 				ifFalse: [contents = newContents
- 						ifTrue: [^ self].
- 					"no substantive change"
- 					newContents].
- 	self fitContents!

Item was changed:
+ ----- Method: StringMorph>>contentsClipped: (in category 'accessing - convenience') -----
- ----- Method: StringMorph>>contentsClipped: (in category 'accessing') -----
  contentsClipped: aString
  	"Change my text, but do not change my size as a result"
  	contents = aString ifTrue: [^ self].  "No substantive change"
  	contents := aString.
  	self changed!

Item was added:
+ ----- Method: StringMorph>>contentsFitted: (in category 'accessing - convenience') -----
+ contentsFitted: aString
+ 	"I fit my contents by default."
+ 	
+ 	self contents: aString.!

Item was changed:
  ----- Method: StringMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas
  
+ 	aCanvas
+ 		drawString: self contents
+ 		in: self bounds
+ 		font: self fontToUse
+ 		color: self color.!
- 	aCanvas drawString: contents in: bounds font: self fontToUse color: color.!

Item was added:
+ ----- Method: StringMorph>>emphasis (in category 'accessing') -----
+ emphasis
+ 	"self assert: emphasis = self font emphasis"
+ 	
+ 	^ emphasis!

Item was changed:
+ ----- Method: StringMorph>>emphasis: (in category 'accessing') -----
- ----- Method: StringMorph>>emphasis: (in category 'font') -----
  emphasis: aNumber
  	"Set the receiver's emphasis as indicated. aNumber is a bitmask with the following format:
  
  	bit	attribute
  	1	bold
  	2	italic
  	4	underlined
  	8	narrow
  	16	struckOut"
  
  	"examples: 0 -> plain.  
  	1 -> bold.  2 -> italic.  3 -> bold italic.  4 -> underlined  
  	5 -> bold underlined.  6 -> italic underlined.   7 -> bold italic underlined   
  	etc..."
  
+ 	self
+ 		setFont: (self font emphasized: aNumber)
+ 		emphasis: aNumber!
- 	emphasis := aNumber.
- 	^ self font: font emphasis: emphasis!

Item was changed:
+ ----- Method: StringMorph>>font: (in category 'accessing') -----
- ----- Method: StringMorph>>font: (in category 'printing') -----
  font: aFont 
  	"Set the font my text will use. The emphasis remains unchanged."
  
  	aFont = font ifTrue: [^ self].
+ 	
+ 	self
+ 		setFont: (aFont emphasized: self emphasis)
+ 		emphasis: self emphasis.!
- 	^ self font: aFont emphasis: emphasis!

Item was changed:
+ ----- Method: StringMorph>>font:emphasis: (in category 'accessing - convenience') -----
- ----- Method: StringMorph>>font:emphasis: (in category 'accessing') -----
  font: aFont emphasis: emphasisCode
+ 
+ 	self
+ 		setFont: ((aFont isNil or: [aFont emphasis = emphasisCode] or: [emphasisCode isNil])
+ 			ifTrue: [aFont]
+ 			ifFalse: [aFont emphasized: emphasisCode])
+ 		emphasis: emphasisCode.!
- 	font := aFont.
- 	emphasis := emphasisCode.
- 	self fitContents.
- "
- in inspector say,
- 	 self font: (TextStyle default fontAt: 2) emphasis: 1
- "!

Item was added:
+ ----- Method: StringMorph>>fontName: (in category 'fonts') -----
+ fontName: fontName
+ 
+ 	self
+ 		fontName: fontName
+ 		size: TextStyle defaultFont pixelSize
+ 		emphasis: 0.!

Item was added:
+ ----- Method: StringMorph>>fontName:pointSize: (in category 'fonts') -----
+ fontName: fontName pointSize: fontSize
+ 
+ 	self
+ 		fontName: fontName
+ 		pointSize: fontSize
+ 		emphasis: 0.!

Item was added:
+ ----- Method: StringMorph>>fontName:pointSize:emphasis: (in category 'fonts') -----
+ fontName: fontName pointSize: fontSize emphasis: emphasisCode
+ 
+ 	self
+ 		setFont: (StrikeFont familyName: fontName pointSize: fontSize emphasized: emphasisCode)
+ 		emphasis: emphasisCode.!

Item was changed:
+ ----- Method: StringMorph>>fontName:size: (in category 'fonts') -----
- ----- Method: StringMorph>>fontName:size: (in category 'accessing') -----
  fontName: fontName size: fontSize
  
+ 	self
+ 		fontName: fontName
+ 		size: fontSize
+ 		emphasis: 0.!
- 	^ self font: (StrikeFont familyName: fontName size: fontSize) 
- 			emphasis: 0!

Item was added:
+ ----- Method: StringMorph>>fontName:size:emphasis: (in category 'fonts') -----
+ fontName: fontName size: fontSize emphasis: emphasisCode
+ 
+ 	self
+ 		setFont: (StrikeFont familyName: fontName size: fontSize emphasized: emphasisCode)
+ 		emphasis: emphasisCode.!

Item was changed:
+ ----- Method: StringMorph>>fontToUse (in category 'drawing') -----
- ----- Method: StringMorph>>fontToUse (in category 'accessing') -----
  fontToUse
+ 	"Support un-initialized font or emphasis variable."
+ 	
+ 	^ font ifNil: [TextStyle defaultFont emphasized: (self emphasis ifNil: [0])]!
- 	| fontToUse |
- 	fontToUse := font isNil ifTrue: [TextStyle defaultFont] ifFalse: [font].
- 	(emphasis isNil or: [emphasis = 0]) 
- 		ifTrue: [^fontToUse]
- 		ifFalse: [^fontToUse emphasized: emphasis]!

Item was removed:
- ----- Method: StringMorph>>fullBounds (in category 'layout') -----
- fullBounds
- 	self contents ifNil: [ self contents: 'String Morph' ].
- 	^super fullBounds!

Item was added:
+ ----- Method: StringMorph>>fullPrintOn: (in category 'printing') -----
+ fullPrintOn: aStream
+ 
+ 	aStream nextPutAll: '('.
+ 	super fullPrintOn: aStream.
+ 	aStream nextPutAll: ') contents: '; print: contents!

Item was changed:
+ ----- Method: StringMorph>>hasTranslucentColor (in category 'testing') -----
- ----- Method: StringMorph>>hasTranslucentColor (in category 'accessing') -----
  hasTranslucentColor
  
  	^true!

Item was changed:
  ----- Method: StringMorph>>initWithContents:font:emphasis: (in category 'initialization') -----
  initWithContents: aString font: aFont emphasis: emphasisCode 
+ 
+ 	self initialize.
- 	super initialize.
  	
+ 	contents := aString.
+ 	
+ 	self font: aFont emphasis: emphasisCode.!
- 	font := aFont.
- 	emphasis := emphasisCode.
- 	hasFocus := false.
- 	self contents: aString!

Item was added:
+ ----- Method: StringMorph>>initializeFromText: (in category 'initialization') -----
+ initializeFromText: aText
+ 
+ 	| scanner |
+ 	scanner := StringMorphAttributeScanner new initializeFromStringMorph: self.
+ 
+ 	(aText attributesAt: 1 forStyle: self font textStyle)
+ 		do: [:attr | attr emphasizeScanner: scanner].
+ 
+ 	emphasis := scanner emphasis.
+ 	font := scanner font.
+ 	color := scanner textColor.
+ 
+ 	self contents: aText string.!

Item was changed:
+ ----- Method: StringMorph>>interimContents: (in category 'accessing - support') -----
- ----- Method: StringMorph>>interimContents: (in category 'accessing') -----
  interimContents: aString
  	"The receiver is under edit and aString represents the string the user sees as she edits, which typically will not have been accepted and indeed may be abandoned"
  
  	self contents: aString!

Item was changed:
+ ----- Method: StringMorph>>label:font: (in category 'accessing - convenience') -----
- ----- Method: StringMorph>>label:font: (in category 'accessing') -----
  label: aString font: aFont
  	"compatible protocol used in ScriptEditorMorph>>bringUpToDate"
  	self contents: aString.
  	self font: aFont!

Item was changed:
+ ----- Method: StringMorph>>measureContents (in category 'accessing - support') -----
- ----- Method: StringMorph>>measureContents (in category 'accessing') -----
  measureContents
  	| f |
  	f := self fontToUse.
  	^(((f widthOfString: contents) max: self minimumWidth)  @ f height).!

Item was changed:
+ ----- Method: StringMorph>>minHeight (in category 'layout') -----
- ----- Method: StringMorph>>minHeight (in category 'connectors-layout') -----
  minHeight
+ 	"Layout specific."
+ 	
- "answer the receiver's minHeight"
  	^ super minHeight max: self fontToUse height!

Item was added:
+ ----- Method: StringMorph>>minWidth (in category 'layout') -----
+ minWidth
+ 	"Layout specific."
+ 	
+ 	^ super minWidth max: (self fontToUse widthOfString: self contents)!

Item was removed:
- ----- Method: StringMorph>>minimumWidth (in category 'accessing') -----
- minimumWidth
- 	"Answer the minimum width that the receiver can have.  A nonzero value here keeps the receiver from degenerating into something that cannot ever be seen or touched again!!  Obeyed by fitContents."
- 
- 	^ 3!

Item was added:
+ ----- Method: StringMorph>>setFont:emphasis: (in category 'initialization') -----
+ setFont: aFont emphasis: emphasisCode
+ 	"self assert: emphasisCode = aFont emphasis."
+ 
+ 	font := aFont.
+ 	emphasis := emphasisCode.
+ 	
+ 	self fitContents.
+ 
+ "
+ in inspector say,
+ 	 self font: (TextStyle default fontAt: 2) emphasis: 1
+ "!

Item was changed:
+ ----- Method: StringMorph>>setWidth: (in category 'accessing - support') -----
- ----- Method: StringMorph>>setWidth: (in category 'accessing') -----
  setWidth: width
  
  	self extent: width @ (font ifNil: [TextStyle defaultFont]) height!

Item was changed:
+ ----- Method: StringMorph>>userString (in category 'accessing - support') -----
- ----- Method: StringMorph>>userString (in category 'accessing') -----
  userString
  	"Do I have a text string to be searched on?"
  
  	^ contents!

Item was changed:
+ ----- Method: StringMorph>>valueFromContents (in category 'accessing - support') -----
- ----- Method: StringMorph>>valueFromContents (in category 'accessing') -----
  valueFromContents
  	"Return a new value from the current contents string."
  	^ contents!

Item was added:
+ ----- Method: TextMorph>>fullPrintOn: (in category 'printing') -----
+ fullPrintOn: aStream
+ 
+ 	aStream nextPutAll: '('.
+ 	super fullPrintOn: aStream.
+ 	aStream nextPutAll: ') contents: '; print: text!

Item was removed:
- ----- Method: UpdatingStringMorph>>contents: (in category 'accessing') -----
- contents: newContents 
- 	"This is the original StringMorph implementation of #contents:, restored down in UpdatingStringMorph because a recent 'optimization' of the StringMorph version of this method broke UpdatingStringMorphs."
- 
- 	contents := newContents isText 
- 				ifTrue:  
- 					[emphasis := newContents emphasisAt: 1.
- 					newContents string]
- 				ifFalse: 
- 					[contents = newContents ifTrue: [^self].	"no substantive change"
- 					newContents].
- 	self fitContents.
- 	self changed!

Item was added:
+ ----- Method: UpdatingStringMorph>>maximumWidth: (in category 'accessing') -----
+ maximumWidth: aValue
+ 	"Set the maximum width that the receiver can have."
+ 
+ 	maximumWidth := aValue!

Item was added:
+ ----- Method: UpdatingStringMorph>>minWidth (in category 'accessing') -----
+ minWidth
+ 	"Answer the minimum width that the receiver can have.  A nonzero value here keeps the receiver from degenerating into something that cannot ever be seen or touched again!!  Obeyed by fitContents."
+ 
+ 	^ minimumWidth ifNil: [minimumWidth := 8]!

Item was added:
+ ----- Method: UpdatingStringMorph>>minWidth: (in category 'accessing') -----
+ minWidth: aWidth
+ 	"Set the minimum width that the receiver can have.  A nonzero value here keeps the receiver from degenerating into something that cannot ever be seen or touched again!!  Obeyed by fitContents."
+ 
+ 	minimumWidth := aWidth!

Item was removed:
- ----- Method: UpdatingStringMorph>>minimumWidth (in category 'accessing') -----
- minimumWidth
- 	"Answer the minimum width that the receiver can have.  A nonzero value here keeps the receiver from degenerating into something that cannot ever be seen or touched again!!  Obeyed by fitContents."
- 
- 	^ minimumWidth ifNil: [minimumWidth := 8]!

Item was removed:
- ----- Method: UpdatingStringMorph>>minimumWidth: (in category 'accessing') -----
- minimumWidth: aWidth
- 	"Set the minimum width that the receiver can have.  A nonzero value here keeps the receiver from degenerating into something that cannot ever be seen or touched again!!  Obeyed by fitContents."
- 
- 	minimumWidth := aWidth!

Item was changed:
+ (PackageInfo named: 'Morphic') postscript: '"Reset contributors."
+ SystemNavigation cleanUp: true.'!
- (PackageInfo named: 'Morphic') postscript: '"Convert all cell insets to cell gaps."
- TableLayoutProperties allInstancesDo: [:ea |
- 	ea cellInset isZero ifFalse: [
- 		ea
- 			cellGap: (ea cellInset isRectangle ifTrue: [ea cellInset topLeft] ifFalse: [ea cellInset]);
- 			cellInset: 0]].'!



More information about the Squeak-dev mailing list