Slab - An Immediate Mode GUI Library In Lua

Showcase your libraries, tools and other projects that help your fellow love users.
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

I found the culprit :-)


The issue is in Slab/Internal/Input/Mouse.lua

Replace

Code: Select all

local function OnMouseMoved(X, Y, DX, DY, IsTouch)
    State.X = X
    State.Y = Y
    State.AsyncDeltaX = State.AsyncDeltaX + DX
    State.AsyncDeltaY = State.AsyncDeltaY + DY
end
with

Code: Select all

local function OnMouseMoved(X, Y, DX, DY, IsTouch)
    State.X = X
    State.Y = Y
    State.AsyncDeltaX = State.AsyncDeltaX + DX
    State.AsyncDeltaY = State.AsyncDeltaY + DY

    if MouseMovedFn ~= nil then
        MouseMovedFn(X, Y, DX, DY, IsTouch)
    end
end


It seems that Slab hijacks the love handler functions, but the default love handler for mouse moving was not called
unlike other ones. I cannot guess if this was intentional or not, at least it solves my issue with possibly the drawback that if
I move one Slab gui, it may also move the background :

is there any simple way to check if any of the slab window is hovered or not ?
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 »

deb75 wrote: Fri Jul 23, 2021 8:47 am I found the culprit :-)


The issue is in Slab/Internal/Input/Mouse.lua

Replace

Code: Select all

local function OnMouseMoved(X, Y, DX, DY, IsTouch)
    State.X = X
    State.Y = Y
    State.AsyncDeltaX = State.AsyncDeltaX + DX
    State.AsyncDeltaY = State.AsyncDeltaY + DY
end
with

Code: Select all

local function OnMouseMoved(X, Y, DX, DY, IsTouch)
    State.X = X
    State.Y = Y
    State.AsyncDeltaX = State.AsyncDeltaX + DX
    State.AsyncDeltaY = State.AsyncDeltaY + DY

    if MouseMovedFn ~= nil then
        MouseMovedFn(X, Y, DX, DY, IsTouch)
    end
end


It seems that Slab hijacks the love handler functions, but the default love handler for mouse moving was not called
unlike other ones. I cannot guess if this was intentional or not, at least it solves my issue with possibly the drawback that if
I move one Slab gui, it may also move the background :

is there any simple way to check if any of the slab window is hovered or not ?
Last released version of Slab has that bug, but it's fixed by the developer (merged from a PR). however, the dev has been inactive for quite a long time now so that patch hasnt been released yet to the master branch. You can modify your clone/submodule and add those or you can use forks (my fork has that patch).
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 found also some other bugs. One is about file path on windows that use "\" instead of "/". Another, possibily related,
is about font loading. I will let you know.

Isn't it a bug ?

Code: Select all

    Style.Font = love.graphics.newFont(Style.FontSize)
Style.FontSize is a number, but love.graphics.newFont expects a filename.

I would like also to add some enhancements, e.g. be able to choose the font name and zize from Slab.Text directly.

Nice library, some small things to make it more portable and more friendly

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 »

There are a range of issues document on that github that haven't been addressed so see if your problem is a known issue.
Current project:
https://togfox.itch.io/backyard-gridiron-manager
American football manager/sim game - build and manage a roster and win season after season
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by pgimeno »

deb75 wrote: Sat Jul 24, 2021 2:29 pm Thanks for your answeer.

I found also some other bugs. One is about file path on windows that use "\" instead of "/". Another, possibily related,
is about font loading. I will let you know.
What about \ vs /? Windows accepts / for paths just fine (except in commands passed to the shell).

deb75 wrote: Sat Jul 24, 2021 2:29 pm Isn't it a bug ?

Code: Select all

    Style.Font = love.graphics.newFont(Style.FontSize)
Style.FontSize is a number, but love.graphics.newFont expects a filename.
It accepts font size too. https://love2d.org/wiki/love.graphics.n ... Function_4
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 currently try to customize the style and I would like to know if it is possible to adjust the border width.

There is a Border paramters for windows but, this controls only the amount of space between window content and
the border which is drawn on screen. How can I make this border (the true window border) thinner of thicker ?

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 »

deb75 wrote: Mon Jul 26, 2021 10:04 am Thanks for your answeer.

I currently try to customize the style and I would like to know if it is possible to adjust the border width.

There is a Border paramters for windows but, this controls only the amount of space between window content and
the border which is drawn on screen. How can I make this border (the true window border) thinner of thicker ?

Regards
Hi, for customizations like that you need to provide your own .ini file, please refer to https://github.com/coding-jackalope/Slab/wiki/Style
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Hi,

I did go to the Slab Style wiki page and did not found any settings for the "true" window border width.
Also, by "*.ini" file, do you refer to the style file, like Dark.style, or to the more general "Slab.ini".

Actually, I did not find in both files any settings for the border width, I will look directly into the code.

Regards

EDIT :

I think there is no way currently to do that, but in fact one can still do :

Code: Select all

    local a = love.graphics.getLineWidth()
    love.graphics.setLineWidth(4)
    Slab.Draw()
    love.graphics.setLineWidth(a)
Unfortunately, this settings will be applied to all Slab window.

But there are little to do I think to incorporate this as a per window settings.
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 »

You can set the line width per window like:

Code: Select all

function love.update(dt)
  love.graphics.setLineWidth(4)
  Slab.BeginWindow(...)
  -- draw stuff
  Slab.EndWindow()
  love.graphics.setLineWidth(1)
  
  love.graphics.setLineWidth(2)
  Slab.BeginWindow(...)
  -- draw stuff
  Slab.EndWindow()
  love.graphics.setLineWidth(1)
  
  love.graphics.setLineWidth(6)
  Slab.BeginWindow(...)
  -- draw stuff
  Slab.EndWindow()
  love.graphics.setLineWidth(1)
end
This way you can control per window the border width
deb75
Prole
Posts: 38
Joined: Sun Apr 18, 2021 1:11 pm

Re: Slab - An Immediate Mode GUI Library In Lua

Post by deb75 »

Yes, better !

But still all graphical elements within your window will inherit from this line width. What if you only want the window border to be affected ?

I dug a little into the Slab API, it seems possible to add a window optional parameter like "BorderWidth". But I would "love" that the Slab author and maintainer gives me some piece of advice about where to add it. At the moment, the Slab technical structure is a bit unclear for me.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests