Löve Frames - A GUI Library

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: Löve Frames - A GUI Library

Post by Doctory »

is there anyway to check if a frame is closed?
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

Doctory wrote:is there anyway to check if a frame is closed?
You can use the frame.OnClose callback to detect when a frame is closed.
MrJones
Prole
Posts: 2
Joined: Tue Sep 09, 2014 10:24 am

Re: Löve Frames - A GUI Library

Post by MrJones »

Is there some way of automated layouting? Like GTK+'s box packing or Qt's layout containers. I don't want to base my design on hardcoded pixel-based button positions if possible
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

MrJones wrote:Is there some way of automated layouting? Like GTK+'s box packing or Qt's layout containers. I don't want to base my design on hardcoded pixel-based button positions if possible
Not currently, though I'd like to add something like that in the future.
suchipi
Prole
Posts: 1
Joined: Mon Nov 03, 2014 9:05 am

Re: Löve Frames - A GUI Library

Post by suchipi »

Just tried out this library tonight- it's clean, functional, and, most importantly, well-documented! I've used Gmod's Derma before and though it was an obvious inspiration to this library, Löve Frames has a leg up on it in many situations (most notably a builtin function to remove all elements- makes prototyping a ton easier). I also really appreciate that even the functions intended for internal use are straightforward and well-documented- I was able to add/change specific functionality to existing elements very easily.

How did you implement dynamic sizing of elements in a resizable frame in your demo? Right now, I've been defining a custom function on each object that tells it what to do when its parent is resized, and telling the parent to call this function on its children when resized. It works, but I feel I may be overlooking a method of accomplishing this you've already built into your library. Am I?
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

suchipi wrote:Just tried out this library tonight- it's clean, functional, and, most importantly, well-documented! I've used Gmod's Derma before and though it was an obvious inspiration to this library, Löve Frames has a leg up on it in many situations (most notably a builtin function to remove all elements- makes prototyping a ton easier). I also really appreciate that even the functions intended for internal use are straightforward and well-documented- I was able to add/change specific functionality to existing elements very easily.
Glad to hear that your experience has been good so far! Also, you're right about Love Frames being inspired by Derma. Before I started doing things in LOVE, I used to make gamemodes and addons for Garry's Mod, and I used Derma quite a bit. My previous experiences with Derma have no doubt inspired many aspects of Love Frames.
suchipi wrote:How did you implement dynamic sizing of elements in a resizable frame in your demo? Right now, I've been defining a custom function on each object that tells it what to do when its parent is resized, and telling the parent to call this function on its children when resized. It works, but I feel I may be overlooking a method of accomplishing this you've already built into your library. Am I?
You're not overlooking anything. For that example, I've essentially created a custom update function for each panel which calculates what their size and position should be based on the size and position of the frame. Ideally, I'd like to implement an object that can handle the resizing automatically without the need for custom update functions. The developer would then be able to customize how the resizing is handled via object methods.
User avatar
Rishavs
Party member
Posts: 103
Joined: Sat Oct 17, 2009 5:29 am
Contact:

Re: Löve Frames - A GUI Library

Post by Rishavs »

Hi Kenny
I am new to both lua and love2d and was trying to get your library to work.
Can you tell me what am i doing wrong here?
This works.

Code: Select all

    button:SetSize(200, 100):SetText("Button"):Center()
    button.OnClick = button:SetText("You clicked the button!")
But doing this throws an exception:

Code: Select all

    button:SetSize(200, 100):SetText("Button"):Center()
    button.OnClick = button:SetText("You clicked the button!")

    button.OnMouseEnter = button:SetText("The mouse entered the button.")

    button.OnMouseExit = button:SetText("Button")
exception.png
exception.png (8.75 KiB) Viewed 5483 times
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

Rishavs wrote:Hi Kenny
I am new to both lua and love2d and was trying to get your library to work.
Can you tell me what am i doing wrong here?
This works.

Code: Select all

    button:SetSize(200, 100):SetText("Button"):Center()
    button.OnClick = button:SetText("You clicked the button!")
But doing this throws an exception:

Code: Select all

    button:SetSize(200, 100):SetText("Button"):Center()
    button.OnClick = button:SetText("You clicked the button!")

    button.OnMouseEnter = button:SetText("The mouse entered the button.")

    button.OnMouseExit = button:SetText("Button")
exception.png
You should create your event callbacks like this instead:

Code: Select all

button.OnClick = function()
    button:SetText("You clicked the button!")
end

button.OnMouseEnter = function()
    button:SetText("The mouse entered the button.")
end

button.OnMouseExit = function()
    button:SetText("Button")
end
User avatar
Rishavs
Party member
Posts: 103
Joined: Sat Oct 17, 2009 5:29 am
Contact:

Re: Löve Frames - A GUI Library

Post by Rishavs »

Kenny

Do you know if your library plays nice with HUMP? http://vrld.github.io/hump/
I think I am screwing up somewhere in trying to use both the libraries.
Here's my entire code

Code: Select all

------------------------------------------------
-- Modules
------------------------------------------------
Gamestate = require "modules.hump.gamestate"
LF = require "modules.loveframes"

------------------------------------------------
-- Declarations
------------------------------------------------
local _state_MainLoader = {} 
local _state_MainMenu = {} 
local _state_Settings = {} 
local _state_Game = {}

------------------------------------------------
-- Base functions
------------------------------------------------
function love.load()
    Gamestate.registerEvents()
    Gamestate.switch(_state_MainLoader)
end

function love.quit()

end

------------------------------------------------
-- State Definition: _state_MainLoader
------------------------------------------------

function _state_MainLoader:draw()
    love.graphics.print("State: _state_MainLoader", 10, 10)
    love.graphics.print("Press ENTER to goto next screen", 10, 20)
