[squeak-dev] The Trunk: Morphic-MAD.203.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Oct 7 04:43:19 UTC 2009


Andreas Raab uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-MAD.203.mcz

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

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've also slightly increased the radius so that the curve is visible.

=============== Diff against Morphic-ar.202 ===============

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 at 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.
+ 	"Tweaked offsets to clean up curves. MAD"
+ 	endPoint := segments last end + rectOffset + (0 at -1).
- 	endPoint := segments last end + rectOffset.
  	1 to: 8 by: 2 do:[:i|
+ 		i = 1 ifTrue:[offset := rectOffset + (rectExtent x @ 0) + (1 at -1)]. "top, tr"
+ 		i = 3 ifTrue:[offset := rectOffset + rectExtent + (1 at 1)]. "right, br"
+ 		i = 5 ifTrue:[offset := rectOffset + (0 @ rectExtent y) + (0 at 1)]. "bottom, bl"
+ 		i = 7 ifTrue:[offset := rectOffset + (0 at -1)]."left, tl"
- 		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].
  		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!

Item was changed:
  ----- Method: PluggableButtonMorph>>drawOn: (in category 'drawing') -----
  drawOn: aCanvas 
  	| cc gradient |
  	cc := self color.
  	cc isTransparent ifTrue:[cc := Color gray: 0.9].
  	self enabled ifFalse:[cc := Color lightGray].
  	cc brightness > 0.9 ifTrue:[cc := cc adjustBrightness: 0.9 - cc brightness].
  	showSelectionFeedback ifTrue:[
  		gradient := GradientFillStyle ramp: {
  			0 -> (Color gray: 0.75).
  			0.5 -> (Color gray: 0.85).
  			0.51 -> (Color gray: 0.9).
  			1 -> (Color gray: 1).
  		}.
  	] ifFalse:[
  		gradient := GradientFillStyle ramp: {
  			0.0 -> Color white.
  			0.5 -> (cc).
  			0.51-> (cc adjustBrightness: -0.1).
  			1 -> (Color gray: 0.95).
  		}
  	].
  	gradient origin: bounds topLeft.
  	gradient direction: 0 at self height.
+ 	^aCanvas frameAndFillRoundRect: bounds radius: 8 fillStyle: gradient borderWidth: 1 borderColor: Color lightGray.!
- 	^aCanvas frameAndFillRoundRect: bounds radius: 6 fillStyle: gradient borderWidth: 1 borderColor: Color lightGray.!




More information about the Squeak-dev mailing list