'From Squeak3.3alpha of 24 January 2002 [latest update: #4730] on 1 February 2002 at 2:18:59 am'! "Change Set: HandRedrawFix Date: 1 February 2002 Author: Andreas Raab A fix for incremental updates in HandMorph."! !HandMorph methodsFor: 'drawing' stamp: 'ar 2/1/2002 02:14'! updateCacheCanvas: aCanvas "Update the cached image of the morphs being held by this hand." | subBnds rectList nPix | "Note: The following is an attempt to quickly get out if there's no change" subBnds _ Rectangle merging: (submorphs collect: [:m | m fullBounds]). rectList _ damageRecorder invalidRectsFullBounds: subBnds. damageRecorder reset. (rectList isEmpty and:[cacheCanvas notNil and:[cacheCanvas extent = subBnds extent]]) ifTrue:[^self]. "Always check for real translucency -- can't be cached in a form" self submorphsDo:[:m| m wantsToBeCachedByHand ifFalse:[ cacheCanvas _ nil. cachedCanvasHasHoles _ true. ^ self]]. (cacheCanvas == nil or: [cacheCanvas extent ~= subBnds extent]) ifTrue: [ cacheCanvas _ (aCanvas allocateForm: subBnds extent) getCanvas. cacheCanvas translateBy: subBnds origin negated during:[:tempCanvas| self drawSubmorphsOn: tempCanvas]. self submorphsDo: [:m | (m areasRemainingToFill: subBnds) isEmpty ifTrue: [^ cachedCanvasHasHoles _ false]]. nPix _ cacheCanvas form tallyPixelValues at: 1. "--> begin rounded corners hack <---" (nPix = 48 and:[submorphs size = 1 and:[submorphs first wantsRoundedCorners]]) ifTrue:[cachedCanvasHasHoles _ false] ifFalse:[cachedCanvasHasHoles _ nPix > 0]. "--> end rounded corners hack <---" ^ self]. "incrementally update the cache canvas" cacheCanvas translateBy: subBnds origin negated during:[:cc| rectList do: [:r | cc clipBy: r during:[:c| c fillColor: Color transparent. self drawSubmorphsOn: c]]].! !