Customizable button areas for the tabs object

This commit is contained in:
Kenny Shields 2013-12-14 11:29:59 -05:00
parent d9e75bd46c
commit 1c5b226ce2
3 changed files with 27 additions and 4 deletions

View File

@ -26,6 +26,7 @@ Version 0.9.6.4 - Alpha (Release Date TBD)
[ADDED] a new util library function: GetHoverObject()
[ADDED] a new callback: textinput(text)
[ADDED] a new object: form
[ADDED] a new skin drawing function: DrawOverTabPanel(object)
[ADDED] basic clipboard support for the textinput object (0.9.0 only)
[ADDED] custom cursor support for the textinput object
[ADDED] support for love.filesystem changes to loveframes.util.GetDirectoryContents (0.9.0 only)

View File

@ -25,7 +25,10 @@ function newobject:initialize()
self.previoustabheight = 25
self.buttonscrollamount = 200
self.mousewheelscrollamount = 1500
self.buttonareax = 0
self.buttonareawidth = self.width
self.autosize = true
self.autobuttonareawidth = true
self.dtscrolling = true
self.internal = false
self.tooltipfont = loveframes.basicfontsmall
@ -62,6 +65,7 @@ function newobject:update(dt)
local tabheight = self.tabheight
local padding = self.padding
local autosize = self.autosize
local autobuttonareawidth = self.autobuttonareawidth
local padding = self.padding
local children = self.children
local numchildren = #children
@ -83,12 +87,17 @@ function newobject:update(dt)
self.tab = 1
end
if autobuttonareawidth then
local width = self.width
self.buttonareawidth = width
end
local pos = 0
for k, v in ipairs(internals) do
v:update(dt)
if v.type == "tabbutton" then
v.x = (v.parent.x + v.staticx) + pos + self.offsetx
v.x = (v.parent.x + v.staticx) + pos + self.offsetx + self.buttonareax
v.y = (v.parent.y + v.staticy)
pos = pos + v.width - 1
end
@ -130,7 +139,7 @@ function newobject:draw()
local height = self.height
local internals = self.internals
local tabheight = self:GetHeightOfButtons()
local stencilfunc = function() love.graphics.rectangle("fill", x, y, width, height) end
local stencilfunc = function() love.graphics.rectangle("fill", x + self.buttonareax, y, self.buttonareawidth, height) end
local loveversion = love._version
local internals = self.internals
local skins = loveframes.skins.available
@ -139,6 +148,7 @@ function newobject:draw()
local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel
local drawoverfunc = skin.DrawOverTabPanel or skins[defaultskin].DrawOverTabPanel
local draw = self.Draw
local drawcount = loveframes.drawcount
@ -168,6 +178,10 @@ function newobject:draw()
self.children[self.tab]:draw()
end
if not draw then
drawoverfunc(self)
end
end
--[[---------------------------------------------------------
@ -355,7 +369,7 @@ function newobject:AddScrollButtons()
if object.down then
if self.offsetx > 0 then
self.offsetx = 0
else
elseif self.offsetx ~= 0 then
local scrollamount = self.buttonscrollamount
local dtscrolling = self.dtscrolling
if dtscrolling then
@ -377,7 +391,7 @@ function newobject:AddScrollButtons()
object.staticx = self.width - object.width
object.staticy = 0
local bwidth = self:GetWidthOfButtons()
if (self.offsetx + bwidth) > self.width then
if (self.offsetx + bwidth) - (self.buttonareax * 2 - 1) > self.width then
object.visible = true
else
object.visible = false

View File

@ -665,6 +665,14 @@ function skin.DrawTabPanel(object)
end
--[[---------------------------------------------------------
- func: DrawOverTabPanel(object)
- desc: draws over the tab panel object
--]]---------------------------------------------------------
function skin.DrawOverTabPanel(object)
end
--[[---------------------------------------------------------
- func: DrawTabButton(object)
- desc: draws the tab button object