end

function _state_MainLoader:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end

------------------------------------------------
-- State Definition: _state_MainMenu
------------------------------------------------

function _state_MainMenu:draw()
    love.graphics.print("State: _state_MainMenu", 10, 10)
    
    bt_settings = LF.Create("button")
    bt_settings:SetSize(100, 50)
    bt_settings:SetText("Setting")
    bt_settings:CenterX()
    bt_settings:SetY(200)
    bt_settings.OnClick = function(object)
        Gamestate.switch(_state_Settings)
    end

    local bt_game = LF.Create("button")
    bt_game:SetSize(100, 50)
    bt_game:SetText("start")
    bt_game:CenterX()
    bt_game:SetY(300)
    bt_game.OnClick = function(object)
        Gamestate.switch(_state_Game)
    end
    
    local bt_quit = LF.Create("button")
    bt_quit:SetSize(100, 50)
    bt_quit:SetText("quit")
    bt_quit:CenterX()
    bt_quit:SetY(400)
    bt_quit.OnClick = function(object)
        Gamestate.switch(_state_Game)
    end
    
    
    LF.draw()
    
end

function _state_MainMenu:keypressed(key)
    LF.keypressed(key, unicode)
end

function _state_MainMenu:keyreleased(key)
    LF.keyreleased(key)
end

function _state_MainMenu:mousepressed(x, y, button)
    LF.mousepressed(x, y, button)

end

function _state_MainMenu:mousereleased(x, y, button)
    LF.mousereleased(x, y, button)
end

function _state_MainMenu:textinput(text)
    LF.textinput(text)
end

function _state_MainMenu:update(dt)
    LF.update(dt)
end


------------------------------------------------
-- State Definition: _state_Settings
------------------------------------------------
function _state_Settings:draw()
    love.graphics.print("State: _state_Settings", 10, 10)
    love.graphics.print("Press ENTER to goto next screen", 10, 20)
end

function _state_Settings:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end
------------------------------------------------
-- State Definition: _state_Game
------------------------------------------------
function _state_Game:draw()
    love.graphics.print("State: _state_Game", 10, 10)
end

function _state_Game:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end
Thank you for your time.
User avatar
Nikolai Resokav
Party member
Posts: 140
Joined: Wed Apr 28, 2010 12:51 am
Location: United States

Re: Löve Frames - A GUI Library

Post by Nikolai Resokav »

Rishavs wrote:Kenny

Do you know if your library plays nice with HUMP? http://vrld.github.io/hump/
I think I am screwing up somewhere in trying to use both the libraries.
Here's my entire code

Code: Select all

------------------------------------------------
-- Modules
------------------------------------------------
Gamestate = require "modules.hump.gamestate"
LF = require "modules.loveframes"

------------------------------------------------
-- Declarations
------------------------------------------------
local _state_MainLoader = {} 
local _state_MainMenu = {} 
local _state_Settings = {} 
local _state_Game = {}

------------------------------------------------
-- Base functions
------------------------------------------------
function love.load()
    Gamestate.registerEvents()
    Gamestate.switch(_state_MainLoader)
end

function love.quit()

end

------------------------------------------------
-- State Definition: _state_MainLoader
------------------------------------------------

function _state_MainLoader:draw()
    love.graphics.print("State: _state_MainLoader", 10, 10)
    love.graphics.print("Press ENTER to goto next screen", 10, 20)
end

function _state_MainLoader:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end

------------------------------------------------
-- State Definition: _state_MainMenu
------------------------------------------------

function _state_MainMenu:draw()
    love.graphics.print("State: _state_MainMenu", 10, 10)
    
    bt_settings = LF.Create("button")
    bt_settings:SetSize(100, 50)
    bt_settings:SetText("Setting")
    bt_settings:CenterX()
    bt_settings:SetY(200)
    bt_settings.OnClick = function(object)
        Gamestate.switch(_state_Settings)
    end

    local bt_game = LF.Create("button")
    bt_game:SetSize(100, 50)
    bt_game:SetText("start")
    bt_game:CenterX()
    bt_game:SetY(300)
    bt_game.OnClick = function(object)
        Gamestate.switch(_state_Game)
    end
    
    local bt_quit = LF.Create("button")
    bt_quit:SetSize(100, 50)
    bt_quit:SetText("quit")
    bt_quit:CenterX()
    bt_quit:SetY(400)
    bt_quit.OnClick = function(object)
        Gamestate.switch(_state_Game)
    end
    
    
    LF.draw()
    
end

function _state_MainMenu:keypressed(key)
    LF.keypressed(key, unicode)
end

function _state_MainMenu:keyreleased(key)
    LF.keyreleased(key)
end

function _state_MainMenu:mousepressed(x, y, button)
    LF.mousepressed(x, y, button)

end

function _state_MainMenu:mousereleased(x, y, button)
    LF.mousereleased(x, y, button)
end

function _state_MainMenu:textinput(text)
    LF.textinput(text)
end

function _state_MainMenu:update(dt)
    LF.update(dt)
end


------------------------------------------------
-- State Definition: _state_Settings
------------------------------------------------
function _state_Settings:draw()
    love.graphics.print("State: _state_Settings", 10, 10)
    love.graphics.print("Press ENTER to goto next screen", 10, 20)
end

function _state_Settings:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end
------------------------------------------------
-- State Definition: _state_Game
------------------------------------------------
function _state_Game:draw()
    love.graphics.print("State: _state_Game", 10, 10)
end

function _state_Game:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(_state_MainMenu)
    end
end
Thank you for your time.
The only hump module that I've used with Love Frames is the camera module, but I don't know of any reason why Love Frames wouldn't work with the rest of hump. Is there a specific problem you are having?
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests