fork/m-overlay

git clone https://git.julia.blue/fork/m-overlay

BkacjiosBugfixes + Dark Mode skina8034e9

v2.1.6
1.0 KiB53 linesraw
1local PANEL = class.create("ContextMenu", "Panel")
2
3function PANEL:ContextMenu()
4	self:super() -- Initialize our baseclass
5
6	self.m_tEntries = {}
7
8	self:DockPadding(0,0,0,0)
9
10	self:SetWidth(128 + 32)
11	self:MakePopup()
12end
13
14function PANEL:OnFocusChanged(b)
15	-- Remove on focus lost
16	if not b then self:Remove() end
17end
18
19function PANEL:PerformLayout()
20	self:SizeToChildren(false, true)
21end
22
23function PANEL:AddSeperator(height)
24	local entry = self:Add("Panel")
25	entry:SetHeight(height or 4)
26	entry:SetBGColor(color_blank)
27	entry:SetBorderColor(color_blank)
28	entry:DockMargin(0,0,0,0)
29	entry:Dock(DOCK_TOP)
30end
31
32function PANEL:AddEntry(name, callback)
33	local entry = self:Add("Button")
34	entry:SetText(name)
35	entry:SetBGColor(color_blank)
36	entry:SetBorderColor(color_blank)
37	entry:DockMargin(0,0,0,0)
38	entry:Dock(DOCK_TOP)
39
40	self.m_tEntries[name] = callback
41
42	entry.OnClick = function(this)
43		self:OnEntryClicked(name, this)
44		if self.m_tEntries[name] then
45			self.m_tEntries[name](panel)
46		end
47	end
48
49	return entry
50end
51
52function PANEL:OnEntryClicked(name, panel)
53end