Slab - An Immediate Mode GUI Library In Lua

Showcase your libraries, tools and other projects that help your fellow love users.
grump
Party member
Posts: 646
Joined: Sat Jul 22, 2017 7:43 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by grump » Sun Nov 03, 2019 9:44 am

Hi guys, I quickly pasted this code together from code I had lying around. Maybe it's useful for what you're trying to do here. It's partly based on lovefs, but without all the weirdness. It provides these functions:

Code: Select all

fileList
driveList
currentDirectory
changeDirectory
readFile
writeFile
writeTextFile
splitPath
makePath
for Windows and POSIX systems. I have used this in a bunch of tool projects.

Example:

Code: Select all

local fs = require('fs')

local f = fs.fileList()
for _,v in ipairs(f) do
	print(v.type, v.name)
end
I didn't know there's still a need for such a lib... if people are interested, i can make a "real" library out of it, with documentation and stuff, and better function naming.

Edit: oh I just realized that splitPath and makePath depends on code not included here. Sorry about that. You can just remove them, rewrite them or not use them.

coding.jackalope
Prole
Posts: 25
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Sun Nov 03, 2019 6:09 pm

Thanks for the feedback guys.
pgimeno wrote:
Fri Nov 01, 2019 11:06 pm
I've found a quoting problem which could become a security problem. The quoting of command-line parameters in commands executed via os.popen is insufficient in Linux and OSX. I've created a patch: https://notabug.org/pgimeno/Slab/pulls/1 together with other Linux&OSX fixes.

However, this method for file list retrieval should be a last resort when every other alternative is exhausted. As I see it, there are at least three alternatives, in order of preference:
grump wrote:
Sun Nov 03, 2019 9:44 am
Hi guys, I quickly pasted this code together from code I had lying around. Maybe it's useful for what you're trying to do here. It's partly based on lovefs, but without all the weirdness. It provides these functions:
Thanks for the filesystem suggestions! I have been looking for an alternative to luafilesystem as I didn't want to have that binary dependency to use Slab. lovefs is exactly what I am looking for!

Yeahyay
Prole
Posts: 7
Joined: Sat Feb 23, 2019 1:58 am
Contact:

Re: Slab - An Immediate Mode GUI Library In Lua

Post by Yeahyay » Sun Mar 01, 2020 9:08 pm

After trying to make a custom gui system that did what I attempted to do, it got too difficult for me to care. I stumbled upon the concept of IMGUIs and found love-imgui and nuklear. I had compilation issues with both so finding slab was a godsend. It's looking really good and something I'd enjoy using. Keep up the good work.

User avatar
YoungNeer
Party member
Posts: 118
Joined: Wed May 15, 2019 7:49 am

Re: Slab - An Immediate Mode GUI Library In Lua

Post by YoungNeer » Fri Mar 20, 2020 7:36 am

Yeahyay wrote:
Sun Mar 01, 2020 9:08 pm
After trying to make a custom gui system that did what I attempted to do, it got too difficult for me to care. I stumbled upon the concept of IMGUIs and found love-imgui and nuklear. I had compilation issues with both so finding slab was a godsend. It's looking really good and something I'd enjoy using. Keep up the good work.
Custom GUIs (especially retained ones) are really hard. The more GUI kits we have here, the better
My Github- your contribution is highly appreciated

coding.jackalope
Prole
Posts: 25
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Sun Mar 29, 2020 11:53 pm

Slab v0.6.2

Slab.love
(231.42 KiB) Downloaded 272 times

Hello everyone. Version 0.6.2 has been released. This is a small release and contains changes to how Slab retrieves directory items along with some minor fixes. The change uses FFI now instead of making system calls which could be a security issue. Thanks to pgimeno and zorg for finding this issue and providing suggestions.
Yeahyay wrote:
Sun Mar 01, 2020 9:08 pm
After trying to make a custom gui system that did what I attempted to do, it got too difficult for me to care. I stumbled upon the concept of IMGUIs and found love-imgui and nuklear. I had compilation issues with both so finding slab was a godsend. It's looking really good and something I'd enjoy using. Keep up the good work.
Thanks Yeahyay. I'm glad you find this library useful in your projects. If you have any questions or suggestions, feel free to let me know.

User avatar
eduardomeloc
Prole
Posts: 1
Joined: Wed Apr 08, 2020 12:30 am

Re: Slab - An Immediate Mode GUI Library In Lua

Post by eduardomeloc » Wed Apr 08, 2020 5:39 am

I messed around trying to make some GUI for my project too and it quickly became a mess. Slab is much more than what I wanted to achieve and I am so glad it exists. Besides showing my gratitude, I came here to point out two bugs I've came across when working on my project.

IsVoidHovered doesn't work correctly when a window is closed. Apparently it still detects the closed window as a HotInstance until it is over another window/region.

FileDialog wasn't working for me on Linux. No files and no folders were shown in the dialog. I didn't know if I was doing something wrong, but then I decided to go to the lib code and after some time of trial and error I managed to fix it. I had no idea of what I was doing, though, I've never seen LuaJIT code :')
Anyway, I just deleted d_namlen from the dirent struct in FileSystem.lua and, in my main.lua, I had to change my require "lib.Slab" to require "lib/Slab".
It took some time to figure that out, it would be funny if I was just skipping some instructions that were actually in the documentation.

