Löve Frames - A GUI Library
Re: Löve Frames - A GUI Library
is there anyway to check if a frame is closed?
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
You can use the frame.OnClose callback to detect when a frame is closed.Doctory wrote:is there anyway to check if a frame is closed?
Re: Löve Frames - A GUI Library
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
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
Not currently, though I'd like to add something like that in the future.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
Re: Löve Frames - A GUI Library
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?
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?
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
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: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.
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.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?
Re: Löve Frames - A GUI Library
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.
But doing this throws an exception:
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!")
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")
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
You should create your event callbacks like this instead: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.But doing this throws an exception:Code: Select all
button:SetSize(200, 100):SetText("Button"):Center() button.OnClick = button:SetText("You clicked the button!")
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")
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
Re: Löve Frames - A GUI Library
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
Thank you for your time.
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
- Nikolai Resokav
- Party member
- Posts: 140
- Joined: Wed Apr 28, 2010 12:51 am
- Location: United States
Re: Löve Frames - A GUI Library
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?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
Thank you for your time.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
Who is online
Users browsing this forum: No registered users and 0 guests