Lemur Container Default Fill Mode

Hello,
I’m trying to build a simple Lemur container having a label & 2 buttons (see code below).
Reading here in the forum I thought that the default fill mode should be “even” so that all buttons per row will be in the same size but in my case the left button is stretched to the max and the right gets just enough size for its text.
How can I enforce the layout to give the buttons even size?

modifyEntityWindow = new Container();
        lblModifierWindowHeader = new Label("Selected Model:");

        modifyEntityWindow.addChild(lblModifierWindowHeader,0,0);
        Button b1 = modifyEntityWindow.addChild(new Button("X-"),1,0);
        b1.addClickCommands(new Command<Button>() {
            @Override
            public void execute( Button source ) {
                String code=selectedObject+".move (x-1) in 0.1 second";
                app.runPartialCode(code,null,false);
            }
        });

        Button b2 = modifyEntityWindow.addChild(new Button("X+"),1,1);
        b2.addClickCommands(new Command<Button>() {
            @Override
            public void execute( Button source ) {
                String code=selectedObject+".move (x+1) in 0.1 second";
                app.runPartialCode(code,null,false);
            }
        });

Thank you

I’m not on my pc so it’s a small nightmare typing exact code.

Container has a constructor that takes a layout. Create a spring grid layout. Something like:

new SpringGridLayout(Axis.Y, Axis.X, FillMode.Even, FillMode.Even);

And add it to the constructor of your container.

1 Like

Even is the default. In fact, the default spring grid layout is exactly what jayfella typed.

It’s because your title is on column 0 and so it stretches it out.
image

If you want a title that stretches across the whole container then the buttons should be in a nested container.

Something like:

        modifyEntityWindow = new Container();
        lblModifierWindowHeader = new Label("Selected Model:");

        modifyEntityWindow.addChild(lblModifierWindowHeader);
        
        Container buttons = modifyEntityWindow.addChild(new Container());
        buttons.setBackground(null);

        Button b1 = buttons.addChild(new Button("X-"),1,0);
        b1.addClickCommands(new Command<Button>() {
            @Override
            public void execute( Button source ) {
                String code=selectedObject+".move (x-1) in 0.1 second";
                app.runPartialCode(code,null,false);
            }
        });

        Button b2 = buttons.addChild(new Button("X+"),1,1);
        b2.addClickCommands(new Command<Button>() {
            @Override
            public void execute( Button source ) {
                String code=selectedObject+".move (x+1) in 0.1 second";
                app.runPartialCode(code,null,false);
            }
        });
1 Like

Makes sense. Thanks a lot!