Version 0.9.2 - Alpha (see changelog.txt)

This commit is contained in:
Kenny Shields 2012-05-22 03:10:18 -04:00
parent 834b7a1d48
commit e16001022c
34 changed files with 1361 additions and 740 deletions

View File

@ -1,3 +1,25 @@
================================================
Version 0.9.2 - Alpha (May 22 - 2012)
================================================
[ADDED] a new slider method: SetButtonSize(width, height)
[ADDED] a new slider method: GetButtonSize()
[ADDED] a new slider method: SetSlideType(slidetype)
[ADDED] a new slider button method: MoveToY(y)
[REMOVED] slider method: SetButtonYCenter(y)
[REMOVED] slider method: GetButtonYCenter()
[FIXED] the column list row object not setting it's text's font to it's font
[FIXED] a small graient error in the default skins
[FIXED] an error that caused tab buttons to be overscrolled with the middle mouse button
[FIXED] the scroll area object not moving it's base parent to the top when clicked (only in situatuions where it'sbase parent was a frame)
[CHANGED] sliders no longer use ycenter for button positioning
[CHANGED] slider functionality, sliders can now be horizontal or vertical (use slider:SetSlideType("horizontal" or "vertical"))
[CHANGED] lots of code for optimization and general cleanliness
[CHANGED] a few minor things in the default skins
[CHANGED] scrollbar hover behavior when being moved via it's scroll area being clicked (will no longer auto hover when it reaches the mouse position)
================================================ ================================================
Version 0.9.1.6 - Alpha (May 17 - 2012) Version 0.9.1.6 - Alpha (May 17 - 2012)
================================================ ================================================

View File

@ -323,7 +323,7 @@ function loveframes.debug.ExamplesMenu()
panel1:SetSize(490, 115) panel1:SetSize(490, 115)
local slider1 = loveframes.Create("slider", panel1) local slider1 = loveframes.Create("slider", panel1)
slider1:SetPos(5, 5) slider1:SetPos(5, 20)
slider1:SetWidth(480) slider1:SetWidth(480)
slider1:SetMinMax(0, 100) slider1:SetMinMax(0, 100)
slider1:SetText("Padding") slider1:SetText("Padding")
@ -332,8 +332,20 @@ function loveframes.debug.ExamplesMenu()
list1:SetPadding(value) list1:SetPadding(value)
end end
local text1 = loveframes.Create("text", panel1)
text1:SetPos(5, 5)
text1:SetFont(love.graphics.newFont(10))
text1:SetText(slider1:GetText())
local text2 = loveframes.Create("text", panel1)
text2:SetFont(love.graphics.newFont(10))
text2.Update = function(object, dt)
object:SetPos(slider1:GetWidth() - object:GetWidth(), 5)
object:SetText(slider1:GetValue())
end
local slider2 = loveframes.Create("slider", panel1) local slider2 = loveframes.Create("slider", panel1)
slider2:SetPos(5, 45) slider2:SetPos(5, 60)
slider2:SetWidth(480) slider2:SetWidth(480)
slider2:SetMinMax(0, 100) slider2:SetMinMax(0, 100)
slider2:SetText("Spacing") slider2:SetText("Spacing")
@ -342,6 +354,18 @@ function loveframes.debug.ExamplesMenu()
list1:SetSpacing(value) list1:SetSpacing(value)
end end
local text3 = loveframes.Create("text", panel1)
text3:SetPos(5, 45)
text3:SetFont(love.graphics.newFont(10))
text3:SetText(slider2:GetText())
local text4 = loveframes.Create("text", panel1)
text4:SetFont(love.graphics.newFont(10))
text4.Update = function(object, dt)
object:SetPos(slider2:GetWidth() - object:GetWidth(), 45)
object:SetText(slider2:GetValue())
end
local button1 = loveframes.Create("button", panel1) local button1 = loveframes.Create("button", panel1)
button1:SetPos(5, 85) button1:SetPos(5, 85)
button1:SetSize(480, 25) button1:SetSize(480, 25)
@ -441,14 +465,27 @@ function loveframes.debug.ExamplesMenu()
end end
local slider1 = loveframes.Create("slider", frame1) local slider1 = loveframes.Create("slider", frame1)
slider1:SetPos(5, 120) slider1:SetPos(5, 135)
slider1:SetWidth(490) slider1:SetWidth(490)
slider1:SetText("Progressbar lerp rate") slider1:SetText("Progressbar lerp rate")
slider1:SetMinMax(1, 50) slider1:SetMinMax(1, 50)
slider1:SetDecimals(0)
slider1.OnValueChanged = function(object2, value) slider1.OnValueChanged = function(object2, value)
progressbar1:SetLerpRate(value) progressbar1:SetLerpRate(value)
end end
local text1 = loveframes.Create("text", frame1)
text1:SetPos(5, 120)
text1:SetText("Lerp Rate")
text1:SetFont(love.graphics.newFont(10))
local text2 = loveframes.Create("text", frame1)
text2:SetFont(love.graphics.newFont(10))
text2.Update = function(object, dt)
object:SetPos(slider1:GetWidth() - object:GetWidth(), 120)
object:SetText(slider1:GetValue())
end
end end
exampleslist:AddItem(progressbarexample) exampleslist:AddItem(progressbarexample)
@ -461,7 +498,7 @@ function loveframes.debug.ExamplesMenu()
local frame1 = loveframes.Create("frame") local frame1 = loveframes.Create("frame")
frame1:SetName("Slider") frame1:SetName("Slider")
frame1:SetSize(300, 70) frame1:SetSize(300, 275)
frame1:Center() frame1:Center()
local slider1 = loveframes.Create("slider", frame1) local slider1 = loveframes.Create("slider", frame1)
@ -469,6 +506,16 @@ function loveframes.debug.ExamplesMenu()
slider1:SetWidth(290) slider1:SetWidth(290)
slider1:SetMinMax(0, 100) slider1:SetMinMax(0, 100)
local slider2 = loveframes.Create("slider", frame1)
slider2:SetPos(5, 60)
slider2:SetHeight(200)
slider2:SetMinMax(0, 100)
slider2:SetButtonSize(20, 10)
slider2:SetSlideType("vertical")
slider2.Update = function(object, dt)
object:CenterX()
end
end end
exampleslist:AddItem(sliderexample) exampleslist:AddItem(sliderexample)

View File

@ -9,7 +9,7 @@ loveframes = {}
-- library info -- library info
loveframes.info = {} loveframes.info = {}
loveframes.info.author = "Nikolai Resokav" loveframes.info.author = "Nikolai Resokav"
loveframes.info.version = "0.9.1.6" loveframes.info.version = "0.9.2"
loveframes.info.stage = "Alpha" loveframes.info.stage = "Alpha"
-- library configurations -- library configurations

View File

@ -30,7 +30,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:update(dt) function base:update(dt)
for k, v in ipairs(self.children) do local children = self.children
for k, v in ipairs(children) do
v:update(dt) v:update(dt)
end end
@ -42,10 +44,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:draw() function base:draw()
local children = self.children
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:draw() v:draw()
end end
@ -57,18 +61,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:mousepressed(x, y, button) function base:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
local children = self.children
local internals = self.internals
if visible == false then
return return
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
end end
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
end end
@ -81,18 +89,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:mousereleased(x, y, button) function base:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
local children = self.children
local internals = self.internals
if visible == false then
return return
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
end end
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
end end
@ -105,18 +117,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:keypressed(key, unicode) function base:keypressed(key, unicode)
if self.visible == false then local visible = self.visible
local children = self.children
local internals = self.internals
if visible == false then
return return
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:keypressed(key, unicode) v:keypressed(key, unicode)
end end
end end
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:keypressed(key, unicode) v:keypressed(key, unicode)
end end
end end
@ -129,18 +145,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:keyreleased(key) function base:keyreleased(key)
if self.visible == false then local visible = self.visible
local children = self.children
local internals = self.internals
if visible == false then
return return
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:keyreleased(key) v:keyreleased(key)
end end
end end
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:keyreleased(key) v:keyreleased(key)
end end
end end
@ -155,9 +175,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:SetPos(x, y) function base:SetPos(x, y)
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
self.x = x self.x = x
self.y = y self.y = y
else else
@ -173,9 +194,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:SetX(x) function base:SetX(x)
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
self.x = x self.x = x
else else
self.staticx = x self.staticx = x
@ -189,9 +211,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:SetY(y) function base:SetY(y)
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
self.y = y self.y = y
else else
self.staticy = y self.staticy = y
@ -266,9 +289,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:Center() function base:Center()
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
local width = love.graphics.getWidth() local width = love.graphics.getWidth()
local height = love.graphics.getHeight() local height = love.graphics.getHeight()
@ -290,9 +314,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:CenterX() function base:CenterX()
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
local width = love.graphics.getWidth() local width = love.graphics.getWidth()
self.x = width/2 - self.width/2 self.x = width/2 - self.width/2
else else
@ -308,9 +333,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:CenterY() function base:CenterY()
local base = loveframes.base
local parent = self.parent local parent = self.parent
if parent == loveframes.base then if parent == base then
local height = love.graphics.getHeight() local height = love.graphics.getHeight()
self.y = height/2 - self.height/2 self.y = height/2 - self.height/2
else else
@ -393,19 +419,15 @@ function base:SetVisible(bool)
self.visible = bool self.visible = bool
if children then if children then
for k, v in ipairs(children) do for k, v in ipairs(children) do
v:SetVisible(bool) v:SetVisible(bool)
end end
end end
if internals then if internals then
for k, v in ipairs(internals) do for k, v in ipairs(internals) do
v:SetVisible(bool) v:SetVisible(bool)
end end
end end
end end
@ -453,7 +475,6 @@ end
function base:GetParent() function base:GetParent()
local parent = self.parent local parent = self.parent
return parent return parent
end end
@ -464,22 +485,29 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:Remove() function base:Remove()
if self.parent.internals then local pinternals = self.parent.internals
local pchildren = self.parent.children
for k, v in ipairs(self.parent.internals) do if pinternals then
for k, v in ipairs(pinternals) do
if v == self then if v == self then
table.remove(self.parent.internals, k) table.remove(pinternals, k)
end end
end end
end end
for k, v in ipairs(self.parent.children) do if pchildren then
for k, v in ipairs(pchildren) do
if v == self then if v == self then
table.remove(self.parent.children, k) table.remove(pchildren, k)
end end
end end
end
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -489,16 +517,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:SetClickBounds(x, y, width, height) function base:SetClickBounds(x, y, width, height)
local internals = self.internals
local children = self.children
self.clickbounds = {x = x, y = y, width = width, height = height} self.clickbounds = {x = x, y = y, width = width, height = height}
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:SetClickBounds(x, y, width, height) v:SetClickBounds(x, y, width, height)
end end
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:SetClickBounds(x, y, width, height) v:SetClickBounds(x, y, width, height)
end end
end end
@ -523,16 +554,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:RemoveClickBounds() function base:RemoveClickBounds()
local internals = self.internals
local children = self.children
self.clickbounds = nil self.clickbounds = nil
if self.internals then if internals then
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:RemoveClickBounds() v:RemoveClickBounds()
end end
end end
if self.children then if children then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:RemoveClickBounds() v:RemoveClickBounds()
end end
end end
@ -550,14 +584,10 @@ function base:InClickBounds()
local bounds = self.clickbounds local bounds = self.clickbounds
if bounds then if bounds then
local col = loveframes.util.BoundingBox(x, bounds.x, y, bounds.y, 1, bounds.width, 1, bounds.height) local col = loveframes.util.BoundingBox(x, bounds.x, y, bounds.y, 1, bounds.width, 1, bounds.height)
return col return col
else else
return false return false
end end
end end
@ -575,11 +605,9 @@ function base:IsTopCollision()
-- loop through the object's parent's children -- loop through the object's parent's children
for k, v in ipairs(cols) do for k, v in ipairs(cols) do
if v.draworder > draworder then if v.draworder > draworder then
top = false top = false
end end
end end
return top return top
@ -593,11 +621,12 @@ end
function base:GetBaseParent(t) function base:GetBaseParent(t)
local t = t or {} local t = t or {}
local parent local base = loveframes.base
local parent = self.parent
if self.parent ~= loveframes.base then if parent ~= base then
table.insert(t, self.parent) table.insert(t, parent)
self.parent:GetBaseParent(t) parent:GetBaseParent(t)
end end
return t[#t] return t[#t]
@ -615,6 +644,7 @@ function base:CheckHover()
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local hoverobject = loveframes.hoverobject local hoverobject = loveframes.hoverobject
local modalobject = loveframes.modalobject local modalobject = loveframes.modalobject
local clickbounds = self.clickbounds
-- is the mouse inside the object? -- is the mouse inside the object?
if selfcol == true then if selfcol == true then
@ -635,7 +665,7 @@ function base:CheckHover()
self.hover = false self.hover = false
end end
if self.clickbounds then if clickbounds then
if self:InClickBounds() == false then if self:InClickBounds() == false then
self.hover = false self.hover = false
end end
@ -714,8 +744,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:GetChildren() function base:GetChildren()
if self.children then local children = self.children
return self.children
if children then
return children
end end
end end
@ -790,8 +822,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:MoveToTop() function base:MoveToTop()
local pchildren = self.parent.children
self:Remove() self:Remove()
table.insert(self.parent.children, self) table.insert(pchildren, self)
end end
@ -801,22 +835,21 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function base:SetSkin(name) function base:SetSkin(name)
local pchildren = self.parent.children
local pinternals = self.parent.internals
self.skin = name self.skin = name
if self.children then if pchildren then
for k, v in ipairs(pchildren) do
for k, v in ipairs(self.children) do
v:SetSkin(name) v:SetSkin(name)
end end
end end
if self.internals then if pinternals then
for k, v in ipairs(pinternals) do
for k, v in ipairs(self.internals) do
v:SetSkin(name) v:SetSkin(name)
end end
end end
end end
@ -881,9 +914,10 @@ end
function base:IsActive() function base:IsActive()
local parent = self.parent local parent = self.parent
local pchildren = parent.children
local valid = false local valid = false
for k, v in ipairs(parent.children) do for k, v in ipairs(pchildren) do
if v == self then if v == self then
valid = true valid = true
end end

View File

@ -31,23 +31,30 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function button:update(dt) function button:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.hover == false then local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
if hover == false then
self.down = false self.down = false
elseif self.hover == true then elseif hover == true then
if loveframes.hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if down == false and hoverobject == self then
self.hover = true self.hover = true
end end
@ -69,19 +76,21 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function button:draw() function button:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin local selfskin = self.skin
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin] local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
if self.Draw ~= nil then if self.Draw ~= nil then
self.Draw(self) self.Draw(self)
else else
@ -96,11 +105,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function button:mousepressed(x, y, button) function button:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -121,7 +134,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function button:mousereleased(x, y, button) function button:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end

