stathissideris/clarity — comment on commit e975b3a61130e4ce7f03e9860ab60e1e692d25b2
File:  line 0
By stathissideris:

Well, the main problem is *when*. The way the (make) macro works in
clarity, I would have to apply the stylesheet at creation time. The
stylesheet mechanism starts with the root and tests each of the
members of the component hierarchy on whether they match any of the
rules, and applies the different looks when applicable. The problem
with that is that when it's just been created, the component is empty,
so nothing happens (unless the root itself matches, in which case
itself is configured but non of its children that are added later). My
solution to that was to add a ContainerListener and listen for
componentAdded events, and apply the same stylesheet to each one of
them as they were being added.

The problem with this solution is that it has the potential to result
in the same stylesheet being applied to the component more than once
(although now that I think about it, maybe not). This should never
happen, because styles in clarity are just a bunch of "mutators",
basically a bit of code that can contain anything (for example a
"style" could add a listener that changes the background on mouse
over) and definitely has side-effects, so "applying" it twice to a
component could have unforeseen and hard to debug consequences.

Does that make sense?

Hm, I need to think about this a bit harder...

On 11 February 2012 00:14, Dave Ray

wrote:
> I'm very interested to hear what was "stupid" about it. I've thought about this problem a bunch (not recently though), but it always seemed to have a bunch of problems. I can't remember what they were though :)
>
> ---
> Reply to this email directly or view it on GitHub:
> https://github.com/stathissideris/clarity/commit/e975b3a61130e4ce7f03e9860ab60e1e692d25b2#commitcomment-955814