Page 1 of 9

[Lib] SUIT - Simple User Interface Toolkit

Posted: Fri Jan 01, 2016 9:07 pm
by vrld
It has taken a while, but the immediate mode GUI library formerly known as Quickie has gotten a much needed makeover. The changes are so severe, that it is fair to call it a different name. Thus, I give to you:

SUIT

The Simple/Smart/...Succulent? User Interface Toolkit for LÖVE.

SUIT takes quite a different approach to user interfaces than most other libraries: immediate, instead of retained mode. In a nutshell, this means that widgets are not objects, but functions, and that you create the entire UI every frame from scratch.

Like my other libraries, SUIT was developed by observing what my needs when programming games and then filtering out the particular techniques. The previous installment, Quickie, became bigger and clunky over time, as new features were added and issues were uncovered. In the end, I couldn't even remember how the API worked, which is usually a very bad sign. SUIT is a rewrite of the core concepts with a very clear API that allows to construct GUIs with very few lines of code.

But enough talk, here is the hello world of SUIT: edit: updated code to reflect current API

Code: Select all

local suit = require 'suit' -- suit up

local input = {text = ""} -- text input data

-- the entire UI is defined inside love.update(dt) (or functions that are called from love.update)
function love.update(dt)
    suit.layout:reset(100,100)

    suit.Input(input, suit.layout:row(200,30))
    suit.Label("Hello, "..input.text, {align = "left"}, suit.layout:row())

    suit.layout:row() -- padding of one cell
    if suit.Button("Close", suit.layout:row()).hit then
        love.event.quit()
    end
end

function love.draw()
    suit.draw()
end

function love.textinput(t)
    suit.textinput(t)
end

function love.keypressed(key)
    suit.keypressed(key)
end
The above produces the following:
suitup.png
suitup.png (2.36 KiB) Viewed 24243 times
As always, you can take a look at the code over at github. The (still incomplete) documentation is hosted at readthedocs.

Happy new year!

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Fri Jan 01, 2016 10:24 pm
by adnzzzzZ
I haven't used Quickie nor this yet but I really like the idea of everything happening in the update function. I've found that doing things this way usually leads to simpler code. I'll try using this to see if it fits my needs too, thanks!

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sat Jan 02, 2016 1:14 pm
by s-ol
I really liked Quickie so I will definetely give this a try. Immediate mode UIs are interesting but it feels a bit weird to me to keep the state around in a seperate variable sometimes, if the state is not just the exact result that I want to "prompt" the user for with the UI basically.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Jan 03, 2016 6:54 am
by OttoRobba
Seems pretty good, I like it! API is pretty clean. :-)

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Jan 03, 2016 7:14 am
by Ortimh
Great library. Love the name by the way. Maybe I will SUIT up.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Jan 03, 2016 9:08 am
by parallax7d
Dream come true, thanks for reworking quickie and adding in these cool new features! The docs are fun to read to boot :ultraglee:

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Jan 03, 2016 6:19 pm
by vrld
Tons of updates! Ok, four, but still: I've attached the big demo that shows ALL THE WIDGETS so you can get a feel for them. Here is how they look, anyway:

Image

Interestingly, the fourth update can be used to implement overlapping windows with SUIT. A demo is attached. This will not become part of the main library, though.
S0lll0s wrote:Immediate mode UIs are interesting but it feels a bit weird to me to keep the state around in a seperate variable sometimes, if the state is not just the exact result that I want to "prompt" the user for with the UI basically.
But you do that with retained mode GUI toolkits, too. The only difference is that they lump behavior with the state, too (and call it OOP). If Lua would have pointers or C++-style references, the API could be more concise, e.g.: Slider(&value, {min = 0, max = 100}), but I don't think the table "hack" is too bad.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Jan 03, 2016 7:21 pm
by pgimeno
Looking great and working great!

It seems main.lua in the repository is deprecated. Could it be either updated or removed to avoid people being confused by it?
EDIT: Oops, my bad. The problem is that main.lua is in .gitignore, not in the repository, and the main.lua I had didn't work.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Mon Jan 04, 2016 1:20 am
by akciom
I was taking a look at Quickie awhile back and liked what it had to offer but found it to be quite messy. Thank you, I appreciate the work you put in to clean it up.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Mon Jan 04, 2016 2:45 am
by padicao2010
Excellent!

SUIT need 0.10?

How about "Hold Backspace to delete multiple characters"?