View File

@ -34,8 +34,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:update(dt) function checkbox:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -97,19 +100,21 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:draw() function checkbox:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin local selfskin = self.skin
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin] local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
if self.Draw ~= nil then if self.Draw ~= nil then
self.Draw(self) self.Draw(self)
else else
@ -128,11 +133,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:mousepressed(x, y, button) function checkbox:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -153,7 +162,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:mousereleased(x, y, button) function checkbox:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -206,7 +217,6 @@ function checkbox:SetText(text)
self.width = self.boxwidth self.width = self.boxwidth
self.height = self.boxheight self.height = self.boxheight
self.internals = {} self.internals = {}
end end
@ -219,8 +229,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:GetText() function checkbox:GetText()
if self.internals[1] then local internals = self.internals
return self.internals[1].text local text = internals[1]
if text then
return text.text
else else
return false return false
end end
@ -288,10 +301,13 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function checkbox:SetFont(font) function checkbox:SetFont(font)
local internals = self.internals
local text = internals[1]
self.font = font self.font = font
if self.internals[1] then if text then
self.internals[1]:SetFont(font) text:SetFont(font)
end end
end end

View File

@ -33,12 +33,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:update(dt) function collapsiblecategory:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local open = self.open
local children = self.children
local curobject = children[1]
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
@ -47,13 +54,11 @@ function collapsiblecategory:update(dt)
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.open == true then if open == true then
for k, v in ipairs(self.children) do curobject:update(dt)
v:update(dt) curobject:SetWidth(self.width - self.padding*2)
v:SetWidth(self.width - self.padding*2) curobject.y = (curobject.parent.y + curobject.staticy)
v.y = (v.parent.y + v.staticy) curobject.x = (curobject.parent.x + curobject.staticx)
v.x = (v.parent.x + v.staticx)
end
end end
if self.Update then if self.Update then
@ -68,12 +73,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:draw() function collapsiblecategory:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1 local open = self.open
self.draworder = loveframes.drawcount local children = self.children
local curobject = children[1]
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
@ -81,16 +89,17 @@ function collapsiblecategory:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin] local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount
if self.Draw ~= nil then if self.Draw ~= nil then
self.Draw(self) self.Draw(self)
else else
skin.DrawCollapsibleCategory(self) skin.DrawCollapsibleCategory(self)
end end
if self.open == true then if open == true then
for k, v in ipairs(self.children) do curobject:draw()
v:draw()
end
end end
end end
@ -101,11 +110,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:mousepressed(x, y, button) function collapsiblecategory:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true then local hover = self.hover
local open = self.open
local children = self.children
local curobject = children[1]
if hover == true then
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
@ -124,12 +140,8 @@ function collapsiblecategory:mousepressed(x, y, button)
end end
if self.open == true then if open == true then
curobject:mousepressed(x, y, button)
for k, v in ipairs(self.children) do
v:mousepressed(x, y, button)
end
end end
end end
@ -140,7 +152,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:mousereleased(x, y, button) function collapsiblecategory:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -150,6 +164,8 @@ function collapsiblecategory:mousereleased(x, y, button)
local enabled = self.enabled local enabled = self.enabled
local open = self.open local open = self.open
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
local children = self.children
local curobject = children[1]
if hover == true and button == "l" and col == true and self.down == true then if hover == true and button == "l" and col == true and self.down == true then
@ -163,12 +179,8 @@ function collapsiblecategory:mousereleased(x, y, button)
end end
if self.open == true then if open == true then
curobject:mousepressed(x, y, button)
for k, v in ipairs(self.children) do
v:mousereleased(x, y, button)
end
end end
end end
@ -199,8 +211,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:SetObject(object) function collapsiblecategory:SetObject(object)
if self.children[1] then local children = self.children
self.children[1]:Remove() local curobject = children[1]
if curobject then
curobject:Remove()
self.children = {} self.children = {}
end end
@ -219,8 +234,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:GetObject() function collapsiblecategory:GetObject()
if self.children[1] then local children = self.children
return self.children[1] local curobject = children[1]
if curobject then
return curobject
else else
return false return false
end end
@ -273,17 +291,20 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function collapsiblecategory:SetOpen(bool) function collapsiblecategory:SetOpen(bool)
local children = self.children
local curobject = children[1]
self.open = bool self.open = bool
if bool == false then if bool == false then
self.height = self.closedheight self.height = self.closedheight
if self.children[1] then if curobject then
self.children[1]:SetVisible(false) curobject:SetVisible(false)
end end
else else
self.height = self.closedheight + self.padding*2 + self.children[1].height self.height = self.closedheight + self.padding*2 + curobject.height
if self.children[1] then if curobject then
self.children[1]:SetVisible(true) curobject:SetVisible(true)
end end
end end

View File

