Marko Pintera 10 лет назад
Родитель
Сommit
42786f0f7f
40 измененных файлов с 235 добавлено и 138 удалено
  1. 1 1
      BansheeEditor/Include/BsGUIComponentFoldout.h
  2. 1 1
      BansheeEditor/Include/BsGUIFieldBase.h
  3. 1 1
      BansheeEditor/Include/BsGUIFoldout.h
  4. 1 1
      BansheeEditor/Include/BsGUIResourceTreeView.h
  5. 1 1
      BansheeEditor/Include/BsGUITabbedTitleBar.h
  6. 1 1
      BansheeEditor/Include/BsGUITextField.h
  7. 1 1
      BansheeEditor/Include/BsGUITreeView.h
  8. 2 2
      BansheeEditor/Source/BsGUIComponentFoldout.cpp
  9. 2 2
      BansheeEditor/Source/BsGUIFieldBase.cpp
  10. 3 3
      BansheeEditor/Source/BsGUIFoldout.cpp
  11. 3 2
      BansheeEditor/Source/BsGUIResourceTreeView.cpp
  12. 5 5
      BansheeEditor/Source/BsGUITabbedTitleBar.cpp
  13. 2 2
      BansheeEditor/Source/BsGUITextField.cpp
  14. 7 7
      BansheeEditor/Source/BsGUITreeView.cpp
  15. 1 1
      BansheeEngine/Include/BsGUIDropDownContent.h
  16. 12 10
      BansheeEngine/Include/BsGUIElementBase.h
  17. 10 8
      BansheeEngine/Include/BsGUILayoutX.h
  18. 10 8
      BansheeEngine/Include/BsGUILayoutY.h
  19. 50 11
      BansheeEngine/Include/BsGUIPanel.h
  20. 2 2
      BansheeEngine/Include/BsGUIProgressBar.h
  21. 1 1
      BansheeEngine/Include/BsGUIScrollArea.h
  22. 2 2
      BansheeEngine/Include/BsGUISlider.h
  23. 1 1
      BansheeEngine/Source/BsGUIArea.cpp
  24. 3 3
      BansheeEngine/Source/BsGUIDropDownContent.cpp
  25. 6 4
      BansheeEngine/Source/BsGUIElementBase.cpp
  26. 5 4
      BansheeEngine/Source/BsGUILayoutX.cpp
  27. 5 4
      BansheeEngine/Source/BsGUILayoutY.cpp
  28. 44 10
      BansheeEngine/Source/BsGUIPanel.cpp
  29. 3 3
      BansheeEngine/Source/BsGUIProgressBar.cpp
  30. 8 6
      BansheeEngine/Source/BsGUIScrollArea.cpp
  31. 3 3
      BansheeEngine/Source/BsGUISlider.cpp
  32. 21 7
      MBansheeEngine/GUI/GUILayout.cs
  33. 6 1
      MBansheeEngine/GUI/GUIPanelNEW.cs
  34. 1 1
      SBansheeEditor/Include/BsGUIGameObjectField.h
  35. 1 1
      SBansheeEditor/Include/BsGUIResourceField.h
  36. 2 2
      SBansheeEditor/Source/BsGUIGameObjectField.cpp
  37. 2 2
      SBansheeEditor/Source/BsGUIResourceField.cpp
  38. 1 1
      SBansheeEngine/Include/BsScriptGUILayout.h
  39. 2 2
      SBansheeEngine/Source/BsScriptGUILayout.cpp
  40. 2 10
      TODO.txt

+ 1 - 1
BansheeEditor/Include/BsGUIComponentFoldout.h

@@ -32,7 +32,7 @@ namespace BansheeEngine
 		virtual void setTint(const Color& color);
 		virtual void setTint(const Color& color);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		Vector2I _getOptimalSize() const;
 		Vector2I _getOptimalSize() const;
 
 

+ 1 - 1
BansheeEditor/Include/BsGUIFieldBase.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 			const String& labelStyle, const GUIDimensions& dimensions, bool withLabel);
 			const String& labelStyle, const GUIDimensions& dimensions, bool withLabel);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		virtual Vector2I _getOptimalSize() const;
 		virtual Vector2I _getOptimalSize() const;
 
 

+ 1 - 1
BansheeEditor/Include/BsGUIFoldout.h

@@ -33,7 +33,7 @@ namespace BansheeEngine
 		virtual void setTint(const Color& color);
 		virtual void setTint(const Color& color);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		Vector2I _getOptimalSize() const;
 		Vector2I _getOptimalSize() const;
 
 

+ 1 - 1
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -71,7 +71,7 @@ namespace BansheeEngine
 			const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUIDimensions& dimensions);
 			const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUIDimensions& dimensions);
 
 
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		virtual TreeElement& getRootElement() { return mRootElement; }
 		virtual TreeElement& getRootElement() { return mRootElement; }
 		virtual const TreeElement& getRootElementConst() const { return mRootElement; }
 		virtual const TreeElement& getRootElementConst() const { return mRootElement; }

+ 1 - 1
BansheeEditor/Include/BsGUITabbedTitleBar.h

@@ -39,7 +39,7 @@ namespace BansheeEngine
 		void updateClippedBounds();
 		void updateClippedBounds();
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 	protected:
 	protected:
 		static const UINT32 TAB_SPACING;
 		static const UINT32 TAB_SPACING;
 		static const UINT32 OPTION_BTN_SPACING;
 		static const UINT32 OPTION_BTN_SPACING;

+ 1 - 1
BansheeEditor/Include/BsGUITextField.h

@@ -46,7 +46,7 @@ namespace BansheeEngine
 			const String& style, const GUIDimensions& dimensions, bool withLabel);
 			const String& style, const GUIDimensions& dimensions, bool withLabel);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		Vector2I _getOptimalSize() const;
 		Vector2I _getOptimalSize() const;
 
 

+ 1 - 1
BansheeEditor/Include/BsGUITreeView.h

@@ -76,7 +76,7 @@ namespace BansheeEngine
 		void updateClippedBounds();
 		void updateClippedBounds();
 
 
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 	protected:
 	protected:
 		static const UINT32 ELEMENT_EXTRA_SPACING;
 		static const UINT32 ELEMENT_EXTRA_SPACING;
 		static const UINT32 INDENT_SIZE;
 		static const UINT32 INDENT_SIZE;

+ 2 - 2
BansheeEditor/Source/BsGUIComponentFoldout.cpp

@@ -85,7 +85,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIComponentFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIComponentFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		UINT32 toggleOffset = 0;
 		UINT32 toggleOffset = 0;
 
 
@@ -97,7 +97,7 @@ namespace BansheeEngine
 			mToggle->_setPosition(offset);
 			mToggle->_setPosition(offset);
 			mToggle->_setWidth(width);
 			mToggle->_setWidth(width);
 			mToggle->_setHeight(optimalSize.y);
 			mToggle->_setHeight(optimalSize.y);
-			mToggle->_setAreaDepth(areaDepth);
+			mToggle->_setAreaDepth(panelDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);

+ 2 - 2
BansheeEditor/Source/BsGUIFieldBase.cpp

@@ -24,9 +24,9 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
-		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 	}
 	}
 
 
 	Vector2I GUIFieldBase::_getOptimalSize() const
 	Vector2I GUIFieldBase::_getOptimalSize() const

+ 3 - 3
BansheeEditor/Source/BsGUIFoldout.cpp

@@ -88,7 +88,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIFoldout::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		UINT32 toggleOffset = 0;
 		UINT32 toggleOffset = 0;
 
 
