[Lib] SUIT - Simple User Interface Toolkit

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by parallax7d »

Seems like suit:draw is leaking color, bg color, font settings. This fixes it for me. Or am I doing something terribly wrong?

Code: Select all

function suit:draw()
        self:exitFrame()
        local oldColor = {love.graphics.getColor()}
        local oldBGColor = {love.graphics.getBackgroundColor()}
        local oldFont = love.graphics.getFont()
        for i = 1,self.draw_queue.n do
        	self.draw_queue[i]()
        end
        love.graphics.setColor(oldColor)
        love.graphics.setBackgroundColor(oldBGColor)
        love.graphics.setFont(oldFont)
        self.draw_queue.n = 0
        self:enterFrame()
end
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Nixola »

I think you're supposed to "cache" and set them on your own, not rely on the lib to do it.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by parallax7d »

I don't understand what you mean.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Nixola »

I mean that I think it's normal for libraries to "leak" settings, and you're supposed to set them after calling libraries' functions.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by parallax7d »

I guess it depends on the library, I don't see what use it is here though. Restoring graphics settings seems like a sensible thing for a UI library to do.
User avatar
alberto_lara
Party member
Posts: 372
Joined: Wed Oct 30, 2013 8:59 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by alberto_lara »

Nixola wrote:I mean that I think it's normal for libraries to "leak" settings, and you're supposed to set them after calling libraries' functions.
Not exactly, if by setting you mean the font set, colors, etc. you can save those and restore them after the library is "executed", inside the library "loop", it's not a bad idea to have somethig like:

Code: Select all

prevFont = love.graphics.getFont()
prevColor = love.graphics.getColor()
lineWidth = love.graphics.getLineWidth()

-- do the library stuff here

love.graphics.setFont(prevFont)
love.graphics.setColor(prevColor)
love.graphics.setLineWidth(lineWidth)
and as parallax7d said, this is really user friendly if we're talking about a GUI lib. I'm using this "technique" in GÖÖi (sorry, I like to put spam).
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by WetDesertRock »

Uh, what about .push and .pop? I coerced slime to make that work for the graphics state. love.graphics.push("all")
User avatar
alberto_lara
Party member
Posts: 372
Joined: Wed Oct 30, 2013 8:59 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by alberto_lara »

Well, there must be some settings the GUI library just can't "restore" after executing, I lust put some of the most commons above, maybe the mssa parameter or stuff like that can not be restored in real time every frame.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by bobbyjones »

Hey vrld use love.js to make an online demo \o/.
Frohman
Prole
Posts: 21
Joined: Sat Dec 08, 2012 12:32 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Frohman »

What'd be the cleanest way to implement pasting functionality? So from the keypressed callback, how can I determine which text input field is active such that I can then set its content accordingly?
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests