[squeak-dev] Morph corner radius set to 8 does surprising things

Bob Arning arning315 at comcast.net
Tue Dec 6 02:57:55 UTC 2016


This method in HandMorph seems to have a view of corner rounding that 
depends on a particular corner geometry. You might try changing the 
highlighted code to


             nPix := cacheCanvas form tallyPixelValues first.         
     "--> begin rounded corners hack <---"             
cachedCanvasHasHoles := true "(nPix = 48                         and: 
[submorphs size = 1 and: [submorphs first wantsRoundedCorners]])         
                     ifTrue: [false]                             
ifFalse: [nPix > 0]".             "--> end rounded corners hack <---"

Some drawing of morphs in the hand may be slower, but on modern machines 
you might never notice it.

updateCacheCanvas: aCanvas     "Update the cached image of the morphs 
being held by this hand."     "Note: The following is an attempt to 
quickly get out if there's no change"     | subBnds rectList nPix |     
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 isNil 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 first.             "--> begin rounded corners hack 
<---"             cachedCanvasHasHoles := (nPix = 48                     
     and: [submorphs size = 1 and: [submorphs first 
wantsRoundedCorners]])                             ifTrue: [false]     
                         ifFalse: [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]]]


On 12/5/16 8:47 PM, tim Rowledge wrote:
> In a plain Squeak 5.1 image, create a RectangleMorph and use its menu to set ‘round corners’.
> Open the PreferenceBrowser and find the ‘Preferred Corner Radius’ - in the copy of the release 5.1-16548 I have that is ‘8’.
>
> Now drag the rectangle morph - note how the corners get replaced by funny little filled triangles instead of being rounded!
> Now change the preferred radius to 7. Note how the dragging works perfectly well. Try 9. Hell, try any other number.
>
> So far as I can tell only 8 causes a problem. Clearly one answer is “don’t do that” and change the default. But I’m completely baffled as to what is going on here. Why only 8? Why only when being dragged? Right now I’m not able to spot where the drag rendering might diverge.
>
> tim
> --
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> "Bother" said Pooh as "Formating Drive C" appeared on the screen...
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20161205/d5ac7c83/attachment.html>


More information about the Squeak-dev mailing list