LoveUI for Love 0.5.0

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

LoveUI for Love 0.5.0

Post by appleide »

See latest posts for downloads
--------------- Original first post ---------------
Not exactly next generation, I'm sorry. It's actually an imitation of a commercially available framework (for free). It will be robust. Adding to this framework is also systematic. Just subclass LoveUI.View and write your drawing and input handling code to create a new gui widget. Distributing input to various 'views' is systematic and formulaic. There is no overlapping, no mistakes; only one widget at a time can receive mouse/key inputs. And hopefully, it is simple to use, too.

So far there is not a single widget done but I have written the foundations. The LoveUI.View is slightly modified so you can actually see what is happening in the example.

What inspired me was my previous gui-lib and the past three months I spent playing with objective-C on the iphone. I looked at the old gui-lib code and it looked pretty old and needed to be redone, probably because of everything I've learnt in between. ;)

I'm hoping, in the future, it'll come with not only buttons, textfields, dialogs, checkboxes, radiobuttons but also tables, multiline textviews, scrollable views and even more, or if I cannot do this, you can.

I'd like some comments on not only my code but also my comments in this example please! I got my first job offer in software (Yes, with low student pay, long hours, etc... :s) so I'd like to learn how to comment more 'professionally'. :)

Here's some example code:

Code: Select all

-- EXAMPLE.lua
-- Just include LoveUI.lua like this:
	love.filesystem.require("LoveUI/LoveUI.lua")

-- Setup a 'context' for your love app.:
	myLoveUIContext=LoveUI.Context:new(640,480);
		
-- All LoveUI widgets you create will belong to this context's view.
-- The Context passes on events from your love app to various views and widgets.
-- Note that you're only supposed to have one context per love app.

-- Plug the context to your event handlers in the load function:
-- Automatically:
	function load()
		myLoveUIContext:plugin();
	end

-- Or Manually:
	function mousepressed(x, y, button)
		myLoveUIContext:mouseEvent(x, y, button, myLoveUIContext.mouseDown)
	end
	
	function mousereleased(x, y, button)
		myLoveUIContext:mouseEvent(x, y, button, myLoveUIContext.mouseUp)
	end
	
	function draw(dt)
		myLoveUIContext:display(dt)
	end
-- Remember to re-plugin the context if you happen to be re-declaring these callback functions later on!

-- Create Views, or subclasses of Views, eg. button, textfields, etc
-- A View is a rectangular region on screen that, when subclassed by widget, displays images or text or both.
-- They also receive mouse and key events.

	local aButton=LoveUI.Button:new(LoveUI.Rect:new(10,10, 128, 32));
	local aView1=LoveUI.View:new(LoveUI.Rect:new(400,10,100,100));
	--local aView2=LoveUI.View:new(LoveUI.Rect:new(10,10,80,80));
	--local aView3=LoveUI.View:new(LoveUI.Rect:new(10,10,60,60));
	
	
-- Add the views to the context's contentView using the addSubview command.
	myLoveUIContext.contentView:addSubview(aView1);
	--myLoveUIContext.contentView:addSubview(aView2);
	myLoveUIContext.contentView:addSubview(aButton);
	
	aButton.action=function(sender)
		sender.color=love.graphics.newColor(0, 0, 255);
	end
	
	
-- Views can have subviews of their own.
-- Note that coordinates used to initialise the views are relative to the view's superview, not to the screen.
	--aView:addSubview(aView3);
The following attachment is released under same license as love where ever legally possible.
Attachments
Picture 1.png
Picture 1.png (33.34 KiB) Viewed 36187 times
LoveUI_release.love
March 22, 2009
(222.71 KiB) Downloaded 1199 times
LoveUI.love
March 18, 2009
(216.55 KiB) Downloaded 1040 times
Last edited by appleide on Mon Oct 05, 2009 9:11 am, edited 16 times in total.
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: LoveUI... The next generation in gui development.

Post by Kaze »

The default responder chain for a key event message begins with the first responder in a context; the default responder chain for a mouse event begins with the view on which the user event occurred.
Your comments are kind of long and hard to read.
User avatar
qubodup
Inner party member
Posts: 775
Joined: Sat Jun 21, 2008 9:21 pm
Location: Berlin, Germany
Contact:

Re: LoveUI... The next generation in gui development.

Post by qubodup »

Kaze: I think appleide means the text block in his post. Not the attachment.

The comments feel fine (length to verbosity), but I don't understand them because I don't know what a context and a view is (defined as).
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)
philnelson
Prole
Posts: 48
Joined: Sun Feb 01, 2009 3:32 am

Re: LoveUI... The next generation in gui development.

Post by philnelson »

I'm in the marketing for a Love-based GUI framework. I dig the verbosity of the comments in the code, that is a good thing.
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: LoveUI... The next generation in gui development.

Post by appleide »

Thanks guys :)

Updated a new example. and new .love zipped attachment in first post. (for mac users unzip and rename with .love extension, for windows users I'm not sure if you can just rename the .zip as .love... but I think you can, I just zipped up the folder and uploaded it.)

Added Button, which is half finished.
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: LoveUI... The next generation in gui development.

Post by Kaze »

appleide wrote:Thanks guys :)

Updated a new example. and new .love zipped attachment in first post. (for mac users unzip and rename with .love extension, for windows users I'm not sure if you can just rename the .zip as .love... but I think you can, I just zipped up the folder and uploaded it.)

Added Button, which is half finished.

Code: Select all

[string "..."]:8: Could not include file "LoveUI\LoveUIObject.lua".
stack traceback:
	[C]: in function 'include'
	[string "..."]:8: in function 'include'
	[string "..."]:13: in function 'require'
	[string "LoveUI/LoveUI.lua"]:131: in function 'loadClass'
	[string "LoveUI/LoveUI.lua"]:159: in main chunk
	[C]: in function 'include'
	[string "..."]:8: in function 'include'
	[string "..."]:13: in function 'require'
	[string "main.lua"]:1: in main chunk
User avatar
mikembley
Citizen
Posts: 72
Joined: Wed Dec 17, 2008 5:30 pm
Location: Blackburn, UK
Contact:

Re: LoveUI... The next generation in gui development.

Post by mikembley »

ditto!
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: LoveUI... The next generation in gui development.

Post by appleide »

What operating system do you two use?
I had this bit of code in there:

Code: Select all

local FILE_PATH_SEPARATOR="/"
	if love.system.getPlatform( )=="Windows" then
		FILE_PATH_SEPARATOR="\\"
	end	
I thought on windows file paths are separated by "\" instead of by "/"...
User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: LoveUI... The next generation in gui development.

Post by Kaze »

appleide wrote:What operating system do you two use?
I had this bit of code in there:

Code: Select all

local FILE_PATH_SEPARATOR="/"
	if love.system.getPlatform( )=="Windows" then
		FILE_PATH_SEPARATOR="\\"
	end	
I thought on windows file paths are separated by "\" instead of by "/"...
Windows. Works without that.
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: LoveUI... The next generation in gui development.

Post by appleide »

Okay, fixed it and uploaded!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest