Löve Frames - A GUI Library

Showcase your libraries, tools and other projects that help your fellow love users.
Grubby
Prole
Posts: 35
Joined: Sat Jun 01, 2013 2:46 am

Re: Löve Frames - A GUI Library

Post by Grubby » Wed May 13, 2015 6:25 pm

So I've been toying with Loveframes and seem to be running into some confusion. Actually, it isn't exactly a Loveframes issue, but probably more so my newbie experience with lua code structure and proper use of modules. I think lua threw out some error about a loop when I try to require my modules. Shrug. To avoid a rather long post, I'll simply start with this:

Suppose I have a single button placed in the top right corner. When you click on it a function (via OnClick) then creates a panel populated with 8 buttons. The very last button is labeled "Exit" and its 'Onclick' function does nothing more then turn the panel invisible. So what happens when I do this again, or 5 times, or a hundred times? Does Loveframes keep making new objects or does it keep just what it needs? Would it be better to create the objects (The first button, the panel, and the panel objects) with some sort of init function in love.load? Or does it even matter?

If it doesn't matter and there are no hidden 'gotchas' I've yet to notice, I think I might be able to reduce or eliminate some module dependencies. Hopefully this post made some sense, but I doubt it. Any suggestions or comments appreciated.

One other thing is this. In the documentation on skinning it is stated:

Code: Select all

loveframe.util.SetActiveSkin("SKINNAME")

Doing this will change the active skin. If you only want to change the skin of one object you can do so like this:

local panel = loveframes.Create("panel")
panel:SetSkin("SKINNAME")

**Doing this will change the object's skin to the skin specified. It will also change all of the object's children's skins recursively.**
That last line doesn't seem to be true or I've missed something. I've created my own skin and it works just fine, but I only created that skin for use with only certain panels and buttons. The skin has a custom draw function for the panel object and different images for the button object. Everything else still uses the default 'Blue' skin. So when I do this:

Code: Select all

local panel = loveframes.Create("panel")
panel:SetSkin("WWar"):SetSize(500, 500):SetPos(512, 384, true)

local button = loveframes.Create("button", panel)
button:SetSize(32,14):SetText("Testing"):CenterX():SetY(32)
button.OnClick = function() end

local button2 = loveframes.Create("button", panel)
button2:SetSize(32,14):SetText("Exit"):CenterX():SetY(50)
button.OnClick = function()
	panel:SetVisible(false)
end
The panel gets drawn differently as expected, but the buttons still have the default skin attached. The only way I can get the buttons to show up with the new skin values is to add SetSkin("WWar") to each button. Aren't the buttons the children of the panel? Have I missed something here?

User avatar
Guard13007
Party member
Posts: 126
Joined: Sat Oct 25, 2014 3:42 am
Location: Internet, USA
Contact:

Re: Löve Frames - A GUI Library

Post by Guard13007 » Tue May 19, 2015 8:59 pm

Grubby wrote:Suppose I have a single button placed in the top right corner. When you click on it a function (via OnClick) then creates a panel populated with 8 buttons. The very last button is labeled "Exit" and its 'Onclick' function does nothing more then turn the panel invisible. So what happens when I do this again, or 5 times, or a hundred times? Does Loveframes keep making new objects or does it keep just what it needs? Would it be better to create the objects (The first button, the panel, and the panel objects) with some sort of init function in love.load? Or does it even matter?
I don't know about the rest of your post, but if you have a button creating objects each time around (and you're using locals and not re-using variables), then yes, you'll keep creating more and more. That said, the question isn't exactly that easy to answer, because depending on how you coded things, you might be allowing the old versions to be destroyed, or you might not.

It also could depend on how LoveFrames works internally, which I don't know much about. (I actually have a similar concern with this file (and I have an issue basically asking for help with that, but I haven't tried to contact anyone about it just yet). I think this gets rid of things, but depending on LoveFrames' internals, it might be keeping the objects around.)

User avatar
Guard13007
Party member
Posts: 126
Joined: Sat Oct 25, 2014 3:42 am
Location: Internet, USA
Contact:

