How can I make my theme for lemur GUI?

what is the meaning of this numbers?

http://jmonkeyengine-contributions.github.io/Lemur/javadoc/Lemur/com/simsilica/lemur/component/TbtQuadBackgroundComponent.html

1 Like

is it possible to use an ID for a container and change its font and bg? something like class in CSS?

how can I reach to it from the groovy file? and how to define it in java code?

The element ID is like a CSS class… or as close to it as you will come.

Edit: I wonder if you’ve seen this documentation yet: Styling · jMonkeyEngine-Contributions/Lemur Wiki · GitHub

1 Like

I need to set element ID to a container.

Give it an individual ID.

what is it? how can I do that?

Here is a small example

@Override
public void simpleInitApp() {
    GuiGlobals.initialize(this);
    GuiGlobals.getInstance().getStyles().setDefault(new NewStyle("new Style"));        
    
    Container container = new Container(new SpringGridLayout(),new ElementId("newid"),"new Style");
    container.setLocalTranslation(0,450,0);
    this.getGuiNode().attachChild(container);        
    
    Container childcontainer1 = new Container(new ElementId("newid").child("child1"),"new Style");
    Container childcontainer2 = new Container(new ElementId("newid").child("child2"),"new Style");
    container.addChild(childcontainer1);
    container.addChild(childcontainer2);
}

and the style

import com.jme3.math.Vector3f;
import com.jme3.texture.Texture;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.Attributes;
import com.simsilica.lemur.style.Styles;

/**
 *
 * @author Pankey
 */
public class NewStyle {
    public NewStyle(String style){
        Styles styles =GuiGlobals.getInstance().getStyles();
        Attributes attrs;

        Texture monkey = GuiGlobals.getInstance().loadTexture("Textures/Monkey.png",false,false);

        attrs = styles.getSelector("newid", style);
        attrs.set("background", new QuadBackgroundComponent (monkey));
        attrs.set("preferredSize", new Vector3f(400,400,1));

        attrs = styles.getSelector("newid.child1", style);
        attrs.set("background", new QuadBackgroundComponent (monkey));
        attrs.set("preferredSize", new Vector3f(100,100,1));

        attrs = styles.getSelector("newid.child2", style);
        attrs.set("background", new QuadBackgroundComponent (monkey));
        attrs.set("preferredSize", new Vector3f(100,100,1));
    }
}

Another thing important to know is that when you see attrs.set(“background”, new QuadBackgroundComponent (monkey)); , that background is a value on a atribute called StyleAttribute and is on the panel class

@StyleAttribute(value = "background", lookupDefault = false)
public void setBackground(GuiComponent bg) {
}

when your using any panel, just check the class methods and extended class methods and see the StyleAttribute value and the parameter of the method and thats what you can use on your style

4 Likes