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