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)
================================================

View File

@ -1,12 +1,13 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- debug library
loveframes.debug = {}
local font = love.graphics.newFont(10)
local changelog, size = love.filesystem.read("libraries/loveframes/changelog.txt")
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.
@ -23,7 +24,7 @@ function loveframes.debug.draw()
local debug = loveframes.config["DEBUG"]
-- do not draw anthing if debug is off
if debug == false then
if not debug then
return
end
@ -38,7 +39,6 @@ function loveframes.debug.draw()
local fps = love.timer.getFPS()
local deltatime = love.timer.getDelta()
-- font for debug text
love.graphics.setFont(font)
@ -608,15 +608,40 @@ function loveframes.debug.ExamplesMenu()
local frame1 = loveframes.Create("frame")
frame1:SetName("Text Input")
frame1:SetSize(500, 60)
frame1:SetSize(500, 90)
frame1:Center()
local textinput1 = loveframes.Create("textinput", frame1)
textinput1:SetPos(5, 30)
textinput1:SetWidth(490)
textinput1.OnEnter = function(object)
if not textinput1.multiline then
object:Clear()
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
exampleslist:AddItem(textinputexample)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- columnlistheader object
-- columnlistheader class
columnlistheader = class("columnlistheader", base)
columnlistheader:include(loveframes.templates.default)
@ -55,34 +55,38 @@ function columnlistheader:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
if self.hover == false then
if not self.hover then
self.down = false
elseif self.hover == true then
else
if loveframes.hoverobject == self then
self.down = true
end
end
if self.down == false and loveframes.hoverobject == self then
if self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -95,7 +99,7 @@ function columnlistheader:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -105,12 +109,14 @@ function columnlistheader:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -123,7 +129,7 @@ end
--]]---------------------------------------------------------
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()
@ -144,7 +150,7 @@ end
--]]---------------------------------------------------------
function columnlistheader:mousereleased(x, y, button)
if self.visible == false then
if not self.visible then
return
end
@ -152,13 +158,24 @@ function columnlistheader:mousereleased(x, y, button)
local down = self.down
local clickable = self.clickable
local enabled = self.enabled
local onclick = self.OnClick
if hover == true and down == true and button == "l" and clickable == true then
if enabled == true then
self.OnClick(self, x, y)
if hover and down and clickable and button == "l" then
if enabled then
onclick(self, x, y)
end
end
self.down = false
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- modalbackground class
@ -39,21 +39,22 @@ function modalbackground:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local object = self.object
local update = self.Update
if object:IsActive() == false then
if not object:IsActive() then
self:Remove()
loveframes.modalobject = false
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -64,7 +65,7 @@ end
--]]---------------------------------------------------------
function modalbackground:draw()
if self.visible == false then
if not self.visible then
return
end
@ -74,12 +75,14 @@ function modalbackground:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end