@@ -100,7 +100,7 @@ namespace BansheeEngine
 			mToggle->_setPosition(offset);
 			mToggle->_setPosition(offset);
 			mToggle->_setWidth(optimalSize.x);
 			mToggle->_setWidth(optimalSize.x);
 			mToggle->_setHeight(optimalSize.y);
 			mToggle->_setHeight(optimalSize.y);
-			mToggle->_setAreaDepth(areaDepth);
+			mToggle->_setAreaDepth(panelDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 			mToggle->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -117,7 +117,7 @@ namespace BansheeEngine
 			mLabel->_setPosition(offset);
 			mLabel->_setPosition(offset);
 			mLabel->_setWidth(optimalSize.x);
 			mLabel->_setWidth(optimalSize.x);
 			mLabel->_setHeight(optimalSize.y);
 			mLabel->_setHeight(optimalSize.y);
-			mLabel->_setAreaDepth(areaDepth);
+			mLabel->_setAreaDepth(panelDepth);
 			mLabel->_setWidgetDepth(widgetDepth);
 			mLabel->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);

+ 3 - 2
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -74,9 +74,10 @@ namespace BansheeEngine
 			foldoutBtnStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle, dragSepHighlightStyle, GUIDimensions::create(options));
 			foldoutBtnStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle, dragSepHighlightStyle, GUIDimensions::create(options));
 	}
 	}
 
 
-	void GUIResourceTreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIResourceTreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, 
+		UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
-		GUITreeView::_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		GUITreeView::_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 		if(mDropTarget != nullptr)
 		if(mDropTarget != nullptr)
 		{
 		{

+ 5 - 5
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -235,7 +235,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUITabbedTitleBar::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUITabbedTitleBar::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		Vector2I minBtnOptimalSize = mMinBtn->_getOptimalSize();
 		Vector2I minBtnOptimalSize = mMinBtn->_getOptimalSize();
 		Vector2I closeBtnOptimalSize = mCloseBtn->_getOptimalSize();
 		Vector2I closeBtnOptimalSize = mCloseBtn->_getOptimalSize();
@@ -251,7 +251,7 @@ namespace BansheeEngine
 			mBackgroundImage->_setPosition(offset);
 			mBackgroundImage->_setPosition(offset);
 			mBackgroundImage->_setWidth(width - 2);
 			mBackgroundImage->_setWidth(width - 2);
 			mBackgroundImage->_setHeight(optimalSize.y);
 			mBackgroundImage->_setHeight(optimalSize.y);
-			mBackgroundImage->_setAreaDepth(areaDepth);
+			mBackgroundImage->_setAreaDepth(panelDepth);
 			mBackgroundImage->_setWidgetDepth(widgetDepth);
 			mBackgroundImage->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -283,7 +283,7 @@ namespace BansheeEngine
 			btn->_setPosition(offset);
 			btn->_setPosition(offset);
 			btn->_setWidth(optimalSize.x);
 			btn->_setWidth(optimalSize.x);
 			btn->_setHeight(optimalSize.y);
 			btn->_setHeight(optimalSize.y);
-			btn->_setAreaDepth(areaDepth);
+			btn->_setAreaDepth(panelDepth);
 			btn->_setWidgetDepth(widgetDepth);
 			btn->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(tabClipRect.x - offset.x, tabClipRect.y - offset.y, tabClipRect.width, tabClipRect.height);
 			Rect2I elemClipRect(tabClipRect.x - offset.x, tabClipRect.y - offset.y, tabClipRect.width, tabClipRect.height);
@@ -300,7 +300,7 @@ namespace BansheeEngine
 			mMinBtn->_setPosition(offset);
 			mMinBtn->_setPosition(offset);
 			mMinBtn->_setWidth(minBtnOptimalSize.x);
 			mMinBtn->_setWidth(minBtnOptimalSize.x);
 			mMinBtn->_setHeight(minBtnOptimalSize.y);
 			mMinBtn->_setHeight(minBtnOptimalSize.y);
-			mMinBtn->_setAreaDepth(areaDepth);
+			mMinBtn->_setAreaDepth(panelDepth);
 			mMinBtn->_setWidgetDepth(widgetDepth);
 			mMinBtn->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -315,7 +315,7 @@ namespace BansheeEngine
 			mCloseBtn->_setPosition(offset);
 			mCloseBtn->_setPosition(offset);
 			mCloseBtn->_setWidth(closeBtnOptimalSize.x);
 			mCloseBtn->_setWidth(closeBtnOptimalSize.x);
 			mCloseBtn->_setHeight(closeBtnOptimalSize.y);
 			mCloseBtn->_setHeight(closeBtnOptimalSize.y);
-			mCloseBtn->_setAreaDepth(areaDepth);
+			mCloseBtn->_setAreaDepth(panelDepth);
 			mCloseBtn->_setWidgetDepth(widgetDepth);
 			mCloseBtn->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);

+ 2 - 2
BansheeEditor/Source/BsGUITextField.cpp

@@ -165,9 +165,9 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUITextField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUITextField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
-		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 	}
 	}
 
 
 	Vector2I GUITextField::_getOptimalSize() const
 	Vector2I GUITextField::_getOptimalSize() const

+ 7 - 7
BansheeEditor/Source/BsGUITreeView.cpp