@ -34,12 +34,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:update(dt) function columnlist:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local children = self.children
local internals = self.internals
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
@ -48,11 +54,11 @@ function columnlist:update(dt)
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
@ -68,13 +74,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:draw() function columnlist:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
local children = self.children
local internals = self.internals
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -87,11 +98,11 @@ function columnlist:draw()
skin.DrawColumnList(self) skin.DrawColumnList(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:draw() v:draw()
end end
@ -103,7 +114,17 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:mousepressed(x, y, button) function columnlist:mousepressed(x, y, button)
if self.hover == true and button == "l" then local visible = self.visible
if visible == false then
return
end
local hover = self.hover
local children = self.children
local internals = self.internals
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -113,11 +134,11 @@ function columnlist:mousepressed(x, y, button)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -129,48 +150,25 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:mousereleased(x, y, button) function columnlist:mousereleased(x, y, button)
for k, v in ipairs(self.internals) do local visible = self.visible
if visible == false then
return
end
local children = self.children
local internals = self.internals
for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
end end
--[[---------------------------------------------------------
- func: keypressed(key)
- desc: called when the player presses a key
--]]---------------------------------------------------------
function columnlist:keypressed(key, unicode)
for k, v in ipairs(self.internals) do
v:keypressed(key, unicode)
end
for k, v in ipairs(self.children) do
v:keypressed(key, unicode)
end
end
--[[---------------------------------------------------------
- func: keyreleased(key)
- desc: called when the player releases a key
--]]---------------------------------------------------------
function columnlist:keyreleased(key)
for k, v in ipairs(self.internals) do
v:keyreleased(key)
end
for k, v in ipairs(self.children) do
v:keyreleased(key)
end
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: Adjustchildren() - func: Adjustchildren()
- desc: adjusts the width of the object's children - desc: adjusts the width of the object's children
@ -208,11 +206,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:AddColumn(name) function columnlist:AddColumn(name)
local internals = self.internals
local list = internals[1]
columnlistheader:new(name, self) columnlistheader:new(name, self)
self:AdjustColumns() self:AdjustColumns()
self.internals[1]:SetSize(self.width, self.height) list:SetSize(self.width, self.height)
self.internals[1]:SetPos(0, 0) list:SetPos(0, 0)
end end
@ -222,7 +223,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:AddRow(...) function columnlist:AddRow(...)
self.internals[1]:AddRow(arg) local internals = self.internals
local list = internals[1]
list:AddRow(arg)
end end
@ -232,8 +236,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:GetColumnSize() function columnlist:GetColumnSize()
if #self.children > 0 then local children = self.children
return self.children[1].width, self.children[1].height local numchildren = #self.children
local column = self.children[1]
local colwidth = column.width
local colheight = column.height
if numchildren > 0 then
return colwidth, colheight
else else
return 0, 0 return 0, 0
end end
@ -246,11 +256,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:SetSize(width, height) function columnlist:SetSize(width, height)
local internals = self.internals
local list = internals[1]
self.width = width self.width = width
self.height = height self.height = height
self.internals[1]:SetSize(width, height) list:SetSize(width, height)
self.internals[1]:SetPos(0, 0) list:SetPos(0, 0)
end end
@ -260,10 +273,13 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:SetWidth(width) function columnlist:SetWidth(width)
local internals = self.internals
local list = internals[1]
self.width = width self.width = width
self.internals[1]:SetSize(width) list:SetSize(width)
self.internals[1]:SetPos(0, 0) list:SetPos(0, 0)
end end
@ -273,10 +289,13 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:SetHeight(height) function columnlist:SetHeight(height)
local internals = self.internals
local list = internals[1]
self.height = height self.height = height
self.internals[1]:SetSize(height) list:SetSize(height)
self.internals[1]:SetPos(0, 0) list:SetPos(0, 0)
end end
@ -287,7 +306,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:SetMaxColorIndex(num) function columnlist:SetMaxColorIndex(num)
self.internals[1].colorindexmax = num local internals = self.internals
local list = internals[1]
list.colorindexmax = num
end end
@ -297,7 +319,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:Clear() function columnlist:Clear()
self.internals[1]:Clear() local internals = self.internals
local list = internals[1]
list:Clear()
end end
@ -309,10 +334,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlist:SetAutoScroll(bool) function columnlist:SetAutoScroll(bool)
local internals = self.internals
local list = internals[1]
self.autoscroll = bool self.autoscroll = bool
if self.internals[1]:GetScrollBar() ~= false then if list then
self.internals[1]:GetScrollBar().autoscroll = bool if list:GetScrollBar() ~= false then
list:GetScrollBar().autoscroll = bool
end
end end
end end

View File

@ -53,27 +53,39 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:update(dt) function frame:update(dt)
local x, y = love.mouse.getPosition() local visible = self.visible
local showclose = self.showclose local alwaysupdate = self.alwaysupdate
local close = self.internals[1]
if self.visible == false then if visible == false then
if self.alwaysupdate == false then if alwaysupdate == false then
return return
end end
end end
local x, y = love.mouse.getPosition()
local showclose = self.showclose
local close = self.internals[1]
local dragging = self.dragging
local screenlocked = self.screenlocked
local modal = self.modal
local base = loveframes.base
local basechildren = base.children
local numbasechildren = #basechildren
local draworder = self.draworder
local children = self.children
local internals = self.internals
close:SetPos(self.width - 22, 4) close:SetPos(self.width - 22, 4)
self:CheckHover() self:CheckHover()
-- dragging check -- dragging check
if self.dragging == true then if dragging == true then
self.x = x - self.clickx self.x = x - self.clickx
self.y = y - self.clicky self.y = y - self.clicky
end end
-- if screenlocked then keep within screen -- if screenlocked then keep within screen
if self.screenlocked == true then if screenlocked == true then
local width = love.graphics.getWidth() local width = love.graphics.getWidth()
local height = love.graphics.getHeight() local height = love.graphics.getHeight()
@ -93,28 +105,28 @@ function frame:update(dt)
end end
if self.modal == true then if modal == true then
local numtooltips = 0 local numtooltips = 0
for k, v in ipairs(loveframes.base.children) do for k, v in ipairs(basechildren) do
if v.type == "tooltip" then if v.type == "tooltip" then
numtooltips = numtooltips + 1 numtooltips = numtooltips + 1
end end
end end
if self.draworder ~= #loveframes.base.children - numtooltips then if draworder ~= numbasechildren - numtooltips then
self.modalbackground:MoveToTop() self.modalbackground:MoveToTop()
self:MoveToTop() self:MoveToTop()
end end
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
end end
@ -130,10 +142,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:draw() function frame:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local children = self.children
local internals = self.internals
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -149,12 +166,12 @@ function frame:draw()
skin.DrawFrame(self) skin.DrawFrame(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
-- loop through the object's children and draw them -- loop through the object's children and draw them
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:draw() v:draw()
end end
@ -166,13 +183,17 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:mousepressed(x, y, button) function frame:mousepressed(x, y, button)
local visible = self.visible
if visible == false then
return
end
local width = self.width local width = self.width
local height = self.height local height = self.height
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
local children = self.children
if self.visible == false then local internals = self.internals
return
end
if selfcol == true then if selfcol == true then
@ -193,11 +214,11 @@ function frame:mousepressed(x, y, button)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -209,20 +230,26 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:mousereleased(x, y, button) function frame:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local dragging = self.dragging
local children = self.children
local internals = self.internals
-- exit the dragging state -- exit the dragging state
if self.dragging == true then if dragging == true then
self.dragging = false self.dragging = false
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
@ -312,29 +339,30 @@ end
function frame:MakeTop() function frame:MakeTop()
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
local children = loveframes.base.children
local numchildren = #children
local key = 0 local key = 0
local base = loveframes.base
local basechildren = base.children
local numbasechildren = #basechildren
if numchildren == 1 then if numbasechildren == 1 then
return return
end end
if children[numchildren] == self then if basechildren[numbasechildren] == self then
return return
end end
-- make this the top element -- make this the top object
for k, v in ipairs(children) do for k, v in ipairs(basechildren) do
if v == self then if v == self then
table.remove(loveframes.base.children, k) table.remove(basechildren, k)
table.insert(loveframes.base.children, self) table.insert(basechildren, self)
key = k key = k
break break
end end
end end
loveframes.base.children[key]:mousepressed(x, y, "l") basechildren[key]:mousepressed(x, y, "l")
end end
@ -345,28 +373,31 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:SetModal(bool) function frame:SetModal(bool)
local modalobject = loveframes.modalobject
local mbackground = self.modalbackground
self.modal = bool self.modal = bool
if bool == true then if bool == true then
if loveframes.modalobject ~= false then if modalobject ~= false then
loveframes.modalobject:SetModal(false) modalobject:SetModal(false)
end end
loveframes.modalobject = self loveframes.modalobject = self
if self.modalbackground == false then if mbackground == false then
self.modalbackground = modalbackground:new(self) self.modalbackground = modalbackground:new(self)
self.modal = true self.modal = true
end end
else else
if loveframes.modalobject == self then if modalobject == self then
loveframes.modalobject = false loveframes.modalobject = false
if self.modalbackground ~= false then if mbackground ~= false then
self.modalbackground:Remove() self.modalbackground:Remove()
self.modalbackground = false self.modalbackground = false
self.modal = false self.modal = false
@ -395,14 +426,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function frame:SetVisible(bool) function frame:SetVisible(bool)
local children = self.children
local internals = self.internals
local closebutton = internals[1]
self.visible = bool self.visible = bool
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:SetVisible(bool) v:SetVisible(bool)
end end
if self.showclose == true then if self.showclose == true then
self.internals[1].visible = bool closebutton[1].visible = bool
end end
end end

View File

@ -28,8 +28,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function image:update(dt) function image:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -52,7 +55,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function image:draw() function image:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -94,8 +99,8 @@ end
- func: SetColor(table) - func: SetColor(table)
- desc: sets the object's color - desc: sets the object's color
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function image:SetColor(t) function image:SetColor(data)
self.imagecolor = t self.imagecolor = data
end end

View File

@ -32,23 +32,30 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function imagebutton:update(dt) function imagebutton:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.hover == false then local hover = self.hover
local hoverobject = loveframes.hoverobject
local down = self.down
if hover == false then
self.down = false self.down = false
elseif self.hover == true then elseif hover == true then
if loveframes.hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if down == false and hoverobject == self then
self.hover = true self.hover = true
end end
@ -70,7 +77,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function imagebutton:draw() function imagebutton:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -92,16 +101,20 @@ function imagebutton:draw()
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: mousepressed(x, y, imagebutton) - func: mousepressed(x, y, button)
- desc: called when the player presses a mouse imagebutton - desc: called when the player presses a mouse button
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function imagebutton:mousepressed(x, y, imagebutton) function imagebutton:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and imagebutton == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -117,12 +130,14 @@ function imagebutton:mousepressed(x, y, imagebutton)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: mousereleased(x, y, imagebutton) - func: mousereleased(x, y, button)
- desc: called when the player releases a mouse imagebutton - desc: called when the player releases a mouse button
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function imagebutton:mousereleased(x, y, imagebutton) function imagebutton:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -233,9 +248,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function imagebutton:SizeToImage() function imagebutton:SizeToImage()
if self.image then local image = self.image
self.width = self.image:getWidth()
self.height = self.image:getHeight() if image then
self.width = image:getWidth()
self.height = image:getHeight()
end end
end end

View File

@ -29,23 +29,30 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function closebutton:update(dt) function closebutton:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.hover == false then local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
if hover == false then
self.down = false self.down = false
elseif self.hover == true then elseif hover == true then
if loveframes.hoverobject == self then if loveframes.hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if down == false and hoverobject == self then
self.hover = true self.hover = true
end end
@ -67,7 +74,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function closebutton:draw() function closebutton:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -94,11 +103,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function closebutton:mousepressed(x, y, button) function closebutton:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -119,11 +132,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function closebutton:mousereleased(x, y, button) function closebutton:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and self.down == true then local hover = self.hover
if hover == true and self.down == true then
if button == "l" then if button == "l" then
self.OnClick(x, y, self) self.OnClick(x, y, self)

View File

@ -38,8 +38,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistarea:update(dt) function columnlistarea:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -79,7 +82,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistarea:draw() function columnlistarea:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end

View File

@ -16,7 +16,7 @@ function columnlistrow:initialize(parent, data)
self.type = "columnlistrow" self.type = "columnlistrow"
self.parent = parent self.parent = parent
self.colorindex = self.parent.rowcolorindex self.colorindex = self.parent.rowcolorindex
self.font = love.graphics.newFont(12) self.font = love.graphics.newFont(10)
self.textcolor = {0, 0, 0, 255} self.textcolor = {0, 0, 0, 255}
self.width = 80 self.width = 80
self.height = 25 self.height = 25
@ -33,8 +33,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistrow:update(dt) function columnlistrow:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -59,7 +62,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistrow:draw() function columnlistrow:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -83,6 +88,7 @@ function columnlistrow:draw()
local textcolor = self.textcolor local textcolor = self.textcolor
for k, v in ipairs(self.columndata) do for k, v in ipairs(self.columndata) do
love.graphics.setFont(self.font)
love.graphics.setColor(unpack(textcolor)) love.graphics.setColor(unpack(textcolor))
love.graphics.print(v, self.x + x, self.y + self.texty) love.graphics.print(v, self.x + x, self.y + self.texty)
x = x + cwidth x = x + cwidth

View File

@ -52,8 +52,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistheader:update(dt) function columnlistheader:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -90,7 +93,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function columnlistheader:draw() function columnlistheader:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end

View File

@ -3,7 +3,7 @@
-- By Nikolai Resokav -- -- By Nikolai Resokav --
--]]------------------------------------------------ --]]------------------------------------------------
-- panel class -- modalbackground class
modalbackground = class("modalbackground", base) modalbackground = class("modalbackground", base)
modalbackground:include(loveframes.templates.default) modalbackground:include(loveframes.templates.default)
@ -36,13 +36,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function modalbackground:update(dt) function modalbackground:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
if self.object:IsActive() == false then local object = self.object
if object:IsActive() == false then
self:Remove() self:Remove()
loveframes.modalobject = false loveframes.modalobject = false
end end

View File

