forked from Be1zebub/Small-GLua-Things
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocking-power.lua
40 lines (33 loc) · 1.13 KB
/
docking-power.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
-- https://github.com/Be1zebub/Small-GLua-Things/blob/master/example/docking-power.lua
-- Panel:Dock usage example
-- this script was created as a quick demo of Docking, so more ppl can learn it.
-- docking system is great, without it vgui literally has no right to live - vgui is terrible, but docking saves it a little bit.
if IsValid(_DockingPower) then
_testDock:Remove()
end
_DockingPower = vgui.Create("DPanel")
_DockingPower:SetSize(512, 512)
_DockingPower:Center()
local function PaintColor(me, w, h)
surface.SetDrawColor(me.backgroundColor)
surface.DrawRect(0, 0, w, h)
end
local left = _DockingPower:Add("EditablePanel")
left:SetWide(256 - 16)
left:Dock(LEFT)
left:DockMargin(0, 0, 32, 0)
left.backgroundColor = Color(255, 52, 94)
left.Paint = PaintColor
left.Think = function(me)
me:SetWide(256 + 64 * math.sin(SysTime() * 2))
end
local top = _DockingPower:Add("EditablePanel")
top:SetTall(256 - 16)
top:Dock(TOP)
top.backgroundColor = Color(52, 255, 94)
top.Paint = PaintColor
local fill = _DockingPower:Add("EditablePanel")
fill:Dock(FILL)
fill:DockMargin(0, 32, 0, 0)
fill.backgroundColor = Color(52, 94, 255)
fill.Paint = PaintColor