@@ -829,7 +829,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUITreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUITreeView::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		struct UpdateTreeElement
 		struct UpdateTreeElement
 		{
 		{
@@ -876,7 +876,7 @@ namespace BansheeEngine
 				current->mElement->_setPosition(offset);
 				current->mElement->_setPosition(offset);
 				current->mElement->_setWidth(elementSize.x);
 				current->mElement->_setWidth(elementSize.x);
 				current->mElement->_setHeight(elementSize.y);
 				current->mElement->_setHeight(elementSize.y);
-				current->mElement->_setAreaDepth(areaDepth);
+				current->mElement->_setAreaDepth(panelDepth);
 				current->mElement->_setWidgetDepth(widgetDepth);
 				current->mElement->_setWidgetDepth(widgetDepth);
 
 
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -904,7 +904,7 @@ namespace BansheeEngine
 				current->mFoldoutBtn->_setPosition(myOffset);
 				current->mFoldoutBtn->_setPosition(myOffset);
 				current->mFoldoutBtn->_setWidth(elementSize.x);
 				current->mFoldoutBtn->_setWidth(elementSize.x);
 				current->mFoldoutBtn->_setHeight(elementSize.y);
 				current->mFoldoutBtn->_setHeight(elementSize.y);
-				current->mFoldoutBtn->_setAreaDepth(areaDepth);
+				current->mFoldoutBtn->_setAreaDepth(panelDepth);
 				current->mFoldoutBtn->_setWidgetDepth(widgetDepth);
 				current->mFoldoutBtn->_setWidgetDepth(widgetDepth);
 
 
 				Rect2I elemClipRect(clipRect.x - myOffset.x, clipRect.y - myOffset.y, clipRect.width, clipRect.height);
 				Rect2I elemClipRect(clipRect.x - myOffset.x, clipRect.y - myOffset.y, clipRect.width, clipRect.height);
@@ -945,7 +945,7 @@ namespace BansheeEngine
 			selectedElem.background->_setPosition(offset);
 			selectedElem.background->_setPosition(offset);
 			selectedElem.background->_setWidth(width);
 			selectedElem.background->_setWidth(width);
 			selectedElem.background->_setHeight(targetElement->_getHeight());
 			selectedElem.background->_setHeight(targetElement->_getHeight());
-			selectedElem.background->_setAreaDepth(areaDepth);
+			selectedElem.background->_setAreaDepth(panelDepth);
 			selectedElem.background->_setWidgetDepth(widgetDepth);
 			selectedElem.background->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -962,7 +962,7 @@ namespace BansheeEngine
 			mNameEditBox->_setPosition(offset);
 			mNameEditBox->_setPosition(offset);
 			mNameEditBox->_setWidth(remainingWidth);
 			mNameEditBox->_setWidth(remainingWidth);
 			mNameEditBox->_setHeight(targetElement->_getHeight());
 			mNameEditBox->_setHeight(targetElement->_getHeight());
-			mNameEditBox->_setAreaDepth(areaDepth);
+			mNameEditBox->_setAreaDepth(panelDepth);
 			mNameEditBox->_setWidgetDepth(widgetDepth);
 			mNameEditBox->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -996,7 +996,7 @@ namespace BansheeEngine
 					mDragHighlight->_setPosition(offset);
 					mDragHighlight->_setPosition(offset);
 					mDragHighlight->_setWidth(interactableElement->bounds.width);
 					mDragHighlight->_setWidth(interactableElement->bounds.width);
 					mDragHighlight->_setHeight(interactableElement->bounds.height);
 					mDragHighlight->_setHeight(interactableElement->bounds.height);
-					mDragHighlight->_setAreaDepth(areaDepth);
+					mDragHighlight->_setAreaDepth(panelDepth);
 					mDragHighlight->_setWidgetDepth(widgetDepth);
 					mDragHighlight->_setWidgetDepth(widgetDepth);
 
 
 					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -1014,7 +1014,7 @@ namespace BansheeEngine
 					mDragSepHighlight->_setPosition(offset);
 					mDragSepHighlight->_setPosition(offset);
 					mDragSepHighlight->_setWidth(interactableElement->bounds.width);
 					mDragSepHighlight->_setWidth(interactableElement->bounds.width);
 					mDragSepHighlight->_setHeight(interactableElement->bounds.height);
 					mDragSepHighlight->_setHeight(interactableElement->bounds.height);
-					mDragSepHighlight->_setAreaDepth(areaDepth);
+					mDragSepHighlight->_setAreaDepth(panelDepth);
 					mDragSepHighlight->_setWidgetDepth(widgetDepth);
 					mDragSepHighlight->_setWidgetDepth(widgetDepth);
 
 
 					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 					Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);

+ 1 - 1
BansheeEngine/Include/BsGUIDropDownContent.h

@@ -99,7 +99,7 @@ namespace BansheeEngine
 		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 */
 		 */
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth) override;
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange) override;
 
 
 		/**
 		/**
 		 * @copydoc	GUIElementContainer::styleUpdated
 		 * @copydoc	GUIElementContainer::styleUpdated

+ 12 - 10
BansheeEngine/Include/BsGUIElementBase.h

@@ -101,19 +101,21 @@ namespace BansheeEngine
 		 * @brief	Updates child elements positions, sizes, clip rectanges and depths so they
 		 * @brief	Updates child elements positions, sizes, clip rectanges and depths so they
 		 *			fit into the provided bounds, while respecting their layout options. 
 		 *			fit into the provided bounds, while respecting their layout options. 
 		 *
 		 *
-		 * @param	x			X position of the area to start laying out the elements. Relative to parent widget.
-		 * @param	y			Y position of the area to start laying out the elements. Relative to parent widget.
-		 * @param	width		Width of the area to lay out the elements, in pixels.
-		 * @param	height		Height of the area to lay out the elements, in pixels.
-		 * @param	clipRect	Rectangle to use for clipping of GUI elements. Any element outside of this rectangle will have its
-		 *						visible geometry clipped. In coordinates relative to parent widget.
-		 * @param	widgetDepth	Depth of the parent widget, will be set for all child elements.
-		 * @param	areaDepth	Depth of the parent area, will be set for all child elements.
+		 * @param	x				X position of the area to start laying out the elements. Relative to parent widget.
+		 * @param	y				Y position of the area to start laying out the elements. Relative to parent widget.
+		 * @param	width			Width of the area to lay out the elements, in pixels.
+		 * @param	height			Height of the area to lay out the elements, in pixels.
+		 * @param	clipRect		Rectangle to use for clipping of GUI elements. Any element outside of this rectangle will have its
+		 *							visible geometry clipped. In coordinates relative to parent widget.
+		 * @param	widgetDepth		Depth of the parent widget, will be set for all child elements.
+		 * @param	panelDepth		Depth of the parent panel, will be set for all child elements.
+		 * @param	panelDepthRange	Maximum depth range that child GUI panels can have (relative to panelDepth). 
+		 *							Values outside of the depth range will be clamped.
 		 *
 		 *
 		 * @note	Internal method.
 		 * @note	Internal method.
 		 */
 		 */
 		virtual void _updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, 
 		virtual void _updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, 
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		/**
 		/**
 		 * @brief	Calculates optimal sizes of all child elements, as determined by their style and layout options.
 		 * @brief	Calculates optimal sizes of all child elements, as determined by their style and layout options.
@@ -128,7 +130,7 @@ namespace BansheeEngine
 		 * @note	Internal method.
 		 * @note	Internal method.
 		 */
 		 */
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		/**
 		/**
 		 * @brief	Calculates positions & sizes of all elements in the layout. This method expects a pre-allocated array to store the data in.
 		 * @brief	Calculates positions & sizes of all elements in the layout. This method expects a pre-allocated array to store the data in.

+ 10 - 8
BansheeEngine/Include/BsGUILayoutX.h

@@ -54,14 +54,16 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 *
 		 *
-		 * @brief	x			Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	y			Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	width		Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
-		 * @brief	height		Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
-		 * @brief	clipRect	Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
-		 * @brief	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
-		 * @brief	areaDepth	Depth of the parent area. Determines depth at which child elements will be placed on. Takes priority over element-specific depth.
+		 * @param	x				Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	y				Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	width			Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
+		 * @param	height			Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
+		 * @param	clipRect		Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
+		 * @param	widgetDepth		Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
+		 * @param	panelDepth		Depth of the parent panel, will be set for all child elements.
+		 * @param	panelDepthRange	Maximum depth range that child GUI panels can have (relative to panelDepth).
+		 *							Values outside of the depth range will be clamped.
 		 */
 		 */
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 	};
 	};
 }
 }

+ 10 - 8
BansheeEngine/Include/BsGUILayoutY.h

@@ -54,14 +54,16 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 *
 		 *
-		 * @brief	x			Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	y			Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	width		Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
-		 * @brief	height		Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
-		 * @brief	clipRect	Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
-		 * @brief	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
-		 * @brief	areaDepth	Depth of the parent area. Determines depth at which child elements will be placed on. Takes priority over element-specific depth.
+		 * @param	x				Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	y				Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	width			Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
+		 * @param	height			Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
+		 * @param	clipRect		Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
+		 * @param	widgetDepth		Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
+		 * @param	panelDepth		Depth of the parent panel, will be set for all child elements.
+		 * @param	panelDepthRange	Maximum depth range that child GUI panels can have (relative to panelDepth). 
+		 *							Values outside of the depth range will be clamped.
 		 */
 		 */
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 	};
 	};
 }
 }

+ 50 - 11
BansheeEngine/Include/BsGUIPanel.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 	{
 	{
 	public:
 	public:
 		GUIPanel(GUIArea* parentArea);
 		GUIPanel(GUIArea* parentArea);
-		GUIPanel(const GUIDimensions& dimensions);
+		GUIPanel(UINT16 depth, UINT16 depthRange, const GUIDimensions& dimensions);
 		GUIPanel() {};
 		GUIPanel() {};
 		~GUIPanel() {};
 		~GUIPanel() {};
 
 
@@ -43,30 +43,69 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual Vector2I _calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const;
 		virtual Vector2I _calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const;
 
 
+		/**
+		 * @brief	Changes values that control at which depth is GUI panel and its children rendered.
+		 *
+		 * @param	depth		Determines rendering order of the GUI panel. Panels with lower depth will be
+		 *						rendered in front of panels with higher depth. Provided depth is relative
+		 *						to depth of the parent GUI panel (if any).
+		 * @param	depthRange	Maximum range of depths that children of this GUI panel can have. If any panel has depth
+		 *						outside of the range [depth, depth + depthRange] it will be clamped to nearest extreme.
+		 *						Value of -1 means infinite range.
+		 */
+		void setDepthRange(UINT16 depth = 0, UINT16 depthRange = -1);
+
 		/**
 		/**
 		 * @brief	Creates a new GUI panel.
 		 * @brief	Creates a new GUI panel.
+		 *
+		 * @param	depth		Determines rendering order of the GUI panel. Panels with lower depth will be
+		 *						rendered in front of panels with higher depth. Provided depth is relative
+		 *						to depth of the parent GUI panel (if any).
+		 * @param	depthRange	Maximum range of depths that children of this GUI panel can have. If any panel has depth
+		 *						outside of the range [depth, depth + depthRange] it will be clamped to nearest extreme.
+		 *						Value of -1 means infinite range.
 		 */
 		 */
-		static GUIPanel* create();
+		static GUIPanel* create(UINT16 depth = 0, UINT16 depthRange = -1);
 
 
 		/**
 		/**
 		 * @brief	Creates a new GUI panel.
 		 * @brief	Creates a new GUI panel.
 		 *
 		 *
-		 * @param	options		Options that allow you to control how is the element positioned and sized.
+		 * @param	depth		Determines rendering order of the GUI panel. Panels with lower depth will be
+		 *						rendered in front of panels with higher depth. Provided depth is relative
+		 *						to depth of the parent GUI panel (if any).
 		 */
 		 */
 		static GUIPanel* create(const GUIOptions& options);
 		static GUIPanel* create(const GUIOptions& options);
 
 
+		/**
+		 * @brief	Creates a new GUI panel.
+		 *
+		 * @param	depth		Determines rendering order of the GUI panel. Panels with lower depth will be
+		 *						rendered in front of panels with higher depth. Provided depth is relative
+		 *						to depth of the parent GUI panel (if any).
+		 * @param	depthRange	Maximum range of depths that children of this GUI panel can have. If any panel has depth
+		 *						outside of the range [depth, depth + depthRange] it will be clamped to nearest extreme.
+		 *						Value of -1 means infinite range.
+		 * @param	options		Options that allow you to control how is the element positioned and sized.
+		 */
+		static GUIPanel* create(UINT16 depth, UINT16 depthRange, const GUIOptions& options);
+
 	protected:
 	protected:
 		/**
 		/**
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 * @brief	Positions/size all child layout elements based on the provided settings and their (previously calculated) optimal sizes.
 		 *
 		 *
-		 * @brief	x			Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	y			Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
-		 * @brief	width		Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
-		 * @brief	height		Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
-		 * @brief	clipRect	Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
-		 * @brief	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
-		 * @brief	areaDepth	Depth of the parent area. Determines depth at which child elements will be placed on. Takes priority over element-specific depth.
+		 * @param	x			Start X coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	y			Start Y coordinate of the layout area. First element will be placed here. Relative to parent widget.
+		 * @param	width		Maximum width of the layout in pixels. Elements will be optimized so they best fit within this width if possible.
+		 * @param	height		Maximum height of the layout in pixels. Elements will be optimized so they best fit within this height if possible.
+		 * @param	clipRect	Rectangle to clip all child elements to. Relative to parent widget. Usually equal to specified x, y, width, height parameters.
+		 * @param	widgetDepth	Depth of the parent widget. Determines depth at which child elements will be placed on. Takes priority over any other depth.
+		 * @param	panelDepth		Depth of the parent panel, will be set for all child elements.
+		 * @param	panelDepthRange	Maximum depth range that child GUI panels can have (relative to panelDepth). 
+		 *							Values outside of the depth range will be clamped. Value of -1 means infinite range.
 		 */
 		 */
-		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
+
+		UINT16 mDepthOffset;
+		UINT16 mDepthRange;
 	};
 	};
 }
 }

+ 2 - 2
BansheeEngine/Include/BsGUIProgressBar.h

