Questions about Lemur

Lemur library experts, I need your help!
How do I correctly place the 3 components highlighted in the red box (Label, TextField and Button) on a single line ? I would like to achieve the effect of AWT’s FlowLayout. I would like to complete the development of this tool, but this problem is taking me too much time.
Here is my code, could you kindly give me the solution please?

Thanks

image

    private Container createVector3Property(String name, Vector3Property vecProperty) {
        Container container = new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.Even, FillMode.Last));
        container.addChild(new Label(name + ":"));
        
        String initialValue = vecProperty.getAsText();
        TextField text = container.addChild(new TextField(initialValue));

        Button button = container.addChild(new Button("Set"));
        button.addClickCommands(cmd -> {
            String newValue = text.getText();
            vecProperty.setAsText(newValue);
        });

        return container;
    }

@pspeed @codex

2 Likes

Set the container’s layout to X axis major, Y axis minor.

container.setLayout(new SpringGridLayout(Axis.X, Axis.Y));
2 Likes

Yep, X-Major (x, y) each add without context adds a column. Y-Major (y, x… the default) each add without context adds a row. That answers your question and is essentially the same thing codex is saying.

But note that you can also specify explicit rows and columns by adding parameters to addChild()… there is even some contextual support to make building panels easier when only specifying one extra value.

For example, in a row-major layout (y, x):

container.addChild(label1) // first row, first column
container.addChild(value1, 1); // same row, second column
container.addChild(label2) // second row, first column
container.addChild(value2, 1); // same row, second column

…makes it easy to build quick property panels and such.

A SpringGridLayout.addChild() with no extra arguments always make a a new row. With one argument, it assumes same row but using the specified column.

With two arguments, you are explicitly setting row and column:

container.addChild(myChild, 0, 1); // first row, second column

And for a column-major layout (X, Y) swap all mentions of ‘row’ and ‘column’ above.

3 Likes

Thanks a lot guys :wink:

1 Like

Hello Lemur experts,
could you tell me how to add a vertical ScrollBar to the panel highlighted in red please?
The root panel contains N RollupPanels. When the RollupPanels are expanded they become unusable if their size exceeds the height of the main window.
How can I solve this problem?

Thanks.

Here is my code:

        Container container = new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, FillMode.Even));

        for (Filter filter : fpp.getFilterList()) {
            String title = filter.getName();
            Panel panel = ...;

            RollupPanel rollup = new RollupPanel(title, panel, "glass");
            rollup.setAlpha(0, false);
            rollup.setOpen(true);
            container.addChild(rollup);
        }

        container.setLocalTranslation(10f, 10f, 1);
        getGuiNode().attachChild(container);

1 Like

You have to do this with JME Viewports and some magic. (There is a demo of viewports in the Lemur demos app.)

JME provides no way to do clipping so Lemur cannot implement a proper scroll panel without a lot of caveats. The only way it will work like everyone expects in all cases is to do off-screen rendering… which is what I will eventually implement but that will come with its own set of down sides. It is also non-trivial to implement.

You can simulate the behavior in your particular use-case with a JME viewport that is positioned over where you want the scrollable part of the container to be… then put your scrolling stuff inside that viewport.

Edit: note that in a lot of cases where I’ve really wanted a scroll pane for a set of rollup panels like you have, I end up just putting multiple pages in a tabbed panel. Invariably I end up happier with that solution in the end.

4 Likes