Fix code indentation

This commit is contained in:
Brandon Dyck 2024-04-22 12:59:33 -06:00
parent 9e4fbccf0c
commit 9fdaa3f00b
2 changed files with 40 additions and 40 deletions

View File

@ -13,13 +13,13 @@ function example.func(loveframes, centerarea)
numberbox:SetPos(5, 30) numberbox:SetPos(5, 30)
numberbox:SetSize(200, 25) numberbox:SetSize(200, 25)
local togglebutton = loveframes.Create("button", frame) local togglebutton = loveframes.Create("button", frame)
togglebutton:SetPos(5, 60) togglebutton:SetPos(5, 60)
togglebutton:SetWidth(200) togglebutton:SetWidth(200)
togglebutton:SetText("Toggle Padding") togglebutton:SetText("Toggle Padding")
togglebutton.OnClick = function(object) togglebutton.OnClick = function(object)
numberbox:SetPad(not numberbox:GetPad()) numberbox:SetPad(not numberbox:GetPad())
end end
end end
return example return example

View File

@ -28,7 +28,7 @@ function newobject:initialize()
self.internal = false self.internal = false
self.canmodify = false self.canmodify = false
self.lastbuttonclicked = false self.lastbuttonclicked = false
self.pad = false self.pad = false
self.internals = {} self.internals = {}
self.OnValueChanged = nil self.OnValueChanged = nil
@ -61,9 +61,9 @@ function newobject:initialize()
end end
end end
end end
input.OnFocusLost = function(object) input.OnFocusLost = function(object)
self:updateinput() self:updateinput()
end end
input.Update = function(object) input.Update = function(object)
object:SetSize(object.parent.width - 20, object.parent.height) object:SetSize(object.parent.width - 20, object.parent.height)
end end
@ -147,24 +147,24 @@ end
function newobject:updateinput() function newobject:updateinput()
local value = self.value local value = self.value
if self.pad then if self.pad then
local maxabs = math.max(math.abs(self.min), math.abs(self.max)) local maxabs = math.max(math.abs(self.min), math.abs(self.max))
-- A range from 0 to 0 would be unusual, but it would break the math. -- A range from 0 to 0 would be unusual, but it would break the math.
if maxabs == 0 then maxabs = 1 end if maxabs == 0 then maxabs = 1 end
local integralwidth = math.floor(math.log10(maxabs)) + 1 local integralwidth = math.floor(math.log10(maxabs)) + 1
local width = integralwidth local width = integralwidth
if self.decimals > 0 then if self.decimals > 0 then
width = width + self.decimals + 1 width = width + self.decimals + 1
end end
if value < 0 then if value < 0 then
width = width + 1 width = width + 1
end end
local formatstring = string.format("%%0%d.%df", width, self.decimals) local formatstring = string.format("%%0%d.%df", width, self.decimals)
value = string.format(formatstring, value) value = string.format(formatstring, value)
end end
local input = self.internals[1] local input = self.internals[1]
input:SetText(value) input:SetText(value)
end end
@ -339,7 +339,7 @@ function newobject:SetMax(max)
onvaluechanged(self, max) onvaluechanged(self, max)
end end
end end
self:updateinput() self:updateinput()
return self return self
@ -371,7 +371,7 @@ function newobject:SetMin(min)
onvaluechanged(self, min) onvaluechanged(self, min)
end end
end end
self:updateinput() self:updateinput()
return self return self
@ -400,7 +400,7 @@ function newobject:SetMinMax(min, max)
if self.value > max then if self.value > max then
self.value = max self.value = max
self:updateinput() self:updateinput()
if onvaluechanged then if onvaluechanged then
onvaluechanged(self, max) onvaluechanged(self, max)
end end
@ -408,7 +408,7 @@ function newobject:SetMinMax(min, max)
if self.value < min then if self.value < min then
self.value = min self.value = min
self:updateinput() self:updateinput()
if onvaluechanged then if onvaluechanged then
onvaluechanged(self, min) onvaluechanged(self, min)
end end
@ -484,7 +484,7 @@ end
function newobject:SetDecimals(decimals) function newobject:SetDecimals(decimals)
self.decimals = decimals self.decimals = decimals
self:updateinput() self:updateinput()
return self return self
end end
@ -503,24 +503,24 @@ end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: SetPad(decimals) - func: SetPad(decimals)
- desc: sets whether to pad the object's value - desc: sets whether to pad the object's value
with zeroes with zeroes
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function newobject:SetPad(pad) function newobject:SetPad(pad)
self.pad = pad self.pad = pad
self:updateinput() self:updateinput()
return self return self
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
- func: GetPad() - func: GetPad()
- desc: gets whether to pad the object's value - desc: gets whether to pad the object's value
with zeroes with zeroes
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function newobject:GetPad() function newobject:GetPad()
return self.pad return self.pad
end end