2012-05-06 00:24:42 +00:00
|
|
|
--[[------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
-- Love Frames - A GUI library for LOVE --
|
|
|
|
-- Copyright (c) 2012 Kenny Shields --
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]------------------------------------------------
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
-- columnlistrow class
|
2012-05-06 00:24:42 +00:00
|
|
|
columnlistrow = class("columnlistrow", base)
|
|
|
|
columnlistrow:include(loveframes.templates.default)
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: initialize()
|
|
|
|
- desc: intializes the element
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:initialize(parent, data)
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
self.type = "columnlistrow"
|
|
|
|
self.parent = parent
|
|
|
|
self.colorindex = self.parent.rowcolorindex
|
|
|
|
self.font = loveframes.basicfontsmall
|
|
|
|
self.width = 80
|
|
|
|
self.height = 25
|
|
|
|
self.textx = 5
|
|
|
|
self.texty = 5
|
|
|
|
self.internal = true
|
|
|
|
self.columndata = data
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: update(deltatime)
|
|
|
|
- desc: updates the object
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:update(dt)
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
local visible = self.visible
|
2012-05-22 07:10:18 +00:00
|
|
|
local alwaysupdate = self.alwaysupdate
|
|
|
|
|
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
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
local parent = self.parent
|
|
|
|
local base = loveframes.base
|
|
|
|
local update = self.Update
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
self:CheckHover()
|
|
|
|
|
|
|
|
-- move to parent if there is a parent
|
2012-09-29 23:20:41 +00:00
|
|
|
if parent ~= base then
|
|
|
|
self.x = parent.x + self.staticx
|
|
|
|
self.y = parent.y + self.staticy
|
2012-05-06 00:24:42 +00:00
|
|
|
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
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:draw()
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
|
|
|
if visible == false then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
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.DrawColumnListRow or skins[defaultskin].DrawColumnListRow
|
|
|
|
local draw = self.Draw
|
|
|
|
local drawcount = loveframes.drawcount
|
|
|
|
|
|
|
|
loveframes.drawcount = drawcount + 1
|
2012-05-06 00:24:42 +00:00
|
|
|
self.draworder = loveframes.drawcount
|
2012-09-02 00:56:32 +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-06 03:35:10 +00:00
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousepressed(x, y, button)
|
|
|
|
- desc: called when the player presses a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:mousepressed(x, y, button)
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not self.visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.hover and button == "l" then
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
local baseparent = self:GetBaseParent()
|
|
|
|
|
|
|
|
if baseparent and baseparent.type == "frame" then
|
|
|
|
baseparent:MakeTop()
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousereleased(x, y, button)
|
|
|
|
- desc: called when the player releases a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:mousereleased(x, y, button)
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not self.visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.hover and button == "l" then
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
local parent1 = self:GetParent()
|
|
|
|
local parent2 = parent1:GetParent()
|
|
|
|
local onrowclicked = parent2.OnRowClicked
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if onrowclicked then
|
|
|
|
onrowclicked(parent2, self, self.columndata)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
2012-05-08 21:48:39 +00:00
|
|
|
- func: SetTextPos(x, y)
|
|
|
|
- desc: sets the positions of the object's text
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-05-08 21:48:39 +00:00
|
|
|
function columnlistrow:SetTextPos(x, y)
|
|
|
|
|
|
|
|
self.textx = x
|
|
|
|
self.texty = y
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetTextX()
|
|
|
|
- desc: gets the object's text x position
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:GetTextX()
|
|
|
|
|
|
|
|
return self.textx
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetTextY()
|
|
|
|
- desc: gets the object's text y position
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:GetTextY()
|
|
|
|
|
|
|
|
return self.texty
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
--[[---------------------------------------------------------
|
2012-05-08 21:48:39 +00:00
|
|
|
- func: SetFont(font)
|
|
|
|
- desc: sets the object's font
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-05-08 21:48:39 +00:00
|
|
|
function columnlistrow:SetFont(font)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-05-08 21:48:39 +00:00
|
|
|
self.font = font
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetFont()
|
|
|
|
- desc: gets the object's font
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:GetFont()
|
|
|
|
|
|
|
|
return self.font
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetColorIndex()
|
|
|
|
- desc: gets the object's color index
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function columnlistrow:GetColorIndex()
|
|
|
|
|
|
|
|
return self.colorindex
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
- func: GetColumnData()
|
|
|
|
- desc: gets the object's column data
|
2012-05-08 21:48:39 +00:00
|
|
|
--]]---------------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
function columnlistrow:GetColumnData()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
return self.columndata
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|