@ -49,8 +49,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicelist:update(dt) function multichoicelist:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -93,11 +96,6 @@ function multichoicelist:update(dt)
v.x = (v.parent.x + v.staticx) - self.offsetx v.x = (v.parent.x + v.staticx) - self.offsetx
end end
--if loveframes.base.children[#loveframes.base.children] ~= self then
-- self:Remove()
-- table.insert(loveframes.base.children, self)
--end
if self.Update then if self.Update then
self.Update(self, dt) self.Update(self, dt)
end end

View File

@ -30,8 +30,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicerow:update(dt) function multichoicerow:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -68,6 +71,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoicerow:draw() function multichoicerow:draw()
local visible = self.visible
if visible == false then
return
end
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount

View File

@ -6,6 +6,10 @@
-- scrollbar class -- scrollbar class
scrollarea = class("scrollarea", base) scrollarea = class("scrollarea", base)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function scrollarea:initialize(parent, bartype) function scrollarea:initialize(parent, bartype)
self.type = "scroll-area" self.type = "scroll-area"
@ -23,10 +27,17 @@ function scrollarea:initialize(parent, bartype)
end end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function scrollarea:update(dt) function scrollarea:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -39,49 +50,59 @@ function scrollarea:update(dt)
self:CheckHover() self:CheckHover()
if self.parent.internals[2] then local parent = self.parent
local pinternals = parent.internals
if self.bartype == "vertical" then local button = pinternals[2]
self.staticx = 0 local bartype = self.bartype
self.staticy = self.parent.internals[2].height - 1
self.width = self.parent.width
self.height = self.parent.height - self.parent.internals[2].height*2 + 2
elseif self.bartype == "horizontal" then
self.staticx = self.parent.internals[2].width - 1
self.staticy = 0
self.width = self.parent.width - self.parent.internals[2].width*2 + 2
self.height = self.parent.height
end
end
local time = love.timer.getTime() local time = love.timer.getTime()
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
local listo = self.parent.parent local listo = parent.parent
local down = self.down
local scrolldelay = self.scrolldelay
local delayamount = self.delayamount
local internals = self.internals
local bar = internals[1]
local hover = self.hover
if self.down == true then if button then
if self.scrolldelay < time then
self.scrolldelay = time + self.delayamount if bartype == "vertical" then
self.staticx = 0
self.staticy = button.height - 1
self.width = parent.width
self.height = parent.height - button.height*2 + 2
elseif bartype == "horizontal" then
self.staticx = button.width - 1
self.staticy = 0
self.width = parent.width - button.width*2 + 2
self.height = parent.height
end
end
if down == true then
if scrolldelay < time then
self.scrolldelay = time + delayamount
if listo.display == "vertical" then if listo.display == "vertical" then
if y > self.internals[1].y then if y > bar.y then
self.internals[1]:Scroll(self.internals[1].height) bar:Scroll(bar.height)
else else
self.internals[1]:Scroll(-self.internals[1].height) bar:Scroll(-bar.height)
end end
elseif listo.display == "horizontal" then elseif listo.display == "horizontal" then
if x > self.internals[1].x then if x > bar.x then
self.internals[1]:Scroll(self.internals[1].width) bar:Scroll(bar.width)
else else
self.internals[1]:Scroll(-self.internals[1].width) bar:Scroll(-bar.width)
end end
end end
end end
if self.hover == false then if hover == false then
self.down = false self.down = false
end end
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
@ -91,12 +112,20 @@ function scrollarea:update(dt)
end end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function scrollarea:draw() function scrollarea:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local internals = self.internals
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -112,56 +141,84 @@ function scrollarea:draw()
skin.DrawScrollArea(self) skin.DrawScrollArea(self)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
end end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function scrollarea:mousepressed(x, y, button) function scrollarea:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local listo = self.parent.parent local listo = self.parent.parent
local time = love.timer.getTime() local time = love.timer.getTime()
local internals = self.internals
local bar = internals[1]
local hover = self.hover
local delayamount = self.delayamount
if self.hover == true and button == "l" then if hover == true and button == "l" then
self.down = true self.down = true
self.scrolldelay = time + self.delayamount + 0.5 self.scrolldelay = time + delayamount + 0.5
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
if listo.display == "vertical" then if listo.display == "vertical" then
if y > self.internals[1].y then if y > self.internals[1].y then
self.internals[1]:Scroll(self.internals[1].height) bar:Scroll(bar.height)
else else
self.internals[1]:Scroll(-self.internals[1].height) bar:Scroll(-bar.height)
end end
elseif listo.display == "horizontal" then elseif listo.display == "horizontal" then
if x > self.internals[1].x then if x > bar.x then
self.internals[1]:Scroll(self.internals[1].width) bar:Scroll(bar.width)
else else
self.internals[1]:Scroll(-self.internals[1].width) bar:Scroll(-bar.width)
end
end end
end end
for k, v in ipairs(self.internals) do loveframes.hoverobject = self
end
for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
end end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function scrollarea:mousereleased(x, y, button) function scrollarea:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local internals = self.internals
if button == "l" then if button == "l" then
self.down = false self.down = false
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end

View File

@ -6,6 +6,10 @@
-- scrollbar class -- scrollbar class
scrollbar = class("scrollbar", base) scrollbar = class("scrollbar", base)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function scrollbar:initialize(parent, bartype) function scrollbar:initialize(parent, bartype)
self.type = "scrollbar" self.type = "scrollbar"
@ -40,23 +44,32 @@ function scrollbar:initialize(parent, bartype)
end end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function scrollbar:update(dt) function scrollbar:update(dt)
local x, y = love.mouse.getPosition() local visible = self.visible
local bartype = self.bartype local alwaysupdate = self.alwaysupdate
local cols, basecols = {}, {}
if self.visible == false then if visible == false then
if self.alwaysupdate == false then if alwaysupdate == false then
return return
end end
end end
self:CheckHover() self:CheckHover()
if self.bartype == "vertical" then local x, y = love.mouse.getPosition()
local bartype = self.bartype
local cols = {}
local basecols = {}
local dragging = self.dragging
if bartype == "vertical" then
self.width = self.parent.width self.width = self.parent.width
elseif self.bartype == "horizontal" then elseif bartype == "horizontal" then
self.height = self.parent.height self.height = self.parent.height
end end
@ -76,7 +89,7 @@ function scrollbar:update(dt)
self.x = parent.x + parent.width - self.width self.x = parent.x + parent.width - self.width
self.y = parent.y + self.staticy self.y = parent.y + self.staticy
if self.dragging == true then if dragging == true then
if self.staticy ~= self.lasty then if self.staticy ~= self.lasty then
if listo.OnScroll then if listo.OnScroll then
listo.OnScroll(listo) listo.OnScroll(listo)
@ -90,6 +103,8 @@ function scrollbar:update(dt)
local remaining = (0 + self.staticy) local remaining = (0 + self.staticy)
local percent = remaining/space local percent = remaining/space
local extra = listo.extra * percent local extra = listo.extra * percent
local autoscroll = self.autoscroll
local lastheight = self.lastheight
listo.offsety = 0 + extra listo.offsety = 0 + extra
@ -103,8 +118,8 @@ function scrollbar:update(dt)
listo.offsety = 0 listo.offsety = 0
end end
if self.autoscroll == true then if autoscroll == true then
if listo.itemheight ~= self.lastheight then if listo.itemheight ~= lastheight then
self.lastheight = listo.itemheight self.lastheight = listo.itemheight
self:Scroll(self.maxy) self:Scroll(self.maxy)
end end
@ -128,7 +143,7 @@ function scrollbar:update(dt)
self.x = parent.x + self.staticx self.x = parent.x + self.staticx
self.y = parent.y + self.staticy self.y = parent.y + self.staticy
if self.dragging == true then if dragging == true then
if self.staticx ~= self.lastx then if self.staticx ~= self.lastx then
if listo.OnScroll then if listo.OnScroll then
listo.OnScroll(listo) listo.OnScroll(listo)
@ -142,6 +157,8 @@ function scrollbar:update(dt)
local remaining = (0 + self.staticx) local remaining = (0 + self.staticx)
local percent = remaining/space local percent = remaining/space
local extra = listo.extra * percent local extra = listo.extra * percent
local autoscroll = self.autoscroll
local lastwidth = self.lastwidth
listo.offsetx = 0 + extra listo.offsetx = 0 + extra
@ -155,8 +172,8 @@ function scrollbar:update(dt)
listo.offsetx = 0 listo.offsetx = 0
end end
if self.autoscroll == true then if autoscroll == true then
if self.width ~= self.lastwidth then if self.width ~= lastwidth then
self.width = self.width self.width = self.width
self:Scroll(self.maxx) self:Scroll(self.maxx)
end end
@ -170,9 +187,15 @@ function scrollbar:update(dt)
end end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function scrollbar:draw() function scrollbar:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -193,13 +216,20 @@ function scrollbar:draw()
end end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function scrollbar:mousepressed(x, y, button) function scrollbar:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
local hover = self.hover
if visible == false then
return return
end end
if self.hover == false then if hover == false then
return return
end end
@ -209,7 +239,9 @@ function scrollbar:mousepressed(x, y, button)
baseparent:MakeTop() baseparent:MakeTop()
end end
if self.dragging == false then local dragging = self.dragging
if dragging == false then
if button == "l" then if button == "l" then
@ -226,9 +258,15 @@ function scrollbar:mousepressed(x, y, button)
end end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function scrollbar:mousereleased(x, y, button) function scrollbar:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -238,18 +276,30 @@ function scrollbar:mousereleased(x, y, button)
end end
--[[---------------------------------------------------------
- func: SetMaxX(x)
- desc: sets the object's max x position
--]]---------------------------------------------------------
function scrollbar:SetMaxX(x) function scrollbar:SetMaxX(x)
self.maxx = x self.maxx = x
end end
--[[---------------------------------------------------------
- func: SetMaxY(y)
- desc: sets the object's max y position
--]]---------------------------------------------------------
function scrollbar:SetMaxY(y) function scrollbar:SetMaxY(y)
self.maxy = y self.maxy = y
end end
--[[---------------------------------------------------------
- func: Scroll(amount)
- desc: scrolls the object
--]]---------------------------------------------------------
function scrollbar:Scroll(amount) function scrollbar:Scroll(amount)
local bartype = self.bartype local bartype = self.bartype

View File

@ -6,6 +6,10 @@
-- scrollbar class -- scrollbar class
scrollbody = class("scrollbody", base) scrollbody = class("scrollbody", base)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function scrollbody:initialize(parent, bartype) function scrollbody:initialize(parent, bartype)
self.type = "scroll-body" self.type = "scroll-body"
@ -86,6 +90,10 @@ function scrollbody:initialize(parent, bartype)
end end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function scrollbody:update(dt) function scrollbody:update(dt)
if self.visible == false then if self.visible == false then
@ -112,6 +120,10 @@ function scrollbody:update(dt)
end end
--[[---------------------------------------------------------
- func: draw()
- desc: draws the object
--]]---------------------------------------------------------
function scrollbody:draw() function scrollbody:draw()
if self.visible == false then if self.visible == false then
@ -138,27 +150,3 @@ function scrollbody:draw()
end end
end end
function scrollbody:mousepressed(x, y, button)
if self.visible == false then
return
end
for k, v in ipairs(self.internals) do
v:mousepressed(x, y, button)
end
end
function scrollbody:mousereleased(x, y, button)
if self.visible == false then
return
end
for k, v in ipairs(self.internals) do
v:mousereleased(x, y, button)
end
end

View File

@ -20,14 +20,14 @@ function sliderbutton:initialize(parent)
self.staticy = 0 self.staticy = 0
self.startx = 0 self.startx = 0
self.clickx = 0 self.clickx = 0
self.starty = 0
self.clicky = 0
self.intervals = true self.intervals = true
self.internal = true self.internal = true
self.down = false self.down = false
self.dragging = false self.dragging = false
self.parent = parent self.parent = parent
self:SetY(self.parent.ycenter - self.height/2)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -36,26 +36,38 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function sliderbutton:update(dt) function sliderbutton:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local x, y = love.mouse.getPosition()
local intervals = self.intervals
self:CheckHover() self:CheckHover()
if self.hover == false then local x, y = love.mouse.getPosition()
local intervals = self.intervals
local progress = 0
local nvalue = 0
local pvalue = 0
local hover = self.hover
local down = self.down
local hoverobject = loveframes.hoverobject
local parent = self.parent
local slidetype = parent.slidetype
local dragging = self.dragging
if hover == false then
self.down = false self.down = false
elseif self.hover == true then elseif hover == true then
if loveframes.hoverobject == self then if hoverobject == self then
self.down = true self.down = true
end end
end end
if self.down == false and loveframes.hoverobject == self then if down == false and hoverobject == self then
self.hover = true self.hover = true
end end
@ -65,7 +77,9 @@ function sliderbutton:update(dt)
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.dragging == true then if slidetype == "horizontal" then
if dragging == true then
self.staticx = self.startx + (x - self.clickx) self.staticx = self.startx + (x - self.clickx)
end end
@ -77,9 +91,29 @@ function sliderbutton:update(dt)
self.staticx = 0 self.staticx = 0
end end
local progress = loveframes.util.Round(self.staticx/(self.parent.width - self.width), 5) progress = loveframes.util.Round(self.staticx/(self.parent.width - self.width), 5)
local nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
local pvalue = self.parent.value pvalue = self.parent.value
elseif slidetype == "vertical" then
if dragging == true then
self.staticy = self.starty + (y - self.clicky)
end
if (self.staticy + self.height) > self.parent.height then
self.staticy = self.parent.height - self.height
end
if self.staticy < 0 then
self.staticy = 0
end
progress = loveframes.util.Round(self.staticy/(self.parent.height - self.height), 5)
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
pvalue = self.parent.value
end
if nvalue ~= pvalue then if nvalue ~= pvalue then
self.parent.value = loveframes.util.Round(nvalue, self.parent.decimals) self.parent.value = loveframes.util.Round(nvalue, self.parent.decimals)
@ -88,6 +122,10 @@ function sliderbutton:update(dt)
end end
end end
if dragging == true then
loveframes.hoverobject = self
end
if self.Update then if self.Update then
self.Update(self, dt) self.Update(self, dt)
end end
@ -100,7 +138,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function sliderbutton:draw() function sliderbutton:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -127,11 +167,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function sliderbutton:mousepressed(x, y, button) function sliderbutton:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -143,6 +187,8 @@ function sliderbutton:mousepressed(x, y, button)
self.dragging = true self.dragging = true
self.startx = self.staticx self.startx = self.staticx
self.clickx = x self.clickx = x
self.starty = self.staticy
self.clicky = y
loveframes.hoverobject = self loveframes.hoverobject = self
end end
@ -155,7 +201,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function sliderbutton:mousereleased(x, y, button) function sliderbutton:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -164,8 +212,22 @@ function sliderbutton:mousereleased(x, y, button)
end end
--[[---------------------------------------------------------
- func: MoveToX(x)
- desc: moves the object to the specified x position
--]]---------------------------------------------------------
function sliderbutton:MoveToX(x) function sliderbutton:MoveToX(x)
self.staticx = x self.staticx = x
end end
--[[---------------------------------------------------------
- func: MoveToY(x)
- desc: moves the object to the specified y position
--]]---------------------------------------------------------
function sliderbutton:MoveToY(y)
self.staticy = y
end

View File

@ -43,8 +43,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabbutton:update(dt) function tabbutton:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -108,12 +111,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabbutton:mousepressed(x, y, button) function tabbutton:mousepressed(x, y, button)
local visible = self.visible
if self.visible == false then if visible == false then
return return
end end
if self.hover == true and button == "l" then local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -134,16 +140,20 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabbutton:mousereleased(x, y, button) function tabbutton:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local pinternals = self.parent.internals local hover = self.hover
local parent = self.parent
local tabnumber = self.tabnumber
if self.hover == true and self.down == true then if hover == true and button == "l" then
if button == "l" then if button == "l" then
self.parent:SwitchToTab(self.tabnumber) parent:SwitchToTab(tabnumber)
end end
end end

View File

@ -45,14 +45,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tooltip:update(dt) function tooltip:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
self.width = self.text.width + self.padding*2 local text = self.text
self.height = self.text.height + self.padding*2
self.width = text.width + self.padding*2
self.height = text.height + self.padding*2
local object = self.object local object = self.object
local draworder = self.draworder local draworder = self.draworder
@ -82,7 +87,7 @@ function tooltip:update(dt)
self:MoveToTop() self:MoveToTop()
end end
self.text:SetPos(self.padding, self.padding) text:SetPos(self.padding, self.padding)
end end
@ -93,7 +98,7 @@ function tooltip:update(dt)
end end
self.text:update(dt) text:update(dt)
if self.Update then if self.Update then
self.Update(self, dt) self.Update(self, dt)
@ -107,20 +112,25 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tooltip:draw() function tooltip:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
local show = self.show
local text = self.text
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
local selfskin = self.skin local selfskin = self.skin
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin] local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
if self.show == true then if show == true then
if self.Draw ~= nil then if self.Draw ~= nil then
self.Draw(self) self.Draw(self)
@ -128,36 +138,12 @@ function tooltip:draw()
skin.DrawToolTip(self) skin.DrawToolTip(self)
end end
self.text:draw() text:draw()
end end
end end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function tooltip:mousepressed(x, y, button)
if self.visible == false then
return
end
end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function tooltip:mousereleased(x, y, button)
if self.visible == false then
return
end
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetFollowCursor(bool) - func: SetFollowCursor(bool)
- desc: sets whether or not the tooltip should follow the - desc: sets whether or not the tooltip should follow the

