Переглянути джерело

Removed all uses of GUIArea (WIP)

Marko Pintera 10 роки тому
батько
коміт
65cdd2a30a
93 змінених файлів з 129 додано та 1262 видалено
  1. 4 0
      BansheeEditor/Include/BsModalWindow.h
  2. 0 1
      BansheeEditor/Source/BsEditorApplication.cpp
  3. 0 1
      BansheeEditor/Source/BsEditorWidget.cpp
  4. 0 1
      BansheeEditor/Source/BsGUIColorField.cpp
  5. 0 1
      BansheeEditor/Source/BsGUIComponentFoldout.cpp
  6. 0 1
      BansheeEditor/Source/BsGUIFloatField.cpp
  7. 0 1
      BansheeEditor/Source/BsGUIFoldout.cpp
  8. 0 1
      BansheeEditor/Source/BsGUIIntField.cpp
  9. 0 1
      BansheeEditor/Source/BsGUITabbedTitleBar.cpp
  10. 0 1
      BansheeEditor/Source/BsGUITextField.cpp
  11. 0 1
      BansheeEditor/Source/BsGUIToggleField.cpp
  12. 0 1
      BansheeEditor/Source/BsGUITreeView.cpp
  13. 0 1
      BansheeEditor/Source/BsGUIVector2Field.cpp
  14. 0 1
      BansheeEditor/Source/BsGUIVector3Field.cpp
  15. 0 1
      BansheeEditor/Source/BsGUIVector4Field.cpp
  16. 8 2
      BansheeEditor/Source/BsModalWindow.cpp
  17. 0 1
      BansheeEditor/Source/BsTestTextSprite.cpp
  18. 0 1
      BansheeEditor/Source/DbgEditorWidget1.cpp
  19. 0 1
      BansheeEditor/Source/DbgEditorWidget2.cpp
  20. 0 2
      BansheeEngine/BansheeEngine.vcxproj
  21. 0 6
      BansheeEngine/BansheeEngine.vcxproj.filters
  22. 0 8
      BansheeEngine/Include/BsEnums.h
  23. 0 237
      BansheeEngine/Include/BsGUIArea.h
  24. 0 9
      BansheeEngine/Include/BsGUILayout.h
  25. 0 1
      BansheeEngine/Include/BsGUILayoutX.h
  26. 0 1
      BansheeEngine/Include/BsGUILayoutY.h
  27. 0 1
      BansheeEngine/Include/BsGUIPanel.h
  28. 0 12
      BansheeEngine/Include/BsGUIWidget.h
  29. 0 1
      BansheeEngine/Include/BsPrerequisites.h
  30. 0 202
      BansheeEngine/Source/BsGUIArea.cpp
  31. 0 1
      BansheeEngine/Source/BsGUIDropDownContent.cpp
  32. 1 6
      BansheeEngine/Source/BsGUILayout.cpp
  33. 9 9
      BansheeEngine/Source/BsGUILayoutUtility.cpp
  34. 0 4
      BansheeEngine/Source/BsGUILayoutX.cpp
  35. 0 4
      BansheeEngine/Source/BsGUILayoutY.cpp
  36. 0 4
      BansheeEngine/Source/BsGUIPanel.cpp
  37. 4 39
      BansheeEngine/Source/BsGUIWidget.cpp
  38. 0 1
      ExampleProject/Main/Main.cpp
  39. 11 8
      MBansheeEditor/ColorPicker.cs
  40. 9 5
      MBansheeEditor/DebugWindow.cs
  41. 1 1
      MBansheeEditor/DialogBox.cs
  42. 1 39
      MBansheeEditor/EditorWindow.cs
  43. 2 2
      MBansheeEditor/Inspector/Inspector.cs
  44. 2 2
      MBansheeEditor/Inspector/InspectorWindow.cs
  45. 1 17
      MBansheeEditor/ModalWindow.cs
  46. 1 1
      MBansheeEditor/ProgressBar.cs
  47. 1 1
      MBansheeEditor/ProjectWindow.cs
  48. 1 1
      MBansheeEditor/Scene/SceneWindow.cs
  49. 0 85
      MBansheeEngine/GUI/GUIArea.cs
  50. 9 12
      MBansheeEngine/GUI/GUILayout.cs
  51. 0 5
      MBansheeEngine/GUI/GUILayoutX.cs
  52. 7 55
      MBansheeEngine/GUI/GUIPanel.cs
  53. 0 18
      MBansheeEngine/GUI/GUIPanelNEW.cs
  54. 1 3
      MBansheeEngine/MBansheeEngine.csproj
  55. 1 10
      SBansheeEditor/Include/BsScriptEditorWindow.h
  56. 1 4
      SBansheeEditor/Include/BsScriptModalWindow.h
  57. 0 1
      SBansheeEditor/Source/BsGUIGameObjectField.cpp
  58. 0 1
      SBansheeEditor/Source/BsGUIResourceField.cpp
  59. 7 63
      SBansheeEditor/Source/BsScriptEditorWindow.cpp
  60. 0 1
      SBansheeEditor/Source/BsScriptGUIColorField.cpp
  61. 0 1
      SBansheeEditor/Source/BsScriptGUIComponentFoldout.cpp
  62. 0 1
      SBansheeEditor/Source/BsScriptGUIFloatField.cpp
  63. 0 1
      SBansheeEditor/Source/BsScriptGUIFoldout.cpp
  64. 0 1
      SBansheeEditor/Source/BsScriptGUIGameObjectField.cpp
  65. 0 1
      SBansheeEditor/Source/BsScriptGUIIntField.cpp
  66. 0 1
      SBansheeEditor/Source/BsScriptGUIResourceField.cpp
  67. 0 1
      SBansheeEditor/Source/BsScriptGUITextField.cpp
  68. 0 1
      SBansheeEditor/Source/BsScriptGUIToggleField.cpp
  69. 0 1
      SBansheeEditor/Source/BsScriptGUIVector2Field.cpp
  70. 0 1
      SBansheeEditor/Source/BsScriptGUIVector3Field.cpp
  71. 0 1
      SBansheeEditor/Source/BsScriptGUIVector4Field.cpp
  72. 9 25
      SBansheeEditor/Source/BsScriptModalWindow.cpp
  73. 0 2
      SBansheeEngine/Include/BsScriptEnginePrerequisites.h
  74. 0 36
      SBansheeEngine/Include/BsScriptGUIArea.h
  75. 1 0
      SBansheeEngine/Include/BsScriptGUIElement.h
  76. 15 2
      SBansheeEngine/Include/BsScriptGUILayout.h
  77. 0 46
      SBansheeEngine/Include/BsScriptGUIPanel.h
  78. 0 4
      SBansheeEngine/SBansheeEngine.vcxproj
  79. 0 12
      SBansheeEngine/SBansheeEngine.vcxproj.filters
  80. 0 88
      SBansheeEngine/Source/BsScriptGUIArea.cpp
  81. 0 1
      SBansheeEngine/Source/BsScriptGUIButton.cpp
  82. 0 1
      SBansheeEngine/Source/BsScriptGUIInputBox.cpp
  83. 0 1
      SBansheeEngine/Source/BsScriptGUILabel.cpp
  84. 18 14
      SBansheeEngine/Source/BsScriptGUILayout.cpp
  85. 0 1
      SBansheeEngine/Source/BsScriptGUIListBox.cpp
  86. 0 97
      SBansheeEngine/Source/BsScriptGUIPanel.cpp
  87. 0 1
      SBansheeEngine/Source/BsScriptGUIProgressBar.cpp
  88. 0 1
      SBansheeEngine/Source/BsScriptGUIRenderTexture.cpp
  89. 0 1
      SBansheeEngine/Source/BsScriptGUIScrollArea.cpp
  90. 0 1
      SBansheeEngine/Source/BsScriptGUISlider.cpp
  91. 0 1
      SBansheeEngine/Source/BsScriptGUITexture.cpp
  92. 0 1
      SBansheeEngine/Source/BsScriptGUIToggle.cpp
  93. 4 13
      TODO.txt

+ 4 - 0
BansheeEditor/Include/BsModalWindow.h

@@ -21,6 +21,7 @@ namespace BansheeEngine
 		Rect2I getContentArea() const;
 
 		virtual void resized();
+
 	private:
 		void updateSize();
 		UINT32 getTitleBarHeight() const;
@@ -31,5 +32,8 @@ namespace BansheeEngine
 		GUILabel* mTitle;
 		GUIButton* mCloseButton;
 		GUITexture* mTitleBarBg;
+
+	protected:
+		GUIPanel* mContents;
 	};
 }

+ 0 - 1
BansheeEditor/Source/BsEditorApplication.cpp

@@ -36,7 +36,6 @@
 #include "BsProjectLibrary.h"
 #include "BsCamera.h"
 #include "BsGUIWidget.h"
-#include "BsGUIArea.h"
 #include "BsGUIButton.h"
 #include "BsGUILayout.h"
 #include "BsEvent.h"

+ 0 - 1
BansheeEditor/Source/BsEditorWidget.cpp

@@ -6,7 +6,6 @@
 #include "BsGUILayout.h"
 #include "BsGUIPanel.h"
 #include "BsBuiltinResources.h"
-#include "BsGUIArea.h"
 #include "BsEditorWidgetContainer.h"
 #include "BsEditorWidgetManager.h"
 #include "BsEditorWindow.h"

+ 0 - 1
BansheeEditor/Source/BsGUIColorField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIColorField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIColor.h"

+ 0 - 1
BansheeEditor/Source/BsGUIComponentFoldout.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIComponentFoldout.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIToggle.h"

+ 0 - 1
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIFloatField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"

+ 0 - 1
BansheeEditor/Source/BsGUIFoldout.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIFoldout.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIToggle.h"

+ 0 - 1
BansheeEditor/Source/BsGUIIntField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIIntField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"

+ 0 - 1
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -1,5 +1,4 @@
 #include "BsGUITabbedTitleBar.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIButton.h"

+ 0 - 1
BansheeEditor/Source/BsGUITextField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUITextField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"

+ 0 - 1
BansheeEditor/Source/BsGUIToggleField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIToggleField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIToggle.h"

+ 0 - 1
BansheeEditor/Source/BsGUITreeView.cpp

@@ -1,5 +1,4 @@
 #include "BsGUITreeView.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIButton.h"

+ 0 - 1
BansheeEditor/Source/BsGUIVector2Field.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIVector2Field.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUILabel.h"

+ 0 - 1
BansheeEditor/Source/BsGUIVector3Field.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIVector3Field.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUILabel.h"

+ 0 - 1
BansheeEditor/Source/BsGUIVector4Field.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIVector4Field.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUILabel.h"

+ 8 - 2
BansheeEditor/Source/BsModalWindow.cpp

@@ -2,7 +2,6 @@
 #include "BsEditorWindowManager.h"
 #include "BsRenderWindow.h"
 #include "BsPlatform.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUISpace.h"
