On 22.12.2012 14:36, Stéphane Ducasse wrote:
Igor
may be having good design could help with little objects having
responsibilities and plugging the right ones :)
We should create
"The club of gentleman against little kitties killing code"
and save the kitties by refactoring the killing code :)
Stef
Thing is, the below code is probably easier to understand/less complex
than one based on plugging.
One could argue that understanding it would just be one #haltOnce away,
but here it's all spelled out in one place.
Also, the reason it was pushed in the first place was there _were_
non-BorderedMorphs which would have rendering errors if the border
wasn't checked, IIRC o_O
When it comes to separation of concerns, I'm not sure I'd be comfortable
with a little object like (Border)Color having methods for determining
the visible areas below a morph it belongs to either, so I guess a
bigger refactoring would be in order ;)
Cheers,
Henry
areasRemainingToFill: aRectangle
"Pushed up from BorderedMorph, all cases tested for there are
supported by basic Morph."
"Morphs which achieve translucency by other means than fillStyle will
have
to reimplement this"
"Fixed here to test the fillStyle rather than color for translucency.
Since can have a translucent fillStyle while the (calculated) color is
not."
self fillStyle isTranslucent
ifTrue: [^ Array with: aRectangle].
self wantsRoundedCorners
ifTrue: [(self borderWidth > 0
and: [self borderColor isColor
and: [self borderColor
isTranslucent]])
ifTrue: [^ aRectangle
areasOutside: (self innerBounds
intersect: self boundsWithinCorners)]
ifFalse: [^ aRectangle areasOutside: self
boundsWithinCorners]]
ifFalse: [(self borderWidth > 0
and: [self borderColor isColor
and: [self borderColor
isTranslucent]])
ifTrue: [^ aRectangle areasOutside: self
innerBounds]
ifFalse: [^ aRectangle areasOutside: self
bounds]]
... the whole Morphic code fall victim of rounded corners (and borders
, of course).
I wonder, is there any way to
a) have multiple concerns
b) at same time, have a clean code
?
But i suspect that smalltalk is not powerful enough for that. :)