-
Notifications
You must be signed in to change notification settings - Fork 15
(API) Frame
The frame object is a mouse-moveable object meant to serve as a base parent for other objects. It has a close button and can have a custom name. It also has a docking functionality that lets it dock onto other frame objects when being moved with the mouse.
function love.load()
loveframes = require("loveframes")
local frame = loveframes.Create("frame")
frame:SetName("Frame")
frame:CenterWithinArea(0, 0, love.graphics.getDimensions())
frame:SetDockable(true)
local text = loveframes.Create("text", frame)
text:SetText("This is an example frame.")
text.Update = function(object, dt)
object:CenterX()
object:SetY(40)
end
local button = loveframes.Create("button", frame)
button:SetText("Modal")
button:SetWidth(100)
button:Center()
button.Update = function(object, dt)
local modal = object:GetParent():GetModal()
if modal then
object:SetText("Remove Modal")
object.OnClick = function()
object:GetParent():SetModal(false)
end
else
object:SetText("Set Modal")
object.OnClick = function()
object:GetParent():SetModal(true)
end
end
end
end
function love.update(dt)
loveframes.update(dt)
end
function love.draw()
loveframes.draw()
end
function love.mousepressed(x, y, button)
loveframes.mousepressed(x, y, button)
end
function love.mousereleased(x, y, button)
loveframes.mousereleased(x, y, button)
end
Called when the object is closed via it's close button
Arguments passed: self [object]
local frame = loveframes.Create("frame")
frame.OnClose = function(object)
print("The frame was closed.")
end
Called when the object docks onto another frame
Arguments passed: self [object], dock_object [object]
local frame = loveframes.Create("frame")
frame.OnDock = function(object, dock_object)
print("Frame " ..object:GetName().. " has dock onto frame " ..dock_object:GetName().. ".")
end
Sets the object's name
object:SetName(name[string])
Gets the object's name
Returns 1 value: object name [string]
local name = object:GetName()
Sets whether the object can be dragged or not
object:SetDraggable(draggable[boolean])
Gets whether the object can be dragged or not
Returns 1 value: draggable [boolean]
local draggable = object:GetDraggable()
Sets whether the frame can be moved passed the boundaries of the window or not
object:SetScreenLocked(screenlocked[boolean])
Gets whether the frame can be moved passed the boundaries of the window or not
Returns 1 value: screen locked [boolean]
local screenlocked = object:GetScreenLocked()
Sets whether the object's close button should be drawn and clickable or not
object:ShowCloseButton(show[boolean])
Makes the object the top most object
object:MakeTop()
Used to modal or unmodal the object
object:SetModal(modal[boolean])
Gets whether the object can is modaled or not
Returns 1 value: modaled [boolean]
local modal = object:GetModal()
Sets whether the object can or cannot be dragged outside of it's parent's boundaries
object:SetParentLocked(parentlocked[boolean])
Gets whether the object can or cannot be dragged outside of it's parent's boundaries
Returns 1 value: parent locked [boolean]
local parentlocked = object:GetParentLocked()
Sets the object's icon
object:SetIcon(icon[string] or icon[image])
Gets the object's icon
Returns 1 value: icon [image]
local icon = object:GetIcon()
Sets whether or not the object can dock onto other frames or be docked by other frames
object:SetDockable(dockable[bool])
Gets whether or not the object is dockable
Returns 1 value: dockable [bool]
local dockable = object:GetDockable()
Sets the size of the object's dock zone
object:SetDockZoneSize(size[number])