View File

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

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- multichoicerow class
@ -33,34 +33,38 @@ function multichoicerow:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
if self.hover == false then
if not self.hover then
self.down = false
elseif self.hover == true then
else
if loveframes.hoverobject == self then
self.down = true
end
end
if self.down == false and loveframes.hoverobject == self then
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -73,7 +77,7 @@ function multichoicerow:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -83,12 +87,14 @@ function multichoicerow:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -101,11 +107,15 @@ end
--]]---------------------------------------------------------
function multichoicerow:mousepressed(x, y, button)
if self.visible == false then
local visible = self.visible
if not visible then
return
end
if self.hover == true and button == "l" then
local hover = self.hover
if hover and button == "l" then
self.down = true
loveframes.hoverobject = self
@ -120,12 +130,16 @@ end
--]]---------------------------------------------------------
function multichoicerow:mousereleased(x, y, button)
if self.visible == false then
local visible = self.visible
if not visible then
return
end
if self.hover == true and self.down == true and self.canclick == true and button == "l" then
self.parent.list:SelectChoice(self.text)
local text = self.text
if self.hover and self.down and self.canclick and button == "l" then
self.parent.list:SelectChoice(text)
end
self.down = false
@ -142,3 +156,13 @@ function multichoicerow:SetText(text)
self.text = text
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
-- scrollarea class
scrollarea = class("scrollarea", base)
--[[---------------------------------------------------------
@ -36,16 +36,20 @@ function scrollarea:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
@ -80,16 +84,16 @@ function scrollarea:update(dt)
end
if down == true then
if down then
if scrolldelay < time then
self.scrolldelay = time + delayamount
if listo.display == "vertical" then
if self.bartype == "vertical" then
if y > bar.y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif listo.display == "horizontal" then
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
@ -97,7 +101,7 @@ function scrollarea:update(dt)
end
end
end
if hover == false then
if not hover then
self.down = false
end
end
@ -106,8 +110,8 @@ function scrollarea:update(dt)
v:update(dt)
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -120,7 +124,7 @@ function scrollarea:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -131,12 +135,14 @@ function scrollarea:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -155,7 +161,7 @@ function scrollarea:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -166,7 +172,7 @@ function scrollarea:mousepressed(x, y, button)
local hover = self.hover
local delayamount = self.delayamount
if hover == true and button == "l" then
if hover and button == "l" then
self.down = true
self.scrolldelay = time + delayamount + 0.5
@ -176,13 +182,13 @@ function scrollarea:mousepressed(x, y, button)
baseparent:MakeTop()
end
if listo.display == "vertical" then
if self.bartype == "vertical" then
if y > self.internals[1].y then
bar:Scroll(bar.height)
else
bar:Scroll(-bar.height)
end
elseif listo.display == "horizontal" then
elseif self.bartype == "horizontal" then
if x > bar.x then
bar:Scroll(bar.width)
else
@ -208,7 +214,7 @@ function scrollarea:mousereleased(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -223,3 +229,13 @@ function scrollarea:mousereleased(x, y, button)
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
@ -53,8 +53,8 @@ function scrollbar:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
@ -78,6 +78,7 @@ function scrollbar:update(dt)
local parent = self.parent
local listo = parent.parent.parent
local height = parent.height * (listo.height/listo.itemheight)
local update = self.Update
if height < 20 then
self.height = 20
@ -89,7 +90,7 @@ function scrollbar:update(dt)
self.x = parent.x + parent.width - self.width
self.y = parent.y + self.staticy
if dragging == true then
if dragging then
if self.staticy ~= self.lasty then
if listo.OnScroll then
listo.OnScroll(listo)
@ -102,7 +103,7 @@ function scrollbar:update(dt)
local space = (self.maxy - parent.y)
local remaining = (0 + self.staticy)
local percent = remaining/space
local extra = listo.extra * percent
local extra = listo.extraheight * percent
local autoscroll = self.autoscroll
local lastheight = self.lastheight
@ -110,7 +111,7 @@ function scrollbar:update(dt)
if self.staticy > space then
self.staticy = space
listo.offsety = listo.extra
listo.offsety = listo.extraheight
end
if self.staticy < 0 then
@ -118,8 +119,8 @@ function scrollbar:update(dt)
listo.offsety = 0
end
if autoscroll == true then
if listo.itemheight ~= lastheight then
if autoscroll then
if listo.itemheight > lastheight then
self.lastheight = listo.itemheight
self:Scroll(self.maxy)
end
@ -127,8 +128,6 @@ function scrollbar:update(dt)
elseif bartype == "horizontal" then
self.lastwidth = self.width
local parent = self.parent
local listo = self.parent.parent.parent
local width = self.parent.width * (listo.width/listo.itemwidth)
@ -143,7 +142,7 @@ function scrollbar:update(dt)
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
if dragging == true then
if dragging then
if self.staticx ~= self.lastx then
if listo.OnScroll then
listo.OnScroll(listo)
@ -156,7 +155,7 @@ function scrollbar:update(dt)
local space = (self.maxx - parent.x)
local remaining = (0 + self.staticx)
local percent = remaining/space
local extra = listo.extra * percent
local extra = listo.extrawidth * percent
local autoscroll = self.autoscroll
local lastwidth = self.lastwidth
@ -164,7 +163,7 @@ function scrollbar:update(dt)
if self.staticx > space then
self.staticx = space
listo.offsetx = listo.extra
listo.offsetx = listo.extrawidth
end
if self.staticx < 0 then
@ -172,17 +171,17 @@ function scrollbar:update(dt)
listo.offsetx = 0
end
if autoscroll == true then
if self.width ~= lastwidth then
self.width = self.width
if autoscroll then
if listo.itemwidth > lastwidth then
self.lastwidth = listo.itemwidth
self:Scroll(self.maxx)
end
end
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -195,7 +194,7 @@ function scrollbar:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -205,12 +204,14 @@ function scrollbar:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -226,11 +227,11 @@ function scrollbar:mousepressed(x, y, button)
local visible = self.visible
local hover = self.hover
if visible == false then
if not visible then
return
end
if hover == false then
if not hover then
return
end
@ -242,7 +243,7 @@ function scrollbar:mousepressed(x, y, button)
local dragging = self.dragging
if dragging == false then
if not dragging then
if button == "l" then
@ -267,11 +268,11 @@ function scrollbar:mousereleased(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
if self.dragging == true then
if self.dragging then
self.dragging = false
end
@ -305,6 +306,7 @@ function scrollbar:Scroll(amount)
local bartype = self.bartype
local listo = self.parent.parent.parent
local onscroll = listo.OnScroll
if bartype == "vertical" then
local newy = (self.y + amount)
@ -328,8 +330,28 @@ function scrollbar:Scroll(amount)
end
end
if listo.OnScroll then
listo.OnScroll(listo)
if onscroll then
onscroll(listo)
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbar class
@ -12,7 +12,7 @@ scrollbody = class("scrollbody", base)
--]]---------------------------------------------------------
function scrollbody:initialize(parent, bartype)
self.type = "scroll-body"
self.type = "scrollbody"
self.bartype = bartype
self.parent = parent
self.x = 0
@ -43,7 +43,7 @@ function scrollbody:initialize(parent, bartype)
upbutton.Update = function(object, dt)
upbutton.staticx = 0 + self.width - upbutton.width
upbutton.staticy = 0
if object.down == true and object.hover == true then
if object.down and object.hover then
bar:Scroll(-0.10)
end
end
@ -53,7 +53,7 @@ function scrollbody:initialize(parent, bartype)
downbutton.Update = function(object, dt)
downbutton.staticx = 0 + self.width - downbutton.width
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)
end
end
@ -68,7 +68,7 @@ function scrollbody:initialize(parent, bartype)
leftbutton.Update = function(object, dt)
leftbutton.staticx = 0
leftbutton.staticy = 0
if object.down == true and object.hover == true then
if object.down and object.hover then
bar:Scroll(-0.10)
end
end
@ -78,7 +78,7 @@ function scrollbody:initialize(parent, bartype)
rightbutton.Update = function(object, dt)
rightbutton.staticx = 0 + self.width - rightbutton.width
rightbutton.staticy = 0
if object.down == true and object.hover == true then
if object.down and object.hover then
bar:Scroll(0.10)
end
end
@ -96,26 +96,34 @@ end
--]]---------------------------------------------------------
function scrollbody:update(dt)
if self.visible == false then
if self.alwaysupdate == false then
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 internals = self.internals
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
self:CheckHover()
for k, v in ipairs(self.internals) do
for k, v in ipairs(internals) do
v:update(dt)
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -126,7 +134,9 @@ end
--]]---------------------------------------------------------
function scrollbody:draw()
if self.visible == false then
local visible = self.visible
if not visible then
return
end
@ -136,17 +146,20 @@ function scrollbody:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
for k, v in ipairs(self.internals) do
for k, v in ipairs(internals) do
v:draw()
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- scrollbutton clas
@ -29,34 +29,42 @@ end
--]]---------------------------------------------------------
function scrollbutton:update(dt)
if self.visible == false then
if self.alwaysupdate == false then
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
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
elseif self.hover == true then
else
if loveframes.hoverobject == self then
self.down = true
end
end
if self.down == false and loveframes.hoverobject == self then
if not self.down and loveframes.hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -67,7 +75,9 @@ end
--]]---------------------------------------------------------
function scrollbutton:draw()
if self.visible == false then
local visible = self.visible
if not visible then
return
end
@ -77,12 +87,14 @@ function scrollbutton:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -90,17 +102,20 @@ function scrollbutton:draw()
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, scrollbutton)
- func: mousepressed(x, y, 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
end
if self.hover == true then
local hover = self.hover
if hover and button == "l" then
local baseparent = self:GetBaseParent()
@ -116,19 +131,25 @@ function scrollbutton:mousepressed(x, y, scrollbutton)
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, scrollbutton)
- func: mousereleased(x, y, 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
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
self.OnClick(x, y, self)
if hover and down then
if button == "l" then
onclick(x, y, self)
end
end
@ -146,3 +167,14 @@ function scrollbutton:SetText(text)
return
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- closebutton clas
-- sliderbutton class
sliderbutton = class("sliderbutton", base)
sliderbutton:include(loveframes.templates.default)
@ -39,8 +39,8 @@ function sliderbutton:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
@ -58,27 +58,30 @@ function sliderbutton:update(dt)
local parent = self.parent
local slidetype = parent.slidetype
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
elseif hover == true then
else
if hoverobject == self then
self.down = true
end
end
if down == false and hoverobject == self then
if not down and hoverobject == self then
self.hover = true
end
-- move to parent if there is a parent
if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
if parent ~= base then
self.x = parent.x + self.staticx
self.y = parent.y + self.staticy
end
-- start calculations if the button is being dragged
if dragging == true then
if dragging then
-- calculations for horizontal sliders
if slidetype == "horizontal" then
@ -142,8 +145,8 @@ function sliderbutton:update(dt)
end
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -156,7 +159,7 @@ function sliderbutton:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -166,12 +169,14 @@ function sliderbutton:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -186,13 +191,13 @@ function sliderbutton:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
local hover = self.hover
if hover == true and button == "l" then
if hover and button == "l" then
local baseparent = self:GetBaseParent()
@ -220,7 +225,7 @@ function sliderbutton:mousereleased(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- tabbutton clas
-- tabbutton class
tabbutton = class("tabbutton", base)
tabbutton:include(loveframes.templates.default)
@ -46,23 +46,27 @@ function tabbutton:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
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
if self.parent ~= loveframes.base then
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -73,7 +77,7 @@ end
--]]---------------------------------------------------------
function tabbutton:draw()
if self.visible == false then
if not self.visible then
return
end
@ -86,12 +90,14 @@ function tabbutton:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -113,13 +119,13 @@ function tabbutton:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
local hover = self.hover
if hover == true and button == "l" then
if hover and button == "l" then
local baseparent = self:GetBaseParent()
@ -142,7 +148,7 @@ function tabbutton:mousereleased(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -150,7 +156,7 @@ function tabbutton:mousereleased(x, y, button)
local parent = self.parent
local tabnumber = self.tabnumber
if hover == true and button == "l" then
if hover and button == "l" then
if button == "l" then
parent:SwitchToTab(tabnumber)
@ -172,6 +178,16 @@ function tabbutton:SetText(text)
end
--[[---------------------------------------------------------
- func: GetText()
- desc: gets the object's text
--]]---------------------------------------------------------
function tabbutton:GetText()
return self.text
end
--[[---------------------------------------------------------
- func: SetImage(image)
- desc: adds an image to the object
@ -185,3 +201,23 @@ function tabbutton:SetImage(image)
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- tooltip clas
@ -48,19 +48,19 @@ function tooltip:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local text = self.text
self.width = text.width + self.padding*2
self.height = text.height + self.padding*2
local object = self.object
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
@ -71,15 +71,15 @@ function tooltip:update(dt)
local hover = object.hover
local odraworder = object.draworder
local ovisible = object.visible
local ohover = object.hover
self.show = object.hover
self.visible = self.show
self.show = ohover
self.visible = ovisible
local show = self.show
if show == true then
if ohover and ovisible then
local top = self:IsTopInternal()
if self.followcursor == true then
if self.followcursor then
local x, y = love.mouse.getPosition()
self.x = x + self.xoffset
self.y = y - self.height + self.yoffset
@ -88,7 +88,7 @@ function tooltip:update(dt)
self.y = object.y - self.height + self.yoffset
end
if top == false then
if not top then
self:MoveToTop()
end
@ -99,7 +99,7 @@ function tooltip:update(dt)
local baseparent = object:GetBaseParent()
if baseparent then
if baseparent.removed and baseparent.removed == true then
if baseparent.removed and baseparent.removed then
self:Remove()
end
elseif object.removed then
@ -110,8 +110,8 @@ function tooltip:update(dt)
text:update(dt)
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -124,7 +124,7 @@ function tooltip:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -136,14 +136,16 @@ function tooltip:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if show == true then
if show then
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end

View File

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

View File

@ -1,9 +1,9 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- progress bar class
-- multichoice class
multichoice = class("multichoice", base)
multichoice:include(loveframes.templates.default)
@ -20,10 +20,10 @@ function multichoice:initialize()
self.height = 25
self.listpadding = 0
self.listspacing = 0
self.listheight = nil
self.haslist = false
self.internal = false
self.choices = {}
self.listheight = nil
end
@ -36,22 +36,25 @@ function multichoice:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local parent = self.parent
local update = self.Update
self:CheckHover()
-- move to parent if there is a parent
if self.parent ~= nil then
if parent then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -64,7 +67,7 @@ function multichoice:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -74,12 +77,14 @@ function multichoice:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -94,14 +99,14 @@ function multichoice:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
local hover = self.hover
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()
@ -125,7 +130,7 @@ function multichoice:mousereleased(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -158,11 +163,13 @@ end
--]]---------------------------------------------------------
function multichoice:SelectChoice(choice)
local onchoiceselected = self.OnChoiceSelected
self.choice = choice
self.list:Close()
if self.OnChoiceSelected then
self.OnChoiceSelected(self, choice)
if onchoiceselected then
onchoiceselected(self, choice)
end
end
@ -216,3 +223,23 @@ function multichoice:GetChoice()
return self.choice
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- panel class
@ -30,16 +30,19 @@ function panel:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local children = self.children
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- 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.y = self.parent.y + self.staticy
end
@ -50,8 +53,8 @@ function panel:update(dt)
v:update(dt)
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -64,7 +67,7 @@ function panel:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -75,12 +78,14 @@ function panel:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -100,14 +105,14 @@ function panel:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
local children = self.children
local hover = self.hover
if hover == true and button == "l" then
if hover and button == "l" then
local baseparent = self:GetBaseParent()
@ -132,7 +137,7 @@ function panel:mousereleased(x, y, button)
local visible = self.visible
local children = self.children
if visible == false then
if not visible then
return
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- progressbar class
@ -19,7 +19,7 @@ function progressbar:initialize()
self.min = 0
self.max = 10
self.value = 0
self.progress = 0
self.barwidth = 0
self.lerprate = 1000
self.lerpvalue = 0
self.lerpto = 0
@ -40,8 +40,8 @@ function progressbar:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
@ -53,11 +53,15 @@ function progressbar:update(dt)
local lerpfrom = self.lerpfrom
local value = self.value
local completed = self.completed
local parent = self.parent
local base = loveframes.base
local update = self.Update
local oncomplete = self.OnComplete
self:CheckHover()
-- caclulate progress
if lerp == true then
-- caclulate barwidth
if lerp then
if lerpfrom < lerpto then
if lerpvalue < lerpto then
self.lerpvalue = lerpvalue + lerprate*dt
@ -74,7 +78,7 @@ function progressbar:update(dt)
self.lerpvalue = lerpto
end
self.progress = self.lerpvalue/self.max * self.width
self.barwidth = self.lerpvalue/self.max * self.width
-- min check
if self.lerpvalue < self.min then
@ -86,37 +90,34 @@ function progressbar:update(dt)
self.lerpvalue = self.max
end
else
self.progress = self.value/self.max * self.width
self.barwidth = value/self.max * self.width
-- min check
if self.value < self.min then
-- min max check
if value < self.min then
self.value = self.min
end
-- max check
if self.value > self.max then
elseif value > self.max then
self.value = self.max
end
end
-- 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.y = self.parent.y + self.staticy
end
-- completion check
if completed == false then
if not completed then
if self.value >= self.max then
self.completed = true
if self.OnComplete then
self.OnComplete(self)
if oncomplete then
oncomplete(self)
end
end
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -129,7 +130,7 @@ function progressbar:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -139,12 +140,14 @@ function progressbar:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -220,7 +223,7 @@ function progressbar:SetValue(value)
local lerp = self.lerp
if lerp == true then
if lerp then
self.lerpvalue = self.lerpvalue
self.lerpto = value
self.lerpfrom = self.lerpvalue
@ -295,3 +298,13 @@ function progressbar:GetCompleted()
return self.completed
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- text clas
@ -43,19 +43,22 @@ function slider:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
local internals = self.internals
local sliderbutton = internals[1]
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- 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.y = self.parent.y + self.staticy
end
@ -73,8 +76,8 @@ function slider:update(dt)
v:update(dt)
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -87,7 +90,7 @@ function slider:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -98,12 +101,14 @@ function slider:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -123,16 +128,18 @@ function slider:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
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
local xpos = x - self.x
local button = self.internals[1]
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
@ -148,7 +155,7 @@ function slider:mousepressed(x, y, button)
elseif self.slidetype == "vertical" then
local ypos = y - self.y
local button = self.internals[1]
local button = internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
@ -166,7 +173,7 @@ function slider:mousepressed(x, y, button)
end
for k, v in ipairs(self.internals) do
for k, v in ipairs(internals) do
v:mousepressed(x, y, button)
end
@ -189,25 +196,31 @@ function slider:SetValue(value)
local decimals = self.decimals
local newval = loveframes.util.Round(value, decimals)
local internals = self.internals
local onvaluechanged = self.OnValueChanged
-- set the new value
self.value = newval
-- slider button object
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
if self.slidetype == "horizontal" then
local xpos = self.width * (( newval - self.min ) / (self.max - self.min))
if slidetype == "horizontal" then
local xpos = width * ((newval - min) / (max - min))
sliderbutton:MoveToX(xpos)
elseif self.slidetype == "vertical" then
local ypos = self.height - self.height * (( newval - self.min ) / (self.max - self.min))
elseif slidetype == "vertical" then
local ypos = height - height * ((newval - min) / (max - min))
sliderbutton:MoveToY(ypos)
end
-- call OnValueChanged
if self.OnValueChanged then
self.OnValueChanged(self)
if onvaluechanged then
onvaluechanged(self)
end
end
@ -336,7 +349,7 @@ end
function slider:SetButtonSize(width, height)
local internals = self.internals
local sliderbutton = self.internals[1]
local sliderbutton = internals[1]
if sliderbutton then
sliderbutton.width = width
@ -352,7 +365,7 @@ end
function slider:GetButtonSize()
local internals = self.internals
local sliderbutton = self.internals[1]
local sliderbutton = internals[1]
if sliderbutton then
return sliderbutton.width, sliderbutton.height
@ -375,3 +388,13 @@ function slider:SetSlideType(slidetype)
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- tabs class
@ -41,8 +41,8 @@ function tabs:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
if not visible then
if not alwaysupdate then
return
end
end
@ -58,9 +58,12 @@ function tabs:update(dt)
local numchildren = #children
local internals = self.internals
local tab = self.tab
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- 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.y = self.parent.y + self.staticy
end
@ -87,8 +90,8 @@ function tabs:update(dt)
v:SetPos(padding, tabheight + padding)
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -101,7 +104,7 @@ function tabs:draw()
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -116,12 +119,14 @@ function tabs:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -148,7 +153,7 @@ function tabs:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
@ -159,7 +164,7 @@ function tabs:mousepressed(x, y, button)
local numinternals = #internals
local hover = self.hover
if hover == true then
if hover 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 visible = internals[numinternals - 1]:GetVisible()
if col == true and visible == true then
if col and visible then
self.offsetx = self.offsetx + 5
if self.offsetx > 0 then
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 visible = internals[numinternals]:GetVisible()
if col == true and visible == true then
if col and visible then
local bwidth = self:GetWidthOfButtons()
if (self.offsetx + bwidth) < self.width then
self.offsetx = bwidth - self.width
@ -227,7 +232,7 @@ function tabs:mousereleased(x, y, button)
local tab = self.tab
local internals = self.internals
if visible == false then
if not visible then
return
end
@ -273,7 +278,7 @@ function tabs:AddTab(name, object, tip, image)
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)
end
@ -464,6 +469,6 @@ end
--]]---------------------------------------------------------
function tabs:GetTabNumber()
return self.tabnumber
return self.tab
end

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
--[[------------------------------------------------
@ -36,22 +36,26 @@ end
--]]---------------------------------------------------------
function text:update(dt)
if self.visible == false then
if self.alwaysupdate == false then
if not self.visible then
if not self.alwaysupdate then
return
end
end
local parent = self.parent
local base = loveframes.base
local update = self.Update
self:CheckHover()
-- 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.y = self.parent.y + self.staticy
end
if self.Update then
self.Update(self, dt)
if update then
update(self, dt)
end
end
@ -62,7 +66,7 @@ end
--]]---------------------------------------------------------
function text:draw()
if self.visible == false then
if not self.visible then
return
end
@ -72,12 +76,14 @@ function text:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
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
if self.Draw ~= nil then
self.Draw(self)
if draw then
draw(self)
else
drawfunc(self)
end
@ -94,13 +100,13 @@ function text:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
if not visible then
return
end
local hover = self.hover
if hover == true and button == "l" then
if hover and button == "l" then
local baseparent = self:GetBaseParent()
@ -158,7 +164,7 @@ function text:SetText(t)
v = v:gsub(string.char(9), " ")
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
table.insert(self.text, {color = prevcolor, text = j})
@ -225,9 +231,9 @@ function text:SetText(t)
local drawy = 0
local lines = 0
local totalwidth = 0
local prevtextwidth
local x = self.x
local y = self.y
local prevtextwidth = 0
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
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
Löve 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/
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.txt or visit this web page: http://creativecommons.org/licenses/by-sa/3.0/
## Credits
Created by Nikolai Resokav
Created by Kenny Shields
**Third Party Stuff**
**Third Party Libraries**
- middleclass: kikito

