Great points. 

If you want a direct override through a global sheet specified externally in
JSON, then you are already in good shape with your proposal. However, you
don't need any changes to pivot at all to do it and you could provide a
small helper class to help folks who want to do it.

I also think I am using the word inherited styles two different ways and its
probably me that's causing confusion. Inherited styles could mean, "a
component inherits styles based on the component that I am" and it could
mean "styles that are specified from parent components should be used within
my lookup scope for the style name." Its the separation of how/where its
specified and how its applied.

My comments about inheritance really applied only when you are doing class
matching and automatic styles, which may or may not be a requirement. The
other comment I'll make is if you implement named styles, do you only search
that global style sheet (specified in JSON)? Or you do want to be able to
place a named style in a parent component and have that applied to any
children who want a named style? In this case the parent can provide the
name style in any way it wants. This also may or may not be a requirement. 


In fact the only thing I would ask for is to add a
suspend/resumePainting/Layout method to reduce processing overhead during
multiple style changes.


Alright...I'm off to weekend vacation activities...except reading Romain's
book again on rich clients.

Enjoy the 4th everyone!


-----Original Message-----
From: Greg Brown [mailto:gkbr...@mac.com] 
Sent: Saturday, July 03, 2010 7:58 AM
To: dev@pivot.apache.org
Subject: Re: Named styles

> a) How can designers created named styles and add them to the application
> easily?

I agree that this is a requirement.

> b) How can I make styles automatically picked up if they are change?

I'm not sure I would include this as a requirement. I know it is possible in
CSS, but I have rarely used it in practice. It's a similar idea to replacing
the entire L&F on the fly, and we don't support that either (we actually
used to, but dropped it because it added needless complexity).

> c) How can I apply styles without having the programmer do anything?

This seems related to (a) and also seems like a valid requirement.

> d) How can named styles build on each other? The union of all applicable
> styles should be honored.

This is the question of multiple styles. Not sure if I'd include it as a
requirement, but it is a nice-to-have.

> If a named style exists, you must use that
> explicitly, but otherwise, how can we aggregate styles through the
> parent-child relationship?

Based on the work I have done over the past couple of days, I think this
will be difficult to achieve (see my earlier email about construction order
in BXML). I'm also not sure it offers enough value. Inheriting styles makes
sense in CSS, because CSS is primarily used to style text (e.g. I want my
<span> to inherit the same color and font as the <div> that contains it).
Pivot's text classes (org.apache.pivot.wtk.text) also support style
inheritance for this reason. However, as I mentioned earlier, components
don't inherit styles because there is generally little or no overlap between
ancestor styles and component styles. 

So, I would not include this as a requirement. IMO, a global set of named
styles (a la CSS) would be sufficient.

> e) How can an individual component indicate they don't want automatic
> styling and turn everything off?

Also not a requirement. If I create a class and assign that class to a
component, the styles for that class should be applied to the component.

> f) How can I add a style "key" but not change any pivot code? 

Not necessarily a requirement, but keeping changes to a minimum would be
good.

> g) Can I have a mechanism that I could change so that styles can be
> specified in another syntax besides JSON? Since JSON is easier XML, maybe
I
> want a dynamic language data structure way of doing this.

The most recently solution I proposed would support this.


Reply via email to