[FIX] CornerRounder

Hans-Martin Mosner hm.mosner at cityweb.de
Sun Mar 12 20:04:55 UTC 2000


This fixes the following two problems with CornerRounder:
1. nested invocations did not work correctly
2. inset and raised bevels were not colored correctly

Incidentally, it also fixes the shadow drawing for rounded corners
(which was probably related to problem #1)

Hans-Martin
-------------- next part --------------
'From Squeak2.8alpha of 19 January 2000 [latest update: #1852] on 11 March 2000 at 5:29:22 pm'!
"Change Set:		CornerRounder-hmm
Date:			11 March 2000
Author:			Hans-Martin Mosner <hmm at heeg.de>

Fixes 2 issues with the CornerRounder:
1. recursive use does work now
2. beveled borders are correctly rounded (for widths 1 and 2)"!


!CornerRounder methodsFor: 'all' stamp: 'hmm 3/8/2000 18:15'!
tweakCornersOf: aMorph on: aCanvas borderWidth: w

	| offset corner saveBits c fourColors c14 c23 mask nonShadowCanvas |
	nonShadowCanvas _ aCanvas isShadowDrawing
			ifTrue: [aCanvas nonShadowCopy]
			ifFalse: [aCanvas].
	w > 0 ifTrue:
		[c _ aMorph borderColor.
		fourColors _ Array new: 4 withAll: c.
		c == #raised ifTrue:
			[c _ aMorph color.
			w = 1
				ifTrue: [c14 _ c twiceLighter. c23 _ c twiceDarker]
				ifFalse: [c14 _ c lighter. c23 _ c darker].
			fourColors _ Array with: c14 with: c with: c23 with: c].
		(c == #inset and: [aMorph owner notNil]) ifTrue:
			[c _ aMorph owner colorForInsets.
			w = 1
				ifTrue: [c14 _ c twiceLighter. c23 _ c twiceDarker]
				ifFalse: [c14 _ c lighter. c23 _ c darker].
			fourColors _ Array with: c23 with: c with: c14 with: c]].
	mask _ Form extent: cornerMasks first extent depth: aCanvas depth.
	(1 to: 4) do:
		[:i | 
		corner _ aMorph bounds corners at: i.
		saveBits _ underBits at: i.
		i = 1 ifTrue: [offset _ 0 at 0].
		i = 2 ifTrue: [offset _ 0 at saveBits height negated].
		i = 3 ifTrue: [offset _ saveBits extent negated].
		i = 4 ifTrue: [offset _ saveBits width negated at 0].

		"Mask out corner area (painting saveBits won't clear if transparent)."
		mask copyBits: mask boundingBox from: (cornerMasks at: i) at: 0 at 0 clippingBox: mask boundingBox rule: Form over fillColor: nil map: (Bitmap with: 0 with: 16rFFFFFFFF).
		nonShadowCanvas image: mask at: corner + offset sourceRect: mask boundingBox rule: Form and.

		"Paint back corner bits."
		nonShadowCanvas image: saveBits at: corner + offset.

		w > 0 ifTrue:
			["Paint over with border if any"
			aCanvas stencil: (cornerOverlays at: i) at: corner + offset
					color: (fourColors at: i)]].

! !


!CornerRounder class methodsFor: 'all' stamp: 'hmm 3/8/2000 17:42'!
roundCornersOf: aMorph on: aCanvas displayBlock: displayBlock borderWidth: w

	| rounder |
	rounder _ CR0.
	w = 1 ifTrue: [rounder _ CR1].
	w = 2 ifTrue: [rounder _ CR2].
	rounder _ rounder copy.
	rounder saveBitsUnderCornersOf: aMorph on: aCanvas.
	displayBlock value.
	rounder tweakCornersOf: aMorph on: aCanvas borderWidth: w! !

!CornerRounder class methodsFor: 'all' stamp: 'hmm 3/8/2000 17:42'!
roundCornersOf: aMorph on: aCanvas displayBlock: displayBlock borderWidth: w corners: aList

	| rounder |
	rounder _ CR0.
	w = 1 ifTrue: [rounder _ CR1].
	w = 2 ifTrue: [rounder _ CR2].
	rounder _ rounder copy.
	rounder saveBitsUnderCornersOf: aMorph on: aCanvas.
	displayBlock value.
	rounder tweakCornersOf: aMorph on: aCanvas borderWidth: w corners: aList! !




More information about the Squeak-dev mailing list