Page 4 of 9

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Feb 09, 2016 11:49 am
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

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Feb 09, 2016 12:38 pm
by Nixola
I think you're supposed to "cache" and set them on your own, not rely on the lib to do it.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Feb 09, 2016 2:29 pm
by parallax7d
I don't understand what you mean.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Feb 09, 2016 3:18 pm
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.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Feb 09, 2016 4:07 pm
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.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Wed Feb 10, 2016 4:26 am
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).

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Wed Feb 10, 2016 8:08 am
by WetDesertRock
Uh, what about .push and .pop? I coerced slime to make that work for the graphics state. love.graphics.push("all")

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Wed Feb 10, 2016 7:22 pm
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.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Wed Feb 10, 2016 8:35 pm
by bobbyjones
Hey vrld use love.js to make an online demo \o/.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sun Feb 21, 2016 6:43 pm
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?