@@ -75,10 +75,10 @@ namespace BansheeEngine
 		GUIProgressBar(const String& styleName, const GUIDimensions& dimensions);
 		GUIProgressBar(const String& styleName, const GUIDimensions& dimensions);
 
 
 		/**
 		/**
-		 * @copydoc	GUIElementContainer::_getOptimalSize
+		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 */
 		 */
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		/**
 		/**
 		 * @copydoc	GUIElementContainer::styleUpdated
 		 * @copydoc	GUIElementContainer::styleUpdated

+ 1 - 1
BansheeEngine/Include/BsGUIScrollArea.h

@@ -168,7 +168,7 @@ namespace BansheeEngine
 		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 */
 		 */
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		/**
 		/**
 		 * @copydoc	GUIElementContainer::_getElementAreas
 		 * @copydoc	GUIElementContainer::_getElementAreas

+ 2 - 2
BansheeEngine/Include/BsGUISlider.h

@@ -50,10 +50,10 @@ namespace BansheeEngine
 		virtual ~GUISlider();
 		virtual ~GUISlider();
 
 
 		/**
 		/**
-		 * @copydoc	GUIElementContainer::_getOptimalSize
+		 * @copydoc	GUIElementContainer::_updateLayoutInternal
 		 */
 		 */
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		/**
 		/**
 		 * @copydoc	GUIElementContainer::styleUpdated
 		 * @copydoc	GUIElementContainer::styleUpdated

+ 1 - 1
BansheeEngine/Source/BsGUIArea.cpp

@@ -152,7 +152,7 @@ namespace BansheeEngine
 				clipRect = newClipRect;
 				clipRect = newClipRect;
 			}
 			}
 
 
-			mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, clipRect, mWidget->getDepth(), mDepth);
+			mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, clipRect, mWidget->getDepth(), mDepth, -1);
 			mIsDirty = false;
 			mIsDirty = false;
 		}
 		}
 	}
 	}

+ 3 - 3
BansheeEngine/Source/BsGUIDropDownContent.cpp

@@ -335,7 +335,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIDropDownContent::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIDropDownContent::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		INT32 yOffset = y;
 		INT32 yOffset = y;
 		for (auto& visElem : mVisibleElements)
 		for (auto& visElem : mVisibleElements)
@@ -355,7 +355,7 @@ namespace BansheeEngine
 			guiMainElement->_setPosition(offset);
 			guiMainElement->_setPosition(offset);
 			guiMainElement->_setWidth(width);
 			guiMainElement->_setWidth(width);
 			guiMainElement->_setHeight(elemHeight);
 			guiMainElement->_setHeight(elemHeight);
-			guiMainElement->_setAreaDepth(areaDepth);
+			guiMainElement->_setAreaDepth(panelDepth);
 			guiMainElement->_setWidgetDepth(widgetDepth);
 			guiMainElement->_setWidgetDepth(widgetDepth);
 
 
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 			Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -368,7 +368,7 @@ namespace BansheeEngine
 				shortcutLabel->_setPosition(offset);
 				shortcutLabel->_setPosition(offset);
 				shortcutLabel->_setWidth(width);
 				shortcutLabel->_setWidth(width);
 				shortcutLabel->_setHeight(elemHeight);
 				shortcutLabel->_setHeight(elemHeight);
-				shortcutLabel->_setAreaDepth(areaDepth);
+				shortcutLabel->_setAreaDepth(panelDepth);
 				shortcutLabel->_setWidgetDepth(widgetDepth);
 				shortcutLabel->_setWidgetDepth(widgetDepth);
 				shortcutLabel->_setClipRect(elemClipRect);
 				shortcutLabel->_setClipRect(elemClipRect);
 			}
 			}

+ 6 - 4
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -180,10 +180,11 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GUIElementBase::_updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIElementBase::_updateLayout(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, 
+		UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		_updateOptimalLayoutSizes(); // We calculate optimal sizes of all layouts as a pre-processing step, as they are requested often during update
 		_updateOptimalLayoutSizes(); // We calculate optimal sizes of all layouts as a pre-processing step, as they are requested often during update
-		_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 	}
 	}
 
 
 	void GUIElementBase::_updateOptimalLayoutSizes()
 	void GUIElementBase::_updateOptimalLayoutSizes()
@@ -194,11 +195,12 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GUIElementBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIElementBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, 
+		UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		for(auto& child : mChildren)
 		for(auto& child : mChildren)
 		{
 		{
-			child->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+			child->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 		}
 		}
 	}
 	}
 
 

+ 5 - 4
BansheeEngine/Source/BsGUILayoutX.cpp

@@ -365,7 +365,8 @@ namespace BansheeEngine
 			stackDeallocLast(processedElements);
 			stackDeallocLast(processedElements);
 	}
 	}
 
 
-	void GUILayoutX::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUILayoutX::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, 
+		UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		UINT32 numElements = (UINT32)mChildren.size();
 		UINT32 numElements = (UINT32)mChildren.size();
 		Rect2I* elementAreas = nullptr;
 		Rect2I* elementAreas = nullptr;
@@ -392,14 +393,14 @@ namespace BansheeEngine
 				element->_setWidth(childArea.width);
 				element->_setWidth(childArea.width);
 				element->_setHeight(childArea.height);
 				element->_setHeight(childArea.height);
 				element->_setWidgetDepth(widgetDepth);
 				element->_setWidgetDepth(widgetDepth);
-				element->_setAreaDepth(areaDepth);
+				element->_setAreaDepth(panelDepth);
 
 
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				element->_setClipRect(elemClipRect);
 				element->_setClipRect(elemClipRect);
 
 
 				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, areaDepth);
+				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].height = childArea.height + child->_getPadding().top + child->_getPadding().bottom;
 				actualSizes[childIdx].height = childArea.height + child->_getPadding().top + child->_getPadding().bottom;
 			}
 			}
@@ -409,7 +410,7 @@ namespace BansheeEngine
 
 
 				Rect2I newClipRect(childArea.x, childArea.y, childArea.width, height);
 				Rect2I newClipRect(childArea.x, childArea.y, childArea.width, height);
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				layout->_updateLayoutInternal(childArea.x, childArea.y, childArea.width, height, newClipRect, widgetDepth, areaDepth);
+				layout->_updateLayoutInternal(childArea.x, childArea.y, childArea.width, height, newClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].height = layout->_getActualHeight();
 				actualSizes[childIdx].height = layout->_getActualHeight();
 			}
 			}

+ 5 - 4
BansheeEngine/Source/BsGUILayoutY.cpp

@@ -363,7 +363,8 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, 
+		UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		UINT32 numElements = (UINT32)mChildren.size();
 		UINT32 numElements = (UINT32)mChildren.size();
 		Rect2I* elementAreas = nullptr;
 		Rect2I* elementAreas = nullptr;
@@ -391,14 +392,14 @@ namespace BansheeEngine
 				element->_setHeight(childArea.height);
 				element->_setHeight(childArea.height);
 				element->_setWidth(childArea.width);
 				element->_setWidth(childArea.width);
 				element->_setWidgetDepth(widgetDepth);
 				element->_setWidgetDepth(widgetDepth);
-				element->_setAreaDepth(areaDepth);
+				element->_setAreaDepth(panelDepth);
 
 
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				element->_setClipRect(elemClipRect);
 				element->_setClipRect(elemClipRect);
 
 
 				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				Rect2I newClipRect(offset.x, offset.y, childArea.width, childArea.height);
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, areaDepth);
+				element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].width = childArea.width + element->_getPadding().left + element->_getPadding().right;
 				actualSizes[childIdx].width = childArea.width + element->_getPadding().left + element->_getPadding().right;
 			}
 			}
@@ -408,7 +409,7 @@ namespace BansheeEngine
 
 
 				Rect2I newClipRect(childArea.x, childArea.y, width, childArea.height);
 				Rect2I newClipRect(childArea.x, childArea.y, width, childArea.height);
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				layout->_updateLayoutInternal(childArea.x, childArea.y, width, childArea.height, newClipRect, widgetDepth, areaDepth);
+				layout->_updateLayoutInternal(childArea.x, childArea.y, width, childArea.height, newClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].width = layout->_getActualWidth();
 				actualSizes[childIdx].width = layout->_getActualWidth();
 			}
 			}

+ 44 - 10
BansheeEngine/Source/BsGUIPanel.cpp

@@ -7,13 +7,21 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	GUIPanel::GUIPanel(GUIArea* parentArea)
 	GUIPanel::GUIPanel(GUIArea* parentArea)
-		:GUILayout(parentArea)
+		:GUILayout(parentArea), mDepthOffset(0), mDepthRange(0)
 	{ }
 	{ }
 
 
-	GUIPanel::GUIPanel(const GUIDimensions& dimensions)
-		: GUILayout(dimensions)
+	GUIPanel::GUIPanel(UINT16 depth, UINT16 depthRange, const GUIDimensions& dimensions)
+		: GUILayout(dimensions), mDepthOffset(depth), mDepthRange(depthRange)
 	{ }
 	{ }
 
 
+	void GUIPanel::setDepthRange(UINT16 depth, UINT16 depthRange)
+	{
+		mDepthOffset = depth;
+		mDepthRange = depthRange;
+
+		markContentAsDirty();
+	}
+
 	LayoutSizeRange GUIPanel::_calculateLayoutSizeRange() const
 	LayoutSizeRange GUIPanel::_calculateLayoutSizeRange() const
 	{
 	{
 		if (mIsDisabled)
 		if (mIsDisabled)
@@ -109,8 +117,29 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	void GUIPanel::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+	void GUIPanel::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
+		UINT32 newPanelDepth = panelDepth + mDepthOffset;
+		UINT32 maxPanelDepth = panelDepth + panelDepthRange;
+
+		newPanelDepth = std::min(newPanelDepth, (UINT32)std::numeric_limits<UINT16>::max());
+
+		if (panelDepthRange != (UINT16)-1)
+		{
+			newPanelDepth = std::min(newPanelDepth, maxPanelDepth);
+
+			UINT16 newRange = (UINT16)(maxPanelDepth - newPanelDepth);
+
+			if (mDepthRange != (UINT16)-1)
+				panelDepthRange = std::min(newRange, mDepthRange);
+			else
+				panelDepthRange = newRange;
+		}
+		else
+			panelDepthRange = mDepthRange;
+
+		panelDepth = (UINT16)newPanelDepth;
+
 		UINT32 numElements = (UINT32)mChildren.size();
 		UINT32 numElements = (UINT32)mChildren.size();
 		Rect2I* elementAreas = nullptr;
 		Rect2I* elementAreas = nullptr;
 
 
@@ -134,7 +163,7 @@ namespace BansheeEngine
 				element->_setWidth(childArea.width);
 				element->_setWidth(childArea.width);
 				element->_setHeight(childArea.height);
 				element->_setHeight(childArea.height);
 				element->_setWidgetDepth(widgetDepth);
 				element->_setWidgetDepth(widgetDepth);
-				element->_setAreaDepth(areaDepth);
+				element->_setAreaDepth(panelDepth);
 
 
 				Vector2I offset = element->_getOffset();
 				Vector2I offset = element->_getOffset();
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 				Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -142,7 +171,7 @@ namespace BansheeEngine
 
 
 				Rect2I newClipRect(offset.x, offset.y, element->_getWidth(), element->_getHeight());
 				Rect2I newClipRect(offset.x, offset.y, element->_getWidth(), element->_getHeight());
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				element->_updateLayoutInternal(offset.x, offset.y, element->_getWidth(), element->_getHeight(), newClipRect, widgetDepth, areaDepth);
+				element->_updateLayoutInternal(offset.x, offset.y, element->_getWidth(), element->_getHeight(), newClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].width = childArea.width + child->_getPadding().top + child->_getPadding().bottom;
 				actualSizes[childIdx].width = childArea.width + child->_getPadding().top + child->_getPadding().bottom;
 				actualSizes[childIdx].height = childArea.height + child->_getPadding().top + child->_getPadding().bottom;
 				actualSizes[childIdx].height = childArea.height + child->_getPadding().top + child->_getPadding().bottom;
@@ -153,7 +182,7 @@ namespace BansheeEngine
 
 
 				Rect2I newClipRect(childArea.x, childArea.y, childArea.width, childArea.height);
 				Rect2I newClipRect(childArea.x, childArea.y, childArea.width, childArea.height);
 				newClipRect.clip(clipRect);
 				newClipRect.clip(clipRect);
-				layout->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, clipRect, widgetDepth, areaDepth);
+				layout->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 				actualSizes[childIdx].width = layout->_getActualWidth();
 				actualSizes[childIdx].width = layout->_getActualWidth();
 				actualSizes[childIdx].height = layout->_getActualHeight();
 				actualSizes[childIdx].height = layout->_getActualHeight();
@@ -194,13 +223,18 @@ namespace BansheeEngine
 		return actualArea;
 		return actualArea;
 	}
 	}
 
 
-	GUIPanel* GUIPanel::create()
+	GUIPanel* GUIPanel::create(UINT16 depth, UINT16 depthRange)
 	{
 	{
-		return bs_new<GUIPanel>();
+		return bs_new<GUIPanel>(depth, depthRange, GUIDimensions::create());
 	}
 	}
 
 
 	GUIPanel* GUIPanel::create(const GUIOptions& options)
 	GUIPanel* GUIPanel::create(const GUIOptions& options)
 	{
 	{
-		return bs_new<GUIPanel>(GUIDimensions::create(options));
+		return bs_new<GUIPanel>(0, -1, GUIDimensions::create(options));
+	}
+
+	GUIPanel* GUIPanel::create(UINT16 depth, UINT16 depthRange, const GUIOptions& options)
+	{
+		return bs_new<GUIPanel>(depth, depthRange, GUIDimensions::create(options));
 	}
 	}
 }
 }

+ 3 - 3
BansheeEngine/Source/BsGUIProgressBar.cpp

@@ -45,7 +45,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIProgressBar::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIProgressBar::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		Vector2I bgOffset(x, y);
 		Vector2I bgOffset(x, y);
 		Rect2I bgClipRect(clipRect.x - bgOffset.x, clipRect.y - bgOffset.y, clipRect.width, clipRect.height);
 		Rect2I bgClipRect(clipRect.x - bgOffset.x, clipRect.y - bgOffset.y, clipRect.width, clipRect.height);
@@ -53,7 +53,7 @@ namespace BansheeEngine
 		mBackground->_setPosition(bgOffset);
 		mBackground->_setPosition(bgOffset);
 		mBackground->_setWidth(width);
 		mBackground->_setWidth(width);
 		mBackground->_setHeight(height);
 		mBackground->_setHeight(height);
-		mBackground->_setAreaDepth(areaDepth);
+		mBackground->_setAreaDepth(panelDepth);
 		mBackground->_setWidgetDepth(widgetDepth);
 		mBackground->_setWidgetDepth(widgetDepth);
 		mBackground->_setClipRect(bgClipRect);
 		mBackground->_setClipRect(bgClipRect);
 
 
@@ -68,7 +68,7 @@ namespace BansheeEngine
 		mBar->_setPosition(barOffset);
 		mBar->_setPosition(barOffset);
 		mBar->_setWidth((UINT32)Math::floorToInt(maxProgressBarWidth * mPercent));
 		mBar->_setWidth((UINT32)Math::floorToInt(maxProgressBarWidth * mPercent));
 		mBar->_setHeight(progressBarHeight);
 		mBar->_setHeight(progressBarHeight);
-		mBar->_setAreaDepth(areaDepth);
+		mBar->_setAreaDepth(panelDepth);
 		mBar->_setWidgetDepth(widgetDepth);
 		mBar->_setWidgetDepth(widgetDepth);
 		mBar->_setClipRect(barClipRect);
 		mBar->_setClipRect(barClipRect);
 	}
 	}

+ 8 - 6
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -189,7 +189,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIScrollArea::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIScrollArea::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		UINT32 numElements = (UINT32)mChildren.size();
 		UINT32 numElements = (UINT32)mChildren.size();
 		Rect2I* elementAreas = nullptr;
 		Rect2I* elementAreas = nullptr;
@@ -227,14 +227,14 @@ namespace BansheeEngine
 		layoutClipRect.width = (UINT32)mVisibleSize.x;
 		layoutClipRect.width = (UINT32)mVisibleSize.x;
 		layoutClipRect.height = (UINT32)mVisibleSize.y;
 		layoutClipRect.height = (UINT32)mVisibleSize.y;
 		mContentLayout->_updateLayoutInternal(layoutBounds.x, layoutBounds.y,
 		mContentLayout->_updateLayoutInternal(layoutBounds.x, layoutBounds.y,
-			layoutBounds.width, layoutBounds.height, layoutClipRect, widgetDepth, areaDepth);
+			layoutBounds.width, layoutBounds.height, layoutClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 		// Vertical scrollbar
 		// Vertical scrollbar
 		{
 		{
 			mVertScroll->_setPosition(Vector2I(vertScrollBounds.x, vertScrollBounds.y));
 			mVertScroll->_setPosition(Vector2I(vertScrollBounds.x, vertScrollBounds.y));
 			mVertScroll->_setWidth(vertScrollBounds.width);
 			mVertScroll->_setWidth(vertScrollBounds.width);
 			mVertScroll->_setHeight(vertScrollBounds.height);
 			mVertScroll->_setHeight(vertScrollBounds.height);
-			mVertScroll->_setAreaDepth(areaDepth);
+			mVertScroll->_setAreaDepth(panelDepth);
 			mVertScroll->_setWidgetDepth(widgetDepth);
 			mVertScroll->_setWidgetDepth(widgetDepth);
 
 
 			UINT32 clippedScrollbarWidth = std::min(width, ScrollBarWidth);
 			UINT32 clippedScrollbarWidth = std::min(width, ScrollBarWidth);
@@ -243,7 +243,8 @@ namespace BansheeEngine
 
 
 			// This element is not a child of any layout so we treat it as a root element
 			// This element is not a child of any layout so we treat it as a root element
 			Rect2I scrollBarLayoutClipRect(clipRect.x + (vertScrollBounds.x - x), clipRect.y + (vertScrollBounds.y - y), clippedScrollbarWidth, clipRect.height);
 			Rect2I scrollBarLayoutClipRect(clipRect.x + (vertScrollBounds.x - x), clipRect.y + (vertScrollBounds.y - y), clippedScrollbarWidth, clipRect.height);
-			mVertScroll->_updateLayout(vertScrollBounds.x, vertScrollBounds.y, vertScrollBounds.width, vertScrollBounds.height, scrollBarLayoutClipRect, widgetDepth, areaDepth);
+			mVertScroll->_updateLayout(vertScrollBounds.x, vertScrollBounds.y, vertScrollBounds.width, 
+				vertScrollBounds.height, scrollBarLayoutClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 			// Set new handle size and update position to match the new size
 			// Set new handle size and update position to match the new size
 			UINT32 newHandleSize = (UINT32)Math::floorToInt(mVertScroll->getMaxHandleSize() * (vertScrollBounds.height / (float)mContentSize.y));
 			UINT32 newHandleSize = (UINT32)Math::floorToInt(mVertScroll->getMaxHandleSize() * (vertScrollBounds.height / (float)mContentSize.y));
@@ -264,7 +265,7 @@ namespace BansheeEngine
 			mHorzScroll->_setPosition(Vector2I(horzScrollBounds.x, horzScrollBounds.y));
 			mHorzScroll->_setPosition(Vector2I(horzScrollBounds.x, horzScrollBounds.y));
 			mHorzScroll->_setWidth(horzScrollBounds.width);
 			mHorzScroll->_setWidth(horzScrollBounds.width);
 			mHorzScroll->_setHeight(horzScrollBounds.height);
 			mHorzScroll->_setHeight(horzScrollBounds.height);
-			mHorzScroll->_setAreaDepth(areaDepth);
+			mHorzScroll->_setAreaDepth(panelDepth);
 			mHorzScroll->_setWidgetDepth(widgetDepth);
 			mHorzScroll->_setWidgetDepth(widgetDepth);
 
 
 			UINT32 clippedScrollbarHeight = std::min(height, ScrollBarWidth);
 			UINT32 clippedScrollbarHeight = std::min(height, ScrollBarWidth);
@@ -273,7 +274,8 @@ namespace BansheeEngine
 
 
 			// This element is not a child of any layout so we treat it as a root element
 			// This element is not a child of any layout so we treat it as a root element
 			Rect2I scrollBarLayoutClipRect(clipRect.x + (horzScrollBounds.x - x), clipRect.y + (horzScrollBounds.y - y), clipRect.width, clippedScrollbarHeight);
 			Rect2I scrollBarLayoutClipRect(clipRect.x + (horzScrollBounds.x - x), clipRect.y + (horzScrollBounds.y - y), clipRect.width, clippedScrollbarHeight);
-			mHorzScroll->_updateLayout(horzScrollBounds.x, horzScrollBounds.y, horzScrollBounds.width, horzScrollBounds.height, scrollBarLayoutClipRect, widgetDepth, areaDepth);
+			mHorzScroll->_updateLayout(horzScrollBounds.x, horzScrollBounds.y, horzScrollBounds.width, 
+				horzScrollBounds.height, scrollBarLayoutClipRect, widgetDepth, panelDepth, panelDepthRange);
 
 
 			// Set new handle size and update position to match the new size
 			// Set new handle size and update position to match the new size
 			UINT32 newHandleSize = (UINT32)Math::floorToInt(mHorzScroll->getMaxHandleSize() * (horzScrollBounds.width / (float)mContentSize.x));
 			UINT32 newHandleSize = (UINT32)Math::floorToInt(mHorzScroll->getMaxHandleSize() * (horzScrollBounds.width / (float)mContentSize.x));

+ 3 - 3
BansheeEngine/Source/BsGUISlider.cpp

@@ -53,7 +53,7 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUISlider::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUISlider::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
 		Vector2I offset(x, y);
 		Vector2I offset(x, y);
 		Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
 		Rect2I elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
@@ -61,14 +61,14 @@ namespace BansheeEngine
 		mBackground->_setPosition(offset);
 		mBackground->_setPosition(offset);
 		mBackground->_setWidth(width);
 		mBackground->_setWidth(width);
 		mBackground->_setHeight(height);
 		mBackground->_setHeight(height);
-		mBackground->_setAreaDepth(areaDepth);
+		mBackground->_setAreaDepth(panelDepth);
 		mBackground->_setWidgetDepth(widgetDepth);
 		mBackground->_setWidgetDepth(widgetDepth);
 		mBackground->_setClipRect(elemClipRect);
 		mBackground->_setClipRect(elemClipRect);
 
 
 		mSliderHandle->_setPosition(offset);
 		mSliderHandle->_setPosition(offset);
 		mSliderHandle->_setWidth(width);
 		mSliderHandle->_setWidth(width);
 		mSliderHandle->_setHeight(height);
 		mSliderHandle->_setHeight(height);
-		mSliderHandle->_setAreaDepth(areaDepth);
+		mSliderHandle->_setAreaDepth(panelDepth);
 		mSliderHandle->_setWidgetDepth(widgetDepth);
 		mSliderHandle->_setWidgetDepth(widgetDepth);
 		mSliderHandle->_setClipRect(elemClipRect);
 		mSliderHandle->_setClipRect(elemClipRect);
 	}
 	}

+ 21 - 7
MBansheeEngine/GUI/GUILayout.cs

@@ -115,21 +115,28 @@ namespace BansheeEngine
 
 
         public GUILayoutX AddLayoutX(params GUIOption[] options)
         public GUILayoutX AddLayoutX(params GUIOption[] options)
         {
         {
-            GUILayoutX layout = new GUILayoutX();
+            GUILayoutX layout = new GUILayoutX(options);
             AddElement(layout);
             AddElement(layout);
             return layout;
             return layout;
         }
         }
 
 
         public GUILayoutY AddLayoutY(params GUIOption[] options)
         public GUILayoutY AddLayoutY(params GUIOption[] options)
         {
         {
-            GUILayoutY layout = new GUILayoutY();
+            GUILayoutY layout = new GUILayoutY(options);
             AddElement(layout);
             AddElement(layout);
             return layout;
             return layout;
         }
         }
 
 
         public GUIPanelNEW AddPanel(params GUIOption[] options)
         public GUIPanelNEW AddPanel(params GUIOption[] options)
         {
         {
-            GUIPanelNEW layout = new GUIPanelNEW();
+            GUIPanelNEW layout = new GUIPanelNEW(options);
+            AddElement(layout);
+            return layout;
+        }
+
+        public GUIPanelNEW AddPanel(ushort depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
+        {
+            GUIPanelNEW layout = new GUIPanelNEW(depth, depthRange, options);
             AddElement(layout);
             AddElement(layout);
             return layout;
             return layout;
         }
         }
@@ -150,21 +157,28 @@ namespace BansheeEngine
 
 
         public GUILayoutX InsertLayoutX(int idx, params GUIOption[] options)
         public GUILayoutX InsertLayoutX(int idx, params GUIOption[] options)
         {
         {
-            GUILayoutX layout = new GUILayoutX();
+            GUILayoutX layout = new GUILayoutX(options);
             InsertElement(idx, layout);
             InsertElement(idx, layout);
             return layout;
             return layout;
         }
         }
 
 
         public GUILayoutY InsertLayoutY(int idx, params GUIOption[] options)
         public GUILayoutY InsertLayoutY(int idx, params GUIOption[] options)
         {
         {
-            GUILayoutY layout = new GUILayoutY();
+            GUILayoutY layout = new GUILayoutY(options);
             InsertElement(idx, layout);
             InsertElement(idx, layout);
             return layout;
             return layout;
         }
         }
 
 
         public GUIPanelNEW InsertPanel(int idx, params GUIOption[] options)
         public GUIPanelNEW InsertPanel(int idx, params GUIOption[] options)
         {
         {
-            GUIPanelNEW layout = new GUIPanelNEW();
+            GUIPanelNEW layout = new GUIPanelNEW(options);
+            InsertElement(idx, layout);
+            return layout;
+        }
+
+        public GUIPanelNEW InsertPanel(int idx, ushort depth = 0, ushort depthRange = ushort.MaxValue, params GUIOption[] options)
+        {
+            GUIPanelNEW layout = new GUIPanelNEW(depth, depthRange, options);
             InsertElement(idx, layout);
             InsertElement(idx, layout);
             return layout;
             return layout;
         }
         }
@@ -196,7 +210,7 @@ namespace BansheeEngine
         protected static extern void Internal_CreateInstanceY(GUILayout instance, GUIOption[] options);
         protected static extern void Internal_CreateInstanceY(GUILayout instance, GUIOption[] options);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        protected static extern void Internal_CreateInstancePanel(GUILayout instance, GUIOption[] options);
+        protected static extern void Internal_CreateInstancePanel(GUILayout instance, ushort depth, ushort depthRange, GUIOption[] options);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         protected static extern void Internal_AddElement(IntPtr instance, IntPtr element);
         protected static extern void Internal_AddElement(IntPtr instance, IntPtr element);

+ 6 - 1
MBansheeEngine/GUI/GUIPanelNEW.cs

@@ -5,9 +5,14 @@ namespace BansheeEngine
 {
 {
     public sealed class GUIPanelNEW : GUILayout
     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)
         public GUIPanelNEW(params GUIOption[] options)
         {
         {
-            Internal_CreateInstancePanel(this, options);
+            Internal_CreateInstancePanel(this, 0, ushort.MaxValue, options);
         }
         }
     }
     }
 }
 }

+ 1 - 1
SBansheeEditor/Include/BsGUIGameObjectField.h

@@ -52,7 +52,7 @@ namespace BansheeEngine
 		virtual void setTint(const Color& color);
 		virtual void setTint(const Color& color);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		Vector2I _getOptimalSize() const;
 		Vector2I _getOptimalSize() const;
 
 

+ 1 - 1
SBansheeEditor/Include/BsGUIResourceField.h

@@ -55,7 +55,7 @@ namespace BansheeEngine
 		virtual void setTint(const Color& color);
 		virtual void setTint(const Color& color);
 
 
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 		void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-			Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth);
+			Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange);
 
 
 		Vector2I _getOptimalSize() const;
 		Vector2I _getOptimalSize() const;
 
 

+ 2 - 2
SBansheeEditor/Source/BsGUIGameObjectField.cpp

@@ -195,9 +195,9 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIGameObjectField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIGameObjectField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
-		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 	}
 	}
 
 
 	Vector2I GUIGameObjectField::_getOptimalSize() const
 	Vector2I GUIGameObjectField::_getOptimalSize() const

+ 2 - 2
SBansheeEditor/Source/BsGUIResourceField.cpp

@@ -200,9 +200,9 @@ namespace BansheeEngine
 	}
 	}
 
 
 	void GUIResourceField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
 	void GUIResourceField::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
-		Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
+		Rect2I clipRect, UINT8 widgetDepth, UINT16 panelDepth, UINT16 panelDepthRange)
 	{
 	{
-		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
+		mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRange);
 	}
 	}
 
 
 	Vector2I GUIResourceField::_getOptimalSize() const
 	Vector2I GUIResourceField::_getOptimalSize() const

+ 1 - 1
SBansheeEngine/Include/BsScriptGUILayout.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	private:
 	private:
 		static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
 		static void internal_createInstanceX(MonoObject* instance, MonoArray* guiOptions);
 		static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
 		static void internal_createInstanceY(MonoObject* instance, MonoArray* guiOptions);
-		static void internal_createInstancePanel(MonoObject* instance, MonoArray* guiOptions);
+		static void internal_createInstancePanel(MonoObject* instance, UINT16 depth, UINT16 depthRange, MonoArray* guiOptions);
 		static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementTBase* element);
 		static void internal_addElement(ScriptGUILayout* instance, ScriptGUIElementTBase* element);
 		static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementTBase* element);
 		static void internal_insertElement(ScriptGUILayout* instance, UINT32 index, ScriptGUIElementTBase* element);
 
 

+ 2 - 2
SBansheeEngine/Source/BsScriptGUILayout.cpp

@@ -69,7 +69,7 @@ namespace BansheeEngine
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 	}
 	}
 
 
-	void ScriptGUILayout::internal_createInstancePanel(MonoObject* instance, MonoArray* guiOptions)
+	void ScriptGUILayout::internal_createInstancePanel(MonoObject* instance, UINT16 depth, UINT16 depthRange, MonoArray* guiOptions)
 	{
 	{
 		GUIOptions options;
 		GUIOptions options;
 
 
@@ -77,7 +77,7 @@ namespace BansheeEngine
 		for (UINT32 i = 0; i < arrayLen; i++)
 		for (UINT32 i = 0; i < arrayLen; i++)
 			options.addOption(mono_array_get(guiOptions, GUIOption, i));
 			options.addOption(mono_array_get(guiOptions, GUIOption, i));
 
 
-		GUILayout* layout = GUIPanel::create(options);
+		GUILayout* layout = GUIPanel::create(depth, depthRange, options);
 
 
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 		ScriptGUILayout* nativeInstance = new (bs_alloc<ScriptGUILayout>()) ScriptGUILayout(instance, layout);
 	}
 	}

+ 2 - 10
TODO.txt

@@ -20,18 +20,10 @@ GUIArea refactor:
 ColorPicker 2D handle is broken because it uses window coordinates for positioning, but it needs coordinates relative to parent GUI 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
  - Will likely need a new method for that
 
 
-Remove GUIPanel and GUIPanel container and rename GUILayoutExplicit to new GUIPanel. Use that instead in code and ensure everything looks okay.
-Change how depth works so GUIPanels can set it (offset + range)
-
-Remove GUIArea and replace it with GUIPanel completely
+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:
 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.
-
-ColorPicker
- - This should work fine as long as I ensure that I add explicit elements to the root GUIPanel (one that has the main layout with all other elements)
-
 ProjectWindow
 ProjectWindow
  - ScrollArea would have a GUIPanel child and then it would work similarly to InspectorWindow
  - ScrollArea would have a GUIPanel child and then it would work similarly to InspectorWindow