@@ -16,7 +15,7 @@ namespace BansheeEngine
 {
 	ModalWindow::ModalWindow(const HString& title, bool hasCloseButton)
 		:EditorWindowBase(true), mTitleBarPanel(nullptr), mTitleBarBgPanel(nullptr), 
-		mCloseButton(nullptr), mTitleBarBg(nullptr), mTitle(nullptr)
+		mCloseButton(nullptr), mTitleBarBg(nullptr), mTitle(nullptr), mContents(nullptr)
 	{
 		EditorWindowManager::instance().registerWindow(this);
 
@@ -59,6 +58,10 @@ namespace BansheeEngine
 		contentLayoutY->addNewElement<GUIFlexibleSpace>();
 		contentLayoutY->addNewElement<GUIFixedSpace>(1);
 
+		mContents = mGUI->getPanel()->addNewElement<GUIPanel>();
+		mContents->setDepthRange(0);
+		mContents->setPosition(1, 1 + getTitleBarHeight());
+
 		updateSize();
 	}
 
@@ -91,6 +94,9 @@ namespace BansheeEngine
 
 	void ModalWindow::updateSize()
 	{
+		mContents->setWidth(getWidth() - 2);
+		mContents->setHeight(getHeight() - 2 - getTitleBarHeight());
+
 		Vector<Rect2I> captionAreas;
 		captionAreas.push_back(Rect2I(1, 1, getWidth() - 2, getTitleBarHeight()));
 

+ 0 - 1
BansheeEditor/Source/BsTestTextSprite.cpp

@@ -14,7 +14,6 @@
 #include "BsBuiltinEditorResources.h"
 #include "BsGUITexture.h"
 #include "BsGUIRenderTexture.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUISpace.h"
 #include "BsGUIViewport.h"

+ 0 - 1
BansheeEditor/Source/DbgEditorWidget1.cpp

@@ -4,7 +4,6 @@
 #include "BsGUIButton.h"
 #include "BsGUIInputBox.h"
 #include "BsGUIScrollArea.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutY.h"
 #include "BsGUIPanel.h"

+ 0 - 1
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -2,7 +2,6 @@
 #include "BsEditorWidgetManager.h"
 #include "BsGUIToggle.h"
 #include "BsGUIScrollArea.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutY.h"
 #include "BsGUIPanel.h"
 #include "BsGUIWidget.h"

+ 0 - 2
BansheeEngine/BansheeEngine.vcxproj

@@ -284,7 +284,6 @@
     <ClInclude Include="Include\BsShapeMeshes2D.h" />
     <ClInclude Include="Include\BsBuiltinResources.h" />
     <ClInclude Include="Include\BsEnums.h" />
-    <ClInclude Include="Include\BsGUIArea.h" />
     <ClInclude Include="Include\BsGUIButton.h" />
     <ClInclude Include="Include\BsGUIButtonBase.h" />
     <ClInclude Include="Include\BsGUICommandEvent.h" />
@@ -362,7 +361,6 @@
     <ClCompile Include="Source\BsShapeMeshes3D.cpp" />
     <ClCompile Include="Source\BsDragAndDropManager.cpp" />
     <ClCompile Include="Source\BsBuiltinResources.cpp" />
-    <ClCompile Include="Source\BsGUIArea.cpp" />
     <ClCompile Include="Source\BsGUIButton.cpp" />
     <ClCompile Include="Source\BsGUIContent.cpp" />
     <ClCompile Include="Source\BsGUIDropDownBox.cpp" />

+ 0 - 6
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -101,9 +101,6 @@
     <ClInclude Include="Include\BsUpdateCallback.h">
       <Filter>Header Files\Components</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsGUIArea.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsGUILayout.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -385,9 +382,6 @@
     <ClCompile Include="Source\BsUpdateCallback.cpp">
       <Filter>Source Files\Components</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsGUIArea.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsGUILayout.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>

+ 0 - 8
BansheeEngine/Include/BsEnums.h

@@ -30,12 +30,4 @@ namespace BansheeEngine
 	{
 		RenType_LitTextured
 	};
-
-	/**
-	 * @brief	Type of layout that a GUIArea can initially be created with.
-	 */
-	enum class GUILayoutType
-	{
-		LayoutX, LayoutY, LayoutExplicit
-	};
 }

+ 0 - 237
BansheeEngine/Include/BsGUIArea.h

@@ -1,237 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRect2I.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	GUIArea represents a freely positionable GUI panel with a GUILayout child.
-	 *			This is one of the top GUI elements (aside from GUIWidget) and all layouts
-	 *			must belong to a single GUIArea.
-	 *
-	 * @note	GUIAreas are automatically cleaned when their parent GUIWidget is destroyed so you
-	 *			dont need to worry about their cleanup.
-	 */
-	class BS_EXPORT GUIArea
-	{
-	public:
-		~GUIArea();
-
-		/**
-		 * Creates a new GUI area. All the layouts used in the area will be placed
-		 * within the specified bounds.
-		 *
-		 * @param	widget		Widget parent of the GUIArea.
-		 * @param	x			X position relative to parent widget position, in pixels.
-		 * @param	y			Y position relative to parent widget position, in pixels.
-		 * @param	width		Width of the area, in pixels. If 0 then the area will be of unlimited width.
-		 * @param	height		Height of the area, in pixels. If 0 then the area will be of unlimited height.
-		 * @param	depth		Depth of the area. This is relative to the depth of parent widget. Depth determines in what
-		 *						order are overlapping GUIAreas drawn. Areas with lower depth will be drawn in front of areas
-		 *						with higher depth.
-		 * @param	layoutType	Type of layout to create as the root layout for the area.
-		 */
-		static GUIArea* create(GUIWidget& widget, INT32 x, INT32 y, UINT32 width = 0, UINT32 height = 0, UINT16 depth = 0, 
-			GUILayoutType layoutType = GUILayoutType::LayoutX);
-
-		/**
-		 * Creates a new GUI area. All the layouts used in the area will be placed
-		 * within the specified bounds.
-		 * 			
-		 * This kind of GUI area will always stretch to completely fill the parent widget, 
-		 * while respecting the provided offsets (in pixels). 
-		 *
-		 * @param	widget			Widget parent of the GUIArea.
-		 * @param	offsetLeft		Offset to keep from the left of the parent widget, in pixels.
-		 * @param	offsetRight		Offset to keep from the right of the parent widget, in pixels.
-		 * @param	offsetTop		Offset to keep from the top of the parent widget, in pixels.
-		 * @param	offsetBottom	Offset to keep from the bottom of the parent widget, in pixels.
-		 * @param	depth			Depth of the area. This is relative to the depth of parent widget. Depth determines in what
-		 *							order are overlapping GUIAreas drawn. Areas with lower depth will be drawn in front of areas
-		 *							with higher depth.
-		 * @param	layoutType		Type of layout to create as the root layout for the area.
-		 */
-		static GUIArea* createStretchedXY(GUIWidget& widget, UINT32 offsetLeft, 
-			UINT32 offsetRight, UINT32 offsetTop, UINT32 offsetBottom, UINT16 depth = 0,
-			GUILayoutType layoutType = GUILayoutType::LayoutX);
-
-		/**
-		 * Creates a new GUI area. All the layouts used in the area will be placed
-		 * within the specified bounds.
-		 * 			
-		 * This kind of GUI area will always stretch to completely fill the parent widget width, 
-		 * while respecting the provided offsets (in pixels). 
-		 *
-		 * @param	widget			Widget parent of the GUIArea.
-		 * @param	offsetLeft		Offset to keep from the left of the parent widget, in pixels.
-		 * @param	offsetRight		Offset to keep from the right of the parent widget, in pixels.
-		 * @param	y				Y position relative to parent widget position, in pixels.
-		 * @param	height			Height of the area, in pixels. If 0 then the area will be of unlimited height.
-		 * @param	depth			Depth of the area. This is relative to the depth of parent widget. Depth determines in what
-		 *							order are overlapping GUIAreas drawn. Areas with lower depth will be drawn in front of areas
-		 *							with higher depth.
-		 * @param	layoutType		Type of layout to create as the root layout for the area.
-		 */
-		static GUIArea* createStretchedX(GUIWidget& widget, UINT32 offsetLeft, 
-			UINT32 offsetRight, UINT32 y, UINT32 height, UINT16 depth = 0,
-			GUILayoutType layoutType = GUILayoutType::LayoutX);
-
-		/**
-		 * Creates a new GUI area. All the layouts used in the area will be placed
-		 * within the specified bounds.
-		 * 			
-		 * This kind of GUI area will always stretch to completely fill the parent widget height, 
-		 * while respecting the provided offsets (in pixels). 
-		 *
-		 * @param	widget			Widget parent of the GUIArea.
-		 * @param	offsetTop		Offset to keep from the top of the parent widget, in pixels.
-		 * @param	offsetBottom	Offset to keep from the bottom of the parent widget, in pixels.
-		 * @param	x				X position relative to parent widget position, in pixels.
-		 * @param	width			Width of the area, in pixels. If 0 then the area will be of unlimited width.
-		 * @param	depth			Depth of the area. This is relative to the depth of parent widget. Depth determines in what
-		 *							order are overlapping GUIAreas drawn. Areas with lower depth will be drawn in front of areas
-		 *							with higher depth.
-		 * @param	layoutType		Type of layout to create as the root layout for the area.
-		 */
-		static GUIArea* createStretchedY(GUIWidget& widget, UINT32 offsetTop, 
-			UINT32 offsetBottom, UINT32 x, UINT32 width, UINT16 depth = 0,
-			GUILayoutType layoutType = GUILayoutType::LayoutX);
-
-		/**
-		 * @brief	Destroys a GUI area and removes it from the parent GUIWidget.
-		 *			Any child layouts are also destroyed so make sure you aren't 
-		 *			not referencing any of them.
-		 *
-		 * @note	Attached GUIElements are not destroyed, you must destroy them manually or
-		 *			they will be destroyed when parent GUIWidget is destroyed.
-		 */
-		static void destroy(GUIArea* area);
-
-		/**
-		 * @brief	Returns primary layout for the GUI area. Use this to
-		 *			attach GUI elements or other layouts.
-		 */
-		GUILayout& getLayout() const { return *mLayout; }
-
-		/**
-		 * @brief	Returns depth of the GUI area. This is relative to the depth of parent widget. 
-		 *			Depth determines in what order are overlapping GUIAreas drawn. Areas with lower 
-		 *			depth will be drawn in front of areas with higher depth.
-		 */
-		UINT16 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Sets depth of the GUI area. This is relative to the depth of parent widget. 
-		 *			Depth determines in what order are overlapping GUIAreas drawn. Areas with lower 
-		 *			depth will be drawn in front of areas with higher depth.
-		 */
-		void setDepth(UINT16 depth) { mDepth = depth; }
-
-		/**
-		 * @brief	Changes the position of the GUI area relative to the parent widget, in pixels.
-		 */
-		void setPosition(INT32 x, INT32 y);
-
-		/**
-		 * @brief	Changes the size of the GUI area, in pixels. If sizes are zero, size is
-		 *			considered to be unlimited.
-		 */
-		void setSize(UINT32 width, UINT32 height);
-
-		/**
-		 * @brief	Sets a rectangle that will be used for clipping of the area contents.
-		 *
-		 * @param	clipRect	Rectangle in coordinates relative to the area. If width or height
-		 *						is zero, no clipping will be done.
-		 */
-		void setClipRect(const Rect2I& clipRect);
-
-		/**
-		 * @brief	Gets a rectangle that is used for clipping of the area contents.
-		 */
-		Rect2I getClipRect() const { return mClipRect; }
-
-		/**
-		 * @brief	Hides the area and any child elements.
-		 */
-		void disable();
-
-		/**
-		 * @brief	Shows the area and any child elements.
-		 */
-		void enable();
-
-		/**
-		 * @brief	Changes the parent widget of the GUI area. This may be null
-		 *			but caller is then responsible for properly cleaning up the area.
-		 *			(Since it's normally done by the parent widget). Areas will
-		 *			null parent won't be rendered.
-		 */
-		void changeParentWidget(GUIWidget* widget);
-
-		/**
-		 * @brief	X position of the GUI area, in pixels relative to parent widget.
-		 */
-		INT32 x() const { return mLeft; }
-
-		/**
-		 * @brief	Y position of the GUI area, in pixels relative to parent widget.
-		 */
-		INT32 y() const { return mTop; }
-
-		/**
-		 * @brief	Width of the GUI area, in pixels. If zero with is unlimited.
-		 */
-		UINT32 width() const { return mWidth; }
-
-		/**
-		 * @brief	Height of the GUI area, in pixels. If zero with is unlimited.
-		 */
-		UINT32 height() const { return mHeight; }
-
-		/**
-		 * @brief	Called once per frame. Updates any child layouts if dirty.
-		 *
-		 * @note	Internal method.
-		 */
-		void _update();		
-	private:
-		friend class GUIWidget;
-
-		/**
-		 * @brief	Constructs the area with the specified parent widget (cannot be null),
-		 *			position relative to the parent widget in pixels, and depth relative to
-		 *			parent widget (smaller depth means closer).
-		 */
-		GUIArea(GUIWidget* widget, INT32 x, INT32 y, UINT16 depth, GUILayoutType layoutType);
-
-		/**
-		 * @brief	Check if any of the area properties changed since the last update.
-		 */
-		bool isDirty() const;
-
-		/**
-		 * @brief	Update area size based on parent size and set offsets (if area is set to be stretched).
-		 */
-		void updateSizeBasedOnParent(UINT32 parentWidth, UINT32 parentHeight);
-
-		/**
-		 * @brief	Destroys the area without unregistering it from the parent (assumed to have done that earlier).
-		 */
-		static void destroyInternal(GUIArea* area);
-
-	private:
-		GUIWidget* mWidget;
-		INT32 mLeft, mRight, mTop, mBottom;
-		UINT32 mWidth, mHeight;
-		UINT16 mDepth;
-		Rect2I mClipRect;
-		bool mResizeXWithWidget;
-		bool mResizeYWithWidget;
-		bool mIsDirty;
-		bool mIsDisabled;
-
-		GUILayout* mLayout;
-	};
-}

+ 0 - 9
BansheeEngine/Include/BsGUILayout.h

@@ -13,7 +13,6 @@ namespace BansheeEngine
 	class BS_EXPORT GUILayout : public GUIElementBase
 	{
 	public:
-		GUILayout(GUIArea* parentArea);
 		GUILayout(const GUIDimensions& dimensions);
 		GUILayout();
 		virtual ~GUILayout();
@@ -105,12 +104,6 @@ namespace BansheeEngine
 		 */
 		UINT32 _getActualHeight() const { return mActualHeight; }
 
-		/**
-		 * @brief	Returns parent GUI area of this layout. This value is only be
-		 *			non null if the layout is top level.
-		 */
-		GUIArea* _getParentGUIArea() const { return mParentGUIArea; }
-
 		/**
 		 * @brief	Calculates the actual size of the layout taken up by all of its elements.
 		 *
@@ -131,8 +124,6 @@ namespace BansheeEngine
 		static void destroy(GUILayout* layout);
 
 	protected:
-		GUIArea* mParentGUIArea;
-
 		Vector<LayoutSizeRange> mChildSizeRanges;
 		LayoutSizeRange mSizeRange;
 

+ 0 - 1
BansheeEngine/Include/BsGUILayoutX.h

@@ -12,7 +12,6 @@ namespace BansheeEngine
 	class BS_EXPORT GUILayoutX : public GUILayout
 	{
 	public:
-		GUILayoutX(GUIArea* parentArea);
 		GUILayoutX(const GUIDimensions& dimensions);
 		GUILayoutX() {};
 		~GUILayoutX() {};

+ 0 - 1
BansheeEngine/Include/BsGUILayoutY.h

@@ -12,7 +12,6 @@ namespace BansheeEngine
 	class BS_EXPORT GUILayoutY : public GUILayout
 	{
 	public:
-		GUILayoutY(GUIArea* parentArea);
 		GUILayoutY(const GUIDimensions& dimensions);
 		GUILayoutY() {};
 		~GUILayoutY() {};

+ 0 - 1
BansheeEngine/Include/BsGUIPanel.h

@@ -12,7 +12,6 @@ namespace BansheeEngine
 	class BS_EXPORT GUIPanel : public GUILayout
 	{
 	public:
-		GUIPanel(GUIArea* parentArea);
 		GUIPanel(UINT16 depth, UINT16 depthRange, const GUIDimensions& dimensions);
 		GUIPanel() {};
 		~GUIPanel() {};

+ 0 - 12
BansheeEngine/Include/BsGUIWidget.h

@@ -116,7 +116,6 @@ namespace BansheeEngine
 	protected:
 		friend class SceneObject;
 		friend class GUIElement;
-		friend class GUIArea;
 		friend class GUIManager;
 
 		/**
@@ -136,16 +135,6 @@ namespace BansheeEngine
 		 */
 		void unregisterElement(GUIElement* elem);
 
-		/**
-		 * @brief	Registers a new areaas a child of the widget.
-		 */
-		void registerArea(GUIArea* area);
-
-		/**
-		 * @brief	Unregisters an area from the widget. Usually called when the area is destroyed.
-		 */
-		void unregisterArea(GUIArea* area);
-
 		/**
 		 * @brief	Called when the viewport size changes and widget elements need to be updated.
 		 */
@@ -175,7 +164,6 @@ namespace BansheeEngine
 
 		Viewport* mTarget;
 		Vector<GUIElement*> mElements;
-		Vector<GUIArea*> mAreas;
 		GUIPanel* mPanel;
 		UINT8 mDepth;
 

+ 0 - 1
BansheeEngine/Include/BsPrerequisites.h

@@ -55,7 +55,6 @@ namespace BansheeEngine
 	class GUITextInputEvent;
 	class GUICommandEvent;
 	class GUIVirtualButtonEvent;
-	class GUIArea;
 	class GUILayout;
 	class GUILayoutX;
 	class GUILayoutY;

+ 0 - 202
BansheeEngine/Source/BsGUIArea.cpp

@@ -1,202 +0,0 @@
-#include "BsGUIArea.h"
-#include "BsGUIWidget.h"
-#include "BsGUILayoutX.h"
-#include "BsGUILayoutY.h"
-#include "BsGUIPanel.h"
-#include "BsGUIWidget.h"
-#include "BsRenderWindow.h"
-#include "BsViewport.h"
-
-namespace BansheeEngine
-{
-	GUIArea::GUIArea(GUIWidget* widget, INT32 x, INT32 y, UINT16 depth, GUILayoutType layoutType)
-		:mWidget(widget), mLeft(x), mTop(y), mDepth(depth), mIsDirty(true), mIsDisabled(false), mLayout(nullptr),
-		mResizeXWithWidget(false), mResizeYWithWidget(false), mWidth(0), mHeight(0), mRight(0), mBottom(0)
-	{
-		switch (layoutType)
-		{
-		case GUILayoutType::LayoutX:
-			mLayout = bs_new<GUILayoutX>(this);
-			break;
-		case GUILayoutType::LayoutY:
-			mLayout = bs_new<GUILayoutY>(this);
-			break;
-		case GUILayoutType::LayoutExplicit:
-			mLayout = bs_new<GUIPanel>(this);
-			break;
-		}
-		
-		mLayout->_changeParentWidget(widget);
-
-		mWidget->registerArea(this);
-	}
-
-	GUIArea::~GUIArea() 
-	{
-		bs_delete(mLayout);
-	}
-
-	GUIArea* GUIArea::create(GUIWidget& widget, INT32 x, INT32 y, UINT32 width, UINT32 height, 
-		UINT16 depth, GUILayoutType layoutType)
-	{
-		GUIArea* area = new (bs_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, x, y, depth, layoutType);
-		area->mWidth = width;
-		area->mHeight = height;
-
-		return area;
-	}
-
-	GUIArea* GUIArea::createStretchedXY(GUIWidget& widget, UINT32 offsetLeft, 
-		UINT32 offsetRight, UINT32 offsetTop, UINT32 offsetBottom, UINT16 depth, GUILayoutType layoutType)
-	{
-		GUIArea* area = new (bs_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, offsetLeft, offsetTop, depth, layoutType);
-
-		area->mWidth = std::max(0, (INT32)widget.getTarget()->getWidth() - (INT32)offsetLeft - (INT32)offsetRight);
-		area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
-		area->mRight = offsetRight;
-		area->mBottom = offsetBottom;
-		area->mResizeXWithWidget = true;
-		area->mResizeYWithWidget = true;
-
-		return area;
-	}
-
-	GUIArea* GUIArea::createStretchedX(GUIWidget& widget, UINT32 offsetLeft, 
-		UINT32 offsetRight, UINT32 offsetTop, UINT32 height, UINT16 depth, GUILayoutType layoutType)
-	{
-		GUIArea* area = new (bs_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, offsetLeft, offsetTop, depth, layoutType);
-
-		area->mWidth = std::max(0, (INT32)widget.getTarget()->getWidth() - (INT32)offsetLeft - (INT32)offsetRight);
-		area->mHeight = height;
-		area->mRight = offsetRight;
-		area->mResizeXWithWidget = true;
-		area->mResizeYWithWidget = false;
-
-		return area;
-	}
-
-	GUIArea* GUIArea::createStretchedY(GUIWidget& widget, UINT32 offsetTop, 
-		UINT32 offsetBottom, UINT32 offsetLeft, UINT32 width, UINT16 depth, GUILayoutType layoutType)
-	{
-		GUIArea* area = new (bs_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, offsetLeft, offsetTop, depth, layoutType);
-
-		area->mWidth = width;
-		area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
-		area->mBottom = offsetBottom;
-		area->mResizeXWithWidget = false;
-		area->mResizeYWithWidget = true;
-
-		return area;
-	}
-
-	void GUIArea::destroy(GUIArea* area)
-	{
-		if(area->mWidget != nullptr)
-			area->mWidget->unregisterArea(area);
-
-		bs_delete<PoolAlloc>(area);
-	}
-
-	void GUIArea::destroyInternal(GUIArea* area)
-	{
-		bs_delete<PoolAlloc>(area);
-	}
-
-	void GUIArea::disable()
-	{
-		mIsDisabled = true;
-
-		mLayout->disableRecursively();
-	}
-
-	void GUIArea::enable()
-	{
-		mIsDisabled = false;
-
-		mLayout->enableRecursively();
-	}
-
-	void GUIArea::changeParentWidget(GUIWidget* widget)
-	{
-		if(mWidget == widget)
-			return;
-
-		if(mWidget != nullptr)
-			mWidget->unregisterArea(this);
-
-		if(widget != nullptr)
-			widget->registerArea(this);
-
-		mWidget = widget;
-
-		mLayout->_changeParentWidget(widget);
-
-		if(mWidget != nullptr)
-		{
-			// Ensure the size is valid, otherwise next GUI layout update will calculate wrong element coordinates
-			updateSizeBasedOnParent(mWidget->getTarget()->getWidth(), mWidget->getTarget()->getHeight());
-		}
-
-		mIsDirty = true;
-	}
-
-	void GUIArea::_update()
-	{
-		if(!mIsDisabled && isDirty() && (mWidget != nullptr))
-		{
-			Rect2I clipRect(mLeft, mTop, mWidth, mHeight);
-			if (mClipRect.width > 0 && mClipRect.height > 0)
-			{
-				Rect2I newClipRect = Rect2I(mLeft + mClipRect.x, mTop + mClipRect.y, mClipRect.width, mClipRect.height);
-				newClipRect.clip(clipRect);
-				clipRect = newClipRect;
-			}
-
-			mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, clipRect, mWidget->getDepth(), mDepth, -1);
-			mIsDirty = false;
-		}
-	}
-
-	bool GUIArea::isDirty() const
-	{
-		if(mIsDirty)
-			return true;
-
-		return mLayout->_isContentDirty();
-	}
-
-	void GUIArea::setPosition(INT32 x, INT32 y)
-	{
-		mLeft = x;
-		mTop = y;
-
-		mIsDirty = true;
-	}
-
-	void GUIArea::setSize(UINT32 width, UINT32 height)
-	{
-		mWidth = width;
-		mHeight = height;
-
-		mIsDirty = true;
-	}
-
-	void GUIArea::setClipRect(const Rect2I& clipRect)
-	{
-		mClipRect = clipRect;
-
-		mIsDirty = true;
-	}
-
-	void GUIArea::updateSizeBasedOnParent(UINT32 parentWidth, UINT32 parentHeight)
-	{
-		if(mResizeXWithWidget)
-			mWidth = (UINT32)std::max(0, (INT32)parentWidth - (INT32)mLeft - (INT32)mRight);
-
-		if(mResizeYWithWidget)
-			mHeight = (UINT32)std::max(0, (INT32)parentHeight - (INT32)mTop - (INT32)mBottom);
-
-		if(mResizeXWithWidget || mResizeYWithWidget)
-			mIsDirty = true;
-	}
-}

+ 0 - 1
BansheeEngine/Source/BsGUIDropDownContent.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIDropDownContent.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIButton.h"

+ 1 - 6
BansheeEngine/Source/BsGUILayout.cpp

@@ -7,16 +7,11 @@
 
 namespace BansheeEngine
 {
-	GUILayout::GUILayout(GUIArea* parentArea)
-		:mParentGUIArea(parentArea)
-	{ }
-
 	GUILayout::GUILayout(const GUIDimensions& dimensions)
-		:GUIElementBase(dimensions), mParentGUIArea(nullptr)
+		:GUIElementBase(dimensions)
 	{ }
 
 	GUILayout::GUILayout()
-		:mParentGUIArea(nullptr)
 	{ }
 
 	GUILayout::~GUILayout() 

+ 9 - 9
BansheeEngine/Source/BsGUILayoutUtility.cpp

@@ -1,9 +1,10 @@
 #include "BsGUILayoutUtility.h"
 #include "BsGUIElementBase.h"
 #include "BsGUILayout.h"
-#include "BsGUIArea.h"
 #include "BsGUIElement.h"
 #include "BsGUIElementStyle.h"
+#include "BsGUIWidget.h"
+#include "BsViewport.h"
 
 namespace BansheeEngine
 {
@@ -29,14 +30,13 @@ namespace BansheeEngine
 		}
 		else
 		{
-			assert(elem->_getType() == GUIElementBase::Type::Layout || elem->_getType() == GUIElementBase::Type::Panel);
-			const GUILayout* layout = static_cast<const GUILayout*>(elem);
-
-			GUIArea* parentGUIArea = layout->_getParentGUIArea();
-			parentArea.x = 0;
-			parentArea.y = 0;
-			parentArea.width = parentGUIArea->width();
-			parentArea.height = parentGUIArea->height();
+			GUIWidget* parentWidget = elem->_getParentWidget();
+
+			if (parentWidget != nullptr)
+			{
+				parentArea.width = parentWidget->getTarget()->getWidth();
+				parentArea.height = parentWidget->getTarget()->getHeight();
+			}
 
 			return parentArea;
 		}

+ 0 - 4
BansheeEngine/Source/BsGUILayoutX.cpp

@@ -6,10 +6,6 @@
 
 namespace BansheeEngine
 {
-	GUILayoutX::GUILayoutX(GUIArea* parentArea)
-		:GUILayout(parentArea)
-	{ }
-
 	GUILayoutX::GUILayoutX(const GUIDimensions& dimensions)
 		: GUILayout(dimensions)
 	{ }

+ 0 - 4
BansheeEngine/Source/BsGUILayoutY.cpp

@@ -6,10 +6,6 @@
 
 namespace BansheeEngine
 {
-	GUILayoutY::GUILayoutY(GUIArea* parentArea)
-		:GUILayout(parentArea)
-	{ }
-
 	GUILayoutY::GUILayoutY(const GUIDimensions& dimensions)
 		: GUILayout(dimensions)
 	{ }

+ 0 - 4
BansheeEngine/Source/BsGUIPanel.cpp

@@ -6,10 +6,6 @@
 
 namespace BansheeEngine
 {
-	GUIPanel::GUIPanel(GUIArea* parentArea)
-		:GUILayout(parentArea), mDepthOffset(0), mDepthRange(0)
-	{ }
-
 	GUIPanel::GUIPanel(UINT16 depth, UINT16 depthRange, const GUIDimensions& dimensions)
 		: GUILayout(dimensions), mDepthOffset(depth), mDepthRange(depthRange)
 	{ }

+ 4 - 39
BansheeEngine/Source/BsGUIWidget.cpp

@@ -3,7 +3,6 @@
 #include "BsGUISkin.h"
 #include "BsGUILabel.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIArea.h"
 #include "BsGUIPanel.h"
 #include "BsCoreApplication.h"
 #include "BsCoreThreadAccessor.h"
@@ -54,11 +53,6 @@ namespace BansheeEngine
 			mOwnerTargetResizedConn.disconnect();
 		}
 
-		for (auto& area : mAreas)
-		{
-			GUIArea::destroyInternal(area);
-		}
-
 		mElements.clear();
 	}
 
@@ -105,14 +99,12 @@ namespace BansheeEngine
 
 	void GUIWidget::_updateLayout()
 	{
-		for(auto& area : mAreas)
+		if (mPanel->_isContentDirty())
 		{
-			area->_update();
+			Rect2I clipRect(0, 0, getTarget()->getWidth(), getTarget()->getHeight());
+			mPanel->_updateLayout(0, 0, getTarget()->getWidth(), getTarget()->getHeight(), clipRect,
+				getDepth(), 0, -1);
 		}
-
-		Rect2I clipRect(0, 0, getTarget()->getWidth(), getTarget()->getHeight());
-		mPanel->_updateLayout(0, 0, getTarget()->getWidth(), getTarget()->getHeight(), clipRect, 
-			getDepth(), 0, -1);
 	}
 
 	bool GUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
@@ -157,28 +149,6 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIWidget::registerArea(GUIArea* area)
-	{
-		assert(area != nullptr);
-
-		mAreas.push_back(area);
-
-		mWidgetIsDirty = true;
-	}
-
-	void GUIWidget::unregisterArea(GUIArea* area)
-	{
-		assert(area != nullptr);
-
-		auto iterFind = std::find(begin(mAreas), end(mAreas), area);
-
-		if(iterFind == mAreas.end())
-			BS_EXCEPT(InvalidParametersException, "Cannot unregister an area that is not registered on this widget.");
-
-		mAreas.erase(iterFind);
-		mWidgetIsDirty = true;
-	}
-
 	void GUIWidget::setSkin(const HGUISkin& skin)
 	{
 		mSkin = skin;
@@ -269,11 +239,6 @@ namespace BansheeEngine
 
 	void GUIWidget::ownerTargetResized()
 	{
-		for(auto& area : mAreas)
-		{
-			area->updateSizeBasedOnParent(getTarget()->getWidth(), getTarget()->getHeight());
-		}
-
 		mPanel->setWidth(getTarget()->getWidth());
 		mPanel->setHeight(getTarget()->getHeight());
 	}

+ 0 - 1
ExampleProject/Main/Main.cpp

@@ -13,7 +13,6 @@
 #include "BsCamera.h"
 #include "BsRenderable.h"
 #include "BsGUIWidget.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
 #include "BsGUISpace.h"

+ 11 - 8
MBansheeEditor/ColorPicker.cs

@@ -148,7 +148,7 @@ namespace BansheeEditor
             guiOK.OnClick += OnOK;
             guiCancel.OnClick += OnCancel;
 
-            GUILayout v0 = GUI.layout.AddLayoutY();
+            GUILayout v0 = GUI.AddLayoutY();
 
             v0.AddSpace(5);
 
@@ -224,13 +224,16 @@ namespace BansheeEditor
 
             v0.AddSpace(5);
 
-            GUIArea overlay = GUI.AddArea(0, 0, Width, Height, -1, GUILayoutType.Explicit);
-            overlay.layout.AddElement(guiSliderVert);
-            overlay.layout.AddElement(guiSliderRHorz);
-            overlay.layout.AddElement(guiSliderGHorz);
-            overlay.layout.AddElement(guiSliderBHorz);
-            overlay.layout.AddElement(guiSliderAHorz);
-            overlay.layout.AddElement(guiSlider2DHandle);
+            GUIPanel overlay = GUI.AddPanel(-1);
+            overlay.SetWidth(Width);
+            overlay.SetHeight(Height);
+
+            overlay.AddElement(guiSliderVert);
+            overlay.AddElement(guiSliderRHorz);
+            overlay.AddElement(guiSliderGHorz);
+            overlay.AddElement(guiSliderBHorz);
+            overlay.AddElement(guiSliderAHorz);
+            overlay.AddElement(guiSlider2DHandle);
 
             colorBox = new ColorSlider2D(guiSlider2DTex, guiSlider2DHandle, ColorBoxWidth, ColorBoxHeight);
             sideSlider = new ColorSlider1DVert(guiSliderVertTex, guiSliderVert, SliderSideWidth, SliderSideHeight);

+ 9 - 5
MBansheeEditor/DebugWindow.cs

@@ -24,14 +24,18 @@ namespace BansheeEditor
             GUIButton openColorPicker = new GUIButton("Color picker");
             openColorPicker.OnClick += OpenColorPicker;
 
-            GUI.layout.AddElement(refreshAssembly);
-            GUI.layout.AddElement(compileGame);
-            GUI.layout.AddElement(openColorPicker);
+            GUILayout horzLayout = GUI.AddLayoutX();
+
+            horzLayout.AddElement(refreshAssembly);
+            horzLayout.AddElement(compileGame);
+            horzLayout.AddElement(openColorPicker);
 
             GUIButton testExplicitBtn = new GUIButton("TESTING EXPLICIT");
             testExplicitBtn.Bounds = compileGame.Bounds;
-            GUIArea overlay = GUI.AddArea(0, 0, Width, Height, -1, GUILayoutType.Explicit);
-            overlay.layout.AddElement(testExplicitBtn);
+            GUIPanel overlay = GUI.AddPanel(-1);
+            overlay.SetWidth(Width);
+            overlay.SetHeight(Height);
+            overlay.AddElement(testExplicitBtn);
         }
 
         [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]

+ 1 - 1
MBansheeEditor/DialogBox.cs

@@ -74,7 +74,7 @@ namespace BansheeEditor
         {
             messageLabel = new GUILabel("");
 
-            GUILayoutY layoutY = GUI.layout.AddLayoutY();
+            GUILayoutY layoutY = GUI.AddLayoutY();
 
             layoutY.AddFlexibleSpace();
             GUILayoutX messageLayout = layoutY.AddLayoutX();

+ 1 - 39
MBansheeEditor/EditorWindow.cs

@@ -12,7 +12,6 @@ namespace BansheeEditor
         public bool HasFocus { get { return Internal_HasFocus(mCachedPtr); } }
 
         protected GUIPanel GUI;
-        private List<GUIPanel> panels = new List<GUIPanel>();
 
         public static T OpenWindow<T>() where T : EditorWindow
         {
@@ -33,22 +32,9 @@ namespace BansheeEditor
             return screenPos;
         }
 
-        private void OnInitializeInternal()
-        {
-            GUI = CreatePanel(0, 0, Width, Height);
-        }
-
-        private void OnDestroyInternal()
-        {
-            GUIPanel[] panelsCopy = panels.ToArray();
-
-            for (int i = 0; i < panelsCopy.Length; i++)
-                DestroyPanel(panelsCopy[i]);
-        }
-
         protected virtual void WindowResized(int width, int height)
         {
-            GUI.SetArea(0, 0, width, height);
+
         }
 
         protected virtual void FocusChanged(bool inFocus)
@@ -56,33 +42,9 @@ namespace BansheeEditor
             
         }
 
-        internal GUIPanel CreatePanel(int x, int y, int width, int height)
-        {
-            GUIPanel newPanel = new GUIPanel();
-            Internal_InitializeGUIPanel(mCachedPtr, newPanel);
-            newPanel.Initialize();
-            newPanel.SetArea(x, y, width, height);
-
-            panels.Add(newPanel);
-            return newPanel;
-        }
-
-        internal void DestroyPanel(GUIPanel panel)
-        {
-            panel.Destroy();
-            panels.Remove(panel);
-            Internal_DestroyGUIPanel(mCachedPtr, panel);
-        }
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DestroyGUIPanel(IntPtr nativeInstance, GUIPanel panel);
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
 

+ 2 - 2
MBansheeEditor/Inspector/Inspector.cs

@@ -8,13 +8,13 @@ namespace BansheeEditor
 {
     public abstract class Inspector
     {
-        protected GUIPanelNEW GUI;
+        protected GUIPanel GUI;
         protected GUILayoutY layout;
         protected object referencedObject;
 
         private InspectorWindow parentWindow;
 
-        internal void Initialize(InspectorWindow parentWindow, GUIPanelNEW gui, object instance)
+        internal void Initialize(InspectorWindow parentWindow, GUIPanel gui, object instance)
         {
             GUI = gui;
             layout = gui.AddLayoutY();

+ 2 - 2
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -9,7 +9,7 @@ namespace BansheeEditor
         private class InspectorData
         {
             public GUIComponentFoldout foldout;
-            public GUIPanelNEW panel;
+            public GUIPanel panel;
             public Inspector inspector;
             public bool expanded = true;
         }
@@ -25,7 +25,7 @@ namespace BansheeEditor
             // TODO - Create SceneObject gui elements (name + transform)
 
             inspectorScrollArea = new GUIScrollArea();
-            GUI.layout.AddElement(inspectorScrollArea);
+            GUI.AddElement(inspectorScrollArea);
             inspectorLayout = inspectorScrollArea.layout;
 
             Component[] allComponents = so.GetComponents();

+ 1 - 17
MBansheeEditor/ModalWindow.cs

@@ -45,22 +45,9 @@ namespace BansheeEditor
             return screenPos;
         }
 
-        private void OnInitializeInternal()
-        {
-            GUI = new GUIPanel();
-            Internal_InitializeGUIPanel(mCachedPtr, GUI);
-            GUI.Initialize();
-            GUI.SetArea(0, 0, Width, Height);
-        }
-
-        private void OnDestroyInternal()
-        {
-            GUI.Destroy();
-        }
-
         protected virtual void OnWindowResized(int width, int height)
         {
-            GUI.SetArea(0, 0, width, height);
+
         }
 
         protected void Close()
@@ -82,9 +69,6 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetTitle(IntPtr nativeInstance, LocString title);
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
 

+ 1 - 1
MBansheeEditor/ProgressBar.cs

@@ -56,7 +56,7 @@ namespace BansheeEditor
             progressBar = new GUIProgressBar();
             messageLabel = new GUILabel("");
 
-            GUILayoutY layoutY = GUI.layout.AddLayoutY();
+            GUILayoutY layoutY = GUI.AddLayoutY();
 
             layoutY.AddFlexibleSpace();
             GUILayoutX messageLayout = layoutY.AddLayoutX();

+ 1 - 1
MBansheeEditor/ProjectWindow.cs

@@ -37,7 +37,7 @@ namespace BansheeEditor
             ProjectLibrary.OnEntryRemoved += OnEntryChanged;
 
             contentScrollArea = new GUIScrollArea(GUIOption.FlexibleWidth(), GUIOption.FlexibleHeight());
-            GUI.layout.AddElement(contentScrollArea);
+            GUI.AddElement(contentScrollArea);
 
             Reset();
         }

+ 1 - 1
MBansheeEditor/Scene/SceneWindow.cs

@@ -48,7 +48,7 @@ namespace BansheeEditor
 
         private void OnInitialize()
         {
-            mainLayout = GUI.layout.AddLayoutY();
+            mainLayout = GUI.AddLayoutY();
 
             GUIToggleGroup handlesTG = new GUIToggleGroup();
             viewButton = new GUIToggle("V", handlesTG, EditorStyles.Button);

+ 0 - 85
MBansheeEngine/GUI/GUIArea.cs

@@ -1,85 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    public sealed class GUIArea : ScriptObject
-    {
-        private GUILayout _layout;
-        private GUIPanel parent;
-        private bool isDestroyed;
-
-        public GUILayout layout
-        {
-            get { return _layout;}
-        }
-
-        internal GUIArea()
-        { }
-
-        internal void SetParent(GUIPanel parent)
-        {
-            if (this.parent != null)
-                this.parent.childAreas.Remove(this);
-
-            this.parent = parent;
-
-            if(parent != null)
-                parent.childAreas.Add(this);
-        }
-
-        // Note: Should only ever be called by its parent GUIPanel
-        internal static GUIArea Create(GUIPanel parent, int x, int y, int width, int height, Int16 depth, GUILayoutType layoutType)
-        {
-            GUIArea newArea = new GUIArea();
-            Internal_CreateInstance(newArea, parent, x, y, width, height, depth, layoutType);
-            newArea._layout = new GUILayoutX(newArea);
-            newArea.SetArea(x, y, width, height, depth);
-
-            return newArea;
-        }
-
-        public void SetArea(int x, int y, int width, int height, Int16 depth = 0)
-        {
-            Internal_SetArea(mCachedPtr, x, y, width, height, depth);
-        }
-
-        public void SetVisible(bool visible)
-        {
-            Internal_SetVisible(mCachedPtr, visible);
-        }
-
-        public bool IsDestroyed()
-        {
-            return isDestroyed;
-        }
-
-        public void Destroy()
-        {
-            SetParent(null);
-            _layout.Destroy();
-            isDestroyed = true;
-
-            Internal_Destroy(mCachedPtr);
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUIArea instance, GUIPanel parent, int x, int y, 
-            int width, int height, Int16 depth, GUILayoutType layoutType);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetArea(IntPtr nativeInstance, int x, int y, int width, int height, Int16 depth);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_Destroy(IntPtr nativeInstance);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetVisible(IntPtr nativeInstance, bool visible);
-    }
-
-    // Note: Must have same layout as GUILayoutType
-    public enum GUILayoutType
-    {
-        X, Y, Explicit
-    }
-}

+ 9 - 12
MBansheeEngine/GUI/GUILayout.cs

@@ -127,16 +127,16 @@ namespace BansheeEngine
             return layout;
         }
 
-        public GUIPanelNEW AddPanel(params GUIOption[] options)
+        public GUIPanel AddPanel(params GUIOption[] options)
         {
-            GUIPanelNEW layout = new GUIPanelNEW(options);
+            GUIPanel layout = new GUIPanel(options);
             AddElement(layout);
             return layout;
         }
 
-        public GUIPanelNEW AddPanel(ushort depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
+        public GUIPanel AddPanel(Int16 depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
         {
-            GUIPanelNEW layout = new GUIPanelNEW(depth, depthRange, options);
+            GUIPanel layout = new GUIPanel(depth, depthRange, options);
             AddElement(layout);
             return layout;
         }
@@ -169,16 +169,16 @@ namespace BansheeEngine
             return layout;
         }
 
-        public GUIPanelNEW InsertPanel(int idx, params GUIOption[] options)
+        public GUIPanel InsertPanel(int idx, params GUIOption[] options)
         {
-            GUIPanelNEW layout = new GUIPanelNEW(options);
+            GUIPanel layout = new GUIPanel(options);
             InsertElement(idx, layout);
             return layout;
         }
 
-        public GUIPanelNEW InsertPanel(int idx, ushort depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
+        public GUIPanel InsertPanel(int idx, Int16 depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
         {
-            GUIPanelNEW layout = new GUIPanelNEW(depth, depthRange, options);
+            GUIPanel layout = new GUIPanel(depth, depthRange, options);
             InsertElement(idx, layout);
             return layout;
         }
@@ -197,9 +197,6 @@ namespace BansheeEngine
             return space;
         }
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        protected static extern void Internal_CreateInstanceXFromArea(GUILayout instance, GUIArea parentArea);
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_CreateInstanceYFromScrollArea(GUILayout instance, GUIScrollArea parentArea);
 
@@ -210,7 +207,7 @@ namespace BansheeEngine
         protected static extern void Internal_CreateInstanceY(GUILayout instance, GUIOption[] options);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        protected static extern void Internal_CreateInstancePanel(GUILayout instance, ushort depth, ushort depthRange, GUIOption[] options);
+        protected static extern void Internal_CreateInstancePanel(GUILayout instance, Int16 depth, ushort depthRange, GUIOption[] options);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_AddElement(IntPtr instance, IntPtr element);

+ 0 - 5
MBansheeEngine/GUI/GUILayoutX.cs

@@ -9,10 +9,5 @@ namespace BansheeEngine
         {
             Internal_CreateInstanceX(this, options);
         }
-
-        internal GUILayoutX(GUIArea parentArea)
-        {
-            Internal_CreateInstanceXFromArea(this, parentArea);
-        }
     }
 }

+ 7 - 55
MBansheeEngine/GUI/GUIPanel.cs

@@ -1,69 +1,21 @@
 using System;
-using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 
 namespace BansheeEngine
 {
-    public sealed class GUIPanel : ScriptObject
+    public sealed class GUIPanel : GUILayout
     {
-        private GUIArea mainArea;
-        private GUILayout _mainLayout;
+        private GUIPanel()
+        { }
 
-        internal List<GUIArea> childAreas = new List<GUIArea>();
-
-        public GUILayout layout
-        {
-            get { return _mainLayout; }
-        }
-
-        public GUISkin skin; // TODO
-
-        internal GUIPanel()
-        {
-            Internal_CreateInstance(this);
-        }
-
-        internal void Initialize()
-        {
-            mainArea = AddArea(0, 0, 0, 0);
-            _mainLayout = mainArea.layout;
-        }
-
-        public GUIArea AddArea(int x, int y, int width, int height, Int16 depth = 0, GUILayoutType layoutType = GUILayoutType.X)
+        public GUIPanel(Int16 depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
         {
-            GUIArea area = GUIArea.Create(this, x, y, width, height, depth, layoutType);
-            area.SetParent(this);
-
-            return area;
-        }
-
-        public void SetVisible(bool visible)
-        {
-            for (int i = 0; i < childAreas.Count; i++)
-                childAreas[i].SetVisible(visible);
+            Internal_CreateInstancePanel(this, depth, depthRange, options);
         }
 
-        internal void SetArea(int x, int y, int width, int height)
+        public GUIPanel(params GUIOption[] options)
         {
-            Internal_SetArea(mCachedPtr, x, y, width, height);
-
-            mainArea.SetArea(0, 0, width, height);
+            Internal_CreateInstancePanel(this, 0, ushort.MaxValue, options);
         }
-
-        // Note: Only to be called from EditorWindow.DestroyPanel
-        internal void Destroy()
-        {
-            GUIArea[] tempAreas = childAreas.ToArray();
-            for (int i = 0; i < tempAreas.Length; i++)
-                tempAreas[i].Destroy();
-
-            childAreas.Clear();
-        }
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetArea(IntPtr nativeInstance, int x, int y, int width, int height);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUIPanel instance);
     }
 }

+ 0 - 18
MBansheeEngine/GUI/GUIPanelNEW.cs

@@ -1,18 +0,0 @@
-using System;
-using System.Runtime.CompilerServices;
-
-namespace BansheeEngine
-{
-    public sealed class GUIPanelNEW : GUILayout
-    {
-        public GUIPanelNEW(ushort depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
-        {
-            Internal_CreateInstancePanel(this, depth, depthRange, options);
-        }
-
-        public GUIPanelNEW(params GUIOption[] options)
-        {
-            Internal_CreateInstancePanel(this, 0, ushort.MaxValue, options);
-        }
-    }
-}

+ 1 - 3
MBansheeEngine/MBansheeEngine.csproj

@@ -57,16 +57,14 @@
     <Compile Include="DontSerializeField.cs" />
     <Compile Include="Font.cs" />
     <Compile Include="GameObject.cs" />
-    <Compile Include="GUI\GUIArea.cs" />
     <Compile Include="GUI\GUILayoutUtility.cs" />
-    <Compile Include="GUI\GUIPanel.cs" />
     <Compile Include="GUI\GUIButton.cs" />
     <Compile Include="GUI\GUIContent.cs" />
     <Compile Include="GUI\GUIElement.cs" />
     <Compile Include="GUI\GUIElementStateStyle.cs" />
     <Compile Include="GUI\GUIElementStyle.cs" />
     <Compile Include="GUI\GUIListBox.cs" />
-    <Compile Include="GUI\GUIPanelNEW.cs" />
+    <Compile Include="GUI\GUIPanel.cs" />
     <Compile Include="GUI\GUIProgressBar.cs" />
     <Compile Include="GUI\GUIRenderTexture.cs" />
     <Compile Include="GUI\GUIScrollArea.cs" />

+ 1 - 10
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -39,12 +39,7 @@ namespace BansheeEngine
 		static UINT32 internal_getWidth(ScriptEditorWindow* thisPtr);
 		static UINT32 internal_getHeight(ScriptEditorWindow* thisPtr);
 
-		static void internal_initializeGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel);
-		static void internal_destroyGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel);
-
-		void onWidgetMoved(INT32 x, INT32 y);
 		void onWidgetResized(UINT32 width, UINT32 height);
-		void onWidgetParentChanged(EditorWidgetContainer* newParent);
 		void onFocusChanged(bool inFocus);
 		void onAssemblyRefreshStarted();
 
@@ -55,18 +50,14 @@ namespace BansheeEngine
 
 		String mName;
 		ScriptEditorWidget* mEditorWidget;
-		Vector<ScriptGUIPanel*> mPanels;
-		HEvent mOnWidgetMovedConn;
 		HEvent mOnWidgetResizedConn;
-		HEvent mOnParentChangedConn;
 		HEvent mOnFocusChangedConn;
 		HEvent mOnAssemblyRefreshStartedConn;
 		bool mRefreshInProgress;
 
 		static MonoMethod* onResizedMethod;
 		static MonoMethod* onFocusChangedMethod;
-		static MonoMethod* onInitializedInternalMethod;
-		static MonoMethod* onDestroyInternalMethod;
+		static MonoField* guiPanelField;
 
 		// Global editor window management methods
 		static void registerScriptEditorWindow(ScriptEditorWindow* editorWindow);

+ 1 - 4
SBansheeEditor/Include/BsScriptModalWindow.h

@@ -32,7 +32,6 @@ namespace BansheeEngine
 		static UINT32 internal_getHeight(ScriptModalWindow* thisPtr);
 		static void internal_setWidth(ScriptModalWindow* thisPtr, UINT32 value);
 		static void internal_setHeight(ScriptModalWindow* thisPtr, UINT32 value);
-		static void internal_initializeGUIPanel(ScriptModalWindow* thisPtr, MonoObject* panel);
 		static void internal_setTitle(ScriptModalWindow* thisPtr, MonoObject* title);
 		static void internal_screenToWindowPos(ScriptModalWindow* thisPtr, Vector2I screenPos, Vector2I* windowPos);
 		static void internal_windowToScreenPos(ScriptModalWindow* thisPtr, Vector2I windowPos, Vector2I* screenPos);
@@ -46,12 +45,10 @@ namespace BansheeEngine
 		void closeWindow();
 
 		ManagedModalWindow* mModalWindow;
-		ScriptGUIPanel* mGUIPanel;
 		HEvent mOnAssemblyRefreshStartedConn;
 		bool mRefreshInProgress;
 
-		static MonoMethod* onInitializedInternalMethod;
-		static MonoMethod* onDestroyInternalMethod;
+		static MonoField* guiPanelField;
 	};
 
 	class BS_SCR_BED_EXPORT ManagedModalWindow : public ModalWindow

+ 0 - 1
SBansheeEditor/Source/BsGUIGameObjectField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIGameObjectField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILabel.h"
 #include "BsGUIDropButton.h"

+ 0 - 1
SBansheeEditor/Source/BsGUIResourceField.cpp

@@ -1,5 +1,4 @@
 #include "BsGUIResourceField.h"
-#include "BsGUIArea.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILabel.h"
 #include "BsGUIDropButton.h"

+ 7 - 63
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -1,6 +1,5 @@
 #include "BsScriptEditorWindow.h"
 #include "BsScriptMeta.h"
-#include "BsScriptGUIPanel.h"
 #include "BsMonoField.h"
 #include "BsMonoClass.h"
 #include "BsMonoMethod.h"
@@ -11,6 +10,7 @@
 #include "BsEditorWidgetContainer.h"
 #include "BsMonoAssembly.h"
 #include "BsScriptObjectManager.h"
+#include "BsScriptGUILayout.h"
 
 using namespace std::placeholders;
 
@@ -20,15 +20,12 @@ namespace BansheeEngine
 	Vector<String> ScriptEditorWindow::AvailableWindowTypes;
 	MonoMethod* ScriptEditorWindow::onResizedMethod = nullptr;
 	MonoMethod* ScriptEditorWindow::onFocusChangedMethod = nullptr;
-	MonoMethod* ScriptEditorWindow::onInitializedInternalMethod = nullptr;
-	MonoMethod* ScriptEditorWindow::onDestroyInternalMethod = nullptr;
+	MonoField* ScriptEditorWindow::guiPanelField = nullptr;
 
 	ScriptEditorWindow::ScriptEditorWindow(ScriptEditorWidget* editorWidget)
 		:ScriptObject(editorWidget->getManagedInstance()), mName(editorWidget->getName()), mEditorWidget(editorWidget), mRefreshInProgress(false)
 	{
-		mOnWidgetMovedConn = editorWidget->onMoved.connect(std::bind(&ScriptEditorWindow::onWidgetMoved, this, _1, _2));
 		mOnWidgetResizedConn = editorWidget->onResized.connect(std::bind(&ScriptEditorWindow::onWidgetResized, this, _1, _2));
-		mOnParentChangedConn = editorWidget->onParentChanged.connect(std::bind(&ScriptEditorWindow::onWidgetParentChanged, this, _1));
 		mOnFocusChangedConn = editorWidget->onFocusChanged.connect(std::bind(&ScriptEditorWindow::onFocusChanged, this, _1));
 
 		mOnAssemblyRefreshStartedConn = ScriptObjectManager::instance().onRefreshStarted.connect(std::bind(&ScriptEditorWindow::onAssemblyRefreshStarted, this));
@@ -37,9 +34,7 @@ namespace BansheeEngine
 	ScriptEditorWindow::~ScriptEditorWindow()
 	{
 		// TODO - This probably need to be called whenever we close a window, and not when script class is destructed
-		mOnWidgetMovedConn.disconnect();
 		mOnWidgetResizedConn.disconnect();
-		mOnParentChangedConn.disconnect();
 		mOnFocusChangedConn.disconnect();
 
 		mOnAssemblyRefreshStartedConn.disconnect();
@@ -48,8 +43,6 @@ namespace BansheeEngine
 	void ScriptEditorWindow::initRuntimeData()
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateOrGetInstance", &ScriptEditorWindow::internal_createOrGetInstance);
-		metaData.scriptClass->addInternalCall("Internal_InitializeGUIPanel", &ScriptEditorWindow::internal_initializeGUIPanel);
-		metaData.scriptClass->addInternalCall("Internal_DestroyGUIPanel", &ScriptEditorWindow::internal_destroyGUIPanel);
 		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptEditorWindow::internal_getWidth);
 		metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptEditorWindow::internal_getHeight);
 		metaData.scriptClass->addInternalCall("Internal_HasFocus", &ScriptEditorWindow::internal_hasFocus);
@@ -58,8 +51,8 @@ namespace BansheeEngine
 
 		onResizedMethod = metaData.scriptClass->getMethod("WindowResized", 2);
 		onFocusChangedMethod = metaData.scriptClass->getMethod("FocusChanged", 1);
-		onInitializedInternalMethod = metaData.scriptClass->getMethod("OnInitializeInternal", 0);
-		onDestroyInternalMethod = metaData.scriptClass->getMethod("OnDestroyInternal", 0);
+
+		guiPanelField = metaData.scriptClass->getField("GUI");
 	}
 
 	MonoObject* ScriptEditorWindow::internal_createOrGetInstance(MonoString* ns, MonoString* typeName)
@@ -175,58 +168,12 @@ namespace BansheeEngine
 		return thisPtr->mEditorWidget->getHeight();
 	}
 
-	void ScriptEditorWindow::internal_initializeGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel)
-	{
-		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
-		thisPtr->mPanels.push_back(scriptGUIPanel);
-
-		scriptGUIPanel->setParentArea(thisPtr->mEditorWidget->getX(), thisPtr->mEditorWidget->getY(), 
-			thisPtr->mEditorWidget->getWidth(), thisPtr->mEditorWidget->getHeight());
-
-		scriptGUIPanel->setParentWidget(&thisPtr->mEditorWidget->_getParent()->getParentWidget());
-	}
-
-	void ScriptEditorWindow::internal_destroyGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel)
-	{
-		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
-
-		auto findIter = std::find(thisPtr->mPanels.begin(), thisPtr->mPanels.end(), scriptGUIPanel);
-		if (findIter != thisPtr->mPanels.end())
-			thisPtr->mPanels.erase(findIter);
-	}
-
-	void ScriptEditorWindow::onWidgetMoved(INT32 x, INT32 y)
-	{
-		for(auto& panel : mPanels)
-		{
-			panel->setParentArea(x, y, 
-				mEditorWidget->getWidth(), mEditorWidget->getHeight());
-		}
-	}
-
 	void ScriptEditorWindow::onWidgetResized(UINT32 width, UINT32 height)
 	{
-		for(auto& panel : mPanels)
-		{
-			panel->setParentArea(mEditorWidget->getX(), mEditorWidget->getY(), 
-				width, height);
-		}
-
 		void* params[2] = { &width, &height };
 		onResizedMethod->invokeVirtual(mManagedInstance, params);
 	}
 
-	void ScriptEditorWindow::onWidgetParentChanged(EditorWidgetContainer* newParent)
-	{
-		for(auto& panel : mPanels)
-		{
-			if(newParent != nullptr)
-				panel->setParentWidget(&newParent->getParentWidget());
-			else
-				panel->setParentWidget(nullptr);
-		}
-	}
-
 	void ScriptEditorWindow::onFocusChanged(bool inFocus)
 	{
 		void* params[1] = { &inFocus};
@@ -331,6 +278,9 @@ namespace BansheeEngine
 			{
 				mManagedInstance = editorWindowClass->createInstance();
 
+				MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContent);
+				ScriptEditorWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+
 				reloadMonoTypes(editorWindowClass);
 				return true;
 			}
@@ -341,9 +291,6 @@ namespace BansheeEngine
 
 	void ScriptEditorWidget::triggerOnInitialize()
 	{
-		if (mManagedInstance != nullptr)
-			ScriptEditorWindow::onInitializedInternalMethod->invoke(mManagedInstance, nullptr);
-
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
 			MonoException* exception = nullptr;
@@ -358,9 +305,6 @@ namespace BansheeEngine
 
 	void ScriptEditorWidget::triggerOnDestroy()
 	{
-		if (mManagedInstance != nullptr)
-			ScriptEditorWindow::onDestroyInternalMethod->invoke(mManagedInstance, nullptr);
-
 		if (mOnDestroyThunk != nullptr && mManagedInstance != nullptr)
 		{
 			MonoException* exception = nullptr;

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIColorField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIComponentFoldout.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIFloatField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIFoldout.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIGameObjectField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 #include "BsScriptGameObject.h"

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIIntField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIResourceField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 #include "BsScriptResource.h"

+ 0 - 1
SBansheeEditor/Source/BsScriptGUITextField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIToggleField.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIVector2Field.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIVector3Field.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEditor/Source/BsScriptGUIVector4Field.cpp

@@ -12,7 +12,6 @@
 #include "BsGUIContent.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 9 - 25
SBansheeEditor/Source/BsScriptModalWindow.cpp

@@ -1,6 +1,5 @@
 #include "BsScriptModalWindow.h"
 #include "BsScriptMeta.h"
-#include "BsScriptGUIPanel.h"
 #include "BsMonoField.h"
 #include "BsMonoClass.h"
 #include "BsMonoMethod.h"
@@ -10,13 +9,13 @@
 #include "BsScriptObjectManager.h"
 #include "BsScriptHString.h"
 #include "BsRenderWindow.h"
+#include "BsScriptGUILayout.h"
 
 using namespace std::placeholders;
 
 namespace BansheeEngine
 {
-	MonoMethod* ScriptModalWindow::onInitializedInternalMethod = nullptr;
-	MonoMethod* ScriptModalWindow::onDestroyInternalMethod = nullptr;
+	MonoField* ScriptModalWindow::guiPanelField = nullptr;
 
 	ScriptModalWindow::ScriptModalWindow(ManagedModalWindow* window)
 		:ScriptObject(window->getManagedInstance()), mModalWindow(window), mRefreshInProgress(false)
@@ -33,7 +32,6 @@ namespace BansheeEngine
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptModalWindow::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_Close", &ScriptModalWindow::internal_close);
-		metaData.scriptClass->addInternalCall("Internal_InitializeGUIPanel", &ScriptModalWindow::internal_initializeGUIPanel);
 		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptModalWindow::internal_getWidth);
 		metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptModalWindow::internal_getHeight);
 		metaData.scriptClass->addInternalCall("Internal_SetWidth", &ScriptModalWindow::internal_setWidth);
@@ -42,8 +40,7 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_ScreenToWindowPos", &ScriptModalWindow::internal_screenToWindowPos);
 		metaData.scriptClass->addInternalCall("Internal_WindowToScreenPos", &ScriptModalWindow::internal_windowToScreenPos);
 
-		onInitializedInternalMethod = metaData.scriptClass->getMethod("OnInitializeInternal", 0);
-		onDestroyInternalMethod = metaData.scriptClass->getMethod("OnDestroyInternal", 0);
+		guiPanelField = metaData.scriptClass->getField("GUI");
 	}
 
 	void ScriptModalWindow::internal_createInstance(MonoObject* instance, bool allowCloseButton)
@@ -172,16 +169,6 @@ namespace BansheeEngine
 			thisPtr->mModalWindow->setSize(thisPtr->mModalWindow->getWidth(), value);
 	}
 
-	void ScriptModalWindow::internal_initializeGUIPanel(ScriptModalWindow* thisPtr, MonoObject* panel)
-	{
-		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
-		thisPtr->mGUIPanel = scriptGUIPanel;
-
-		Rect2I contentArea = thisPtr->mModalWindow->getContentArea();
-		scriptGUIPanel->setParentArea(contentArea.x, contentArea.y, contentArea.width, contentArea.height);
-		scriptGUIPanel->setParentWidget(thisPtr->mModalWindow->getGUIWidget().get());
-	}
-
 	void ScriptModalWindow::internal_screenToWindowPos(ScriptModalWindow* thisPtr, Vector2I screenPos, Vector2I* windowPos)
 	{
 		RenderWindowPtr parentRenderWindow = thisPtr->mModalWindow->getRenderWindow();
@@ -201,6 +188,9 @@ namespace BansheeEngine
 	{
 		mGCHandle = mono_gchandle_new(mManagedInstance, false);
 
+		MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContents);
+		ScriptModalWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+
 		::MonoClass* rawMonoClass = mono_object_get_class(mManagedInstance);
 		MonoClass* monoClass = MonoManager::instance().findClass(rawMonoClass);
 
@@ -228,6 +218,9 @@ namespace BansheeEngine
 				mManagedInstance = editorWindowClass->createInstance();
 				mGCHandle = mono_gchandle_new(mManagedInstance, false);
 
+				MonoObject* guiPanel = ScriptGUIPanel::createFromExisting(mContents);
+				ScriptModalWindow::guiPanelField->setValue(mManagedInstance, guiPanel);
+
 				reloadMonoTypes(editorWindowClass);
 				return true;
 			}
@@ -244,9 +237,6 @@ namespace BansheeEngine
 
 	void ManagedModalWindow::triggerOnInitialize()
 	{
-		if (mManagedInstance != nullptr)
-			ScriptModalWindow::onInitializedInternalMethod->invoke(mManagedInstance, nullptr);
-
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
 			MonoException* exception = nullptr;
@@ -261,9 +251,6 @@ namespace BansheeEngine
 
 	void ManagedModalWindow::triggerOnDestroy()
 	{
-		if (mManagedInstance != nullptr)
-			ScriptModalWindow::onDestroyInternalMethod->invoke(mManagedInstance, nullptr);
-
 		if (mOnDestroyThunk != nullptr && mManagedInstance != nullptr)
 		{
 			MonoException* exception = nullptr;
@@ -300,9 +287,6 @@ namespace BansheeEngine
 		UINT32 width = getWidth();
 		UINT32 height = getHeight();
 
-		Rect2I contentArea = getContentArea();
-		mScriptParent->mGUIPanel->setParentArea(contentArea.x, contentArea.y, contentArea.width, contentArea.height);
-
 		if (mOnWindowResizedMethod != nullptr && mManagedInstance != nullptr)
 		{
 			void* params[] = { &width, &height };

+ 0 - 2
SBansheeEngine/Include/BsScriptEnginePrerequisites.h

@@ -32,8 +32,6 @@ namespace BansheeEngine
 	class ScriptScriptCode;
 	class ScriptGUIElementStyle;
 	class ScriptGUIElementStateStyle;
-	class ScriptGUIPanel;
-	class ScriptGUIArea;
 	class ScriptGUILayout;
 	class ScriptGUILabel;
 	class ScriptGameObjectBase;

+ 0 - 36
SBansheeEngine/Include/BsScriptGUIArea.h

@@ -1,36 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsRect2I.h"
-
-namespace BansheeEngine
-{
-	class BS_SCR_BE_EXPORT ScriptGUIArea : public ScriptObject<ScriptGUIArea>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIArea")
-
-		GUIArea* getInternalValue() const { return mGUIArea; }
-		void* getNativeRaw() const { return mGUIArea; }
-
-		void updateArea();
-
-	private:
-		static void internal_createInstance(MonoObject* instance, MonoObject* parentGUI, INT32 x, INT32 y, UINT32 width, UINT32 height, 
-			INT16 depth, GUILayoutType layoutType);
-
-		static void internal_destroy(ScriptGUIArea* thisPtr);
-		static void internal_setVisible(ScriptGUIArea* thisPtr, bool visible);
-		static void internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, INT16 depth);
-
-		ScriptGUIArea(MonoObject* instance, GUIArea* area, ScriptGUIPanel* panel);
-
-		void destroy();
-
-		GUIArea* mGUIArea;
-		Rect2I mArea;
-		ScriptGUIPanel* mParentPanel;
-		bool mIsDestroyed;
-	};
-}

+ 1 - 0
SBansheeEngine/Include/BsScriptGUIElement.h

@@ -3,6 +3,7 @@
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptObject.h"
 #include "BsGUIOptions.h"
+#include "BsGUIElementBase.h"
 
 namespace BansheeEngine
 {

+ 15 - 2
SBansheeEngine/Include/BsScriptGUILayout.h

@@ -14,13 +14,14 @@ namespace BansheeEngine
 		void* getNativeRaw() const { return mLayout; }
 
 	private:
+		friend class ScriptGUIPanel;
+
 		static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
 		static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
-		static void internal_createInstancePanel(MonoObject* instance, UINT16 depth, UINT16 depthRange, MonoArray* guiOptions);
+		static void internal_createInstancePanel(MonoObject* instance, INT16 depth, UINT16 depthRange, MonoArray* guiOptions);
 		static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementTBase* element);
 		static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementTBase* element);
 
-		static void internal_createInstanceXFromArea(MonoObject* instance, MonoObject* parentArea);
 		static void internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea);
 
 		ScriptGUILayout(MonoObject* instance, GUILayout* layout);
@@ -30,4 +31,16 @@ namespace BansheeEngine
 		GUILayout* mLayout;
 		bool mIsDestroyed;
 	};
+
+	class BS_SCR_BE_EXPORT ScriptGUIPanel : public ScriptObject<ScriptGUIPanel>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIPanel")
+
+		static MonoObject* createFromExisting(GUIPanel* panel);
+
+	private:
+		ScriptGUIPanel(MonoObject* instance);
+	};
+
 }

+ 0 - 46
SBansheeEngine/Include/BsScriptGUIPanel.h

@@ -1,46 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsRect2I.h"
-
-namespace BansheeEngine
-{
-	class BS_SCR_BE_EXPORT ScriptGUIPanel : public ScriptObject<ScriptGUIPanel>
-	{
-	public:
-		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "GUIPanel")
-
-		GUIWidget& getWidget() const { return *mParentWidget; }
-		const Rect2I& getClippedArea() const { return mClippedArea; }
-
-		void setParentArea(INT32 x, INT32 y, UINT32 width, UINT32 height);
-		void setParentWidget(GUIWidget* widget);
-
-		void registerArea(ScriptGUIArea* area);
-		void unregisterArea(ScriptGUIArea* area);
-
-		const Vector<ScriptGUIArea*>& getAreas() const { return mAreas; }
-		Rect2I getArea() const { return mMyArea; }
-
-		void destroy();
-
-	protected:
-		ScriptGUIPanel(MonoObject* instance);
-
-		static void internal_createInstance(MonoObject* instance);
-		static void internal_setArea(ScriptGUIPanel* thisPtr, INT32 x, INT32 y, 
-			UINT32 width, UINT32 height);
-
-		void updateArea();
-
-		GUIWidget* mParentWidget;
-		Vector<ScriptGUIArea*> mAreas;
-
-		Rect2I mParentArea;
-		Rect2I mMyArea;
-		Rect2I mClippedArea;
-
-		static MonoMethod* mDestroyMethod;
-	};
-}

+ 0 - 4
SBansheeEngine/SBansheeEngine.vcxproj

@@ -266,9 +266,7 @@
     <ClInclude Include="Include\BsScriptGUIFixedSpace.h" />
     <ClInclude Include="Include\BsScriptGUIFlexibleSpace.h" />
     <ClInclude Include="Include\BsScriptFont.h" />
-    <ClInclude Include="Include\BsScriptGUIArea.h" />
     <ClInclude Include="Include\BsScriptGUILayoutUtility.h" />
-    <ClInclude Include="Include\BsScriptGUIPanel.h" />
     <ClInclude Include="Include\BsScriptGUIElementStateStyle.h" />
     <ClInclude Include="Include\BsScriptGUIElementStyle.h" />
     <ClInclude Include="Include\BsScriptGUIInputBox.h" />
@@ -343,9 +341,7 @@
     <ClCompile Include="Source\BsScriptGUIFixedSpace.cpp" />
     <ClCompile Include="Source\BsScriptGUIFlexibleSpace.cpp" />
     <ClCompile Include="Source\BsScriptFont.cpp" />
-    <ClCompile Include="Source\BsScriptGUIArea.cpp" />
     <ClCompile Include="Source\BsScriptGUILayoutUtility.cpp" />
-    <ClCompile Include="Source\BsScriptGUIPanel.cpp" />
     <ClCompile Include="Source\BsScriptGUIElementStateStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUIElementStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUILabel.cpp" />

+ 0 - 12
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -78,9 +78,6 @@
     <ClInclude Include="Include\BsScriptSceneObject.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptGUIArea.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptGUIButton.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -123,9 +120,6 @@
     <ClInclude Include="Include\BsScriptGUIToggleGroup.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptGUIPanel.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsManagedSerializableArrayRTTI.h">
       <Filter>Header Files\Serialization\RTTI</Filter>
     </ClInclude>
@@ -332,9 +326,6 @@
     <ClCompile Include="Source\BsScriptSceneObject.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptGUIArea.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptGUIButton.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
@@ -377,9 +368,6 @@
     <ClCompile Include="Source\BsScriptGUIToggleGroup.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptGUIPanel.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsManagedSerializableArray.cpp">
       <Filter>Source Files\Serialization</Filter>
     </ClCompile>

+ 0 - 88
SBansheeEngine/Source/BsScriptGUIArea.cpp

@@ -1,88 +0,0 @@
-#include "BsScriptGUIArea.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsScriptGUIArea.h"
-#include "BsGUIArea.h"
-#include "BsGUILayout.h"
-#include "BsScriptGUIPanel.h"
-
-namespace BansheeEngine
-{
-	ScriptGUIArea::ScriptGUIArea(MonoObject* instance, GUIArea* area, ScriptGUIPanel* parentGUI)
-		:ScriptObject(instance), mGUIArea(area), mParentPanel(parentGUI), mIsDestroyed(false)
-	{
-		mParentPanel->registerArea(this);
-	}
-
-	void ScriptGUIArea::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIArea::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_SetArea", &ScriptGUIArea::internal_setArea);
-		metaData.scriptClass->addInternalCall("Internal_Destroy", &ScriptGUIArea::internal_destroy);
-		metaData.scriptClass->addInternalCall("Internal_SetVisible", &ScriptGUIArea::internal_setVisible);
-	}
-
-	void ScriptGUIArea::destroy()
-	{
-		if(!mIsDestroyed)
-		{
-			mParentPanel->unregisterArea(this);
-
-			GUIArea::destroy(mGUIArea);
-			mGUIArea = nullptr;
-
-			mIsDestroyed = true;
-		}
-	}
-
-	void ScriptGUIArea::internal_createInstance(MonoObject* instance, MonoObject* panel, INT32 x, INT32 y, UINT32 width, 
-		UINT32 height, INT16 depth, GUILayoutType layoutType)
-	{
-		UINT16 signedDepth = depth + 32768;
-
-		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
-		GUIArea* nativeArea = GUIArea::create(scriptGUIPanel->getWidget(), x, y, width, height, signedDepth, layoutType);
-
-		ScriptGUIArea* nativeInstance = new (bs_alloc<ScriptGUIArea>()) ScriptGUIArea(instance, nativeArea, scriptGUIPanel);
-	}
-
-	void ScriptGUIArea::internal_destroy(ScriptGUIArea* thisPtr)
-	{
-		thisPtr->destroy();
-	}
-
-	void ScriptGUIArea::internal_setVisible(ScriptGUIArea* thisPtr, bool visible)
-	{
-		if(visible)
-			thisPtr->mGUIArea->enable();
-		else
-			thisPtr->mGUIArea->disable();
-	}
-
-	void ScriptGUIArea::internal_setArea(ScriptGUIArea* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height, INT16 depth)
-	{
-		UINT16 signedDepth = depth + 32768;
-
-		thisPtr->mArea.x = x;
-		thisPtr->mArea.y = y;
-		thisPtr->mArea.width = width;
-		thisPtr->mArea.height = height;
-
-		thisPtr->updateArea();
-		thisPtr->mGUIArea->setDepth(signedDepth);
-	}
-
-	void ScriptGUIArea::updateArea()
-	{
-		Rect2I parentArea = mParentPanel->getClippedArea();
-		Rect2I myClippedArea = mArea;
-		myClippedArea.x += parentArea.x;
-		myClippedArea.y += parentArea.y;
-		myClippedArea.clip(parentArea);
-		
-		mGUIArea->setPosition(myClippedArea.x, myClippedArea.y);
-		mGUIArea->setSize(myClippedArea.width, myClippedArea.height);
-	}
-}

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIButton.cpp

@@ -11,7 +11,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIInputBox.cpp

@@ -11,7 +11,6 @@
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUILabel.cpp

@@ -10,7 +10,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 18 - 14
SBansheeEngine/Source/BsScriptGUILayout.cpp

@@ -3,9 +3,7 @@
 #include "BsMonoField.h"
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptGUIScrollArea.h"
-#include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
@@ -25,7 +23,6 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceX", &ScriptGUILayout::internal_createInstanceX);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceY", &ScriptGUILayout::internal_createInstanceY);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstancePanel", &ScriptGUILayout::internal_createInstancePanel);
-		metaData.scriptClass->addInternalCall("Internal_CreateInstanceXFromArea", &ScriptGUILayout::internal_createInstanceXFromArea);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstanceYFromScrollArea", &ScriptGUILayout::internal_createInstanceYFromScrollArea);
 		metaData.scriptClass->addInternalCall("Internal_AddElement", &ScriptGUILayout::internal_addElement);
 		metaData.scriptClass->addInternalCall("Internal_InsertElement", &ScriptGUILayout::internal_insertElement);
@@ -69,7 +66,7 @@ namespace BansheeEngine
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 	}
 
-	void ScriptGUILayout::internal_createInstancePanel(MonoObject* instance, UINT16 depth, UINT16 depthRange, MonoArray* guiOptions)
+	void ScriptGUILayout::internal_createInstancePanel(MonoObject* instance, INT16 depth, UINT16 depthRange, MonoArray* guiOptions)
 	{
 		GUIOptions options;
 
@@ -77,20 +74,12 @@ namespace BansheeEngine
 		for (UINT32 i = 0; i < arrayLen; i++)
 			options.addOption(mono_array_get(guiOptions, GUIOption, i));
 
-		GUILayout* layout = GUIPanel::create(depth, depthRange, options);
+		UINT16 signedDepth = depth + 32768;
+		GUILayout* layout = GUIPanel::create(signedDepth, depthRange, options);
 
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 	}
 
-	void ScriptGUILayout::internal_createInstanceXFromArea(MonoObject* instance, MonoObject* parentArea)
-	{
-		ScriptGUIArea* scriptArea = ScriptGUIArea::toNative(parentArea);
-		GUIArea* nativeArea = scriptArea->getInternalValue();
-
-		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) 
-			ScriptGUILayout(instance, &nativeArea->getLayout());
-	}
-
 	void ScriptGUILayout::internal_createInstanceYFromScrollArea(MonoObject* instance, MonoObject* parentScrollArea)
 	{
 		ScriptGUIScrollArea* scriptScrollArea = ScriptGUIScrollArea::toNative(parentScrollArea);
@@ -111,4 +100,19 @@ namespace BansheeEngine
 	{
 		instance->getInternalValue()->insertElement(index, element->getGUIElement());
 	}
+
+	ScriptGUIPanel::ScriptGUIPanel(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
+	void ScriptGUIPanel::initRuntimeData()
+	{ }
+
+	MonoObject* ScriptGUIPanel::createFromExisting(GUIPanel* panel)
+	{
+		MonoObject* managedInstance = metaData.scriptClass->createInstance();
+		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(managedInstance, panel);
+
+		return managedInstance;
+	}
 }

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIListBox.cpp

@@ -11,7 +11,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 
 using namespace std::placeholders;

+ 0 - 97
SBansheeEngine/Source/BsScriptGUIPanel.cpp

@@ -1,97 +0,0 @@
-#include "BsScriptGUIPanel.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsScriptGUIArea.h"
-#include "BsGUIArea.h"
-#include "BsGUILayout.h"
-#include "BsMonoMethod.h"
-
-namespace BansheeEngine
-{
-	MonoMethod* ScriptGUIPanel::mDestroyMethod = nullptr;
-
-	ScriptGUIPanel::ScriptGUIPanel(MonoObject* instance)
-		:ScriptObject(instance)
-	{
-
-	}
-
-	void ScriptGUIPanel::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIPanel::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_SetArea", &ScriptGUIPanel::internal_setArea);
-
-		mDestroyMethod = metaData.scriptClass->getMethod("Destroy", 0);
-	}
-
-	void ScriptGUIPanel::internal_createInstance(MonoObject* instance)
-	{
-		ScriptGUIPanel* nativeInstance = new (bs_alloc<ScriptGUIPanel>()) ScriptGUIPanel(instance);
-	}
-
-	void ScriptGUIPanel::internal_setArea(ScriptGUIPanel* thisPtr, INT32 x, INT32 y, UINT32 width, UINT32 height)
-	{
-		thisPtr->mMyArea.x = x;
-		thisPtr->mMyArea.y = y;
-		thisPtr->mMyArea.width = width;
-		thisPtr->mMyArea.height = height;
-
-		thisPtr->updateArea();
-	}
-
-	void ScriptGUIPanel::setParentArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
-	{
-		mParentArea.x = x;
-		mParentArea.y = y;
-		mParentArea.width = width;
-		mParentArea.height = height;
-
-		updateArea();
-	}
-
-	void ScriptGUIPanel::setParentWidget(GUIWidget* widget) 
-	{ 
-		mParentWidget = widget; 
-
-		for(auto& area : mAreas)
-		{
-			area->getInternalValue()->changeParentWidget(widget);
-		}
-	}
-
-	void ScriptGUIPanel::registerArea(ScriptGUIArea* area)
-	{
-		mAreas.push_back(area);
-	}
-
-	void ScriptGUIPanel::unregisterArea(ScriptGUIArea* area)
-	{
-		auto iterFind = std::find(mAreas.begin(), mAreas.end(), area);
-
-		if(iterFind != mAreas.end())
-			mAreas.erase(iterFind);
-	}
-
-	void ScriptGUIPanel::destroy()
-	{
-		assert(mDestroyMethod != nullptr);
-
-		mDestroyMethod->invoke(mManagedInstance, nullptr);
-	}
-
-	void ScriptGUIPanel::updateArea()
-	{
-		mClippedArea = mMyArea;
-		mClippedArea.x += mParentArea.x;
-		mClippedArea.y += mParentArea.y;
-
-		mClippedArea.clip(mParentArea);
-
-		for(auto& area : mAreas)
-		{
-			area->updateArea();
-		}
-	}
-}

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIProgressBar.cpp

@@ -11,7 +11,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIRenderTexture.cpp

@@ -10,7 +10,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 #include "BsScriptRenderTexture2D.h"

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIScrollArea.cpp

@@ -11,7 +11,6 @@
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUISlider.cpp

@@ -11,7 +11,6 @@
 #include "BsGUIOptions.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUITexture.cpp

@@ -11,7 +11,6 @@
 #include "BsScriptSpriteTexture.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 0 - 1
SBansheeEngine/Source/BsScriptGUIToggle.cpp

@@ -13,7 +13,6 @@
 #include "BsScriptGUIToggleGroup.h"
 #include "BsScriptGUIElementStyle.h"
 #include "BsScriptGUILayout.h"
-#include "BsScriptGUIArea.h"
 #include "BsScriptHString.h"
 #include "BsScriptGUIContent.h"
 

+ 4 - 13
TODO.txt

@@ -17,21 +17,12 @@ the same and the only variable will be the 4byte random number, which can someti
 ----------------------------------------------------------------------
 GUIArea refactor:
 
+EditorWindow and ModalWindow need to initialize the C# "GUI" field.
+ - Check if the default GUIPanel has proper size. EditorWindow should be fine, but modal window might need additional handling (I don't think it even has a default contents panel)
+
 ColorPicker 2D handle is broken because it uses window coordinates for positioning, but it needs coordinates relative to parent GUI panel
  - Will likely need a new method for that
-
-Remove GUIArea and GUIPanel from C# and replace its uses with the new GUIPanel. Also replace any child GUIAreas with GUIPanels in C++ code.
- - Once that is ensured to work, go to the final step and replace GUIWidget GUIArea as well.
-
-Use cases:
-ProjectWindow
- - ScrollArea would have a GUIPanel child and then it would work similarly to InspectorWindow
-
-Three child GUIPanels in a widget, title-bar, contents and background
- - Add three GUIPanels to the root panel, each with its own depth
- - Title GUIPanel: Add GUISpaces for padding, GUIFlexibleSpace to anchor to the top, specify GUIPanel height but leave width at 0 for flexible expand
- - Content GUIPanel: Similar as title, but leave both width and height as 0, add GUISpace as padding
- - Background GUIPanel: Leave as is
+ - Extend GUILayoutUtility::calcBounds so it can returns bounds relative to specific GUIPanel
 
 ----------------------------------------------------------------------
 Project window