-
Notifications
You must be signed in to change notification settings - Fork 841
Expand file tree
/
Copy pathdcolumnsheet.lua
More file actions
85 lines (59 loc) · 1.94 KB
/
dcolumnsheet.lua
File metadata and controls
85 lines (59 loc) · 1.94 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
local PANEL = {}
AccessorFunc( PANEL, "ActiveButton", "ActiveButton" )
function PANEL:Init()
self.Navigation = vgui.Create( "DScrollPanel", self )
self.Navigation:Dock( LEFT )
self.Navigation:SetWidth( 100 )
self.Navigation:DockMargin( 10, 10, 10, 0 )
self.Content = vgui.Create( "Panel", self )
self.Content:Dock( FILL )
self.Items = {}
end
function PANEL:UseButtonOnlyStyle()
self.ButtonOnly = true
end
function PANEL:AddSheet( label, panel, material )
if ( !IsValid( panel ) ) then return end
local Sheet = {}
if ( self.ButtonOnly ) then
Sheet.Button = vgui.Create( "DImageButton", self.Navigation )
else
Sheet.Button = vgui.Create( "DButton", self.Navigation )
end
Sheet.Button:SetImage( material )
Sheet.Button.Target = panel
Sheet.Button:Dock( TOP )
Sheet.Button:SetText( label )
Sheet.Button:DockMargin( 0, 1, 0, 0 )
Sheet.Button.DoClick = function()
self:SetActiveButton( Sheet.Button )
end
Sheet.Panel = panel
Sheet.Panel:SetParent( self.Content )
Sheet.Panel:SetVisible( false )
if ( self.ButtonOnly ) then
Sheet.Button:SizeToContents()
--Sheet.Button:SetColor( Color( 150, 150, 150, 100 ) )
end
table.insert( self.Items, Sheet )
if ( !IsValid( self.ActiveButton ) ) then
self:SetActiveButton( Sheet.Button )
end
return Sheet
end
function PANEL:SetActiveButton( active )
if ( self.ActiveButton == active ) then return end
if ( self.ActiveButton and self.ActiveButton.Target ) then
self.ActiveButton.Target:SetVisible( false )
self.ActiveButton:SetSelected( false )
self.ActiveButton:SetToggle( false )
--self.ActiveButton:SetColor( Color( 150, 150, 150, 100 ) )
end
self.ActiveButton = active
active.Target:SetVisible( true )
active:SetSelected( true )
active:SetToggle( true )
--active:SetColor( color_white )
self.Content:InvalidateLayout()
end
derma.DefineControl( "DColumnSheet", "", PANEL, "Panel" )