summaryrefslogtreecommitdiff
path: root/gamemode/vgui/vgui_panelbase.lua
blob: b7a4d197ba1408238df89bbc1bae54e1911f84e0 (plain)
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
local PANEL = {}

function PANEL:Init()

	//self:SetTitle( "" )
	self:ChooseParent()
	
end

function PANEL:ChooseParent()
	
end

function PANEL:OnMousePressed( mc )

	self.Dragging = { gui.MouseX() - self.x, gui.MouseY() - self.y }
	self:MouseCapture( true )

end

function PANEL:Think()

	if self.Dragging then
		
		local x = gui.MouseX() - self.Dragging[1]
        local y = gui.MouseY() - self.Dragging[2]
		
		x = math.Clamp( x, 0, ScrW() - self:GetWide() )
		y = math.Clamp( y, 0, ScrH() - self:GetTall() )
		
		self:SetPos( x, y )
	
	end

end

function PANEL:GetPadding()
	return 1
end

function PANEL:GetDefaultTextColor()
	return Color( 255, 255, 255, 255 )
end

function PANEL:GetTextLabelColor()
	return Color( 255, 255, 0 )
end

function PANEL:GetTextLabelFont()
	return "PanelText"
end

function PANEL:SetTitle( title )

	self.Title = title

end

function PANEL:GetTitle()

	return self.Title

end

function PANEL:Paint()

	draw.RoundedBox( 4, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) )
	draw.RoundedBox( 4, 1, 1, self:GetWide() - 2, self:GetTall() - 2, Color( 150, 150, 150, 150 ) )
	
	if self.Title then
	
		draw.SimpleText( self.Title, "ItemDisplayFont", 5, 5, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
	
	end

end

derma.DefineControl( "PanelBase", "A HUD Base Element", PANEL, "DPanel" )