@t0neg0d said:
Thanks!
I really like the idea of CSS type layouts/properties/whatever.
Yeah, it’s “css-like” at best and based on the element ID (plus overall style)
So in the basic case, where CSS might have:
[java]
p
{
color:red;
text-align:center;
}
[/java]
Lemur might have:
[java]
selector(“label”, “myStyle”)
{
color:color(1,0,0,1)
textHAlignment=HAlignment.CENTER
}
[/java]
…or something. (“selector” being a word I stole from CSS even if it doesn’t use it in its syntax.")
And I support a similar nesting though it’s based on ID instead of hierarchy.
so in CSS:
[java]
.impact p
{
color:white
}
[/java]
…would apply to any paragraph inside of an element with class ‘impact’. Even if it’s way nested.
In Lemur, I can’t really do this because the styles are applied before the element has a hierarchy but I liked the idea and it’s still useful. So Lemur takes apart the ID and does containment that way.
So if I have some Label with a special element ID “impact.option.label” then the similar Lemur style would be:
[java]
selector(“impact”, “label”, “myStyle”)
{
color:color(1,1,1,1)
}
[/java]
…which apply to any label with “impact.label”, “impact.foo.bar.label”, and our original “impact.option.label”.
Anything applied to the style directly would be the default for any gui element of that style. So if I want all of the fonts of “myStyle” to default to some special font:
[java]
selector(“myStyle”)
{
font:font(“Interface/arial.fnt”)
}
[/java]
Any GUI element property with a Style annotation can be set this way. So it just depends on what the GUI element has defined… but layouts, insets, font, font size, etc. are all pretty standard.
Also note: in the above examples I intentionally left the formatting similar to the CSS though I generally use C-style formatting in my own style files.
And because the style file is actually a groovy script, you can do a little coding there too. So here is a snippet of one of my actual style files (for the book UI):
[java]
// Defaults for the style
selector(“book-paper”) {
font = font(“Interface/templar64.fnt”)
color = color(0.1, 0.3, 70f/255, 0.70)
highlightColor = color(0.0, 0.5, 0.6, 0.980)
highlightShadowColor = color(0, 0, 0, 0.5)
shadowColor = color(0, 0, 0, 0);
// For any containers... by default this will be their layout
layout = new SpringGridLayout();
}
// The root container for a page
selector(“page”, “book-paper”) {
insets = new Insets3f(10, 20, 10, 10);
}
selector(“button”, “book-paper”) {
fontSize = 52
insets = new Insets3f(10, 20, 0, 0);
}
selector(“bookmark.button”, “book-paper”) {
background = new QuadBackgroundComponent(texture(“Interface/ribbon.png”))
background.setMargin(48, 7)
background.color = color(0.2, 0.5, 0.6, 1)
color = color(161/255f, 134/255f, 51f/255, 0.7)
highlightColor = color(0.9, 0.9, 0.6, 0.80)
}
[/java]
And a final note: the style stuff is not dependent on any other Lemur classes and can be used independently for any other classes/objects that may want similar “cascading” attribute setting behavior.
Edit: P.S.: at some point I will add a “style” keyword that can be used to wrap a bunch of selectors so that you don’t have to keep repeating the style name every time.
Edit2: got rid of an erroneous comment… gotta clean up this file someday.