Page 4 of 41

Re: Löve Frames - A GUI Library

Posted: Thu May 10, 2012 1:34 am
by linux-man
Lovely library! Thanks for the image buttons.
Now I needed a button array (a list of buttons where only one stays "down"), so I made some little changes to your code.
If groupIndex > 0 a button is allways "on". Other buttons of the same group are "off"
In button.lua:

Code: Select all

function button:initialize()

	self.type			= "button"
	self.text 			= "Button"
	self.width 			= 80
	self.height 		= 25
	self.internal		= false
	self.down			= false
	self.clickable		= true
	self.enabled		= true
	self.OnClick		= nil
	self.groupIndex		= 0
	self.switched 		= false
end
and

Code: Select all

function button:mousereleased(x, y, button)
	
	if self.visible == false then
		return
	end
	
	local hover = self.hover
	local down = self.down
	local clickable = self.clickable
	local enabled = self.enabled
	
	if hover == true and down == true and button == "l" and clickable == true then
		if enabled == true then
			if self.groupIndex ~= 0 then
				local baseparent = self:GetBaseParent()
				if baseparent then
					if baseparent.children then
						for k, v in ipairs(baseparent.children) do
							if v.type == "button" and v.groupIndex == self.groupIndex then
								v.switched = false
							end
						end
					end
				end
				self.switched = true
			end
			if self.OnClick then
				self.OnClick(self, x, y)
			end
		end
	end
	self.down = false
end
On skin.lua:

Code: Select all

function skin.DrawButton(object)

	local index	= loveframes.config["ACTIVESKIN"]
	local font = skin.controls.button_text_font
	local twidth = font:getWidth(object.text)
	local theight = font:getHeight(object.text)
	local hover = object.hover
	local down = object.down
	local switched = object.switched
	local gradientcolor = {}
	
	if down == true or switched == true then
...

Re: Löve Frames - A GUI Library

Posted: Thu May 10, 2012 10:02 am
by SiENcE
linux-man wrote:Lovely library! Thanks for the image buttons.
Now I needed a button array (a list of buttons where only one stays "down"), so I made some little changes to your code.
You can "Fork" the github repo and than "Clone" it to your desktop. "Merge" your changes in, "Commit" and "Push" it to your Github Fork. Than send a "Pull request" to Nikolai.

This way it's a lot easier for him to merge your changes.

Hope this helps using github :).

thx and good luck!

Re: Löve Frames - A GUI Library

Posted: Thu May 10, 2012 10:52 am
by linux-man
Thanks for the tips. I'll do it if I can contribute more.

One bug: function list:GetScrollBar() crash if there are no scrollbars. Should return nil...
Also, I think that list size shouldn't include scrollbars.

One question: What's the difference between "enabled" and "clickable" ? They seem to have the same behavior.

Re: Löve Frames - A GUI Library

Posted: Thu May 10, 2012 6:59 pm
by Nikolai Resokav
Averice wrote:This look absolutely amazing, awesome work Nikolai ( It makes my GUI look like poo. )
Thanks!
bartoleo wrote: awesome
it's the best GUI I saw with Love
Thanks!
Ensayia wrote: This is by far one of the most polished GUI libraries I have seen for LOVE.

If you don't mind, i'll seriously consider using this while making the editor for my game.
Thanks! I hope my library works well for your editor if you decide to use it.
linux-man wrote:Lovely library! Thanks for the image buttons.
Now I needed a button array (a list of buttons where only one stays "down"), so I made some little changes to your code.
If groupIndex > 0 a button is allways "on". Other buttons of the same group are "off"
In button.lua:

Code: Select all

function button:initialize()

	self.type			= "button"
	self.text 			= "Button"
	self.width 			= 80
	self.height 		= 25
	self.internal		= false
	self.down			= false
	self.clickable		= true
	self.enabled		= true
	self.OnClick		= nil
	self.groupIndex		= 0
	self.switched 		= false
end
and

Code: Select all

function button:mousereleased(x, y, button)
	
	if self.visible == false then
		return
	end
	
	local hover = self.hover
	local down = self.down
	local clickable = self.clickable
	local enabled = self.enabled
	
	if hover == true and down == true and button == "l" and clickable == true then
		if enabled == true then
			if self.groupIndex ~= 0 then
				local baseparent = self:GetBaseParent()
				if baseparent then
					if baseparent.children then
						for k, v in ipairs(baseparent.children) do
							if v.type == "button" and v.groupIndex == self.groupIndex then
								v.switched = false
							end
						end
					end
				end
				self.switched = true
			end
			if self.OnClick then
				self.OnClick(self, x, y)
			end
		end
	end
	self.down = false
