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: 14
Joined: Sun Feb 24, 2019 6:30 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Mon Jun 03, 2019 10:55 pm

yintercept wrote:
Fri May 31, 2019 11:09 pm
I encountered the following problem..

xdelta, ydelta = slab.GetMouseDelta()
slab.Text(v.name)
if slab.IsControlClicked()
print "ydelta: " .. ydelta -- ydelta is ALWAYS 0
end


Don't know whats going on, if it's on my end, or if it's a bug or maybe it's something to do with scope?
I tried printing it before and after slab.Text, and before and after slab.IsControlClicked, it's only 0 inside the if statement.
I'll take a look at why this is occurring.
Bunnybacon wrote:
Mon Jun 03, 2019 8:43 pm
Hey!

Really excited about this lib!

Any easy way to know whether a click is inside or outside the UI layer?

Thanks!
Yes, this is something I want to add real soon.

I am wrapping up some last bit of features for the v0.4.0 release. Once I am completed with this, I will put out another version with the said fixes. I hope to have this release within the next week.

User avatar
Bunnybacon
Prole
Posts: 18
Joined: Fri Mar 25, 2016 8:42 am

Re: Slab - An Immediate Mode GUI Library In Lua

Post by Bunnybacon » Wed Jun 05, 2019 10:22 am

coding.jackalope wrote:
Mon Jun 03, 2019 10:55 pm
Bunnybacon wrote:
Mon Jun 03, 2019 8:43 pm
Hey!

Really excited about this lib!

Any easy way to know whether a click is inside or outside the UI layer?

Thanks!
Yes, this is something I want to add real soon.
I managed to hack this with

Code: Select all

local Region = require(SLAB_PATH .. '.Internal.UI.Region')
and then checking for

Code: Select all

#Region.GetHotInstanceId() == 0 
on mouse behaviour

pauljessup
Party member
Posts: 141
Joined: Wed Jul 03, 2013 4:06 am

Re: Slab - An Immediate Mode GUI Library In Lua

Post by pauljessup » Wed Jun 05, 2019 12:38 pm

Interesting...

I'm slowly working on an Open Sourced RPGMaker in Lua, and this would be a huge benefit...

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

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Wed Jun 12, 2019 10:14 pm

Slab v0.4.0

Slab.love
(93.31 KiB) Downloaded 36 times

Hello everyone. Version 0.4.0 has just been released. This release expands the input control to support multiple lines and allows the control to mimic the behavior of standard text editors. Support for UTF-8 characters has been added as well. This release also adds Void (Non-Slab) interaction and Keyboard interaction. Refer to the Github release page at https://github.com/coding-jackalope/Slab/releases for more information.

Multiline Input
The input control has the ability to support multiple line editing similar to a standard text editor. Most key controls that are supported in text editors are supported in the input control.
Image

Image

Void Interaction
Slab now provides functions through its API to test if the mouse is hovered or has clicked in a non-Slab area. The functions added are:
  • IsVoidHovered
  • IsVoidClicked
Keyboard Interaction
Keyboard functions similar to the Mouse functions has been added to the API. The functions added are:
  • IsKeyDown
  • IsKeyPressed
  • IsKeyReleased
If anyone has any comments, questions, or suggestions, feel free to reach out and let me know.

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

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Wed Jun 12, 2019 10:22 pm

yintercept wrote:
Fri May 31, 2019 11:09 pm
I encountered the following problem..

xdelta, ydelta = slab.GetMouseDelta()
slab.Text(v.name)
if slab.IsControlClicked()
print "ydelta: " .. ydelta -- ydelta is ALWAYS 0
end


Don't know whats going on, if it's on my end, or if it's a bug or maybe it's something to do with scope?
I tried printing it before and after slab.Text, and before and after slab.IsControlClicked, it's only 0 inside the if statement.
I tested this locally and I am seeing valid ydelta values. Make sure you are calling Slab.Update(dt) before Slab.GetMouseDelta().
Bunnybacon wrote:
Wed Jun 05, 2019 10:22 am
coding.jackalope wrote:
Mon Jun 03, 2019 10:55 pm
Bunnybacon wrote:
Mon Jun 03, 2019 8:43 pm
Hey!

Really excited about this lib!

Any easy way to know whether a click is inside or outside the UI layer?

Thanks!
Yes, this is something I want to add real soon.
I managed to hack this with

Code: Select all

local Region = require(SLAB_PATH .. '.Internal.UI.Region')
and then checking for

Code: Select all

#Region.GetHotInstanceId() == 0 
on mouse behaviour
I have just released a new version and have added functions IsVoidHovered and IsVoidClicked. These functions will let you know when the mouse is interacting with the non-Slab layer.

User avatar
Darlex
Party member
Posts: 117
Joined: Sun Sep 24, 2017 10:02 am
Location: absolutely not Chile
Contact:

Re: Slab - An Immediate Mode GUI Library In Lua

Post by Darlex » Sat Jun 29, 2019 8:15 pm

I love this project! I'm using it on my project to create a working love2d ide!
Could you please add a highlight option for text inputs, please? like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {"here","goes","the","highlighted","words"}}
And some function to get where is the cursor pointing at? like:

Code: Select all

cursorchar, cursorline = Slab.GetInputCursor("code_input") 
That would be very appreciated!
culdud uwu

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

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Sun Jun 30, 2019 7:13 pm

