mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Version 0.9.4.2 - Alpha (see changelog.txt)
This commit is contained in:
parent
c6196570e5
commit
3d006ec389
@ -1,3 +1,38 @@
|
||||
================================================
|
||||
Version 0.9.4.2 - Alpha (November 5 - 2012)
|
||||
================================================
|
||||
[ADDED] a new text object method: SetIgnoreNewlines(bool)
|
||||
[ADDED] a new text object method: GetIgnoreNewlines()
|
||||
[ADDED] a new text image method: SetOrientation(orientation)
|
||||
[ADDED] a new text image method: GetOrientation()
|
||||
[ADDED] a new text image method: SetScaleX(scalex)
|
||||
[ADDED] a new text image method: GetScaleX()
|
||||
[ADDED] a new text image method: SetScaleY(scaley)
|
||||
[ADDED] a new text image method: GetScaleY()
|
||||
[ADDED] a new text image method: SetScale(scalex, scaley)
|
||||
[ADDED] a new text image method: GetScale()
|
||||
[ADDED] a new text image method: SetOffsetX(x)
|
||||
[ADDED] a new text image method: GetOffsetX()
|
||||
[ADDED] a new text image method: SetOffsetY(y)
|
||||
[ADDED] a new text image method: GetOffsetY()
|
||||
[ADDED] a new text image method: SetOffset(x, y)
|
||||
[ADDED] a new text image method: GetOffset()
|
||||
[ADDED] a new text image method: SetShearX(x)
|
||||
[ADDED] a new text image method: GetShearX()
|
||||
[ADDED] a new text image method: SetShearY(y)
|
||||
[ADDED] a new text image method: GetShearY()
|
||||
[ADDED] a new text image method: SetShear(x, y)
|
||||
[ADDED] a new text image method: GetShear()
|
||||
|
||||
[FIXED] an error that ocurred after pressing enter on a multiline text input while all of it's text was selected
|
||||
[FIXED] text in a single line text input always being cleared when the enter key was pressed
|
||||
[FIXED] a syntax error in both default skin files that caused imaged to draw incorrect when they had a custom color
|
||||
[FIXED] an error that would occur when a tab button was being drawn while no font had been set
|
||||
[FIXED] textinput.OnTextChanged being called to early when using the backspace key or the delete key
|
||||
|
||||
[CHANGED] tab buttons no longer calculate their width from within their internal drawing function and should be sized externally from now on
|
||||
[CHANGED] the text object now calculates what characters should be drawn while in a list object to improve performance with list objects that contain large amounts of text
|
||||
|
||||
================================================
|
||||
Version 0.9.4.1 - Alpha (October 25 - 2012)
|
||||
================================================
|
||||
|
75
debug.lua
75
debug.lua
@ -295,13 +295,86 @@ function loveframes.debug.ExamplesMenu()
|
||||
|
||||
local frame1 = loveframes.Create("frame")
|
||||
frame1:SetName("Image")
|
||||
frame1:SetSize(138, 163)
|
||||
frame1:SetSize(138, 315)
|
||||
frame1:Center()
|
||||
|
||||
local image1 = loveframes.Create("image", frame1)
|
||||
image1:SetImage("resources/images/carlsagan.png")
|
||||
image1:SetPos(5, 30)
|
||||
|
||||
local panel1 = loveframes.Create("panel", frame1)
|
||||
panel1:SetPos(5, 160)
|
||||
panel1:SetSize(128, 150)
|
||||
|
||||
|
||||
local text1 = loveframes.Create("text", panel1)
|
||||
text1:SetPos(5, 5)
|
||||
text1:SetText("Orientation: ")
|
||||
|
||||
local slider1 = loveframes.Create("slider", panel1)
|
||||
slider1:SetPos(5, 20)
|
||||
slider1:SetWidth(118)
|
||||
slider1:SetMinMax(0, 360)
|
||||
slider1:SetDecimals(0)
|
||||
slider1.OnValueChanged = function(object)
|
||||
image1:SetOrientation(object:GetValue())
|
||||
end
|
||||
|
||||
text1.Update = function(object, dt)
|
||||
object:SetText("Orientation: " ..slider1:GetValue())
|
||||
end
|
||||
|
||||
local text2 = loveframes.Create("text", panel1)
|
||||
text2:SetPos(5, 40)
|
||||
text2:SetText("Scale")
|
||||
|
||||
local slider2 = loveframes.Create("slider", panel1)
|
||||
slider2:SetPos(5, 55)
|
||||
slider2:SetWidth(118)
|
||||
slider2:SetMinMax(1, 2)
|
||||
slider2:SetDecimals(5)
|
||||
slider2.OnValueChanged = function(object)
|
||||
image1:SetScale(object:GetValue(), object:GetValue())
|
||||
end
|
||||
|
||||
text2.Update = function(object, dt)
|
||||
object:SetText("Scale: " ..slider2:GetValue())
|
||||
end
|
||||
|
||||
local text3 = loveframes.Create("text", panel1)
|
||||
text3:SetPos(5, 75)
|
||||
text3:SetText("Offset")
|
||||
|
||||
local slider3 = loveframes.Create("slider", panel1)
|
||||
slider3:SetPos(5, 90)
|
||||
slider3:SetWidth(118)
|
||||
slider3:SetMinMax(1, 50)
|
||||
slider3:SetDecimals(5)
|
||||
slider3.OnValueChanged = function(object)
|
||||
image1:SetOffset(object:GetValue(), object:GetValue())
|
||||
end
|
||||
|
||||
text3.Update = function(object, dt)
|
||||
object:SetText("Offset: " ..slider3:GetValue())
|
||||
end
|
||||
|
||||
local text4 = loveframes.Create("text", panel1)
|
||||
text4:SetPos(5, 110)
|
||||
text4:SetText("Shear")
|
||||
|
||||
local slider4 = loveframes.Create("slider", panel1)
|
||||
slider4:SetPos(5, 125)
|
||||
slider4:SetWidth(118)
|
||||
slider4:SetMinMax(0, 10)
|
||||
slider4:SetDecimals(5)
|
||||
slider4.OnValueChanged = function(object)
|
||||
image1:SetShear(object:GetValue(), object:GetValue())
|
||||
end
|
||||
|
||||
text4.Update = function(object, dt)
|
||||
object:SetText("Shear: " ..slider4:GetValue())
|
||||
end
|
||||
|
||||
end
|
||||
exampleslist:AddItem(imageexample)
|
||||
|
||||
|
2
init.lua
2
init.lua
@ -9,7 +9,7 @@ loveframes = {}
|
||||
-- library info
|
||||
loveframes.info = {}
|
||||
loveframes.info.author = "Nikolai Resokav"
|
||||
loveframes.info.version = "0.9.4.1"
|
||||
loveframes.info.version = "0.9.4.2"
|
||||
loveframes.info.stage = "Alpha"
|
||||
|
||||
-- library configurations
|
||||
|
@ -15,6 +15,13 @@ function image: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
|
||||
@ -130,3 +137,206 @@ function image:GetColor()
|
||||
return self.imagecolor
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetOrientation(orientation)
|
||||
- desc: sets the object's orientation
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetOrientation(orientation)
|
||||
|
||||
self.orientation = orientation
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetOrientation()
|
||||
- desc: gets the object's orientation
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetOrientation()
|
||||
|
||||
return self.orientation
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetScaleX(scalex)
|
||||
- desc: sets the object's x scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetScaleX(scalex)
|
||||
|
||||
self.scalex = scalex
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetScaleX()
|
||||
- desc: gets the object's x scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetScaleX()
|
||||
|
||||
return self.scalex
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetScaleY(scaley)
|
||||
- desc: sets the object's y scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetScaleY(scaley)
|
||||
|
||||
self.scaley = scaley
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetScaleY()
|
||||
- desc: gets the object's y scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetScaleY()
|
||||
|
||||
return self.scaley
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetScale(scalex, scaley)
|
||||
- desc: sets the object's x and y scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetScale(scalex, scaley)
|
||||
|
||||
self.scalex = x
|
||||
self.scaley = y
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetScale()
|
||||
- desc: gets the object's x and y scale
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetScale()
|
||||
|
||||
return self.scalex, self.scaley
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetOffsetX(x)
|
||||
- desc: sets the object's x offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetOffsetX(x)
|
||||
|
||||
self.offsetx = x
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetOffsetX()
|
||||
- desc: gets the object's x offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetOffsetX()
|
||||
|
||||
return self.offsetx
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetOffsetY(y)
|
||||
- desc: sets the object's y offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetOffsetY(y)
|
||||
|
||||
self.offsety = y
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetOffsetY()
|
||||
- desc: gets the object's y offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetOffsetY()
|
||||
|
||||
return self.offsety
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetOffset(x, y)
|
||||
- desc: sets the object's x and y offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetOffset(x, y)
|
||||
|
||||
self.offsetx = x
|
||||
self.offsety = y
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetOffset()
|
||||
- desc: gets the object's x and y offset
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetOffset()
|
||||
|
||||
return self.offsetx, self.offsety
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetShearX(shearx)
|
||||
- desc: sets the object's x shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetShearX(shearx)
|
||||
|
||||
self.shearx = shearx
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetShearX()
|
||||
- desc: gets the object's x shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetShearX()
|
||||
|
||||
return self.shearx
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetShearY(sheary)
|
||||
- desc: sets the object's y shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetShearY(sheary)
|
||||
|
||||
self.sheary = sheary
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetShearY()
|
||||
- desc: gets the object's y shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetShearY()
|
||||
|
||||
return self.sheary
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetShear(shearx, sheary)
|
||||
- desc: sets the object's x and y shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetShear(shearx, sheary)
|
||||
|
||||
self.shearx = shearx
|
||||
self.sheary = sheary
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetShear()
|
||||
- desc: gets the object's x and y shear
|
||||
--]]---------------------------------------------------------
|
||||
function image:GetShear()
|
||||
|
||||
return self.shearx, self.sheary
|
||||
|
||||
end
|
@ -13,6 +13,7 @@ tabbutton = class("tabbutton", base)
|
||||
function tabbutton:initialize(parent, text, tabnumber, tip, image)
|
||||
|
||||
self.type = "tabbutton"
|
||||
self.font = loveframes.smallfont
|
||||
self.text = text
|
||||
self.tabnumber = tabnumber
|
||||
self.parent = parent
|
||||
@ -83,8 +84,6 @@ function tabbutton:draw()
|
||||
return
|
||||
end
|
||||
|
||||
local font = love.graphics.getFont()
|
||||
local width = font:getWidth(self.text)
|
||||
local image = self.image
|
||||
local skins = loveframes.skins.available
|
||||
local skinindex = loveframes.config["ACTIVESKIN"]
|
||||
@ -104,13 +103,6 @@ function tabbutton:draw()
|
||||
drawfunc(self)
|
||||
end
|
||||
|
||||
if image then
|
||||
local imagewidth = image:getWidth()
|
||||
self.width = imagewidth + 15 + width
|
||||
else
|
||||
self.width = 10 + width
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
|
@ -22,6 +22,7 @@ function tabs:initialize()
|
||||
self.tabnumber = 1
|
||||
self.padding = 5
|
||||
self.tabheight = 25
|
||||
self.previoustabheight = 25
|
||||
self.autosize = true
|
||||
self.internal = false
|
||||
self.tooltipfont = loveframes.basicfontsmall
|
||||
@ -50,7 +51,6 @@ function tabs:update(dt)
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local children = self.children
|
||||
@ -58,6 +58,7 @@ function tabs:update(dt)
|
||||
local internals = self.internals
|
||||
local tab = self.tab
|
||||
local parent = self.parent
|
||||
local autosize = self.autosize
|
||||
local base = loveframes.base
|
||||
local update = self.Update
|
||||
|
||||
@ -251,23 +252,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:AddTab(name, object, tip, image)
|
||||
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local retainsize = object.retainsize
|
||||
local tabnumber = self.tabnumber
|
||||
local tabheight = self.tabheight
|
||||
local internals = self.internals
|
||||
|
||||
object:Remove()
|
||||
object.parent = self
|
||||
object.staticx = 0
|
||||
object.staticy = 0
|
||||
object:SetWidth(self.width - 10)
|
||||
object:SetHeight(self.height - 35)
|
||||
|
||||
table.insert(self.children, object)
|
||||
internals[tabnumber] = tabbutton:new(self, name, tabnumber, tip, image)
|
||||
internals[tabnumber].height = self.tabheight
|
||||
self.tabnumber = tabnumber + 1
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
@ -434,10 +431,26 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:SetTabHeight(height)
|
||||
|
||||
local autosize = self.autosize
|
||||
local padding = self.padding
|
||||
local previoustabheight = self.previoustabheight
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
self.tabheight = height
|
||||
|
||||
local tabheight = self.tabheight
|
||||
|
||||
if tabheight ~= previoustabheight then
|
||||
for k, v in ipairs(children) do
|
||||
local retainsize = v.retainsize
|
||||
if autosize and not retainsize then
|
||||
v:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2)
|
||||
end
|
||||
end
|
||||
self.previoustabheight = tabheight
|
||||
end
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "tabbutton" then
|
||||
v:SetHeight(self.tabheight)
|
||||
|
@ -26,6 +26,7 @@ function text:initialize()
|
||||
self.lines = 1
|
||||
self.formattedtext = {}
|
||||
self.original = {}
|
||||
self.ignorenewlines = false
|
||||
self.internal = false
|
||||
|
||||
end
|
||||
@ -162,8 +163,11 @@ function text:SetText(t)
|
||||
|
||||
elseif dtype == "string" then
|
||||
|
||||
v = v:gsub(string.char(9), " ")
|
||||
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, " ")
|
||||
|
||||
@ -331,6 +335,7 @@ function text:DrawText()
|
||||
|
||||
local textdata = self.formattedtext
|
||||
local font = self.font
|
||||
local theight = font:getHeight("a")
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
|
||||
@ -339,10 +344,17 @@ function text:DrawText()
|
||||
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)
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.printf(text, x + v.x, y + v.y, 0, "left")
|
||||
|
||||
end
|
||||
else
|
||||
love.graphics.setFont(font)
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.printf(text, x + v.x, y + v.y, 0, "left")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@ -434,3 +446,23 @@ function text:GetLines()
|
||||
return self.lines
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetIgnoreNewlines(bool)
|
||||
- desc: sets whether the object should ignore \n or not
|
||||
--]]---------------------------------------------------------
|
||||
function text:SetIgnoreNewlines(bool)
|
||||
|
||||
self.ignorenewlines = bool
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetIgnoreNewlines()
|
||||
- desc: gets whether the object should ignore \n or not
|
||||
--]]---------------------------------------------------------
|
||||
function text:GetIgnoreNewlines()
|
||||
|
||||
return self.ignorenewlines
|
||||
|
||||
end
|
@ -412,7 +412,6 @@ function textinput:keypressed(key, unicode)
|
||||
|
||||
self:RunKey(key, unicode)
|
||||
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
@ -461,6 +460,7 @@ function textinput:RunKey(key, unicode)
|
||||
local multiline = self.multiline
|
||||
local alltextselected = self.alltextselected
|
||||
local editable = self.editable
|
||||
local initialtext = self:GetText()
|
||||
local ontextchanged = self.OnTextChanged
|
||||
local onenter = self.OnEnter
|
||||
|
||||
@ -531,9 +531,13 @@ function textinput:RunKey(key, unicode)
|
||||
|
||||
-- key input checking system
|
||||
if key == "backspace" then
|
||||
|
||||
ckey = key
|
||||
|
||||
if not editable then
|
||||
return
|
||||
end
|
||||
|
||||
if alltextselected then
|
||||
self:Clear()
|
||||
self.alltextselected = false
|
||||
@ -542,9 +546,6 @@ function textinput:RunKey(key, unicode)
|
||||
if text ~= "" and indicatornum ~= 0 then
|
||||
text = self:RemoveFromeText(indicatornum)
|
||||
self:MoveIndicator(-1)
|
||||
if ontextchanged then
|
||||
ontextchanged(self, "")
|
||||
end
|
||||
lines[line] = text
|
||||
end
|
||||
if multiline then
|
||||
@ -567,7 +568,11 @@ function textinput:RunKey(key, unicode)
|
||||
self.offsetx = self.offsetx - cwidth
|
||||
end
|
||||
end
|
||||
|
||||
elseif key == "delete" then
|
||||
|
||||
ckey = key
|
||||
|
||||
if alltextselected then
|
||||
self:Clear()
|
||||
self.alltextselected = false
|
||||
@ -575,9 +580,6 @@ function textinput:RunKey(key, unicode)
|
||||
else
|
||||
if text ~= "" and indicatornum < #text then
|
||||
text = self:RemoveFromeText(indicatornum + 1)
|
||||
if ontextchanged then
|
||||
ontextchanged(self, "")
|
||||
end
|
||||
lines[line] = text
|
||||
elseif indicatornum == #text and line < #lines then
|
||||
local oldtext = lines[line + 1]
|
||||
@ -586,24 +588,26 @@ function textinput:RunKey(key, unicode)
|
||||
lines[self.line] = lines[self.line] .. oldtext
|
||||
end
|
||||
table.remove(lines, line + 1)
|
||||
print(indicatornum, #text)
|
||||
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
|
||||
self.alltextselected = false
|
||||
self:Clear()
|
||||
indicatornum = self.indicatornum
|
||||
line = self.line
|
||||
end
|
||||
|
||||
-- newline calculations for multiline mode
|
||||
if multiline then
|
||||
local newtext = ""
|
||||
if indicatornum == 0 then
|
||||
newtext = self.lines[line]
|
||||
@ -623,11 +627,15 @@ function textinput:RunKey(key, unicode)
|
||||
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
|
||||
|
||||
@ -692,11 +700,6 @@ function textinput:RunKey(key, unicode)
|
||||
self:MoveIndicator(1)
|
||||
end
|
||||
|
||||
-- call on text changed it if exists
|
||||
if ontextchanged then
|
||||
ontextchanged(self, ckey)
|
||||
end
|
||||
|
||||
lines = self.lines
|
||||
line = self.line
|
||||
curline = lines[line]
|
||||
@ -712,6 +715,13 @@ function textinput:RunKey(key, unicode)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local curtext = self:GetText()
|
||||
|
||||
if ontextchanged and initialtext ~= curtext then
|
||||
ontextchanged(self, ckey)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -443,15 +443,22 @@ function skin.DrawImage(object)
|
||||
|
||||
local x = object:GetX()
|
||||
local y = object:GetY()
|
||||
local orientation = object:GetOrientation()
|
||||
local scalex = object:GetScaleX()
|
||||
local scaley = object:GetScaleY()
|
||||
local offsetx = object:GetOffsetX()
|
||||
local offsety = object:GetOffsetY()
|
||||
local shearx = object:GetShearX()
|
||||
local sheary = object:GetShearY()
|
||||
local image = object.image
|
||||
local color = object.imagecolor
|
||||
|
||||
if color then
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.draw(image)
|
||||
love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
|
||||
else
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
love.graphics.draw(image, x, y)
|
||||
love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
|
||||
end
|
||||
|
||||
end
|
||||
@ -743,8 +750,6 @@ function skin.DrawTabButton(object)
|
||||
|
||||
local x = object:GetX()
|
||||
local y = object:GetY()
|
||||
local width = object:GetWidth()
|
||||
local height = object:GetHeight()
|
||||
local hover = object:GetHover()
|
||||
local text = object:GetText()
|
||||
local image = object:GetImage()
|
||||
@ -766,7 +771,22 @@ function skin.DrawTabButton(object)
|
||||
if image then
|
||||
imagewidth = image:getWidth()
|
||||
imageheight = image:getHeight()
|
||||
object.width = imagewidth + 15 + twidth
|
||||
if imageheight > theight then
|
||||
parent:SetTabHeight(imageheight + 5)
|
||||
object.height = imageheight + 5
|
||||
else
|
||||
parent:SetTabHeight(theight + 5)
|
||||
object.height = theight + 5
|
||||
end
|
||||
else
|
||||
object.width = 10 + twidth
|
||||
parent:SetTabHeight(theight + 5)
|
||||
object.height = theight + 5
|
||||
end
|
||||
|
||||
local width = object:GetWidth()
|
||||
local height = object:GetHeight()
|
||||
|
||||
if tabnumber == ptabnumber then
|
||||
|
||||
|
@ -443,15 +443,22 @@ function skin.DrawImage(object)
|
||||
|
||||
local x = object:GetX()
|
||||
local y = object:GetY()
|
||||
local orientation = object:GetOrientation()
|
||||
local scalex = object:GetScaleX()
|
||||
local scaley = object:GetScaleY()
|
||||
local offsetx = object:GetOffsetX()
|
||||
local offsety = object:GetOffsetY()
|
||||
local shearx = object:GetShearX()
|
||||
local sheary = object:GetShearY()
|
||||
local image = object.image
|
||||
local color = object.imagecolor
|
||||
|
||||
if color then
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.draw(image)
|
||||
love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
|
||||
else
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
love.graphics.draw(image, x, y)
|
||||
love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
|
||||
end
|
||||
|
||||
end
|
||||
@ -766,6 +773,18 @@ function skin.DrawTabButton(object)
|
||||
if image then
|
||||
imagewidth = image:getWidth()
|
||||
imageheight = image:getHeight()
|
||||
object.width = imagewidth + 15 + twidth
|
||||
if imageheight > theight then
|
||||
parent:SetTabHeight(imageheight + 5)
|
||||
object.height = imageheight + 5
|
||||
else
|
||||
parent:SetTabHeight(theight + 5)
|
||||
object.height = theight + 5
|
||||
end
|
||||
else
|
||||
object.width = 10 + twidth
|
||||
parent:SetTabHeight(theight + 5)
|
||||
object.height = theight + 5
|
||||
end
|
||||
|
||||
if tabnumber == ptabnumber then
|
||||
|
139
third-party/middleclass/middleclass.lua
vendored
139
third-party/middleclass/middleclass.lua
vendored
@ -1,139 +0,0 @@
|
||||
-- middleclass.lua - v2.0 (2011-09)
|
||||
-- Copyright (c) 2011 Enrique García Cota
|
||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-- Based on YaciCode, from Julien Patte and LuaObject, from Sebastien Rocca-Serra
|
||||
|
||||
local _classes = setmetatable({}, {__mode = "k"})
|
||||
|
||||
local function _setClassDictionariesMetatables(klass)
|
||||
local dict = klass.__instanceDict
|
||||
dict.__index = dict
|
||||
|
||||
local super = klass.super
|
||||
if super then
|
||||
local superStatic = super.static
|
||||
setmetatable(dict, super.__instanceDict)
|
||||
setmetatable(klass.static, { __index = function(_,k) return dict[k] or superStatic[k] end })
|
||||
else
|
||||
setmetatable(klass.static, { __index = function(_,k) return dict[k] end })
|
||||
end
|
||||
end
|
||||
|
||||
local function _setClassMetatable(klass)
|
||||
setmetatable(klass, {
|
||||
__tostring = function() return "class " .. klass.name end,
|
||||
__index = klass.static,
|
||||
__newindex = klass.__instanceDict,
|
||||
__call = function(self, ...) return self:new(...) end
|
||||
})
|
||||
end
|
||||
|
||||
local function _createClass(name, super)
|
||||
local klass = { name = name, super = super, static = {}, __mixins = {}, __instanceDict={} }
|
||||
klass.subclasses = setmetatable({}, {__mode = "k"})
|
||||
|
||||
_setClassDictionariesMetatables(klass)
|
||||
_setClassMetatable(klass)
|
||||
_classes[klass] = true
|
||||
|
||||
return klass
|
||||
end
|
||||
|
||||
local function _createLookupMetamethod(klass, name)
|
||||
return function(...)
|
||||
local method = klass.super[name]
|
||||
assert( type(method)=='function', tostring(klass) .. " doesn't implement metamethod '" .. name .. "'" )
|
||||
return method(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function _setClassMetamethods(klass)
|
||||
for _,m in ipairs(klass.__metamethods) do
|
||||
klass[m]= _createLookupMetamethod(klass, m)
|
||||
end
|
||||
end
|
||||
|
||||
local function _setDefaultInitializeMethod(klass, super)
|
||||
klass.initialize = function(instance, ...)
|
||||
return super.initialize(instance, ...)
|
||||
end
|
||||
end
|
||||
|
||||
local function _includeMixin(klass, mixin)
|
||||
assert(type(mixin)=='table', "mixin must be a table")
|
||||
for name,method in pairs(mixin) do
|
||||
if name ~= "included" and name ~= "static" then klass[name] = method end
|
||||
end
|
||||
if mixin.static then
|
||||
for name,method in pairs(mixin.static) do
|
||||
klass.static[name] = method
|
||||
end
|
||||
end
|
||||
if type(mixin.included)=="function" then mixin:included(klass) end
|
||||
klass.__mixins[mixin] = true
|
||||
end
|
||||
|
||||
Object = _createClass("Object", nil)
|
||||
|
||||
Object.static.__metamethods = { '__add', '__call', '__concat', '__div', '__le', '__lt',
|
||||
'__mod', '__mul', '__pow', '__sub', '__tostring', '__unm' }
|
||||
|
||||
function Object.static:allocate()
|
||||
assert(_classes[self], "Make sure that you are using 'Class:allocate' instead of 'Class.allocate'")
|
||||
return setmetatable({ class = self }, self.__instanceDict)
|
||||
end
|
||||
|
||||
function Object.static:new(...)
|
||||
local instance = self:allocate()
|
||||
instance:initialize(...)
|
||||
return instance
|
||||
end
|
||||
|
||||
function Object.static:subclass(name)
|
||||
assert(_classes[self], "Make sure that you are using 'Class:subclass' instead of 'Class.subclass'")
|
||||
assert(type(name) == "string", "You must provide a name(string) for your class")
|
||||
|
||||
local subclass = _createClass(name, self)
|
||||
_setClassMetamethods(subclass)
|
||||
_setDefaultInitializeMethod(subclass, self)
|
||||
self.subclasses[subclass] = true
|
||||
self:subclassed(subclass)
|
||||
|
||||
return subclass
|
||||
end
|
||||
|
||||
function Object.static:subclassed(other) end
|
||||
|
||||
function Object.static:include( ... )
|
||||
assert(_classes[self], "Make sure you that you are using 'Class:include' instead of 'Class.include'")
|
||||
for _,mixin in ipairs({...}) do _includeMixin(self, mixin) end
|
||||
return self
|
||||
end
|
||||
|
||||
function Object:initialize() end
|
||||
|
||||
function Object:__tostring() return "instance of " .. tostring(self.class) end
|
||||
|
||||
function class(name, super, ...)
|
||||
super = super or Object
|
||||
return super:subclass(name, ...)
|
||||
end
|
||||
|
||||
function instanceOf(aClass, obj)
|
||||
if not _classes[aClass] or type(obj) ~= 'table' or not _classes[obj.class] then return false end
|
||||
if obj.class == aClass then return true end
|
||||
return subclassOf(aClass, obj.class)
|
||||
end
|
||||
|
||||
function subclassOf(other, aClass)
|
||||
if not _classes[aClass] or not _classes[other] or aClass.super == nil then return false end
|
||||
return aClass.super == other or subclassOf(other, aClass.super)
|
||||
end
|
||||
|
||||
function includes(mixin, aClass)
|
||||
if not _classes[aClass] then return false end
|
||||
if aClass.__mixins[mixin] then return true end
|
||||
return includes(mixin, aClass.super)
|
||||
end
|
Loading…
Reference in New Issue
Block a user