View File

@ -40,12 +40,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:update(dt) function list:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local internals = self.internals
local children = self.children
local display = self.display
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if self.parent ~= loveframes.base then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
@ -54,17 +61,17 @@ function list:update(dt)
self:CheckHover() self:CheckHover()
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
v:SetClickBounds(self.x, self.y, self.width, self.height) v:SetClickBounds(self.x, self.y, self.width, self.height)
v.y = (v.parent.y + v.staticy) - self.offsety v.y = (v.parent.y + v.staticy) - self.offsety
v.x = (v.parent.x + v.staticx) - self.offsetx v.x = (v.parent.x + v.staticx) - self.offsetx
if self.display == "vertical" then if display == "vertical" then
if v.lastheight ~= v.height then if v.lastheight ~= v.height then
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -85,13 +92,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:draw() function list:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
local internals = self.internals
local children = self.children
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -109,7 +121,7 @@ function list:draw()
love.graphics.setStencil(stencil) love.graphics.setStencil(stencil)
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height) local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
if col == true then if col == true then
v:draw() v:draw()
@ -118,7 +130,7 @@ function list:draw()
love.graphics.setStencil() love.graphics.setStencil()
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
@ -134,13 +146,20 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:mousepressed(x, y, button) function list:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local toplist = self:IsTopList() local toplist = self:IsTopList()
local hover = self.hover
local vbar = self.vbar
local hbar = self.hbar
local children = self.children
local internals = self.internals
if self.hover == true and button == "l" then if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -150,7 +169,7 @@ function list:mousepressed(x, y, button)
end end
if self.vbar == true or self.hbar == true then if vbar == true or hbar == true then
if toplist == true then if toplist == true then
@ -166,36 +185,16 @@ function list:mousepressed(x, y, button)
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
end end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function list:mousereleased(x, y, button)
if self.visible == false then
return
end
for k, v in ipairs(self.internals) do
v:mousereleased(x, y, button)
end
for k, v in ipairs(self.children) do
v:mousereleased(x, y, button)
end
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: AddItem(object) - func: AddItem(object)
- desc: adds an item to the object - desc: adds an item to the object
@ -206,10 +205,12 @@ function list:AddItem(object)
return return
end end
local children = self.children
object:Remove() object:Remove()
object.parent = self object.parent = self
table.insert(self.children, object) table.insert(children, object)
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -223,7 +224,6 @@ end
function list:RemoveItem(object) function list:RemoveItem(object)
object:Remove() object:Remove()
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -245,6 +245,8 @@ function list:CalculateSize()
local display = self.display local display = self.display
local vbar = self.vbar local vbar = self.vbar
local hbar = self.hbar local hbar = self.hbar
local internals = self.internals
local children = self.children
if display == "vertical" then if display == "vertical" then
@ -254,13 +256,15 @@ function list:CalculateSize()
self.itemheight = (itemheight - spacing) + padding self.itemheight = (itemheight - spacing) + padding
if self.itemheight > height then local itemheight = self.itemheight
self.extra = self.itemheight - height if itemheight > height then
self.extra = itemheight - height
if vbar == false then if vbar == false then
local scrollbar = scrollbody:new(self, display) local scrollbar = scrollbody:new(self, display)
table.insert(self.internals, scrollbar) table.insert(internals, scrollbar)
self.vbar = true self.vbar = true
self:GetScrollBar().autoscroll = self.autoscroll self:GetScrollBar().autoscroll = self.autoscroll
end end
@ -268,7 +272,8 @@ function list:CalculateSize()
else else
if vbar == true then if vbar == true then
self.internals[1]:Remove() local bar = internals[1]
bar:Remove()
self.vbar = false self.vbar = false
self.offsety = 0 self.offsety = 0
end end
@ -277,19 +282,21 @@ function list:CalculateSize()
elseif display == "horizontal" then elseif display == "horizontal" then
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
itemwidth = itemwidth + v.width + spacing itemwidth = itemwidth + v.width + spacing
end end
self.itemwidth = (itemwidth - spacing) + padding self.itemwidth = (itemwidth - spacing) + padding
if self.itemwidth > width then local itemwidth = self.itemwidth
self.extra = self.itemwidth - width if itemwidth > width then
self.extra = itemwidth - width
if hbar == false then if hbar == false then
local scrollbar = scrollbody:new(self, display) local scrollbar = scrollbody:new(self, display)
table.insert(self.internals, scrollbar) table.insert(internals, scrollbar)
self.hbar = true self.hbar = true
self:GetScrollBar().autoscroll = self.autoscroll self:GetScrollBar().autoscroll = self.autoscroll
end end
@ -297,7 +304,8 @@ function list:CalculateSize()
else else
if hbar == true then if hbar == true then
self.internals[1]:Remove() local bar = internals[1]
bar:Remove()
self.hbar = false self.hbar = false
self.offsetx = 0 self.offsetx = 0
end end
@ -390,6 +398,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:SetDisplayType(type) function list:SetDisplayType(type)
local children = self.children
local numchildren = #children
self.display = type self.display = type
self.internals = {} self.internals = {}
@ -398,7 +409,7 @@ function list:SetDisplayType(type)
self.offsetx = 0 self.offsetx = 0
self.offsety = 0 self.offsety = 0
if #self.children > 0 then if numchildren > 0 then
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
end end
@ -421,9 +432,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:SetPadding(amount) function list:SetPadding(amount)
local children = self.children
local numchildren = #children
self.padding = amount self.padding = amount
if #self.children > 0 then if numchildren > 0 then
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
end end
@ -436,9 +450,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:SetSpacing(amount) function list:SetSpacing(amount)
local children = self.children
local numchildren = #children
self.spacing = amount self.spacing = amount
if #self.children > 0 then if numchildren > 0 then
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
end end
@ -464,7 +481,6 @@ end
function list:SetWidth(width) function list:SetWidth(width)
self.width = width self.width = width
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -477,7 +493,6 @@ end
function list:SetHeight(height) function list:SetHeight(height)
self.height = height self.height = height
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -491,7 +506,6 @@ function list:SetSize(width, height)
self.width = width self.width = width
self.height = height self.height = height
self:CalculateSize() self:CalculateSize()
self:RedoLayout() self:RedoLayout()
@ -503,16 +517,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function list:GetScrollBar() function list:GetScrollBar()
if self.vbar == true or self.hbar == true then local vbar = self.vbar
local hbar = self.hbar
if vbar == true or hbar == true then
local scrollbar = self.internals[1].internals[1].internals[1] local scrollbar = self.internals[1].internals[1].internals[1]
return scrollbar return scrollbar
else else
return false return false
end end
end end

