[squeak-dev] The Inbox: Morphic-ct.1998.mcz

commits at source.squeak.org commits at source.squeak.org
Fri May 20 20:50:12 UTC 2022


A new version of Morphic was added to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1998.mcz

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

Name: Morphic-ct.1998
Author: ct
Time: 20 May 2022, 10:50:05.367428 pm
UUID: 8ff0b2bd-e9c1-8a40-b996-c5e4e6278b63
Ancestors: Morphic-ct.1996

Proposal to fix protruding pixels in rounded rects. This can be reproduced as follows:

	Turn on the preference #alternateHandlesLook and blue-drag any morph to the left/to the bottom.
	
	Alternatively, do the following:
	
		m := RectangleMorph new.
		
		m borderWidth: 0.
		m useRoundedCorners.
		m color: Color blue.
		m fillStyle: ((GradientFillStyle ramp: {0.0 -> Color red. 1.0 -> Color blue})
			origin: m topLeft;
			direction: m extent;
			yourself).
		
		m openInWorld.
		m position: 100 asPoint.
		
		m left: m left - 1. "evaluate"
		m left: m left - 1. "step"
		m left: m left - 1. "by"
		m left: m left - 1. "step"

Debugging reveals that the BalloonCanvas draws some pixels outside of the bounds of the morph, so the damage is not recorded properly (all screenshots will be sent in a follow-up email).

This proposed fix effectively reverts Morphic-MAD.203 and restores the original version of BalloonCanvas>>#makeRoundRectShape:radius: (ar 7/22/2009 21:34) from Morphic-ar.136 by Andreas Raab (just made the formatting consistent). The patch of Michael Davies seemed suspicious to me, here is his version message:

	Name: Morphic-MAD.203
	Author: MAD
	Time: 6 October 2009, 7:24:39 am
	UUID: 3098c8d3-ea9e-4db8-910e-53d9bf57f9e2
	Ancestors: Morphic-ar.202

	Hack to fix problem with rounding of buttons - I'm happy to take advice on how to address the underlying problem. [...]

I cannot make any sense out of this. Neither in a current Trunk image nor in an old Squeak 4.4 image, I can find any rounding problems with buttons when I revert to Andreas' original implementation. A pixel-by-pixel comparison only shows that Michael's version draws pixels outside of the bounds, but otherwise, both rectangles look identical (none of them are rendered symmetrically, by the way). In order to fix the obvious problem, I propose to revert to the original version.

=============== Diff against Morphic-ct.1996 ===============

Item was changed:
  ----- Method: BalloonCanvas>>makeRoundRectShape:radius: (in category 'private') -----
  makeRoundRectShape: aRectangle radius: radius
  	"decompose a rounded rectangle into bezier form"
  	| ovalDiameter rectExtent segments points endPoint seg idx offset rectOffset |
  	ovalDiameter := (radius * 2) asPoint min: aRectangle extent.
  	(ovalDiameter x <= 0 or: [ovalDiameter y <= 0]) ifTrue: [
  		"degenerates into rectangle - just hand back four lines"
  		| topLeft topRight bottomLeft bottomRight |
  		topLeft := aRectangle topLeft.
  		topRight := aRectangle topRight.
  		bottomLeft := aRectangle bottomLeft.
  		bottomRight := aRectangle bottomRight.
  
  		points := Array new: 4 * 3.
  		points at: 1 put: topLeft.
  		points at: 2 put: topLeft.
  		points at: 3 put: topRight.
  
  		points at: 4 put: topRight.
  		points at: 5 put: topRight.
  		points at: 6 put: bottomRight.
  
  		points at: 7 put: bottomRight.
  		points at: 8 put: bottomRight.
  		points at: 9 put: bottomLeft.
  
  		points at: 10 put: bottomLeft.
  		points at: 11 put: bottomLeft.
  		points at: 12 put: topLeft.
  		^points
  	].
  	rectExtent := aRectangle extent - ovalDiameter.
  	rectOffset := aRectangle origin.
  	segments := Bezier2Segment makeEllipseSegments: (0 @ 0 extent: ovalDiameter).
  	"patch up the segments to include lines connecting the oval parts.
  	we need: 8*3 points for the oval parts + 4*3 points for the connecting lines"
  	points := Array new: 12 * 3.
  	idx := 0.
+ 	endPoint := segments last end + rectOffset.
- 	"Tweaked offsets to clean up curves. MAD"
- 	endPoint := segments last end + rectOffset + (0 @ -1).
  	1 to: 8 by: 2 do: [:i |
+ 		i = 1 ifTrue: [offset := rectOffset + (rectExtent x @ 0)].
+ 		i = 3 ifTrue: [offset := rectOffset + rectExtent].
+ 		i = 5 ifTrue: [offset := rectOffset + (0 @ rectExtent y)].
+ 		i = 7 ifTrue: [offset := rectOffset].
- 		i = 1 ifTrue: [offset := rectOffset + (rectExtent x @ 0) + (1 @ -1)]. "top, tr"
- 		i = 3 ifTrue: [offset := rectOffset + rectExtent + (1 @ 1)]. "right, br"
- 		i = 5 ifTrue: [offset := rectOffset + (0 @ rectExtent y) + (0 @ 1)]. "bottom, bl"
- 		i = 7 ifTrue: [offset := rectOffset + (0 @ -1)]."left, tl"
  		seg := segments at: i.
  		"insert a line segment for the horizontal part of the round rect"
  		points at: (idx := idx + 1) put: endPoint.
  		points at: (idx := idx + 1) put: endPoint.
  		points at: (idx := idx + 1) put: seg start + offset.
  		"now the first half-arc"
  		points at: (idx := idx + 1) put: seg start + offset.
  		points at: (idx := idx + 1) put: seg via + offset.
  		points at: (idx := idx + 1) put: seg end + offset.
  		"the second half-arc"
  		seg := segments at: i + 1.
  		points at: (idx := idx + 1) put: seg start + offset.
  		points at: (idx := idx + 1) put: seg via + offset.
  		points at: (idx := idx + 1) put: seg end + offset.
  		endPoint := seg end + offset.
  	].
  	^points!



More information about the Squeak-dev mailing list