[Library] Thranduil

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

[Library] Thranduil

Post by adnzzzzZ »

Hi. I've created a UI library for LÖVE. The idea is that for all UI elements their state and input logic is abstracted away while the user of the library only has to care about how each element is drawn. This makes it easy to create all sorts of UIs for games (since in games they need to look really different all the time) and also makes it simpler to build more complex UI elements on top of the ones that exist right now. The library is under development still, I've only added 3 UI elements so far and no themes, but I thought I'd publish it as it is now to see if people find it useful or not.

Thranduil

Documentation
Last edited by adnzzzzZ on Sat Mar 21, 2015 5:50 am, edited 1 time in total.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: [Library, WIP] Thranduil

Post by SiENcE »

I'm watching :).
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: [Library, WIP] Thranduil

Post by Doctory »

looks really cool :)
i may use it in future projects
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: [Library, WIP] Thranduil

Post by Muris »

I tried using the library, but I couldnt figure out if there is like a function or something that gets called when button is being clicked. In general if you click a button, you can start holding down on top of button, then drag mouse off from button and release, but it doesn't actually do clicking. I am not really sure if its neccessary to be able to cancel a click, but currently from what I tested you cannot have a state where released is true and down is true, or maybe it was, but this would mean that you would yourself have to manually keep a state of each button.

Also out of curiosity I tried the gui with android phone, because that is what I have been looking for, a gui that works with Android phone (currently Quickie is only one, but I had a problem with the button click being registered few frames after the click ), but sadly at least out of box thranduil didn't.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: [Library, WIP] Thranduil

Post by Roland_Yonaba »

I dont know for the name... Why not cap up the "U" ?
Just my two cents.
This is awesome anyway. Nice API, and well written documentation.
I'd love some demos though. :awesome:
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: [Library, WIP] Thranduil

Post by Jeeper »

That is some pretty impressive documentation. The library seems awesome and it is clear that you have put a lot of effect into it :)
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: [Library, WIP] Thranduil

Post by adnzzzzZ »

Muris wrote:I tried using the library, but I couldnt figure out if there is like a function or something that gets called when button is being clicked. In general if you click a button, you can start holding down on top of button, then drag mouse off from button and release, but it doesn't actually do clicking. I am not really sure if its neccessary to be able to cancel a click, but currently from what I tested you cannot have a state where released is true and down is true, or maybe it was, but this would mean that you would yourself have to manually keep a state of each button.
There's no function that gets called when anything happens. All that happens is that the object's state changes and if you wanna do anything you keep looking at that:

Code: Select all

function update(dt)
    button:update(dt)
    if button.pressed then
        doYourPressedAction()
    end
    if button.down then
        doYourDownAction()
    end
    if button.released then
        doYourReleasedAction()
    end
end
If you wanna make things not do the clicking if you hold the button, drag the mouse off and then release, do something like this:

Code: Select all

function update(dt)
    button:update(dt)
    if button.released and button.hot then
        doYourReleasedAction()
    end
end
This way it will only do the action when the button is released and when the mouse is hovering the button.
Muris wrote:Also out of curiosity I tried the gui with android phone, because that is what I have been looking for, a gui that works with Android phone (currently Quickie is only one, but I had a problem with the button click being registered few frames after the click ), but sadly at least out of box thranduil didn't.
I don't care about mobile so yea, it won't work there. It should be some work to get it working there because you have to change the Input module https://github.com/adonaac/thomas to support the additional events that exist in mobile and then add those events to each UI element.
User avatar
SiENcE
Party member
Posts: 792
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: [Library, WIP] Thranduil

Post by SiENcE »

I don't like the decision that I have to call button:update() and button:draw() myself. By using GSpot I only have to register gspot:update() in my update function and everything is done. Like you register the Input Callbacks.
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: [Library, WIP] Thranduil

Post by adnzzzzZ »

Well, I made that decision because that gives the user more control over his UI objects and makes things more explicit. Imagine the idea is to create one of those terminals that some games have:

Image

Image

It really doesn't help you when coding the logic for these things to have your UI objects hidden away somewhere and doing too many things automatically, right?

Anyway, you can change this if you want by creating UI.update and UI.draw functions in the UI.lua file, going over the elements list and updating/drawing each object.

Code: Select all

UI.update = function(dt)
    for _, element in ipairs(UI.elements) do
        if not element.parent then
            element:update(dt)
        end
    end
end

UI.draw = function()
    for _, element in ipairs(UI.elements) do
        if not element.parent then
            element:draw()
        end
    end
end
And then just register UI.update and UI.draw on love.update and love.draw. The if not element.parent check is so that you don't update/draw elements that are inside a frame twice, since when objects are added to a frame, their parent attribute is changed to point to the frame and the frame already takes care of updating/drawing its children.
User avatar
TsT
Party member
Posts: 161
Joined: Thu Sep 25, 2008 7:04 pm
Location: France
Contact:

Re: [Library, WIP] Thranduil

Post by TsT »

I added your library in the wiki (you can fix information yourself, if I'm wrong) :

https://www.love2d.org/wiki/Thranduil

Shown in the GUI list :

https://www.love2d.org/wiki/Graphical_User_Interface
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)
Post Reply

Who is online

Users browsing this forum: No registered users and 49 guests