[Lib] SUIT - Simple User Interface Toolkit

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

[Lib] SUIT - Simple User Interface Toolkit

Post 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 28400 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!
Last edited by vrld on Sun Jan 03, 2016 6:20 pm, edited 1 time in total.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
adnzzzzZ
Party member
Posts: 305
Joined: Sun Dec 26, 2010 11:04 pm
Location: Porto Alegre, Brazil

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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!
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
OttoRobba
Party member
Posts: 104
Joined: Mon Jan 06, 2014 5:02 am
Location: Sao Paulo, Brazil

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by OttoRobba »

Seems pretty good, I like it! API is pretty clean. :-)
User avatar
Ortimh
Citizen
Posts: 90
Joined: Tue Sep 09, 2014 5:07 am
Location: Indonesia

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Ortimh »

Great library. Love the name by the way. Maybe I will SUIT up.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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:
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
Attachments
bigdemo.love
(13.88 KiB) Downloaded 895 times
windows.love
(13.89 KiB) Downloaded 859 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
User avatar
akciom
Prole
Posts: 2
Joined: Mon Jan 04, 2016 12:05 am

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
padicao2010
Prole
Posts: 15
Joined: Wed Jan 15, 2014 8:38 am

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by padicao2010 »

Excellent!

SUIT need 0.10?

How about "Hold Backspace to delete multiple characters"?
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests