flamendless / Slab

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

Menu bar just doesn't work in a window when it should #134

Closed ashifolfi closed 2 years ago

ashifolfi commented 2 years ago

https://user-images.githubusercontent.com/29577987/170036314-208e0e06-5e29-4b9d-9150-4113e863cdf0.mp4

When I attempt to use a menubar inside a window not only does it look very funky but if I moved the window the menubar goes behind it.

But most importantly if I click ANYTHING in the menubar I get an error about not having EndWindow() even though I do.

This is a very bruh moment.

ashifolfi commented 2 years ago

Also I would like to add the same result occurs even if I don't have an if statement for begin window and just have it on it's own. Except for one thing. The menu bar now appears even when the window is closed.

flamendless commented 2 years ago

Please show minimal code that shows the behavior you raise has the issue

ashifolfi commented 2 years ago

apologies for the wait!

lvledit.win = {}
lvledit.win.main = {Title = "Level Editor", IsOpen = true, AutoSizeWindow = false, AllowResize = true}

function lvledit:drawMain(dt)
    Slab.BeginWindow("lvl_main", lvledit.win.main)
    -- Menu Bar
    if Slab.BeginMenuBar() then
        if Slab.BeginMenu("File") then
            if Slab.MenuItem("New") then
                print("Not Implemented")
            end
            if Slab.MenuItem("Open") then
                print("Not Implemented")
            end
            Slab.Separator()
            if Slab.MenuItem("Exit") then
                print("Not Implemented")
            end
        end
        Slab.EndMenuBar()
    end
    Slab.Text("TEST!")
    Slab.EndWindow()
end

here is a stripped down variant of the window that I found this issue with. Just put lvledit:drawMain(dt) inside a standard slab setup alongside this code and it should trigger the issue.

ashifolfi commented 2 years ago

NOTE: Though this differs slightly from that that you can see in the recording it does indeed still trigger the issue for me.

flamendless commented 2 years ago

Sorry for the late response, you need Slab.EndMenu().

    Slab.BeginWindow("lvl_main", lvledit.win.main)
        if Slab.BeginMenuBar() then
            if Slab.BeginMenu("File") then
                if Slab.MenuItem("New") then
                    print("Not Implemented")
                end
                if Slab.MenuItem("Open") then
                    print("Not Implemented")
                end
                Slab.Separator()
                if Slab.MenuItem("Exit") then
                    print("Not Implemented")
                end
                Slab.EndMenu() --THIS
            end
            Slab.EndMenuBar()
        end
        Slab.Text("TEST!")
    Slab.EndWindow()