fork/m-overlay

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

BkacjiosBugfixes + Dark Mode skina8034e9

v2.1.6
1.7 KiB72 linesraw
1local PANEL = class.create("Panel", "BasePanel")
2
3PANEL:ACCESSOR("Enabled", "m_bEnabled", true)
4PANEL:ACCESSOR("BorderColor", "m_cBorderColor", color(165, 165, 165))
5PANEL:ACCESSOR({"BGColor","BackgroundColor"}, "m_cBackgroundColor", color(200, 200, 200))
6PANEL:ACCESSOR("TooltipTitle", "m_strTooltipTitle")
7PANEL:ACCESSOR("TooltipBody", "m_strTooltipBody")
8PANEL:ACCESSOR("TooltipParent", "m_pTooltipParent")
9PANEL:ACCESSOR("DrawPanel", "m_bDrawPanel", true)
10
11function PANEL:Panel()
12	self:super() -- Initialize our baseclass
13end
14
15function PANEL:Skin()
16	gui.skinHook("Init", "Panel", self)
17end
18
19function PANEL:PrePaint(w, h)
20	if self.m_bDrawPanel then
21		gui.skinHook("Paint", "Panel", self, w, h)
22	end
23end
24
25function PANEL:Paint(w, h)
26	-- Override
27end
28
29function PANEL:PaintOverlay(w, h)
30	if self.m_bDrawPanel then
31		gui.skinHook("PaintOverlay", "Panel", self, w, h)
32	end
33end
34
35function PANEL:PostPaint(w, h)
36	if not self:IsEnabled() then
37		graphics.setColor(color(0, 0, 0, 100))
38		graphics.rectangle("fill", 0, 0, w, h)
39	end
40end
41
42function PANEL:OnQueryTooltip()
43	if self.m_strTooltipTitle and self.m_strTooltipBody then
44		gui.setTooltip(self.m_pTooltipParent or self, self.m_strTooltipTitle, self.m_strTooltipBody)
45		return true
46	end
47end
48
49function PANEL:IsPressed()
50	return self.m_bPressed and self:IsHovered()
51end
52
53function PANEL:OnMousePressed(x, y, but)
54	if not self.m_bEnabled or but ~= 1 then return end
55	self.m_bPressed = true
56	return true
57end
58
59function PANEL:OnMouseReleased(x, y, but)
60	if not self.m_bEnabled or but ~= 1 then return end
61	if self.m_bPressed then
62		self.m_bPressed = false
63		if self:IsHovered() then
64			self:OnClick()
65			return true
66		end
67	end
68end
69
70function PANEL:OnClick()
71	-- Override
72end