It occurred to me earlier that the styling solution I am proposing would 
actually support dynamically updated styles. Fundamentally, all styles are set 
via Component#getStyles(). This method returns an instance of StyleDictionary 
that, in turn, wraps a bean dictionary that wraps the skin. So, a put() to the 
style dictionary ultimately translates to a bean setter on the skin.

However, in practice, most styles are set via one of Component's setStyle() 
overloads. These methods ultimately result in a call to setStyles(Map<String, 
?), which applies the styles from the map to the StyleDictionary. Since Maps 
fire events when properties change, a component instance could actually listen 
for change events on the map and update the style dictionary when a property 
changes. This would allow an application to update a style definition and have 
it automatically propagated to all components using that style.

Again, I'm not sure how often this might be used in a real application, but it 
could be supported easily. The only thing I might want to add is a way to turn 
auto-updates on and off:

<Label styles="$styles.myLabel" autoUpdateStyles="false"/>

Anyways, I'm not entirely sure it is worth implementing, but it is something to 
think about.

G

Reply via email to