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 util library function: GetHoverObject()
[ADDED] a new callback: textinput(text) [ADDED] a new callback: textinput(text)
[ADDED] a new object: form [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] basic clipboard support for the textinput object (0.9.0 only)
[ADDED] custom cursor support for the textinput object [ADDED] custom cursor support for the textinput object
[ADDED] support for love.filesystem changes to loveframes.util.GetDirectoryContents (0.9.0 only) [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.previoustabheight = 25
self.buttonscrollamount = 200 self.buttonscrollamount = 200
self.mousewheelscrollamount = 1500 self.mousewheelscrollamount = 1500
self.buttonareax = 0
self.buttonareawidth = self.width
self.autosize = true self.autosize = true
self.autobuttonareawidth = true
self.dtscrolling = true self.dtscrolling = true
self.internal = false self.internal = false
self.tooltipfont = loveframes.basicfontsmall self.tooltipfont = loveframes.basicfontsmall
@ -62,6 +65,7 @@ function newobject:update(dt)
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 autobuttonareawidth = self.autobuttonareawidth
local padding = self.padding local padding = self.padding
local children = self.children local children = self.children
local numchildren = #children local numchildren = #children
@ -83,12 +87,17 @@ function newobject:update(dt)
self.tab = 1 self.tab = 1
end end
if autobuttonareawidth then
local width = self.width
self.buttonareawidth = width
end
local pos = 0 local pos = 0
for k, v in ipairs(internals) do for k, v in ipairs(internals) do
v:update(dt) v:update(dt)
if v.type == "tabbutton" then 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) v.y = (v.parent.y + v.staticy)
pos = pos + v.width - 1 pos = pos + v.width - 1
end end
@ -130,7 +139,7 @@ function newobject:draw()
local height = self.height local height = self.height
local internals = self.internals local internals = self.internals
local tabheight = self:GetHeightOfButtons() 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 loveversion = love._version
local internals = self.internals local internals = self.internals
local skins = loveframes.skins.available local skins = loveframes.skins.available
@ -139,6 +148,7 @@ function newobject:draw()
local selfskin = self.skin local selfskin = self.skin
local skin = skins[selfskin] or skins[skinindex] local skin = skins[selfskin] or skins[skinindex]
local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel local drawfunc = skin.DrawTabPanel or skins[defaultskin].DrawTabPanel
local drawoverfunc = skin.DrawOverTabPanel or skins[defaultskin].DrawOverTabPanel
local draw = self.Draw local draw = self.Draw
local drawcount = loveframes.drawcount local drawcount = loveframes.drawcount
@ -168,6 +178,10 @@ function newobject:draw()
self.children[self.tab]:draw() self.children[self.tab]:draw()
end end
if not draw then
drawoverfunc(self)
end
end end
--[[--------------------------------------------------------- --[[---------------------------------------------------------
@ -355,7 +369,7 @@ function newobject:AddScrollButtons()
if object.down then if object.down then
if self.offsetx > 0 then if self.offsetx > 0 then
self.offsetx = 0 self.offsetx = 0
else elseif self.offsetx ~= 0 then
local scrollamount = self.buttonscrollamount local scrollamount = self.buttonscrollamount
local dtscrolling = self.dtscrolling local dtscrolling = self.dtscrolling
if dtscrolling then if dtscrolling then
@ -377,7 +391,7 @@ function newobject:AddScrollButtons()
object.staticx = self.width - object.width object.staticx = self.width - object.width
object.staticy = 0 object.staticy = 0
local bwidth = self:GetWidthOfButtons() 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 object.visible = true
else else
object.visible = false object.visible = false

View File

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