Version 0.9.3.2 - Alpha (see changelog.txt)

This commit is contained in:
Kenny Shields 2012-09-29 19:20:41 -04:00
parent d6190b4757
commit 0e327e5d01
41 changed files with 5041 additions and 2770 deletions

View File

@ -1,3 +1,65 @@
================================================
Version 0.9.3.2 - Alpha (Spetember 29 - 2012)
================================================
[ADDED] a new text input method: SetMultiline(bool)
[ADDED] a new text input method: GetVerticalScrollBody()
[ADDED] a new text input method: GetHorizontalScrollBody()
[ADDED] a new text input method: SetText(text)
[ADDED] a new text input method: HasVerticalScrollBar()
[ADDED] a new text input method: HasHorizontalScrollBar()
[ADDED] a new text input method: GetFont()
[ADDED] a new text input method: GetTextColor()
[ADDED] a new text input method: GetLineNumbersPanel()
[ADDED] a new text input method: GetMultiline()
[ADDED] a new text input method: GetTextX()
[ADDED] a new text input method: GetTextY()
[ADDED] a new text input method: IsAllTextSelected()
[ADDED] a new text input method: GetLines()
[ADDED] a new text input method: GetOffsetX()
[ADDED] a new text input method: GetOffsetY()
[ADDED] a new text input method: GetIndicatorX()
[ADDED] a new text input method: GetIndicatorY()
[ADDED] a new text input method: GetLineNumbersEnabled()
[ADDED] a new text input method: GetItemWidth()
[ADDED] a new text input method: GetItemHeight()
[ADDED] a new text input method: SetTabReplacement(tabreplacement)
[ADDED] a new text input method: GetTabReplacement()
[ADDED] a new scroll area method: GetBarType()
[ADDED] a new scroll bar method: IsDragging()
[ADDED] a new scroll bar method: GetBarType()
[ADDED] a new scroll button method: GetScrollType()
[ADDED] a new tab button method: GetText()
[ADDED] a new tab button method: GetImage()
[ADDED] a new tab button method: GetTabNumber()
[ADDED] a new column list header method: GetName()
[ADDED] a new column list row method: GetColumnData()
[ADDED] a new multichoice method: SetText(text)
[ADDED] a new multichoice method: GetText()
[ADDED] a new multichoice row method: GetText()
[ADDED] a new progressbar method: GetBarWidth()
[ADDED] a new internal object: linenumberspanel
[ADDED] multiline support for the text input object
[ADDED] ability to select all text within a text input
[FIXED] progressbar object not positioning itself properly if it's parent was the base object
[FIXED] a typeo in the syntax of loveframes.util.SplitString (was "SplitSring", changed to "SplitString")
[FIXED] the tooltip object not disapearing if it was visible when it's object's visibility was changed to false
[FIXED] the text input object's x offset not being adjusted initially when the width of it's text would would become wider than it's drawing area
[CHANGED] massive code cleanup for optimization and
[CHANGED] frames can now be parent to other objects
[CHANGED] textinput:RunBlink() to textinput:UpdateIndicator()
[CHANGED] textinput:GetBlinkerVisisbility() to textinput:GetIndicatorVisisbility()
[CHANGED] textinput:MoveBlinker(num, exact) to textinput:MoveIndicator(num, exact)
[CHANGED] scrollbars now only autoscroll when their list's item width/height is greater thant their previous list's previous item width/height
[CHANGED] cleaned up the code for the default skins
[CHANGED] the text input object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[CHANGED] the column list row object's text is no longer drawn internally by the object and should now be draw within the object's skin drawing function
[REMOVED] textinput:SetTextColor(color)
[REMOVED] textinput:GetTextColor()
[REMOVED] columnlistrow:SetTextColor()
================================================ ================================================
Version 0.9.3.1 - Alpha (Spetember 2 - 2012) Version 0.9.3.1 - Alpha (Spetember 2 - 2012)
================================================ ================================================

View File