I really enjoy using Slab and I am looking forward for the next updates~

@Edit:
I just noticed another bug. The application crashes when selecting an already existing file in savefile's Dialog.

coding.jackalope
Prole
Posts: 25
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Tue Apr 14, 2020 1:26 am

Slab v0.6.3

Slab.love
(232.79 KiB) Downloaded 242 times

Hello everyone. Version 0.6.3 has been released. This release addresses some issues found within the last release as well as some long standing ones. Please visit the releases page linked above for a list of important changes made.
eduardomeloc wrote:
Wed Apr 08, 2020 5:39 am
I messed around trying to make some GUI for my project too and it quickly became a mess. Slab is much more than what I wanted to achieve and I am so glad it exists. Besides showing my gratitude, I came here to point out two bugs I've came across when working on my project.

IsVoidHovered doesn't work correctly when a window is closed. Apparently it still detects the closed window as a HotInstance until it is over another window/region.

FileDialog wasn't working for me on Linux. No files and no folders were shown in the dialog. I didn't know if I was doing something wrong, but then I decided to go to the lib code and after some time of trial and error I managed to fix it. I had no idea of what I was doing, though, I've never seen LuaJIT code :')
Anyway, I just deleted d_namlen from the dirent struct in FileSystem.lua and, in my main.lua, I had to change my require "lib.Slab" to require "lib/Slab".
It took some time to figure that out, it would be funny if I was just skipping some instructions that were actually in the documentation.

I really enjoy using Slab and I am looking forward for the next updates~

@Edit:
I just noticed another bug. The application crashes when selecting an already existing file in savefile's Dialog.
Glad to hear this tool is helping you with your project. This release also contains fixes for issues you mentioned here.

coding.jackalope
Prole
Posts: 25
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Mon May 25, 2020 12:45 am

Slab v0.6.4

Slab.love
(234.75 KiB) Downloaded 267 times

Hello everyone, Version 0.6.4 has been released. This release addresses some issues found within the last release as well as some feature requests. Please visit the releases page linked above for a list of important changes made.

Teo434
Prole
Posts: 1
Joined: Mon Apr 27, 2020 12:21 am

Re: Slab - An Immediate Mode GUI Library In Lua

Post by Teo434 » Thu Jun 11, 2020 10:46 pm

Edit:
I've fixed the problem, I didnt know you had to call it's update function at the top of love.update() :ultraglee:

Hey! this seems cool, I've been looking for libraries like this for a while now. I've been trying to use the ColorPicker function however I'm running into some issues.

Code: Select all

Error

Slab/Internal/Core/DrawCommands.lua:386: attempt to index a nil value


Traceback

Slab/Internal/Core/DrawCommands.lua:386: in function 'Begin'
Slab/Internal/UI/Window.lua:540: in function 'BeginWindow'
main.lua:32: in function 'update'
[C]: in function 'xpcall'
The code:

Code: Select all

slab.BeginWindow("Color", {title = "Color Picker"})
  slab.Text("Pick a color to use with your brush.")
  slab.ColorPicker({Color = {1.0, 1.0, 1.0, 1.0}})
  slab.EndWindow()

  slab.BeginWindow("BackgroundColor", {title = "Background Color Picker"})
  slab.Text("Pick a color to use for your Background.")
  slab.ColorPicker({Color = {1.0, 1.0, 1.0, 1.0}})
  slab.EndWindow()
  
  -- This is inside love.update(), and at the top of the script slab is defined, and initialized.
  -- Version is 0.6.4
If there's anything I'm missing please tell me, This is my first time using these fourms! ^^

coding.jackalope
Prole
Posts: 25
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Thu Jul 23, 2020 10:37 pm

Slab v0.7.0

Slab.love
(239.25 KiB) Downloaded 121 times

Hello everyone. Version 0.7.0 has been released. This release adds new features such as the docking system and numeric sliders. Issues are also addressed and includes fixes from the community. For more information on the update, refer to the wiki page: https://github.com/coding-jackalope/Slab/wiki.

Docks

Slab now offers the ability for windows to be docked to a specific side of the viewport. Docked windows can be resized based on their dock position and can be undocked when the window is dragged from their position.

Image

Sliders

Numeric input controls now support drag and slider behavior. By default, numeric input controls allows the user to click and drag the control to alter the value. The slider input control will display the position of the value based on the min and max values specified.

Image

Image

Shaders

Slab now offers support for applying shader effects to controls through a stack managed internally. Slab doesn't manage any shaders internally and should be handled by the user.

Image

Tree Table Ids

Trees have been modified so that tables can be used as Ids and not just strings. These tables will be kept as weak references internally and when garbage collected, will free up the cached entry. This will help to keep the number of cached entries to a minimum internally for systems that potentially use a large number of entries such as entities in a game engine. For now, this system is only used for trees but if no issues come up with these changes, could be extended to other Slab controls in future updates.

As always, if anyone has any comments, questions, or suggestions, feel free to reach out and let me know.

Post Reply

Who is online

Users browsing this forum: No registered users and 28 guests