Darlex wrote:
Sat Jun 29, 2019 8:15 pm
I love this project! I'm using it on my project to create a working love2d ide!
Could you please add a highlight option for text inputs, please? like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {"here","goes","the","highlighted","words"}}
And some function to get where is the cursor pointing at? like:

Code: Select all

cursorchar, cursorline = Slab.GetInputCursor("code_input") 
That would be very appreciated!
Thanks Darlex. Glad this project is helping out with yours. I am currently wrapping up another release so I can add these functions and options to the next release. I'll add Slab.GetInputCursor and Slab.SetInputCursor functions to allow for managing the text cursor.

I've had plans to add text highlighting to the Input control. I like the idea of specifying the words to highlight like in your example so I'll have something like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {{"function", {0, 0, 1, 1}}, {"end", {0, 0, 1, 1}}, {"local", {0, 0, 1, 1}}, ...}}
where Highlight is a table that takes in a list of words and what color the word should be highlighted in. Slab will then build out what needs to be rendered and in the color specified so the Input control can mimic syntax highlighting like in standard text editors. Hopefully this is what you are looking for and helps out in your project. If not, feel free to let me know.

User avatar
Darlex
Party member
Posts: 117
Joined: Sun Sep 24, 2017 10:02 am
Location: absolutely not Chile
Contact:

Re: Slab - An Immediate Mode GUI Library In Lua

Post by Darlex » Sun Jun 30, 2019 8:24 pm

coding.jackalope wrote:
Sun Jun 30, 2019 7:13 pm
Darlex wrote:
Sat Jun 29, 2019 8:15 pm
I love this project! I'm using it on my project to create a working love2d ide!
Could you please add a highlight option for text inputs, please? like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {"here","goes","the","highlighted","words"}}
And some function to get where is the cursor pointing at? like:

Code: Select all

cursorchar, cursorline = Slab.GetInputCursor("code_input") 
That would be very appreciated!
Thanks Darlex. Glad this project is helping out with yours. I am currently wrapping up another release so I can add these functions and options to the next release. I'll add Slab.GetInputCursor and Slab.SetInputCursor functions to allow for managing the text cursor.

I've had plans to add text highlighting to the Input control. I like the idea of specifying the words to highlight like in your example so I'll have something like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {{"function", {0, 0, 1, 1}}, {"end", {0, 0, 1, 1}}, {"local", {0, 0, 1, 1}}, ...}}
where Highlight is a table that takes in a list of words and what color the word should be highlighted in. Slab will then build out what needs to be rendered and in the color specified so the Input control can mimic syntax highlighting like in standard text editors. Hopefully this is what you are looking for and helps out in your project. If not, feel free to let me know.
THANKS! That's way better than my idea! Your GUI project is one of the only ones that doesnt make my brain explode! Send ya good vibes!
culdud uwu

User avatar
pgimeno
Party member
Posts: 1687
Joined: Sun Oct 18, 2015 2:58 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by pgimeno » Sun Jun 30, 2019 8:47 pm

coding.jackalope wrote:
Sun Jun 30, 2019 7:13 pm
I've had plans to add text highlighting to the Input control. I like the idea of specifying the words to highlight like in your example so I'll have something like:

Code: Select all

Slab.Input("code_input", {
	Text = examplecode,
	MultiLine = true,
	H=500, W=500,
	Highlight = {{"function", {0, 0, 1, 1}}, {"end", {0, 0, 1, 1}}, {"local", {0, 0, 1, 1}}, ...}}
where Highlight is a table that takes in a list of words and what color the word should be highlighted in.
Wouldn't it be better to have the words in a table where the keys are the words to highlight? That would avoid more objects, and the lookup would presumably be faster. Iterating would be slower, though, if it's necessary at all.

To put it explicitly, this is what I mean:

Code: Select all

Highlight = {["function"] = {0, 0, 1, 1}, ["end"] = {0, 0, 1, 1}, ["local"] = {0, 0, 1, 1}, ...}

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

Re: Slab - An Immediate Mode GUI Library In Lua

Post by coding.jackalope » Wed Jul 10, 2019 10:24 pm

Slab v0.5.0

Slab.love
(149.88 KiB) Downloaded 5 times

Hello everyone. Version 0.5.0 has just been released. This release adds API functions to render basic shapes to a window, such as rectangles and circles. The Input control also has support for highlighting words with custom colors to mimic syntax highlighting found in various text editors. The Slab Test module has now been refactored to show off the various features of Slab and can act as a good reference point for the API. Refer to the Github release page at https://github.com/coding-jackalope/Slab/releases for more information.

Shapes
Slab offers functions to draw basic shapes to a window. These shapes can complement the controls and provides some flexibility in the look the UI. The shapes that are supported through the API are: Image

Input
The Input control now offers the ability to highlight words with a specific color. This is a table passed into the Highlight option of the Input function.

Image

Image

Functions for getting and setting the input cursor position has also been added along with querying and setting the focus of the input control. Slab Test
The Slab Test module has now been re-worked to act as a reference point for overviews of controls and how they are implemented. Each control is given their own section which can be selected with the combo box at the top of the window and example usage of the controls are displayed.

Image

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: Pyuu and 6 guests