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.3 KiB124 linesraw
1local PANEL = {}
2
3function PANEL:Initialize()
4	-- Initialize values within Panel:Initialize()
5	self:super()
6
7	-- Display should have no padding or margin
8	-- since it will match the size of the window
9	self:DockPadding(0,0,0,0)
10	self:DockMargin(0,0,0,0)
11
12	-- Transparent for use with OBS game capture
13	self:SetBGColor(color_blank)
14	self:SetBorderColor(color_blank)
15
16	self.m_pTaskBar = self:Add("SceneTaskBar")
17	self.m_pTaskBar:DockMargin(0, 0, 0, 0)
18	self.m_pTaskBar:SetBGColor(color(200, 200, 200))
19	self.m_pTaskBar:Dock(DOCK_TOP)
20	self.m_pTaskBar:SetVisible(false)
21
22	self.m_pInfoBar = self:Add("SceneInfoBar")
23	self.m_pInfoBar:DockMargin(0, 0, 0, 0)
24	self.m_pInfoBar:SetBGColor(color(200, 200, 200))
25	self.m_pInfoBar:Dock(DOCK_BOTTOM)
26	self.m_pInfoBar:SetVisible(false)
27
28	-- Object list when in editor mode
29	-- TODO: Make a new class for this, maybe a list panel
30	--[[self.m_pObjectList = self:Add("ScrollPanel")
31	self.m_pObjectList:DockMargin(4, 4, 0, 4)
32	self.m_pObjectList:SetWidth(128 + 32)
33
34	-- Dock to the left
35	self.m_pObjectList:Dock(DOCK_LEFT)
36	-- Not visible on startup
37	self.m_pObjectList:SetVisible(false)]]
38
39	-- The output display
40	self.m_pSceneDisplay = self:Add("SceneDisplay")
41	-- FILL so the panel will stretch and fit inside our window
42	self.m_pSceneDisplay:Dock(DOCK_FILL)
43
44	-- Member values
45	self.m_bEditable = false
46end
47
48-- Special method to add a new element to our scene
49function PANEL:AddToScene(name)
50	-- Add the panel we want to add
51	local panel = self.m_pSceneDisplay:Add(name)
52	panel:SetFocusable(true)
53
54	--[[
55	-- Add a matching button to our object list, for ordering/removing/settings and stuff?
56	local but = self.m_pObjectList:AddItem("Button") -- TODO: Make a new class for this, maybe a list panel
57	but:DockMargin(0, 0, 0, 0)
58	but:Dock(DOCK_TOP)
59	but:SetText(name)
60	]]
61
62	-- Return the panel we added
63	return panel
64end
65
66function PANEL:SetEditorMode(b)
67	-- Set the mode..
68	self.m_bEditable = b
69
70	self.m_pTaskBar:SetVisible(b)
71	self.m_pInfoBar:SetVisible(b)
72	--self.m_pObjectList:SetVisible(b)
73
74	if b then
75		-- WE ARE IN EDITOR MODE
76
77		-- Set BG color to something pleasant, rather than being transparent
78		self:SetBGColor(color(240, 240, 240))
79
80		-- Add a simple margin to the display, so it matches the margin of the object list
81		self.m_pSceneDisplay:DockMargin(0, 0, 0, 0)
82
83		-- Fake the black background of the window, since it would normally be "transparent" for OBS capture
84		-- This will now look black in OBS capture, rather than transparent
85		self.m_pSceneDisplay:SetBGColor(color_black)
86	else
87		-- WE ARE IN DISPLAY MODE
88
89		-- Reset everything for display mode
90		self:SetBGColor(color_blank)
91		self.m_pSceneDisplay:DockMargin(0, 0, 0, 0)
92		self.m_pSceneDisplay:SetBGColor(color_blank)
93	end
94
95	-- Invalidate the layout so the panels get resized and moved properly
96	self:InvalidateLayout()
97end
98
99function PANEL:GetUnusableSpace()
100	local margins = self.m_pSceneDisplay:GetDockMargin()
101
102	local w = margins.left + margins.right
103	local h = margins.top + margins.bottom
104
105	h = h + self.m_pTaskBar:GetHeightPlusMargin()
106	h = h + self.m_pInfoBar:GetHeightPlusMargin()
107	--w = w + self.m_pObjectList:GetWidthPlusMargin()
108
109	return w, h
110end
111
112function PANEL:IsInEditorMode()
113	return self.m_bEditable
114end
115
116function PANEL:GetObjectList()
117	return self.m_pObjectList
118end
119
120function PANEL:GetDisplay()
121	return self.m_pSceneDisplay
122end
123
124gui.register("SceneEditor", PANEL, "Panel")