end
On skin.lua:

Code: Select all

function skin.DrawButton(object)

	local index	= loveframes.config["ACTIVESKIN"]
	local font = skin.controls.button_text_font
	local twidth = font:getWidth(object.text)
	local theight = font:getHeight(object.text)
	local hover = object.hover
	local down = object.down
	local switched = object.switched
	local gradientcolor = {}
	
	if down == true or switched == true then
...
No problem! Also, I'm glad you're finding extended use of the button object!

Re: Löve Frames - A GUI Library

Posted: Fri May 11, 2012 6:23 am
by DumpOnIt
Wow! This is really really cool! The thing where you press down on a button then drag outside above other buttons and have them do nothing doesn't seem to work exactly like that in the demo, but I absolutely LOVE your work!

Re: Löve Frames - A GUI Library

Posted: Fri May 11, 2012 8:15 am
by Nikolai Resokav
linux-man wrote: One bug: function list:GetScrollBar() crash if there are no scrollbars. Should return nil...
Also, I think that list size shouldn't include scrollbars.
Thanks for the info! I'll have that fixed in the next update. Also, please report the bugs you find to the issue tracker on the github repository if you can, as this makes keeping track of bugs easier and it also helps people who may be encountering the same bugs.
linux-man wrote: One question: What's the difference between "enabled" and "clickable" ? They seem to have the same behavior.
If a button is "clickable" it will become "down" when pressed. If a button is "enabled" it will run it's OnClick function when clicked if it has one.
DumpOnIt wrote: Wow! This is really really cool!
Thanks!
DumpOnIt wrote: The thing where you press down on a button then drag outside above other buttons and have them do nothing doesn't seem to work exactly like that in the demo, but I absolutely LOVE your work!
I'm not quite sure what you mean dragging buttons and them not doing anything. If you could give me more details I should be able to help you whatever the problem is.

Re: Löve Frames - A GUI Library

Posted: Sat May 12, 2012 2:45 am
by DumpOnIt
Nikolai Resokav wrote:I'm not quite sure what you mean dragging buttons and them not doing anything. If you could give me more details I should be able to help you whatever the problem is.
Sorry I guess I could have explained that better :roll: . I was talking about the hover animation of other buttons when you are still dragging off a different button. Here's a video: http://www.youtube.com/watch?v=e0nwK_X5x-8

Re: Löve Frames - A GUI Library

Posted: Sat May 12, 2012 11:05 pm
by Nikolai Resokav
DumpOnIt wrote:
Nikolai Resokav wrote:I'm not quite sure what you mean dragging buttons and them not doing anything. If you could give me more details I should be able to help you whatever the problem is.
Sorry I guess I could have explained that better :roll: . I was talking about the hover animation of other buttons when you are still dragging off a different button. Here's a video: http://www.youtube.com/watch?v=e0nwK_X5x-8
Oh thats what you meant. Yeah I've considered preventing objects from being hovered over when another object is "down". I'll probably change that in the next update.

Re: Löve Frames - A GUI Library

Posted: Thu May 24, 2012 1:05 am
by KingRecycle
Do you mind posting the code for your demo?

I read the documentation and what not but I believe I must be doing something wrong as nothing works.
It will draw like a button but the doclick function won't work it seems.

Love the look of the library though. Reminds me of Garry's Mod's DERMA or GWEN by Garry Newman.

Re: Löve Frames - A GUI Library

Posted: Fri May 25, 2012 11:27 am
by Nikolai Resokav
KingRecycle wrote:Do you mind posting the code for your demo?

I read the documentation and what not but I believe I must be doing something wrong as nothing works.
It will draw like a button but the doclick function won't work it seems.
The code for the demo can be found by opening up the .love file with an archiving application such as 7-Zip. Your problem sounds strange though. Is it possible you could make a video showing what the issue is?
KingRecycle wrote: Love the look of the library though. Reminds me of Garry's Mod's DERMA or GWEN by Garry Newman.
Yeah, I used to code gamemodes and addons for Garry's Mod a lot. Me using DERMA so much in the past has no doubt influenced many aspects of Löve Frames.