Version 0.9.4.2 - Alpha (see changelog.txt)

This commit is contained in:
Kenny Shields 2012-11-05 08:53:22 -05:00
parent c6196570e5
commit 3d006ec389
11 changed files with 539 additions and 274 deletions

View File

@ -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) Version 0.9.4.1 - Alpha (October 25 - 2012)
================================================ ================================================

View File

@ -295,13 +295,86 @@ function loveframes.debug.ExamplesMenu()
local frame1 = loveframes.Create("frame") local frame1 = loveframes.Create("frame")
frame1:SetName("Image") frame1:SetName("Image")
frame1:SetSize(138, 163) frame1:SetSize(138, 315)
frame1:Center() frame1:Center()
local image1 = loveframes.Create("image", frame1) local image1 = loveframes.Create("image", frame1)
image1:SetImage("resources/images/carlsagan.png") image1:SetImage("resources/images/carlsagan.png")
image1:SetPos(5, 30) 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 end
exampleslist:AddItem(imageexample) exampleslist:AddItem(imageexample)

View File

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

View File

@ -15,6 +15,13 @@ function image:initialize()
self.type = "image" self.type = "image"
self.width = 0 self.width = 0
self.height = 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.internal = false
self.image = nil self.image = nil
self.imagecolor = nil self.imagecolor = nil
@ -130,3 +137,206 @@ function image:GetColor()
return self.imagecolor return self.imagecolor
end 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

View File

@ -13,6 +13,7 @@ tabbutton = class("tabbutton", base)
function tabbutton:initialize(parent, text, tabnumber, tip, image) function tabbutton:initialize(parent, text, tabnumber, tip, image)
self.type = "tabbutton" self.type = "tabbutton"
self.font = loveframes.smallfont
self.text = text self.text = text
self.tabnumber = tabnumber self.tabnumber = tabnumber
self.parent = parent self.parent = parent
@ -83,8 +84,6 @@ function tabbutton:draw()
return return
end end
local font = love.graphics.getFont()
local width = font:getWidth(self.text)
local image = self.image local image = self.image
local skins = loveframes.skins.available local skins = loveframes.skins.available
local skinindex = loveframes.config["ACTIVESKIN"] local skinindex = loveframes.config["ACTIVESKIN"]
@ -104,13 +103,6 @@ function tabbutton:draw()
drawfunc(self) drawfunc(self)
end end
if image then
local imagewidth = image:getWidth()
self.width = imagewidth + 15 + width
else
self.width = 10 + width
end
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------

View File

@ -12,22 +12,23 @@ tabs = class("tabpanel", base)
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:initialize() function tabs:initialize()
self.type = "tabs" self.type = "tabs"
self.width = 100 self.width = 100
self.height = 50 self.height = 50
self.clickx = 0 self.clickx = 0
self.clicky = 0 self.clicky = 0
self.offsetx = 0 self.offsetx = 0
self.tab = 1 self.tab = 1
self.tabnumber = 1 self.tabnumber = 1
self.padding = 5 self.padding = 5
self.tabheight = 25 self.tabheight = 25
self.autosize = true self.previoustabheight = 25
self.internal = false self.autosize = true
self.tooltipfont = loveframes.basicfontsmall self.internal = false
self.tabs = {} self.tooltipfont = loveframes.basicfontsmall
self.internals = {} self.tabs = {}
self.children = {} self.internals = {}
self.children = {}
end end
@ -46,20 +47,20 @@ function tabs:update(dt)
end end
end end
local x, y = love.mouse.getPosition() local x, y = love.mouse.getPosition()
local tabheight = self.tabheight local tabheight = self.tabheight
local padding = self.padding local padding = self.padding
local autosize = self.autosize local autosize = self.autosize
local tabheight = self.tabheight local padding = self.padding
local padding = self.padding local autosize = self.autosize
local autosize = self.autosize local children = self.children
local children = self.children local numchildren = #children
local numchildren = #children local internals = self.internals
local internals = self.internals local tab = self.tab
local tab = self.tab local parent = self.parent
local parent = self.parent local autosize = self.autosize
local base = loveframes.base local base = loveframes.base
local update = self.Update local update = self.Update
-- move to parent if there is a parent -- move to parent if there is a parent
if parent ~= base then if parent ~= base then
@ -251,23 +252,19 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:AddTab(name, object, tip, image) function tabs:AddTab(name, object, tip, image)
local tabheight = self.tabheight local padding = self.padding
local padding = self.padding local autosize = self.autosize
local autosize = self.autosize local tabnumber = self.tabnumber
local retainsize = object.retainsize local tabheight = self.tabheight
local tabnumber = self.tabnumber local internals = self.internals
local internals = self.internals
object:Remove() object:Remove()
object.parent = self object.parent = self
object.staticx = 0 object.staticx = 0
object.staticy = 0 object.staticy = 0
object:SetWidth(self.width - 10)
object:SetHeight(self.height - 35)
table.insert(self.children, object) table.insert(self.children, object)
internals[tabnumber] = tabbutton:new(self, name, tabnumber, tip, image) internals[tabnumber] = tabbutton:new(self, name, tabnumber, tip, image)
internals[tabnumber].height = self.tabheight
self.tabnumber = tabnumber + 1 self.tabnumber = tabnumber + 1
for k, v in ipairs(internals) do for k, v in ipairs(internals) do
@ -434,10 +431,26 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function tabs:SetTabHeight(height) function tabs:SetTabHeight(height)
local internals = self.internals local autosize = self.autosize
local padding = self.padding
local previoustabheight = self.previoustabheight
local children = self.children
local internals = self.internals
self.tabheight = height 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 for k, v in ipairs(internals) do
if v.type == "tabbutton" then if v.type == "tabbutton" then
v:SetHeight(self.tabheight) v:SetHeight(self.tabheight)

View File

@ -26,6 +26,7 @@ function text:initialize()
self.lines = 1 self.lines = 1
self.formattedtext = {} self.formattedtext = {}
self.original = {} self.original = {}
self.ignorenewlines = false
self.internal = false self.internal = false
end end
@ -162,8 +163,11 @@ function text:SetText(t)
elseif dtype == "string" then 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), " ") v = v:gsub(string.char(9), " ")
v = v:gsub(string.char(92) .. string.char(110), string.char(10))
local parts = loveframes.util.SplitString(v, " ") local parts = loveframes.util.SplitString(v, " ")
@ -331,6 +335,7 @@ function text:DrawText()
local textdata = self.formattedtext local textdata = self.formattedtext
local font = self.font local font = self.font
local theight = font:getHeight("a")
local x = self.x local x = self.x
local y = self.y local y = self.y
@ -339,10 +344,17 @@ function text:DrawText()
local text = v.text local text = v.text
local color = v.color local color = v.color
love.graphics.setFont(font) if self.parent.type == "list" then
love.graphics.setColor(unpack(color)) if (y + v.y) <= (self.parent.y + self.parent.height) and self.y + ((v.y + theight)) >= self.parent.y then
love.graphics.printf(text, x + v.x, y + v.y, 0, "left") 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
end end
@ -434,3 +446,23 @@ function text:GetLines()
return self.lines return self.lines
end 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

View File

