2013-01-21 22:36:53 +01:00
|
|
|
-- @docclass
|
2014-06-06 18:10:14 +02:00
|
|
|
UIMoveableTabBar = extends(UIWidget, "UIMoveableTabBar")
|
2013-01-21 22:36:53 +01:00
|
|
|
|
|
|
|
-- private functions
|
|
|
|
local function onTabClick(tab)
|
|
|
|
tab.tabBar:selectTab(tab)
|
|
|
|
end
|
|
|
|
|
2015-04-20 03:32:18 +02:00
|
|
|
local function updateMargins(tabBar)
|
2013-01-21 22:36:53 +01:00
|
|
|
if #tabBar.tabs == 0 then return end
|
2014-01-18 15:09:26 +01:00
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local currentMargin = 0
|
|
|
|
for i = 1, #tabBar.tabs do
|
2013-01-24 18:45:26 +01:00
|
|
|
tabBar.tabs[i]:setMarginLeft(currentMargin)
|
|
|
|
currentMargin = currentMargin + tabBar.tabSpacing + tabBar.tabs[i]:getWidth()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-12-03 20:25:13 +01:00
|
|
|
local function updateNavigation(tabBar)
|
2015-01-27 21:14:07 +01:00
|
|
|
if tabBar.prevNavigation then
|
2013-12-03 20:25:13 +01:00
|
|
|
if #tabBar.preTabs > 0 or table.find(tabBar.tabs, tabBar.currentTab) ~= 1 then
|
2015-01-27 21:14:07 +01:00
|
|
|
tabBar.prevNavigation:enable()
|
2013-12-03 20:25:13 +01:00
|
|
|
else
|
2015-01-27 21:14:07 +01:00
|
|
|
tabBar.prevNavigation:disable()
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-27 21:14:07 +01:00
|
|
|
if tabBar.nextNavigation then
|
2013-12-03 20:25:13 +01:00
|
|
|
if #tabBar.postTabs > 0 or table.find(tabBar.tabs, tabBar.currentTab) ~= #tabBar.tabs then
|
2015-01-27 21:14:07 +01:00
|
|
|
tabBar.nextNavigation:enable()
|
2013-12-03 20:25:13 +01:00
|
|
|
else
|
2015-01-27 21:14:07 +01:00
|
|
|
tabBar.nextNavigation:disable()
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-24 18:45:26 +01:00
|
|
|
local function updateIndexes(tabBar, tab, xoff)
|
|
|
|
local tabs = tabBar.tabs
|
|
|
|
local currentMargin = 0
|
|
|
|
local prevIndex = table.find(tabs, tab)
|
|
|
|
local newIndex = prevIndex
|
|
|
|
local xmid = xoff + tab:getWidth()/2
|
|
|
|
for i = 1, #tabs do
|
|
|
|
local nextTab = tabs[i]
|
|
|
|
if xmid >= currentMargin + nextTab:getWidth()/2 then
|
|
|
|
newIndex = table.find(tabs, nextTab)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
2013-01-24 18:45:26 +01:00
|
|
|
currentMargin = currentMargin + tabBar.tabSpacing * (i - 1) + tabBar.tabs[i]:getWidth()
|
|
|
|
end
|
|
|
|
if newIndex ~= prevIndex then
|
|
|
|
table.remove(tabs, table.find(tabs, tab))
|
|
|
|
table.insert(tabs, newIndex, tab)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
2013-12-03 20:25:13 +01:00
|
|
|
updateNavigation(tabBar)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
2013-01-24 18:45:26 +01:00
|
|
|
local function getMaxMargin(tabBar, tab)
|
2013-12-03 20:25:13 +01:00
|
|
|
if #tabBar.tabs == 0 then return 0 end
|
2013-01-24 18:45:26 +01:00
|
|
|
|
|
|
|
local maxMargin = 0
|
|
|
|
for i = 1, #tabBar.tabs do
|
|
|
|
if tabBar.tabs[i] ~= tab then
|
|
|
|
maxMargin = maxMargin + tabBar.tabs[i]:getWidth()
|
|
|
|
end
|
|
|
|
end
|
2013-12-03 20:25:13 +01:00
|
|
|
return maxMargin + tabBar.tabSpacing * (#tabBar.tabs - 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function updateTabs(tabBar)
|
|
|
|
if #tabBar.postTabs > 0 then
|
|
|
|
local i = 1
|
|
|
|
while i <= #tabBar.postTabs do
|
|
|
|
local tab = tabBar.postTabs[i]
|
|
|
|
if getMaxMargin(tabBar) + tab:getWidth() > tabBar:getWidth() then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
|
|
|
|
table.remove(tabBar.postTabs, i)
|
|
|
|
table.insert(tabBar.tabs, tab)
|
|
|
|
tab:setVisible(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #tabBar.preTabs > 0 then
|
|
|
|
for i = #tabBar.preTabs, 1, -1 do
|
|
|
|
local tab = tabBar.preTabs[i]
|
|
|
|
if getMaxMargin(tabBar) + tab:getWidth() > tabBar:getWidth() then
|
|
|
|
break
|
|
|
|
end
|
|
|
|
|
|
|
|
table.remove(tabBar.preTabs, i)
|
|
|
|
table.insert(tabBar.tabs, 1, tab)
|
|
|
|
tab:setVisible(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
updateNavigation(tabBar)
|
|
|
|
updateMargins(tabBar)
|
|
|
|
|
|
|
|
if not tabBar.currentTab and #tabBar.tabs > 0 then
|
|
|
|
tabBar:selectTab(tabBar.tabs[1])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function hideTabs(tabBar, fromBack, toArray, width)
|
|
|
|
while #tabBar.tabs > 0 and getMaxMargin(tabBar) + width > tabBar:getWidth() do
|
|
|
|
local index = fromBack and #tabBar.tabs or 1
|
|
|
|
local tab = tabBar.tabs[index]
|
|
|
|
table.remove(tabBar.tabs, index)
|
|
|
|
if fromBack then
|
|
|
|
table.insert(toArray, 1, tab)
|
|
|
|
else
|
|
|
|
table.insert(toArray, tab)
|
|
|
|
end
|
|
|
|
if tabBar.currentTab == tab then
|
|
|
|
if #tabBar.tabs > 0 then
|
|
|
|
tabBar:selectTab(tabBar.tabs[#tabBar.tabs])
|
|
|
|
else
|
|
|
|
tabBar.currentTab:setChecked(false)
|
|
|
|
tabBar.currentTab = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
tab:setVisible(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function showPreTab(tabBar)
|
|
|
|
if #tabBar.preTabs == 0 then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
local tmpTab = tabBar.preTabs[#tabBar.preTabs]
|
|
|
|
hideTabs(tabBar, true, tabBar.postTabs, tmpTab:getWidth())
|
|
|
|
|
|
|
|
table.remove(tabBar.preTabs, #tabBar.preTabs)
|
|
|
|
table.insert(tabBar.tabs, 1, tmpTab)
|
|
|
|
tmpTab:setVisible(true)
|
|
|
|
return tmpTab
|
|
|
|
end
|
|
|
|
|
|
|
|
local function showPostTab(tabBar)
|
|
|
|
if #tabBar.postTabs == 0 then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
local tmpTab = tabBar.postTabs[1]
|
|
|
|
hideTabs(tabBar, false, tabBar.preTabs, tmpTab:getWidth())
|
|
|
|
|
|
|
|
table.remove(tabBar.postTabs, 1)
|
|
|
|
table.insert(tabBar.tabs, tmpTab)
|
|
|
|
tmpTab:setVisible(true)
|
|
|
|
return tmpTab
|
2013-01-24 18:45:26 +01:00
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local function onTabMousePress(tab, mousePos, mouseButton)
|
|
|
|
if mouseButton == MouseRightButton then
|
|
|
|
if tab.menuCallback then tab.menuCallback(tab, mousePos, mouseButton) end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-24 18:45:26 +01:00
|
|
|
local function onTabDragEnter(tab, mousePos)
|
2013-01-21 22:36:53 +01:00
|
|
|
tab:raise()
|
2013-01-24 18:45:26 +01:00
|
|
|
tab.hotSpot = mousePos.x - tab:getMarginLeft()
|
2013-01-21 22:36:53 +01:00
|
|
|
tab.tabBar.selected = tab
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onTabDragLeave(tab)
|
|
|
|
updateMargins(tab.tabBar)
|
|
|
|
tab.tabBar.selected = nil
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
local function onTabDragMove(tab, mousePos, mouseMoved)
|
|
|
|
if tab == tab.tabBar.selected then
|
2013-01-24 18:45:26 +01:00
|
|
|
local xoff = mousePos.x - tab.hotSpot
|
2013-01-21 22:36:53 +01:00
|
|
|
|
2013-01-24 18:45:26 +01:00
|
|
|
-- update indexes
|
|
|
|
updateIndexes(tab.tabBar, tab, xoff)
|
|
|
|
updateIndexes(tab.tabBar, tab, xoff)
|
|
|
|
|
|
|
|
-- update margins
|
|
|
|
updateMargins(tab.tabBar)
|
|
|
|
xoff = math.max(xoff, 0)
|
|
|
|
xoff = math.min(xoff, getMaxMargin(tab.tabBar, tab))
|
|
|
|
tab:setMarginLeft(xoff)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-02-27 20:24:32 +01:00
|
|
|
local function tabBlink(tab, step)
|
2015-01-30 19:56:56 +01:00
|
|
|
local step = step or 0
|
2013-01-21 22:36:53 +01:00
|
|
|
tab:setOn(not tab:isOn())
|
2013-02-27 20:24:32 +01:00
|
|
|
|
|
|
|
removeEvent(tab.blinkEvent)
|
|
|
|
if step < 4 then
|
|
|
|
tab.blinkEvent = scheduleEvent(function() tabBlink(tab, step+1) end, 500)
|
|
|
|
else
|
|
|
|
tab:setOn(true)
|
|
|
|
tab.blinkEvent = nil
|
|
|
|
end
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- public functions
|
|
|
|
function UIMoveableTabBar.create()
|
|
|
|
local tabbar = UIMoveableTabBar.internalCreate()
|
|
|
|
tabbar:setFocusable(false)
|
|
|
|
tabbar.tabs = {}
|
|
|
|
tabbar.selected = nil -- dragged tab
|
2013-01-24 18:45:26 +01:00
|
|
|
tabbar.tabSpacing = 0
|
2013-01-21 22:36:53 +01:00
|
|
|
tabbar.tabsMoveable = false
|
2013-12-03 20:25:13 +01:00
|
|
|
tabbar.preTabs = {}
|
|
|
|
tabbar.postTabs = {}
|
|
|
|
tabbar.prevNavigation = nil
|
|
|
|
tabbar.nextNavigation = nil
|
|
|
|
tabbar.onGeometryChange = function()
|
|
|
|
hideTabs(tabbar, true, tabbar.postTabs, 0)
|
|
|
|
updateTabs(tabbar)
|
|
|
|
end
|
2013-01-21 22:36:53 +01:00
|
|
|
return tabbar
|
|
|
|
end
|
|
|
|
|
2015-01-27 21:14:07 +01:00
|
|
|
function UIMoveableTabBar:onDestroy()
|
|
|
|
if self.prevNavigation then
|
|
|
|
self.prevNavigation:disable()
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.nextNavigation then
|
|
|
|
self.nextNavigation:disable()
|
|
|
|
end
|
|
|
|
|
|
|
|
self.nextNavigation = nil
|
|
|
|
self.prevNavigation = nil
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
function UIMoveableTabBar:setContentWidget(widget)
|
|
|
|
self.contentWidget = widget
|
|
|
|
if #self.tabs > 0 then
|
|
|
|
self.contentWidget:addChild(self.tabs[1].tabPanel)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:setTabSpacing(tabSpacing)
|
|
|
|
self.tabSpacing = tabSpacing
|
|
|
|
updateMargins(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:addTab(text, panel, menuCallback)
|
|
|
|
if panel == nil then
|
|
|
|
panel = g_ui.createWidget(self:getStyleName() .. 'Panel')
|
|
|
|
panel:setId('tabPanel')
|
|
|
|
end
|
|
|
|
|
|
|
|
local tab = g_ui.createWidget(self:getStyleName() .. 'Button', self)
|
|
|
|
panel.isTab = true
|
|
|
|
tab.tabPanel = panel
|
|
|
|
tab.tabBar = self
|
|
|
|
tab:setId('tab')
|
|
|
|
tab:setDraggable(self.tabsMoveable)
|
|
|
|
tab:setText(text)
|
|
|
|
tab:setWidth(tab:getTextSize().width + tab:getPaddingLeft() + tab:getPaddingRight())
|
|
|
|
tab.menuCallback = menuCallback or nil
|
|
|
|
tab.onClick = onTabClick
|
|
|
|
tab.onMousePress = onTabMousePress
|
|
|
|
tab.onDragEnter = onTabDragEnter
|
|
|
|
tab.onDragLeave = onTabDragLeave
|
|
|
|
tab.onDragMove = onTabDragMove
|
|
|
|
tab.onDestroy = function() tab.tabPanel:destroy() end
|
|
|
|
|
2013-12-03 20:25:13 +01:00
|
|
|
if #self.tabs == 0 then
|
2013-01-21 22:36:53 +01:00
|
|
|
self:selectTab(tab)
|
|
|
|
tab:setMarginLeft(0)
|
2013-12-03 20:25:13 +01:00
|
|
|
table.insert(self.tabs, tab)
|
2013-01-21 22:36:53 +01:00
|
|
|
else
|
2013-12-03 20:25:13 +01:00
|
|
|
local newMargin = self.tabSpacing * #self.tabs
|
|
|
|
for i = 1, #self.tabs do
|
2013-01-21 22:36:53 +01:00
|
|
|
newMargin = newMargin + self.tabs[i]:getWidth()
|
|
|
|
end
|
|
|
|
tab:setMarginLeft(newMargin)
|
2013-12-03 20:25:13 +01:00
|
|
|
|
|
|
|
hideTabs(self, true, self.postTabs, tab:getWidth())
|
|
|
|
table.insert(self.tabs, tab)
|
|
|
|
if #self.tabs == 1 then
|
|
|
|
self:selectTab(tab)
|
|
|
|
end
|
|
|
|
updateMargins(self)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
2013-12-03 20:25:13 +01:00
|
|
|
updateNavigation(self)
|
2013-01-21 22:36:53 +01:00
|
|
|
return tab
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Additional function to move the tab by lua
|
|
|
|
function UIMoveableTabBar:moveTab(tab, units)
|
|
|
|
local index = table.find(self.tabs, tab)
|
|
|
|
if index == nil then return end
|
2014-01-18 15:09:26 +01:00
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local focus = false
|
|
|
|
if self.currentTab == tab then
|
|
|
|
self:selectPrevTab()
|
|
|
|
focus = true
|
|
|
|
end
|
2014-01-18 15:09:26 +01:00
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
table.remove(self.tabs, index)
|
2014-01-18 15:09:26 +01:00
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local newIndex = math.min(#self.tabs+1, math.max(index + units, 1))
|
2014-01-18 15:09:26 +01:00
|
|
|
table.insert(self.tabs, newIndex, tab)
|
2013-01-21 22:36:53 +01:00
|
|
|
if focus then self:selectTab(tab) end
|
|
|
|
updateMargins(self)
|
|
|
|
return newIndex
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:onStyleApply(styleName, styleNode)
|
2015-04-20 03:32:18 +02:00
|
|
|
if styleNode['movable'] then
|
|
|
|
self.tabsMoveable = styleNode['movable']
|
|
|
|
end
|
|
|
|
if styleNode['tab-spacing'] then
|
|
|
|
self:setTabSpacing(styleNode['tab-spacing'])
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:removeTab(tab)
|
2013-12-03 20:25:13 +01:00
|
|
|
local tabTables = {self.tabs, self.preTabs, self.postTabs}
|
|
|
|
local index = nil
|
|
|
|
local tabTable = nil
|
|
|
|
for i = 1, #tabTables do
|
|
|
|
index = table.find(tabTables[i], tab)
|
|
|
|
if index ~= nil then
|
|
|
|
tabTable = tabTables[i]
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if tabTable == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
if self.currentTab == tab then
|
|
|
|
self:selectPrevTab()
|
2013-12-03 20:25:13 +01:00
|
|
|
if #self.tabs == 1 then
|
|
|
|
self.currentTab = nil
|
|
|
|
end
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
2013-12-03 20:25:13 +01:00
|
|
|
table.remove(tabTable, index)
|
2013-01-21 22:36:53 +01:00
|
|
|
if tab.blinkEvent then
|
|
|
|
removeEvent(tab.blinkEvent)
|
|
|
|
end
|
|
|
|
tab:destroy()
|
2013-12-03 20:25:13 +01:00
|
|
|
updateTabs(self)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:getTab(text)
|
|
|
|
for k,tab in pairs(self.tabs) do
|
|
|
|
if tab:getText():lower() == text:lower() then
|
|
|
|
return tab
|
|
|
|
end
|
|
|
|
end
|
2013-12-03 20:25:13 +01:00
|
|
|
for k,tab in pairs(self.preTabs) do
|
|
|
|
if tab:getText():lower() == text:lower() then
|
|
|
|
return tab
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for k,tab in pairs(self.postTabs) do
|
|
|
|
if tab:getText():lower() == text:lower() then
|
|
|
|
return tab
|
|
|
|
end
|
|
|
|
end
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:selectTab(tab)
|
|
|
|
if self.currentTab == tab then return end
|
|
|
|
if self.contentWidget then
|
|
|
|
local selectedWidget = self.contentWidget:getLastChild()
|
|
|
|
if selectedWidget and selectedWidget.isTab then
|
|
|
|
self.contentWidget:removeChild(selectedWidget)
|
|
|
|
end
|
|
|
|
self.contentWidget:addChild(tab.tabPanel)
|
|
|
|
tab.tabPanel:fill('parent')
|
|
|
|
end
|
|
|
|
|
|
|
|
if self.currentTab then
|
|
|
|
self.currentTab:setChecked(false)
|
|
|
|
end
|
|
|
|
signalcall(self.onTabChange, self, tab)
|
|
|
|
self.currentTab = tab
|
|
|
|
tab:setChecked(true)
|
|
|
|
tab:setOn(false)
|
|
|
|
tab.blinking = false
|
|
|
|
|
|
|
|
local parent = tab:getParent()
|
|
|
|
parent:focusChild(tab, MouseFocusReason)
|
2013-12-03 20:25:13 +01:00
|
|
|
updateNavigation(self)
|
2013-01-21 22:36:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:selectNextTab()
|
2013-12-03 20:25:13 +01:00
|
|
|
if self.currentTab == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local index = table.find(self.tabs, self.currentTab)
|
2013-12-03 20:25:13 +01:00
|
|
|
if index == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local newIndex = index + 1
|
|
|
|
if newIndex > #self.tabs then
|
|
|
|
if #self.postTabs > 0 then
|
|
|
|
local widget = showPostTab(self)
|
|
|
|
self:selectTab(widget)
|
2014-01-15 02:32:02 +01:00
|
|
|
else
|
2014-01-15 04:56:42 +01:00
|
|
|
if #self.preTabs > 0 then
|
|
|
|
for i = 1, #self.preTabs do
|
|
|
|
showPreTab(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-15 02:32:02 +01:00
|
|
|
self:selectTab(self.tabs[1])
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
2014-01-15 04:56:42 +01:00
|
|
|
updateTabs(self)
|
2013-12-03 20:25:13 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local nextTab = self.tabs[newIndex]
|
|
|
|
if not nextTab then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
self:selectTab(nextTab)
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:selectPrevTab()
|
2013-12-03 20:25:13 +01:00
|
|
|
if self.currentTab == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
local index = table.find(self.tabs, self.currentTab)
|
2013-12-03 20:25:13 +01:00
|
|
|
if index == nil then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local newIndex = index - 1
|
|
|
|
if newIndex <= 0 then
|
|
|
|
if #self.preTabs > 0 then
|
|
|
|
local widget = showPreTab(self)
|
|
|
|
self:selectTab(widget)
|
2014-01-15 02:32:02 +01:00
|
|
|
else
|
2014-01-15 04:56:42 +01:00
|
|
|
if #self.postTabs > 0 then
|
|
|
|
for i = 1, #self.postTabs do
|
|
|
|
showPostTab(self)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-15 02:32:02 +01:00
|
|
|
self:selectTab(self.tabs[#self.tabs])
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
2014-01-15 04:56:42 +01:00
|
|
|
updateTabs(self)
|
2013-12-03 20:25:13 +01:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local prevTab = self.tabs[newIndex]
|
|
|
|
if not prevTab then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-21 22:36:53 +01:00
|
|
|
self:selectTab(prevTab)
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:blinkTab(tab)
|
2013-02-27 20:24:32 +01:00
|
|
|
if tab:isChecked() then return end
|
2013-01-21 22:36:53 +01:00
|
|
|
tab.blinking = true
|
|
|
|
tabBlink(tab)
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:getTabPanel(tab)
|
|
|
|
return tab.tabPanel
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:getCurrentTabPanel()
|
|
|
|
if self.currentTab then
|
|
|
|
return self.currentTab.tabPanel
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIMoveableTabBar:getCurrentTab()
|
|
|
|
return self.currentTab
|
|
|
|
end
|
2013-12-03 20:25:13 +01:00
|
|
|
|
|
|
|
function UIMoveableTabBar:setNavigation(prevButton, nextButton)
|
2015-01-27 21:14:07 +01:00
|
|
|
self.prevNavigation = prevButton
|
|
|
|
self.nextNavigation = nextButton
|
2013-12-03 20:25:13 +01:00
|
|
|
|
2015-01-27 21:14:07 +01:00
|
|
|
if self.prevNavigation then
|
|
|
|
self.prevNavigation.onClick = function() self:selectPrevTab() end
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
2015-01-27 21:14:07 +01:00
|
|
|
if self.nextNavigation then
|
|
|
|
self.nextNavigation.onClick = function() self:selectNextTab() end
|
2013-12-03 20:25:13 +01:00
|
|
|
end
|
|
|
|
updateNavigation(self)
|
2014-01-15 02:32:02 +01:00
|
|
|
end
|