mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Version 0.9.4.11 - Alpha (see changelog.txt)
This commit is contained in:
parent
f9e7d7be66
commit
f8356fbd36
@ -1,3 +1,15 @@
|
||||
================================================
|
||||
Version 0.9.4.11 - Alpha (December 28 - 2012)
|
||||
================================================
|
||||
[ADDED] a new textinput method: SetAutoScroll(bool)
|
||||
[ADDED] a new textinput method: GetAutoScroll()
|
||||
|
||||
[FIXED] a couple of typos in the changelog
|
||||
[FIXED] a sliderbutton calculation error that caused the sliderbutton object to flash while moving the cursor out of it's bounding box while it was down
|
||||
|
||||
[CHANGED] cleaned up a lot of code
|
||||
[CHANGED] the text object's shadow color now defaults to black
|
||||
|
||||
================================================
|
||||
Version 0.9.4.10 - Alpha (December 26 - 2012)
|
||||
================================================
|
||||
@ -8,7 +20,7 @@ Version 0.9.4.9 - Alpha (December 26 - 2012)
|
||||
================================================
|
||||
[ADDED] a new default skin: Blue (basic)
|
||||
[ADDED] a new default skin: Orange (basic)
|
||||
[ADDED] a new skins library function: loveframes.skins.GetAvailalbe()
|
||||
[ADDED] a new skins library function: loveframes.skins.GetAvailable()
|
||||
|
||||
[CHANGED] the license from CC BY-SA 3.0 to CC BY 3.0
|
||||
[CHANGED] made minor improvements to the default skins
|
||||
@ -214,7 +226,7 @@ Version 0.9.3.2 - Alpha (Spetember 29 - 2012)
|
||||
[ADDED] ability to select all text within a text input
|
||||
|
||||
[FIXED] progressbar object not positioning itself properly if it's parent was the base object
|
||||
[FIXED] a typeo in the syntax of loveframes.util.SplitString (was "SplitSring", changed to "SplitString")
|
||||
[FIXED] a typo in the syntax of loveframes.util.SplitString (was "SplitSring", changed to "SplitString")
|
||||
[FIXED] the tooltip object not disapearing if it was visible when it's object's visibility was changed to false
|
||||
[FIXED] the text input object's x offset not being adjusted initially when the width of it's text would would become wider than it's drawing area
|
||||
|
||||
|
11
debug.lua
11
debug.lua
@ -669,7 +669,7 @@ function loveframes.debug.ExamplesMenu()
|
||||
|
||||
local frame1 = loveframes.Create("frame")
|
||||
frame1:SetName("Text")
|
||||
frame1:SetSize(500, 300)
|
||||
frame1:SetSize(500, 330)
|
||||
frame1:CenterWithinArea(unpack(centerarea))
|
||||
|
||||
local list1 = loveframes.Create("list", frame1)
|
||||
@ -680,8 +680,17 @@ function loveframes.debug.ExamplesMenu()
|
||||
|
||||
local text1 = loveframes.Create("text")
|
||||
text1:SetText(loremipsum)
|
||||
text1:SetShadowColor(200, 200, 200, 255)
|
||||
list1:AddItem(text1)
|
||||
|
||||
local shadowbutton = loveframes.Create("button", frame1)
|
||||
shadowbutton:SetSize(490, 25)
|
||||
shadowbutton:SetPos(5, 300)
|
||||
shadowbutton:SetText("Toggle Text Shadow")
|
||||
shadowbutton.OnClick = function()
|
||||
text1:SetShadow(not text1:GetShadow())
|
||||
end
|
||||
|
||||
end
|
||||
exampleslist:AddItem(textexample)
|
||||
|
||||
|
14
init.lua
14
init.lua
@ -9,7 +9,7 @@ loveframes = {}
|
||||
-- library info
|
||||
loveframes.info = {}
|
||||
loveframes.info.author = "Kenny Shields"
|
||||
loveframes.info.version = "0.9.4.10"
|
||||
loveframes.info.version = "0.9.4.11"
|
||||
loveframes.info.stage = "Alpha"
|
||||
|
||||
-- library configurations
|
||||
@ -210,29 +210,21 @@ function loveframes.Create(data, parent)
|
||||
-- this function reads a table that contains a layout of object properties and then
|
||||
-- creates objects based on those properties
|
||||
local function CreateObjects(t, o, c)
|
||||
|
||||
local child = c or false
|
||||
|
||||
for k, v in pairs(t) do
|
||||
|
||||
-- current default object
|
||||
local object = _G[v.type]:new()
|
||||
|
||||
-- indert the object into the table of objects being created
|
||||
table.insert(objects, object)
|
||||
|
||||
-- parent the new object by default to the base gui object
|
||||
object.parent = loveframes.base
|
||||
table.insert(loveframes.base.children, object)
|
||||
|
||||
if o then
|
||||
object:SetParent(o)
|
||||
end
|
||||
|
||||
-- loop through the current layout table and assign the properties found
|
||||
-- to the current object
|
||||
for i, j in pairs(v) do
|
||||
|
||||
if i ~= "children" and i ~= "func" then
|
||||
if child == true then
|
||||
if i == "x" then
|
||||
@ -248,15 +240,11 @@ function loveframes.Create(data, parent)
|
||||
elseif i == "children" then
|
||||
CreateObjects(j, object, true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if v.func then
|
||||
v.func(object)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- create the objects
|
||||
|
@ -16,12 +16,12 @@ function newobject:initialize()
|
||||
local w = love.graphics.getWidth()
|
||||
local h = love.graphics.getHeight()
|
||||
|
||||
self.type = "base"
|
||||
self.width = w
|
||||
self.height = h
|
||||
self.internal = true
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
self.type = "base"
|
||||
self.width = w
|
||||
self.height = h
|
||||
self.internal = true
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
|
||||
end
|
||||
|
||||
@ -616,10 +616,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:IsTopCollision()
|
||||
|
||||
local cols = loveframes.util.GetCollisions()
|
||||
local cols = loveframes.util.GetCollisions()
|
||||
local draworder = self.draworder
|
||||
local found = false
|
||||
local top = true
|
||||
local found = false
|
||||
local top = true
|
||||
|
||||
for k, v in ipairs(cols) do
|
||||
if v == self then
|
||||
@ -676,9 +676,7 @@ function newobject:CheckHover()
|
||||
|
||||
-- is the mouse inside the object?
|
||||
if selfcol then
|
||||
|
||||
local top = self:IsTopCollision()
|
||||
|
||||
if top then
|
||||
if not hoverobject then
|
||||
self.hover = true
|
||||
@ -692,66 +690,46 @@ function newobject:CheckHover()
|
||||
else
|
||||
self.hover = false
|
||||
end
|
||||
|
||||
if clickbounds then
|
||||
if not self:InClickBounds() then
|
||||
self.hover = false
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
self.hover = false
|
||||
|
||||
end
|
||||
|
||||
if modalobject then
|
||||
|
||||
if modalobject ~= self then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent ~= modalobject and self.type ~= "multichoicerow" then
|
||||
|
||||
self.hover = false
|
||||
|
||||
if self.focus then
|
||||
self.focus = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- this chunk of code handles mouse enter and exit
|
||||
if self.hover then
|
||||
|
||||
if not self.calledmousefunc then
|
||||
|
||||
if self.OnMouseEnter then
|
||||
self.OnMouseEnter(self)
|
||||
self.calledmousefunc = true
|
||||
else
|
||||
self.calledmousefunc = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if self.calledmousefunc then
|
||||
|
||||
if self.OnMouseExit then
|
||||
self.OnMouseExit(self)
|
||||
self.calledmousefunc = false
|
||||
else
|
||||
self.calledmousefunc = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -794,17 +772,13 @@ function newobject:IsTopList()
|
||||
local found = false
|
||||
|
||||
local function IsChild(object)
|
||||
|
||||
local parents = object:GetParents()
|
||||
|
||||
for k, v in ipairs(parents) do
|
||||
if v == self then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(cols) do
|
||||
@ -980,22 +954,17 @@ end
|
||||
function newobject:GetParents()
|
||||
|
||||
local function GetParents(object, t)
|
||||
|
||||
local t = t or {}
|
||||
local type = object.type
|
||||
local parent = object.parent
|
||||
|
||||
if type ~= "base" then
|
||||
table.insert(t, parent)
|
||||
GetParents(parent, t)
|
||||
end
|
||||
|
||||
return t
|
||||
|
||||
end
|
||||
|
||||
local parents = GetParents(self)
|
||||
|
||||
return parents
|
||||
|
||||
end
|
||||
|
@ -12,15 +12,15 @@ local newobject = loveframes.NewObject("button", "loveframes_object_button", tru
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "button"
|
||||
self.text = "Button"
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.internal = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.OnClick = nil
|
||||
self.type = "button"
|
||||
self.text = "Button"
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.internal = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.OnClick = nil
|
||||
|
||||
end
|
||||
|
||||
@ -30,7 +30,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -41,12 +41,12 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
self.down = false
|
||||
@ -83,14 +83,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawButton or skins[defaultskin].DrawButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawButton or skins[defaultskin].DrawButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -118,16 +118,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -144,11 +140,11 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local clickable = self.clickable
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and down and clickable and button == "l" then
|
||||
if enabled then
|
||||
@ -175,7 +171,7 @@ function newobject:keypressed(key, unicode)
|
||||
end
|
||||
|
||||
local selectedobject = loveframes.selectedobject
|
||||
local onclick = self.OnClick
|
||||
local onclick = self.OnClick
|
||||
|
||||
if key == "return" and selectedobject == self then
|
||||
onclick(self, 0, 0)
|
||||
|
@ -12,18 +12,18 @@ local newobject = loveframes.NewObject("checkbox", "loveframes_object_checkbox",
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "checkbox"
|
||||
self.width = 0
|
||||
self.height = 0
|
||||
self.boxwidth = 20
|
||||
self.boxheight = 20
|
||||
self.font = loveframes.basicfont
|
||||
self.checked = false
|
||||
self.lastvalue = false
|
||||
self.internal = false
|
||||
self.down = true
|
||||
self.internals = {}
|
||||
self.OnChanged = nil
|
||||
self.type = "checkbox"
|
||||
self.width = 0
|
||||
self.height = 0
|
||||
self.boxwidth = 20
|
||||
self.boxheight = 20
|
||||
self.font = loveframes.basicfont
|
||||
self.checked = false
|
||||
self.lastvalue = false
|
||||
self.internal = false
|
||||
self.down = true
|
||||
self.internals = {}
|
||||
self.OnChanged = nil
|
||||
|
||||
end
|
||||
|
||||
@ -44,13 +44,13 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local internals = self.internals
|
||||
local boxwidth = self.boxwidth
|
||||
local boxwidth = self.boxwidth
|
||||
local boxheight = self.boxheight
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
self.down = false
|
||||
@ -71,9 +71,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
if internals[1] then
|
||||
|
||||
self.width = boxwidth + 5 + internals[1].width
|
||||
|
||||
if internals[1].height == boxheight then
|
||||
self.height = boxheight
|
||||
else
|
||||
@ -83,12 +81,9 @@ function newobject:update(dt)
|
||||
self.height = boxheight
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
self.width = boxwidth
|
||||
self.height = boxheight
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -113,15 +108,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox
|
||||
local draw = self.Draw
|
||||
local internals = self.internals
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCheckBox or skins[defaultskin].DrawCheckBox
|
||||
local draw = self.Draw
|
||||
local internals = self.internals
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -153,16 +148,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -179,22 +170,19 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local checked = self.checked
|
||||
local hover = self.hover
|
||||
local checked = self.checked
|
||||
local onchanged = self.OnChanged
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
if checked then
|
||||
self.checked = false
|
||||
else
|
||||
self.checked = true
|
||||
end
|
||||
|
||||
if onchanged then
|
||||
onchanged(self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -215,7 +203,6 @@ function newobject:keypressed(key, unicode)
|
||||
else
|
||||
self.checked = true
|
||||
end
|
||||
|
||||
if onchanged then
|
||||
onchanged(self)
|
||||
end
|
||||
@ -229,13 +216,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetText(text)
|
||||
|
||||
local boxwidth = self.boxwidth
|
||||
local boxwidth = self.boxwidth
|
||||
local boxheight = self.boxheight
|
||||
|
||||
if text ~= "" then
|
||||
|
||||
self.internals = {}
|
||||
|
||||
local textobject = loveframes.Create("text")
|
||||
textobject:Remove()
|
||||
textobject.parent = self
|
||||
@ -249,15 +234,11 @@ function newobject:SetText(text)
|
||||
object:SetPos(boxwidth + 5, boxheight/2 - object.height/2)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(self.internals, textobject)
|
||||
|
||||
else
|
||||
|
||||
self.width = boxwidth
|
||||
self.height = boxheight
|
||||
self.width = boxwidth
|
||||
self.height = boxheight
|
||||
self.internals = {}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -269,7 +250,7 @@ end
|
||||
function newobject:GetText()
|
||||
|
||||
local internals = self.internals
|
||||
local text = internals[1]
|
||||
local text = internals[1]
|
||||
|
||||
if text then
|
||||
return text.text
|
||||
@ -285,7 +266,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetSize(width, height)
|
||||
|
||||
self.boxwidth = width
|
||||
self.boxwidth = width
|
||||
self.boxheight = height
|
||||
|
||||
end
|
||||
@ -343,7 +324,7 @@ end
|
||||
function newobject:SetFont(font)
|
||||
|
||||
local internals = self.internals
|
||||
local text = internals[1]
|
||||
local text = internals[1]
|
||||
|
||||
self.font = font
|
||||
|
||||
|
@ -12,16 +12,16 @@ local newobject = loveframes.NewObject("collapsiblecategory", "loveframes_object
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "collapsiblecategory"
|
||||
self.text = "Category"
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.closedheight = 25
|
||||
self.padding = 5
|
||||
self.internal = false
|
||||
self.open = false
|
||||
self.down = false
|
||||
self.children = {}
|
||||
self.type = "collapsiblecategory"
|
||||
self.text = "Category"
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.closedheight = 25
|
||||
self.padding = 5
|
||||
self.internal = false
|
||||
self.open = false
|
||||
self.down = false
|
||||
self.children = {}
|
||||
self.OnOpenedClosed = nil
|
||||
|
||||
end
|
||||
@ -32,7 +32,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -41,12 +41,12 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -79,17 +79,17 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCollapsibleCategory or skins[defaultskin].DrawCollapsibleCategory
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCollapsibleCategory or skins[defaultskin].DrawCollapsibleCategory
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -118,28 +118,21 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local hover = self.hover
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if hover then
|
||||
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
|
||||
|
||||
if button == "l" and col then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if open and curobject then
|
||||
@ -160,25 +153,22 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local clickable = self.clickable
|
||||
local enabled = self.enabled
|
||||
local open = self.open
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
|
||||
local children = self.children
|
||||
local enabled = self.enabled
|
||||
local open = self.open
|
||||
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 and col and down and button == "l" then
|
||||
|
||||
if open then
|
||||
self:SetOpen(false)
|
||||
else
|
||||
self:SetOpen(true)
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
||||
end
|
||||
|
||||
if open and curobject then
|
||||
@ -213,7 +203,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetObject(object)
|
||||
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if curobject then
|
||||
@ -225,7 +215,6 @@ function newobject:SetObject(object)
|
||||
object.parent = self
|
||||
object:SetWidth(self.width - self.padding*2)
|
||||
object:SetPos(self.padding, self.closedheight + self.padding)
|
||||
|
||||
table.insert(self.children, object)
|
||||
|
||||
end
|
||||
@ -236,7 +225,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetObject()
|
||||
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if curobject then
|
||||
@ -293,11 +282,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetOpen(bool)
|
||||
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
local closedheight = self.closedheight
|
||||
local padding = self.padding
|
||||
local onopenedclosed = self.OnOpenedClosed
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
local closedheight = self.closedheight
|
||||
local padding = self.padding
|
||||
local onopenedclosed = self.OnOpenedClosed
|
||||
|
||||
self.open = bool
|
||||
|
||||
|
@ -12,18 +12,18 @@ local newobject = loveframes.NewObject("columnlist", "loveframes_object_columnli
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "columnlist"
|
||||
self.width = 300
|
||||
self.height = 100
|
||||
self.columnheight = 16
|
||||
self.buttonscrollamount = 0.10
|
||||
self.type = "columnlist"
|
||||
self.width = 300
|
||||
self.height = 100
|
||||
self.columnheight = 16
|
||||
self.buttonscrollamount = 0.10
|
||||
self.mousewheelscrollamount = 5
|
||||
self.autoscroll = false
|
||||
self.internal = false
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
self.OnRowClicked = nil
|
||||
self.OnScroll = nil
|
||||
self.autoscroll = false
|
||||
self.internal = false
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
self.OnRowClicked = nil
|
||||
self.OnScroll = nil
|
||||
|
||||
local list = loveframes.objects["columnlistarea"]:new(self)
|
||||
table.insert(self.internals, list)
|
||||
@ -45,11 +45,11 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local children = self.children
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local update = self.Update
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -85,16 +85,16 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnList or skins[defaultskin].DrawColumnList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnList or skins[defaultskin].DrawColumnList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -127,7 +127,7 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
@ -183,16 +183,16 @@ end
|
||||
function newobject:AdjustColumns()
|
||||
|
||||
local width = self.width
|
||||
local bar = self.internals[1].bar
|
||||
local bar = self.internals[1].bar
|
||||
|
||||
if bar then
|
||||
width = width - self.internals[1].internals[1].width
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local columnwidth = width/numchildren
|
||||
local x = 0
|
||||
local x = 0
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
if bar == true then
|
||||
@ -214,9 +214,9 @@ end
|
||||
function newobject:AddColumn(name)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local list = internals[1]
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
|
||||
loveframes.objects["columnlistheader"]:new(name, self)
|
||||
self:AdjustColumns()
|
||||
@ -233,7 +233,7 @@ end
|
||||
function newobject:AddRow(...)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
list:AddRow(arg)
|
||||
|
||||
@ -245,7 +245,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetColumnSize()
|
||||
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local numchildren = #self.children
|
||||
|
||||
if numchildren > 0 then
|
||||
@ -266,7 +266,7 @@ end
|
||||
function newobject:SetSize(width, height)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
self.width = width
|
||||
self.height = height
|
||||
@ -283,7 +283,7 @@ end
|
||||
function newobject:SetWidth(width)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
self.width = width
|
||||
|
||||
@ -299,7 +299,7 @@ end
|
||||
function newobject:SetHeight(height)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
self.height = height
|
||||
|
||||
@ -316,7 +316,7 @@ end
|
||||
function newobject:SetMaxColorIndex(num)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
list.colorindexmax = num
|
||||
|
||||
@ -329,7 +329,7 @@ end
|
||||
function newobject:Clear()
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
|
||||
list:Clear()
|
||||
|
||||
@ -344,7 +344,7 @@ end
|
||||
function newobject:SetAutoScroll(bool)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
local list = internals[1]
|
||||
local scrollbar = list:GetScrollBar()
|
||||
|
||||
self.autoscroll = bool
|
||||
|
@ -12,23 +12,23 @@ local newobject = loveframes.NewObject("frame", "loveframes_object_frame", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "frame"
|
||||
self.name = "Frame"
|
||||
self.width = 300
|
||||
self.height = 150
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.internal = false
|
||||
self.draggable = true
|
||||
self.screenlocked = false
|
||||
self.parentlocked = false
|
||||
self.dragging = false
|
||||
self.modal = false
|
||||
self.type = "frame"
|
||||
self.name = "Frame"
|
||||
self.width = 300
|
||||
self.height = 150
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.internal = false
|
||||
self.draggable = true
|
||||
self.screenlocked = false
|
||||
self.parentlocked = false
|
||||
self.dragging = false
|
||||
self.modal = false
|
||||
self.modalbackground = false
|
||||
self.showclose = true
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.OnClose = nil
|
||||
self.showclose = true
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.OnClose = nil
|
||||
|
||||
-- create the close button for the frame
|
||||
local close = loveframes.objects["closebutton"]:new()
|
||||
@ -51,7 +51,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -60,21 +60,21 @@ function newobject:update(dt)
|
||||
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 parentlocked = self.parentlocked
|
||||
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
|
||||
local parent = self.parent
|
||||
local update = self.Update
|
||||
local x, y = love.mouse.getPosition()
|
||||
local showclose = self.showclose
|
||||
local close = self.internals[1]
|
||||
local dragging = self.dragging
|
||||
local screenlocked = self.screenlocked
|
||||
local parentlocked = self.parentlocked
|
||||
local modal = self.modal
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
local numbasechildren = #basechildren
|
||||
local draworder = self.draworder
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local parent = self.parent
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -91,12 +91,10 @@ function newobject:update(dt)
|
||||
|
||||
-- if screenlocked then keep within screen
|
||||
if screenlocked then
|
||||
|
||||
local width = love.graphics.getWidth()
|
||||
local height = love.graphics.getHeight()
|
||||
local selfwidth = self.width
|
||||
local selfheight = self.height
|
||||
|
||||
if self.x < 0 then
|
||||
self.x = 0
|
||||
end
|
||||
@ -109,16 +107,13 @@ function newobject:update(dt)
|
||||
if self.y + selfheight > height then
|
||||
self.y = height - selfheight
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if parentlocked then
|
||||
|
||||
local width = self.parent.width
|
||||
local height = self.parent.height
|
||||
local selfwidth = self.width
|
||||
local selfheight = self.height
|
||||
|
||||
if self.staticx < 0 then
|
||||
self.staticx = 0
|
||||
end
|
||||
@ -131,32 +126,26 @@ function newobject:update(dt)
|
||||
if self.staticy + selfheight > height then
|
||||
self.staticy = height - selfheight
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if modal then
|
||||
|
||||
local tip = false
|
||||
local key = 0
|
||||
|
||||
for k, v in ipairs(basechildren) do
|
||||
if v.type == "tooltip" and v.show == true then
|
||||
tip = v
|
||||
key = k
|
||||
end
|
||||
end
|
||||
|
||||
if tip ~= false then
|
||||
self:Remove()
|
||||
self.modalbackground:Remove()
|
||||
table.insert(basechildren, key - 2, self.modalbackground)
|
||||
table.insert(basechildren, key - 1, self)
|
||||
end
|
||||
|
||||
if self.modalbackground.draworder > self.draworder then
|
||||
self:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if parent ~= base then
|
||||
@ -190,16 +179,16 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -233,19 +222,17 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local dragging = self.dragging
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local children = self.children
|
||||
local dragging = self.dragging
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
|
||||
if selfcol then
|
||||
|
||||
local top = self:IsTopCollision()
|
||||
|
||||
-- initiate dragging if not currently dragging
|
||||
if not dragging and top and button == "l" then
|
||||
if y < self.y + 25 and self.draggable then
|
||||
@ -259,11 +246,9 @@ function newobject:mousepressed(x, y, button)
|
||||
self.dragging = true
|
||||
end
|
||||
end
|
||||
|
||||
if top and button == "l" then
|
||||
self:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -288,8 +273,8 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local dragging = self.dragging
|
||||
local children = self.children
|
||||
local dragging = self.dragging
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
-- exit the dragging state
|
||||
@ -390,12 +375,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:MakeTop()
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local key = 0
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
local x, y = love.mouse.getPosition()
|
||||
local key = 0
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
local numbasechildren = #basechildren
|
||||
local parent = self.parent
|
||||
local parent = self.parent
|
||||
|
||||
-- check to see if the object's parent is not the base object
|
||||
if parent ~= base then
|
||||
@ -437,8 +422,8 @@ function newobject:SetModal(bool)
|
||||
|
||||
local modalobject = loveframes.modalobject
|
||||
local mbackground = self.modalbackground
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
|
||||
if parent ~= base then
|
||||
return
|
||||
@ -447,32 +432,24 @@ function newobject:SetModal(bool)
|
||||
self.modal = bool
|
||||
|
||||
if bool then
|
||||
|
||||
if modalobject then
|
||||
modalobject:SetModal(false)
|
||||
end
|
||||
|
||||
loveframes.modalobject = self
|
||||
|
||||
if not mbackground then
|
||||
self.modalbackground = loveframes.objects["modalbackground"]:new(self)
|
||||
self.modal = true
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if modalobject == self then
|
||||
|
||||
loveframes.modalobject = false
|
||||
|
||||
if mbackground then
|
||||
self.modalbackground:Remove()
|
||||
self.modalbackground = false
|
||||
self.modal = false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -494,8 +471,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetVisible(bool)
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local closebutton = internals[1]
|
||||
|
||||
self.visible = bool
|
||||
|
@ -12,19 +12,19 @@ local newobject = loveframes.NewObject("image", "loveframes_object_image", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "image"
|
||||
self.width = 0
|
||||
self.height = 0
|
||||
self.orientation = 0
|
||||
self.scalex = 1
|
||||
self.scaley = 1
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.shearx = 0
|
||||
self.sheary = 0
|
||||
self.internal = false
|
||||
self.image = nil
|
||||
self.imagecolor = nil
|
||||
self.type = "image"
|
||||
self.width = 0
|
||||
self.height = 0
|
||||
self.orientation = 0
|
||||
self.scalex = 1
|
||||
self.scaley = 1
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.shearx = 0
|
||||
self.sheary = 0
|
||||
self.internal = false
|
||||
self.image = nil
|
||||
self.imagecolor = nil
|
||||
|
||||
end
|
||||
|
||||
@ -34,7 +34,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -44,7 +44,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -71,14 +71,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawImage or skins[defaultskin].DrawImage
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
|
@ -12,16 +12,16 @@ local newobject = loveframes.NewObject("imagebutton", "loveframes_object_imagebu
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "imagebutton"
|
||||
self.text = "Image Button"
|
||||
self.width = 50
|
||||
self.height = 50
|
||||
self.internal = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.image = nil
|
||||
self.OnClick = nil
|
||||
self.type = "imagebutton"
|
||||
self.text = "Image Button"
|
||||
self.width = 50
|
||||
self.height = 50
|
||||
self.internal = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.image = nil
|
||||
self.OnClick = nil
|
||||
|
||||
end
|
||||
|
||||
@ -31,7 +31,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -42,12 +42,12 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local down = self.down
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local down = self.down
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
self.down = false
|
||||
@ -85,14 +85,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawImageButton or skins[defaultskin].DrawImageButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -120,16 +120,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -146,11 +142,11 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local clickable = self.clickable
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and down and clickable and button == "l" then
|
||||
if enabled then
|
||||
|
@ -12,13 +12,13 @@ local newobject = loveframes.NewObject("closebutton", "loveframes_object_closebu
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "closebutton"
|
||||
self.width = 16
|
||||
self.height = 16
|
||||
self.internal = true
|
||||
self.hover = false
|
||||
self.down = false
|
||||
self.OnClick = function() end
|
||||
self.type = "closebutton"
|
||||
self.width = 16
|
||||
self.height = 16
|
||||
self.internal = true
|
||||
self.hover = false
|
||||
self.down = false
|
||||
self.OnClick = function() end
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -31,7 +31,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -42,12 +42,12 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
self.down = false
|
||||
@ -85,13 +85,13 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCloseButton or skins[defaultskin].DrawCloseButton
|
||||
local draw = self.Draw
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawCloseButton or skins[defaultskin].DrawCloseButton
|
||||
local draw = self.Draw
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -119,16 +119,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -145,15 +141,13 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and self.down then
|
||||
|
||||
if button == "l" then
|
||||
onclick(x, y, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
@ -12,25 +12,25 @@ local newobject = loveframes.NewObject("columnlistarea", "loveframes_object_colu
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent)
|
||||
|
||||
self.type = "columnlistarea"
|
||||
self.display = "vertical"
|
||||
self.parent = parent
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.rowcolorindex = 1
|
||||
self.rowcolorindexmax = 2
|
||||
self.buttonscrollamount = parent.buttonscrollamount
|
||||
self.type = "columnlistarea"
|
||||
self.display = "vertical"
|
||||
self.parent = parent
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.rowcolorindex = 1
|
||||
self.rowcolorindexmax = 2
|
||||
self.buttonscrollamount = parent.buttonscrollamount
|
||||
self.mousewheelscrollamount = parent.mousewheelscrollamount
|
||||
self.bar = false
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.bar = false
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -43,7 +43,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -53,11 +53,11 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local cwidth, cheight = self.parent:GetColumnSize()
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -96,19 +96,19 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListArea or skins[defaultskin].DrawColumnListArea
|
||||
local drawoverfunc = skin.DrawOverColumnListArea or skins[defaultskin].DrawOverColumnListArea
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListArea or skins[defaultskin].DrawColumnListArea
|
||||
local drawoverfunc = skin.DrawOverColumnListArea or skins[defaultskin].DrawOverColumnListArea
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -146,31 +146,25 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:mousepressed(x, y, button)
|
||||
|
||||
local toplist = self:IsTopList()
|
||||
local toplist = self:IsTopList()
|
||||
local scrollamount = self.mousewheelscrollamount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
if self.hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if self.bar and toplist then
|
||||
|
||||
local bar = self:GetScrollBar()
|
||||
|
||||
if button == "wu" then
|
||||
bar:Scroll(-scrollamount)
|
||||
elseif button == "wd" then
|
||||
bar:Scroll(scrollamount)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -209,13 +203,13 @@ end
|
||||
function newobject:CalculateSize()
|
||||
|
||||
local columnheight = self.parent.columnheight
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local width = self.width
|
||||
local itemheight = columnheight
|
||||
local itemwidth = 0
|
||||
local bar = self.bar
|
||||
local children = self.children
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local width = self.width
|
||||
local itemheight = columnheight
|
||||
local itemwidth = 0
|
||||
local bar = self.bar
|
||||
local children = self.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
itemheight = itemheight + v.height
|
||||
@ -224,23 +218,18 @@ function newobject:CalculateSize()
|
||||
self.itemheight = itemheight
|
||||
|
||||
if self.itemheight > height then
|
||||
|
||||
self.extraheight = self.itemheight - height
|
||||
|
||||
if not bar then
|
||||
table.insert(self.internals, loveframes.objects["scrollbody"]:new(self, "vertical"))
|
||||
self.bar = true
|
||||
self:GetScrollBar().autoscroll = self.parent.autoscroll
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if bar then
|
||||
self.internals[1]:Remove()
|
||||
self.bar = false
|
||||
self.offsety = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -252,20 +241,16 @@ end
|
||||
function newobject:RedoLayout()
|
||||
|
||||
local children = self.children
|
||||
local starty = 0
|
||||
local startx = 0
|
||||
local bar = self.bar
|
||||
local display = self.display
|
||||
local starty = 0
|
||||
local startx = 0
|
||||
local bar = self.bar
|
||||
local display = self.display
|
||||
|
||||
if #children > 0 then
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
||||
local height = v.height
|
||||
|
||||
v.staticx = startx
|
||||
v.staticy = starty
|
||||
|
||||
if bar then
|
||||
v:SetWidth(self.width - self.internals[1].width)
|
||||
self.internals[1].staticx = self.width - self.internals[1].width
|
||||
@ -273,13 +258,9 @@ function newobject:RedoLayout()
|
||||
else
|
||||
v:SetWidth(self.width)
|
||||
end
|
||||
|
||||
starty = starty + v.height
|
||||
|
||||
v.lastheight = v.height
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -291,8 +272,7 @@ end
|
||||
function newobject:AddRow(data)
|
||||
|
||||
local row = loveframes.objects["columnlistrow"]:new(self, data)
|
||||
|
||||
local colorindex = self.rowcolorindex
|
||||
local colorindex = self.rowcolorindex
|
||||
local colorindexmax = self.rowcolorindexmax
|
||||
|
||||
if colorindex == colorindexmax then
|
||||
@ -336,7 +316,7 @@ function newobject:Sort(column, desc)
|
||||
self.rowcolorindex = 1
|
||||
|
||||
local colorindexmax = self.rowcolorindexmax
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
|
||||
table.sort(children, function(a, b)
|
||||
if desc then
|
||||
@ -347,17 +327,13 @@ function newobject:Sort(column, desc)
|
||||
end)
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
||||
local colorindex = self.rowcolorindex
|
||||
|
||||
v.colorindex = colorindex
|
||||
|
||||
if colorindex == colorindexmax then
|
||||
self.rowcolorindex = 1
|
||||
else
|
||||
self.rowcolorindex = colorindex + 1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self:CalculateSize()
|
||||
|
@ -12,16 +12,16 @@ local newobject = loveframes.NewObject("columnlistrow", "loveframes_object_colum
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent, data)
|
||||
|
||||
self.type = "columnlistrow"
|
||||
self.parent = parent
|
||||
self.colorindex = self.parent.rowcolorindex
|
||||
self.font = loveframes.basicfontsmall
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.textx = 5
|
||||
self.texty = 5
|
||||
self.internal = true
|
||||
self.columndata = data
|
||||
self.type = "columnlistrow"
|
||||
self.parent = parent
|
||||
self.colorindex = self.parent.rowcolorindex
|
||||
self.font = loveframes.basicfontsmall
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
self.textx = 5
|
||||
self.texty = 5
|
||||
self.internal = true
|
||||
self.columndata = data
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -34,7 +34,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -44,7 +44,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
@ -73,14 +73,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListRow or skins[defaultskin].DrawColumnListRow
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListRow or skins[defaultskin].DrawColumnListRow
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -104,13 +104,10 @@ function newobject:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
if self.hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -127,8 +124,8 @@ function newobject:mousereleased(x, y, button)
|
||||
|
||||
if self.hover and button == "l" then
|
||||
|
||||
local parent1 = self:GetParent()
|
||||
local parent2 = parent1:GetParent()
|
||||
local parent1 = self:GetParent()
|
||||
local parent2 = parent1:GetParent()
|
||||
local onrowclicked = parent2.OnRowClicked
|
||||
|
||||
if onrowclicked then
|
||||
|
@ -12,17 +12,17 @@ local newobject = loveframes.NewObject("columnlistheader", "loveframes_object_co
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(name, parent)
|
||||
|
||||
self.type = "columnlistheader"
|
||||
self.parent = parent
|
||||
self.name = name
|
||||
self.width = 80
|
||||
self.height = self.parent.columnheight
|
||||
self.hover = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.type = "columnlistheader"
|
||||
self.parent = parent
|
||||
self.name = name
|
||||
self.width = 80
|
||||
self.height = self.parent.columnheight
|
||||
self.hover = false
|
||||
self.down = false
|
||||
self.clickable = true
|
||||
self.enabled = true
|
||||
self.descending = true
|
||||
self.internal = true
|
||||
self.internal = true
|
||||
|
||||
table.insert(parent.children, self)
|
||||
|
||||
@ -54,7 +54,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -105,14 +105,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListHeader or skins[defaultskin].DrawColumnListHeader
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawColumnListHeader or skins[defaultskin].DrawColumnListHeader
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -132,16 +132,12 @@ end
|
||||
function newobject:mousepressed(x, y, button)
|
||||
|
||||
if self.hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" and button == "l" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -156,11 +152,11 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local clickable = self.clickable
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
local enabled = self.enabled
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and down and clickable and button == "l" then
|
||||
if enabled then
|
||||
|
@ -12,14 +12,14 @@ local newobject = loveframes.NewObject("linenumberspanel", "loveframes_object_li
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent)
|
||||
|
||||
self.parent = parent
|
||||
self.type = "linenumberspanel"
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.offsety = 0
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.internal = true
|
||||
self.parent = parent
|
||||
self.type = "linenumberspanel"
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.offsety = 0
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.internal = true
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -41,14 +41,14 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local height = self.parent.height
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local height = self.parent.height
|
||||
local parentinternals = parent.internals
|
||||
|
||||
self.height = height
|
||||
self.offsety = self.parent.offsety - self.parent.textoffsety
|
||||
self.height = height
|
||||
self.offsety = self.parent.offsety - self.parent.textoffsety
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base then
|
||||
@ -82,16 +82,16 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawLineNumbersPanel or skins[defaultskin].DrawLineNumbersPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawLineNumbersPanel or skins[defaultskin].DrawLineNumbersPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
|
||||
if self.parent.hbar then
|
||||
stencilfunc = function() love.graphics.rectangle("fill", self.parent.x, self.parent.y, self.width, self.parent.height - 16) end
|
||||
@ -127,13 +127,10 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -12,14 +12,14 @@ local newobject = loveframes.NewObject("modalbackground", "loveframes_object_mod
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(object)
|
||||
|
||||
self.type = "modalbackground"
|
||||
self.width = love.graphics.getWidth()
|
||||
self.height = love.graphics.getHeight()
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.internal = true
|
||||
self.parent = loveframes.base
|
||||
self.object = object
|
||||
self.type = "modalbackground"
|
||||
self.width = love.graphics.getWidth()
|
||||
self.height = love.graphics.getHeight()
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.internal = true
|
||||
self.parent = loveframes.base
|
||||
self.object = object
|
||||
|
||||
table.insert(loveframes.base.children, self)
|
||||
|
||||
@ -38,7 +38,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -47,9 +47,9 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local object = self.object
|
||||
local update = self.Update
|
||||
local base = loveframes.base
|
||||
local object = self.object
|
||||
local update = self.Update
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
|
||||
if #basechildren > 1 then
|
||||
@ -80,14 +80,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawModalBackground or skins[defaultskin].DrawModalBackground
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
|
@ -12,28 +12,28 @@ local newobject = loveframes.NewObject("multichoicelist", "loveframes_object_mul
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(object)
|
||||
|
||||
self.type = "multichoicelist"
|
||||
self.parent = loveframes.base
|
||||
self.list = object
|
||||
self.x = object.x
|
||||
self.y = object.y + self.list.height
|
||||
self.width = self.list.width
|
||||
self.height = 0
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.padding = self.list.listpadding
|
||||
self.spacing = self.list.listspacing
|
||||
self.buttonscrollamount = object.buttonscrollamount
|
||||
self.type = "multichoicelist"
|
||||
self.parent = loveframes.base
|
||||
self.list = object
|
||||
self.x = object.x
|
||||
self.y = object.y + self.list.height
|
||||
self.width = self.list.width
|
||||
self.height = 0
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.padding = self.list.listpadding
|
||||
self.spacing = self.list.listspacing
|
||||
self.buttonscrollamount = object.buttonscrollamount
|
||||
self.mousewheelscrollamount = object.mousewheelscrollamount
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.canremove = false
|
||||
self.internal = true
|
||||
self.vbar = false
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.canremove = false
|
||||
self.internal = true
|
||||
self.vbar = false
|
||||
self.children = {}
|
||||
self.internals = {}
|
||||
|
||||
for k, v in ipairs(object.choices) do
|
||||
local row = loveframes.objects["multichoicerow"]:new()
|
||||
@ -54,7 +54,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -63,15 +63,15 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local width = love.graphics.getWidth()
|
||||
local height = love.graphics.getHeight()
|
||||
local x, y = love.mouse.getPosition()
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local upadte = self.Update
|
||||
local width = love.graphics.getWidth()
|
||||
local height = love.graphics.getHeight()
|
||||
local x, y = love.mouse.getPosition()
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local upadte = self.Update
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base then
|
||||
@ -118,25 +118,25 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:draw()
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
|
||||
if not visible then
|
||||
return
|
||||
end
|
||||
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoiceList or skins[defaultskin].DrawMultiChoiceList
|
||||
local drawoverfunc = skin.DrawOverMultiChoiceList or skins[defaultskin].DrawOverMultiChoiceList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoiceList or skins[defaultskin].DrawMultiChoiceList
|
||||
local drawoverfunc = skin.DrawOverMultiChoiceList or skins[defaultskin].DrawOverMultiChoiceList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -180,10 +180,10 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local toplist = self:IsTopList()
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local toplist = self:IsTopList()
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local scrollamount = self.mousewheelscrollamount
|
||||
|
||||
if not selfcol and self.canremove and button == "l" then
|
||||
@ -191,13 +191,11 @@ function newobject:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
if self.vbar and toplist then
|
||||
|
||||
if button == "wu" then
|
||||
internals[1].internals[1].internals[1]:Scroll(-scrollamount)
|
||||
elseif button == "wd" then
|
||||
internals[1].internals[1].internals[1]:Scroll(scrollamount)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -223,7 +221,7 @@ function newobject:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
|
||||
self.canremove = true
|
||||
|
||||
@ -248,7 +246,6 @@ function newobject:AddItem(object)
|
||||
end
|
||||
|
||||
object.parent = self
|
||||
|
||||
table.insert(self.children, object)
|
||||
|
||||
self:CalculateSize()
|
||||
@ -265,11 +262,9 @@ function newobject:RemoveItem(object)
|
||||
local children = self.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
||||
if v == object then
|
||||
table.remove(children, k)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self:CalculateSize()
|
||||
@ -297,13 +292,13 @@ function newobject:CalculateSize()
|
||||
self.height = love.graphics.getHeight()
|
||||
end
|
||||
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local itemheight = self.padding
|
||||
local vbar = self.vbar
|
||||
local children = self.children
|
||||
local vbar = self.vbar
|
||||
local children = self.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
itemheight = itemheight + v.height + spacing
|
||||
@ -312,23 +307,18 @@ function newobject:CalculateSize()
|
||||
self.itemheight = (itemheight - spacing) + padding
|
||||
|
||||
if self.itemheight > height then
|
||||
|
||||
self.extraheight = self.itemheight - height
|
||||
|
||||
if not vbar then
|
||||
local scroll = loveframes.objects["scrollbody"]:new(self, "vertical")
|
||||
table.insert(self.internals, scroll)
|
||||
self.vbar = true
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if vbar then
|
||||
self.internals[1]:Remove()
|
||||
self.vbar = false
|
||||
self.offsety = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -340,18 +330,15 @@ end
|
||||
function newobject:RedoLayout()
|
||||
|
||||
local children = self.children
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local starty = padding
|
||||
local vbar = self.vbar
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local starty = padding
|
||||
local vbar = self.vbar
|
||||
|
||||
if #children > 0 then
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
||||
v.staticx = padding
|
||||
v.staticy = starty
|
||||
|
||||
if vbar then
|
||||
v.width = (self.width - self.internals[1].width) - padding * 2
|
||||
self.internals[1].staticx = self.width - self.internals[1].width
|
||||
@ -359,12 +346,9 @@ function newobject:RedoLayout()
|
||||
else
|
||||
v.width = self.width - padding * 2
|
||||
end
|
||||
|
||||
starty = starty + v.height
|
||||
starty = starty + spacing
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -389,9 +373,13 @@ function newobject:SetSpacing(amount)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: Close()
|
||||
- desc: closes the object
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:Close()
|
||||
|
||||
self:Remove()
|
||||
self.list.haslist = false
|
||||
|
||||
|
||||
end
|
@ -12,14 +12,14 @@ local newobject = loveframes.NewObject("multichoicerow", "loveframes_object_mult
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "multichoicerow"
|
||||
self.text = ""
|
||||
self.width = 50
|
||||
self.height = 25
|
||||
self.hover = false
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.canclick = false
|
||||
self.type = "multichoicerow"
|
||||
self.text = ""
|
||||
self.width = 50
|
||||
self.height = 25
|
||||
self.hover = false
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.canclick = false
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -32,7 +32,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -42,7 +42,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
@ -83,13 +83,13 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoiceRow or skins[defaultskin].DrawMultiChoiceRow
|
||||
local draw = self.Draw
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoiceRow or skins[defaultskin].DrawMultiChoiceRow
|
||||
local draw = self.Draw
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -117,10 +117,8 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -154,7 +152,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:keypressed(key, unicode)
|
||||
|
||||
local text = self.text
|
||||
local text = self.text
|
||||
local selectedobject = loveframes.selectedobject
|
||||
|
||||
if key == "return" and selectedobject == self then
|
||||
|
@ -12,16 +12,16 @@ local newobject = loveframes.NewObject("scrollarea", "loveframes_object_scrollar
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent, bartype)
|
||||
|
||||
self.type = "scroll-area"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.scrolldelay = 0
|
||||
self.delayamount = 0.05
|
||||
self.down = false
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
self.type = "scroll-area"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.scrolldelay = 0
|
||||
self.delayamount = 0.05
|
||||
self.down = false
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
|
||||
table.insert(self.internals, loveframes.objects["scrollbar"]:new(self, bartype))
|
||||
|
||||
@ -36,7 +36,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -46,7 +46,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -57,34 +57,32 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local parent = self.parent
|
||||
local pinternals = parent.internals
|
||||
local button = pinternals[2]
|
||||
local bartype = self.bartype
|
||||
local time = love.timer.getTime()
|
||||
local x, y = love.mouse.getPosition()
|
||||
local listo = parent.parent
|
||||
local down = self.down
|
||||
local parent = self.parent
|
||||
local pinternals = parent.internals
|
||||
local button = pinternals[2]
|
||||
local bartype = self.bartype
|
||||
local time = love.timer.getTime()
|
||||
local x, y = love.mouse.getPosition()
|
||||
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
|
||||
local internals = self.internals
|
||||
local bar = internals[1]
|
||||
local hover = self.hover
|
||||
|
||||
if button then
|
||||
|
||||
if bartype == "vertical" then
|
||||
self.staticx = 0
|
||||
self.staticy = button.height - 1
|
||||
self.width = parent.width
|
||||
self.height = parent.height - button.height*2 + 2
|
||||
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
|
||||
self.staticx = button.width - 1
|
||||
self.staticy = 0
|
||||
self.width = parent.width - button.width*2 + 2
|
||||
self.height = parent.height
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if down then
|
||||
@ -131,15 +129,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollArea or skins[defaultskin].DrawScrollArea
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -168,23 +166,20 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local listo = self.parent.parent
|
||||
local time = love.timer.getTime()
|
||||
local internals = self.internals
|
||||
local bar = internals[1]
|
||||
local hover = self.hover
|
||||
local listo = self.parent.parent
|
||||
local time = love.timer.getTime()
|
||||
local internals = self.internals
|
||||
local bar = internals[1]
|
||||
local hover = self.hover
|
||||
local delayamount = self.delayamount
|
||||
|
||||
if hover and button == "l" then
|
||||
self.down = true
|
||||
self.scrolldelay = time + delayamount + 0.5
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
if y > self.internals[1].y then
|
||||
bar:Scroll(bar.height)
|
||||
@ -198,9 +193,7 @@ function newobject:mousepressed(x, y, button)
|
||||
bar:Scroll(-bar.width)
|
||||
end
|
||||
end
|
||||
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
|
@ -12,34 +12,34 @@ local newobject = loveframes.NewObject("scrollbar", "loveframes_object_scrollbar
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent, bartype)
|
||||
|
||||
self.type = "scrollbar"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.maxx = 0
|
||||
self.maxy = 0
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.starty = 0
|
||||
self.lastwidth = 0
|
||||
self.lastheight = 0
|
||||
self.lastx = 0
|
||||
self.lasty = 0
|
||||
self.internal = true
|
||||
self.hover = false
|
||||
self.dragging = false
|
||||
self.autoscroll = false
|
||||
self.internal = true
|
||||
self.type = "scrollbar"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.maxx = 0
|
||||
self.maxy = 0
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.starty = 0
|
||||
self.lastwidth = 0
|
||||
self.lastheight = 0
|
||||
self.lastx = 0
|
||||
self.lasty = 0
|
||||
self.internal = true
|
||||
self.hover = false
|
||||
self.dragging = false
|
||||
self.autoscroll = false
|
||||
self.internal = true
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
self.width = self.parent.width
|
||||
self.height = 5
|
||||
self.width = self.parent.width
|
||||
self.height = 5
|
||||
elseif self.bartype == "horizontal" then
|
||||
self.width = 5
|
||||
self.height = self.parent.height
|
||||
self.width = 5
|
||||
self.height = self.parent.height
|
||||
end
|
||||
|
||||
-- apply template properties to the object
|
||||
@ -53,7 +53,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -77,22 +77,18 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
if bartype == "vertical" then
|
||||
|
||||
local parent = self.parent
|
||||
local listo = parent.parent.parent
|
||||
local listo = parent.parent.parent
|
||||
local height = parent.height * (listo.height/listo.itemheight)
|
||||
local update = self.Update
|
||||
|
||||
if height < 20 then
|
||||
self.height = 20
|
||||
else
|
||||
self.height = height
|
||||
end
|
||||
|
||||
self.maxy = parent.y + (parent.height - self.height)
|
||||
self.x = parent.x + parent.width - self.width
|
||||
self.y = parent.y + self.staticy
|
||||
|
||||
if dragging then
|
||||
if self.staticy ~= self.lasty then
|
||||
if listo.OnScroll then
|
||||
@ -102,49 +98,54 @@ function newobject:update(dt)
|
||||
end
|
||||
self.staticy = self.starty + (y - self.clicky)
|
||||
end
|
||||
|
||||
local space = (self.maxy - parent.y)
|
||||
local remaining = (0 + self.staticy)
|
||||
local percent = remaining/space
|
||||
local extra = listo.extraheight * percent
|
||||
local space = (self.maxy - parent.y)
|
||||
local remaining = (0 + self.staticy)
|
||||
local percent = remaining/space
|
||||
local extra = listo.extraheight * percent
|
||||
local autoscroll = self.autoscroll
|
||||
local lastheight = self.lastheight
|
||||
|
||||
listo.offsety = 0 + extra
|
||||
|
||||
if self.staticy > space then
|
||||
self.staticy = space
|
||||
listo.offsety = listo.extraheight
|
||||
end
|
||||
|
||||
if self.staticy < 0 then
|
||||
self.staticy = 0
|
||||
listo.offsety = 0
|
||||
end
|
||||
|
||||
if autoscroll then
|
||||
if listo.itemheight > lastheight then
|
||||
local type = listo.type
|
||||
self.lastheight = listo.itemheight
|
||||
self:Scroll(self.maxy)
|
||||
if type == "textinput" then
|
||||
local indicatory = listo.indicatory
|
||||
local font = listo.font
|
||||
local theight = font:getHeight("a")
|
||||
local y = listo.y
|
||||
local height = listo.height
|
||||
local linecount = #listo.lines
|
||||
local parentheight = self.parent.height
|
||||
if (indicatory + theight) > (y + height) then
|
||||
self:Scroll(parentheight/linecount)
|
||||
end
|
||||
else
|
||||
local maxy = self.maxy
|
||||
self:Scroll(maxy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif bartype == "horizontal" then
|
||||
|
||||
local parent = self.parent
|
||||
local listo = self.parent.parent.parent
|
||||
local width = self.parent.width * (listo.width/listo.itemwidth)
|
||||
|
||||
local listo = self.parent.parent.parent
|
||||
local width = self.parent.width * (listo.width/listo.itemwidth)
|
||||
if width < 20 then
|
||||
self.width = 20
|
||||
else
|
||||
self.width = width
|
||||
end
|
||||
|
||||
self.maxx = parent.x + (parent.width) - self.width
|
||||
self.x = parent.x + self.staticx
|
||||
self.y = parent.y + self.staticy
|
||||
|
||||
if dragging then
|
||||
if self.staticx ~= self.lastx then
|
||||
if listo.OnScroll then
|
||||
@ -154,16 +155,13 @@ function newobject:update(dt)
|
||||
end
|
||||
self.staticx = self.startx + (x - self.clickx)
|
||||
end
|
||||
|
||||
local space = (self.maxx - parent.x)
|
||||
local remaining = (0 + self.staticx)
|
||||
local percent = remaining/space
|
||||
local extra = listo.extrawidth * percent
|
||||
local autoscroll = self.autoscroll
|
||||
local lastwidth = self.lastwidth
|
||||
|
||||
listo.offsetx = 0 + extra
|
||||
|
||||
if self.staticx > space then
|
||||
self.staticx = space
|
||||
listo.offsetx = listo.extrawidth
|
||||
@ -173,14 +171,12 @@ function newobject:update(dt)
|
||||
self.staticx = 0
|
||||
listo.offsetx = 0
|
||||
end
|
||||
|
||||
if autoscroll then
|
||||
if listo.itemwidth > lastwidth then
|
||||
self.lastwidth = listo.itemwidth
|
||||
self:Scroll(self.maxx)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if update then
|
||||
@ -201,14 +197,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollBar or skins[defaultskin].DrawScrollBar
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -228,7 +224,7 @@ end
|
||||
function newobject:mousepressed(x, y, button)
|
||||
|
||||
local visible = self.visible
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
|
||||
if not visible then
|
||||
return
|
||||
@ -247,18 +243,14 @@ function newobject:mousepressed(x, y, button)
|
||||
local dragging = self.dragging
|
||||
|
||||
if not dragging then
|
||||
|
||||
if button == "l" then
|
||||
|
||||
self.starty = self.staticy
|
||||
self.startx = self.staticx
|
||||
self.clickx = x
|
||||
self.clicky = y
|
||||
self.dragging = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -307,13 +299,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:Scroll(amount)
|
||||
|
||||
local bartype = self.bartype
|
||||
local listo = self.parent.parent.parent
|
||||
local bartype = self.bartype
|
||||
local listo = self.parent.parent.parent
|
||||
local onscroll = listo.OnScroll
|
||||
|
||||
if bartype == "vertical" then
|
||||
local newy = (self.y + amount)
|
||||
|
||||
if newy > self.maxy then
|
||||
self.staticy = self.maxy - self.parent.y
|
||||
elseif newy < self.parent.y then
|
||||
@ -323,7 +314,6 @@ function newobject:Scroll(amount)
|
||||
end
|
||||
elseif bartype == "horizontal" then
|
||||
local newx = (self.x + amount)
|
||||
|
||||
if newx > self.maxx then
|
||||
self.staticx = self.maxx - self.parent.x
|
||||
elseif newx < self.parent.x then
|
||||
|
@ -12,24 +12,24 @@ local newobject = loveframes.NewObject("scrollbody", "loveframes_object_scrollbo
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent, bartype)
|
||||
|
||||
self.type = "scrollbody"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
self.type = "scrollbody"
|
||||
self.bartype = bartype
|
||||
self.parent = parent
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.internal = true
|
||||
self.internals = {}
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
self.width = 16
|
||||
self.height = self.parent.height
|
||||
self.staticx = self.parent.width - self.width
|
||||
self.staticy = 0
|
||||
self.width = 16
|
||||
self.height = self.parent.height
|
||||
self.staticx = self.parent.width - self.width
|
||||
self.staticy = 0
|
||||
elseif self.bartype == "horizontal" then
|
||||
self.width = self.parent.width
|
||||
self.height = 16
|
||||
self.staticx = 0
|
||||
self.staticy = self.parent.height - self.height
|
||||
self.width = self.parent.width
|
||||
self.height = 16
|
||||
self.staticx = 0
|
||||
self.staticy = self.parent.height - self.height
|
||||
end
|
||||
|
||||
table.insert(self.internals, loveframes.objects["scrollarea"]:new(self, bartype))
|
||||
@ -37,9 +37,8 @@ function newobject:initialize(parent, bartype)
|
||||
local bar = self.internals[1].internals[1]
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
|
||||
local upbutton = loveframes.objects["scrollbutton"]:new("up")
|
||||
upbutton.parent = self
|
||||
local upbutton = loveframes.objects["scrollbutton"]:new("up")
|
||||
upbutton.parent = self
|
||||
upbutton.Update = function(object, dt)
|
||||
upbutton.staticx = 0 + self.width - upbutton.width
|
||||
upbutton.staticy = 0
|
||||
@ -47,9 +46,8 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(-self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
local downbutton = loveframes.objects["scrollbutton"]:new("down")
|
||||
downbutton.parent = self
|
||||
local downbutton = loveframes.objects["scrollbutton"]:new("down")
|
||||
downbutton.parent = self
|
||||
downbutton.Update = function(object, dt)
|
||||
downbutton.staticx = 0 + self.width - downbutton.width
|
||||
downbutton.staticy = 0 + self.height - downbutton.height
|
||||
@ -57,14 +55,11 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(self.internals, upbutton)
|
||||
table.insert(self.internals, downbutton)
|
||||
|
||||
elseif self.bartype == "horizontal" then
|
||||
|
||||
local leftbutton = loveframes.objects["scrollbutton"]:new("left")
|
||||
leftbutton.parent = self
|
||||
local leftbutton = loveframes.objects["scrollbutton"]:new("left")
|
||||
leftbutton.parent = self
|
||||
leftbutton.Update = function(object, dt)
|
||||
leftbutton.staticx = 0
|
||||
leftbutton.staticy = 0
|
||||
@ -72,9 +67,8 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(-self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
local rightbutton = loveframes.objects["scrollbutton"]:new("right")
|
||||
rightbutton.parent = self
|
||||
local rightbutton = loveframes.objects["scrollbutton"]:new("right")
|
||||
rightbutton.parent = self
|
||||
rightbutton.Update = function(object, dt)
|
||||
rightbutton.staticx = 0 + self.width - rightbutton.width
|
||||
rightbutton.staticy = 0
|
||||
@ -82,10 +76,8 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(self.internals, leftbutton)
|
||||
table.insert(self.internals, rightbutton)
|
||||
|
||||
end
|
||||
|
||||
-- apply template properties to the object
|
||||
@ -99,7 +91,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -108,9 +100,9 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local internals = self.internals
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -143,15 +135,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollBody or skins[defaultskin].DrawScrollBody
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
|
@ -12,13 +12,13 @@ local newobject = loveframes.NewObject("scrollbutton", "loveframes_object_scroll
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(scrolltype)
|
||||
|
||||
self.type = "scrollbutton"
|
||||
self.scrolltype = scrolltype
|
||||
self.width = 16
|
||||
self.height = 16
|
||||
self.down = false
|
||||
self.internal = true
|
||||
self.OnClick = function() end
|
||||
self.type = "scrollbutton"
|
||||
self.scrolltype = scrolltype
|
||||
self.width = 16
|
||||
self.height = 16
|
||||
self.down = false
|
||||
self.internal = true
|
||||
self.OnClick = function() end
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -31,7 +31,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -42,9 +42,9 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
@ -83,14 +83,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawScrollButton or skins[defaultskin].DrawScrollButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -118,16 +118,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -144,33 +140,20 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and down then
|
||||
|
||||
if button == "l" then
|
||||
onclick(x, y, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetText(text)
|
||||
- desc: sets the object's text
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetText(text)
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetScrollType()
|
||||
- desc: gets the object's scroll type
|
||||
|
@ -12,20 +12,20 @@ local newobject = loveframes.NewObject("sliderbutton", "loveframes_object_slider
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent)
|
||||
|
||||
self.type = "sliderbutton"
|
||||
self.width = 10
|
||||
self.height = 20
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.startx = 0
|
||||
self.clickx = 0
|
||||
self.starty = 0
|
||||
self.clicky = 0
|
||||
self.intervals = true
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.dragging = false
|
||||
self.parent = parent
|
||||
self.type = "sliderbutton"
|
||||
self.width = 10
|
||||
self.height = 20
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.startx = 0
|
||||
self.clickx = 0
|
||||
self.starty = 0
|
||||
self.clicky = 0
|
||||
self.intervals = true
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.dragging = false
|
||||
self.parent = parent
|
||||
|
||||
-- apply template properties to the object
|
||||
loveframes.templates.ApplyToObject(self)
|
||||
@ -38,7 +38,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -49,23 +49,26 @@ function newobject:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local intervals = self.intervals
|
||||
local progress = 0
|
||||
local nvalue = 0
|
||||
local pvalue = self.parent.value
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local parent = self.parent
|
||||
local slidetype = parent.slidetype
|
||||
local dragging = self.dragging
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local x, y = love.mouse.getPosition()
|
||||
local intervals = self.intervals
|
||||
local progress = 0
|
||||
local nvalue = 0
|
||||
local pvalue = self.parent.value
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local parent = self.parent
|
||||
local slidetype = parent.slidetype
|
||||
local dragging = self.dragging
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
if not hover then
|
||||
self.down = false
|
||||
if hoverobject == self then
|
||||
self.hover = true
|
||||
end
|
||||
else
|
||||
if hoverobject == self then
|
||||
self.down = true
|
||||
@ -84,52 +87,37 @@ function newobject:update(dt)
|
||||
|
||||
-- start calculations if the button is being dragged
|
||||
if dragging then
|
||||
|
||||
-- calculations for horizontal sliders
|
||||
if slidetype == "horizontal" then
|
||||
|
||||
self.staticx = self.startx + (x - self.clickx)
|
||||
|
||||
progress = self.staticx/(self.parent.width - self.width)
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
|
||||
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
|
||||
|
||||
self.staticx = self.startx + (x - self.clickx)
|
||||
progress = self.staticx/(self.parent.width - self.width)
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
|
||||
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
|
||||
-- calculations for vertical sliders
|
||||
elseif slidetype == "vertical" then
|
||||
|
||||
self.staticy = self.starty + (y - self.clicky)
|
||||
|
||||
local space = self.parent.height - self.height
|
||||
local remaining = (self.parent.height - self.height) - self.staticy
|
||||
local percent = remaining/space
|
||||
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * percent
|
||||
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
|
||||
|
||||
self.staticy = self.starty + (y - self.clicky)
|
||||
local space = self.parent.height - self.height
|
||||
local remaining = (self.parent.height - self.height) - self.staticy
|
||||
local percent = remaining/space
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * percent
|
||||
nvalue = loveframes.util.Round(nvalue, self.parent.decimals)
|
||||
end
|
||||
|
||||
if nvalue > self.parent.max then
|
||||
nvalue = self.parent.max
|
||||
end
|
||||
|
||||
if nvalue < self.parent.min then
|
||||
nvalue = self.parent.min
|
||||
end
|
||||
|
||||
self.parent.value = nvalue
|
||||
|
||||
if self.parent.value == -0 then
|
||||
self.parent.value = math.abs(self.parent.value)
|
||||
end
|
||||
|
||||
if nvalue ~= pvalue and nvalue >= self.parent.min and nvalue <= self.parent.max then
|
||||
if self.parent.OnValueChanged then
|
||||
self.parent.OnValueChanged(self.parent, self.parent.value)
|
||||
end
|
||||
end
|
||||
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
if slidetype == "horizontal" then
|
||||
@ -168,14 +156,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawSliderButton or skins[defaultskin].DrawSliderButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -203,13 +191,10 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
self.dragging = true
|
||||
self.startx = self.staticx
|
||||
@ -217,7 +202,6 @@ function newobject:mousepressed(x, y, button)
|
||||
self.starty = self.staticy
|
||||
self.clicky = y
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -12,18 +12,18 @@ local newobject = loveframes.NewObject("tabbutton", "loveframes_object_tabbutton
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize(parent, text, tabnumber, tip, image)
|
||||
|
||||
self.type = "tabbutton"
|
||||
self.font = loveframes.smallfont
|
||||
self.text = text
|
||||
self.tabnumber = tabnumber
|
||||
self.parent = parent
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.width = 50
|
||||
self.height = 25
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.image = nil
|
||||
self.type = "tabbutton"
|
||||
self.font = loveframes.smallfont
|
||||
self.text = text
|
||||
self.tabnumber = tabnumber
|
||||
self.parent = parent
|
||||
self.staticx = 0
|
||||
self.staticy = 0
|
||||
self.width = 50
|
||||
self.height = 25
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.image = nil
|
||||
|
||||
if tip then
|
||||
self.tooltip = loveframes.objects["tooltip"]:new(self, tip)
|
||||
@ -46,7 +46,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -56,7 +56,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
@ -84,15 +84,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local image = self.image
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local image = self.image
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTabButton or skins[defaultskin].DrawTabButton
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -120,16 +120,12 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.down = true
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -146,16 +142,14 @@ function newobject:mousereleased(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local parent = self.parent
|
||||
local hover = self.hover
|
||||
local parent = self.parent
|
||||
local tabnumber = self.tabnumber
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
if button == "l" then
|
||||
parent:SwitchToTab(tabnumber)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
@ -14,18 +14,18 @@ function newobject:initialize(object, text, width)
|
||||
|
||||
local width = width or 0
|
||||
|
||||
self.type = "tooltip"
|
||||
self.parent = loveframes.base
|
||||
self.object = object or nil
|
||||
self.width = width or 0
|
||||
self.height = 0
|
||||
self.padding = 5
|
||||
self.xoffset = 10
|
||||
self.yoffset = -10
|
||||
self.internal = true
|
||||
self.show = false
|
||||
self.followcursor = true
|
||||
self.alwaysupdate = true
|
||||
self.type = "tooltip"
|
||||
self.parent = loveframes.base
|
||||
self.object = object or nil
|
||||
self.width = width or 0
|
||||
self.height = 0
|
||||
self.padding = 5
|
||||
self.xoffset = 10
|
||||
self.yoffset = -10
|
||||
self.internal = true
|
||||
self.show = false
|
||||
self.followcursor = true
|
||||
self.alwaysupdate = true
|
||||
|
||||
self.text = loveframes.Create("text")
|
||||
self.text:Remove()
|
||||
@ -47,7 +47,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -56,29 +56,25 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local text = self.text
|
||||
local object = self.object
|
||||
local text = self.text
|
||||
local object = self.object
|
||||
local draworder = self.draworder
|
||||
local update = self.Update
|
||||
local update = self.Update
|
||||
|
||||
self.width = text.width + self.padding * 2
|
||||
self.width = text.width + self.padding * 2
|
||||
self.height = text.height + self.padding * 2
|
||||
|
||||
if object then
|
||||
|
||||
if object == loveframes.base then
|
||||
self:Remove()
|
||||
return
|
||||
end
|
||||
|
||||
local hover = object.hover
|
||||
local hover = object.hover
|
||||
local odraworder = object.draworder
|
||||
local ovisible = object.visible
|
||||
local ohover = object.hover
|
||||
|
||||
self.show = ohover
|
||||
local ovisible = object.visible
|
||||
local ohover = object.hover
|
||||
self.show = ohover
|
||||
self.visible = ovisible
|
||||
|
||||
if ohover and ovisible then
|
||||
local top = self:IsTopInternal()
|
||||
if self.followcursor then
|
||||
@ -86,17 +82,12 @@ function newobject:update(dt)
|
||||
self.x = x + self.xoffset
|
||||
self.y = y - self.height + self.yoffset
|
||||
end
|
||||
|
||||
if not top then
|
||||
self:MoveToTop()
|
||||
end
|
||||
|
||||
text:SetPos(self.padding, self.padding)
|
||||
|
||||
end
|
||||
|
||||
local baseparent = object:GetBaseParent()
|
||||
|
||||
if baseparent then
|
||||
if baseparent.removed and baseparent.removed then
|
||||
self:Remove()
|
||||
@ -104,7 +95,6 @@ function newobject:update(dt)
|
||||
elseif object.removed then
|
||||
self:Remove()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
text:update(dt)
|
||||
@ -127,30 +117,27 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local show = self.show
|
||||
local text = self.text
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local show = self.show
|
||||
local text = self.text
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawToolTip or skins[defaultskin].DrawToolTip
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
|
||||
if show then
|
||||
|
||||
if draw then
|
||||
draw(self)
|
||||
else
|
||||
drawfunc(self)
|
||||
end
|
||||
|
||||
text:draw()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
199
objects/list.lua
199
objects/list.lua
@ -12,27 +12,27 @@ local newobject = loveframes.NewObject("list", "loveframes_object_list", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "list"
|
||||
self.display = "vertical"
|
||||
self.width = 300
|
||||
self.height = 150
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.padding = 0
|
||||
self.spacing = 0
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.type = "list"
|
||||
self.display = "vertical"
|
||||
self.width = 300
|
||||
self.height = 150
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.padding = 0
|
||||
self.spacing = 0
|
||||
self.offsety = 0
|
||||
self.offsetx = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.mousewheelscrollamount = 5
|
||||
self.internal = false
|
||||
self.hbar = false
|
||||
self.vbar = false
|
||||
self.autoscroll = false
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.OnScroll = nil
|
||||
self.internal = false
|
||||
self.hbar = false
|
||||
self.vbar = false
|
||||
self.autoscroll = false
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.OnScroll = nil
|
||||
|
||||
end
|
||||
|
||||
@ -42,7 +42,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -51,12 +51,12 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local display = self.display
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local display = self.display
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base then
|
||||
@ -75,14 +75,12 @@ function newobject:update(dt)
|
||||
v:SetClickBounds(self.x, self.y, self.width, self.height)
|
||||
v.y = (v.parent.y + v.staticy) - self.offsety
|
||||
v.x = (v.parent.x + v.staticx) - self.offsetx
|
||||
|
||||
if display == "vertical" then
|
||||
if v.lastheight ~= v.height then
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if update then
|
||||
@ -103,19 +101,19 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawList or skins[defaultskin].DrawList
|
||||
local drawoverfunc = skin.DrawOverList or skins[defaultskin].DrawOverList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawList or skins[defaultskin].DrawList
|
||||
local drawoverfunc = skin.DrawOverList or skins[defaultskin].DrawOverList
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -159,38 +157,30 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local toplist = self:IsTopList()
|
||||
local hover = self.hover
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local toplist = self:IsTopList()
|
||||
local hover = self.hover
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local scrollamount = self.mousewheelscrollamount
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if vbar or hbar then
|
||||
|
||||
if toplist then
|
||||
|
||||
local bar = self:GetScrollBar()
|
||||
|
||||
if button == "wu" then
|
||||
bar:Scroll(-scrollamount)
|
||||
elseif button == "wd" then
|
||||
bar:Scroll(scrollamount)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -246,83 +236,63 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:CalculateSize()
|
||||
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local width = self.width
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local itemheight = self.padding
|
||||
local itemwidth = self.padding
|
||||
local display = self.display
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local numitems = #self.children
|
||||
local height = self.height
|
||||
local width = self.width
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local itemheight = self.padding
|
||||
local itemwidth = self.padding
|
||||
local display = self.display
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
if display == "vertical" then
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
itemheight = itemheight + v.height + spacing
|
||||
end
|
||||
|
||||
self.itemheight = (itemheight - spacing) + padding
|
||||
|
||||
local itemheight = self.itemheight
|
||||
|
||||
if itemheight > height then
|
||||
|
||||
self.extraheight = itemheight - height
|
||||
|
||||
if not vbar then
|
||||
local scrollbar = loveframes.objects["scrollbody"]:new(self, display)
|
||||
table.insert(internals, scrollbar)
|
||||
self.vbar = true
|
||||
self:GetScrollBar().autoscroll = self.autoscroll
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if vbar then
|
||||
local bar = internals[1]
|
||||
bar:Remove()
|
||||
self.vbar = false
|
||||
self.offsety = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
elseif display == "horizontal" then
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
itemwidth = itemwidth + v.width + spacing
|
||||
end
|
||||
|
||||
self.itemwidth = (itemwidth - spacing) + padding
|
||||
|
||||
local itemwidth = self.itemwidth
|
||||
|
||||
if itemwidth > width then
|
||||
|
||||
self.extrawidth = itemwidth - width
|
||||
|
||||
if not hbar then
|
||||
local scrollbar = loveframes.objects["scrollbody"]:new(self, display)
|
||||
table.insert(internals, scrollbar)
|
||||
self.hbar = true
|
||||
self:GetScrollBar().autoscroll = self.autoscroll
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if hbar then
|
||||
local bar = internals[1]
|
||||
bar:Remove()
|
||||
self.hbar = false
|
||||
self.offsetx = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -334,26 +304,21 @@ end
|
||||
function newobject:RedoLayout()
|
||||
|
||||
local children = self.children
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local starty = padding
|
||||
local startx = padding
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local display = self.display
|
||||
local padding = self.padding
|
||||
local spacing = self.spacing
|
||||
local starty = padding
|
||||
local startx = padding
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local display = self.display
|
||||
|
||||
if #children > 0 then
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
||||
if display == "vertical" then
|
||||
|
||||
local height = v.height
|
||||
|
||||
v.staticx = padding
|
||||
v.staticy = starty
|
||||
v.lastheight = v.height
|
||||
|
||||
if vbar then
|
||||
if v.width + padding > (self.width - self.internals[1].width) then
|
||||
v:SetWidth((self.width - self.internals[1].width) - (padding*2))
|
||||
@ -368,15 +333,11 @@ function newobject:RedoLayout()
|
||||
v:SetWidth(self.width - (padding*2))
|
||||
end
|
||||
end
|
||||
|
||||
starty = starty + v.height
|
||||
starty = starty + spacing
|
||||
|
||||
elseif display == "horizontal" then
|
||||
|
||||
v.staticx = startx
|
||||
v.staticy = padding
|
||||
|
||||
if hbar then
|
||||
if v.height + padding > (self.height - self.internals[1].height) then
|
||||
v:SetHeight((self.height - self.internals[1].height) - (padding*2))
|
||||
@ -391,14 +352,10 @@ function newobject:RedoLayout()
|
||||
v:SetHeight(self.height - (padding*2))
|
||||
end
|
||||
end
|
||||
|
||||
startx = startx + v.width
|
||||
startx = startx + spacing
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -409,14 +366,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetDisplayType(type)
|
||||
|
||||
local children = self.children
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.display = type
|
||||
self.vbar = false
|
||||
self.hbar = false
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.display = type
|
||||
self.vbar = false
|
||||
self.hbar = false
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.internals = {}
|
||||
|
||||
if numchildren > 0 then
|
||||
@ -442,8 +399,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetPadding(amount)
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.padding = amount
|
||||
|
||||
@ -460,8 +417,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetSpacing(amount)
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.spacing = amount
|
||||
|
||||
@ -527,14 +484,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetScrollBar()
|
||||
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local internals = self.internals
|
||||
|
||||
if vbar or hbar then
|
||||
local scrollbody = internals[1]
|
||||
local scrollarea = scrollbody.internals[1]
|
||||
local scrollbar = scrollarea.internals[1]
|
||||
local scrollbar = scrollarea.internals[1]
|
||||
return scrollbar
|
||||
else
|
||||
return false
|
||||
|
@ -12,19 +12,19 @@ local newobject = loveframes.NewObject("multichoice", "loveframes_object_multich
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "multichoice"
|
||||
self.choice = ""
|
||||
self.text = "Select an option"
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.listpadding = 0
|
||||
self.listspacing = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.type = "multichoice"
|
||||
self.choice = ""
|
||||
self.text = "Select an option"
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.listpadding = 0
|
||||
self.listspacing = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.mousewheelscrollamount = 5
|
||||
self.haslist = false
|
||||
self.internal = false
|
||||
self.choices = {}
|
||||
self.listheight = nil
|
||||
self.haslist = false
|
||||
self.internal = false
|
||||
self.choices = {}
|
||||
self.listheight = nil
|
||||
|
||||
end
|
||||
|
||||
@ -34,7 +34,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -44,7 +44,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
@ -73,14 +73,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawMultiChoice or skins[defaultskin].DrawMultiChoice
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -105,21 +105,17 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
local haslist = self.haslist
|
||||
|
||||
if hover and not haslist and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
self.haslist = true
|
||||
self.list = loveframes.objects["multichoicelist"]:new(self)
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -12,11 +12,11 @@ local newobject = loveframes.NewObject("panel", "loveframes_object_panel", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "panel"
|
||||
self.width = 200
|
||||
self.height = 50
|
||||
self.internal = false
|
||||
self.children = {}
|
||||
self.type = "panel"
|
||||
self.width = 200
|
||||
self.height = 50
|
||||
self.internal = false
|
||||
self.children = {}
|
||||
|
||||
end
|
||||
|
||||
@ -36,9 +36,9 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base and parent.type ~= "list" then
|
||||
@ -70,15 +70,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local children = self.children
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawPanel or skins[defaultskin].DrawPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -109,16 +109,13 @@ function newobject:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
@ -12,20 +12,20 @@ local newobject = loveframes.NewObject("progressbar", "loveframes_object_progres
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "progressbar"
|
||||
self.width = 100
|
||||
self.height = 25
|
||||
self.min = 0
|
||||
self.max = 10
|
||||
self.value = 0
|
||||
self.barwidth = 0
|
||||
self.lerprate = 1000
|
||||
self.lerpvalue = 0
|
||||
self.lerpto = 0
|
||||
self.lerpfrom = 0
|
||||
self.completed = false
|
||||
self.lerp = false
|
||||
self.internal = false
|
||||
self.type = "progressbar"
|
||||
self.width = 100
|
||||
self.height = 25
|
||||
self.min = 0
|
||||
self.max = 10
|
||||
self.value = 0
|
||||
self.barwidth = 0
|
||||
self.lerprate = 1000
|
||||
self.lerpvalue = 0
|
||||
self.lerpto = 0
|
||||
self.lerpfrom = 0
|
||||
self.completed = false
|
||||
self.lerp = false
|
||||
self.internal = false
|
||||
self.OnComplete = nil
|
||||
|
||||
end
|
||||
@ -36,7 +36,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -45,16 +45,16 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local lerp = self.lerp
|
||||
local lerprate = self.lerprate
|
||||
local lerpvalue = self.lerpvalue
|
||||
local lerpto = self.lerpto
|
||||
local lerpfrom = self.lerpfrom
|
||||
local value = self.value
|
||||
local completed = self.completed
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local lerp = self.lerp
|
||||
local lerprate = self.lerprate
|
||||
local lerpvalue = self.lerpvalue
|
||||
local lerpto = self.lerpto
|
||||
local lerpfrom = self.lerpfrom
|
||||
local value = self.value
|
||||
local completed = self.completed
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local oncomplete = self.OnComplete
|
||||
|
||||
self:CheckHover()
|
||||
@ -76,21 +76,17 @@ function newobject:update(dt)
|
||||
elseif lerpfrom == lerpto then
|
||||
self.lerpvalue = lerpto
|
||||
end
|
||||
|
||||
self.barwidth = self.lerpvalue/self.max * self.width
|
||||
|
||||
-- min check
|
||||
if self.lerpvalue < self.min then
|
||||
self.lerpvalue = self.min
|
||||
end
|
||||
|
||||
-- max check
|
||||
if self.lerpvalue > self.max then
|
||||
self.lerpvalue = self.max
|
||||
end
|
||||
else
|
||||
self.barwidth = value/self.max * self.width
|
||||
|
||||
-- min max check
|
||||
if value < self.min then
|
||||
self.value = self.min
|
||||
@ -133,14 +129,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawProgressBar or skins[defaultskin].DrawProgressBar
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawProgressBar or skins[defaultskin].DrawProgressBar
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
|
@ -12,17 +12,17 @@ local newobject = loveframes.NewObject("slider", "loveframes_object_slider", tru
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "slider"
|
||||
self.text = "Slider"
|
||||
self.slidetype = "horizontal"
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.max = 10
|
||||
self.min = 0
|
||||
self.value = 0
|
||||
self.decimals = 5
|
||||
self.internal = false
|
||||
self.internals = {}
|
||||
self.type = "slider"
|
||||
self.text = "Slider"
|
||||
self.slidetype = "horizontal"
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.max = 10
|
||||
self.min = 0
|
||||
self.value = 0
|
||||
self.decimals = 5
|
||||
self.internal = false
|
||||
self.internals = {}
|
||||
self.OnValueChanged = nil
|
||||
|
||||
-- create the slider button
|
||||
@ -39,7 +39,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -48,11 +48,11 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local internals = self.internals
|
||||
local sliderbutton = internals[1]
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -93,15 +93,15 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawSlider or skins[defaultskin].DrawSlider
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -134,43 +134,32 @@ function newobject:mousepressed(x, y, button)
|
||||
local internals = self.internals
|
||||
|
||||
if self.hover and button == "l" then
|
||||
|
||||
if self.slidetype == "horizontal" then
|
||||
|
||||
local xpos = x - self.x
|
||||
local button = internals[1]
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
button:MoveToX(xpos)
|
||||
button.down = true
|
||||
button.dragging = true
|
||||
button.startx = button.staticx
|
||||
button.clickx = x
|
||||
|
||||
elseif self.slidetype == "vertical" then
|
||||
|
||||
local ypos = y - self.y
|
||||
local button = 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
|
||||
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
@ -192,9 +181,9 @@ function newobject:SetValue(value)
|
||||
return
|
||||
end
|
||||
|
||||
local decimals = self.decimals
|
||||
local newval = loveframes.util.Round(value, decimals)
|
||||
local internals = self.internals
|
||||
local decimals = self.decimals
|
||||
local newval = loveframes.util.Round(value, decimals)
|
||||
local internals = self.internals
|
||||
local onvaluechanged = self.OnValueChanged
|
||||
|
||||
-- set the new value
|
||||
@ -202,11 +191,11 @@ function newobject:SetValue(value)
|
||||
|
||||
-- slider button object
|
||||
local sliderbutton = internals[1]
|
||||
local slidetype = self.slidetype
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local min = self.min
|
||||
local max = self.max
|
||||
local slidetype = self.slidetype
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local min = self.min
|
||||
local max = self.max
|
||||
|
||||
-- move the slider button to the new position
|
||||
if slidetype == "horizontal" then
|
||||
@ -347,7 +336,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetButtonSize(width, height)
|
||||
|
||||
local internals = self.internals
|
||||
local internals = self.internals
|
||||
local sliderbutton = internals[1]
|
||||
|
||||
if sliderbutton then
|
||||
@ -363,7 +352,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetButtonSize()
|
||||
|
||||
local internals = self.internals
|
||||
local internals = self.internals
|
||||
local sliderbutton = internals[1]
|
||||
|
||||
if sliderbutton then
|
||||
|
139
objects/tabs.lua
139
objects/tabs.lua
@ -12,23 +12,23 @@ local newobject = loveframes.NewObject("tabs", "loveframes_object_tabs", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "tabs"
|
||||
self.width = 100
|
||||
self.height = 50
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.offsetx = 0
|
||||
self.tab = 1
|
||||
self.tabnumber = 1
|
||||
self.padding = 5
|
||||
self.tabheight = 25
|
||||
self.type = "tabs"
|
||||
self.width = 100
|
||||
self.height = 50
|
||||
self.clickx = 0
|
||||
self.clicky = 0
|
||||
self.offsetx = 0
|
||||
self.tab = 1
|
||||
self.tabnumber = 1
|
||||
self.padding = 5
|
||||
self.tabheight = 25
|
||||
self.previoustabheight = 25
|
||||
self.autosize = true
|
||||
self.internal = false
|
||||
self.tooltipfont = loveframes.basicfontsmall
|
||||
self.tabs = {}
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
self.autosize = true
|
||||
self.internal = false
|
||||
self.tooltipfont = loveframes.basicfontsmall
|
||||
self.tabs = {}
|
||||
self.internals = {}
|
||||
self.children = {}
|
||||
|
||||
end
|
||||
|
||||
@ -38,7 +38,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -47,20 +47,20 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local internals = self.internals
|
||||
local tab = self.tab
|
||||
local parent = self.parent
|
||||
local autosize = self.autosize
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local x, y = love.mouse.getPosition()
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local internals = self.internals
|
||||
local tab = self.tab
|
||||
local parent = self.parent
|
||||
local autosize = self.autosize
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base then
|
||||
@ -108,19 +108,19 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local tabheight = self:GetHeightOfButtons()
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, tabheight) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local tabheight = self:GetHeightOfButtons()
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, tabheight) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local internals = self.internals
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -157,48 +157,38 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
local numinternals = #internals
|
||||
local hover = self.hover
|
||||
local hover = self.hover
|
||||
|
||||
if hover then
|
||||
|
||||
if button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if button == "wu" then
|
||||
|
||||
local buttonheight = self:GetHeightOfButtons()
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = internals[numinternals - 1]:GetVisible()
|
||||
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = internals[numinternals - 1]:GetVisible()
|
||||
if col and visible then
|
||||
self.offsetx = self.offsetx + 5
|
||||
if self.offsetx > 0 then
|
||||
self.offsetx = 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if button == "wd" then
|
||||
|
||||
local buttonheight = self:GetHeightOfButtons()
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = internals[numinternals]:GetVisible()
|
||||
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = internals[numinternals]:GetVisible()
|
||||
if col and visible then
|
||||
local bwidth = self:GetWidthOfButtons()
|
||||
if (self.offsetx + bwidth) < self.width then
|
||||
@ -207,7 +197,6 @@ function newobject:mousepressed(x, y, button)
|
||||
self.offsetx = self.offsetx - 5
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -226,11 +215,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:mousereleased(x, y, button)
|
||||
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
|
||||
if not visible then
|
||||
return
|
||||
@ -252,8 +241,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:AddTab(name, object, tip, image)
|
||||
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local tabnumber = self.tabnumber
|
||||
local tabheight = self.tabheight
|
||||
local internals = self.internals
|
||||
@ -349,7 +338,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetWidthOfButtons()
|
||||
|
||||
local width = 0
|
||||
local width = 0
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -431,11 +420,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetTabHeight(height)
|
||||
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local previoustabheight = self.previoustabheight
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
self.tabheight = height
|
||||
|
||||
|
133
objects/text.lua
133
objects/text.lua
@ -17,21 +17,21 @@ local newobject = loveframes.NewObject("text", "loveframes_object_text", true)
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "text"
|
||||
self.text = ""
|
||||
self.font = loveframes.basicfont
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.maxw = 0
|
||||
self.lines = 1
|
||||
self.shadowxoffset = 1
|
||||
self.shadowyoffset = 1
|
||||
self.formattedtext = {}
|
||||
self.original = {}
|
||||
self.shadowcolor = {}
|
||||
self.type = "text"
|
||||
self.text = ""
|
||||
self.font = loveframes.basicfont
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.maxw = 0
|
||||
self.lines = 1
|
||||
self.shadowxoffset = 1
|
||||
self.shadowyoffset = 1
|
||||
self.formattedtext = {}
|
||||
self.original = {}
|
||||
self.shadowcolor = {0, 0, 0, 255}
|
||||
self.ignorenewlines = false
|
||||
self.shadow = false
|
||||
self.internal = false
|
||||
self.shadow = false
|
||||
self.internal = false
|
||||
|
||||
end
|
||||
|
||||
@ -48,7 +48,7 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
self:CheckHover()
|
||||
@ -75,14 +75,14 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawText or skins[defaultskin].DrawText
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawText or skins[defaultskin].DrawText
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -112,13 +112,10 @@ function newobject:mousepressed(x, y, button)
|
||||
local hover = self.hover
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -129,13 +126,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetText(t)
|
||||
|
||||
local dtype = type(t)
|
||||
local maxw = self.maxw
|
||||
local font = self.font
|
||||
local dtype = type(t)
|
||||
local maxw = self.maxw
|
||||
local font = self.font
|
||||
local inserts = {}
|
||||
local tdata, prevcolor
|
||||
|
||||
self.text = ""
|
||||
self.text = ""
|
||||
self.formattedtext = {}
|
||||
|
||||
if dtype == "string" then
|
||||
@ -152,58 +149,39 @@ function newobject:SetText(t)
|
||||
end
|
||||
|
||||
for k, v in ipairs(tdata) do
|
||||
|
||||
local dtype = type(v)
|
||||
|
||||
if k == 1 and dtype ~= "table" then
|
||||
prevcolor = {0, 0, 0, 255}
|
||||
end
|
||||
|
||||
if dtype == "table" then
|
||||
prevcolor = v
|
||||
elseif dtype == "number" then
|
||||
|
||||
table.insert(self.formattedtext, {color = prevcolor, text = tostring(v)})
|
||||
|
||||
elseif dtype == "string" then
|
||||
|
||||
if self.ignorenewlines == false then
|
||||
v = v:gsub(string.char(92) .. string.char(110), string.char(10))
|
||||
end
|
||||
|
||||
v = v:gsub(string.char(9), " ")
|
||||
|
||||
local parts = loveframes.util.SplitString(v, " ")
|
||||
|
||||
for i, j in ipairs(parts) do
|
||||
table.insert(self.formattedtext, {color = prevcolor, text = j})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if maxw > 0 then
|
||||
|
||||
for k, v in ipairs(self.formattedtext) do
|
||||
|
||||
local data = v.text
|
||||
local width = font:getWidth(data)
|
||||
local curw = 0
|
||||
local new = ""
|
||||
local key = k
|
||||
|
||||
if width > maxw then
|
||||
|
||||
table.remove(self.formattedtext, k)
|
||||
|
||||
for n=1, #data do
|
||||
|
||||
for n=1, #data do
|
||||
local item = data:sub(n, n)
|
||||
local itemw = font:getWidth(item)
|
||||
|
||||
if n ~= #data then
|
||||
|
||||
if (curw + itemw) > maxw then
|
||||
table.insert(inserts, {key = key, color = v.color, text = new})
|
||||
new = item
|
||||
@ -213,53 +191,41 @@ function newobject:SetText(t)
|
||||
new = new .. item
|
||||
curw = curw + itemw
|
||||
end
|
||||
|
||||
else
|
||||
new = new .. item
|
||||
table.insert(inserts, {key = key, color = v.color, text = new})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(inserts) do
|
||||
table.insert(self.formattedtext, v.key, {color = v.color, text = v.text})
|
||||
end
|
||||
|
||||
local textdata = self.formattedtext
|
||||
local maxw = self.maxw
|
||||
local font = self.font
|
||||
local height = font:getHeight("a")
|
||||
local twidth = 0
|
||||
local drawx = 0
|
||||
local drawy = 0
|
||||
local lines = 0
|
||||
local totalwidth = 0
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local textdata = self.formattedtext
|
||||
local maxw = self.maxw
|
||||
local font = self.font
|
||||
local height = font:getHeight("a")
|
||||
local twidth = 0
|
||||
local drawx = 0
|
||||
local drawy = 0
|
||||
local lines = 0
|
||||
local totalwidth = 0
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local prevtextwidth = 0
|
||||
|
||||
for k, v in ipairs(textdata) do
|
||||
|
||||
local text = v.text
|
||||
local color = v.color
|
||||
|
||||
if type(text) == "string" then
|
||||
|
||||
self.text = self.text .. text
|
||||
|
||||
local width = font:getWidth(text)
|
||||
totalwidth = totalwidth + width
|
||||
|
||||
if maxw > 0 then
|
||||
|
||||
if k ~= 1 then
|
||||
|
||||
if string.byte(text) == 10 then
|
||||
twidth = 0
|
||||
drawx = 0
|
||||
@ -278,27 +244,18 @@ function newobject:SetText(t)
|
||||
else
|
||||
twidth = twidth + width
|
||||
end
|
||||
|
||||
prevtextwidth = width
|
||||
|
||||
v.x = drawx
|
||||
v.y = drawy
|
||||
|
||||
else
|
||||
|
||||
if k ~= 1 then
|
||||
drawx = drawx + prevtextwidth
|
||||
end
|
||||
|
||||
prevtextwidth = width
|
||||
|
||||
v.x = drawx
|
||||
v.y = drawy
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if maxw > 0 then
|
||||
@ -306,7 +263,7 @@ function newobject:SetText(t)
|
||||
else
|
||||
self.width = totalwidth
|
||||
end
|
||||
|
||||
|
||||
self.height = drawy + height
|
||||
|
||||
end
|
||||
@ -338,20 +295,18 @@ end
|
||||
function newobject:DrawText()
|
||||
|
||||
local textdata = self.formattedtext
|
||||
local font = self.font
|
||||
local font = self.font
|
||||
local theight = font:getHeight("a")
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local shadow = self.shadow
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local shadow = self.shadow
|
||||
local shadowxoffset = self.shadowxoffset
|
||||
local shadowyoffset = self.shadowyoffset
|
||||
local shadowcolor = self.shadowcolor
|
||||
|
||||
for k, v in ipairs(textdata) do
|
||||
|
||||
local text = v.text
|
||||
local color = v.color
|
||||
|
||||
if self.parent.type == "list" then
|
||||
if (y + v.y) <= (self.parent.y + self.parent.height) and self.y + ((v.y + theight)) >= self.parent.y then
|
||||
love.graphics.setFont(font)
|
||||
|
@ -13,54 +13,55 @@ local newobject = loveframes.NewObject("textinput", "loveframes_object_textinput
|
||||
|
||||
function newobject:initialize()
|
||||
|
||||
self.type = "textinput"
|
||||
self.keydown = "none"
|
||||
self.tabreplacement = " "
|
||||
self.font = loveframes.basicfont
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.delay = 0
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.indincatortime = 0
|
||||
self.indicatornum = 0
|
||||
self.indicatorx = 0
|
||||
self.indicatory = 0
|
||||
self.textx = 0
|
||||
self.texty = 0
|
||||
self.textoffsetx = 5
|
||||
self.textoffsety = 5
|
||||
self.unicode = 0
|
||||
self.limit = 0
|
||||
self.line = 1
|
||||
self.itemwidth = 0
|
||||
self.itemheight = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.rightpadding = 0
|
||||
self.bottompadding = 0
|
||||
self.lastclicktime = 0
|
||||
self.maxx = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.type = "textinput"
|
||||
self.keydown = "none"
|
||||
self.tabreplacement = " "
|
||||
self.font = loveframes.basicfont
|
||||
self.width = 200
|
||||
self.height = 25
|
||||
self.delay = 0
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.indincatortime = 0
|
||||
self.indicatornum = 0
|
||||
self.indicatorx = 0
|
||||
self.indicatory = 0
|
||||
self.textx = 0
|
||||
self.texty = 0
|
||||
self.textoffsetx = 5
|
||||
self.textoffsety = 5
|
||||
self.unicode = 0
|
||||
self.limit = 0
|
||||
self.line = 1
|
||||
self.itemwidth = 0
|
||||
self.itemheight = 0
|
||||
self.extrawidth = 0
|
||||
self.extraheight = 0
|
||||
self.rightpadding = 0
|
||||
self.bottompadding = 0
|
||||
self.lastclicktime = 0
|
||||
self.maxx = 0
|
||||
self.buttonscrollamount = 0.10
|
||||
self.mousewheelscrollamount = 5
|
||||
self.usable = {}
|
||||
self.unusable = {}
|
||||
self.lines = {""}
|
||||
self.internals = {}
|
||||
self.showindicator = true
|
||||
self.focus = false
|
||||
self.multiline = false
|
||||
self.vbar = false
|
||||
self.hbar = false
|
||||
self.alltextselected = false
|
||||
self.linenumbers = true
|
||||
self.linenumberspanel = false
|
||||
self.editable = true
|
||||
self.internal = false
|
||||
self.OnEnter = nil
|
||||
self.OnTextChanged = nil
|
||||
self.OnFocusGained = nil
|
||||
self.OnFocusLost = nil
|
||||
self.usable = {}
|
||||
self.unusable = {}
|
||||
self.lines = {""}
|
||||
self.internals = {}
|
||||
self.showindicator = true
|
||||
self.focus = false
|
||||
self.multiline = false
|
||||
self.vbar = false
|
||||
self.hbar = false
|
||||
self.alltextselected = false
|
||||
self.linenumbers = true
|
||||
self.linenumberspanel = false
|
||||
self.editable = true
|
||||
self.internal = false
|
||||
self.autoscroll = false
|
||||
self.OnEnter = nil
|
||||
self.OnTextChanged = nil
|
||||
self.OnFocusGained = nil
|
||||
self.OnFocusLost = nil
|
||||
|
||||
end
|
||||
|
||||
@ -70,7 +71,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if not visible then
|
||||
@ -82,23 +83,23 @@ function newobject:update(dt)
|
||||
-- check to see if the object is being hovered over
|
||||
self:CheckHover()
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local keydown = self.keydown
|
||||
local unicode = self.unicode
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local theight = self.font:getHeight("a")
|
||||
local delay = self.delay
|
||||
local lines = self.lines
|
||||
local numlines = #lines
|
||||
local multiline = self.multiline
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local time = love.timer.getTime()
|
||||
local keydown = self.keydown
|
||||
local unicode = self.unicode
|
||||
local parent = self.parent
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
local theight = self.font:getHeight("a")
|
||||
local delay = self.delay
|
||||
local lines = self.lines
|
||||
local numlines = #lines
|
||||
local multiline = self.multiline
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local inputobject = loveframes.inputobject
|
||||
local internals = self.internals
|
||||
local internals = self.internals
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if parent ~= base then
|
||||
@ -127,10 +128,8 @@ function newobject:update(dt)
|
||||
|
||||
-- calculations for multiline mode
|
||||
if multiline then
|
||||
|
||||
local twidth = 0
|
||||
local panel = self:GetLineNumbersPanel()
|
||||
|
||||
-- get the longest line of text
|
||||
for k, v in ipairs(lines) do
|
||||
local linewidth = self.font:getWidth(v)
|
||||
@ -138,36 +137,30 @@ function newobject:update(dt)
|
||||
twidth = linewidth
|
||||
end
|
||||
end
|
||||
|
||||
-- item width calculation
|
||||
if vbar then
|
||||
self.itemwidth = twidth + 16 + self.textoffsetx * 2
|
||||
else
|
||||
self.itemwidth = twidth
|
||||
end
|
||||
|
||||
if panel then
|
||||
self.itemwidth = self.itemwidth + panel.width
|
||||
end
|
||||
|
||||
-- item height calculation
|
||||
if hbar then
|
||||
self.itemheight = theight * numlines + 16 + self.textoffsety * 2
|
||||
else
|
||||
self.itemheight = theight * numlines
|
||||
end
|
||||
|
||||
-- extra width and height calculations
|
||||
self.extrawidth = self.itemwidth - self.width
|
||||
self.extrawidth = self.itemwidth - self.width
|
||||
self.extraheight = self.itemheight - self.height
|
||||
|
||||
local itemwidth = self.itemwidth
|
||||
local itemheight = self.itemheight
|
||||
|
||||
if itemheight > height then
|
||||
if not vbar then
|
||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "vertical")
|
||||
scrollbody.internals[1].internals[1].autoscroll = false
|
||||
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
||||
table.insert(self.internals, scrollbody)
|
||||
self.vbar = true
|
||||
if hbar then
|
||||
@ -192,7 +185,7 @@ function newobject:update(dt)
|
||||
if itemwidth > width then
|
||||
if not hbar then
|
||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "horizontal")
|
||||
scrollbody.internals[1].internals[1].autoscroll = false
|
||||
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
||||
table.insert(self.internals, scrollbody)
|
||||
self.hbar = true
|
||||
if self.vbar then
|
||||
@ -215,7 +208,6 @@ function newobject:update(dt)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.linenumbers then
|
||||
if not self.linenumberspanel then
|
||||
local linenumberspanel = loveframes.objects["linenumberspanel"]:new(self)
|
||||
@ -228,7 +220,6 @@ function newobject:update(dt)
|
||||
self.linenumberspanel = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -253,20 +244,20 @@ function newobject:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTextInput or skins[defaultskin].DrawTextInput
|
||||
local drawoverfunc = skin.DrawOverTextInput or skins[defaultskin].DrawOverTextInput
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||
local stencil = love.graphics.newStencil(stencilfunc)
|
||||
local selfskin = self.skin
|
||||
local skin = skins[selfskin] or skins[skinindex]
|
||||
local drawfunc = skin.DrawTextInput or skins[defaultskin].DrawTextInput
|
||||
local drawoverfunc = skin.DrawOverTextInput or skins[defaultskin].DrawOverTextInput
|
||||
local draw = self.Draw
|
||||
local drawcount = loveframes.drawcount
|
||||
local internals = self.internals
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
|
||||
-- set the object's draw order
|
||||
self:SetDrawOrder()
|
||||
@ -307,25 +298,22 @@ function newobject:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local internals = self.internals
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local scrollamount = self.mousewheelscrollamount
|
||||
local focus = self.focus
|
||||
local hover = self.hover
|
||||
local internals = self.internals
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local scrollamount = self.mousewheelscrollamount
|
||||
local focus = self.focus
|
||||
local onfocusgained = self.OnFocusGained
|
||||
local onfocuslost = self.OnFocusLost
|
||||
local time = love.timer.getTime()
|
||||
local inputobject = loveframes.inputobject
|
||||
local onfocuslost = self.OnFocusLost
|
||||
local time = love.timer.getTime()
|
||||
local inputobject = loveframes.inputobject
|
||||
|
||||
if hover then
|
||||
|
||||
if button == "l" then
|
||||
|
||||
if inputobject ~= self then
|
||||
loveframes.inputobject = self
|
||||
end
|
||||
|
||||
if not self.alltextselected then
|
||||
if time > self.lastclicktime and time < (self.lastclicktime + 0.25) then
|
||||
self.alltextselected = true
|
||||
@ -333,21 +321,17 @@ function newobject:mousepressed(x, y, button)
|
||||
else
|
||||
self.alltextselected = false
|
||||
end
|
||||
|
||||
self.focus = true
|
||||
self.lastclicktime = time
|
||||
self:GetTextCollisions(x, y)
|
||||
|
||||
if onfocusgained and not focus then
|
||||
onfocusgained(self)
|
||||
end
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
elseif button == "wu" then
|
||||
if vbar and not hbar then
|
||||
local vbar = self:GetVerticalScrollBody().internals[1].internals[1]
|
||||
@ -371,16 +355,13 @@ function newobject:mousepressed(x, y, button)
|
||||
hbar:Scroll(scrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if inputobject == self then
|
||||
loveframes.inputobject = false
|
||||
if onfocuslost then
|
||||
onfocuslost(self)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -426,7 +407,7 @@ function newobject:keypressed(key, unicode)
|
||||
local rctrl = love.keyboard.isDown("rctrl")
|
||||
local focus = self.focus
|
||||
|
||||
self.delay = time + 0.80
|
||||
self.delay = time + 0.80
|
||||
self.keydown = key
|
||||
|
||||
if (lctrl or rctrl) and focus then
|
||||
@ -462,7 +443,7 @@ end
|
||||
function newobject:RunKey(key, unicode)
|
||||
|
||||
local visible = self.visible
|
||||
local focus = self.focus
|
||||
local focus = self.focus
|
||||
|
||||
if not visible then
|
||||
return
|
||||
@ -472,22 +453,22 @@ function newobject:RunKey(key, unicode)
|
||||
return
|
||||
end
|
||||
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local numlines = #lines
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local ckey = ""
|
||||
local font = self.font
|
||||
local swidth = self.width
|
||||
local textoffsetx = self.textoffsetx
|
||||
local indicatornum = self.indicatornum
|
||||
local multiline = self.multiline
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local numlines = #lines
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local ckey = ""
|
||||
local font = self.font
|
||||
local swidth = self.width
|
||||
local textoffsetx = self.textoffsetx
|
||||
local indicatornum = self.indicatornum
|
||||
local multiline = self.multiline
|
||||
local alltextselected = self.alltextselected
|
||||
local editable = self.editable
|
||||
local initialtext = self:GetText()
|
||||
local ontextchanged = self.OnTextChanged
|
||||
local onenter = self.OnEnter
|
||||
local editable = self.editable
|
||||
local initialtext = self:GetText()
|
||||
local ontextchanged = self.OnTextChanged
|
||||
local onenter = self.OnEnter
|
||||
|
||||
self.unicode = unicode
|
||||
|
||||
@ -560,9 +541,7 @@ function newobject:RunKey(key, unicode)
|
||||
|
||||
-- key input checking system
|
||||
if key == "backspace" then
|
||||
|
||||
ckey = key
|
||||
|
||||
if alltextselected then
|
||||
self:Clear()
|
||||
self.alltextselected = false
|
||||
@ -593,15 +572,11 @@ function newobject:RunKey(key, unicode)
|
||||
self.offsetx = self.offsetx - cwidth
|
||||
end
|
||||
end
|
||||
|
||||
elseif key == "delete" then
|
||||
|
||||
if not editable then
|
||||
return
|
||||
end
|
||||
|
||||
ckey = key
|
||||
|
||||
if alltextselected then
|
||||
self:Clear()
|
||||
self.alltextselected = false
|
||||
@ -619,16 +594,12 @@ function newobject:RunKey(key, unicode)
|
||||
table.remove(lines, line + 1)
|
||||
end
|
||||
end
|
||||
|
||||
elseif key == "return" or key == "kpenter" then
|
||||
|
||||
ckey = key
|
||||
|
||||
-- call onenter if it exists
|
||||
if onenter then
|
||||
onenter(self, text)
|
||||
end
|
||||
|
||||
-- newline calculations for multiline mode
|
||||
if multiline then
|
||||
if alltextselected then
|
||||
@ -654,20 +625,15 @@ function newobject:RunKey(key, unicode)
|
||||
end
|
||||
self.indicatornum = 0
|
||||
end
|
||||
|
||||
elseif key == "tab" then
|
||||
|
||||
ckey = key
|
||||
|
||||
for i=1, #self.tabreplacement do
|
||||
local number = string.byte(self.tabreplacement:sub(i, i))
|
||||
self.lines[self.line] = self:AddIntoText(number, self.indicatornum)
|
||||
self:MoveIndicator(1)
|
||||
end
|
||||
|
||||
else
|
||||
if unicode > 31 and unicode < 127 then
|
||||
|
||||
if alltextselected then
|
||||
self.alltextselected = false
|
||||
self:Clear()
|
||||
@ -676,15 +642,12 @@ function newobject:RunKey(key, unicode)
|
||||
lines = self.lines
|
||||
line = self.line
|
||||
end
|
||||
|
||||
-- do not continue if the text limit has been reached or exceeded
|
||||
if #text >= self.limit and self.limit ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- set the current key
|
||||
ckey = string.char(unicode)
|
||||
|
||||
-- check for unusable characters
|
||||
if #self.usable > 0 then
|
||||
local found = false
|
||||
@ -697,7 +660,6 @@ function newobject:RunKey(key, unicode)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- check for usable characters
|
||||
if #self.unusable > 0 then
|
||||
local found = false
|
||||
@ -710,7 +672,6 @@ function newobject:RunKey(key, unicode)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if indicatornum ~= 0 and indicatornum ~= #text then
|
||||
text = self:AddIntoText(unicode, indicatornum)
|
||||
lines[line] = text
|
||||
@ -724,12 +685,10 @@ function newobject:RunKey(key, unicode)
|
||||
lines[line] = text
|
||||
self:MoveIndicator(1)
|
||||
end
|
||||
|
||||
lines = self.lines
|
||||
line = self.line
|
||||
curline = lines[line]
|
||||
text = curline
|
||||
|
||||
lines = self.lines
|
||||
line = self.line
|
||||
curline = lines[line]
|
||||
text = curline
|
||||
if not multiline then
|
||||
local twidth = font:getWidth(text)
|
||||
local cwidth = font:getWidth(ckey)
|
||||
@ -740,7 +699,6 @@ function newobject:RunKey(key, unicode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local curtext = self:GetText()
|
||||
@ -757,10 +715,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:MoveIndicator(num, exact)
|
||||
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local indicatornum = self.indicatornum
|
||||
|
||||
if not exact then
|
||||
@ -788,16 +746,16 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:UpdateIndicator()
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local indincatortime = self.indincatortime
|
||||
local indicatornum = self.indicatornum
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local theight = self.font:getHeight("a")
|
||||
local offsetx = self.offsetx
|
||||
local multiline = self.multiline
|
||||
local time = love.timer.getTime()
|
||||
local indincatortime = self.indincatortime
|
||||
local indicatornum = self.indicatornum
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local theight = self.font:getHeight("a")
|
||||
local offsetx = self.offsetx
|
||||
local multiline = self.multiline
|
||||
|
||||
if indincatortime < time then
|
||||
if self.showindicator then
|
||||
@ -835,13 +793,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:AddIntoText(t, p)
|
||||
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local part1 = text:sub(1, p)
|
||||
local part2 = text:sub(p + 1)
|
||||
local new = part1 .. string.char(t) .. part2
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local part1 = text:sub(1, p)
|
||||
local part2 = text:sub(p + 1)
|
||||
local new = part1 .. string.char(t) .. part2
|
||||
|
||||
return new
|
||||
|
||||
@ -854,10 +812,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:RemoveFromeText(p)
|
||||
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local lines = self.lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local indicatornum = self.indicatornum
|
||||
|
||||
local part1 = text:sub(1, p - 1)
|
||||
@ -873,24 +831,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetTextCollisions(x, y)
|
||||
|
||||
local font = self.font
|
||||
local lines = self.lines
|
||||
local numlines = #lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local xpos = 0
|
||||
local line = 0
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local font = self.font
|
||||
local lines = self.lines
|
||||
local numlines = #lines
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
local text = curline
|
||||
local xpos = 0
|
||||
local line = 0
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local multiline = self.multiline
|
||||
|
||||
if multiline then
|
||||
|
||||
local theight = self.font:getHeight("a")
|
||||
local liney = 0
|
||||
local liney = 0
|
||||
local selfcol
|
||||
|
||||
if vbar and not hbar then
|
||||
selfcol = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width - 16, 1, self.height, 1)
|
||||
elseif hbar and not vbar then
|
||||
@ -900,9 +856,7 @@ function newobject:GetTextCollisions(x, y)
|
||||
elseif vbar and hbar then
|
||||
selfcol = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width - 16, 1, self.height - 16, 1)
|
||||
end
|
||||
|
||||
if selfcol then
|
||||
|
||||
for i=1, numlines do
|
||||
local linecol = loveframes.util.BoundingBox(self.x, x, (self.y - self.offsety) + self.textoffsety + (theight * i) - theight, y, self.width, 1, theight, 1)
|
||||
if linecol then
|
||||
@ -910,17 +864,14 @@ function newobject:GetTextCollisions(x, y)
|
||||
self.line = i
|
||||
end
|
||||
end
|
||||
|
||||
local line = self.line
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
|
||||
for i=1, #curline do
|
||||
|
||||
local width = font:getWidth(curline:sub(i, i))
|
||||
local width = font:getWidth(curline:sub(i, i))
|
||||
local height = font:getHeight(curline:sub(i, i))
|
||||
local tx = self.textx + xpos
|
||||
local ty = self.texty
|
||||
local col = loveframes.util.BoundingBox(tx, x, liney, y, width, 1, height, 1)
|
||||
local tx = self.textx + xpos
|
||||
local ty = self.texty
|
||||
local col = loveframes.util.BoundingBox(tx, x, liney, y, width, 1, height, 1)
|
||||
|
||||
xpos = xpos + width
|
||||
|
||||
@ -938,42 +889,31 @@ function newobject:GetTextCollisions(x, y)
|
||||
if x > (tx + width) then
|
||||
self:MoveIndicator(#curline, true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if #curline == 0 then
|
||||
self.indicatornum = 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
for i=1, #text do
|
||||
|
||||
local width = font:getWidth(text:sub(i, i))
|
||||
local width = font:getWidth(text:sub(i, i))
|
||||
local height = font:getHeight(text:sub(i, i))
|
||||
local tx = self.textx + xpos
|
||||
local ty = self.texty
|
||||
local col = loveframes.util.BoundingBox(tx, x, ty, y, width, 1, height, 1)
|
||||
|
||||
local tx = self.textx + xpos
|
||||
local ty = self.texty
|
||||
local col = loveframes.util.BoundingBox(tx, x, ty, y, width, 1, height, 1)
|
||||
xpos = xpos + width
|
||||
|
||||
if col then
|
||||
self:MoveIndicator(i - 1, true)
|
||||
break
|
||||
end
|
||||
|
||||
if x < tx then
|
||||
self:MoveIndicator(0, true)
|
||||
end
|
||||
|
||||
if x > (tx + width) then
|
||||
self:MoveIndicator(#text, true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -984,13 +924,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:PositionText()
|
||||
|
||||
local multiline = self.multiline
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local offsetx = self.offsetx
|
||||
local offsety = self.offsety
|
||||
local textoffsetx = self.textoffsetx
|
||||
local textoffsety = self.textoffsety
|
||||
local multiline = self.multiline
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
local offsetx = self.offsetx
|
||||
local offsety = self.offsety
|
||||
local textoffsetx = self.textoffsetx
|
||||
local textoffsety = self.textoffsety
|
||||
local linenumberspanel = self.linenumberspanel
|
||||
|
||||
if multiline then
|
||||
@ -1055,9 +995,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetFocus(focus)
|
||||
|
||||
local inputobject = loveframes.inputobject
|
||||
local inputobject = loveframes.inputobject
|
||||
local onfocusgained = self.OnFocusGained
|
||||
local onfocuslost = self.OnFocusLost
|
||||
local onfocuslost = self.OnFocusLost
|
||||
|
||||
self.focus = focus
|
||||
|
||||
@ -1157,11 +1097,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:Clear()
|
||||
|
||||
self.lines = {""}
|
||||
self.line = 1
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.indicatornum = 0
|
||||
self.lines = {""}
|
||||
self.line = 1
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
self.indicatornum = 0
|
||||
|
||||
end
|
||||
|
||||
@ -1172,7 +1112,7 @@ end
|
||||
function newobject:SetText(text)
|
||||
|
||||
local tabreplacement = self.tabreplacement
|
||||
local multiline = self.multiline
|
||||
local multiline = self.multiline
|
||||
|
||||
-- replace any tabs character with spaces
|
||||
text = text:gsub(string.char(9), tabreplacement)
|
||||
@ -1192,7 +1132,7 @@ function newobject:SetText(text)
|
||||
text = text:gsub(string.char(92) .. string.char(110), "")
|
||||
text = text:gsub(string.char(10), "")
|
||||
self.lines = {text}
|
||||
self.line = 1
|
||||
self.line = 1
|
||||
end
|
||||
|
||||
end
|
||||
@ -1204,8 +1144,8 @@ end
|
||||
function newobject:GetText()
|
||||
|
||||
local multiline = self.multiline
|
||||
local lines = self.lines
|
||||
local text = ""
|
||||
local lines = self.lines
|
||||
local text = ""
|
||||
|
||||
if multiline then
|
||||
for k, v in ipairs(lines) do
|
||||
@ -1226,7 +1166,7 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetMultiline(bool)
|
||||
|
||||
local text = ""
|
||||
local text = ""
|
||||
local lines = self.lines
|
||||
|
||||
self.multiline = bool
|
||||
@ -1263,9 +1203,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetVerticalScrollBody()
|
||||
|
||||
local vbar = self.vbar
|
||||
local vbar = self.vbar
|
||||
local internals = self.internals
|
||||
local item = false
|
||||
local item = false
|
||||
|
||||
if vbar then
|
||||
for k, v in ipairs(internals) do
|
||||
@ -1285,9 +1225,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetHorizontalScrollBody()
|
||||
|
||||
local hbar = self.hbar
|
||||
local hbar = self.hbar
|
||||
local internals = self.internals
|
||||
local item = false
|
||||
local item = false
|
||||
|
||||
if hbar then
|
||||
for k, v in ipairs(internals) do
|
||||
@ -1329,9 +1269,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetLineNumbersPanel()
|
||||
|
||||
local panel = self.linenumberspanel
|
||||
local panel = self.linenumberspanel
|
||||
local internals = self.internals
|
||||
local item = false
|
||||
local item = false
|
||||
|
||||
if panel then
|
||||
for k, v in ipairs(internals) do
|
||||
@ -1554,4 +1494,32 @@ function newobject:GetButtonScrollAmount()
|
||||
|
||||
return self.mousewheelscrollamount
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetAutoScroll(bool)
|
||||
- desc: sets whether or not the object should autoscroll
|
||||
when in multiline mode
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:SetAutoScroll(bool)
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
self.autoscroll = bool
|
||||
|
||||
if internals[2] then
|
||||
internals[2].internals[1].internals[1].autoscroll = bool
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetAutoScroll()
|
||||
- desc: gets whether or not the object should autoscroll
|
||||
when in multiline mode
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:GetAutoScroll()
|
||||
|
||||
return self.autoscroll
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user