fork/m-overlay

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

blackops7799More config file work (exporting/importing/defaults) Properly cleanup orphaned panels and "removed" panels SetZPos will now reorder the parents child panels MakePopup will take the place of the highest Z positioned panel29daa42

GUI
3.9 KiB150 linesraw
1local SKIN = {}
2
3SKIN.Background = color(240, 240, 240)
4
5SKIN.PanelBorder = color(165, 165, 165)
6SKIN.PanelFocused = color(0, 162, 232)
7
8SKIN.FrameBorder = color(100, 100, 100)
9SKIN.FrameControlBar = color(225, 225, 225)
10SKIN.FrameFocusedControlBar = color(0, 162, 232)
11
12SKIN.ButtonBackground = color(215, 215, 215)
13SKIN.ButtonDisabled = color(100, 100, 100, 100)
14SKIN.ButtonPressed = color(153, 217, 234)
15SKIN.ButtonHover = color(220, 242, 248)
16
17SKIN.ButtonClosePressed = color(243, 105, 113)
18SKIN.ButtonCloseHover = color(248, 167, 171)
19
20SKIN.TextEntryBackground = color(255, 255, 255)
21SKIN.TextEntryFocused = color(0, 162, 232)
22
23SKIN.ScrollBarGrip = color(205, 205, 205, 255)
24SKIN.ScrollBarGripPressed = color(96, 96, 96, 255)
25SKIN.ScrollBarGripHover = color(166, 166, 166, 255)
26
27function SKIN:InitPanel(panel)
28	panel:SetBGColor(self.Background)
29	panel:SetBorderColor(self.PanelBorder)
30end
31
32function SKIN:PaintPanel(panel, w, h)
33	graphics.setColor(panel:GetBGColor())
34	graphics.rectangle("fill", 0, 0, w, h)
35
36	graphics.setLineStyle("rough")
37	graphics.setLineWidth(1)
38	
39	graphics.setColor(panel:GetBorderColor())
40	graphics.innerRectangle(0, 0, w, h)
41end
42
43function SKIN:PaintFocusPanel(panel, w, h)
44	graphics.setColor(panel:GetBGColor())
45	graphics.rectangle("fill", 0, 0, w, h)
46
47	graphics.setLineStyle("rough")
48	graphics.setLineWidth(1)
49
50	if panel:HasFocus() then
51		graphics.setColor(self.PanelFocused)
52		graphics.innerRectangle(0, 0, w, h)
53	else
54		graphics.setColor(panel:GetBorderColor())
55		graphics.innerRectangle(0, 0, w, h)
56	end
57end
58
59function SKIN:PaintScrollBarButtonUp(panel, w, h)
60	self:PaintButton(panel,w,h)
61	graphics.setColor(150, 150, 150, 255)
62	graphics.polygon('fill', 4, 12, 8, 4, 12, 12)
63end
64
65function SKIN:PaintScrollBarButtonDown(panel, w, h)
66	self:PaintButton(panel,w,h)
67	graphics.setColor(150, 150, 150, 255)
68	graphics.polygon('fill', 4, 4, 12, 4, 8, 12)
69end
70
71function SKIN:PaintScrollBarGrip(panel, w, h)
72	local color = self.ScrollBarGrip
73	if panel:IsPressed() then
74		color = self.ScrollBarGripPressed
75	elseif panel:IsHovered() then
76		color = self.ScrollBarGripHover
77	end
78	graphics.setColor(color)
79	graphics.rectangle("fill", 1, 0, w-2, h)
80end
81
82function SKIN:InitButton(panel)
83	panel:SetBorderColor(self.PanelBorder)
84	panel:SetPressedColor(self.ButtonPressed)
85	panel:SetHoveredColor(self.ButtonHover)
86end
87
88function SKIN:InitExitButton(panel)
89	panel:SetPressedColor(self.ButtonClosePressed)
90	panel:SetHoveredColor(self.ButtonCloseHover)
91end
92
93function SKIN:PaintButton(panel, w, h)
94	local color = self.ButtonBackground
95
96	if not panel:IsEnabled() then
97		color = self.ButtonDisabled
98	elseif panel:IsPressed() then
99		color = panel:GetPressedColor() or self.ButtonPressed
100	elseif panel:IsHovered() then
101		color = panel:GetHoveredColor() or self.ButtonHover
102	end
103
104	graphics.setColor(color)
105	graphics.rectangle("fill", 0, 0, w, h)
106
107	graphics.setLineStyle("rough")
108	graphics.setLineWidth(1)
109	
110	--[[graphics.setColor(255, 255, 255, 255)
111	graphics.innerRectangle(0, 1, w, h - 2)]]
112
113	graphics.setColor(panel:GetBorderColor())
114	graphics.innerRectangle(0, 0, w, h)
115end
116
117function SKIN:PaintFrame(panel, w, h)
118	graphics.setColor(unpackcolor(self.Background))
119	graphics.rectangle("fill", 0, 0, w, h)
120	
121	graphics.setColor(unpackcolor(panel:HasFocus(true) and self.FrameFocusedControlBar or self.FrameControlBar))
122	graphics.rectangle("fill", 0, 0, w, 32)
123
124	graphics.setLineStyle("rough")
125	graphics.setLineWidth(1)
126	
127	--[[graphics.setColor(255, 255, 255, 255)
128	graphics.innerRectangle(0, 1, w, h - 2)]]
129	
130	graphics.setColor(panel.m_cBordercolor or self.FrameBorder)
131	graphics.innerRectangle(0, 0, w, h)
132end
133
134function SKIN:PaintTextEntry(panel, w, h)
135	graphics.setColor(self.TextEntryBackground)
136	graphics.rectangle("fill", 0, 0, w, h)
137
138	graphics.setLineStyle("rough")
139	graphics.setLineWidth(1)
140
141	if panel:HasFocus() then
142		graphics.setColor(self.TextEntryFocused)
143		graphics.innerRectangle(0, 0, w, h)
144	else
145		graphics.setColor(panel:GetBorderColor())
146		graphics.innerRectangle(0, 0, w, h)
147	end
148end
149
150gui.registerSkin("default", SKIN)