2012-05-06 00:24:42 +00:00
|
|
|
--[[------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
-- Love Frames - A GUI library for LOVE --
|
2014-01-14 11:29:11 +00:00
|
|
|
-- Copyright (c) 2012-2014 Kenny Shields --
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]------------------------------------------------
|
|
|
|
|
2014-10-23 22:36:16 +00:00
|
|
|
-- get the current require path
|
|
|
|
local path = string.sub(..., 1, string.len(...) - string.len(".objects.frame"))
|
|
|
|
local loveframes = require(path .. ".libraries.common")
|
|
|
|
|
2013-11-25 13:06:41 +00:00
|
|
|
-- frame object
|
2012-11-24 22:42:16 +00:00
|
|
|
local newobject = loveframes.NewObject("frame", "loveframes_object_frame", true)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: initialize()
|
|
|
|
- desc: initializes the object
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:initialize()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
self.type = "frame"
|
|
|
|
self.name = "Frame"
|
|
|
|
self.width = 300
|
|
|
|
self.height = 150
|
|
|
|
self.clickx = 0
|
|
|
|
self.clicky = 0
|
2013-08-12 13:48:51 +00:00
|
|
|
self.dockx = 0
|
|
|
|
self.docky = 0
|
|
|
|
self.dockzonesize = 10
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resizex = 0
|
|
|
|
self.resizey = 0
|
|
|
|
self.resizexmod = 0
|
|
|
|
self.resizeymod = 0
|
|
|
|
self.resizewidth = 0
|
|
|
|
self.resizeheight = 0
|
|
|
|
self.minwidth = 100
|
|
|
|
self.minheight = 30
|
|
|
|
self.maxwidth = 500
|
|
|
|
self.maxheight = 500
|
2012-12-28 12:19:02 +00:00
|
|
|
self.internal = false
|
|
|
|
self.draggable = true
|
|
|
|
self.screenlocked = false
|
|
|
|
self.parentlocked = false
|
|
|
|
self.dragging = false
|
|
|
|
self.modal = false
|
2012-12-10 14:19:35 +00:00
|
|
|
self.modalbackground = false
|
2012-12-28 12:19:02 +00:00
|
|
|
self.showclose = true
|
2013-08-12 13:48:51 +00:00
|
|
|
self.dockedtop = false
|
|
|
|
self.dockedbottom = false
|
|
|
|
self.dockedleft = false
|
|
|
|
self.dockedright = false
|
|
|
|
self.topdockobject = false
|
|
|
|
self.bottomdockobject = false
|
|
|
|
self.leftdockobject = false
|
|
|
|
self.rightdockobject = false
|
|
|
|
self.dockable = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resizing = false
|
|
|
|
self.canresize = false
|
2014-02-26 12:34:04 +00:00
|
|
|
self.alwaysontop = false
|
2012-12-28 12:19:02 +00:00
|
|
|
self.internals = {}
|
|
|
|
self.children = {}
|
2013-05-05 23:51:20 +00:00
|
|
|
self.icon = nil
|
2012-12-28 12:19:02 +00:00
|
|
|
self.OnClose = nil
|
2013-08-12 13:48:51 +00:00
|
|
|
self.OnDock = nil
|
2014-01-08 00:06:03 +00:00
|
|
|
self.OnResize = nil
|
2013-08-12 13:48:51 +00:00
|
|
|
|
|
|
|
-- create docking zones
|
2014-01-08 00:06:03 +00:00
|
|
|
self.dockzones = {
|
2013-08-12 13:48:51 +00:00
|
|
|
top = {x = 0, y = 0, width = 0, height = 0},
|
|
|
|
bottom = {x = 0, y = 0, width = 0, height = 0},
|
|
|
|
left = {x = 0, y = 0, width = 0, height = 0},
|
|
|
|
right = {x = 0, y = 0, width = 0, height = 0}
|
|
|
|
}
|
2012-09-29 23:20:41 +00:00
|
|
|
|
|
|
|
-- create the close button for the frame
|
2012-11-24 22:42:16 +00:00
|
|
|
local close = loveframes.objects["closebutton"]:new()
|
2012-05-06 00:24:42 +00:00
|
|
|
close.parent = self
|
2013-09-14 15:37:01 +00:00
|
|
|
close.OnClick = function(x, y, object)
|
|
|
|
local onclose = object.parent.OnClose
|
2012-09-29 23:20:41 +00:00
|
|
|
if onclose then
|
2014-04-14 15:52:06 +00:00
|
|
|
local ret = onclose(object.parent)
|
|
|
|
|
|
|
|
if ret ~= false then
|
|
|
|
object.parent:Remove()
|
|
|
|
end
|
|
|
|
else
|
|
|
|
object.parent:Remove()
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(self.internals, close)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: update(deltatime)
|
|
|
|
- desc: updates the element
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:update(dt)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local visible = self.visible
|
2012-05-22 07:10:18 +00:00
|
|
|
local alwaysupdate = self.alwaysupdate
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
|
|
|
if not alwaysupdate then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-12 13:48:51 +00:00
|
|
|
local mx, my = love.mouse.getPosition()
|
2012-12-28 12:19:02 +00:00
|
|
|
local showclose = self.showclose
|
|
|
|
local close = self.internals[1]
|
|
|
|
local dragging = self.dragging
|
|
|
|
local screenlocked = self.screenlocked
|
|
|
|
local parentlocked = self.parentlocked
|
|
|
|
local modal = self.modal
|
|
|
|
local base = loveframes.base
|
|
|
|
local basechildren = base.children
|
|
|
|
local numbasechildren = #basechildren
|
|
|
|
local draworder = self.draworder
|
2013-08-12 13:48:51 +00:00
|
|
|
local dockedtop = self.dockedtop
|
|
|
|
local dockedbottom = self.dockedbottom
|
|
|
|
local dockedleft = self.dockedleft
|
|
|
|
local dockedright = self.dockedright
|
|
|
|
local dockable = self.dockable
|
|
|
|
local dockzonesize = self.dockzonesize
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local internals = self.internals
|
|
|
|
local parent = self.parent
|
|
|
|
local update = self.Update
|
2012-09-02 00:56:32 +00:00
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
self:CheckHover()
|
|
|
|
|
2013-08-12 13:48:51 +00:00
|
|
|
-- update dockzones
|
|
|
|
self.dockzones.top = {x = self.x, y = self.y - dockzonesize, width = self.width, height = dockzonesize}
|
|
|
|
self.dockzones.bottom = {x = self.x, y = self.y + self.height, width = self.width, height = dockzonesize}
|
|
|
|
self.dockzones.left = {x = self.x - dockzonesize, y = self.y, width = dockzonesize, height = self.height}
|
|
|
|
self.dockzones.right = {x = self.x + self.width, y = self.y, width = dockzonesize, height = self.height}
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
-- dragging check
|
2012-09-29 23:20:41 +00:00
|
|
|
if dragging then
|
2012-10-22 14:19:02 +00:00
|
|
|
if parent == base then
|
2014-01-08 00:06:03 +00:00
|
|
|
local width = self.width
|
|
|
|
local height = self.height
|
2013-08-12 13:48:51 +00:00
|
|
|
if not dockedtop and not dockedbottom then
|
|
|
|
self.y = my - self.clicky
|
|
|
|
end
|
|
|
|
if not dockedleft and not dockedright then
|
|
|
|
self.x = mx - self.clickx
|
|
|
|
end
|
|
|
|
local basechildren = loveframes.base.children
|
|
|
|
-- check for frames to dock with
|
|
|
|
if dockable then
|
|
|
|
local ondock = self.OnDock
|
|
|
|
for k, v in ipairs(basechildren) do
|
|
|
|
if v.type == "frame" then
|
|
|
|
local topcol = loveframes.util.RectangleCollisionCheck(self.dockzones.bottom, v.dockzones.top)
|
|
|
|
local botcol = loveframes.util.RectangleCollisionCheck(self.dockzones.top, v.dockzones.bottom)
|
|
|
|
local leftcol = loveframes.util.RectangleCollisionCheck(self.dockzones.right, v.dockzones.left)
|
|
|
|
local rightcol = loveframes.util.RectangleCollisionCheck(self.dockzones.left, v.dockzones.right)
|
|
|
|
local candockobject = v.dockable
|
|
|
|
if candockobject then
|
|
|
|
if topcol and not dockedtop then
|
|
|
|
self.y = v.y - self.height
|
|
|
|
self.docky = my
|
|
|
|
self.dockedtop = true
|
|
|
|
self.topdockobject = v
|
|
|
|
if ondock then
|
|
|
|
ondock(object, v)
|
|
|
|
end
|
|
|
|
elseif botcol and not dockedbottom then
|
|
|
|
self.y = v.y + v.height
|
|
|
|
self.docky = my
|
|
|
|
self.dockedbottom = true
|
|
|
|
self.bottomdockobject = v
|
|
|
|
if ondock then
|
|
|
|
ondock(object, v)
|
|
|
|
end
|
|
|
|
elseif leftcol and not dockedleft then
|
|
|
|
self.x = v.x - self.width
|
|
|
|
self.dockx = mx
|
|
|
|
self.dockedleft = true
|
|
|
|
self.leftdockobject = v
|
|
|
|
if ondock then
|
|
|
|
ondock(object, v)
|
|
|
|
end
|
|
|
|
elseif rightcol and not dockedright then
|
|
|
|
self.x = v.x + v.width
|
|
|
|
self.dockx = mx
|
|
|
|
self.dockedright = true
|
|
|
|
self.rightdockobject = v
|
|
|
|
if ondock then
|
|
|
|
ondock(object, v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local dockx = self.dockx
|
|
|
|
local docky = self.docky
|
|
|
|
local x = self.x
|
|
|
|
local y = self.y
|
|
|
|
-- check to see if the frame should be undocked
|
|
|
|
if dockedtop then
|
|
|
|
local topdockobject = self.topdockobject
|
|
|
|
local tdox = topdockobject.x
|
|
|
|
local tdowidth = topdockobject.width
|
|
|
|
if my > (docky + 20) or my < (docky - 20) or (x + width) < tdox or x > (tdox + tdowidth) then
|
|
|
|
self.dockedtop = false
|
|
|
|
self.docky = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if dockedbottom then
|
|
|
|
local bottomdockobject = self.bottomdockobject
|
|
|
|
local bdox = bottomdockobject.x
|
|
|
|
local bdowidth = bottomdockobject.width
|
|
|
|
if my > (docky + 20) or my < (docky - 20) or (x + width) < bdox or x > (bdox + bdowidth) then
|
|
|
|
self.dockedbottom = false
|
|
|
|
self.docky = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if dockedleft then
|
|
|
|
local leftdockobject = self.leftdockobject
|
|
|
|
local ldoy = leftdockobject.y
|
|
|
|
local ldoheight = leftdockobject.height
|
|
|
|
if mx > (dockx + 20) or mx < (dockx - 20) or (y + height) < ldoy or y > (ldoy + ldoheight) then
|
|
|
|
self.dockedleft = false
|
|
|
|
self.dockx = 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if dockedright then
|
|
|
|
local rightdockobject = self.rightdockobject
|
|
|
|
local rdoy = rightdockobject.y
|
|
|
|
local rdoheight = rightdockobject.height
|
|
|
|
if mx > (dockx + 20) or mx < (dockx - 20) or (y + height) < rdoy or y > (rdoy + rdoheight) then
|
|
|
|
self.dockedright = false
|
|
|
|
self.dockx = 0
|
|
|
|
end
|
|
|
|
end
|
2012-11-24 22:42:16 +00:00
|
|
|
else
|
2013-08-12 13:48:51 +00:00
|
|
|
self.staticx = mx - self.clickx
|
|
|
|
self.staticy = my - self.clicky
|
2012-10-22 14:19:02 +00:00
|
|
|
end
|
2014-01-08 00:06:03 +00:00
|
|
|
elseif self.resizing then
|
|
|
|
local width = self.width
|
|
|
|
local height = self.height
|
|
|
|
if self.resize_mode == "top_left" then
|
|
|
|
local new_width = self.resizewidth + (self.resizex - mx)
|
|
|
|
local new_height = self.resizeheight + (self.resizey - my)
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
self.x = mx - self.resizexmod
|
|
|
|
end
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
self.y = my - self.resizeymod
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "bottom_right" then
|
|
|
|
local new_width = (mx - self.x) + self.resizexmod
|
|
|
|
local new_height = (my - self.y) + self.resizeymod
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
end
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "top_right" then
|
|
|
|
local new_width = (mx - self.x) + self.resizexmod
|
|
|
|
local new_height = self.resizeheight + (self.resizey - my)
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
end
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
self.y = my - self.resizeymod
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "bottom_left" then
|
|
|
|
local new_width = self.resizewidth + (self.resizex - mx)
|
|
|
|
local new_height = (my - self.y) + self.resizeymod
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
self.x = mx - self.resizexmod
|
|
|
|
end
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "top" then
|
|
|
|
local new_height = self.resizeheight + (self.resizey - my)
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
self.y = my - self.resizeymod
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "bottom" then
|
|
|
|
local new_height = (my - self.y) + self.resizeymod
|
|
|
|
if new_height >= self.minheight and new_height <= self.maxheight then
|
|
|
|
self.height = new_height
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "left" then
|
|
|
|
local new_width = self.resizewidth + (self.resizex - mx)
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
self.x = mx - self.resizexmod
|
|
|
|
end
|
|
|
|
elseif self.resize_mode == "right" then
|
|
|
|
local new_width = (mx - self.x) + self.resizexmod
|
|
|
|
if new_width >= self.minwidth and new_width <= self.maxwidth then
|
|
|
|
self.width = new_width
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if self.width ~= width or self.height ~= height then
|
|
|
|
local onresize = self.OnResize
|
|
|
|
if onresize then
|
|
|
|
onresize(self, self.width, self.height)
|
|
|
|
end
|
|
|
|
end
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- if screenlocked then keep within screen
|
2012-11-24 22:42:16 +00:00
|
|
|
if screenlocked then
|
2014-01-08 00:06:03 +00:00
|
|
|
local width = self.width
|
|
|
|
local height = self.height
|
2013-08-12 13:48:51 +00:00
|
|
|
local screenwidth = love.graphics.getWidth()
|
|
|
|
local screenheight = love.graphics.getHeight()
|
|
|
|
local x = self.x
|
|
|
|
local y = self.y
|
|
|
|
if x < 0 then
|
2012-05-06 00:24:42 +00:00
|
|
|
self.x = 0
|
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if x + width > screenwidth then
|
|
|
|
self.x = screenwidth - width
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if y < 0 then
|
2012-05-06 00:24:42 +00:00
|
|
|
self.y = 0
|
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if y + height > screenheight then
|
|
|
|
self.y = screenheight - height
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-12 13:48:51 +00:00
|
|
|
-- keep the frame within its parent's boundaries if parentlocked
|
2012-11-24 22:42:16 +00:00
|
|
|
if parentlocked then
|
2014-01-08 00:06:03 +00:00
|
|
|
local width = self.width
|
|
|
|
local height = self.height
|
2013-08-12 13:48:51 +00:00
|
|
|
local parentwidth = self.parent.width
|
|
|
|
local parentheight = self.parent.height
|
|
|
|
local staticx = self.staticx
|
|
|
|
local staticy = self.staticy
|
|
|
|
if staticx < 0 then
|
2012-11-24 22:42:16 +00:00
|
|
|
self.staticx = 0
|
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if staticx + width > parentwidth then
|
|
|
|
self.staticx = parentwidth - width
|
2012-11-24 22:42:16 +00:00
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if staticy < 0 then
|
2012-11-24 22:42:16 +00:00
|
|
|
self.staticy = 0
|
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if staticy + height > parentheight then
|
|
|
|
self.staticy = parentheight - height
|
2012-11-24 22:42:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-26 12:34:04 +00:00
|
|
|
if parent == base and self.alwaysontop and not self:IsTopChild() then
|
|
|
|
self:MakeTop()
|
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
if modal then
|
2012-09-02 00:56:32 +00:00
|
|
|
local tip = false
|
|
|
|
local key = 0
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(basechildren) do
|
2013-08-12 13:48:51 +00:00
|
|
|
if v.type == "tooltip" and v.show then
|
2012-09-02 00:56:32 +00:00
|
|
|
tip = v
|
|
|
|
key = k
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
end
|
2013-08-12 13:48:51 +00:00
|
|
|
if tip then
|
2012-09-02 00:56:32 +00:00
|
|
|
self:Remove()
|
|
|
|
self.modalbackground:Remove()
|
|
|
|
table.insert(basechildren, key - 2, self.modalbackground)
|
|
|
|
table.insert(basechildren, key - 1, self)
|
|
|
|
end
|
|
|
|
if self.modalbackground.draworder > self.draworder then
|
|
|
|
self:MakeTop()
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
2014-03-29 16:07:26 +00:00
|
|
|
if self.modalbackground.state ~= self.state then
|
|
|
|
self.modalbackground:SetState(self.state)
|
|
|
|
end
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
if parent ~= base then
|
|
|
|
self.x = self.parent.x + self.staticx
|
|
|
|
self.y = self.parent.y + self.staticy
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:update(dt)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:update(dt)
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if update then
|
|
|
|
update(self, dt)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: draw()
|
|
|
|
- desc: draws the object
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:draw()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local internals = self.internals
|
|
|
|
local skins = loveframes.skins.available
|
|
|
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
|
|
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
|
|
|
local selfskin = self.skin
|
|
|
|
local skin = skins[selfskin] or skins[skinindex]
|
|
|
|
local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame
|
|
|
|
local draw = self.Draw
|
|
|
|
local drawcount = loveframes.drawcount
|
2012-09-29 23:20:41 +00:00
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- set the object's draw order
|
|
|
|
self:SetDrawOrder()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if draw then
|
|
|
|
draw(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
else
|
2012-09-02 00:56:32 +00:00
|
|
|
drawfunc(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- loop through the object's children and draw them
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousepressed(x, y, button)
|
|
|
|
- desc: called when the player presses a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:mousepressed(x, y, button)
|
2013-02-11 21:15:40 +00:00
|
|
|
|
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-22 07:10:18 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local width = self.width
|
|
|
|
local height = self.height
|
2012-05-22 07:10:18 +00:00
|
|
|
local internals = self.internals
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local dragging = self.dragging
|
|
|
|
local parent = self.parent
|
|
|
|
local base = loveframes.base
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2015-10-31 13:40:19 +00:00
|
|
|
if button == 1 then
|
2012-05-06 00:24:42 +00:00
|
|
|
-- initiate dragging if not currently dragging
|
2014-02-26 12:37:03 +00:00
|
|
|
if not dragging and self.hover and self.draggable then
|
|
|
|
local topcol
|
|
|
|
if self.canresize then
|
|
|
|
topcol = loveframes.util.BoundingBox(x, self.x + 2, y, self.y + 2, 1, self.width - 4, 1, 21)
|
|
|
|
else
|
|
|
|
topcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, 25)
|
|
|
|
end
|
|
|
|
if topcol then
|
2012-11-24 22:42:16 +00:00
|
|
|
if parent == base then
|
|
|
|
self.clickx = x - self.x
|
|
|
|
self.clicky = y - self.y
|
|
|
|
else
|
|
|
|
self.clickx = x - self.staticx
|
|
|
|
self.clicky = y - self.staticy
|
|
|
|
end
|
2012-05-06 00:24:42 +00:00
|
|
|
self.dragging = true
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = self
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
end
|
2014-09-28 19:17:13 +00:00
|
|
|
if not self.resizing and self.canresize and loveframes.hoverobject == self then
|
2014-01-08 00:06:03 +00:00
|
|
|
if loveframes.util.BoundingBox(self.x, x, self.y, y, 5, 1, 5, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "top_left"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x then
|
|
|
|
self.resizexmod = x - self.x
|
|
|
|
end
|
|
|
|
if y ~= self.y then
|
|
|
|
self.resizeymod = y - self.y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x + self.width - 5, x, self.y + self.height - 5, y, 5, 1, 5, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.resize_mode = "bottom_right"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x + self.width then
|
|
|
|
self.resizexmod = (self.x + self.width) - x
|
|
|
|
end
|
|
|
|
if y ~= self.y + self.height then
|
|
|
|
self.resizeymod = (self.y + self.height) - y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x + self.width - 5, x, self.y, y, 5, 1, 5, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "top_right"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x + self.width then
|
|
|
|
self.resizexmod = (self.x + self.width) - x
|
|
|
|
end
|
|
|
|
if y ~= self.y then
|
|
|
|
self.resizeymod = y - self.y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x, x, self.y + self.height - 5, y, 5, 1, 5, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "bottom_left"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x then
|
|
|
|
self.resizexmod = x - self.x
|
|
|
|
end
|
|
|
|
if y ~= self.y + self.height then
|
|
|
|
self.resizeymod = (self.y + self.height) - y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x + 5, x, self.y, y, self.width - 10, 1, 2, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "top"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if y ~= self.y then
|
|
|
|
self.resizeymod = y - self.y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x + 5, x, self.y + self.height - 2, y, self.width - 10, 1, 2, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "bottom"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if y ~= self.y then
|
|
|
|
self.resizeymod = (self.y + self.height) - y
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x, x, self.y + 5, y, 2, 1, self.height - 10, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "left"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x then
|
|
|
|
self.resizexmod = x - self.x
|
|
|
|
end
|
|
|
|
elseif loveframes.util.BoundingBox(self.x + self.width - 2, x, self.y + 5, y, 2, 1, self.height - 10, 1) then
|
|
|
|
self.resizing = true
|
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
self.resize_mode = "right"
|
|
|
|
self.resizex = x
|
|
|
|
self.resizey = y
|
|
|
|
self.resizewidth = self.width
|
|
|
|
self.resizeheight = self.height
|
|
|
|
loveframes.resizeobject = self
|
|
|
|
if x ~= self.x + self.width then
|
|
|
|
self.resizexmod = (self.x + self.width) - x
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-10-31 13:40:19 +00:00
|
|
|
if self.hover and button == 1 then
|
2012-05-06 00:24:42 +00:00
|
|
|
self:MakeTop()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousepressed(x, y, button)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousepressed(x, y, button)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousereleased(x, y, button)
|
|
|
|
- desc: called when the player releases a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:mousereleased(x, y, button)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
2012-05-22 07:10:18 +00:00
|
|
|
local internals = self.internals
|
|
|
|
|
2014-01-08 00:06:03 +00:00
|
|
|
self.dragging = false
|
2014-11-01 18:27:21 +00:00
|
|
|
loveframes.dragobject = false
|
2014-01-08 00:06:03 +00:00
|
|
|
|
|
|
|
if self.resizing then
|
|
|
|
self.resizex = 0
|
|
|
|
self.resizey = 0
|
|
|
|
self.resizexmod = 0
|
|
|
|
self.resizeymod = 0
|
|
|
|
self.resizewidth = 0
|
|
|
|
self.resizeheight = 0
|
|
|
|
self.resizing = false
|
|
|
|
loveframes.resizeobject = false
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousereleased(x, y, button)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousereleased(x, y, button)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetName(name)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets the object's name
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetName(name)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.name = name
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetName()
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: gets the object's name
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetName()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetDraggable(true/false)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets whether the object can be dragged or not
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetDraggable(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.draggable = bool
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetDraggable()
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: gets whether the object can be dragged ot not
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetDraggable()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.draggable
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetScreenLocked(bool)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets whether the object can be moved passed the
|
2012-05-06 00:24:42 +00:00
|
|
|
boundaries of the window or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetScreenLocked(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.screenlocked = bool
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetScreenLocked()
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: gets whether the object can be moved passed the
|
2012-05-06 00:24:42 +00:00
|
|
|
boundaries of window or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetScreenLocked()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.screenlocked
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: ShowCloseButton(bool)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets whether the object's close button should
|
|
|
|
be drawn
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:ShowCloseButton(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
local close = self.internals[1]
|
|
|
|
|
|
|
|
close.visible = bool
|
2012-05-15 02:47:38 +00:00
|
|
|
self.showclose = bool
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2012-05-15 02:47:38 +00:00
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: MakeTop()
|
|
|
|
- desc: makes the object the top object in the drawing
|
|
|
|
order
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:MakeTop()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local key = 0
|
2014-05-02 21:14:45 +00:00
|
|
|
local base = loveframes.base
|
2012-12-28 12:19:02 +00:00
|
|
|
local basechildren = base.children
|
2012-05-22 07:10:18 +00:00
|
|
|
local numbasechildren = #basechildren
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- check to see if the object's parent is not the base object
|
2014-05-02 21:14:45 +00:00
|
|
|
if self.parent ~= base then
|
2012-10-22 14:19:02 +00:00
|
|
|
local baseparent = self:GetBaseParent()
|
|
|
|
if baseparent.type == "frame" then
|
|
|
|
baseparent:MakeTop()
|
|
|
|
end
|
2014-04-16 15:14:34 +00:00
|
|
|
return self
|
2012-10-22 14:19:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- check to see if the object is the only child of the base object
|
2012-05-22 07:10:18 +00:00
|
|
|
if numbasechildren == 1 then
|
2014-04-16 15:14:34 +00:00
|
|
|
return self
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- check to see if the object is already at the top
|
2012-05-22 07:10:18 +00:00
|
|
|
if basechildren[numbasechildren] == self then
|
2014-04-16 15:14:34 +00:00
|
|
|
return self
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
-- make this the top object
|
|
|
|
for k, v in ipairs(basechildren) do
|
2012-05-06 00:24:42 +00:00
|
|
|
if v == self then
|
2012-05-22 07:10:18 +00:00
|
|
|
table.remove(basechildren, k)
|
|
|
|
table.insert(basechildren, self)
|
2012-05-06 00:24:42 +00:00
|
|
|
key = k
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetModal(bool)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets whether or not the object is in a modal
|
|
|
|
state
|
2012-05-15 02:47:38 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetModal(bool)
|
2012-05-15 02:47:38 +00:00
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local modalobject = loveframes.modalobject
|
|
|
|
local mbackground = self.modalbackground
|
2012-12-28 12:19:02 +00:00
|
|
|
local parent = self.parent
|
|
|
|
local base = loveframes.base
|
2012-10-22 14:19:02 +00:00
|
|
|
|
|
|
|
if parent ~= base then
|
|
|
|
return
|
|
|
|
end
|
2012-05-22 07:10:18 +00:00
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modal = bool
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if bool then
|
|
|
|
if modalobject then
|
2012-05-22 07:10:18 +00:00
|
|
|
modalobject:SetModal(false)
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
loveframes.modalobject = self
|
2012-09-29 23:20:41 +00:00
|
|
|
if not mbackground then
|
2012-11-24 22:42:16 +00:00
|
|
|
self.modalbackground = loveframes.objects["modalbackground"]:new(self)
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modal = true
|
|
|
|
end
|
|
|
|
else
|
2012-05-22 07:10:18 +00:00
|
|
|
if modalobject == self then
|
2012-05-15 02:47:38 +00:00
|
|
|
loveframes.modalobject = false
|
2012-09-29 23:20:41 +00:00
|
|
|
if mbackground then
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modalbackground:Remove()
|
|
|
|
self.modalbackground = false
|
|
|
|
self.modal = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetModal()
|
|
|
|
- desc: gets whether or not the object is in a modal
|
|
|
|
state
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetModal()
|
2012-05-15 02:47:38 +00:00
|
|
|
|
|
|
|
return self.modal
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetVisible(bool)
|
|
|
|
- desc: set's whether the object is visible or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetVisible(bool)
|
2012-05-15 02:47:38 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local internals = self.internals
|
2012-05-22 07:10:18 +00:00
|
|
|
local closebutton = internals[1]
|
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
self.visible = bool
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-15 02:47:38 +00:00
|
|
|
v:SetVisible(bool)
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.showclose then
|
2012-05-27 16:58:37 +00:00
|
|
|
closebutton.visible = bool
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
|
|
|
|
2012-11-24 22:42:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetParentLocked(bool)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: sets whether the object can be moved passed the
|
2013-03-23 19:50:44 +00:00
|
|
|
boundaries of its parent or not
|
2012-11-24 22:42:16 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetParentLocked(bool)
|
|
|
|
|
|
|
|
self.parentlocked = bool
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2012-11-24 22:42:16 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetParentLocked(bool)
|
2013-11-25 13:06:41 +00:00
|
|
|
- desc: gets whether the object can be moved passed the
|
2013-03-23 19:50:44 +00:00
|
|
|
boundaries of its parent or not
|
2012-11-24 22:42:16 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetParentLocked()
|
|
|
|
|
|
|
|
return self.parentlocked
|
|
|
|
|
2013-05-05 23:51:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetIcon(icon)
|
|
|
|
- desc: sets the object's icon
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetIcon(icon)
|
|
|
|
|
|
|
|
if type(icon) == "string" then
|
|
|
|
self.icon = love.graphics.newImage(icon)
|
|
|
|
else
|
|
|
|
self.icon = icon
|
|
|
|
end
|
|
|
|
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
|
|
|
|
2013-05-05 23:51:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetIcon()
|
|
|
|
- desc: gets the object's icon
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetIcon()
|
|
|
|
|
|
|
|
local icon = self.icon
|
|
|
|
|
|
|
|
if icon then
|
|
|
|
return icon
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
2013-08-12 13:48:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetDockable(dockable)
|
|
|
|
- desc: sets whether or not the object can dock onto
|
2013-11-25 13:06:41 +00:00
|
|
|
another object of its type or be docked
|
|
|
|
by another object of its type
|
2013-08-12 13:48:51 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetDockable(dockable)
|
|
|
|
|
|
|
|
self.dockable = dockable
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2013-08-12 13:48:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetDockable()
|
|
|
|
- desc: gets whether or not the object can dock onto
|
2013-11-25 13:06:41 +00:00
|
|
|
another object of its type or be docked
|
|
|
|
by another object of its type
|
2013-08-12 13:48:51 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetDockable()
|
|
|
|
|
|
|
|
return self.dockable
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetDockZoneSize(size)
|
|
|
|
- desc: sets the size of the object's docking zone
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetDockZoneSize(size)
|
|
|
|
|
|
|
|
self.dockzonesize = size
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2013-08-12 13:48:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetDockZoneSize(size)
|
|
|
|
- desc: gets the size of the object's docking zone
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetDockZoneSize()
|
|
|
|
|
|
|
|
return self.dockzonesize
|
|
|
|
|
2014-01-08 00:33:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetResizable(bool)
|
|
|
|
- desc: sets whether or not the object can be resized
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetResizable(bool)
|
|
|
|
|
|
|
|
self.canresize = bool
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2014-01-08 00:33:30 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetResizable()
|
|
|
|
- desc: gets whether or not the object can be resized
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetResizable()
|
|
|
|
|
|
|
|
return self.canresize
|
|
|
|
|
2014-01-08 01:06:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMinWidth(width)
|
|
|
|
- desc: sets the object's minimum width
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMinWidth(width)
|
|
|
|
|
|
|
|
self.minwidth = width
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2014-01-08 01:06:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMinWidth()
|
|
|
|
- desc: gets the object's minimum width
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMinWidth()
|
|
|
|
|
|
|
|
return self.minwidth
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMaxWidth(width)
|
|
|
|
- desc: sets the object's maximum width
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMaxWidth(width)
|
|
|
|
|
|
|
|
self.maxwidth = width
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2014-01-08 01:06:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMaxWidth()
|
|
|
|
- desc: gets the object's maximum width
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMaxWidth()
|
|
|
|
|
|
|
|
return self.maxwidth
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMinHeight(height)
|
|
|
|
- desc: sets the object's minimum height
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMinHeight(height)
|
|
|
|
|
|
|
|
self.minheight = height
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2014-01-08 01:06:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMinHeight()
|
|
|
|
- desc: gets the object's minimum height
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMinHeight()
|
|
|
|
|
|
|
|
return self.minheight
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMaxHeight(height)
|
|
|
|
- desc: sets the object's maximum height
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMaxHeight(height)
|
|
|
|
|
|
|
|
self.maxheight = height
|
2014-02-11 12:34:07 +00:00
|
|
|
return self
|
2014-01-08 01:06:51 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMaxHeight()
|
|
|
|
- desc: gets the object's maximum height
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMaxHeight()
|
|
|
|
|
|
|
|
return self.maxheight
|
|
|
|
|
2014-02-26 12:34:04 +00:00
|
|
|
end
|
|
|
|
|
2014-09-13 15:55:41 +00:00
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMinSize(width, height)
|
|
|
|
- desc: sets the object's minimum size
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMinSize(width, height)
|
|
|
|
|
|
|
|
self.minwidth = width
|
|
|
|
self.minheight = height
|
|
|
|
return self
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMinSize()
|
|
|
|
- desc: gets the object's minimum size
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMinSize()
|
|
|
|
|
|
|
|
return self.minwidth, self.maxwidth
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-09-13 15:57:21 +00:00
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetMaxSize(width, height)
|
|
|
|
- desc: sets the object's maximum size
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetMaxSize(width, height)
|
|
|
|
|
|
|
|
self.maxwidth = width
|
|
|
|
self.maxheight = height
|
|
|
|
return self
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetMaxSize()
|
|
|
|
- desc: gets the object's maximum size
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetMaxSize()
|
|
|
|
|
|
|
|
return self.maxwidth, self.maxheight
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-02-26 12:34:04 +00:00
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetAlwaysOnTop(bool)
|
|
|
|
- desc: sets whether or not a frame should always be
|
|
|
|
drawn on top of other objects
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetAlwaysOnTop(bool)
|
|
|
|
|
|
|
|
self.alwaysontop = bool
|
|
|
|
return self
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetAlwaysOnTop()
|
|
|
|
- desc: gets whether or not a frame should always be
|
|
|
|
drawn on top of other objects
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetAlwaysOnTop()
|
|
|
|
|
|
|
|
return self.alwaysontop
|
|
|
|
|
2014-04-16 15:14:34 +00:00
|
|
|
end
|