fork/m-overlay

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

BkacjiosLayout the rest of all settings pads.7d53a4b

settings-overhaul
21.9 KiB956 linesraw
1local PANEL = class.create("BasePanel")
2
3require("extensions.table")
4
5function PANEL:BasePanel()
6	self.m_tChildren = {}
7	self.m_tOrphans = {}
8	self.m_iWorldPosX = 0
9	self.m_iWorldPosY = 0
10	self.m_fScaleX = 1
11	self.m_fScaleY = 1
12	self.m_iPosX = 0
13	self.m_iPosY = 0
14	self.m_iWidth = 42
15	self.m_iHeight = 24
16	self.m_bHovered = false
17	self.m_pParent = nil
18	self.m_iZPos = 0
19	self.m_bScissorEnabled = true
20	self.m_bValidated = false
21	self.m_bVisible = true
22	self.m_bFocusable = true
23	self.m_bOrphaned = false
24	self.m_bDeleted = false
25	self.m_iDock = DOCK_NONE
26	self.m_iCenter = CENTER_NONE
27	self.m_tDockMargins = { left = 2, top = 2, right = 2, bottom = 2 }
28	self.m_tDockPadding = { left = 2, top = 2, right = 2, bottom = 2 }
29end
30
31function PANEL:GetClassName()
32	return self.__classname
33end
34
35function PANEL:__tostring()
36	return ("Panel[%q]"):format(self.__classname)
37end
38
39function PANEL:GetConfig()
40	local w, h = self:GetPixelSize()
41	local sx, sy = self:GetScale()
42
43	local config = {
44		classname = self:GetClassName(),
45		pos = { x = self:GetX(), y = self:GetY(), z = self:GetZPos() },
46		size = { width = w, height = h },
47		scale = { x = sx, y = sy },
48		visible = self:IsVisible(),
49		accessors = self.__accessors,
50	}
51
52	if self.m_iDock ~= 0 then
53		config.dock = {
54			mode = self.m_iDock,
55			margins = self.m_tDockMargins,
56			padding = self.m_tDockPadding,
57		}
58	end
59
60	return config
61end
62
63function PANEL:SetVisible(b)
64	self.m_bVisible = b
65end
66
67function PANEL:IsVisible()
68	return self.m_bVisible
69end
70
71function PANEL:SetFocusable(b)
72	self.m_bFocusable = b
73end
74
75function PANEL:IsFocusable()
76	return self.m_bFocusable
77end
78
79function PANEL:BringToFront()
80	local parent = self.m_pParent
81	if not parent then return end -- There's nothing for it to go in front of!
82	
83	local highest = nil
84
85	for _,child in ipairs(parent.m_tChildren) do
86		if not highest or child:GetZPos() > highest:GetZPos() then
87			highest = child
88		end
89	end
90
91	-- No panels or the highest is already ourself
92	if not highest or highest == self then return end
93
94	-- Get the position of the highest panel
95	local replace = highest:GetZPos()
96
97	-- Set the highest panel to our current position
98	highest:SetZPos(self:GetZPos())
99
100	-- Set our position to where the highest panel used to be
101	self:SetZPos(replace)
102end
103
104function PANEL:Dock(i)
105	self.m_iDock = i
106	self:InvalidateLayout()
107end
108
109function PANEL:GetDock()
110	return self.m_iDock
111end
112
113function PANEL:DockMargin(left, top, right, bottom)
114	self.m_tDockMargins.left = left
115	self.m_tDockMargins.top = top
116	self.m_tDockMargins.right = right
117	self.m_tDockMargins.bottom = bottom
118end
119
120function PANEL:GetDockMargin()
121	return self.m_tDockMargins
122end
123
124function PANEL:DockPadding(left, top, right, bottom)
125	self.m_tDockPadding.left = left
126	self.m_tDockPadding.top = top
127	self.m_tDockPadding.right = right
128	self.m_tDockPadding.bottom = bottom
129end
130
131function PANEL:GetDockPadding()
132	return self.m_tDockPadding
133end
134
135function PANEL:GetWidthPlusMargin()
136	if not self:IsVisible() then return 0 end
137	local margins = self:GetDockMargin()
138	return margins.left + margins.right + self:GetWidth()
139end
140
141function PANEL:GetHeightPlusMargin()
142	if not self:IsVisible() then return 0 end
143	local margins = self:GetDockMargin()
144	return margins.top + margins.bottom + self:GetHeight()
145end
146
147function PANEL:GetSizePlusMargin()
148	local w, h = self:GetWidthPlusMargin(), self:GetHeightPlusMargin()
149
150	--[[for _,child in ipairs(self.m_tChildren) do
151		if child:IsVisible() then
152			margins = child:GetDockMargin()
153			padding = child:GetDockPadding()
154			w = w + margins.left + margins.right + padding.left + padding.right
155			h = h + margins.top + margins.bottom + padding.top + padding.bottom
156		end
157	end]]
158
159	return w, h
160end
161
162--[[function PANEL:GetSpaceAround(panel)
163	local margins = panel:GetDockMargin()
164	local padding = panel:GetDockPadding()
165
166	local w = margins.left + margins.right + padding.left + padding.right
167	local h = margins.top + margins.bottom + padding.top + padding.bottom
168
169	for _,child in ipairs(self.m_tChildren) do
170		if child ~= panel and child:IsVisible() then
171			local margins = child:GetDockMargin()
172			local padding = child:GetDockPadding()
173			w = w + margins.left + margins.right + padding.left + padding.right + child:GetWidth()
174			h = h + margins.top + margins.bottom + padding.top + padding.bottom + child:GetHeight()
175		end
176	end
177
178	local width, height = self:GetSize()
179
180	return w, h
181end]]
182
183function PANEL:SetZPos(i)
184	self.m_iZPos = i
185	self:GetParent():ReorderChildren()
186end
187
188function PANEL:ReorderChildren()
189	table.sort(self.m_tChildren, function(a, b) return a.m_iZPos < b.m_iZPos end)
190end
191
192function PANEL:GetZPos()
193	return self.m_iZPos
194end
195
196function PANEL:CallAll(func, ...)
197	if not self:IsVisible() then return end
198	self[ func ](self, ...)
199	for _,child in ipairs(self.m_tChildren) do
200		child:CallAll(func, ...)
201	end
202end
203
204function PANEL:CallSelfAndParents(func, ...)
205	if not self:IsVisible() then return end
206	if self[ func ](self, ...) then return end
207	local parent = self.m_pParent
208	if not parent then return end
209	parent:CallSelfAndParents(func, ...)
210end
211
212function PANEL:Remove()
213	local parent = self:GetParent()
214	if parent then
215		parent:OnChildRemoved(self)
216	end
217
218	self.m_bDeleted = true
219	self:OnRemoved()
220
221	for zpos, child in ipairs(self.m_tChildren) do
222		child:Remove()
223	end
224end
225
226function PANEL:Clear()
227	for zpos, child in ipairs(self.m_tChildren) do
228		child:Remove()
229	end
230end
231
232function PANEL:InvalidateLayout()
233	self.m_bValidated = false
234	for _,child in ipairs(self.m_tChildren) do
235		child:InvalidateLayout()
236	end
237end
238
239function PANEL:InvalidateParent()
240	if not self.m_pParent then return end
241	self.m_pParent:InvalidateLayout()
242end
243
244function PANEL:MarkAsOrphan()
245	self.m_bOrphaned = true
246end
247
248function PANEL:CleanupOrphans()
249	for key, child in reversedipairs(self.m_tChildren) do
250		child:CleanupOrphans()
251		if child.m_bOrphaned then
252			table.remove(self.m_tChildren, key)
253		end
254	end
255end
256
257function PANEL:CleanupDeleted()
258	for key, child in reversedipairs(self.m_tChildren) do
259		child:CleanupDeleted()
260		if child.m_bDeleted then
261			self.m_tChildren[key] = nil
262			table.remove(self.m_tChildren, key)
263		end
264	end
265end
266
267function PANEL:SetParent(parent)
268	if self.m_pParent then
269		self:MarkAsOrphan()
270	end
271	self.m_pParent = parent
272	if parent then
273		table.insert(parent.m_tChildren, self)
274		parent:OnChildAdded(self)
275		self:SetZPos(#parent.m_tChildren)
276	end
277end
278
279function PANEL:HasParent()
280	return self:GetParent() ~= nil
281end
282
283function PANEL:GetParent()
284	return self.m_pParent
285end
286
287function PANEL:GetParents()
288	local parents = {}
289	
290	local parent = self:GetParent()
291	
292	while parent do
293		table.insert(parents, parent)
294		parent = parent:GetParent()
295	end
296	return parents
297end
298
299function PANEL:GetChildren()
300	return self.m_tChildren
301end
302
303function PANEL:GetFamily(family)
304	local family = family or {}
305	
306	local children = self.m_tChildren
307	family[self] = children
308	
309	for _,child in ipairs(children) do
310		child:GetFamily(family[self])
311	end
312	
313	return family
314end
315
316function PANEL:SizeToScreen()
317	self:SetSize(graphics.getPixelDimensions())
318end
319
320function PANEL:SizeToParent()
321	local parent = self:GetParent()
322
323	if parent then
324		self:SetSize(parent:GetSize())
325	end
326end
327
328function PANEL:SizeToChildren(doWidth, doHeight)
329	local all = doWidth == nil and doHeight == nil
330	local w,h = 0, 0
331	local padding = self:GetDockPadding()
332
333	w = padding.left + padding.right
334	h = padding.top + padding.bottom
335
336	local lw, lh = 0, 0
337
338	for _,child in ipairs(self.m_tChildren) do
339		if child:IsVisible() then
340			local x, y = child:GetPos()
341			local margin = child:GetDockMargin()
342			local cw, ch = child:GetPixelSize()
343
344			-- Position + size + margins = maximum bounds
345			cw = x + cw + margin.left + margin.right
346			ch = y + ch + margin.top + margin.bottom
347
348			-- Update the largest widths and heights
349			if cw > lw then lw = cw end
350			if ch > lh then lh = ch end
351		end
352	end
353	-- Don't use SetWidth/SetHeight so we don't invalidate the layout..
354	if all or doWidth then self.m_iWidth = w + lw end
355	if all or doHeight then self.m_iHeight = h + lh end
356end
357
358function PANEL:Add(class)
359	return gui.create(class, self)
360end
361
362function PANEL:SetScale(x, y)
363	y = y or x
364	self.m_fScaleX, self.m_fScaleY = x, y
365end
366
367function PANEL:GetScale()
368	return self.m_fScaleX, self.m_fScaleY
369end
370
371function PANEL:SetPos(x, y)
372	self.m_iPosX, self.m_iPosY = math.floor(x + 0.5), math.floor(y + 0.5)
373end
374
375function PANEL:GetPos()
376	return self.m_iPosX, self.m_iPosY
377end
378
379function PANEL:SetWorldPos(x, y)
380	self.m_iWorldPosX, self.m_iWorldPosY = x, y
381end
382
383function PANEL:GetWorldPos()
384	return self.m_iWorldPosX, self.m_iWorldPosY
385end
386
387function PANEL:LocalToWorld(x, y)
388	local sx, sy = self:GetPos()
389	x = x + sx
390	y = y + sy
391	
392	local parent = self:GetParent()
393	
394	while parent do
395		local px, py = parent:GetPos()
396		x = x + px
397		y = y + py
398		parent = parent:GetParent()
399	end
400	
401	return x, y
402end
403
404function PANEL:WorldToLocal(x, y)
405	local sx, sy = self:LocalToWorld(0, 0)
406	return x - sx, y - sy
407end
408
409function PANEL:SetX(x)
410	self.m_iPosX = math.floor(x + 0.5)
411end
412
413function PANEL:GetX()
414	return self.m_iPosX
415end
416
417function PANEL:SetY(y)
418	self.m_iPosY = math.floor(y + 0.5)
419end
420
421function PANEL:GetY()
422	return self.m_iPosY
423end
424
425function PANEL:SetSize(w, h)
426	self:SetWidth(w)
427	self:SetHeight(h)
428	self:OnResize(w, h)
429end
430
431function PANEL:GetSize()
432	return self:GetWidth(), self:GetHeight()
433end
434
435function PANEL:GetPixelSize()
436	return math.max(0, self.m_iWidth), math.max(0, self.m_iHeight)
437end
438
439function PANEL:SetWidth(w)
440	w = math.max(0, math.floor(w + 0.5))
441	if self.m_iWidth ~= w then
442		self.m_iWidth = w
443		self:InvalidateLayout()
444	end
445end
446
447function PANEL:GetActualWidth()
448	return math.max(0, self.m_iWidth)
449end
450
451function PANEL:GetWidth()
452	return self:GetActualWidth() * self.m_fScaleX
453end
454
455function PANEL:SetHeight(h)
456	h = math.max(0, math.floor(h + 0.5))
457	if self.m_iHeight ~= h then
458		self.m_iHeight = h
459		self:InvalidateLayout()
460	end
461end
462
463function PANEL:GetActualHeight()
464	return math.max(0, self.m_iHeight)
465end
466
467function PANEL:GetHeight()
468	return self:GetActualHeight() * self.m_fScaleY
469end
470
471function PANEL:IsWorldPointInside(x, y)
472	local px, py = self:LocalToWorld(0, 0)
473	return x > px and x < px + self:GetWidth() and y > py and y < py + self:GetHeight()
474end
475
476function PANEL:Render()
477	if not self:IsVisible() then return end
478
479	local x, y = self:LocalToWorld(0, 0)
480	local w, h = self:GetSize()
481	
482	local parent = self:GetParent()
483
484	-- Start the scissor position and size with our own values
485	local sx, sy = x, y
486	local sw, sh = w, h
487
488	while self.m_bScissorEnabled and parent do
489		-- If we have a parent, fit the scissor to fit inside their bounds
490		local px, py = parent:LocalToWorld(0, 0)
491		local pw, ph = parent:GetSize()
492
493		if sx < px then
494			sw = math.max(0, sw + sx - px)
495			sx = px
496		end
497		if sx + sw > px + pw then
498			sw = math.max(0, sw - ((sx + sw) - (px + pw)))
499			sx = math.min(sx, px + pw)
500		end
501		if sy < py then
502			sh = math.max(0, sh + sy - py)
503			sy = py
504		end
505		if sy + sh > py + ph then
506			sh = math.max(0, sh - ((sy + sh) - (py + ph)))
507			sy = math.min(sy, py + ph)
508		end
509
510		parent = parent:GetParent()
511	end
512
513	self:SetWorldPos(sx, sy)
514
515	-- Only bother to render if the panel is visible within the scissor
516	if math.max(x, sx) < math.min(x + w, sx + sw) and math.max(y, sy) < math.min(y + h, sy + sh) then
517		local rsx, rsy = self:GetScale()
518
519		if self.m_bScissorEnabled then
520			graphics.setScissor(sx, sy, sw, sh)
521		end
522
523		graphics.push("all") -- Push the current graphics state
524			graphics.translate(x, y) -- Translate so Paint has localized position values for drawing objects
525			graphics.scale(rsx, rsy)
526
527			local uw, uh = self:GetPixelSize()
528			graphics.setColor(255, 255, 255, 255)
529			self:PrePaint(uw, uh)
530			graphics.setColor(255, 255, 255, 255)
531			self:Paint(uw, uh)
532			graphics.setColor(255, 255, 255, 255)
533			self:PostPaint(uw, uh)
534
535			graphics.origin()
536
537			-- recently added panels are drawn last, thus, ontop of older panels
538			for _, child in ipairs(self.m_tChildren) do
539				child:Render()
540			end
541
542			graphics.translate(x, y) -- Translate so Paint has localized position values for drawing objects
543			graphics.scale(rsx, rsy)
544			graphics.setColor(255, 255, 255, 255)
545			self:PaintOverlay(self:GetPixelSize())
546
547			graphics.origin()
548		graphics.pop() -- Reset the graphics state to what it was
549
550		if self.m_bDebug then
551			-- Debug the scissor rect
552			graphics.setColor(255, 0, 0, 25)
553			graphics.rectangle("fill", sx, sy, sw, sh)
554		end
555		
556		graphics.setScissor()
557	end
558end
559
560function PANEL:DisableScissor()
561	self.m_bScissorEnabled = false
562end
563
564function PANEL:ValidateLayout()
565	if self:IsVisible() and not self.m_bValidated then
566		self.m_bValidated = true
567		self:CenterLayout()
568		self:DockLayout()
569		self:PerformLayout()
570	end
571
572	for _,child in ipairs(self.m_tChildren) do
573		child:ValidateLayout()
574	end
575end
576
577function PANEL:CenterLayout()
578	local parent = self:GetParent()
579
580	local w, h = self:GetSize()
581	local pw, ph = graphics.getPixelDimensions() -- Default to window size if no parent
582	if parent then
583		pw, ph = parent:GetSize()
584	end
585
586	local vertical = bit.band(self.m_iCenter, CENTER_VERTICAL) == CENTER_VERTICAL
587	local horizontal = bit.band(self.m_iCenter, CENTER_HORIZONTAL) == CENTER_HORIZONTAL
588
589	if vertical == true then
590		self:SetY((ph / 2) - (h / 2))
591	end
592	if horizontal == true then
593		self:SetX((pw / 2) - (w / 2))
594	end
595end
596
597function PANEL:Center(vertical, horizontal)
598	self:CenterVertical(vertical)
599	self:CenterHorizontal(horizontal)
600end
601
602function PANEL:CenterVertical(center)
603	self.m_iCenter = bit.bor(self.m_iCenter, CENTER_VERTICAL)
604	self:InvalidateLayout()
605end
606
607function PANEL:CenterHorizontal(center)
608	self.m_iCenter = bit.bor(self.m_iCenter, CENTER_HORIZONTAL)
609	self:InvalidateLayout()
610end
611
612function PANEL:DockLayout()
613	local x, y = 0, 0
614	local w, h = self:GetPixelSize()
615	
616	local padding = self.m_tDockPadding
617	
618	for _,child in ipairs(self.m_tChildren) do
619		local margin = child.m_tDockMargins
620	
621		local dx = x + padding.left
622		local dy = y + padding.top
623		local dw = w - (padding.left + padding.right)
624		local dh = h - (padding.top + padding.bottom)
625	
626		local dock = child.m_iDock
627		if dock ~= DOCK_NONE then
628			local cw, ch = child:GetPixelSize()
629			if(dock == DOCK_TOP) then
630				child:SetPos(dx + margin.left, dy + margin.top)
631				child:SetSize(dw - margin.left - margin.right, ch)
632				if child:IsVisible() then
633					local height = margin.top + margin.bottom + ch
634					y = y + height
635					h = h - height
636				end
637			elseif(dock == DOCK_LEFT) then
638				child:SetPos(dx + margin.left, dy + margin.top)
639				child:SetSize(cw, dh - margin.top - margin.bottom)
640				if child:IsVisible() then
641					local width = margin.left + margin.right + cw
642					x = x + width
643					w = w - width
644				end
645			elseif(dock == DOCK_RIGHT) then
646				child:SetPos((dx + dw) - cw - margin.right, dy + margin.top)
647				child:SetSize(cw, dh - margin.top - margin.bottom)
648				if child:IsVisible() then
649					local width = margin.left + margin.right + cw
650					w = w - width
651				end
652			elseif(dock == DOCK_BOTTOM) then
653				child:SetPos(dx + margin.left, (dy + dh) - ch - margin.bottom)
654				child:SetSize(dw - margin.left - margin.right, ch)
655				if child:IsVisible() then
656					h = h - (ch + margin.bottom + margin.top)
657				end
658			end
659		end
660	end
661	
662	for _,child in ipairs(self.m_tChildren) do
663		local dock = child.m_iDock
664		
665		if dock ~= DOCK_NONE then
666			local margin = child.m_tDockMargins
667		
668			local dx = x + padding.left
669			local dy = y + padding.top
670			local dw = w - (padding.left + padding.right)
671			local dh = h - (padding.top + padding.bottom)
672			
673			if(dock == DOCK_FILL) then
674				child:SetPos(dx + margin.left, dy + margin.top)
675				child:SetSize(dw - margin.left - margin.right, dh - margin.top - margin.bottom)
676			end
677		end
678	end
679end
680
681function PANEL:GiveFocus()
682	gui.setFocusedPanel(self)
683end
684
685function PANEL:MakePopup()
686	self:BringToFront()
687	self:GiveFocus()
688end
689
690function PANEL:HasFocus(checkchildren)
691	if checkchildren then
692		for _,child in ipairs(self.m_tChildren) do
693			if child:HasFocus(checkchildren) then
694				return true
695			end
696		end
697	end
698	return gui.getFocusedPanel() == self
699end
700
701function PANEL:IsHovered()
702	return gui.getHoveredPanel() == self
703end
704
705function PANEL:GetHoveredChild(x, y, ignore)
706	local panel = nil
707	for _,child in reversedipairs(self.m_tChildren) do
708		if child:IsVisible() and child:IsFocusable() and child:IsWorldPointInside(x, y) and ((ignore and child ~= ignore) or not ignore) then
709			panel = child:GetHoveredPanel(x, y)
710			break
711		end
712	end
713	return panel
714end
715
716function PANEL:GetHoveredPanel(x, y, ignore)
717	local panel = self
718	for _,child in reversedipairs(self.m_tChildren) do
719		if child:IsVisible() and child:IsFocusable() and child:IsWorldPointInside(x, y) and ((ignore and child ~= ignore) or not ignore) then
720			panel = child:GetHoveredPanel(x, y)
721			break
722		end
723	end
724	return panel
725end
726
727-- Tries to get find a position that can fit "other" somehwere around ourself without clipping outside our world
728function PANEL:SetPosAround(other, world)
729	world = world or gui.getWorldPanel()
730
731	local pw, ph = self:GetPixelSize()
732
733	local ox, oy = other:GetWorldPos()
734	local ow, oh = other:GetPixelSize()
735
736	local sx, sy = world:GetWorldPos()
737	local sw, sh = world:GetPixelSize()
738
739	local canFitAbove = (oy - sy) >= ph
740	local canFitBelow = ((sy + sh) - (oy + oh)) >= ph
741	local canFitLeft = (ox - sx) >= pw
742	local canFitRight = ((sx + sw) - (ox + ow)) >= pw
743
744	local finalX, finalY = 0, 0
745	local midX, midY = 0,0
746
747	if canFitAbove or canFitBelow then -- Prefer above or below
748		midX = ox + ow/2
749
750		-- set our x position centered against our other
751		finalX = midX - pw/2
752
753		-- fit our x position within our world
754		finalX = math.min(sx + sw - pw, math.max(sx, finalX))
755		if canFitAbove then
756			-- set y above
757			finalY = oy - ph
758			midY = oy
759		else
760			-- set y below
761			finalY = oy + oh
762			midY = finalY
763		end
764	elseif canFitLeft or canFitRight then -- Try left or right if above and below fails
765		midY = oy + oh/2
766
767		-- set our y position centered against our other
768		finalY = midY - ph/2
769
770		-- fit our y position within our world
771		finalY = math.min(sy + sh - ph, math.max(sy, finalY))
772		if canFitLeft then
773			-- set y left
774			finalX = ox - pw
775			midX = ox
776		else
777			-- set y right
778			finalX = ox + ow
779			midX = finalX
780		end
781	end
782
783	-- return our position as a local position within the given world
784	finalX, finalY = world:WorldToLocal(finalX, finalY)
785	self:SetPos(finalX, finalY)
786	return self:WorldToLocal(midX, midY)
787end
788
789-- PANEL OVERRIDE DEFAULTS
790
791function PANEL:PerformLayout()
792	-- Called when we are Validating the layout.
793	-- Good for manually positioning child panels.
794end
795
796function PANEL:PrePaint(w, h)
797end
798
799function PANEL:Paint(w, h)
800	-- Called every frame, when we are drawing the panel to the screen.
801	-- Used to draw custom things within the panel.
802end
803
804function PANEL:PostPaint(w, h)
805end
806
807function PANEL:PaintOverlay(w, h)
808end
809
810function PANEL:OnResize(w, h)
811	-- Called when the size of the panel has changed.
812	-- Good for manually positioning child panels, like in PerformLayout.
813end
814
815function PANEL:OnFocusChanged(b)
816	-- Called when the panels focus has either been gained or lost
817end
818
819function PANEL:OnHoveredChanged(b)
820	-- Called when the panels hovered state has either been gained or lost
821end
822
823function PANEL:OnKeyPressed(key, hex)
824	-- Called when the panel is focused, and a keyboard key has been pressed
825end
826
827function PANEL:OnKeyReleased(key)
828	-- Called when the panel is focused, and a keyboard key has been released
829end
830
831function PANEL:OnHoveredKeyPressed(key, hex)
832	-- Called when the panel is hovered over, and a keyboard key has been pressed
833end
834
835function PANEL:OnHoveredKeyReleased(key)
836	-- Called when the panel is hovered over, and a keyboard key has been released
837end
838
839function PANEL:OnTextInput(text)
840	-- Called when the panel is focused.
841	-- Good for a text input panel.
842end
843
844function PANEL:OnHoveredTextInput(text)
845	-- Called when the panel is hovered.
846	-- Good for a text input panel.
847end
848
849function PANEL:OnJoyPressed(joy, but)
850	-- Override
851end
852
853function PANEL:OnJoyReleased(joy, but)
854	-- Override
855end
856
857function PANEL:OnMouseMoved(x, y, dx, dy, istouch)
858	--[[
859	Called when when the mouse has been moved.
860
861	number x
862		The mouse position on the x-axis.
863	number y
864		The mouse position on the y-axis.
865	number dx
866		The amount moved along the x-axis since the last time love.mousemoved was called.
867	number dy
868		The amount moved along the y-axis since the last time love.mousemoved was called.
869
870	Returning true will stop the event from going up the family tree
871	Child->Parent->Parent->Parent->etc, etc..
872	]]
873	
874	return false
875end
876
877function PANEL:OnMousePressed(x, y, button, istouch, presses)
878	--[[
879	Called when a mouse press event has been made.
880
881	number x
882		The mouse position on the x-axis.
883	number y
884		The mouse position on the y-axis.
885	number dx
886		The amount moved along the x-axis since the last time love.mousemoved was called.
887	number dy
888		The amount moved along the y-axis since the last time love.mousemoved was called.
889
890	Returning true will stop the event from going up the family tree
891	Child->Parent->Parent->Parent->etc, etc..
892	]]
893	
894	return false
895end
896
897function PANEL:OnMouseReleased(x, y, button, istouch, presses)
898	--[[
899	Called when a mouse release event has been made.
900
901	number x
902		The mouse position on the x-axis.
903	number y
904		The mouse position on the y-axis.
905	number dx
906		The amount moved along the x-axis since the last time love.mousemoved was called.
907	number dy
908		The amount moved along the y-axis since the last time love.mousemoved was called.
909
910	Returning true will stop the event from going up the family tree
911	Child->Parent->Parent->Parent->etc, etc..
912	]]
913	
914	return false
915end
916
917function PANEL:OnMouseWheeled(x, y)
918	--[[
919	Called when the scrollwheel has been turned.
920
921	number x
922		Amount of horizontal mouse wheel movement. Positive values indicate movement to the right.
923	number y
924		Amount of vertical mouse wheel movement. Positive values indicate upward movement.
925
926	See an example in..
927	gui/panels/scrollpanel.lua 
928	&
929	gui/panels/scrollbar.lua 
930
931	Returning true will stop the event from going up the family tree
932	Child->Parent->Parent->Parent->etc, etc..
933    ]]
934
935	return false
936end
937
938function PANEL:OnChildAdded(panel)
939	-- Called when a panel has been added
940end
941
942function PANEL:OnRemoved()
943	
944end
945
946function PANEL:OnChildRemoved(panel)
947	-- Called when a panel has been removed
948end
949
950function PANEL:Think(dt)
951	-- Called every frame
952end
953
954function PANEL:OnQuertyTooltip()
955	-- Called when the user has hovered over the panel for more than a second
956end