View File

@ -1,6 +1,6 @@
--[[------------------------------------------------
-- Löve Frames --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
loveframes.skins = {}
@ -17,11 +17,11 @@ function loveframes.skins.Register(skin)
local images = loveframes.util.GetDirContents(dir .. "/images")
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.")
end
if author == "" or author == nil then
if author == "" or not author then
error("Could not register skin: Invalid or missing author data.")
end
@ -29,11 +29,11 @@ function loveframes.skins.Register(skin)
error("Could not register skin: Invalid or missing version data.")
end
if namecheck ~= nil then
if namecheck then
error("Could not register skin: A skin with the name '" ..name.. "' already exists.")
end
if dircheck == false then
if not dircheck then
error("Could not register skin: Could not find a directory for skin '" ..name.. "'.")
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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- 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 --
-- Copyright 2012 Kenny Shields --
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012 Kenny Shields --
--]]------------------------------------------------
-- util library
@ -163,7 +163,7 @@ function loveframes.util.GetDirContents(dir, t)
if isdir == true then
table.insert(dirs, dir.. "/" ..v)
else
local parts = loveframes.util.SplitSring(v, "([.])")
local parts = loveframes.util.SplitString(v, "([.])")
local extension = parts[#parts]
local name = restore(parts)
table.insert(t, {path = dir, fullpath = dir.. "/" ..v, name = name, extension = extension})
@ -195,11 +195,11 @@ function loveframes.util.Round(num, idp)
end
--[[---------------------------------------------------------
- func: SplitSring(string, pattern)
- func: SplitString(string, pattern)
- desc: splits a string into a table based on a given pattern
- 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