Slab - An Immediate Mode GUI Library In Lua

Showcase your libraries, tools and other projects that help your fellow love users.
coding.jackalope
Prole
Posts: 29
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope »

Thanks for sharing a screenshot of your project using Slab. Its always great seeing Slab used by other developers.
pericles
Prole
Posts: 10
Joined: Tue Dec 25, 2018 6:31 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by pericles »

I did try it out and worked really well. Nice tutorial file, good wiki documentation and easy to follow :3

Thanks Jackalope, awesome work ^~^
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Hello,

Is it possible to make the gui semi-transparent ?

I retrieved Slab from github, but it is unclear for me how to install it. In my project directory, I have ./lib/ext directory where I put all
external libraires. What should I put in there from Slab ? There is "Slab.lua", but also "init.lua" ? Do I have to put "main.lua" which seems to be an example file ?

regards
User avatar
togFox
Party member
Posts: 764
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Slab - An Immediate Mode GUI Library In Lua

Post by togFox »

Put the whole slab folder in a subdirectory under main.lua.

In main.lua you use

Slab = require 'Slab.Slab

Slab.Slab refers to the slab.lua file in the slab subfolder.

Maybe you can set the alpha value when setting slab colours to get transparency.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by grump »

deb75 wrote: Thu Jun 03, 2021 9:33 pm There is "Slab.lua", but also "init.lua" ?
When you have a lib in a folder, and it has a file named init.lua, you require the folder. In your case

Code: Select all

local Slab = require('lib.ext.Slab')
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Thanks for your answeers.

By the way, what is the best practice with external libraries.

I used to putting them within the root project directory. However, I noticed that love2d also searches in /path/to/lovedir/ (for dlls) and /path/to/lovedir/lua/ for lua files.

On the one hand, it seems better to put external libraries in a project independent location but on the other hand, if I want to distribute the game as a *.love file, I will have to embed them.
coding.jackalope
Prole
Posts: 29
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope »

deb75 wrote: Thu Jun 03, 2021 9:33 pm Hello,

Is it possible to make the gui semi-transparent ?

regards
Hi deb75, you can make the gui semi-transparent in a few ways. One way is to modify the 'BgColor' option when calling the 'BeginWindow' function. Another option is to modify the 'WindowBackgroundColor' style setting in 'Styles.lua'. You can find more information about this here.
deb75 wrote: Fri Jun 04, 2021 9:22 am Thanks for your answeers.

By the way, what is the best practice with external libraries.

I used to putting them within the root project directory. However, I noticed that love2d also searches in /path/to/lovedir/ (for dlls) and /path/to/lovedir/lua/ for lua files.

On the one hand, it seems better to put external libraries in a project independent location but on the other hand, if I want to distribute the game as a *.love file, I will have to embed them.
I think this is more personal preference. I like to place dependencies as sub-folders under the root project under some 'ext' folder. This makes it easy for distribution, and you can quickly move this over to another platform and test without having to re-download dependencies again.
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Thanks for your answeer.

I got transparency working with :

Code: Select all

local Slab = require("lib.ext.Slab")

function love.load(args)
    love.graphics.setBackgroundColor(0.4, 0.88, 1.0)
    Slab.Initialize(args)
end

function love.update(dt)
    Slab.Update(dt)

    Slab.BeginWindow("MyFirstWindow", {
        BgColor = { 0.5, 0.5, 0.5, 0.5 },
        Rounding = 5,
    })
    Slab.Text("Hello World")
   
    Slab.EndWindow()
end

function love.draw()
    Slab.Draw()
end

However, when I move the window, some shadow windows appear at some place, if I put the window into one of the shadow one,
the window gets stuck to one of the border. Can I suppress this behavior ?

Also, is it possible to round not all corner of the box ? say only two diagonally opposed of them ?

Regards
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Slab - An Immediate Mode GUI Library In Lua

Post by yetneverdone »

Hi @coding.jackalope, just wondering why there's no activity for a very long time at Slab's repo at Github?
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Hello,

I experience some difficulties with Slab.

I develop a game which has a background composed of tiled images which can change when moving the mouse, just like when you use openstreet map. Tiled images are drawn on a canvas during the

Code: Select all

love.update
and the canvas itself is drawn during

Code: Select all

love.draw
It runs smoothly, that is to say I can drag the background with the mouse like on google map.

However, as soon as I add :

Code: Select all

Slab.Initialize(args)
I can no more drag the background smoothly. More precisely, the background is no more drawn when moving the mouse.
However, when I release the mouse button, it does draw again the background as expected.

Do you have any idea for why Slab has this effect on the drawing ? So sad that it prevents me from using Slab.

Regards
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests