Răsfoiți Sursa

Removed GUIPanelContainers and using the new built-in GUIPanel instead

Marko Pintera 10 ani în urmă
părinte
comite
d4d09c85d9

+ 0 - 30
MBansheeEditor/GUI/GUIPanelContainer.cs

@@ -1,30 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-using BansheeEngine;
-
-namespace BansheeEditor
-{
-    public sealed class GUIPanelContainer : GUIElement
-    {
-        public GUIPanelContainer(GUIPanel panel, params GUIOption[] options)
-        {
-            Internal_CreateInstance(this, panel, options);
-        }
-
-        public GUIPanelContainer(GUIPanel panel)
-        {
-            Internal_CreateInstance(this, panel, new GUIOption[0]);
-        }
-
-        public void SetPanel(GUIPanel panel)
-        {
-            Internal_SetPanel(mCachedPtr, panel);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUIPanelContainer instance, GUIPanel panel, GUIOption[] options);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPanel(IntPtr nativeInstance, GUIPanel panel);
-    }
-}

+ 4 - 9
MBansheeEditor/Inspector/Inspector.cs

@@ -8,25 +8,20 @@ namespace BansheeEditor
 {
     public abstract class Inspector
     {
-        protected GUIPanel GUI;
+        protected GUIPanelNEW GUI;
         protected GUILayoutY layout;
         protected object referencedObject;
 
         private InspectorWindow parentWindow;
 
-        internal void Initialize(InspectorWindow parentWindow, GUIPanel gui, object instance)
+        internal void Initialize(InspectorWindow parentWindow, GUIPanelNEW gui, object instance)
         {
             GUI = gui;
-            layout = gui.layout.AddLayoutY();
+            layout = gui.AddLayoutY();
             referencedObject = instance;
             this.parentWindow = parentWindow;
         }
 
-        internal void SetArea(int x, int y, int width, int height)
-        {
-            GUI.SetArea(x, y, width, height);
-        }
-
         internal void SetVisible(bool visible)
         {
             GUI.SetVisible(visible);
@@ -35,7 +30,7 @@ namespace BansheeEditor
         internal void Destroy()
         {
             layout.Destroy();
-            parentWindow.DestroyPanel(GUI);
+            GUI.Destroy();
         }
 
         internal abstract bool Refresh();

+ 5 - 39
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -9,7 +9,7 @@ namespace BansheeEditor
         private class InspectorData
         {
             public GUIComponentFoldout foldout;
-            public GUIPanelContainer container;
+            public GUIPanelNEW panel;
             public Inspector inspector;
             public bool expanded = true;
         }
@@ -32,15 +32,13 @@ namespace BansheeEditor
             for (int i = 0; i < allComponents.Length; i++)
             {
                 InspectorData data = new InspectorData();
-                GUIPanel inspectorPanel = CreatePanel(0, 0, 0, 0);
 
                 data.foldout = new GUIComponentFoldout(allComponents[i].GetType().Name);
                 inspectorLayout.AddElement(data.foldout);
-                data.container = new GUIPanelContainer(inspectorPanel);
-                inspectorLayout.AddElement(data.container);
-
+                data.panel = inspectorLayout.AddPanel();
+                
                 data.inspector = GetInspector(allComponents[i].GetType());
-                data.inspector.Initialize(this, inspectorPanel, allComponents[i]);
+                data.inspector.Initialize(this, data.panel, allComponents[i]);
 
                 data.foldout.SetExpanded(true);
                 data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
@@ -51,29 +49,20 @@ namespace BansheeEditor
             }
 
             inspectorLayout.AddFlexibleSpace();
-
-            RepositionInspectors();
         }
 
         private void OnComponentFoldoutToggled(InspectorData inspectorData, bool expanded)
         {
             inspectorData.expanded = expanded;
             inspectorData.inspector.SetVisible(expanded);
-
-            RepositionInspectors();
         }
 
         private void EditorUpdate()
         {
-            bool anythingModified = false;
-
             for (int i = 0; i < inspectorData.Count; i++)
             {
-                anythingModified |= inspectorData[i].inspector.Refresh();
+                inspectorData[i].inspector.Refresh();
             }
-
-            if (anythingModified)
-                RepositionInspectors();
         }
 
         internal void Destroy()
@@ -100,29 +89,6 @@ namespace BansheeEditor
             }
         }
 
-        protected override void WindowResized(int width, int height)
-        {
-            base.WindowResized(width, height);
-
-            RepositionInspectors();
-        }
-
-        private void RepositionInspectors()
-        {
-            int curPosition = 0;
-            for (int i = 0; i < inspectorData.Count; i++)
-            {
-                int inspectorHeight = inspectorData[i].inspector.GetOptimalHeight();
-
-                if (!inspectorData[i].expanded)
-                    inspectorHeight = 0;
-
-                inspectorData[i].inspector.SetArea(0, curPosition, Width, inspectorHeight);
-                inspectorData[i].container.SetHeight(inspectorHeight);
-                curPosition += inspectorHeight;
-            } 
-        }
-
         private Inspector GetInspector(Type type)
         {
             // TODO - Check if type has a custom inspector

+ 0 - 1
MBansheeEditor/MBansheeEditor.csproj

@@ -68,7 +68,6 @@
     <Compile Include="GUI\GUIFloatField.cs" />
     <Compile Include="GUI\GUIComponentFoldout.cs" />
     <Compile Include="GUI\GUIIntField.cs" />
-    <Compile Include="GUI\GUIPanelContainer.cs" />
     <Compile Include="GUI\GUITextField.cs" />
     <Compile Include="GUI\GUIToggleField.cs" />
     <Compile Include="GUI\GUIVector2Field.cs" />

+ 0 - 32
SBansheeEditor/Include/BsGUIPanelContainer.h

@@ -1,32 +0,0 @@
-#pragma once
-
-#include "BsScriptEditorPrerequisites.h"
-#include "BsGUIElementContainer.h"
-#include "BsScriptGUIPanel.h"
-
-namespace BansheeEngine
-{
-	class BS_SCR_BED_EXPORT GUIPanelContainer : public GUIElementContainer
-	{
-		struct PrivatelyConstruct {};
-
-	public:
-		static const String& getGUITypeName();
-
-		static GUIPanelContainer* create(const ScriptGUIPanel& guiPanel, const GUIOptions& options);
-		static GUIPanelContainer* create(const ScriptGUIPanel& guiPanel);
-
-		GUIPanelContainer(const PrivatelyConstruct& dummy, const ScriptGUIPanel& guiPanel, const GUIDimensions& dimensions);
-
-		void setPanel(const ScriptGUIPanel& guiPanel) { mGUIPanel = &guiPanel; }
-
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
-
-		Vector2I _getOptimalSize() const;
-	protected:
-		virtual ~GUIPanelContainer();
-
-		const ScriptGUIPanel* mGUIPanel;
-	};
-}

+ 0 - 21
SBansheeEditor/Include/BsScriptGUIPanelContainer.h

@@ -1,21 +0,0 @@
-#pragma once
-
-#include "BsScriptEditorPrerequisites.h"
-#include "BsScriptGUIElement.h"
-#include "BsGUIPanelContainer.h"
-#include "BsScriptGUIPanel.h"
-
-namespace BansheeEngine
-{
-	class BS_SCR_BED_EXPORT ScriptGUIPanelContainer : public TScriptGUIElement<ScriptGUIPanelContainer>
-	{
-	public:
-		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "GUIPanelContainer")
-
-	private:
-		static void internal_createInstance(MonoObject* instance, MonoObject* panel, MonoArray* guiOptions);
-		static void internal_setPanel(ScriptGUIPanelContainer* nativeInstance, MonoObject* panel);
-
-		ScriptGUIPanelContainer(MonoObject* instance, GUIPanelContainer* panelContainer);
-	};
-}

+ 0 - 4
SBansheeEditor/SBansheeEditor.vcxproj

@@ -234,7 +234,6 @@
   <ItemGroup>
     <ClInclude Include="Include\BsEditorScriptManager.h" />
     <ClInclude Include="Include\BsGUIGameObjectField.h" />
-    <ClInclude Include="Include\BsGUIPanelContainer.h" />
     <ClInclude Include="Include\BsGUIResourceField.h" />
     <ClInclude Include="Include\BsMenuItemManager.h" />
     <ClInclude Include="Include\BsScriptBrowseDialog.h" />
@@ -255,7 +254,6 @@
     <ClInclude Include="Include\BsScriptGUIFoldout.h" />
     <ClInclude Include="Include\BsScriptGUIGameObjectField.h" />
     <ClInclude Include="Include\BsScriptGUIIntField.h" />
-    <ClInclude Include="Include\BsScriptGUIPanelContainer.h" />
     <ClInclude Include="Include\BsScriptGUIResourceField.h" />
     <ClInclude Include="Include\BsScriptGUITextField.h" />
     <ClInclude Include="Include\BsScriptGUIToggleField.h" />
@@ -283,7 +281,6 @@
     <ClCompile Include="Source\BsScriptDragDropManager.cpp" />
     <ClCompile Include="Source\BsEditorScriptManager.cpp" />
     <ClCompile Include="Source\BsGUIGameObjectField.cpp" />
-    <ClCompile Include="Source\BsGUIPanelContainer.cpp" />
     <ClCompile Include="Source\BsGUIResourceField.cpp" />
     <ClCompile Include="Source\BsScriptBrowseDialog.cpp" />
     <ClCompile Include="Source\BsScriptEditorApplication.cpp" />
@@ -300,7 +297,6 @@
     <ClCompile Include="Source\BsScriptGUIFoldout.cpp" />
     <ClCompile Include="Source\BsScriptGUIGameObjectField.cpp" />
     <ClCompile Include="Source\BsScriptGUIIntField.cpp" />
-    <ClCompile Include="Source\BsScriptGUIPanelContainer.cpp" />
     <ClCompile Include="Source\BsScriptGUIResourceField.cpp" />
     <ClCompile Include="Source\BsScriptGUITextField.cpp" />
     <ClCompile Include="Source\BsScriptGUIToggleField.cpp" />

+ 0 - 12
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -24,12 +24,6 @@
     <ClInclude Include="Include\BsScriptGUIIntField.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIPanelContainer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsScriptGUIPanelContainer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptGUIFloatField.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -155,12 +149,6 @@
     <ClCompile Include="Source\BsScriptGUIIntField.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsGUIPanelContainer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsScriptGUIPanelContainer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptGUIFloatField.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 0 - 79
SBansheeEditor/Source/BsGUIPanelContainer.cpp

@@ -1,79 +0,0 @@
-#include "BsGUIPanelContainer.h"
-#include "BsGUIArea.h"
-#include "BsScriptGUIPanel.h"
-#include "BsGUILayout.h"
-#include "BsGUIWidget.h"
-#include "BsScriptGUIArea.h"
-
-namespace BansheeEngine
-{
-	GUIPanelContainer::GUIPanelContainer(const PrivatelyConstruct& dummy, const ScriptGUIPanel& guiPanel, const GUIDimensions& dimensions)
-		:GUIElementContainer(dimensions), mGUIPanel(&guiPanel)
-	{
-
-	}
-
-	GUIPanelContainer::~GUIPanelContainer()
-	{
-
-	}
-
-	GUIPanelContainer* GUIPanelContainer::create(const ScriptGUIPanel& guiPanel, const GUIOptions& options)
-	{
-		return bs_new<GUIPanelContainer>(PrivatelyConstruct(), guiPanel, GUIDimensions::create(options));
-	}
-
-	GUIPanelContainer* GUIPanelContainer::create(const ScriptGUIPanel& guiPanel)
-	{
-		return bs_new<GUIPanelContainer>(PrivatelyConstruct(), guiPanel, GUIDimensions::create());
-	}
-
-	void GUIPanelContainer::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
-	{
-		const Vector<ScriptGUIArea*> areas = mGUIPanel->getAreas();
-
-		for (auto& scriptArea : areas)
-		{
-			GUIArea* area = scriptArea->getInternalValue();
-
-			if (area->x() != x || area->y() != y)
-				area->setPosition(x, y);
-
-			if (area->width() != width || area->height() != height)
-				area->setSize(width, height);
-
-			Rect2I areaClipRect(clipRect.x - x, clipRect.y - y, clipRect.width, clipRect.height);
-			if (area->getClipRect() != areaClipRect)
-				area->setClipRect(areaClipRect);
-
-			// We want to force the layout update right away otherwise it might get delayed until next frame.
-			// (Since we are currently in a middle of a layout update its possible this area was already processed)
-			area->_update();
-		}
-	}
-
-	Vector2I GUIPanelContainer::_getOptimalSize() const
-	{
-		const Vector<ScriptGUIArea*> areas = mGUIPanel->getAreas();
-
-		Vector2I optimalSize;
-
-		for (auto& scriptArea : areas)
-		{
-			GUIArea* area = scriptArea->getInternalValue();
-			area->_update();
-
-			optimalSize.x = std::max(optimalSize.x, area->getLayout()._getOptimalSize().x);
-			optimalSize.y = std::max(optimalSize.y, area->getLayout()._getOptimalSize().y);
-		}
-
-		return optimalSize;
-	}
-
-	const String& GUIPanelContainer::getGUITypeName()
-	{
-		static String typeName = "GUIAreaContainer";
-		return typeName;
-	}
-}

+ 0 - 47
SBansheeEditor/Source/BsScriptGUIPanelContainer.cpp

@@ -1,47 +0,0 @@
-#include "BsScriptGUIPanelContainer.h"
-#include "BsGUIPanelContainer.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsMonoMethod.h"
-#include "BsGUIOptions.h"
-#include "BsDebug.h"
-
-namespace BansheeEngine
-{
-	ScriptGUIPanelContainer::ScriptGUIPanelContainer(MonoObject* instance, GUIPanelContainer* panelContainer)
-		:TScriptGUIElement(instance, panelContainer)
-	{
-
-	}
-
-	void ScriptGUIPanelContainer::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIPanelContainer::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_SetPanel", &ScriptGUIPanelContainer::internal_setPanel);
-	}
-
-	void ScriptGUIPanelContainer::internal_createInstance(MonoObject* instance, MonoObject* panel, MonoArray* guiOptions)
-	{
-		GUIOptions options;
-
-		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
-		for (UINT32 i = 0; i < arrayLen; i++)
-			options.addOption(mono_array_get(guiOptions, GUIOption, i));
-
-		ScriptGUIPanel* guiPanel = ScriptGUIPanel::toNative(panel);
-		LOGWRN("Creating panel: " + toString((UINT64)guiPanel));
-		GUIPanelContainer* guiPanelContainer = GUIPanelContainer::create(*guiPanel, options);
-
-		ScriptGUIPanelContainer* nativeInstance = new (bs_alloc<ScriptGUIPanelContainer>()) ScriptGUIPanelContainer(instance, guiPanelContainer);
-	}
-
-	void ScriptGUIPanelContainer::internal_setPanel(ScriptGUIPanelContainer* nativeInstance, MonoObject* panel)
-	{
-		ScriptGUIPanel* guiPanel = ScriptGUIPanel::toNative(panel);
-
-		GUIPanelContainer* panelContainer = static_cast<GUIPanelContainer*>(nativeInstance->getGUIElement());
-		panelContainer->setPanel(*guiPanel);
-	}
-}

+ 0 - 1
TODO.txt

@@ -25,7 +25,6 @@ Change how depth works so GUIPanels can set it (offset + range)
 
 Remove GUIArea and replace it with GUIPanel completely
 
-
 Use cases:
 InspectorWindow:
  - It has a scroll area that will have a GUIPanel as its child. User can then add custom GUIPanels as children to the root GUIPanels main layout.