@ -1,12 +1,13 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- debug library -- debug library
loveframes.debug = {} loveframes.debug = {}
local font = love.graphics.newFont(10) local font = love.graphics.newFont(10)
local changelog, size = love.filesystem.read("libraries/loveframes/changelog.txt")
local loremipsum = local loremipsum =
[[ [[
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dui enim, porta eget facilisis quis, laoreet sit amet urna. Maecenas lobortis venenatis euismod. Sed at diam sit amet odio feugiat pretium nec quis libero. Quisque auctor semper imperdiet. Maecenas risus eros, varius pharetra volutpat in, fermentum scelerisque lacus. Proin lectus erat, luctus non facilisis vel, hendrerit vitae nisl. Aliquam vulputate scelerisque odio id faucibus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin dui enim, porta eget facilisis quis, laoreet sit amet urna. Maecenas lobortis venenatis euismod. Sed at diam sit amet odio feugiat pretium nec quis libero. Quisque auctor semper imperdiet. Maecenas risus eros, varius pharetra volutpat in, fermentum scelerisque lacus. Proin lectus erat, luctus non facilisis vel, hendrerit vitae nisl. Aliquam vulputate scelerisque odio id faucibus.
@ -23,7 +24,7 @@ function loveframes.debug.draw()
local debug = loveframes.config["DEBUG"] local debug = loveframes.config["DEBUG"]
-- do not draw anthing if debug is off -- do not draw anthing if debug is off
if debug == false then if not debug then
return return
end end
@ -38,7 +39,6 @@ function loveframes.debug.draw()
local fps = love.timer.getFPS() local fps = love.timer.getFPS()
local deltatime = love.timer.getDelta() local deltatime = love.timer.getDelta()
-- font for debug text -- font for debug text
love.graphics.setFont(font) love.graphics.setFont(font)
@ -608,15 +608,40 @@ function loveframes.debug.ExamplesMenu()
local frame1 = loveframes.Create("frame") local frame1 = loveframes.Create("frame")
frame1:SetName("Text Input") frame1:SetName("Text Input")
frame1:SetSize(500, 60) frame1:SetSize(500, 90)
frame1:Center() frame1:Center()
local textinput1 = loveframes.Create("textinput", frame1) local textinput1 = loveframes.Create("textinput", frame1)
textinput1:SetPos(5, 30) textinput1:SetPos(5, 30)
textinput1:SetWidth(490) textinput1:SetWidth(490)
textinput1.OnEnter = function(object) textinput1.OnEnter = function(object)
if not textinput1.multiline then
object:Clear() object:Clear()
end end
end
textinput1:SetFont(love.graphics.newFont(12))
local togglebutton = loveframes.Create("button", frame1)
togglebutton:SetPos(5, 60)
togglebutton:SetWidth(490)
togglebutton:SetText("Toggle Multiline")
togglebutton.OnClick = function(object)
if textinput1.multiline then
frame1:SetHeight(90)
frame1:Center()
togglebutton:SetPos(5, 60)
textinput1:SetMultiline(false)
textinput1:SetHeight(25)
textinput1:SetText("")
else
frame1:SetHeight(365)
frame1:Center()
togglebutton:SetPos(5, 335)
textinput1:SetMultiline(true)
textinput1:SetHeight(300)
textinput1:SetText(changelog)
end
end
end end
exampleslist:AddItem(textinputexample) exampleslist:AddItem(textinputexample)

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- central library table -- central library table
@ -9,7 +9,7 @@ loveframes = {}
-- library info -- library info
loveframes.info = {} loveframes.info = {}
loveframes.info.author = "Nikolai Resokav" loveframes.info.author = "Nikolai Resokav"
loveframes.info.version = "0.9.3.1" loveframes.info.version = "0.9.3.2"
loveframes.info.stage = "Alpha" loveframes.info.stage = "Alpha"
-- library configurations -- library configurations
@ -36,7 +36,7 @@ function loveframes.load()
local dir = loveframes.config["DIRECTORY"] local dir = loveframes.config["DIRECTORY"]
-- require the internal base libraries -- require the internal base libraries
require(dir .. "/third-party/middleclass/middleclass") require(dir .. "/third-party/middleclass")
require(dir .. "/util") require(dir .. "/util")
require(dir .. "/skins") require(dir .. "/skins")
require(dir .. "/templates") require(dir .. "/templates")
@ -172,7 +172,7 @@ function loveframes.Create(data, parent)
end end
-- remove the object if it is an internal -- remove the object if it is an internal
if object.internal == true then if object.internal then
object:Remove() object:Remove()
return return
end end
@ -182,7 +182,7 @@ function loveframes.Create(data, parent)
table.insert(loveframes.base.children, object) table.insert(loveframes.base.children, object)
-- if the parent argument is not nil, make that argument the object's new parent -- if the parent argument is not nil, make that argument the object's new parent
if parent ~= nil then if parent then
object:SetParent(parent) object:SetParent(parent)
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- base object -- base object
@ -74,7 +74,7 @@ function base:mousepressed(x, y, button)
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
if visible == false then if not visible then
return return
end end
@ -102,7 +102,7 @@ function base:mousereleased(x, y, button)
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
if visible == false then if not visible then
return return
end end
@ -130,7 +130,7 @@ function base:keypressed(key, unicode)
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
if visible == false then if not visible then
return return
end end
@ -158,7 +158,7 @@ function base:keyreleased(key)
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
if visible == false then if not visible then
return return
end end
@ -466,10 +466,6 @@ function base:SetParent(parent)
return return
end end
if stype == "frame" then
return
end
self:Remove() self:Remove()
self.parent = tparent self.parent = tparent
@ -498,23 +494,19 @@ function base:Remove()
local pchildren = self.parent.children local pchildren = self.parent.children
if pinternals then if pinternals then
for k, v in ipairs(pinternals) do for k, v in ipairs(pinternals) do
if v == self then if v == self then
table.remove(pinternals, k) table.remove(pinternals, k)
end end
end end
end end
if pchildren then if pchildren then
for k, v in ipairs(pchildren) do for k, v in ipairs(pchildren) do
if v == self then if v == self then
table.remove(pchildren, k) table.remove(pchildren, k)
end end
end end
end end
self.removed = true self.removed = true
@ -658,12 +650,12 @@ function base:CheckHover()
local clickbounds = self.clickbounds local clickbounds = self.clickbounds
-- is the mouse inside the object? -- is the mouse inside the object?
if selfcol == true then if selfcol then
local top = self:IsTopCollision() local top = self:IsTopCollision()
if top == true then if top then
if hoverobject == false then if not hoverobject then
self.hover = true self.hover = true
else else
if hoverobject == self then if hoverobject == self then
@ -677,7 +669,7 @@ function base:CheckHover()
end end
if clickbounds then if clickbounds then
if self:InClickBounds() == false then if not self:InClickBounds() then
self.hover = false self.hover = false
end end
end end
@ -688,7 +680,7 @@ function base:CheckHover()
end end
if modalobject ~= false then if modalobject then
if modalobject ~= self then if modalobject ~= self then
@ -711,9 +703,9 @@ function base:CheckHover()
-- this chunk of code handles mouse enter and exit -- this chunk of code handles mouse enter and exit
if self.hover == true then if self.hover == true then
if self.calledmousefunc == false then if not self.calledmousefunc then
if self.OnMouseEnter ~= nil then if self.OnMouseEnter then
self.OnMouseEnter(self) self.OnMouseEnter(self)
self.calledmousefunc = true self.calledmousefunc = true
else else
@ -724,9 +716,9 @@ function base:CheckHover()
else else
if self.calledmousefunc == true then if self.calledmousefunc then
if self.OnMouseExit ~= nil then if self.OnMouseExit then
self.OnMouseExit(self) self.OnMouseExit(self)
self.calledmousefunc = false self.calledmousefunc = false
else else
@ -849,7 +841,7 @@ function base:MoveToTop()
self:Remove() self:Remove()
if internal == true then if internal then
table.insert(pinternals, self) table.insert(pinternals, self)
else else
table.insert(pchildren, self) table.insert(pchildren, self)

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- button clas -- button class
button = class("button", base) button = class("button", base)
button:include(loveframes.templates.default) button:include(loveframes.templates.default)
@ -34,8 +34,8 @@ function button:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -45,27 +45,30 @@ function button:update(dt)
local hover = self.hover local hover = self.hover
local down = self.down local down = self.down
local hoverobject = loveframes.hoverobject local hoverobject = loveframes.hoverobject
local parent = self.parent
local base = loveframes.base
local update = self.Update
if hover == false then if not hover then
self.down = false self.down = false
elseif hover == true then else
if hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if down == false and hoverobject == self then if not down and hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -78,7 +81,7 @@ function button:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -88,12 +91,14 @@ function button:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawButton or skins[defaultskin].DrawButton local drawfunc = skin.DrawButton or skins[defaultskin].DrawButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -108,13 +113,13 @@ function button:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -137,7 +142,7 @@ function button:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -145,11 +150,12 @@ function button:mousereleased(x, y, button)
local down = self.down local down = self.down
local clickable = self.clickable local clickable = self.clickable
local enabled = self.enabled local enabled = self.enabled
local onclick = self.OnClick
if hover == true and down == true and button == "l" and clickable == true then if hover and down and clickable and button == "l" then
if enabled == true then if enabled then
if self.OnClick then if onclick then
self.OnClick(self, x, y) onclick(self, x, y)
end end
end end
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- checkbox class -- checkbox class
@ -37,59 +37,67 @@ function checkbox:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.hover == false then local hover = self.hover
local internals = self.internals
local boxwidth = self.boxwidth
local boxheight = self.boxheight
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false self.down = false
elseif self.hover == true then else
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if not self.down and loveframes.hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base and self.parent.type ~= "list" then if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.internals[1] then if internals[1] then
self.width = self.boxwidth + 5 + self.internals[1].width self.width = boxwidth + 5 + internals[1].width
if self.internals[1].height == self.boxheight then if internals[1].height == boxheight then
self.height = self.boxheight self.height = boxheight
else else
if self.internals[1].height > self.boxheight then if internals[1].height > boxheight then
self.height = self.internals[1].height self.height = internals[1].height
else else
self.height = self.boxheight self.height = boxheight
end end
end end
else else
self.width = self.boxwidth self.width = boxwidth
self.height = self.boxheight self.height = boxheight
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -102,7 +110,7 @@ function checkbox:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -112,17 +120,20 @@ function checkbox:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox
local draw = self.Draw
local internals = self.internals
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
@ -136,13 +147,13 @@ function checkbox:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -165,23 +176,24 @@ function checkbox:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
local checked = self.checked local checked = self.checked
local onchanged = self.OnChanged
if hover == true and button == "l" then if hover and button == "l" then
if checked == true then if checked then
self.checked = false self.checked = false
else else
self.checked = true self.checked = true
end end
if self.OnChanged then if onchanged then
self.OnChanged(self) onchanged(self)
end end
end end
@ -194,6 +206,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:SetText(text) function checkbox:SetText(text)
local boxwidth = self.boxwidth
local boxheight = self.boxheight
if text ~= "" then if text ~= "" then
self.internals = {} self.internals = {}
@ -205,10 +220,10 @@ function checkbox:SetText(text)
textobject:SetFont(self.font) textobject:SetFont(self.font)
textobject:SetText(text) textobject:SetText(text)
textobject.Update = function(object, dt) textobject.Update = function(object, dt)
if object.height > self.boxheight then if object.height > boxheight then
object:SetPos(self.boxwidth + 5, 0) object:SetPos(boxwidth + 5, 0)
else else
object:SetPos(self.boxwidth + 5, self.boxheight/2 - object.height/2) object:SetPos(boxwidth + 5, boxheight/2 - object.height/2)
end end
end end
@ -216,8 +231,8 @@ function checkbox:SetText(text)
else else
self.width = self.boxwidth self.width = boxwidth
self.height = self.boxheight self.height = boxheight
self.internals = {} self.internals = {}
end end
@ -278,10 +293,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:SetChecked(bool) function checkbox:SetChecked(bool)
local onchanged = self.OnChanged
self.checked = bool self.checked = bool
if self.OnChanged then if onchanged then
self.OnChanged(self) onchanged(self)
end end
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- button clas -- collapsiblecategory class
collapsiblecategory = class("collapsiblecategory", base) collapsiblecategory = class("collapsiblecategory", base)
collapsiblecategory:include(loveframes.templates.default) collapsiblecategory:include(loveframes.templates.default)
@ -36,8 +36,8 @@ function collapsiblecategory:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -45,22 +45,25 @@ function collapsiblecategory:update(dt)
local open = self.open local open = self.open
local children = self.children local children = self.children
local curobject = children[1] local curobject = children[1]
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base and self.parent.type ~= "list" then if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if open == true then if open == true then
curobject:SetWidth(self.width - self.padding*2) curobject:SetWidth(self.width - self.padding * 2)
curobject:update(dt) curobject:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -86,17 +89,19 @@ function collapsiblecategory:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawCollapsibleCategory or skins[defaultskin].DrawCollapsibleCategory local drawfunc = skin.DrawCollapsibleCategory or skins[defaultskin].DrawCollapsibleCategory
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
if open == true then if open then
curobject:draw() curobject:draw()
end end
@ -110,7 +115,7 @@ function collapsiblecategory:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -119,11 +124,11 @@ function collapsiblecategory:mousepressed(x, y, button)
local children = self.children local children = self.children
local curobject = children[1] local curobject = children[1]
if hover == true then if hover then
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
if button == "l" and col == true then if button == "l" and col then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -138,7 +143,7 @@ function collapsiblecategory:mousepressed(x, y, button)
end end
if open == true then if open then
curobject:mousepressed(x, y, button) curobject:mousepressed(x, y, button)
end end
@ -152,7 +157,7 @@ function collapsiblecategory:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -165,9 +170,9 @@ function collapsiblecategory:mousereleased(x, y, button)
local children = self.children local children = self.children
local curobject = children[1] local curobject = children[1]
if hover == true and button == "l" and col == true and self.down == true then if hover and col and down and button == "l" then
if open == true then if open then
self:SetOpen(false) self:SetOpen(false)
else else
self:SetOpen(true) self:SetOpen(true)
@ -177,7 +182,7 @@ function collapsiblecategory:mousereleased(x, y, button)
end end
if open == true then if open then
curobject:mousepressed(x, y, button) curobject:mousepressed(x, y, button)
end end
@ -291,23 +296,28 @@ function collapsiblecategory:SetOpen(bool)
local children = self.children local children = self.children
local curobject = children[1] local curobject = children[1]
local closedheight = self.closedheight
local padding = self.padding
local curobjectheight = curobject.height
local onopenedclosed = self.OnOpenedClosed
self.open = bool self.open = bool
if bool == false then if not bool then
self.height = self.closedheight self.height = closedheight
if curobject then if curobject then
curobject:SetVisible(false) curobject:SetVisible(false)
end end
else else
self.height = self.closedheight + self.padding*2 + curobject.height self.height = closedheight + padding * 2 + curobjectheight
if curobject then if curobject then
curobject:SetVisible(true) curobject:SetVisible(true)
end end
end end
if self.OnOpenedClosed then -- call the on opened closed callback if it exists
self.OnOpenedClosed(self) if onopenedclosed then
onopenedclosed(self)
end end
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- columnlist object -- columnlist class
columnlist = class("columnlist", base) columnlist = class("columnlist", base)
columnlist:include(loveframes.templates.default) columnlist:include(loveframes.templates.default)
@ -37,19 +37,22 @@ function columnlist:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
@ -62,8 +65,8 @@ function columnlist:update(dt)
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -76,13 +79,10 @@ function columnlist:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
local skins = loveframes.skins.available local skins = loveframes.skins.available
@ -91,12 +91,14 @@ function columnlist:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnList or skins[defaultskin].DrawColumnList local drawfunc = skin.DrawColumnList or skins[defaultskin].DrawColumnList
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -211,11 +213,12 @@ function columnlist:AddColumn(name)
local internals = self.internals local internals = self.internals
local list = internals[1] local list = internals[1]
local height = self.height
columnlistheader:new(name, self) columnlistheader:new(name, self)
self:AdjustColumns() self:AdjustColumns()
list:SetSize(self.width, self.height) list:SetSize(self.width, height)
list:SetPos(0, 0) list:SetPos(0, 0)
end end
@ -339,12 +342,13 @@ function columnlist:SetAutoScroll(bool)
local internals = self.internals local internals = self.internals
local list = internals[1] local list = internals[1]
local scrollbar = list:GetScrollBar()
self.autoscroll = bool self.autoscroll = bool
if list then if list then
if list:GetScrollBar() ~= false then if scrollbar then
list:GetScrollBar().autoscroll = bool scrollbar.autoscroll = bool
end end
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- frame class -- frame class
@ -30,17 +30,16 @@ function frame:initialize()
self.children = {} self.children = {}
self.OnClose = nil self.OnClose = nil
-- create the close button for the frame
local close = closebutton:new() local close = closebutton:new()
close.parent = self close.parent = self
close:SetSize(16, 16) close:SetSize(16, 16)
close.OnClick = function() close.OnClick = function()
local onclose = self.OnClose
self:Remove() self:Remove()
if onclose then
if self.OnClose then onclose(self)
self.OnClose(self)
end end
end end
table.insert(self.internals, close) table.insert(self.internals, close)
@ -56,8 +55,8 @@ function frame:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -74,12 +73,13 @@ function frame:update(dt)
local draworder = self.draworder local draworder = self.draworder
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
local update = self.Update
close:SetPos(self.width - 20, 4) close:SetPos(self.width - 20, 4)
self:CheckHover() self:CheckHover()
-- dragging check -- dragging check
if dragging == true then if dragging then
self.x = x - self.clickx self.x = x - self.clickx
self.y = y - self.clicky self.y = y - self.clicky
end end
@ -89,18 +89,20 @@ function frame:update(dt)
local width = love.graphics.getWidth() local width = love.graphics.getWidth()
local height = love.graphics.getHeight() local height = love.graphics.getHeight()
local selfwidth = self.width
local selfheight = self.height
if self.x < 0 then if self.x < 0 then
self.x = 0 self.x = 0
end end
if self.x + self.width > width then if self.x + selfwidth > width then
self.x = width - self.width self.x = width - selfwidth
end end
if self.y < 0 then if self.y < 0 then
self.y = 0 self.y = 0
end end
if self.y + self.height > height then if self.y + selfheight > height then
self.y = height - self.height self.y = height - selfheight
end end
end end
@ -138,8 +140,8 @@ function frame:update(dt)
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -152,7 +154,7 @@ function frame:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -164,12 +166,14 @@ function frame:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -193,30 +197,30 @@ function frame:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local width = self.width local width = self.width
local height = self.height local height = self.height
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local children = self.children
local internals = self.internals local internals = self.internals
local children = self.children
if selfcol == true then if selfcol then
local top = self:IsTopCollision() local top = self:IsTopCollision()
-- initiate dragging if not currently dragging -- initiate dragging if not currently dragging
if self.dragging == false and top == true and button == "l" then if not self.dragging and top and button == "l" then
if y < self.y + 25 and self.draggable == true then if y < self.y + 25 and self.draggable then
self.clickx = x - self.x self.clickx = x - self.x
self.clicky = y - self.y self.clicky = y - self.y
self.dragging = true self.dragging = true
end end
end end
if top == true and button == "l" then if top and button == "l" then
self:MakeTop() self:MakeTop()
end end
@ -240,7 +244,7 @@ function frame:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -249,7 +253,7 @@ function frame:mousereleased(x, y, button)
local internals = self.internals local internals = self.internals
-- exit the dragging state -- exit the dragging state
if dragging == true then if dragging then
self.dragging = false self.dragging = false
end end
@ -386,15 +390,15 @@ function frame:SetModal(bool)
self.modal = bool self.modal = bool
if bool == true then if bool then
if modalobject ~= false then if modalobject then
modalobject:SetModal(false) modalobject:SetModal(false)
end end
loveframes.modalobject = self loveframes.modalobject = self
if mbackground == false then if not mbackground then
self.modalbackground = modalbackground:new(self) self.modalbackground = modalbackground:new(self)
self.modal = true self.modal = true
end end
@ -405,7 +409,7 @@ function frame:SetModal(bool)
loveframes.modalobject = false loveframes.modalobject = false
if mbackground ~= false then if mbackground then
self.modalbackground:Remove() self.modalbackground:Remove()
self.modalbackground = false self.modalbackground = false
self.modal = false self.modal = false
@ -444,7 +448,7 @@ function frame:SetVisible(bool)
v:SetVisible(bool) v:SetVisible(bool)
end end
if self.showclose == true then if self.showclose then
closebutton.visible = bool closebutton.visible = bool
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- progress bar class -- progressbar class
image = class("image", base) image = class("image", base)
image:include(loveframes.templates.default) image:include(loveframes.templates.default)
@ -31,20 +31,24 @@ function image:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= nil then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -57,7 +61,7 @@ function image:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -67,12 +71,14 @@ function image:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- imagebutton clas -- imagebutton class
imagebutton = class("imagebutton", base) imagebutton = class("imagebutton", base)
imagebutton:include(loveframes.templates.default) imagebutton:include(loveframes.templates.default)
@ -35,8 +35,8 @@ function imagebutton:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -46,27 +46,30 @@ function imagebutton:update(dt)
local hover = self.hover local hover = self.hover
local hoverobject = loveframes.hoverobject local hoverobject = loveframes.hoverobject
local down = self.down local down = self.down
local parent = self.parent
local base = loveframes.base
local update = self.Update
if hover == false then if not hover then
self.down = false self.down = false
elseif hover == true then else
if hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if down == false and hoverobject == self then if not down and hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -79,7 +82,7 @@ function imagebutton:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -89,12 +92,14 @@ function imagebutton:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -109,13 +114,13 @@ function imagebutton:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -138,7 +143,7 @@ function imagebutton:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -146,11 +151,12 @@ function imagebutton:mousereleased(x, y, button)
local down = self.down local down = self.down
local clickable = self.clickable local clickable = self.clickable
local enabled = self.enabled local enabled = self.enabled
local onclick = self.OnClick
if hover == true and down == true and button == "l" and clickable == true then if hover and down and clickable and button == "l" then
if enabled == true then if enabled then
if self.OnClick then if onclick then
self.OnClick(self, x, y) onclick(self, x, y)
end end
end end
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- closebutton clas -- closebutton class
closebutton = class("closebutton", base) closebutton = class("closebutton", base)
closebutton:include(loveframes.templates.default) closebutton:include(loveframes.templates.default)
@ -32,8 +32,8 @@ function closebutton:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -43,27 +43,30 @@ function closebutton:update(dt)
local hover = self.hover local hover = self.hover
local down = self.down local down = self.down
local hoverobject = loveframes.hoverobject local hoverobject = loveframes.hoverobject
local parent = self.parent
local base = loveframes.base
local update = self.Update
if hover == false then if not hover then
self.down = false self.down = false
elseif hover == true then else
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if down == false and hoverobject == self then if not down and hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -76,7 +79,7 @@ function closebutton:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -86,12 +89,14 @@ function closebutton:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawCloseButton or skins[defaultskin].DrawCloseButton local drawfunc = skin.DrawCloseButton or skins[defaultskin].DrawCloseButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -106,13 +111,13 @@ function closebutton:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -135,16 +140,17 @@ function closebutton:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
local onclick = self.OnClick
if hover == true and self.down == true then if hover and self.down then
if button == "l" then if button == "l" then
self.OnClick(x, y, self) onclick(x, y, self)
end end
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- columnlistarea object -- columnlistarea class
columnlistarea = class("columnlistarea", base) columnlistarea = class("columnlistarea", base)
columnlistarea:include(loveframes.templates.default) columnlistarea:include(loveframes.templates.default)
@ -22,7 +22,8 @@ function columnlistarea:initialize(parent)
self.clicky = 0 self.clicky = 0
self.offsety = 0 self.offsety = 0
self.offsetx = 0 self.offsetx = 0
self.extra = 0 self.extrawidth = 0
self.extraheight = 0
self.rowcolorindex = 1 self.rowcolorindex = 1
self.rowcolorindexmax = 2 self.rowcolorindexmax = 2
self.bar = false self.bar = false
@ -41,37 +42,40 @@ function columnlistarea:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local cwidth, cheight = self.parent:GetColumnSize() local cwidth, cheight = self.parent:GetColumnSize()
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
local children = self.children
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
v:SetClickBounds(self.x, self.y, self.width, self.height) v:SetClickBounds(self.x, self.y, self.width, self.height)
v.y = (v.parent.y + v.staticy) - self.offsety + cheight v.y = (v.parent.y + v.staticy) - self.offsety + cheight
v.x = (v.parent.x + v.staticx) - self.offsetx v.x = (v.parent.x + v.staticx) - self.offsetx
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -84,7 +88,7 @@ function columnlistarea:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -96,19 +100,24 @@ function columnlistarea:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListArea or skins[defaultskin].DrawColumnListArea local drawfunc = skin.DrawColumnListArea or skins[defaultskin].DrawColumnListArea
local drawoverfunc = skin.DrawOverColumnListArea or skins[defaultskin].DrawOverColumnListArea
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
local children = self.children
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
love.graphics.setStencil(stencil) love.graphics.setStencil(stencil)
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height) local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
if col == true then if col == true then
v:draw() v:draw()
@ -117,11 +126,11 @@ function columnlistarea:draw()
love.graphics.setStencil() love.graphics.setStencil()
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
if self.Draw == nil then if not draw then
skin.DrawOverColumnListArea(self) skin.DrawOverColumnListArea(self)
end end
@ -134,8 +143,10 @@ end
function columnlistarea:mousepressed(x, y, button) function columnlistarea:mousepressed(x, y, button)
local toplist = self:IsTopList() local toplist = self:IsTopList()
local internals = self.internals
local children = self.children
if self.hover == true and button == "l" then if self.hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -145,9 +156,7 @@ function columnlistarea:mousepressed(x, y, button)
end end
if self.bar == true then if self.bar and toplist then
if toplist == true then
local bar = self:GetScrollBar() local bar = self:GetScrollBar()
@ -159,13 +168,11 @@ function columnlistarea:mousepressed(x, y, button)
end end
end for k, v in ipairs(internals) do
for k, v in ipairs(self.internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -177,11 +184,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistarea:mousereleased(x, y, button) function columnlistarea:mousereleased(x, y, button)
for k, v in ipairs(self.internals) do local internals = self.internals
local children = self.children
for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
@ -200,8 +210,9 @@ function columnlistarea:CalculateSize()
local itemheight = ih local itemheight = ih
local itemwidth = 0 local itemwidth = 0
local bar = self.bar local bar = self.bar
local children = self.children
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
itemheight = itemheight + v.height itemheight = itemheight + v.height
end end
@ -209,9 +220,9 @@ function columnlistarea:CalculateSize()
if self.itemheight > height then if self.itemheight > height then
self.extra = self.itemheight - height self.extraheight = self.itemheight - height
if bar == false then if not bar then
table.insert(self.internals, scrollbody:new(self, "vertical")) table.insert(self.internals, scrollbody:new(self, "vertical"))
self.bar = true self.bar = true
self:GetScrollBar().autoscroll = self.parent.autoscroll self:GetScrollBar().autoscroll = self.parent.autoscroll
@ -219,7 +230,7 @@ function columnlistarea:CalculateSize()
else else
if bar == true then if bar then
self.internals[1]:Remove() self.internals[1]:Remove()
self.bar = false self.bar = false
self.offsety = 0 self.offsety = 0
@ -250,7 +261,7 @@ function columnlistarea:RedoLayout()
v.staticx = startx v.staticx = startx
v.staticy = starty v.staticy = starty
if bar == true then if bar then
v:SetWidth(self.width - self.internals[1].width) v:SetWidth(self.width - self.internals[1].width)
self.internals[1].staticx = self.width - self.internals[1].width self.internals[1].staticx = self.width - self.internals[1].width
self.internals[1].height = self.height self.internals[1].height = self.height
@ -298,16 +309,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistarea:GetScrollBar() function columnlistarea:GetScrollBar()
if self.bar ~= false then local internals = self.internals
local scrollbar = self.internals[1].internals[1].internals[1]
if self.bar then
local scrollbody = internals[1]
local scrollarea = scrollbody.internals[1]
local scrollbar = scrollarea.internals[1]
return scrollbar return scrollbar
else else
return false return false
end end
end end
@ -321,8 +331,9 @@ function columnlistarea:Sort(column, desc)
self.rowcolorindex = 1 self.rowcolorindex = 1
local colorindexmax = self.rowcolorindexmax local colorindexmax = self.rowcolorindexmax
local children = self.children
table.sort(self.children, function(a, b) table.sort(children, function(a, b)
if desc then if desc then
return a.columndata[column] < b.columndata[column] return a.columndata[column] < b.columndata[column]
else else
@ -330,7 +341,7 @@ function columnlistarea:Sort(column, desc)
end end
end) end)
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
local colorindex = self.rowcolorindex local colorindex = self.rowcolorindex

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- columnlistrow object -- columnlistrow class
columnlistrow = class("columnlistrow", base) columnlistrow = class("columnlistrow", base)
columnlistrow:include(loveframes.templates.default) columnlistrow:include(loveframes.templates.default)
@ -17,7 +17,6 @@ function columnlistrow:initialize(parent, data)
self.parent = parent self.parent = parent
self.colorindex = self.parent.rowcolorindex self.colorindex = self.parent.rowcolorindex
self.font = loveframes.basicfontsmall self.font = loveframes.basicfontsmall
self.textcolor = {0, 0, 0, 255}
self.width = 80 self.width = 80
self.height = 25 self.height = 25
self.textx = 5 self.textx = 5
@ -36,22 +35,26 @@ function columnlistrow:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -68,32 +71,24 @@ function columnlistrow:draw()
return return
end end
local cwidth, cheight = self:GetParent():GetParent():GetColumnSize()
local x = self.textx
local textcolor = self.textcolor
local skins = loveframes.skins.available local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"] local skinindex = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListRow or skins[defaultskin].DrawColumnListRow local drawfunc = skin.DrawColumnListRow or skins[defaultskin].DrawColumnListRow
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
for k, v in ipairs(self.columndata) do
love.graphics.setFont(self.font)
love.graphics.setColor(unpack(textcolor))
love.graphics.print(v, self.x + x, self.y + self.texty)
x = x + cwidth
end
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -102,11 +97,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistrow:mousepressed(x, y, button) function columnlistrow:mousepressed(x, y, button)
if self.visible == false then if not self.visible then
return return
end end
if self.hover == true and button == "l" then if self.hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -124,17 +119,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistrow:mousereleased(x, y, button) function columnlistrow:mousereleased(x, y, button)
if self.visible == false then if not self.visible then
return return
end end
if self.hover == true and button == "l" then if self.hover and button == "l" then
local parent1 = self:GetParent() local parent1 = self:GetParent()
local parent2 = parent1:GetParent() local parent2 = parent1:GetParent()
local onrowclicked = parent2.OnRowClicked
if parent2.OnRowClicked then if onrowclicked then
parent2.OnRowClicked(parent2, self, self.columndata) onrowclicked(parent2, self, self.columndata)
end end
end end
@ -152,6 +148,26 @@ function columnlistrow:SetTextPos(x, y)
end end
--[[---------------------------------------------------------
- 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
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetFont(font) - func: SetFont(font)
- desc: sets the object's font - desc: sets the object's font
@ -183,11 +199,11 @@ function columnlistrow:GetColorIndex()
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetTextColor(color) - func: GetColumnData()
- desc: sets the object's text color - desc: gets the object's column data
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistrow:SetTextColor(color) function columnlistrow:GetColumnData()
self.textcolor = color return self.columndata
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- columnlistheader object -- columnlistheader class
columnlistheader = class("columnlistheader", base) columnlistheader = class("columnlistheader", base)
columnlistheader:include(loveframes.templates.default) columnlistheader:include(loveframes.templates.default)
@ -55,34 +55,38 @@ function columnlistheader:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
if self.hover == false then if not self.hover then
self.down = false self.down = false
elseif self.hover == true then else
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if self.down and loveframes.hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -95,7 +99,7 @@ function columnlistheader:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -105,12 +109,14 @@ function columnlistheader:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawColumnListHeader or skins[defaultskin].DrawColumnListHeader local drawfunc = skin.DrawColumnListHeader or skins[defaultskin].DrawColumnListHeader
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -123,7 +129,7 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistheader:mousepressed(x, y, button) function columnlistheader:mousepressed(x, y, button)
if self.hover == true and button == "l" then if self.hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -144,7 +150,7 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistheader:mousereleased(x, y, button) function columnlistheader:mousereleased(x, y, button)
if self.visible == false then if not self.visible then
return return
end end
@ -152,13 +158,24 @@ function columnlistheader:mousereleased(x, y, button)
local down = self.down local down = self.down
local clickable = self.clickable local clickable = self.clickable
local enabled = self.enabled local enabled = self.enabled
local onclick = self.OnClick
if hover == true and down == true and button == "l" and clickable == true then if hover and down and clickable and button == "l" then
if enabled == true then if enabled then
self.OnClick(self, x, y) onclick(self, x, y)
end end
end end
self.down = false self.down = false
end end
--[[---------------------------------------------------------
- func: GetName()
- desc: gets the object's name
--]]---------------------------------------------------------
function columnlistheader:GetName()
return self.name
end

View File

@ -0,0 +1,161 @@
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- linenumberspanel class
linenumberspanel = class("linenumberspanel", base)
linenumberspanel:include(loveframes.templates.default)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function linenumberspanel:initialize(parent)
self.parent = parent
self.type = "linenumberspanel"
self.width = 5
self.height = 5
self.offsety = 0
self.staticx = 0
self.staticy = 0
self.internal = true
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the element
--]]---------------------------------------------------------
function linenumberspanel:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local height = self.parent.height
local parentinternals = parent.internals
self.height = height
self.offsety = self.parent.offsety - self.parent.textoffsety
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if parentinternals[1] ~= self then
self:Remove()
table.insert(parentinternals, 1, self)
return
end
self:CheckHover()
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function linenumberspanel:draw()
local visible = self.visible
if not visible then
return
end
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.DrawLineNumbersPanel or skins[defaultskin].DrawLineNumbersPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
local stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.height) end
local stencil = love.graphics.newStencil(stencilfunc)
if self.parent.hbar then
stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.parent.height - 16) end
end
loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount
love.graphics.setStencil(stencilfunc)
if draw then
draw(self)
else
drawfunc(self)
end
love.graphics.setStencil()
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function linenumberspanel:mousepressed(x, y, button)
local visible = self.visible
if not visible then
return
end
local hover = self.hover
if hover and button == "l" then
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 linenumberspanel:mousereleased(x, y, button)
local visible = self.visible
if not visible then
return
end
end
--[[---------------------------------------------------------
- func: GetOffsetY()
- desc: gets the object's y offset
--]]---------------------------------------------------------
function linenumberspanel:GetOffsetY()
return self.offsety
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- modalbackground class -- modalbackground class
@ -39,21 +39,22 @@ function modalbackground:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local object = self.object local object = self.object
local update = self.Update
if object:IsActive() == false then if not object:IsActive() then
self:Remove() self:Remove()
loveframes.modalobject = false loveframes.modalobject = false
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -64,7 +65,7 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function modalbackground:draw() function modalbackground:draw()
if self.visible == false then if not self.visible then
return return
end end
@ -74,12 +75,14 @@ function modalbackground:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- multichoicelist class -- multichoicelist class
@ -52,8 +52,8 @@ function multichoicelist:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -62,11 +62,16 @@ function multichoicelist:update(dt)
local height = love.graphics.getHeight() local height = love.graphics.getHeight()
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local parent = self.parent
local base = loveframes.base
local upadte = self.Update
local internals = self.internals
local children = self.children
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.x < 0 then if self.x < 0 then
@ -85,19 +90,19 @@ function multichoicelist:update(dt)
self.y = height - self.height self.y = height - self.height
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
v:SetClickBounds(self.x, self.y, self.width, self.height) v:SetClickBounds(self.x, self.y, self.width, self.height)
v.y = (v.parent.y + v.staticy) - self.offsety v.y = (v.parent.y + v.staticy) - self.offsety
v.x = (v.parent.x + v.staticx) - self.offsetx v.x = (v.parent.x + v.staticx) - self.offsetx
end end
if self.Update then if upadte then
self.Update(self, dt) upadte(self, dt)
end end
end end
@ -108,8 +113,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicelist:draw() function multichoicelist:draw()
loveframes.drawcount = loveframes.drawcount + 1 local visible = self.visible
self.draworder = loveframes.drawcount
if not visible then
return
end
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
local stencil = love.graphics.newStencil(stencilfunc) local stencil = love.graphics.newStencil(stencilfunc)
@ -119,33 +127,38 @@ function multichoicelist:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMultiChoiceList or skins[defaultskin].DrawMultiChoiceList local drawfunc = skin.DrawMultiChoiceList or skins[defaultskin].DrawMultiChoiceList
local drawoverfunc = skin.DrawOverMultiChoiceList or skins[defaultskin].DrawOverMultiChoiceList
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
local children = self.children
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
love.graphics.setStencil(stencil) love.graphics.setStencil(stencil)
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height) local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
if col == true then if col then
v:draw() v:draw()
end end
end end
love.graphics.setStencil() love.graphics.setStencil()
if self.Draw == nil and skin.DrawOverMultiChoiceList then if not draw then
skin.DrawOverMultiChoiceList(self) drawoverfunc(self)
end end
end end
@ -156,32 +169,36 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicelist:mousepressed(x, y, button) function multichoicelist:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local toplist = self:IsTopList() local toplist = self:IsTopList()
local internals = self.internals
local children = self.children
if selfcol == false and button == "l" and self.canremove == true then if not selfcol and self.canremove and button == "l" then
self:Close() self:Close()
end end
if self.vbar == true and toplist == true then if self.vbar and toplist then
if button == "wu" then if button == "wu" then
self.internals[1].internals[1].internals[1]:Scroll(-5) internals[1].internals[1].internals[1]:Scroll(-5)
elseif button == "wd" then elseif button == "wd" then
self.internals[1].internals[1].internals[1]:Scroll(5) internals[1].internals[1].internals[1]:Scroll(5)
end end
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -193,17 +210,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicelist:mousereleased(x, y, button) function multichoicelist:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
local internals = self.internals
local children = self.children
self.canremove = true self.canremove = true
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
@ -234,10 +256,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicelist:RemoveItem(object) function multichoicelist:RemoveItem(object)
for k, v in ipairs(self.children) do local children = self.children
for k, v in ipairs(children) do
if v == object then if v == object then
table.remove(self.children, k) table.remove(children, k)
end end
end end
@ -273,8 +297,9 @@ function multichoicelist:CalculateSize()
local spacing = self.spacing local spacing = self.spacing
local itemheight = self.padding local itemheight = self.padding
local vbar = self.vbar local vbar = self.vbar
local children = self.children
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
itemheight = itemheight + v.height + spacing itemheight = itemheight + v.height + spacing
end end
@ -284,7 +309,7 @@ function multichoicelist:CalculateSize()
self.extra = self.itemheight - height self.extra = self.itemheight - height
if vbar == false then if not vbar then
local scroll = scrollbody:new(self, "vertical") local scroll = scrollbody:new(self, "vertical")
table.insert(self.internals, scroll) table.insert(self.internals, scroll)
self.vbar = true self.vbar = true
@ -292,7 +317,7 @@ function multichoicelist:CalculateSize()
else else
if vbar == true then if vbar then
self.internals[1]:Remove() self.internals[1]:Remove()
self.vbar = false self.vbar = false
self.offsety = 0 self.offsety = 0
@ -321,12 +346,12 @@ function multichoicelist:RedoLayout()
v.staticx = padding v.staticx = padding
v.staticy = starty v.staticy = starty
if vbar == true then if vbar then
v.width = (self.width - self.internals[1].width) - padding*2 v.width = (self.width - self.internals[1].width) - padding * 2
self.internals[1].staticx = self.width - self.internals[1].width self.internals[1].staticx = self.width - self.internals[1].width
self.internals[1].height = self.height self.internals[1].height = self.height
else else
v.width = self.width - padding*2 v.width = self.width - padding * 2
end end
starty = starty + v.height starty = starty + v.height

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- multichoicerow class -- multichoicerow class
@ -33,34 +33,38 @@ function multichoicerow:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
if self.hover == false then if not self.hover then
self.down = false self.down = false
elseif self.hover == true then else
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if not self.down and loveframes.hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -73,7 +77,7 @@ function multichoicerow:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -83,12 +87,14 @@ function multichoicerow:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMultiChoiceRow or skins[defaultskin].DrawMultiChoiceRow local drawfunc = skin.DrawMultiChoiceRow or skins[defaultskin].DrawMultiChoiceRow
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -101,11 +107,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicerow:mousepressed(x, y, button) function multichoicerow:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover and button == "l" then
self.down = true self.down = true
loveframes.hoverobject = self loveframes.hoverobject = self
@ -120,12 +130,16 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicerow:mousereleased(x, y, button) function multichoicerow:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
if self.hover == true and self.down == true and self.canclick == true and button == "l" then local text = self.text
self.parent.list:SelectChoice(self.text)
if self.hover and self.down and self.canclick and button == "l" then
self.parent.list:SelectChoice(text)
end end
self.down = false self.down = false
@ -142,3 +156,13 @@ function multichoicerow:SetText(text)
self.text = text self.text = text
end end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function multichoicerow:GetText()
return self.text
end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- scrollbar class -- scrollarea class
scrollarea = class("scrollarea", base) scrollarea = class("scrollarea", base)
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -36,16 +36,20 @@ function scrollarea:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
self:CheckHover() self:CheckHover()
@ -80,16 +84,16 @@ function scrollarea:update(dt)
end end
if down == true then if down then
if scrolldelay < time then if scrolldelay < time then
self.scrolldelay = time + delayamount self.scrolldelay = time + delayamount
if listo.display == "vertical" then if self.bartype == "vertical" then
if y > bar.y then if y > bar.y then
bar:Scroll(bar.height) bar:Scroll(bar.height)
else else
bar:Scroll(-bar.height) bar:Scroll(-bar.height)
end end
elseif listo.display == "horizontal" then elseif self.bartype == "horizontal" then
if x > bar.x then if x > bar.x then
bar:Scroll(bar.width) bar:Scroll(bar.width)
else else
@ -97,7 +101,7 @@ function scrollarea:update(dt)
end end
end end
end end
if hover == false then if not hover then
self.down = false self.down = false
end end
end end
@ -106,8 +110,8 @@ function scrollarea:update(dt)
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -120,7 +124,7 @@ function scrollarea:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -131,12 +135,14 @@ function scrollarea:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -155,7 +161,7 @@ function scrollarea:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -166,7 +172,7 @@ function scrollarea:mousepressed(x, y, button)
local hover = self.hover local hover = self.hover
local delayamount = self.delayamount local delayamount = self.delayamount
if hover == true and button == "l" then if hover and button == "l" then
self.down = true self.down = true
self.scrolldelay = time + delayamount + 0.5 self.scrolldelay = time + delayamount + 0.5
@ -176,13 +182,13 @@ function scrollarea:mousepressed(x, y, button)
baseparent:MakeTop() baseparent:MakeTop()
end end
if listo.display == "vertical" then if self.bartype == "vertical" then
if y > self.internals[1].y then if y > self.internals[1].y then
bar:Scroll(bar.height) bar:Scroll(bar.height)
else else
bar:Scroll(-bar.height) bar:Scroll(-bar.height)
end end
elseif listo.display == "horizontal" then elseif self.bartype == "horizontal" then
if x > bar.x then if x > bar.x then
bar:Scroll(bar.width) bar:Scroll(bar.width)
else else
@ -208,7 +214,7 @@ function scrollarea:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -223,3 +229,13 @@ function scrollarea:mousereleased(x, y, button)
end end
end end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bar type
--]]---------------------------------------------------------
function scrollarea:GetBarType()
return self.bartype
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- scrollbar class -- scrollbar class
@ -53,8 +53,8 @@ function scrollbar:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -78,6 +78,7 @@ function scrollbar:update(dt)
local parent = self.parent local parent = self.parent
local listo = parent.parent.parent local listo = parent.parent.parent
local height = parent.height * (listo.height/listo.itemheight) local height = parent.height * (listo.height/listo.itemheight)
local update = self.Update
if height < 20 then if height < 20 then
self.height = 20 self.height = 20
@ -89,7 +90,7 @@ function scrollbar:update(dt)
self.x = parent.x + parent.width - self.width self.x = parent.x + parent.width - self.width
self.y = parent.y + self.staticy self.y = parent.y + self.staticy
if dragging == true then if dragging then
if self.staticy ~= self.lasty then if self.staticy ~= self.lasty then
if listo.OnScroll then if listo.OnScroll then
listo.OnScroll(listo) listo.OnScroll(listo)
@ -102,7 +103,7 @@ function scrollbar:update(dt)
local space = (self.maxy - parent.y) local space = (self.maxy - parent.y)
local remaining = (0 + self.staticy) local remaining = (0 + self.staticy)
local percent = remaining/space local percent = remaining/space
local extra = listo.extra * percent local extra = listo.extraheight * percent
local autoscroll = self.autoscroll local autoscroll = self.autoscroll
local lastheight = self.lastheight local lastheight = self.lastheight
@ -110,7 +111,7 @@ function scrollbar:update(dt)
if self.staticy > space then if self.staticy > space then
self.staticy = space self.staticy = space
listo.offsety = listo.extra listo.offsety = listo.extraheight
end end
if self.staticy < 0 then if self.staticy < 0 then
@ -118,8 +119,8 @@ function scrollbar:update(dt)
listo.offsety = 0 listo.offsety = 0
end end
if autoscroll == true then if autoscroll then
if listo.itemheight ~= lastheight then if listo.itemheight > lastheight then
self.lastheight = listo.itemheight self.lastheight = listo.itemheight
self:Scroll(self.maxy) self:Scroll(self.maxy)
end end
@ -127,8 +128,6 @@ function scrollbar:update(dt)
elseif bartype == "horizontal" then elseif bartype == "horizontal" then
self.lastwidth = self.width
local parent = self.parent local parent = self.parent
local listo = self.parent.parent.parent local listo = self.parent.parent.parent
local width = self.parent.width * (listo.width/listo.itemwidth) local width = self.parent.width * (listo.width/listo.itemwidth)
@ -143,7 +142,7 @@ function scrollbar:update(dt)
self.x = parent.x + self.staticx self.x = parent.x + self.staticx
self.y = parent.y + self.staticy self.y = parent.y + self.staticy
if dragging == true then if dragging then
if self.staticx ~= self.lastx then if self.staticx ~= self.lastx then
if listo.OnScroll then if listo.OnScroll then
listo.OnScroll(listo) listo.OnScroll(listo)
@ -156,7 +155,7 @@ function scrollbar:update(dt)
local space = (self.maxx - parent.x) local space = (self.maxx - parent.x)
local remaining = (0 + self.staticx) local remaining = (0 + self.staticx)
local percent = remaining/space local percent = remaining/space
local extra = listo.extra * percent local extra = listo.extrawidth * percent
local autoscroll = self.autoscroll local autoscroll = self.autoscroll
local lastwidth = self.lastwidth local lastwidth = self.lastwidth
@ -164,7 +163,7 @@ function scrollbar:update(dt)
if self.staticx > space then if self.staticx > space then
self.staticx = space self.staticx = space
listo.offsetx = listo.extra listo.offsetx = listo.extrawidth
end end
if self.staticx < 0 then if self.staticx < 0 then
@ -172,17 +171,17 @@ function scrollbar:update(dt)
listo.offsetx = 0 listo.offsetx = 0
end end
if autoscroll == true then if autoscroll then
if self.width ~= lastwidth then if listo.itemwidth > lastwidth then
self.width = self.width self.lastwidth = listo.itemwidth
self:Scroll(self.maxx) self:Scroll(self.maxx)
end end
end end
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -195,7 +194,7 @@ function scrollbar:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -205,12 +204,14 @@ function scrollbar:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -226,11 +227,11 @@ function scrollbar:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
local hover = self.hover local hover = self.hover
if visible == false then if not visible then
return return
end end
if hover == false then if not hover then
return return
end end
@ -242,7 +243,7 @@ function scrollbar:mousepressed(x, y, button)
local dragging = self.dragging local dragging = self.dragging
if dragging == false then if not dragging then
if button == "l" then if button == "l" then
@ -267,11 +268,11 @@ function scrollbar:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
if self.dragging == true then if self.dragging then
self.dragging = false self.dragging = false
end end
@ -305,6 +306,7 @@ function scrollbar:Scroll(amount)
local bartype = self.bartype local bartype = self.bartype
local listo = self.parent.parent.parent local listo = self.parent.parent.parent
local onscroll = listo.OnScroll
if bartype == "vertical" then if bartype == "vertical" then
local newy = (self.y + amount) local newy = (self.y + amount)
@ -328,8 +330,28 @@ function scrollbar:Scroll(amount)
end end
end end
if listo.OnScroll then if onscroll then
listo.OnScroll(listo) onscroll(listo)
end end
end end
--[[---------------------------------------------------------
- func: IsDragging()
- desc: gets whether the object is being dragged or not
--]]---------------------------------------------------------
function scrollbar:IsDragging()
return self.dragging
end
--[[---------------------------------------------------------
- func: GetBarType()
- desc: gets the object's bartype
--]]---------------------------------------------------------
function scrollbar:GetBarType()
return self.bartype
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- scrollbar class -- scrollbar class
@ -12,7 +12,7 @@ scrollbody = class("scrollbody", base)
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbody:initialize(parent, bartype) function scrollbody:initialize(parent, bartype)
self.type = "scroll-body" self.type = "scrollbody"
self.bartype = bartype self.bartype = bartype
self.parent = parent self.parent = parent
self.x = 0 self.x = 0
@ -43,7 +43,7 @@ function scrollbody:initialize(parent, bartype)
upbutton.Update = function(object, dt) upbutton.Update = function(object, dt)
upbutton.staticx = 0 + self.width - upbutton.width upbutton.staticx = 0 + self.width - upbutton.width
upbutton.staticy = 0 upbutton.staticy = 0
if object.down == true and object.hover == true then if object.down and object.hover then
bar:Scroll(-0.10) bar:Scroll(-0.10)
end end
end end
@ -53,7 +53,7 @@ function scrollbody:initialize(parent, bartype)
downbutton.Update = function(object, dt) downbutton.Update = function(object, dt)
downbutton.staticx = 0 + self.width - downbutton.width downbutton.staticx = 0 + self.width - downbutton.width
downbutton.staticy = 0 + self.height - downbutton.height downbutton.staticy = 0 + self.height - downbutton.height
if object.down == true and object.hover == true then if object.down and object.hover then
bar:Scroll(0.10) bar:Scroll(0.10)
end end
end end
@ -68,7 +68,7 @@ function scrollbody:initialize(parent, bartype)
leftbutton.Update = function(object, dt) leftbutton.Update = function(object, dt)
leftbutton.staticx = 0 leftbutton.staticx = 0
leftbutton.staticy = 0 leftbutton.staticy = 0
if object.down == true and object.hover == true then if object.down and object.hover then
bar:Scroll(-0.10) bar:Scroll(-0.10)
end end
end end
@ -78,7 +78,7 @@ function scrollbody:initialize(parent, bartype)
rightbutton.Update = function(object, dt) rightbutton.Update = function(object, dt)
rightbutton.staticx = 0 + self.width - rightbutton.width rightbutton.staticx = 0 + self.width - rightbutton.width
rightbutton.staticy = 0 rightbutton.staticy = 0
if object.down == true and object.hover == true then if object.down and object.hover then
bar:Scroll(0.10) bar:Scroll(0.10)
end end
end end
@ -96,26 +96,34 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbody:update(dt) function scrollbody:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
local internals = self.internals
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
self:CheckHover() self:CheckHover()
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -126,7 +134,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbody:draw() function scrollbody:draw()
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
@ -136,17 +146,20 @@ function scrollbody:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody
local draw = self.Draw
local drawcount = loveframes.drawcount
local internals = self.internals
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- scrollbutton clas -- scrollbutton clas
@ -29,34 +29,42 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbutton:update(dt) function scrollbutton:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.hover == false then local hover = self.hover
local parent = self.parent
local base = loveframes.base
local update = self.Update
if not hover then
self.down = false self.down = false
elseif self.hover == true then else
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if not self.down and loveframes.hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -67,7 +75,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbutton:draw() function scrollbutton:draw()
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
@ -77,12 +87,14 @@ function scrollbutton:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -90,17 +102,20 @@ function scrollbutton:draw()
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: mousepressed(x, y, scrollbutton) - func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button - desc: called when the player presses a mouse button
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbutton:mousepressed(x, y, scrollbutton) function scrollbutton:mousepressed(x, y, button)
local visible = self.visible
if self.visible == false then if not visible then
return return
end end
if self.hover == true then local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -116,19 +131,25 @@ function scrollbutton:mousepressed(x, y, scrollbutton)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: mousereleased(x, y, scrollbutton) - func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button - desc: called when the player releases a mouse button
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function scrollbutton:mousereleased(x, y, scrollbutton) function scrollbutton:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if not visible then
return return
end end
if self.hover == true and self.down == true then local hover = self.hover
local down = self.down
local onclick = self.OnClick
if scrollbutton == "l" then if hover and down then
self.OnClick(x, y, self)
if button == "l" then
onclick(x, y, self)
end end
end end
@ -146,3 +167,14 @@ function scrollbutton:SetText(text)
return return
end end
--[[---------------------------------------------------------
- func: GetScrollType()
- desc: gets the object's scroll type
--]]---------------------------------------------------------
function scrollbutton:GetScrollType()
return self.scrolltype
end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- closebutton clas -- sliderbutton class
sliderbutton = class("sliderbutton", base) sliderbutton = class("sliderbutton", base)
sliderbutton:include(loveframes.templates.default) sliderbutton:include(loveframes.templates.default)
@ -39,8 +39,8 @@ function sliderbutton:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -58,27 +58,30 @@ function sliderbutton:update(dt)
local parent = self.parent local parent = self.parent
local slidetype = parent.slidetype local slidetype = parent.slidetype
local dragging = self.dragging local dragging = self.dragging
local parent = self.parent
local base = loveframes.base
local update = self.Update
if hover == false then if not hover then
self.down = false self.down = false
elseif hover == true then else
if hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if down == false and hoverobject == self then if not down and hoverobject == self then
self.hover = true self.hover = true
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = parent.y + self.staticy
end end
-- start calculations if the button is being dragged -- start calculations if the button is being dragged
if dragging == true then if dragging then
-- calculations for horizontal sliders -- calculations for horizontal sliders
if slidetype == "horizontal" then if slidetype == "horizontal" then
@ -142,8 +145,8 @@ function sliderbutton:update(dt)
end end
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -156,7 +159,7 @@ function sliderbutton:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -166,12 +169,14 @@ function sliderbutton:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -186,13 +191,13 @@ function sliderbutton:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -220,7 +225,7 @@ function sliderbutton:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- tabbutton clas -- tabbutton class
tabbutton = class("tabbutton", base) tabbutton = class("tabbutton", base)
tabbutton:include(loveframes.templates.default) tabbutton:include(loveframes.templates.default)
@ -46,23 +46,27 @@ function tabbutton:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
self:SetClickBounds(self.parent.x, self.parent.y, self.parent.width, self.parent.height) self:SetClickBounds(parent.x, parent.y, parent.width, parent.height)
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -73,7 +77,7 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabbutton:draw() function tabbutton:draw()
if self.visible == false then if not self.visible then
return return
end end
@ -86,12 +90,14 @@ function tabbutton:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -113,13 +119,13 @@ function tabbutton:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -142,7 +148,7 @@ function tabbutton:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -150,7 +156,7 @@ function tabbutton:mousereleased(x, y, button)
local parent = self.parent local parent = self.parent
local tabnumber = self.tabnumber local tabnumber = self.tabnumber
if hover == true and button == "l" then if hover and button == "l" then
if button == "l" then if button == "l" then
parent:SwitchToTab(tabnumber) parent:SwitchToTab(tabnumber)
@ -172,6 +178,16 @@ function tabbutton:SetText(text)
end end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function tabbutton:GetText()
return self.text
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetImage(image) - func: SetImage(image)
- desc: adds an image to the object - desc: adds an image to the object
@ -185,3 +201,23 @@ function tabbutton:SetImage(image)
end end
end end
--[[---------------------------------------------------------
- func: GetImage()
- desc: gets the object's image
--]]---------------------------------------------------------
function tabbutton:GetImage()
return self.image
end
--[[---------------------------------------------------------
- func: GetTabNumber()
- desc: gets the object's tab number
--]]---------------------------------------------------------
function tabbutton:GetTabNumber()
return self.tabnumber
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- tooltip clas -- tooltip clas
@ -48,19 +48,19 @@ function tooltip:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local text = self.text local text = self.text
self.width = text.width + self.padding*2
self.height = text.height + self.padding*2
local object = self.object local object = self.object
local draworder = self.draworder local draworder = self.draworder
local update = self.Update
self.width = text.width + self.padding * 2
self.height = text.height + self.padding * 2
if object then if object then
@ -71,15 +71,15 @@ function tooltip:update(dt)
local hover = object.hover local hover = object.hover
local odraworder = object.draworder local odraworder = object.draworder
local ovisible = object.visible
local ohover = object.hover
self.show = object.hover self.show = ohover
self.visible = self.show self.visible = ovisible
local show = self.show if ohover and ovisible then
if show == true then
local top = self:IsTopInternal() local top = self:IsTopInternal()
if self.followcursor == true then if self.followcursor then
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
self.x = x + self.xoffset self.x = x + self.xoffset
self.y = y - self.height + self.yoffset self.y = y - self.height + self.yoffset
@ -88,7 +88,7 @@ function tooltip:update(dt)
self.y = object.y - self.height + self.yoffset self.y = object.y - self.height + self.yoffset
end end
if top == false then if not top then
self:MoveToTop() self:MoveToTop()
end end
@ -99,7 +99,7 @@ function tooltip:update(dt)
local baseparent = object:GetBaseParent() local baseparent = object:GetBaseParent()
if baseparent then if baseparent then
if baseparent.removed and baseparent.removed == true then if baseparent.removed and baseparent.removed then
self:Remove() self:Remove()
end end
elseif object.removed then elseif object.removed then
@ -110,8 +110,8 @@ function tooltip:update(dt)
text:update(dt) text:update(dt)
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -124,7 +124,7 @@ function tooltip:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -136,14 +136,16 @@ function tooltip:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if show == true then if show then
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- list class -- list class
@ -23,7 +23,8 @@ function list:initialize()
self.spacing = 0 self.spacing = 0
self.offsety = 0 self.offsety = 0
self.offsetx = 0 self.offsetx = 0
self.extra = 0 self.extrawidth = 0
self.extraheight = 0
self.internal = false self.internal = false
self.hbar = false self.hbar = false
self.vbar = false self.vbar = false
@ -43,8 +44,8 @@ function list:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -52,9 +53,12 @@ function list:update(dt)
local internals = self.internals local internals = self.internals
local children = self.children local children = self.children
local display = self.display local display = self.display
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
@ -80,8 +84,8 @@ function list:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -94,7 +98,7 @@ function list:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -108,12 +112,15 @@ function list:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawList or skins[defaultskin].DrawList local drawfunc = skin.DrawList or skins[defaultskin].DrawList
local drawoverfunc = skin.DrawOverList or skins[defaultskin].DrawOverList
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -133,8 +140,8 @@ function list:draw()
v:draw() v:draw()
end end
if self.Draw == nil then if not draw then
skin.DrawOverList(self) drawoverfunc(self)
end end
end end
@ -147,7 +154,7 @@ function list:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -158,7 +165,7 @@ function list:mousepressed(x, y, button)
local children = self.children local children = self.children
local internals = self.internals local internals = self.internals
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -168,9 +175,9 @@ function list:mousepressed(x, y, button)
end end
if vbar == true or hbar == true then if vbar or hbar then
if toplist == true then if toplist then
local bar = self:GetScrollBar() local bar = self:GetScrollBar()
@ -206,11 +213,14 @@ function list:AddItem(object)
local children = self.children local children = self.children
-- remove the item object from it's current parent and make it's new parent the list object
object:Remove() object:Remove()
object.parent = self object.parent = self
-- insert the item object into the list object's children table
table.insert(children, object) table.insert(children, object)
-- resize the list and redo it's layout
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -259,9 +269,9 @@ function list:CalculateSize()
if itemheight > height then if itemheight > height then
self.extra = itemheight - height self.extraheight = itemheight - height
if vbar == false then if not vbar then
local scrollbar = scrollbody:new(self, display) local scrollbar = scrollbody:new(self, display)
table.insert(internals, scrollbar) table.insert(internals, scrollbar)
self.vbar = true self.vbar = true
@ -270,7 +280,7 @@ function list:CalculateSize()
else else
if vbar == true then if vbar then
local bar = internals[1] local bar = internals[1]
bar:Remove() bar:Remove()
self.vbar = false self.vbar = false
@ -291,9 +301,9 @@ function list:CalculateSize()
if itemwidth > width then if itemwidth > width then
self.extra = itemwidth - width self.extrawidth = itemwidth - width
if hbar == false then if not hbar then
local scrollbar = scrollbody:new(self, display) local scrollbar = scrollbody:new(self, display)
table.insert(internals, scrollbar) table.insert(internals, scrollbar)
self.hbar = true self.hbar = true
@ -302,7 +312,7 @@ function list:CalculateSize()
else else
if hbar == true then if hbar then
local bar = internals[1] local bar = internals[1]
bar:Remove() bar:Remove()
self.hbar = false self.hbar = false
@ -342,17 +352,17 @@ function list:RedoLayout()
v.staticy = starty v.staticy = starty
v.lastheight = v.height v.lastheight = v.height
if vbar == true then if vbar then
if v.width + padding > (self.width - self.internals[1].width) then if v.width + padding > (self.width - self.internals[1].width) then
v:SetWidth((self.width - self.internals[1].width) - (padding*2)) v:SetWidth((self.width - self.internals[1].width) - (padding*2))
end end
if v.retainsize == false then if not v.retainsize then
v:SetWidth((self.width - self.internals[1].width) - (padding*2)) v:SetWidth((self.width - self.internals[1].width) - (padding*2))
end end
self.internals[1].staticx = self.width - self.internals[1].width self.internals[1].staticx = self.width - self.internals[1].width
self.internals[1].height = self.height self.internals[1].height = self.height
else else
if v.retainsize == false then if not v.retainsize then
v:SetWidth(self.width - (padding*2)) v:SetWidth(self.width - (padding*2))
end end
end end
@ -365,17 +375,17 @@ function list:RedoLayout()
v.staticx = startx v.staticx = startx
v.staticy = padding v.staticy = padding
if hbar == true then if hbar then
if v.height + padding > (self.height - self.internals[1].height) then if v.height + padding > (self.height - self.internals[1].height) then
v:SetHeight((self.height - self.internals[1].height) - (padding*2)) v:SetHeight((self.height - self.internals[1].height) - (padding*2))
end end
if v.retainsize == false then if not v.retainsize then
v:SetHeight((self.height - self.internals[1].height) - (padding*2)) v:SetHeight((self.height - self.internals[1].height) - (padding*2))
end end
self.internals[1].staticy = self.height - self.internals[1].height self.internals[1].staticy = self.height - self.internals[1].height
self.internals[1].width = self.width self.internals[1].width = self.width
else else
if v.retainsize == false then if not v.retainsize then
v:SetHeight(self.height - (padding*2)) v:SetHeight(self.height - (padding*2))
end end
end end
@ -401,12 +411,11 @@ function list:SetDisplayType(type)
local numchildren = #children local numchildren = #children
self.display = type self.display = type
self.internals = {}
self.vbar = false self.vbar = false
self.hbar = false self.hbar = false
self.offsetx = 0 self.offsetx = 0
self.offsety = 0 self.offsety = 0
self.internals = {}
if numchildren > 0 then if numchildren > 0 then
self:CalculateSize() self:CalculateSize()
@ -518,9 +527,12 @@ function list:GetScrollBar()
local vbar = self.vbar local vbar = self.vbar
local hbar = self.hbar local hbar = self.hbar
local internals = self.internals
if vbar == true or hbar == true then if vbar or hbar then
local scrollbar = self.internals[1].internals[1].internals[1] local scrollbody = internals[1]
local scrollarea = scrollbody.internals[1]
local scrollbar = scrollarea.internals[1]
return scrollbar return scrollbar
else else
return false return false
@ -536,10 +548,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:SetAutoScroll(bool) function list:SetAutoScroll(bool)
local scrollbar = self:GetScrollBar()
self.autoscroll = bool self.autoscroll = bool
if self:GetScrollBar() ~= false then if scrollbar then
self:GetScrollBar().autoscroll = bool scrollbar.autoscroll = bool
end end
end end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- progress bar class -- multichoice class
multichoice = class("multichoice", base) multichoice = class("multichoice", base)
multichoice:include(loveframes.templates.default) multichoice:include(loveframes.templates.default)
@ -20,10 +20,10 @@ function multichoice:initialize()
self.height = 25 self.height = 25
self.listpadding = 0 self.listpadding = 0
self.listspacing = 0 self.listspacing = 0
self.listheight = nil
self.haslist = false self.haslist = false
self.internal = false self.internal = false
self.choices = {} self.choices = {}
self.listheight = nil
end end
@ -36,22 +36,25 @@ function multichoice:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local parent = self.parent
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= nil then if parent then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -64,7 +67,7 @@ function multichoice:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -74,12 +77,14 @@ function multichoice:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -94,14 +99,14 @@ function multichoice:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
local haslist = self.haslist local haslist = self.haslist
if hover == true and haslist == false and button == "l" then if hover and not haslist and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -125,7 +130,7 @@ function multichoice:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -158,11 +163,13 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:SelectChoice(choice) function multichoice:SelectChoice(choice)
local onchoiceselected = self.OnChoiceSelected
self.choice = choice self.choice = choice
self.list:Close() self.list:Close()
if self.OnChoiceSelected then if onchoiceselected then
self.OnChoiceSelected(self, choice) onchoiceselected(self, choice)
end end
end end
@ -216,3 +223,23 @@ function multichoice:GetChoice()
return self.choice return self.choice
end end
--[[---------------------------------------------------------
- func: SetText(text)
- desc: sets the object's text
--]]---------------------------------------------------------
function multichoice:SetText(text)
self.text = text
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function multichoice:GetText()
return self.text
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- panel class -- panel class
@ -30,16 +30,19 @@ function panel:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local children = self.children local children = self.children
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base and self.parent.type ~= "list" then if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
@ -50,8 +53,8 @@ function panel:update(dt)
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -64,7 +67,7 @@ function panel:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -75,12 +78,14 @@ function panel:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -100,14 +105,14 @@ function panel:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local children = self.children local children = self.children
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -132,7 +137,7 @@ function panel:mousereleased(x, y, button)
local visible = self.visible local visible = self.visible
local children = self.children local children = self.children
if visible == false then if not visible then
return return
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- progressbar class -- progressbar class
@ -19,7 +19,7 @@ function progressbar:initialize()
self.min = 0 self.min = 0
self.max = 10 self.max = 10
self.value = 0 self.value = 0
self.progress = 0 self.barwidth = 0
self.lerprate = 1000 self.lerprate = 1000
self.lerpvalue = 0 self.lerpvalue = 0
self.lerpto = 0 self.lerpto = 0
@ -40,8 +40,8 @@ function progressbar:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -53,11 +53,15 @@ function progressbar:update(dt)
local lerpfrom = self.lerpfrom local lerpfrom = self.lerpfrom
local value = self.value local value = self.value
local completed = self.completed local completed = self.completed
local parent = self.parent
local base = loveframes.base
local update = self.Update
local oncomplete = self.OnComplete
self:CheckHover() self:CheckHover()
-- caclulate progress -- caclulate barwidth
if lerp == true then if lerp then
if lerpfrom < lerpto then if lerpfrom < lerpto then
if lerpvalue < lerpto then if lerpvalue < lerpto then
self.lerpvalue = lerpvalue + lerprate*dt self.lerpvalue = lerpvalue + lerprate*dt
@ -74,7 +78,7 @@ function progressbar:update(dt)
self.lerpvalue = lerpto self.lerpvalue = lerpto
end end
self.progress = self.lerpvalue/self.max * self.width self.barwidth = self.lerpvalue/self.max * self.width
-- min check -- min check
if self.lerpvalue < self.min then if self.lerpvalue < self.min then
@ -86,37 +90,34 @@ function progressbar:update(dt)
self.lerpvalue = self.max self.lerpvalue = self.max
end end
else else
self.progress = self.value/self.max * self.width self.barwidth = value/self.max * self.width
-- min check -- min max check
if self.value < self.min then if value < self.min then
self.value = self.min self.value = self.min
end elseif value > self.max then
-- max check
if self.value > self.max then
self.value = self.max self.value = self.max
end end
end end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= nil then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
-- completion check -- completion check
if completed == false then if not completed then
if self.value >= self.max then if self.value >= self.max then
self.completed = true self.completed = true
if self.OnComplete then if oncomplete then
self.OnComplete(self) oncomplete(self)
end end
end end
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -129,7 +130,7 @@ function progressbar:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -139,12 +140,14 @@ function progressbar:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawProgressBar or skins[defaultskin].DrawProgressBar local drawfunc = skin.DrawProgressBar or skins[defaultskin].DrawProgressBar
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -220,7 +223,7 @@ function progressbar:SetValue(value)
local lerp = self.lerp local lerp = self.lerp
if lerp == true then if lerp then
self.lerpvalue = self.lerpvalue self.lerpvalue = self.lerpvalue
self.lerpto = value self.lerpto = value
self.lerpfrom = self.lerpvalue self.lerpfrom = self.lerpvalue
@ -295,3 +298,13 @@ function progressbar:GetCompleted()
return self.completed return self.completed
end end
--[[---------------------------------------------------------
- func: GetBarWidth()
- desc: gets the object's bar width
--]]---------------------------------------------------------
function progressbar:GetBarWidth()
return self.barwidth
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- text clas -- text clas
@ -43,19 +43,22 @@ function slider:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
local internals = self.internals local internals = self.internals
local sliderbutton = internals[1] local sliderbutton = internals[1]
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base and self.parent.type ~= "list" then if parent ~= base and parent.type ~= "list" then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
@ -73,8 +76,8 @@ function slider:update(dt)
v:update(dt) v:update(dt)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -87,7 +90,7 @@ function slider:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -98,12 +101,14 @@ function slider:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -123,16 +128,18 @@ function slider:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
if self.hover == true and button == "l" then local internals = self.internals
if self.hover and button == "l" then
if self.slidetype == "horizontal" then if self.slidetype == "horizontal" then
local xpos = x - self.x local xpos = x - self.x
local button = self.internals[1] local button = internals[1]
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then if baseparent and baseparent.type == "frame" then
@ -148,7 +155,7 @@ function slider:mousepressed(x, y, button)
elseif self.slidetype == "vertical" then elseif self.slidetype == "vertical" then
local ypos = y - self.y local ypos = y - self.y
local button = self.internals[1] local button = internals[1]
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then if baseparent and baseparent.type == "frame" then
@ -166,7 +173,7 @@ function slider:mousepressed(x, y, button)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -189,25 +196,31 @@ function slider:SetValue(value)
local decimals = self.decimals local decimals = self.decimals
local newval = loveframes.util.Round(value, decimals) local newval = loveframes.util.Round(value, decimals)
local internals = self.internals local internals = self.internals
local onvaluechanged = self.OnValueChanged
-- set the new value -- set the new value
self.value = newval self.value = newval
-- slider button object -- slider button object
local sliderbutton = internals[1] local sliderbutton = internals[1]
local slidetype = self.slidetype
local width = self.width
local height = self.height
local min = self.min
local max = self.max
-- move the slider button to the new position -- move the slider button to the new position
if self.slidetype == "horizontal" then if slidetype == "horizontal" then
local xpos = self.width * (( newval - self.min ) / (self.max - self.min)) local xpos = width * ((newval - min) / (max - min))
sliderbutton:MoveToX(xpos) sliderbutton:MoveToX(xpos)
elseif self.slidetype == "vertical" then elseif slidetype == "vertical" then
local ypos = self.height - self.height * (( newval - self.min ) / (self.max - self.min)) local ypos = height - height * ((newval - min) / (max - min))
sliderbutton:MoveToY(ypos) sliderbutton:MoveToY(ypos)
end end
-- call OnValueChanged -- call OnValueChanged
if self.OnValueChanged then if onvaluechanged then
self.OnValueChanged(self) onvaluechanged(self)
end end
end end
@ -336,7 +349,7 @@ end
function slider:SetButtonSize(width, height) function slider:SetButtonSize(width, height)
local internals = self.internals local internals = self.internals
local sliderbutton = self.internals[1] local sliderbutton = internals[1]
if sliderbutton then if sliderbutton then
sliderbutton.width = width sliderbutton.width = width
@ -352,7 +365,7 @@ end
function slider:GetButtonSize() function slider:GetButtonSize()
local internals = self.internals local internals = self.internals
local sliderbutton = self.internals[1] local sliderbutton = internals[1]
if sliderbutton then if sliderbutton then
return sliderbutton.width, sliderbutton.height return sliderbutton.width, sliderbutton.height
@ -375,3 +388,13 @@ function slider:SetSlideType(slidetype)
end end
end end
--[[---------------------------------------------------------
- func: GetSlideType()
- desc: gets the objects's slide type
--]]---------------------------------------------------------
function slider:GetSlideType()
return self.slidetype
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- tabs class -- tabs class
@ -41,8 +41,8 @@ function tabs:update(dt)
local visible = self.visible local visible = self.visible
local alwaysupdate = self.alwaysupdate local alwaysupdate = self.alwaysupdate
if visible == false then if not visible then
if alwaysupdate == false then if not alwaysupdate then
return return
end end
end end
@ -58,9 +58,12 @@ function tabs:update(dt)
local numchildren = #children local numchildren = #children
local internals = self.internals local internals = self.internals
local tab = self.tab local tab = self.tab
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
@ -87,8 +90,8 @@ function tabs:update(dt)
v:SetPos(padding, tabheight + padding) v:SetPos(padding, tabheight + padding)
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -101,7 +104,7 @@ function tabs:draw()
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -116,12 +119,14 @@ function tabs:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -148,7 +153,7 @@ function tabs:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
@ -159,7 +164,7 @@ function tabs:mousepressed(x, y, button)
local numinternals = #internals local numinternals = #internals
local hover = self.hover local hover = self.hover
if hover == true then if hover then
if button == "l" then if button == "l" then
@ -179,7 +184,7 @@ function tabs:mousepressed(x, y, button)
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
local visible = internals[numinternals - 1]:GetVisible() local visible = internals[numinternals - 1]:GetVisible()
if col == true and visible == true then if col and visible then
self.offsetx = self.offsetx + 5 self.offsetx = self.offsetx + 5
if self.offsetx > 0 then if self.offsetx > 0 then
self.offsetx = 0 self.offsetx = 0
@ -194,7 +199,7 @@ function tabs:mousepressed(x, y, button)
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
local visible = internals[numinternals]:GetVisible() local visible = internals[numinternals]:GetVisible()
if col == true and visible == true then if col and visible then
local bwidth = self:GetWidthOfButtons() local bwidth = self:GetWidthOfButtons()
if (self.offsetx + bwidth) < self.width then if (self.offsetx + bwidth) < self.width then
self.offsetx = bwidth - self.width self.offsetx = bwidth - self.width
@ -227,7 +232,7 @@ function tabs:mousereleased(x, y, button)
local tab = self.tab local tab = self.tab
local internals = self.internals local internals = self.internals
if visible == false then if not visible then
return return
end end
@ -273,7 +278,7 @@ function tabs:AddTab(name, object, tip, image)
self:AddScrollButtons() self:AddScrollButtons()
if autosize == true and retainsize == false then if autosize and not retainsize then
object:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2) object:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2)
end end
@ -464,6 +469,6 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:GetTabNumber() function tabs:GetTabNumber()
return self.tabnumber return self.tab
end end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
--[[------------------------------------------------ --[[------------------------------------------------
@ -36,22 +36,26 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function text:update(dt) function text:update(dt)
if self.visible == false then if not self.visible then
if self.alwaysupdate == false then if not self.alwaysupdate then
return return
end end
end end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if parent ~= base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.Update then if update then
self.Update(self, dt) update(self, dt)
end end
end end
@ -62,7 +66,7 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function text:draw() function text:draw()
if self.visible == false then if not self.visible then
return return
end end
@ -72,12 +76,14 @@ function text:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawText or skins[defaultskin].DrawText local drawfunc = skin.DrawText or skins[defaultskin].DrawText
local draw = self.Draw
local drawcount = loveframes.drawcount
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
if self.Draw ~= nil then if draw then
self.Draw(self) draw(self)
else else
drawfunc(self) drawfunc(self)
end end
@ -94,13 +100,13 @@ function text:mousepressed(x, y, button)
local visible = self.visible local visible = self.visible
if visible == false then if not visible then
return return
end end
local hover = self.hover local hover = self.hover
if hover == true and button == "l" then if hover and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -158,7 +164,7 @@ function text:SetText(t)
v = v:gsub(string.char(9), " ") v = v:gsub(string.char(9), " ")
v = v:gsub(string.char(92) .. string.char(110), string.char(10)) v = v:gsub(string.char(92) .. string.char(110), string.char(10))
local parts = loveframes.util.SplitSring(v, " ") local parts = loveframes.util.SplitString(v, " ")
for i, j in ipairs(parts) do for i, j in ipairs(parts) do
table.insert(self.text, {color = prevcolor, text = j}) table.insert(self.text, {color = prevcolor, text = j})
@ -225,9 +231,9 @@ function text:SetText(t)
local drawy = 0 local drawy = 0
local lines = 0 local lines = 0
local totalwidth = 0 local totalwidth = 0
local prevtextwidth
local x = self.x local x = self.x
local y = self.y local y = self.y
local prevtextwidth = 0
for k, v in ipairs(textdata) do for k, v in ipairs(textdata) do

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
# Löve Frames # Love Frames
## Information ## Information
For information on installation and usage, please visit the wiki. Love Frames is a GUI library for LÖVE. For information on installation and usage, please visit the wiki. A demo of the library can be found at: http://nikolairesokav.com/projects/loveframes/
## License ## License
Löve Frames is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license. Love Frames is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.
For more information on this license, please read license.html or visit this web page: http://creativecommons.org/licenses/by-sa/3.0/ For more information on this license, please read license.txt or visit this web page: http://creativecommons.org/licenses/by-sa/3.0/
## Credits ## Credits
Created by Nikolai Resokav Created by Kenny Shields
**Third Party Stuff** **Third Party Libraries**
- middleclass: kikito - middleclass: kikito

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
loveframes.skins = {} loveframes.skins = {}
@ -17,11 +17,11 @@ function loveframes.skins.Register(skin)
local images = loveframes.util.GetDirContents(dir .. "/images") local images = loveframes.util.GetDirContents(dir .. "/images")
local indeximages = loveframes.config["INDEXSKINIMAGES"] local indeximages = loveframes.config["INDEXSKINIMAGES"]
if name == "" or name == nil then if name == "" or not name then
error("Could not register skin: Invalid or missing name data.") error("Could not register skin: Invalid or missing name data.")
end end
if author == "" or author == nil then if author == "" or not author then
error("Could not register skin: Invalid or missing author data.") error("Could not register skin: Invalid or missing author data.")
end end
@ -29,11 +29,11 @@ function loveframes.skins.Register(skin)
error("Could not register skin: Invalid or missing version data.") error("Could not register skin: Invalid or missing version data.")
end end
if namecheck ~= nil then if namecheck then
error("Could not register skin: A skin with the name '" ..name.. "' already exists.") error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end end
if dircheck == false then if not dircheck then
error("Could not register skin: Could not find a directory for skin '" ..name.. "'.") error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
end end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- templates -- templates

139
third-party/middleclass.lua vendored Normal file
View File

@ -0,0 +1,139 @@
-- middleclass.lua - v2.0 (2011-09)
-- Copyright (c) 2011 Enrique García Cota
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-- Based on YaciCode, from Julien Patte and LuaObject, from Sebastien Rocca-Serra
local _classes = setmetatable({}, {__mode = "k"})
local function _setClassDictionariesMetatables(klass)
local dict = klass.__instanceDict
dict.__index = dict
local super = klass.super
if super then
local superStatic = super.static
setmetatable(dict, super.__instanceDict)
setmetatable(klass.static, { __index = function(_,k) return dict[k] or superStatic[k] end })
else
setmetatable(klass.static, { __index = function(_,k) return dict[k] end })
end
end
local function _setClassMetatable(klass)
setmetatable(klass, {
__tostring = function() return "class " .. klass.name end,
__index = klass.static,
__newindex = klass.__instanceDict,
__call = function(self, ...) return self:new(...) end
})
end
local function _createClass(name, super)
local klass = { name = name, super = super, static = {}, __mixins = {}, __instanceDict={} }
klass.subclasses = setmetatable({}, {__mode = "k"})
_setClassDictionariesMetatables(klass)
_setClassMetatable(klass)
_classes[klass] = true
return klass
end
local function _createLookupMetamethod(klass, name)
return function(...)
local method = klass.super[name]
assert( type(method)=='function', tostring(klass) .. " doesn't implement metamethod '" .. name .. "'" )
return method(...)
end
end
local function _setClassMetamethods(klass)
for _,m in ipairs(klass.__metamethods) do
klass[m]= _createLookupMetamethod(klass, m)
end
end
local function _setDefaultInitializeMethod(klass, super)
klass.initialize = function(instance, ...)
return super.initialize(instance, ...)
end
end
local function _includeMixin(klass, mixin)
assert(type(mixin)=='table', "mixin must be a table")
for name,method in pairs(mixin) do
if name ~= "included" and name ~= "static" then klass[name] = method end
end
if mixin.static then
for name,method in pairs(mixin.static) do
klass.static[name] = method
end
end
if type(mixin.included)=="function" then mixin:included(klass) end
klass.__mixins[mixin] = true
end
Object = _createClass("Object", nil)
Object.static.__metamethods = { '__add', '__call', '__concat', '__div', '__le', '__lt',
'__mod', '__mul', '__pow', '__sub', '__tostring', '__unm' }
function Object.static:allocate()
assert(_classes[self], "Make sure that you are using 'Class:allocate' instead of 'Class.allocate'")
return setmetatable({ class = self }, self.__instanceDict)
end
function Object.static:new(...)
local instance = self:allocate()
instance:initialize(...)
return instance
end
function Object.static:subclass(name)
assert(_classes[self], "Make sure that you are using 'Class:subclass' instead of 'Class.subclass'")
assert(type(name) == "string", "You must provide a name(string) for your class")
local subclass = _createClass(name, self)
_setClassMetamethods(subclass)
_setDefaultInitializeMethod(subclass, self)
self.subclasses[subclass] = true
self:subclassed(subclass)
return subclass
end
function Object.static:subclassed(other) end
function Object.static:include( ... )
assert(_classes[self], "Make sure you that you are using 'Class:include' instead of 'Class.include'")
for _,mixin in ipairs({...}) do _includeMixin(self, mixin) end
return self
end
function Object:initialize() end
function Object:__tostring() return "instance of " .. tostring(self.class) end
function class(name, super, ...)
super = super or Object
return super:subclass(name, ...)
end
function instanceOf(aClass, obj)
if not _classes[aClass] or type(obj) ~= 'table' or not _classes[obj.class] then return false end
if obj.class == aClass then return true end
return subclassOf(aClass, obj.class)
end
function subclassOf(other, aClass)
if not _classes[aClass] or not _classes[other] or aClass.super == nil then return false end
return aClass.super == other or subclassOf(other, aClass.super)
end
function includes(mixin, aClass)
if not _classes[aClass] then return false end
if aClass.__mixins[mixin] then return true end
return includes(mixin, aClass.super)
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------ --[[------------------------------------------------
-- Löve Frames -- -- Love Frames - A GUI library for LOVE --
-- Copyright 2012 Kenny Shields -- -- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------ --]]------------------------------------------------
-- util library -- util library
@ -163,7 +163,7 @@ function loveframes.util.GetDirContents(dir, t)
if isdir == true then if isdir == true then
table.insert(dirs, dir.. "/" ..v) table.insert(dirs, dir.. "/" ..v)
else else
local parts = loveframes.util.SplitSring(v, "([.])") local parts = loveframes.util.SplitString(v, "([.])")
local extension = parts[#parts] local extension = parts[#parts]
local name = restore(parts) local name = restore(parts)
table.insert(t, {path = dir, fullpath = dir.. "/" ..v, name = name, extension = extension}) table.insert(t, {path = dir, fullpath = dir.. "/" ..v, name = name, extension = extension})
@ -195,11 +195,11 @@ function loveframes.util.Round(num, idp)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SplitSring(string, pattern) - func: SplitString(string, pattern)
- desc: splits a string into a table based on a given pattern - desc: splits a string into a table based on a given pattern
- note: i take no credit for this function - note: i take no credit for this function
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function loveframes.util.SplitSring(str, pat) function loveframes.util.SplitString(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0 local t = {} -- NOTE: use {n = 0} in Lua-5.0