fork/m-overlay

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

BkacjiosStylize the Tabs on a TabPanel.be5d99b

settings-overhaul
5.8 KiB220 linesraw
1local SKIN = gui.newSkin("default")
2
3SKIN.Background = color(255, 255, 255)
4
5SKIN.PanelBackground = color(240, 240, 240)
6SKIN.PanelBorder = color(165, 165, 165)
7SKIN.PanelFocused = color(0, 162, 232)
8
9SKIN.FrameBorder = color(100, 100, 100)
10SKIN.FrameControlBar = color(225, 225, 225)
11SKIN.FrameFocusedControlBar = color(0, 162, 232)
12
13SKIN.ButtonBackground = color(215, 215, 215)
14SKIN.ButtonDisabled = color(100, 100, 100, 100)
15SKIN.ButtonPressed = color(153, 217, 234)
16SKIN.ButtonHover = color(220, 242, 248)
17
18SKIN.ButtonClosePressed = color(243, 105, 113)
19SKIN.ButtonCloseHover = color(248, 167, 171)
20
21SKIN.TextEntryBackground = color(255, 255, 255)
22SKIN.TextEntryFocused = color(0, 162, 232)
23
24SKIN.ScrollBarGrip = color(205, 205, 205, 255)
25SKIN.ScrollBarGripPressed = color(96, 96, 96, 255)
26SKIN.ScrollBarGripHover = color(166, 166, 166, 255)
27
28SKIN.CheckboxBorder = color(100, 100, 100)
29SKIN.CheckboxOff = color(200, 200, 200)
30SKIN.CheckboxOn = color(0, 162, 232)
31
32SKIN.TabActiveColor = color(0, 0, 0, 75)
33
34SKIN.CheckImage = graphics.newImage("textures/gui/checkmark.png")
35
36function SKIN:InitPanel(panel)
37	panel:SetBGColor(self.PanelBackground)
38	panel:SetBorderColor(self.PanelBorder)
39end
40
41function SKIN:PaintPanel(panel, w, h)
42	graphics.setColor(panel:GetBGColor())
43	graphics.rectangle("fill", 0, 0, w, h)
44end
45
46function SKIN:PaintOverlayPanel(panel, w, h)
47	graphics.setLineStyle("rough")
48	graphics.setLineWidth(1)
49	
50	graphics.setColor(panel:GetBorderColor())
51	graphics.innerRectangle(0, 0, w, h)
52end
53
54function SKIN:PaintSlider(panel, w, h)
55	graphics.setColor(self.Background)
56	graphics.rectangle("fill", 0, 0, w, h)
57
58	graphics.setLineStyle("rough")
59	graphics.setLineWidth(1)
60	
61	graphics.setColor(panel:GetBorderColor())
62	graphics.innerRectangle(0, 0, w, h)
63end
64
65function SKIN:PaintOverlayFocusPanel(panel, w, h)
66	graphics.setLineStyle("rough")
67	graphics.setLineWidth(1)
68
69	if panel:IsEnabled() and panel:HasFocus() then
70		graphics.setColor(self.PanelFocused)
71		graphics.innerRectangle(0, 0, w, h)
72	else
73		graphics.setColor(panel:GetBorderColor())
74		graphics.innerRectangle(0, 0, w, h)
75	end
76end
77
78function SKIN:PaintScrollBarButtonUp(panel, w, h)
79	self:PaintButton(panel,w,h)
80	graphics.setColor(150, 150, 150, 255)
81	graphics.polygon('fill', 4, 12, 8, 4, 12, 12)
82end
83
84function SKIN:PaintScrollBarButtonDown(panel, w, h)
85	self:PaintButton(panel,w,h)
86	graphics.setColor(150, 150, 150, 255)
87	graphics.polygon('fill', 4, 4, 12, 4, 8, 12)
88end
89
90function SKIN:PaintScrollBarGrip(panel, w, h)
91	local color = self.ScrollBarGrip
92	if panel:IsPressed() then
93		color = self.ScrollBarGripPressed
94	elseif panel:IsHovered() then
95		color = self.ScrollBarGripHover
96	end
97	graphics.setColor(color)
98	graphics.rectangle("fill", 1, 0, w-2, h)
99end
100
101function SKIN:InitButton(panel)
102	panel:SetBGColor(self.ButtonBackground)
103	panel:SetBorderColor(self.PanelBorder)
104	panel:SetPressedColor(self.ButtonPressed)
105	panel:SetHoveredColor(self.ButtonHover)
106end
107
108function SKIN:InitExitButton(panel)
109	panel:SetPressedColor(self.ButtonClosePressed)
110	panel:SetHoveredColor(self.ButtonCloseHover)
111end
112
113function SKIN:PaintButton(panel, w, h)
114	local color = self.ButtonBackground
115
116	if panel:IsPressed() then
117		color = panel:GetPressedColor() or self.ButtonPressed
118	elseif panel:IsHovered() then
119		color = panel:GetHoveredColor() or self.ButtonHover
120	end
121
122	graphics.setColor(color)
123	graphics.rectangle("fill", 0, 0, w, h)
124
125	graphics.setLineStyle("rough")
126	graphics.setLineWidth(1)
127
128	graphics.setColor(panel:GetBorderColor() or self.PanelBorder)
129	graphics.innerRectangle(0, 0, w, h)
130end
131
132function SKIN:PaintTab(panel, w, h)
133	local color = self.ButtonBackground
134
135	if panel:IsPressed() then
136		color = panel:GetPressedColor() or self.ButtonPressed
137	elseif panel:IsHovered() then
138		color = panel:GetHoveredColor() or self.ButtonHover
139	end
140
141	graphics.setColor(color)
142	graphics.roundRect(0, 0, w, h+8, 8)
143
144	if panel:IsActive() then
145		graphics.setColor(panel:GetActiveColor() or self.TabActiveColor)
146		graphics.roundRect(0, 0, w, h+8, 8)
147	end
148end
149
150function SKIN:PaintOverlayButton(panel, w, h)
151	if not panel:IsEnabled() then
152		graphics.setColor(self.ButtonDisabled)
153		graphics.rectangle("fill", 0, 0, w, h)
154	end
155end
156
157function SKIN:PaintFrame(panel, w, h)
158	graphics.setColor(self.Background)
159	graphics.rectangle("fill", 0, 0, w, h)
160	
161	graphics.setColor(panel:HasFocus(true) and self.FrameFocusedControlBar or self.FrameControlBar)
162	graphics.rectangle("fill", 0, 0, w, 32)
163
164	graphics.setLineStyle("rough")
165	graphics.setLineWidth(1)
166	
167	--[[graphics.setColor(255, 255, 255, 255)
168	graphics.innerRectangle(0, 1, w, h - 2)]]
169	
170	graphics.setColor(panel.m_cBordercolor or self.FrameBorder)
171	graphics.innerRectangle(0, 0, w, h)
172end
173
174function SKIN:PaintTextEntry(panel, w, h)
175	graphics.setColor(self.TextEntryBackground)
176	graphics.rectangle("fill", 0, 0, w, h)
177
178	graphics.setLineStyle("rough")
179	graphics.setLineWidth(1)
180
181	if panel:HasFocus() then
182		graphics.setColor(self.TextEntryFocused)
183		graphics.innerRectangle(0, 0, w, h)
184	else
185		graphics.setColor(panel:GetBorderColor())
186		graphics.innerRectangle(0, 0, w, h)
187	end
188end
189
190function SKIN:PaintCheckbox(panel, w, h)
191	graphics.setColor(panel:IsToggled() and self.CheckboxOn or self.CheckboxOff)
192	graphics.rectangle("fill", 4, 4, h-8, h-8)
193
194	if panel:IsToggled() then
195		graphics.setColor(255, 255, 255, 255)
196		graphics.easyDraw(self.CheckImage, 4, 4, 0, h-8, h-8)
197	end
198	
199	graphics.setLineStyle("rough")
200	graphics.setLineWidth(1)
201	
202	graphics.setColor(self.CheckboxBorder)
203	graphics.rectangle("line", 4, 4, h-8, h-8)
204end
205
206function SKIN:PaintRadio(panel, w, h)
207	graphics.setColor(panel:IsToggled() and self.CheckboxOn or self.CheckboxOff)
208	graphics.circle("fill", 12, 12, h/2-8, 32)
209
210	graphics.setLineStyle("smooth")
211	graphics.setLineWidth(1)
212
213	graphics.setColor(self.CheckboxBorder)
214	graphics.circle("line", 12, 12, h/2-8, 32)
215end
216
217function SKIN:InitHorizontalSelect(panel)
218	panel:SetBGColor(self.PanelBackground)
219	panel:SetBorderColor(self.PanelBorder)
220end