flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
294 stars 25 forks source link

When putting 2nd layout after 1st layout the 2nd layout starts at wrong 'y' #83

Open togfoxy opened 3 years ago

togfoxy commented 3 years ago

Will do my best to describe:

I create a layout with 6 columns. I fill the first column then the 2nd column etc using Slab.SetLayoutColumn(intColNumber)

and that works. It is important to note that the columns are different length - that is - each has a different number of rows. Most of the 6 columns are NOT completely filled.

I then close that layout with

Slab.EndLayout()

and then begin a 2nd layout immediately after the first and put a button in the 2nd layout:

Slab.BeginLayout('2ndlayout', {})
        if Slab.Button("Main menu") then
            MoveToNewState("MainMenu")
        end
Slab.EndLayout()

Slab.EndWindow()

Now, because I closed the first layout and started the 2nd layout, I was expecting that MAIN MENU button to be underneath the first layout - because - sequence. What is really happening is the button is being placed immediately after the last item in column 6, meaning, closing off the first layout does NOT move the cursor to the end of that layout.

My button ended up being displayed in the middle of the first layout because that's where the cursor was during the creation of that layout.

Should I expect the cursor to be placed at the end of a layout when it is closed? That has been my experience before but this is the first time I've used columns. What is my work around here? Get size of first layout and set cursor accordingly? Thanks.

Edit: as suspected, I have to do this:

Slab.SetCursorPos(nil, 650) -- set cursor y value to 650 so it appears under the first layer

to get the 2nd layout to appear under the first and not drawn somewhere in the middle. Just checking if this is expected behavior?

flamendless commented 3 years ago

Hi @togfoxy this is not the expected behavior as far as i know. The 2nd layout should start after the 1st layout since the 1st layout has been closed/ended. Can you send a minimal main.lua code of demonstrating this issue so I can take a look at it and hopefully fix it? Thanks