On Mon, Mar 21, 2011 at 11:38 PM, Chris Bartlett <[email protected]>wrote:
> On 22 March 2011 09:26, Bill van Melle <[email protected]> wrote: > >> There's a note in the 2.0 change log about "named styles" ( >> https://issues.apache.org/jira/browse/PIVOT-553). ... >> > I think this example goes with that JIRA ticket on named styles. > > http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/styles/ > I don't get the connection. It's a visually complicated demo that as best I can tell is showing a way to experiment with different base colors in the global terra theme. I don't see named or typed styles anywhere. > Styles can be named or typed and are stored in static maps in Component, so > I don't think it is possible to scope them. Of course you could use > different style names for your different BXML files, but that may not help > you much. > > http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getNamedStyles() > > http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/Component.html#getTypedStyles() > http://pivot.apache.org/2.0/docs/api/org/apache/pivot/wtk/ > ApplicationContext.html#applyStylesheet(java.lang.String) > You can apply a stylesheet programmatically like this > > ApplicationContext.applyStylesheet("/fully/qualified/path/to/my_styles_file.json"); > If the only way to change the style of, say, a Label is to change the style of *all* Labels, then that's pretty useless to me. That's more of a global skinning facility. I don't object to having a style name per BXML file, but it's unclear to me how I make use of it. Sorry if I'm being obtuse here. If I have to do something like this in foo.bxml: <bxml:define> <bxml:include bxml:id="fooStyle" src="foo_styles.json"/> </bxml:define> and then throughout foo.bxml have markup that looks like <Label text="..." styles="$fooStyle.labelStyle"/> well, that's kind of painful. I was kind of hoping for something I could put at the top of the bxml file to set styles for the whole file. I suppose there could be a programmatic workaround, if there were a function I could call in Foo.java to walk the component structure of Foo and apply a set of styles to each node (though it's always nicer to have all the markup in one place and not separated like that).
