Lemur z-order messing up

This must sound quite stupid (and maybe it is xD) but I can’t get the z-index as I want it. I tried translating it (but I think layouts touch the translations so it is overriding whatever z value I give to it) and scaling it (seemed to work fine until I got some hierarchy).

The example isn’t working is:

  1. Container → Container → Label
  2. Container → Container → Label

Both are in the same parent container but whatever layout I can’t achieve to get the z-order I want so the desired overlaps the other when I want. Using the scale works fine for the containers background but not for the labels.

So… is there any standard way to z-order this in lemur?.

Z-order is managed with Z. If you’ve flattened everything to 0 then they will all get the same Z in the layout.

Beyond that, I can’t comment on anything you’ve written without seeing code and understanding what you actually want things to look like.

Why did you put them in a container if you don’t want them laid out by a layout?

Not really sure what that means… but code would probably help.

Well, because I wanted some of the advantages of the layout (x/y layout) but not the z one (ie: things that partially overlaps). Another reason is because attaching things to a panel doesn’t show them and I’m not skilled enough just now to make my own layout (it must be pretty simple but I took a look and gave up fast, tried to use what already is made).

I’ll try to isolate some simple code.

PD: A default “AbsoluteLayout” or “SimpleLayout” or “FreeLayout” to just add things to and manage them on a raw manner with translates and such would be great :smiley: .

If you don’t want layout then just attachChild() to a regular spatial. Is there some other benefit to having them in a container that you miss?

That’s called Node.attachChild(). It will give you an absolute layout… just position the children where you want like any other spatial.

Note: there is a way to control the z-layering within lemur for some specific cases but it isn’t meant for this use-case you have.

I think I’m missing something somewhere. I tried to use the attachChild of a panel as what I want is to attach the non-layout/absolute-layout to a lemur component (ie: panel). If I do so, the thing I attach just disappears. Where have I to attach this?.

Ie: I have a panel inside a more complex UI. On this panel I want an “absolute layout emulation” but I want that area managed by Lemur so I create a panel with the size of the desired “absolute layout emulation panel”, how can I attach my other lemur components to it on a way I can’t have the absolute thing?

However, I think the implemented layouts shouldn’t be overriding the z translation, just the x/y.

A simple example code for this is:

import com.jme3.app.SimpleApplication;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.simsilica.lemur.Container;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.lemur.Insets3f;
import com.simsilica.lemur.Label;
import com.simsilica.lemur.component.QuadBackgroundComponent;
import com.simsilica.lemur.style.Attributes;
import com.simsilica.lemur.style.BaseStyles;
import com.simsilica.lemur.style.Styles;

public class MainZorder extends SimpleApplication {

    public static void main(String[] args) {
        new MainZorder().start();


    public void simpleInitApp() {

        Container zorder = new Zorder();
        zorder.setLocalTranslation(300, 300, 0);

    public static class Zorder extends Container {

        public Zorder() {
            Styles styles = GuiGlobals.getInstance().getStyles();
            Attributes attrs;

            attrs = styles.getSelector("box1");
            attrs.set("background", new QuadBackgroundComponent(new ColorRGBA(1, 1, 0, 1)));

            attrs = styles.getSelector("box2");
            attrs.set("background", new QuadBackgroundComponent(new ColorRGBA(1, 1, 1, 1)));

            for (int i = 0; i < 5; i++) {
                // Containers
                Container pane1;
                if (i % 2 == 0) {
                    pane1 = new Container("box1");
                else {
                    pane1 = new Container("box2");


                pane1.setPreferredSize(new Vector3f(30, 30, 0));
                pane1.setInsets(new Insets3f(-50, -10 * (5 - i), 0, -10 * i));

                // Labels
                pane1.addChild(new Label("AAA"));
                pane1.addChild(new Label("BBB"));

                // Z scale of the container
                pane1.scale(1, 1, 1 + i * 10);

In that example the z-order of the things messes up completely :S.

They have to because they control Z also. You are kind of trying to abuse layouts in this example.

If you want absolute layout of children of a panel for some reason then add an intermediate node.

Node absolute = new Node("myStuff");

or whatever.

When a GUI element is the direct child of another GUI element then it thinks it should be managed by that layout. So you have to add a regular spatial between them.

Also note that you add the panel twice as a child… which may confuse some things also.

My bad doing the example, just too much things in head.

That’s just what I need (I don’t know how I didn’t try it, I was sure I tried all combinations xD).

However, couldn’t you add a simple layout allowing this?. With the current way it seems a little bit “hack”, while if there was a layout allowing this it would seem more neat (and other users, just like me, wouldn’t have the same issue). It could make users to abuse of this absolute layout if present but in my opinion this isn’t something that one should have in mind when adding feature.

Well, above all, thanks for your help!