Page 1 of 1

Simplify - simple Event-driven GUI library

Posted: Fri Jun 30, 2017 5:13 pm
by mastermarkus
Repository: https://github.com/mastermarkus/simplify
Documantation: https://github.com/mastermarkus/simplify/wiki

Simplify is a simple Event-driven GUI library for Löve2D. With this library you can simply create GUI elements and listen for mouse and keyboard input. This library also support's ZIndex drawing order system, where you can specify the display order of GUI elements.



Quick example:

Code: Select all


function love.load()
    simplify = require('simplify')

    local testbutton = simplify:TextButton(200,100)--size paramters
    --testbutton:SetSize(500,500) you can also set size at any time with :SetSize()
    testbutton:SetTextXAlignment("Center")-- "Left", "Center", "Right"
    testbutton:SetTextYAlignment("Center")-- "Top", "Center", "Bottom"
    testbutton:SetPosition(300,300)
    testbutton:SetText("Hello world!")
    testbutton:SetTextColor(0,0,255)--Blue text ,you cant set alpha with this method directly
    testbutton:SetBorderSizePixel(5)
    testbutton:SetBorderColor(255,0,0)
    testbutton:SetBackgroundColor(70,70,70) -- grey background
end

Listening for mouse events

Code: Select all


 testbutton.MouseButton1Down:connect(function(x,y)--return where mouse clicked on button
        print("Mouse Clicked at X: "..x.." Y:"..y)
    end)

    testbutton.MouseEnter:connect(function(x,y)--return where mouse entered on button
        print("Mouse Enteres at X: "..x.." Y:"..y)
    end)



The main purpose of this project is to make development of Gui easier and more fun. Right now, there's no documentation, but it's pretty straightforward, by simply looking at "Simplify.lua" main file and other class modules.

In future i plan to add Gui groups. Lets say you have minimap or inventory UI in your game and you want them to always to stay on top of
other Guis, well that's the point of Gui groups,they have their specific MasterZIndex and then children are individual GUI elements, that also have regular ZIndex property.

Because i do this all myself, it takes a lot of time and i would be glad if you are willing to contribute to the repositiory bug fixes, new features etc...

Re: Simplify - simple Event-driven GUI library

Posted: Fri Jun 30, 2017 9:19 pm
by Shadowblitz16
This is cool I have tried to develop GUI libraries in gamemaker in the past however I'm not very good at it.

one thing you might want to do early on though is support tiling and scaling for 9slice sprites
this would allow people to add sprite skins to their gui's

also I would help but looking at the source it looks like you know far more in lua then i do, I would probably mess it up.

Re: Simplify - simple Event-driven GUI library

Posted: Sun Jul 02, 2017 1:45 am
by Beelz
Not too shabby, athough I do want to point out one thing... In lines 99-106 of 'Simplify.lua' you overwrite the Love callbacks... While not too much of an issue for a personal project, doing so in a library you're releasing to the public is another story. That said, what you should do is either document that the end user needs to forward the callbacks, or monkey-patch it(preferably the former). Below is an easy way to monkey patch it, if that's the route you take.

Code: Select all

-- if love.update is already defined we make a local copy, else use anonymous function
local love_update = love.update ~= nil and love.update or function() end

-- overwrite love.update
function love.update(dt)
	-- do stuff
	
	-- call the original love.update the end user created
	-- or an empty function, if they didn't
	love_update(dt)
end


Re: Simplify - simple Event-driven GUI library

Posted: Sun Jul 02, 2017 10:13 am
by Nixola
Monkeypatching is not a good thing. The user could overwrite the callbacks at any moment, breaking the library.

Re: Simplify - simple Event-driven GUI library

Posted: Sun Jul 02, 2017 1:57 pm
by mastermarkus
Beelz wrote: Sun Jul 02, 2017 1:45 am Not too shabby, athough I do want to point out one thing... In lines 99-106 of 'Simplify.lua' you overwrite the Love callbacks... While not too much of an issue for a personal project, doing so in a library you're releasing to the public is another story. That said, what you should do is either document that the end user needs to forward the callbacks, or monkey-patch it(preferably the former). Below is an easy way to monkey patch it, if that's the route you take.

Code: Select all

-- if love.update is already defined we make a local copy, else use anonymous function
local love_update = love.update ~= nil and love.update or function() end

-- overwrite love.update
function love.update(dt)
	-- do stuff
	
	-- call the original love.update the end user created
	-- or an empty function, if they didn't
	love_update(dt)
end

Alrighty thanks for pointing that one out, i fixed the problem.

Re: Simplify - simple Event-driven GUI library

Posted: Mon Jul 03, 2017 5:42 pm
by mastermarkus
I now added detailed Documentation for all the available Gui elements.