View File

@ -33,8 +33,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:update(dt) function multichoice:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -59,7 +62,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:draw() function multichoice:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -86,11 +91,16 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:mousepressed(x, y, button) function multichoice:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and self.haslist == false and button == "l" then local hover = self.hover
local haslist = self.haslist
if hover == true and haslist == false and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -112,7 +122,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:mousereleased(x, y, button) function multichoice:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -124,7 +136,8 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function multichoice:AddChoice(choice) function multichoice:AddChoice(choice)
table.insert(self.choices, choice) local choices = self.choices
table.insert(choices, choice)
end end
@ -145,7 +158,6 @@ end
function multichoice:SelectChoice(choice) function multichoice:SelectChoice(choice)
self.choice = choice self.choice = choice
self.list:Close() self.list:Close()
if self.OnChoiceSelected then if self.OnChoiceSelected then

View File

@ -27,12 +27,17 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function panel:update(dt) function panel:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local children = self.children
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base and self.parent.type ~= "list" then if self.parent ~= loveframes.base and self.parent.type ~= "list" then
self.x = self.parent.x + self.staticx self.x = self.parent.x + self.staticx
@ -41,7 +46,7 @@ function panel:update(dt)
self:CheckHover() self:CheckHover()
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
end end
@ -57,10 +62,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function panel:draw() function panel:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local children = self.children
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -77,7 +86,7 @@ function panel:draw()
end end
-- loop through the object's children and draw them -- loop through the object's children and draw them
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:draw() v:draw()
end end
@ -89,11 +98,16 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function panel:mousepressed(x, y, button) function panel:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then local children = self.children
local hover = self.hover
if hover == true and button == "l" then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -103,7 +117,7 @@ function panel:mousepressed(x, y, button)
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
@ -115,11 +129,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function panel:mousereleased(x, y, button) function panel:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
local children = self.children
if visible == false then
return return
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end

View File

@ -37,8 +37,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function progressbar:update(dt) function progressbar:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
@ -49,6 +52,7 @@ function progressbar:update(dt)
local lerpto = self.lerpto local lerpto = self.lerpto
local lerpfrom = self.lerpfrom local lerpfrom = self.lerpfrom
local value = self.value local value = self.value
local completed = self.completed
self:CheckHover() self:CheckHover()
@ -102,7 +106,7 @@ function progressbar:update(dt)
end end
-- completion check -- completion check
if self.completed == false then if completed == false then
if self.value >= self.max then if self.value >= self.max then
self.completed = true self.completed = true
if self.OnComplete then if self.OnComplete then
@ -123,7 +127,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function progressbar:draw() function progressbar:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end

View File

@ -15,12 +15,12 @@ function slider:initialize()
self.type = "slider" self.type = "slider"
self.text = "Slider" self.text = "Slider"
self.width = 200 self.slidetype = "horizontal"
self.height = 35 self.width = 5
self.height = 5
self.max = 10 self.max = 10
self.min = 0 self.min = 0
self.value = 0 self.value = 0
self.ycenter = 25
self.decimals = 5 self.decimals = 5
self.internal = false self.internal = false
self.internals = {} self.internals = {}
@ -40,12 +40,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function slider:update(dt) function slider:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local internals = self.internals
local sliderbutton = internals[1]
self:CheckHover() self:CheckHover()
-- move to parent if there is a parent -- move to parent if there is a parent
@ -54,6 +60,14 @@ function slider:update(dt)
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if sliderbutton then
if self.slidetype == "horizontal" then
self.height = sliderbutton.height
elseif self.slidetype == "vertical" then
self.width = sliderbutton.width
end
end
-- update internals -- update internals
for k, v in ipairs(self.internals) do for k, v in ipairs(self.internals) do
v:update(dt) v:update(dt)
@ -71,10 +85,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function slider:draw() function slider:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local internals = self.internals
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
@ -91,7 +109,7 @@ function slider:draw()
end end
-- draw internals -- draw internals
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
@ -103,12 +121,16 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function slider:mousepressed(x, y, button) function slider:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true and button == "l" then if self.hover == true and button == "l" then
if self.slidetype == "horizontal" then
local xpos = x - self.x local xpos = x - self.x
local button = self.internals[1] local button = self.internals[1]
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -123,6 +145,24 @@ function slider:mousepressed(x, y, button)
button.startx = button.staticx button.startx = button.staticx
button.clickx = x button.clickx = x
elseif self.slidetype == "vertical" then
local ypos = y - self.y
local button = self.internals[1]
local baseparent = self:GetBaseParent()
if baseparent and baseparent.type == "frame" then
baseparent:MakeTop()
end
button:MoveToY(ypos)
button.down = true
button.dragging = true
button.starty = button.staticy
button.clicky = y
end
end end
@ -132,22 +172,6 @@ function slider:mousepressed(x, y, button)
end end
--[[---------------------------------------------------------
- func: mousereleased(x, y, button)
- desc: called when the player releases a mouse button
--]]---------------------------------------------------------
function slider:mousereleased(x, y, button)
if self.visible == false then
return
end
for k, v in ipairs(self.internals) do
v:mousereleased(x, y, button)
end
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetValue(value) - func: SetValue(value)
- desc: sets the object's value - desc: sets the object's value
@ -164,18 +188,22 @@ function slider:SetValue(value)
local decimals = self.decimals local decimals = self.decimals
local newval = loveframes.util.Round(value, decimals) local newval = loveframes.util.Round(value, decimals)
local internals = self.internals
-- set the new value -- set the new value
self.value = newval self.value = newval
-- slider button object -- slider button object
local button = self.internals[1] local sliderbutton = internals[1]
-- new position for the slider button
local xpos = self.width * (( newval - self.min ) / (self.max - self.min))
-- move the slider button to the new position -- move the slider button to the new position
button:MoveToX(xpos) if self.slidetype == "horizontal" then
local xpos = self.width * (( newval - self.min ) / (self.max - self.min))
sliderbutton:MoveToX(xpos)
elseif self.slidetype == "vertical" then
local ypos = self.height * (( newval - self.min ) / (self.max - self.min))
sliderbutton:MoveToY(ypos)
end
-- call OnValueChanged -- call OnValueChanged
if self.OnValueChanged then if self.OnValueChanged then
@ -255,28 +283,6 @@ function slider:GetMinMax()
end end
--[[---------------------------------------------------------
- func: SetButtonYCenter(y)
- desc: sets the object's y center for it's slider
button
--]]---------------------------------------------------------
function slider:SetButtonYCenter(y)
self.ycenter = y
end
--[[---------------------------------------------------------
- func: GetButtonYCenter()
- desc: get's the object's y center of it's slider
button
--]]---------------------------------------------------------
function slider:GetButtonYCenter()
return self.ycenter
end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetText(name) - func: SetText(name)
- desc: sets the objects's text - desc: sets the objects's text
@ -306,3 +312,46 @@ function slider:SetDecimals(decimals)
self.decimals = decimals self.decimals = decimals
end end
--[[---------------------------------------------------------
- func: SetButtonSize(width, height)
- desc: sets the objects's button size
--]]---------------------------------------------------------
function slider:SetButtonSize(width, height)
local internals = self.internals
local sliderbutton = self.internals[1]
if sliderbutton then
sliderbutton.width = width
sliderbutton.height = height
end
end
--[[---------------------------------------------------------
- func: GetButtonSize()
- desc: gets the objects's button size
--]]---------------------------------------------------------
function slider:GetButtonSize()
local internals = self.internals
local sliderbutton = self.internals[1]
if sliderbutton then
return sliderbutton.width, sliderbutton.height
else
return false
end
end
--[[---------------------------------------------------------
- func: SetSlideType(slidetype)
- desc: sets the objects's slide type
--]]---------------------------------------------------------
function slider:SetSlideType(slidetype)
self.slidetype = slidetype
end

View File

