[SOLVED]One more layout question

Hi! As i cant find enought doc about how to to what i need i have to ask one more annoing qustion about Lemur.
I have tried some stuff with Lemur and like it, but i have hard time when i start need to just make simple panel on bottom of the screen with just 2 buttons “Apply” and “Back”. This is how i do:

    container = new Container(new BorderLayout());
    container.setPreferredSize(new Vector3f(settings.getResolution().getWidth(), settings.getResolution().getHeight(), 0));

    Container buttons = container.addChild(new Container(new BorderLayout()), BorderLayout.Position.South);
    Container b = buttons.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, FillMode.None)), BorderLayout.Position.East);

    Button applyButton = b.addChild(new Button("Apply"), 0, 0);
    applyButton.addClickCommands(button -> apply());

    Button backButton = b.addChild(new Button("Back"), 0, 1);
    backButton.addClickCommands(button -> back());


if i using
Container b = buttons.addChild(new Container(new SpringGridLayout(Axis.Y, Axis.X, FillMode.None, illMode.None)), BorderLayout.Position.Center); both buttons stick to left side of buttons panel and i understand why. Cause Left node is empty. But in this case what can i do for just solve my simple ploblem?
Maybe picture will enlight more then words;

And of cource if possible can i have some expanations about sizing and layout system, without documentation it is not purely intuitive for me.
This topic was like awesome

but it is still not enought to make what i need make.

After that:
b.setInsetsComponents(new DynamicInsetsComponent(0, 0.5f, 0, 0.5f));

…which means none of the ‘available space’ on top and bottom but half of the ‘available space’ on the left and right… ie: center it.

I don’t have time to finish those docs right now but feel free to continue asking specific questions until it clicks.

By the way, for side-by-side containers like this then you can simplify things a lot by using a column major layout instead of the row-major one that you are using:

    Container b = buttons.addChild(new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.None, FillMode.None)), BorderLayout.Position.East);

    Button applyButton = b.addChild(new Button("Apply"));
    applyButton.addClickCommands(button -> apply());

    Button backButton = b.addChild(new Button("Back"));
    backButton.addClickCommands(button -> back());

Note: the lack of specific row/column specification. By default, in a column major SpringGridLayout, each new element will get its own column.

Also, not sure what that’s about if you just want buttons on the bottom. You can probably just use the buttons container directly (though you will want to give it the Axis.X, Axis.Y flip like just showed you.

Thank you so much! Will try it asap.
Yes i can understand why u can’t finish docs, we r all pretty busy monkeys:slight_smile:, but i really need to understand better layouting(sizing and scaling concepts) in ur library sisnce i decide to use it in my projects. Hope you gonna find some time to complete docs a little.

It could be a case where you are thinking that it’s more complicated than it is.

It’s pretty simple. GUI Elements are sized according to the layout. The layouts are pretty rigid in how they size and position things. For example, SpringGridLayout will force a grid. The width of the columns and the height of the rows is dependent on what it’s in them and what the flow is… but once that’s decided all GUI elements are forced to the size of their respective cell.

After that, it’s up to the GUI element’s component stack to determine how things look within that size. And that part of Lemur is pretty well documented at least:

…that may help you understand how the DynamicInsetsComponent works. It’s a GUI component that doesn’t draw anything… just helps size and position the next things in the stack.

Edit: and note: I’m not trying to get out of writing docs… just trying to get you past your current hurdles to a point where you can ask more specific questions as needed. Partly these exchanges will help me write docs later anyway.

1 Like

Yes i just want to put 2 buttons in the center bottom. What u mean directly? Without “b” container?
My logic was like this:

  1. Put root container on screen by absolute positions with BorderLayout. Top is for title, center is for content and bottom is for buttons panel.
  2. Put buttons containter on bottom with BorderLayout to have automatic centering feature(like it was in Swing and like it is in JavaFX now).
  3. Put new container with SpringGridLayout just for place buttons in a one row, cause i thought BorderLayout is not fit to put 2 buttons in a row

Thank u, i should spend some time to learn GUI element’s component stack before continue using Lmeur. Can i ask u again if more specific questions apperas?

Of course.

Also remember that there is the SimEthereal examples that use Lemur. For example, you can see how I’ve created a container with buttons at the bottom here:

It doesn’t use a BorderLayout but it could have just as easily done.

For a waaay more complicated Lemur UI example there is also the SimArboreal-Editor application.

Looks helpful!
After ur advices and reading some docs about Insets everything goes as i expected, thank u so much! :slight_smile: