mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -184,17 +175,14 @@ function newobject:mousereleased(x, y, button)
|
||||
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
|
||||
@ -233,9 +220,7 @@ function newobject:SetText(text)
|
||||
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.internals = {}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -124,22 +124,15 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
@ -170,15 +163,12 @@ function newobject:mousereleased(x, y, button)
|
||||
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
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -243,9 +232,7 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -149,11 +145,9 @@ function newobject:mousereleased(x, y, button)
|
||||
local onclick = self.OnClick
|
||||
|
||||
if hover and self.down then
|
||||
|
||||
if button == "l" then
|
||||
onclick(x, y, self)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
@ -152,25 +152,19 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
@ -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
|
||||
@ -258,14 +247,10 @@ function newobject:RedoLayout()
|
||||
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,7 +272,6 @@ end
|
||||
function newobject:AddRow(data)
|
||||
|
||||
local row = loveframes.objects["columnlistrow"]:new(self, data)
|
||||
|
||||
local colorindex = self.rowcolorindex
|
||||
local colorindexmax = self.rowcolorindexmax
|
||||
|
||||
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -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()
|
||||
@ -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
|
||||
@ -346,12 +336,9 @@ function newobject:RedoLayout()
|
||||
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,6 +373,10 @@ function newobject:SetSpacing(amount)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: Close()
|
||||
- desc: closes the object
|
||||
--]]---------------------------------------------------------
|
||||
function newobject:Close()
|
||||
|
||||
self:Remove()
|
||||
|
@ -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
|
||||
|
@ -72,7 +72,6 @@ function newobject:update(dt)
|
||||
local hover = self.hover
|
||||
|
||||
if button then
|
||||
|
||||
if bartype == "vertical" then
|
||||
self.staticx = 0
|
||||
self.staticy = button.height - 1
|
||||
@ -84,7 +83,6 @@ function newobject:update(dt)
|
||||
self.width = parent.width - button.width*2 + 2
|
||||
self.height = parent.height
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if down then
|
||||
@ -178,13 +176,10 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
|
@ -77,22 +77,18 @@ function newobject:update(dt)
|
||||
end
|
||||
|
||||
if bartype == "vertical" then
|
||||
|
||||
local parent = self.parent
|
||||
local listo = parent.parent.parent
|
||||
local height = parent.height * (listo.height/listo.itemheight)
|
||||
local update = self.Update
|
||||
|
||||
if height < 20 then
|
||||
self.height = 20
|
||||
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 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)
|
||||
|
||||
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
|
||||
@ -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
|
||||
@ -313,7 +305,6 @@ function newobject:Scroll(amount)
|
||||
|
||||
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
|
||||
|
@ -37,7 +37,6 @@ 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
|
||||
upbutton.Update = function(object, dt)
|
||||
@ -47,7 +46,6 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(-self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
local downbutton = loveframes.objects["scrollbutton"]:new("down")
|
||||
downbutton.parent = self
|
||||
downbutton.Update = function(object, dt)
|
||||
@ -57,12 +55,9 @@ 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
|
||||
leftbutton.Update = function(object, dt)
|
||||
@ -72,7 +67,6 @@ function newobject:initialize(parent, bartype)
|
||||
bar:Scroll(-self.parent.buttonscrollamount)
|
||||
end
|
||||
end
|
||||
|
||||
local rightbutton = loveframes.objects["scrollbutton"]:new("right")
|
||||
rightbutton.parent = self
|
||||
rightbutton.Update = function(object, dt)
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -149,28 +145,15 @@ function newobject:mousereleased(x, y, button)
|
||||
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
|
||||
|
@ -66,6 +66,9 @@ function newobject:update(dt)
|
||||
|
||||
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)
|
||||
|
||||
-- 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)
|
||||
|
||||
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
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -151,11 +147,9 @@ function newobject:mousereleased(x, y, button)
|
||||
local tabnumber = self.tabnumber
|
||||
|
||||
if hover and button == "l" then
|
||||
|
||||
if button == "l" then
|
||||
parent:SwitchToTab(tabnumber)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
self.down = false
|
||||
|
@ -65,20 +65,16 @@ function newobject:update(dt)
|
||||
self.height = text.height + self.padding * 2
|
||||
|
||||
if object then
|
||||
|
||||
if object == loveframes.base then
|
||||
self:Remove()
|
||||
return
|
||||
end
|
||||
|
||||
local hover = object.hover
|
||||
local odraworder = object.draworder
|
||||
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)
|
||||
@ -142,15 +132,12 @@ function newobject:draw()
|
||||
self:SetDrawOrder()
|
||||
|
||||
if show then
|
||||
|
||||
if draw then
|
||||
draw(self)
|
||||
else
|
||||
drawfunc(self)
|
||||
end
|
||||
|
||||
text:draw()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -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
|
||||
@ -168,29 +166,21 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
@ -260,69 +250,49 @@ function newobject:CalculateSize()
|
||||
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
|
||||
@ -343,17 +313,12 @@ function newobject:RedoLayout()
|
||||
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
|
||||
|
@ -109,17 +109,13 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
|
@ -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
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
|
@ -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
|
||||
|
@ -134,44 +134,33 @@ 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)
|
||||
end
|
||||
|
@ -165,40 +165,30 @@ function newobject:mousepressed(x, y, button)
|
||||
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()
|
||||
|
||||
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()
|
||||
|
||||
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
|
||||
|
@ -28,7 +28,7 @@ function newobject:initialize()
|
||||
self.shadowyoffset = 1
|
||||
self.formattedtext = {}
|
||||
self.original = {}
|
||||
self.shadowcolor = {}
|
||||
self.shadowcolor = {0, 0, 0, 255}
|
||||
self.ignorenewlines = false
|
||||
self.shadow = false
|
||||
self.internal = false
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
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,18 +191,13 @@ 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
|
||||
@ -245,21 +218,14 @@ function newobject:SetText(t)
|
||||
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
|
||||
@ -348,10 +305,8 @@ function newobject:DrawText()
|
||||
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)
|
||||
|
@ -57,6 +57,7 @@ function newobject:initialize()
|
||||
self.linenumberspanel = false
|
||||
self.editable = true
|
||||
self.internal = false
|
||||
self.autoscroll = false
|
||||
self.OnEnter = nil
|
||||
self.OnTextChanged = nil
|
||||
self.OnFocusGained = nil
|
||||
@ -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.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
|
||||
@ -319,13 +310,10 @@ function newobject:mousepressed(x, y, button)
|
||||
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
|
||||
@ -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
|
||||
|
||||
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()
|
||||
@ -886,11 +844,9 @@ function newobject:GetTextCollisions(x, y)
|
||||
local multiline = self.multiline
|
||||
|
||||
if multiline then
|
||||
|
||||
local theight = self.font:getHeight("a")
|
||||
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,12 +864,9 @@ function newobject:GetTextCollisions(x, y)
|
||||
self.line = i
|
||||
end
|
||||
end
|
||||
|
||||
local line = self.line
|
||||
local curline = lines[line]
|
||||
|
||||
for i=1, #curline do
|
||||
|
||||
local width = font:getWidth(curline:sub(i, i))
|
||||
local height = font:getHeight(curline:sub(i, i))
|
||||
local tx = self.textx + xpos
|
||||
@ -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 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)
|
||||
|
||||
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
|
||||
@ -1555,3 +1495,31 @@ 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