@ -38,6 +38,15 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:update(dt) function tabs:update(dt)
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return
end
end
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
local tabheight = self.tabheight local tabheight = self.tabheight
local padding = self.padding local padding = self.padding
@ -45,12 +54,10 @@ function tabs:update(dt)
local tabheight = self.tabheight local tabheight = self.tabheight
local padding = self.padding local padding = self.padding
local autosize = self.autosize local autosize = self.autosize
local children = self.children
if self.visible == false then local numchildren = #children
if self.alwaysupdate == false then local internals = self.internals
return local tab = self.tab
end
end
-- move to parent if there is a parent -- move to parent if there is a parent
if self.parent ~= loveframes.base then if self.parent ~= loveframes.base then
@ -60,13 +67,13 @@ function tabs:update(dt)
self:CheckHover() self:CheckHover()
if #self.children > 0 and self.tab == 0 then if numchildren > 0 and tab == 0 then
self.tab = 1 self.tab = 1
end end
local pos = 0 local pos = 0
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
if v.type == "tabbutton" then if v.type == "tabbutton" then
v.y = (v.parent.y + v.staticy) v.y = (v.parent.y + v.staticy)
@ -75,7 +82,7 @@ function tabs:update(dt)
end end
end end
for k, v in ipairs(self.children) do for k, v in ipairs(children) do
v:update(dt) v:update(dt)
v:SetPos(padding, tabheight + padding) v:SetPos(padding, tabheight + padding)
end end
@ -92,10 +99,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:draw() function tabs:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
local internals = self.internals
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
@ -117,7 +128,7 @@ function tabs:draw()
love.graphics.setStencil(stencil) love.graphics.setStencil(stencil)
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:draw() v:draw()
end end
@ -135,11 +146,20 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:mousepressed(x, y, button) function tabs:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
if self.hover == true then local children = self.children
local numchildren = #children
local tab = self.tab
local internals = self.internals
local numinternals = #internals
local hover = self.hover
if hover == true then
if button == "l" then if button == "l" then
@ -157,7 +177,7 @@ function tabs:mousepressed(x, y, button)
local buttonheight = self:GetHeightOfButtons() local buttonheight = self:GetHeightOfButtons()
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
local visible = self.internals[#self.internals - 1]:GetVisible() local visible = internals[numinternals - 1]:GetVisible()
if col == true and visible == true then if col == true and visible == true then
self.offsetx = self.offsetx + 5 self.offsetx = self.offsetx + 5
@ -172,24 +192,25 @@ function tabs:mousepressed(x, y, button)
local buttonheight = self:GetHeightOfButtons() local buttonheight = self:GetHeightOfButtons()
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1) local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
local visible = self.internals[#self.internals]:GetVisible() local visible = internals[numinternals]:GetVisible()
if col == true and visible == true then if col == true and visible == true then
self.offsetx = self.offsetx - 5
local bwidth = self:GetWidthOfButtons() local bwidth = self:GetWidthOfButtons()
if (self.offsetx + bwidth) < self.width then if (self.offsetx + bwidth) < self.width then
self.offsetx = bwidth - self.width self.offsetx = bwidth - self.width
else
self.offsetx = self.offsetx - 5
end end
end end
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousepressed(x, y, button) v:mousepressed(x, y, button)
end end
if #self.children > 0 then if numchildren > 0 then
self.children[self.tab]:mousepressed(x, y, button) children[tab]:mousepressed(x, y, button)
end end
end end
@ -200,16 +221,22 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:mousereleased(x, y, button) function tabs:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
local children = self.children
local numchildren = #children
local tab = self.tab
local internals = self.internals
if visible == false then
return return
end end
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
v:mousereleased(x, y, button) v:mousereleased(x, y, button)
end end
if #self.children > 0 then if numchildren > 0 then
self.children[self.tab]:mousereleased(x, y, button) children[tab]:mousereleased(x, y, button)
end end
end end
@ -223,6 +250,9 @@ function tabs:AddTab(name, object, tip, image)
local tabheight = self.tabheight local tabheight = self.tabheight
local padding = self.padding local padding = self.padding
local autosize = self.autosize local autosize = self.autosize
local retainsize = object.retainsize
local tabnumber = self.tabnumber
local internals = self.internals
object:Remove() object:Remove()
object.parent = self object.parent = self
@ -232,18 +262,18 @@ function tabs:AddTab(name, object, tip, image)
object:SetHeight(self.height - 35) object:SetHeight(self.height - 35)
table.insert(self.children, object) table.insert(self.children, object)
self.internals[self.tabnumber] = tabbutton:new(self, name, self.tabnumber, tip, image) internals[tabnumber] = tabbutton:new(self, name, tabnumber, tip, image)
self.internals[self.tabnumber].height = self.tabheight internals[tabnumber].height = self.tabheight
self.tabnumber = self.tabnumber + 1 self.tabnumber = tabnumber + 1
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
self:SwitchToTab(k) self:SwitchToTab(k)
break break
end end
self:AddScrollButtons() self:AddScrollButtons()
if autosize == true and object.retainsize == false then if autosize == true and retainsize == false then
object:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2) object:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2)
end end
@ -256,9 +286,11 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:AddScrollButtons() function tabs:AddScrollButtons()
for k, v in ipairs(self.internals) do local internals = self.internals
for k, v in ipairs(internals) do
if v.type == "scrollbutton" then if v.type == "scrollbutton" then
table.remove(self.internals, k) table.remove(internals, k)
end end
end end
@ -305,8 +337,8 @@ function tabs:AddScrollButtons()
end end
end end
table.insert(self.internals, leftbutton) table.insert(internals, leftbutton)
table.insert(self.internals, rightbutton) table.insert(internals, rightbutton)
end end
@ -317,8 +349,9 @@ end
function tabs:GetWidthOfButtons() function tabs:GetWidthOfButtons()
local width = 0 local width = 0
local internals = self.internals
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
if v.type == "tabbutton" then if v.type == "tabbutton" then
width = width + v.width width = width + v.width
end end
@ -344,12 +377,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:SwitchToTab(tabnumber) function tabs:SwitchToTab(tabnumber)
for k, v in ipairs(self.children) do local children = self.children
for k, v in ipairs(children) do
v.visible = false v.visible = false
end end
self.tab = tabnumber self.tab = tabnumber
self.children[self.tab].visible = true self.children[tabnumber].visible = true
end end
@ -359,12 +394,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:SetScrollButtonSize(width, height) function tabs:SetScrollButtonSize(width, height)
for k, v in ipairs(self.internals) do local internals = self.internals
for k, v in ipairs(internals) do
if v.type == "scrollbutton" then if v.type == "scrollbutton" then
v:SetSize(width, height) v:SetSize(width, height)
end end
end end
end end
@ -395,14 +430,14 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:SetTabHeight(height) function tabs:SetTabHeight(height)
local internals = self.internals
self.tabheight = height self.tabheight = height
for k, v in ipairs(self.internals) do for k, v in ipairs(internals) do
if v.type == "tabbutton" then if v.type == "tabbutton" then
v:SetHeight(self.tabheight) v:SetHeight(self.tabheight)
end end
end end
end end
@ -413,12 +448,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:SetToolTipFont(font) function tabs:SetToolTipFont(font)
for k, v in ipairs(self.internals) do local internals = self.internals
for k, v in ipairs(internals) do
if v.type == "tabbutton" and v.tooltip then if v.type == "tabbutton" and v.tooltip then
v.tooltip:SetFont(font) v.tooltip:SetFont(font)
end end
end end
end end

View File

@ -130,9 +130,7 @@ function text:SetText(t)
local parts = loveframes.util.SplitSring(v, " ") local parts = loveframes.util.SplitSring(v, " ")
for i, j in ipairs(parts) do for i, j in ipairs(parts) do
table.insert(self.text, {color = prevcolor, text = j}) table.insert(self.text, {color = prevcolor, text = j})
end end
end end
@ -215,12 +213,17 @@ function text:DrawText()
local lines = 0 local lines = 0
local totalwidth = 0 local totalwidth = 0
local prevtextwidth local prevtextwidth
local x = self.x
local y = self.y
for k, v in ipairs(textdata) do for k, v in ipairs(textdata) do
if type(v.text) == "string" then local text = v.text
local color = v.color
local width = font:getWidth(v.text) if type(text) == "string" then
local width = font:getWidth(text)
totalwidth = totalwidth + width totalwidth = totalwidth + width
if maxw > 0 then if maxw > 0 then
@ -243,8 +246,8 @@ function text:DrawText()
prevtextwidth = width prevtextwidth = width
love.graphics.setFont(font) love.graphics.setFont(font)
love.graphics.setColor(unpack(v.color)) love.graphics.setColor(unpack(color))
love.graphics.print(v.text, self.x + drawx, self.y + drawy) love.graphics.print(text, x + drawx, y + drawy)
else else
@ -255,8 +258,8 @@ function text:DrawText()
prevtextwidth = width prevtextwidth = width
love.graphics.setFont(font) love.graphics.setFont(font)
love.graphics.setColor(unpack(v.color)) love.graphics.setColor(unpack(color))
love.graphics.print(v.text, self.x + drawx, self.y) love.graphics.print(text, x + drawx, y)
end end
@ -332,10 +335,12 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function text:SetFont(font) function text:SetFont(font)
local original = self.original
self.font = font self.font = font
if self.original then if original then
self:SetText(self.original) self:SetText(original)
end end
end end

View File