@ -13,50 +13,50 @@ textinput = class("textinput", base)
function textinput:initialize() function textinput:initialize()
self.type = "textinput" self.type = "textinput"
self.keydown = "none" self.keydown = "none"
self.tabreplacement = " " self.tabreplacement = " "
self.font = loveframes.basicfont self.font = loveframes.basicfont
self.width = 200 self.width = 200
self.height = 25 self.height = 25
self.delay = 0 self.delay = 0
self.offsetx = 0 self.offsetx = 0
self.offsety = 0 self.offsety = 0
self.indincatortime = 0 self.indincatortime = 0
self.indicatornum = 0 self.indicatornum = 0
self.indicatorx = 0 self.indicatorx = 0
self.indicatory = 0 self.indicatory = 0
self.textx = 0 self.textx = 0
self.texty = 0 self.texty = 0
self.textoffsetx = 5 self.textoffsetx = 5
self.textoffsety = 5 self.textoffsety = 5
self.unicode = 0 self.unicode = 0
self.limit = 0 self.limit = 0
self.line = 1 self.line = 1
self.itemwidth = 0 self.itemwidth = 0
self.itemheight = 0 self.itemheight = 0
self.extrawidth = 0 self.extrawidth = 0
self.extraheight = 0 self.extraheight = 0
self.rightpadding = 0 self.rightpadding = 0
self.bottompadding = 0 self.bottompadding = 0
self.lastclicktime = 0 self.lastclicktime = 0
self.maxx = 0 self.maxx = 0
self.usable = {} self.usable = {}
self.unusable = {} self.unusable = {}
self.lines = {""} self.lines = {""}
self.internals = {} self.internals = {}
self.showindicator = true self.showindicator = true
self.focus = false self.focus = false
self.multiline = false self.multiline = false
self.vbar = false self.vbar = false
self.hbar = false self.hbar = false
self.alltextselected = false self.alltextselected = false
self.linenumbers = true self.linenumbers = true
self.linenumberspanel = false self.linenumberspanel = false
self.editable = true self.editable = true
self.internal = false self.internal = false
self.OnEnter = nil self.OnEnter = nil
self.OnTextChanged = nil self.OnTextChanged = nil
end end
@ -412,7 +412,6 @@ function textinput:keypressed(key, unicode)
self:RunKey(key, unicode) self:RunKey(key, unicode)
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -461,6 +460,7 @@ function textinput:RunKey(key, unicode)
local multiline = self.multiline local multiline = self.multiline
local alltextselected = self.alltextselected local alltextselected = self.alltextselected
local editable = self.editable local editable = self.editable
local initialtext = self:GetText()
local ontextchanged = self.OnTextChanged local ontextchanged = self.OnTextChanged
local onenter = self.OnEnter local onenter = self.OnEnter
@ -531,9 +531,13 @@ function textinput:RunKey(key, unicode)
-- key input checking system -- key input checking system
if key == "backspace" then if key == "backspace" then
ckey = key
if not editable then if not editable then
return return
end end
if alltextselected then if alltextselected then
self:Clear() self:Clear()
self.alltextselected = false self.alltextselected = false
@ -542,9 +546,6 @@ function textinput:RunKey(key, unicode)
if text ~= "" and indicatornum ~= 0 then if text ~= "" and indicatornum ~= 0 then
text = self:RemoveFromeText(indicatornum) text = self:RemoveFromeText(indicatornum)
self:MoveIndicator(-1) self:MoveIndicator(-1)
if ontextchanged then
ontextchanged(self, "")
end
lines[line] = text lines[line] = text
end end
if multiline then if multiline then
@ -567,7 +568,11 @@ function textinput:RunKey(key, unicode)
self.offsetx = self.offsetx - cwidth self.offsetx = self.offsetx - cwidth
end end
end end
elseif key == "delete" then elseif key == "delete" then
ckey = key
if alltextselected then if alltextselected then
self:Clear() self:Clear()
self.alltextselected = false self.alltextselected = false
@ -575,9 +580,6 @@ function textinput:RunKey(key, unicode)
else else
if text ~= "" and indicatornum < #text then if text ~= "" and indicatornum < #text then
text = self:RemoveFromeText(indicatornum + 1) text = self:RemoveFromeText(indicatornum + 1)
if ontextchanged then
ontextchanged(self, "")
end
lines[line] = text lines[line] = text
elseif indicatornum == #text and line < #lines then elseif indicatornum == #text and line < #lines then
local oldtext = lines[line + 1] local oldtext = lines[line + 1]
@ -586,24 +588,26 @@ function textinput:RunKey(key, unicode)
lines[self.line] = lines[self.line] .. oldtext lines[self.line] = lines[self.line] .. oldtext
end end
table.remove(lines, line + 1) table.remove(lines, line + 1)
print(indicatornum, #text)
end end
end end
elseif key == "return" or key == "kpenter" then elseif key == "return" or key == "kpenter" then
ckey = key
-- call onenter if it exists -- call onenter if it exists
if onenter then if onenter then
onenter(self, text) onenter(self, text)
end end
if alltextselected then
self.alltextselected = false
self:Clear()
indicatornum = self.indicatornum
end
-- newline calculations for multiline mode -- newline calculations for multiline mode
if multiline then if multiline then
if alltextselected then
self.alltextselected = false
self:Clear()
indicatornum = self.indicatornum
line = self.line
end
local newtext = "" local newtext = ""
if indicatornum == 0 then if indicatornum == 0 then
newtext = self.lines[line] newtext = self.lines[line]
@ -623,11 +627,15 @@ function textinput:RunKey(key, unicode)
end end
elseif key == "tab" then elseif key == "tab" then
ckey = key
for i=1, #self.tabreplacement do for i=1, #self.tabreplacement do
local number = string.byte(self.tabreplacement:sub(i, i)) local number = string.byte(self.tabreplacement:sub(i, i))
self.lines[self.line] = self:AddIntoText(number, self.indicatornum) self.lines[self.line] = self:AddIntoText(number, self.indicatornum)
self:MoveIndicator(1) self:MoveIndicator(1)
end end
else else
if unicode > 31 and unicode < 127 then if unicode > 31 and unicode < 127 then
@ -692,11 +700,6 @@ function textinput:RunKey(key, unicode)
self:MoveIndicator(1) self:MoveIndicator(1)
end end
-- call on text changed it if exists
if ontextchanged then
ontextchanged(self, ckey)
end
lines = self.lines lines = self.lines
line = self.line line = self.line
curline = lines[line] curline = lines[line]
@ -712,6 +715,13 @@ function textinput:RunKey(key, unicode)
end end
end end
end end
end
local curtext = self:GetText()
if ontextchanged and initialtext ~= curtext then
ontextchanged(self, ckey)
end end
end end

View File

@ -441,17 +441,24 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function skin.DrawImage(object) function skin.DrawImage(object)
local x = object:GetX() local x = object:GetX()
local y = object:GetY() local y = object:GetY()
local image = object.image local orientation = object:GetOrientation()
local color = object.imagecolor 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 if color then
love.graphics.setColor(unpack(color)) love.graphics.setColor(unpack(color))
love.graphics.draw(image) love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
else else
love.graphics.setColor(255, 255, 255, 255) 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
end end
@ -743,8 +750,6 @@ function skin.DrawTabButton(object)
local x = object:GetX() local x = object:GetX()
local y = object:GetY() local y = object:GetY()
local width = object:GetWidth()
local height = object:GetHeight()
local hover = object:GetHover() local hover = object:GetHover()
local text = object:GetText() local text = object:GetText()
local image = object:GetImage() local image = object:GetImage()
@ -766,8 +771,23 @@ function skin.DrawTabButton(object)
if image then if image then
imagewidth = image:getWidth() imagewidth = image:getWidth()
imageheight = image:getHeight() 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 end
local width = object:GetWidth()
local height = object:GetHeight()
if tabnumber == ptabnumber then if tabnumber == ptabnumber then
-- button body -- button body

View File

@ -441,17 +441,24 @@ end
--]]--------------------------------------------------------- --]]---------------------------------------------------------
function skin.DrawImage(object) function skin.DrawImage(object)
local x = object:GetX() local x = object:GetX()
local y = object:GetY() local y = object:GetY()
local image = object.image local orientation = object:GetOrientation()
local color = object.imagecolor 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 if color then
love.graphics.setColor(unpack(color)) love.graphics.setColor(unpack(color))
love.graphics.draw(image) love.graphics.draw(image, x, y, orientation, scalex, scaley, offsetx, offsety, shearx, sheary)
else else
love.graphics.setColor(255, 255, 255, 255) 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
end end
@ -766,6 +773,18 @@ function skin.DrawTabButton(object)
if image then if image then
imagewidth = image:getWidth() imagewidth = image:getWidth()
imageheight = image:getHeight() 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 end
if tabnumber == ptabnumber then if tabnumber == ptabnumber then

View File

@ -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