-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathframetabgroup.lua
63 lines (52 loc) · 1.59 KB
/
frametabgroup.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--=========== Copyright © 2019, Planimeter, All rights reserved. ===========--
--
-- Purpose: Frame Tab Group class
--
--==========================================================================--
class "gui.frametabgroup" ( "gui.radiobuttongroup" )
local frametabgroup = gui.frametabgroup
function frametabgroup:frametabgroup( parent, name )
gui.radiobuttongroup.radiobuttongroup( self, parent, name )
self.height = 61
self:setScheme( "Default" )
end
function frametabgroup:addTab( tabName, default )
local frametab = gui.frametab( self, tabName .. " Frame Tab", tabName )
self:addItem( frametab )
local numItems = #self:getItems()
frametab:setValue( numItems )
if ( default or numItems == 1 ) then
frametab:setDefault( true )
end
end
function frametabgroup:addItem( tab )
gui.radiobuttongroup.addItem( self, tab )
self:invalidateLayout()
end
function frametabgroup:draw()
love.graphics.setColor( self:getScheme( "frametab.borderColor" ) )
love.graphics.setLineStyle( "rough" )
local lineWidth = 1
love.graphics.setLineWidth( lineWidth )
love.graphics.line(
lineWidth / 2, 0, -- Top-left
lineWidth / 2, self:getHeight() -- Bottom-left
)
gui.panel.draw( self )
end
function frametabgroup:invalidateLayout()
local tabs = self:getItems()
if ( tabs ) then
local x = 1
for _, tab in ipairs( tabs ) do
tab:setX( x )
x = x + tab:getWidth()
end
self:setWidth( x )
end
gui.panel.invalidateLayout( self )
end
function frametabgroup:onValueChanged( oldValue, newValue )
local tabPanels = self:getParent():getTabPanels()
tabPanels:setSelectedChild( newValue )
end