@ -46,13 +46,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:update(dt) function textinput:update(dt)
if self.visible == false then local visible = self.visible
if self.alwaysupdate == false then local alwaysupdate = self.alwaysupdate
if visible == false then
if alwaysupdate == false then
return return
end end
end end
local time = love.timer.getTime() local time = love.timer.getTime()
local keydown = self.keydown
local unicode = self.unicode
self:CheckHover() self:CheckHover()
@ -62,9 +67,9 @@ function textinput:update(dt)
self.y = self.parent.y + self.staticy self.y = self.parent.y + self.staticy
end end
if self.keydown ~= "none" then if keydown ~= "none" then
if time > self.delay then if time > self.delay then
self:RunKey(self.keydown, self.unicode) self:RunKey(keydown, unicode)
self.delay = time + 0.02 self.delay = time + 0.02
end end
end end
@ -84,13 +89,21 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:draw() function textinput:draw()
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
loveframes.drawcount = loveframes.drawcount + 1 loveframes.drawcount = loveframes.drawcount + 1
self.draworder = loveframes.drawcount self.draworder = loveframes.drawcount
local font = self.font
local textcolor = self.textcolor
local text = self.text
local textx = self.textx
local texty = self.texty
-- skin variables -- skin variables
local index = loveframes.config["ACTIVESKIN"] local index = loveframes.config["ACTIVESKIN"]
local defaultskin = loveframes.config["DEFAULTSKIN"] local defaultskin = loveframes.config["DEFAULTSKIN"]
@ -107,9 +120,9 @@ function textinput:draw()
skin.DrawTextInput(self) skin.DrawTextInput(self)
end end
love.graphics.setFont(self.font) love.graphics.setFont(font)
love.graphics.setColor(unpack(self.textcolor)) love.graphics.setColor(unpack(textcolor))
love.graphics.print(self.text, self.textx, self.texty) love.graphics.print(text, textx, self.texty)
love.graphics.setStencil() love.graphics.setStencil()
@ -125,7 +138,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:mousepressed(x, y, button) function textinput:mousepressed(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -133,7 +148,9 @@ function textinput:mousepressed(x, y, button)
return return
end end
if self.hover == true then local hover = self.hover
if hover == true then
local baseparent = self:GetBaseParent() local baseparent = self:GetBaseParent()
@ -159,7 +176,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:mousereleased(x, y, button) function textinput:mousereleased(x, y, button)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -175,13 +194,16 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:keypressed(key, unicode) function textinput:keypressed(key, unicode)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
self.delay = love.timer.getTime() + 0.80 local time = love.timer.getTime()
self.keydown = key
self.delay = time + 0.80
self.keydown = key
self:RunKey(key, unicode) self:RunKey(key, unicode)
end end
@ -192,7 +214,9 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:keyreleased(key) function textinput:keyreleased(key)
if self.visible == false then local visible = self.visible
if visible == false then
return return
end end
@ -206,16 +230,10 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:RunKey(key, unicode) function textinput:RunKey(key, unicode)
local text = self.text local visible = self.visible
local ckey = "" local focus = self.focus
local font = self.font
local swidth = self.width
local twidth = font:getWidth(self.text)
local textxoffset = self.textxoffset
self.unicode = unicode if visible == false then
if self.visible == false then
return return
end end
@ -223,28 +241,39 @@ function textinput:RunKey(key, unicode)
return return
end end
local text = self.text
local ckey = ""
local font = self.font
local swidth = self.width
local twidth = font:getWidth(self.text)
local textxoffset = self.textxoffset
local blinkx = self.blinkx
local blinknum = self.blinknum
self.unicode = unicode
if key == "left" then if key == "left" then
self:MoveBlinker(-1) self:MoveBlinker(-1)
if self.blinkx <= self.x and self.blinknum ~= 0 then if blinkx <= self.x and blinknum ~= 0 then
local width = self.font:getWidth(self.text:sub(self.blinknum, self.blinknum + 1)) local width = self.font:getWidth(self.text:sub(blinknum, blinknum + 1))
self.xoffset = self.xoffset + width self.xoffset = self.xoffset + width
elseif self.blinknum == 0 and self.xoffset ~= 0 then elseif blinknum == 0 and self.xoffset ~= 0 then
self.xoffset = 0 self.xoffset = 0
end end
elseif key == "right" then elseif key == "right" then
self:MoveBlinker(1) self:MoveBlinker(1)
if self.blinkx >= self.x + self.width and self.blinknum ~= #self.text then if blinkx >= self.x + swidth and blinknum ~= #self.text then
local width = self.font:getWidth(self.text:sub(self.blinknum, self.blinknum)) local width = self.font:getWidth(self.text:sub(blinknum, blinknum))
self.xoffset = self.xoffset - width self.xoffset = self.xoffset - width
elseif self.blinknum == #self.text and self.xoffset ~= ((0 - font:getWidth(self.text)) + self.width) then elseif blinknum == #self.text and self.xoffset ~= ((0 - font:getWidth(self.text)) + swidth) then
self.xoffset = ((0 - font:getWidth(self.text)) + self.width) self.xoffset = ((0 - font:getWidth(self.text)) + swidth)
end end
end end
-- key input checking system -- key input checking system
if key == "backspace" then if key == "backspace" then
if text ~= "" then if text ~= "" then
self.text = self:RemoveFromeText(self.blinknum) self.text = self:RemoveFromeText(blinknum)
self:MoveBlinker(-1) self:MoveBlinker(-1)
end end
elseif key == "return" then elseif key == "return" then
@ -254,8 +283,8 @@ function textinput:RunKey(key, unicode)
else else
if unicode > 31 and unicode < 127 then if unicode > 31 and unicode < 127 then
ckey = string.char(unicode) ckey = string.char(unicode)
if self.blinknum ~= 0 and self.blinknum ~= #self.text then if blinknum ~= 0 and blinknum ~= #self.text then
self.text = self:AddIntoText(unicode, self.blinknum) self.text = self:AddIntoText(unicode, blinknum)
self:MoveBlinker(1) self:MoveBlinker(1)
else else
self.text = text .. ckey self.text = text .. ckey
@ -313,12 +342,15 @@ end
function textinput:RunBlink() function textinput:RunBlink()
local time = love.timer.getTime() local time = love.timer.getTime()
local blink = self.blink
local blinknum = self.blinknum
local text = self.text
if self.xoffset > 0 then if self.xoffset > 0 then
self.xoffset = 0 self.xoffset = 0
end end
if self.blink < time then if blink < time then
if self.showblink == true then if self.showblink == true then
self.showblink = false self.showblink = false
else else
@ -329,8 +361,8 @@ function textinput:RunBlink()
local width = 0 local width = 0
for i=1, self.blinknum do for i=1, blinknum do
width = width + self.font:getWidth(self.text:sub(i, i)) width = width + self.font:getWidth(text:sub(i, i))
end end
self.blinkx = self.textx + width self.blinkx = self.textx + width
@ -352,8 +384,6 @@ function textinput:AddIntoText(t, p)
return new return new
--print(part1, part2)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -363,15 +393,18 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function textinput:RemoveFromeText(p) function textinput:RemoveFromeText(p)
if self.blinknum ~= 0 then local blinknum = self.blinknum
local s = self.text local text = self.text
if blinknum ~= 0 then
local s = text
local part1 = s:sub(1, p - 1) local part1 = s:sub(1, p - 1)
local part2 = s:sub(p + 1) local part2 = s:sub(p + 1)
local new = part1 .. part2 local new = part1 .. part2
return new return new
end end
return self.text return text
end end

View File

@ -123,13 +123,11 @@ skin.controls.textinput_blinker_color = {0, 0, 0, 255}
-- slider -- slider
skin.controls.slider_bar_color = bordercolor skin.controls.slider_bar_color = bordercolor
skin.controls.slider_bar_outline_color = {220, 220, 220, 255} skin.controls.slider_bar_outline_color = {220, 220, 220, 255}
skin.controls.slider_text_color = {0, 0, 0, 255}
skin.controls.slider_text_font = smallfont
-- checkbox -- checkbox
skin.controls.checkbox_border_color = bordercolor skin.controls.checkbox_border_color = bordercolor
skin.controls.checkbox_body_color = {255, 255, 255, 255} skin.controls.checkbox_body_color = {255, 255, 255, 255}
skin.controls.checkbox_check_color = {0, 0, 0, 255} skin.controls.checkbox_check_color = {128, 204, 255, 255}
skin.controls.checkbox_text_color = {0, 0, 0, 255} skin.controls.checkbox_text_color = {0, 0, 0, 255}
skin.controls.checkbox_text_font = smallfont skin.controls.checkbox_text_font = smallfont
@ -540,21 +538,21 @@ function skin.DrawScrollBar(object)
love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
elseif object.hover == true then elseif object.hover == true then
love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
else else
love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
end end
@ -758,11 +756,14 @@ function skin.DrawMultiChoiceList(object)
end end
--[[---------------------------------------------------------
- func: DrawOverMultiChoiceList(object)
- desc: draws over the multi choice list object
--]]---------------------------------------------------------
function skin.DrawOverMultiChoiceList(object) function skin.DrawOverMultiChoiceList(object)
love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color)) love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true) skin.OutlinedRectangle(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight() + 1)
end end
@ -950,19 +951,23 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function skin.DrawSlider(object) function skin.DrawSlider(object)
if object.slidetype == "horizontal" then
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object.ycenter - 5, object:GetWidth(), 10) love.graphics.rectangle("fill", object:GetX(), object:GetY() + object:GetHeight()/2 - 5, object:GetWidth(), 10)
love.graphics.setColor(unpack(skin.controls.slider_bar_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_color))
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object.ycenter - 0.5, object:GetWidth() - 10, 1) love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object:GetHeight()/2, object:GetWidth() - 10, 1)
love.graphics.setFont(skin.controls.slider_text_font) elseif object.slidetype == "vertical" then
love.graphics.setColor(unpack(skin.controls.slider_text_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
love.graphics.print(object.text, object:GetX(), object:GetY()) love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2 - 5, object:GetY(), 10, object:GetHeight())
love.graphics.setColor(unpack(skin.controls.slider_text_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_color))
love.graphics.printf(object.value, object:GetX() + object:GetWidth(), object:GetY(), 0, "right") love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2, object:GetY() + 5, 1, object:GetHeight() - 10)
end
end end
@ -1030,6 +1035,7 @@ function skin.DrawCheckBox(object)
local linesize = (1 * (object.boxwidth * 0.05)) local linesize = (1 * (object.boxwidth * 0.05))
local checked = object.checked local checked = object.checked
local height = font:getHeight() local height = font:getHeight()
local gradientcolor = {}
love.graphics.setColor(unpack(skin.controls.checkbox_body_color)) love.graphics.setColor(unpack(skin.controls.checkbox_body_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight) love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight)
@ -1039,11 +1045,11 @@ function skin.DrawCheckBox(object)
if checked == true then if checked == true then
love.graphics.setLine(linesize, "smooth")
love.graphics.setColor(unpack(skin.controls.checkbox_check_color)) love.graphics.setColor(unpack(skin.controls.checkbox_check_color))
love.graphics.line(object:GetX() + 5 + linesize, object:GetY() + 5 + linesize, object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + object.boxheight - 5 - linesize) love.graphics.rectangle("fill", object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8)
love.graphics.line(object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + 5 + linesize, object:GetX() + 5 + linesize, object:GetY() + object.boxheight - 5 - linesize)
gradientcolor = {skin.controls.checkbox_check_color[1] - 20, skin.controls.checkbox_check_color[2] - 20, skin.controls.checkbox_check_color[3] - 20, 255}
skin.DrawGradient(object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8, "up", gradientcolor)
end end

View File

@ -123,13 +123,11 @@ skin.controls.textinput_blinker_color = {0, 0, 0, 255}
-- slider -- slider
skin.controls.slider_bar_color = bordercolor skin.controls.slider_bar_color = bordercolor
skin.controls.slider_bar_outline_color = {220, 220, 220, 255} skin.controls.slider_bar_outline_color = {220, 220, 220, 255}
skin.controls.slider_text_color = {0, 0, 0, 255}
skin.controls.slider_text_font = smallfont
-- checkbox -- checkbox
skin.controls.checkbox_border_color = bordercolor skin.controls.checkbox_border_color = bordercolor
skin.controls.checkbox_body_color = {255, 255, 255, 255} skin.controls.checkbox_body_color = {255, 255, 255, 255}
skin.controls.checkbox_check_color = {0, 0, 0, 255} skin.controls.checkbox_check_color = {255, 173, 51, 255}
skin.controls.checkbox_text_color = {0, 0, 0, 255} skin.controls.checkbox_text_color = {0, 0, 0, 255}
skin.controls.checkbox_text_font = smallfont skin.controls.checkbox_text_font = smallfont
@ -541,21 +539,21 @@ function skin.DrawScrollBar(object)
love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
elseif object.hover == true then elseif object.hover == true then
love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
else else
love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color))
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2) love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255} gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255}
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor) skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color)) love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight()) skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
end end
@ -759,11 +757,14 @@ function skin.DrawMultiChoiceList(object)
end end
--[[---------------------------------------------------------
- func: DrawOverMultiChoiceList(object)
- desc: draws over the multi choice list object
--]]---------------------------------------------------------
function skin.DrawOverMultiChoiceList(object) function skin.DrawOverMultiChoiceList(object)
love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color)) love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color))
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true) skin.OutlinedRectangle(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight() + 1)
end end
@ -951,19 +952,23 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function skin.DrawSlider(object) function skin.DrawSlider(object)
if object.slidetype == "horizontal" then
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object.ycenter - 5, object:GetWidth(), 10) love.graphics.rectangle("fill", object:GetX(), object:GetY() + object:GetHeight()/2 - 5, object:GetWidth(), 10)
love.graphics.setColor(unpack(skin.controls.slider_bar_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_color))
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object.ycenter - 0.5, object:GetWidth() - 10, 1) love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object:GetHeight()/2, object:GetWidth() - 10, 1)
love.graphics.setFont(skin.controls.slider_text_font) elseif object.slidetype == "vertical" then
love.graphics.setColor(unpack(skin.controls.slider_text_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
love.graphics.print(object.text, object:GetX(), object:GetY()) love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2 - 5, object:GetY(), 10, object:GetHeight())
love.graphics.setColor(unpack(skin.controls.slider_text_color)) love.graphics.setColor(unpack(skin.controls.slider_bar_color))
love.graphics.printf(object.value, object:GetX() + object:GetWidth(), object:GetY(), 0, "right") love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2, object:GetY() + 5, 1, object:GetHeight() - 10)
end
end end
@ -1031,6 +1036,7 @@ function skin.DrawCheckBox(object)
local linesize = (1 * (object.boxwidth * 0.05)) local linesize = (1 * (object.boxwidth * 0.05))
local checked = object.checked local checked = object.checked
local height = font:getHeight() local height = font:getHeight()
local gradientcolor = {}
love.graphics.setColor(unpack(skin.controls.checkbox_body_color)) love.graphics.setColor(unpack(skin.controls.checkbox_body_color))
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight) love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight)
@ -1040,11 +1046,11 @@ function skin.DrawCheckBox(object)
if checked == true then if checked == true then
love.graphics.setLine(linesize, "smooth")
love.graphics.setColor(unpack(skin.controls.checkbox_check_color)) love.graphics.setColor(unpack(skin.controls.checkbox_check_color))
love.graphics.line(object:GetX() + 5 + linesize, object:GetY() + 5 + linesize, object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + object.boxheight - 5 - linesize) love.graphics.rectangle("fill", object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8)
love.graphics.line(object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + 5 + linesize, object:GetX() + 5 + linesize, object:GetY() + object.boxheight - 5 - linesize)
gradientcolor = {skin.controls.checkbox_check_color[1] - 20, skin.controls.checkbox_check_color[2] - 20, skin.controls.checkbox_check_color[3] - 20, 255}
skin.DrawGradient(object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8, "up", gradientcolor)
end end