Re: Löve Frames - A GUI Library

Post by Guard13007 » Thu May 21, 2015 6:08 am

I'm having an issue with using tab to switch between different textinput objects. I posted about it here, and maybe I'm just being too impatient about it, but I really want to figure out what's going wrong, so I thought I'd ask for help here as well.

The reason I'm asking it about it is because I got it working...one way. There are two textinputs I would like to tab between, and they both use the same method to switch, and as far as I can tell, it should work, but it only works from one to the other.

The specific file that is having the issue, if you want to see it, is here. I'll also update that thread to link to the file.

Muzz
Citizen
Posts: 54
Joined: Sun Jun 28, 2015 1:24 pm

Re: Löve Frames - A GUI Library

Post by Muzz » Wed Jul 01, 2015 4:05 pm

Hi Guys.

Awesome library! Has everything i need for the current project.

I found a bug that i'm having trouble locating the source of.

With the sliders, both vertical and horizontal, clicking and dragging will set the right value, but calling a change of value by code, or using the scroll wheel to modify the position put it in the wrong spot.

I've been trying to track variables for the last few hours with no luck :/.

User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: Löve Frames - A GUI Library

Post by qubodup » Sat Jul 04, 2015 4:34 pm

lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)

Muzz
Citizen
Posts: 54
Joined: Sun Jun 28, 2015 1:24 pm

Re: Löve Frames - A GUI Library

Post by Muzz » Sun Jul 05, 2015 8:27 am

Btw i found the fix to the slider bug

line 256 on slider.lua under if slidetype == "horizontal" then

local xpos = width * ((newval - min) / (max - min))

change to

local xpos = (width-internals[1].width) * ((newval - min) / (max - min))

Thanks for the great library btw!

DrPresident
Prole
Posts: 2
Joined: Thu Jul 02, 2015 7:12 pm

Re: Löve Frames - A GUI Library

Post by DrPresident » Wed Jul 08, 2015 6:04 am

Is there a way to place an object without a parent frame? Or maybe put down a frame that is not visible?
I also have a problem where I set the initial state, and everything for that state works perfectly until i call SetState again to change it, in which case it stops drawing anything for loveframes

Grubby
Prole
Posts: 35
Joined: Sat Jun 01, 2013 2:46 am

Re: Löve Frames - A GUI Library

Post by Grubby » Thu Jul 16, 2015 1:35 am

DrPresident wrote:Is there a way to place an object without a parent frame? Or maybe put down a frame that is not visible?
I also have a problem where I set the initial state, and everything for that state works perfectly until i call SetState again to change it, in which case it stops drawing anything for loveframes
As I don't have the docs handy, I believe you can put objects anywhere without the need for a frame/panel. For the second part, what I did in my Sim was to create a panel with an empty draw function, then associate all my other objects with that panel. The panel exists and functions yet nothing gets drawn. Maybe try something like this?

Code: Select all

local lf = require "Lib.LoveFrames"

local Panel = lf.Create("panel")
Panel:SetSize(120, 124):SetPos(512, 384, true)
-- Empty panel draw function for now
Panel.Draw = function() end
Panel:SetVisible(true)
HTH

User avatar
arampl
Party member
Posts: 245
Joined: Mon Oct 20, 2014 3:26 pm

Re: Löve Frames - A GUI Library

Post by arampl » Fri Jul 17, 2015 11:55 pm

Does anybody used Tree component?
Can't figure out how to make it work.

P.S. I'm getting an error about "iconwidth" var (nil value) when trying to add node.

duckdotexe
Prole
Posts: 4
Joined: Sat Apr 25, 2015 2:46 pm

Re: Löve Frames - A GUI Library

Post by duckdotexe » Sat Sep 19, 2015 2:32 am

What are the chances you could add a Resize callback to objects? It'd be fired when love.resize is called. It'd be really helpful for resizing toolbars automatically when the window changes size.

I know you can already do that by doing it right in love.resize but I wish I could just do it right on the object.

Post Reply

Who is online

Users browsing this forum: Exabot [Bot] and 8 guests