Explorar o código

Finishing up exposing GUI widgets to C#

BearishSun %!s(int64=10) %!d(string=hai) anos
pai
achega
abac7348d8
Modificáronse 100 ficheiros con 4957 adicións e 5074 borrados
  1. 257 251
      BansheeCore/Source/BsViewport.cpp
  2. 232 236
      BansheeD3D11RenderAPI/BansheeD3D11RenderAPI.vcxproj.filters
  3. 0 4
      BansheeD3D9RenderAPI/BansheeD3D9RenderAPI.vcxproj.filters
  4. 0 4
      BansheeEditor/BansheeEditor.vcxproj.filters
  5. 1 1
      BansheeEditor/Include/BsEditorWidget.h
  6. 3 3
      BansheeEditor/Include/BsEditorWidgetContainer.h
  7. 2 2
      BansheeEditor/Include/BsGUIMenuBar.h
  8. 1 1
      BansheeEditor/Include/BsGUIResourceTreeView.h
  9. 16 26
      BansheeEditor/Include/BsGUIWindowFrameWidget.h
  10. 33 33
      BansheeEditor/Include/BsGUIWindowFrameWidgetRTTI.h
  11. 3 8
      BansheeEditor/Source/BsDockManager.cpp
  12. 119 119
      BansheeEditor/Source/BsDropDownWindow.cpp
  13. 2 4
      BansheeEditor/Source/BsEditorWidget.cpp
  14. 2 3
      BansheeEditor/Source/BsEditorWidgetContainer.cpp
  15. 2 1
      BansheeEditor/Source/BsEditorWindow.cpp
  16. 0 1
      BansheeEditor/Source/BsEditorWindowBase.cpp
  17. 1 4
      BansheeEditor/Source/BsGUIColor.cpp
  18. 0 5
      BansheeEditor/Source/BsGUIColorField.cpp
  19. 0 5
      BansheeEditor/Source/BsGUIDockSlider.cpp
  20. 0 7
      BansheeEditor/Source/BsGUIDropButton.cpp
  21. 0 2
      BansheeEditor/Source/BsGUIFieldBase.cpp
  22. 2 5
      BansheeEditor/Source/BsGUIFloatField.cpp
  23. 49 52
      BansheeEditor/Source/BsGUIHoverHitBox.cpp
  24. 1 4
      BansheeEditor/Source/BsGUIIntField.cpp
  25. 223 227
      BansheeEditor/Source/BsGUIListBoxField.cpp
  26. 2 2
      BansheeEditor/Source/BsGUIMenuBar.cpp
  27. 2 7
      BansheeEditor/Source/BsGUIResourceTreeView.cpp
  28. 1 7
      BansheeEditor/Source/BsGUISliderField.cpp
  29. 0 5
      BansheeEditor/Source/BsGUITabbedTitleBar.cpp
  30. 0 4
      BansheeEditor/Source/BsGUITextField.cpp
  31. 1 5
      BansheeEditor/Source/BsGUIToggleField.cpp
  32. 0 2
      BansheeEditor/Source/BsGUITreeViewEditBox.cpp
  33. 1 6
      BansheeEditor/Source/BsGUIVector2Field.cpp
  34. 1 6
      BansheeEditor/Source/BsGUIVector3Field.cpp
  35. 1 6
      BansheeEditor/Source/BsGUIVector4Field.cpp
  36. 0 8
      BansheeEditor/Source/BsGUIWindowFrame.cpp
  37. 1 9
      BansheeEditor/Source/BsGUIWindowFrameWidget.cpp
  38. 1 1
      BansheeEditor/Source/BsMainEditorWindow.cpp
  39. 4 2
      BansheeEngine/BansheeEngine.vcxproj
  40. 12 6
      BansheeEngine/BansheeEngine.vcxproj.filters
  41. 103 210
      BansheeEngine/Include/BsCGUIWidget.h
  42. 33 33
      BansheeEngine/Include/BsCGUIWidgetRTTI.h
  43. 1 1
      BansheeEngine/Include/BsGUIContextMenu.h
  44. 305 307
      BansheeEngine/Include/BsGUIDropDownMenu.h
  45. 1 1
      BansheeEngine/Include/BsGUIElement.h
  46. 3 3
      BansheeEngine/Include/BsGUIElementBase.h
  47. 13 13
      BansheeEngine/Include/BsGUIManager.h
  48. 1 1
      BansheeEngine/Include/BsGUITooltip.h
  49. 1 1
      BansheeEngine/Include/BsGUITooltipManager.h
  50. 1 1
      BansheeEngine/Include/BsGUIViewport.h
  51. 2 1
      BansheeEngine/Include/BsPrerequisites.h
  52. 1 1
      BansheeEngine/Include/BsProfilerOverlay.h
  53. 113 350
      BansheeEngine/Source/BsCGUIWidget.cpp
  54. 0 8
      BansheeEngine/Source/BsGUIButton.cpp
  55. 0 2
      BansheeEngine/Source/BsGUIButtonBase.cpp
  56. 1 1
      BansheeEngine/Source/BsGUIContextMenu.cpp
  57. 418 420
      BansheeEngine/Source/BsGUIDropDownContent.cpp
  58. 0 2
      BansheeEngine/Source/BsGUIDropDownHitBox.cpp
  59. 497 497
      BansheeEngine/Source/BsGUIDropDownMenu.cpp
  60. 2 6
      BansheeEngine/Source/BsGUIElement.cpp
  61. 2 6
      BansheeEngine/Source/BsGUIElementBase.cpp
  62. 0 6
      BansheeEngine/Source/BsGUIInputBox.cpp
  63. 1 1
      BansheeEngine/Source/BsGUIInputCaret.cpp
  64. 1 1
      BansheeEngine/Source/BsGUIInputSelection.cpp
  65. 0 3
      BansheeEngine/Source/BsGUILabel.cpp
  66. 88 94
      BansheeEngine/Source/BsGUILayoutUtility.cpp
  67. 2 8
      BansheeEngine/Source/BsGUIListBox.cpp
  68. 23 22
      BansheeEngine/Source/BsGUIManager.cpp
  69. 98 99
      BansheeEngine/Source/BsGUIProgressBar.cpp
  70. 0 2
      BansheeEngine/Source/BsGUIRenderTexture.cpp
  71. 0 6
      BansheeEngine/Source/BsGUIScrollArea.cpp
  72. 0 4
      BansheeEngine/Source/BsGUIScrollBar.cpp
  73. 0 3
      BansheeEngine/Source/BsGUISlider.cpp
  74. 0 4
      BansheeEngine/Source/BsGUISliderHandle.cpp
  75. 0 2
      BansheeEngine/Source/BsGUITexture.cpp
  76. 0 7
      BansheeEngine/Source/BsGUIToggle.cpp
  77. 1 2
      BansheeEngine/Source/BsGUITooltip.cpp
  78. 1 1
      BansheeEngine/Source/BsGUITooltipManager.cpp
  79. 2 3
      BansheeEngine/Source/BsGUIViewport.cpp
  80. 387 0
      BansheeEngine/Source/BsGUIWidget.cpp
  81. 10 10
      BansheeEngine/Source/BsProfilerOverlay.cpp
  82. 40 44
      BansheeFBXImporter/BansheeFBXImporter.vcxproj.filters
  83. 28 32
      BansheeFontImporter/BansheeFontImporter.vcxproj.filters
  84. 28 32
      BansheeFreeImgImporter/BansheeFreeImgImporter.vcxproj.filters
  85. 223 227
      BansheeGLRenderAPI/BansheeGLRenderAPI.vcxproj.filters
  86. 0 4
      BansheeMono/BansheeMono.vcxproj.filters
  87. 28 32
      BansheeOISInput/BansheeOISInput.vcxproj.filters
  88. 62 66
      BansheeSL/BansheeSL.vcxproj.filters
  89. 20 5
      BansheeUtility/Include/BsMath.h
  90. 35 0
      BansheeUtility/Include/BsStdHeaders.h
  91. 328 349
      BansheeUtility/Source/BsMath.cpp
  92. 150 150
      BansheeUtility/Source/Win32/BsWin32PlatformUtility.cpp
  93. 504 509
      ExampleProject/Main/Main.cpp
  94. 5 4
      MBansheeEngine/GUI/GUI.cs
  95. 10 2
      MBansheeEngine/GUI/GUIWidget.cs
  96. 39 6
      MBansheeEngine/NativeGUIWidget.cs
  97. 67 71
      RenderBeast/RenderBeast.vcxproj.filters
  98. 0 4
      SBansheeEditor/SBansheeEditor.vcxproj.filters
  99. 302 305
      SBansheeEditor/Source/BsGUIGameObjectField.cpp
  100. 0 5
      SBansheeEditor/Source/BsGUIResourceField.cpp

+ 257 - 251
BansheeCore/Source/BsViewport.cpp

@@ -1,251 +1,257 @@
-#include "BsViewport.h"
-#include "BsViewportRTTI.h"
-#include "BsException.h"
-#include "BsRenderTarget.h"
-#include "BsMath.h"
-#include "BsRenderAPI.h"
-#include "BsFrameAlloc.h"
-
-namespace BansheeEngine 
-{
-	const Color Viewport::DEFAULT_CLEAR_COLOR = Color(83.0f / 255.0f, 83.0f / 255.0f, 83.0f / 255.0f);
-
-	ViewportBase::ViewportBase(float x, float y, float width, float height)
-         :mNormArea(x, y, width, height), mClearColor(DEFAULT_CLEAR_COLOR), mRequiresColorClear(true), 
-		 mRequiresDepthClear(true), mRequiresStencilClear(false), mStencilClearValue(0), mDepthClearValue(1.0f)
-    {
-
-    }
-
-	void ViewportBase::setArea(float x, float y, float width, float height)
-    {
-        mNormArea.x = x;
-        mNormArea.y = y;
-        mNormArea.width = width;
-        mNormArea.height = height;
-
-		_markCoreDirty();
-    }
-
-	Rect2I ViewportBase::getArea() const
-	{
-		float width = (float)getTargetWidth();
-		float height = (float)getTargetHeight();
-		
-		Rect2I area;
-		area.x = (int)(mNormArea.x * width);
-		area.y = (int)(mNormArea.y * height);
-		area.width = (int)(mNormArea.width * width);
-		area.height = (int)(mNormArea.height * height);
-
-		return area;
-	}
-
-	void ViewportBase::setRequiresClear(bool colorClear, bool depthClear, bool stencilClear)
-	{
-		mRequiresColorClear = colorClear;
-		mRequiresDepthClear = depthClear;
-		mRequiresStencilClear = stencilClear;
-
-		_markCoreDirty();
-	}
-
-	void ViewportBase::setClearValues(const Color& clearColor, float clearDepth, UINT16 clearStencil)
-	{
-		mClearColor = clearColor;
-		mDepthClearValue = clearDepth;
-		mStencilClearValue = clearStencil;
-
-		_markCoreDirty();
-	}
-
-	INT32 ViewportBase::getX() const
-	{ 
-		return (INT32)(mNormArea.x * getTargetWidth());
-	}
-
-	INT32 ViewportBase::getY() const
-	{ 
-		return (INT32)(mNormArea.y * getTargetHeight());
-	}
-
-	INT32 ViewportBase::getWidth() const
-	{ 
-		return (INT32)(mNormArea.width * getTargetWidth());
-	}
-
-	INT32 ViewportBase::getHeight() const
-	{ 
-		return (INT32)(mNormArea.height * getTargetHeight());
-	}
-
-	ViewportCore::ViewportCore(const SPtr<RenderTargetCore>& target, float x, float y, float width, float height)
-		:ViewportBase(x, y, width, height), mTarget(target)
-	{
-
-	}
-
-	SPtr<ViewportCore> ViewportCore::create(const SPtr<RenderTargetCore>& target, float x, float y, float width, float height)
-	{
-		ViewportCore* viewport = new (bs_alloc<Viewport>()) ViewportCore(target, x, y, width, height);
-
-		SPtr<ViewportCore> viewportPtr = bs_shared_ptr<ViewportCore>(viewport);
-		viewportPtr->_setThisPtr(viewportPtr);
-		viewportPtr->initialize();
-
-		return viewportPtr;
-	}
-
-	UINT32 ViewportCore::getTargetWidth() const
-	{
-		if (mTarget != nullptr)
-			return mTarget->getProperties().getWidth();
-
-		return 0;
-	}
-
-	UINT32 ViewportCore::getTargetHeight() const
-	{
-		if (mTarget != nullptr)
-			return mTarget->getProperties().getHeight();
-
-		return 0;
-	}
-
-	void ViewportCore::syncToCore(const CoreSyncData& data)
-	{
-		char* dataPtr = (char*)data.getBuffer();
-		dataPtr = rttiReadElem(mNormArea, dataPtr);
-		dataPtr = rttiReadElem(mRequiresColorClear, dataPtr);
-		dataPtr = rttiReadElem(mRequiresDepthClear, dataPtr);
-		dataPtr = rttiReadElem(mRequiresStencilClear, dataPtr);
-		dataPtr = rttiReadElem(mClearColor, dataPtr);
-		dataPtr = rttiReadElem(mDepthClearValue, dataPtr);
-		dataPtr = rttiReadElem(mStencilClearValue, dataPtr);
-
-		SPtr<RenderTargetCore>* rtPtr = (SPtr<RenderTargetCore>*)dataPtr;
-		mTarget = *rtPtr;
-
-		rtPtr->~SPtr<RenderTargetCore>();
-	}
-
-	Viewport::Viewport()
-		:ViewportBase()
-	{ }
-
-	Viewport::Viewport(const RenderTargetPtr& target, float x, float y, float width, float height)
-		:ViewportBase(x, y, width, height), mTarget(target)
-	{
-
-	}
-
-	void Viewport::setTarget(const RenderTargetPtr& target)
-	{
-		mTarget = target; 
-		
-		markDependenciesDirty();
-		_markCoreDirty();
-	}
-
-	SPtr<ViewportCore> Viewport::getCore() const
-	{
-		return std::static_pointer_cast<ViewportCore>(mCoreSpecific);
-	}
-
-	void Viewport::_markCoreDirty()
-	{
-		markCoreDirty();
-	}
-
-	UINT32 Viewport::getTargetWidth() const
-	{
-		return mTarget->getProperties().getWidth();
-	}
-
-	UINT32 Viewport::getTargetHeight() const
-	{
-		return mTarget->getProperties().getHeight();
-	}
-
-	SPtr<CoreObjectCore> Viewport::createCore() const
-	{
-		SPtr<RenderTargetCore> targetCore;
-		if (mTarget != nullptr)
-			targetCore = mTarget->getCore();
-
-		ViewportCore* viewport = new (bs_alloc<Viewport>()) 
-			ViewportCore(targetCore, mNormArea.x, mNormArea.y, mNormArea.width, mNormArea.height);
-
-		SPtr<ViewportCore> viewportPtr = bs_shared_ptr<ViewportCore>(viewport);
-		viewportPtr->_setThisPtr(viewportPtr);
-
-		return viewportPtr;
-	}
-
-	CoreSyncData Viewport::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 size = 0;
-		size += rttiGetElemSize(mNormArea);
-		size += rttiGetElemSize(mRequiresColorClear);
-		size += rttiGetElemSize(mRequiresDepthClear);
-		size += rttiGetElemSize(mRequiresStencilClear);
-		size += rttiGetElemSize(mClearColor);
-		size += rttiGetElemSize(mDepthClearValue);
-		size += rttiGetElemSize(mStencilClearValue);
-		size += sizeof(SPtr<RenderTargetCore>);
-
-		UINT8* buffer = allocator->alloc(size);
-
-		char* dataPtr = (char*)buffer;
-		dataPtr = rttiWriteElem(mNormArea, dataPtr);
-		dataPtr = rttiWriteElem(mRequiresColorClear, dataPtr);
-		dataPtr = rttiWriteElem(mRequiresDepthClear, dataPtr);
-		dataPtr = rttiWriteElem(mRequiresStencilClear, dataPtr);
-		dataPtr = rttiWriteElem(mClearColor, dataPtr);
-		dataPtr = rttiWriteElem(mDepthClearValue, dataPtr);
-		dataPtr = rttiWriteElem(mStencilClearValue, dataPtr);
-
-		SPtr<RenderTargetCore>* rtPtr = new (dataPtr) SPtr<RenderTargetCore>();
-		if (mTarget != nullptr)
-			*rtPtr = mTarget->getCore();
-		else
-			*rtPtr = nullptr;
-
-		return CoreSyncData(buffer, size);
-	}
-
-	void Viewport::getCoreDependencies(Vector<CoreObject*>& dependencies)
-	{
-		if (mTarget != nullptr)
-			dependencies.push_back(mTarget.get());
-	}
-
-	ViewportPtr Viewport::create(const RenderTargetPtr& target, float x, float y, float width, float height)
-	{
-		Viewport* viewport = new (bs_alloc<Viewport>()) Viewport(target, x, y, width, height);
-		ViewportPtr viewportPtr = bs_core_ptr<Viewport>(viewport);
-		viewportPtr->_setThisPtr(viewportPtr);
-		viewportPtr->initialize();
-
-		return viewportPtr;
-	}
-
-	ViewportPtr Viewport::createEmpty()
-	{
-		Viewport* viewport = new (bs_alloc<Viewport>()) Viewport();
-		ViewportPtr viewportPtr = bs_core_ptr<Viewport>(viewport);
-		viewportPtr->_setThisPtr(viewportPtr);
-
-		return viewportPtr;
-	}
-
-	RTTITypeBase* Viewport::getRTTIStatic()
-	{
-		return ViewportRTTI::instance();
-	}
-
-	RTTITypeBase* Viewport::getRTTI() const
-	{
-		return Viewport::getRTTIStatic();
-	}
-}
+#include "BsViewport.h"
+#include "BsViewportRTTI.h"
+#include "BsException.h"
+#include "BsRenderTarget.h"
+#include "BsMath.h"
+#include "BsRenderAPI.h"
+#include "BsFrameAlloc.h"
+
+namespace BansheeEngine 
+{
+	const Color Viewport::DEFAULT_CLEAR_COLOR = Color(83.0f / 255.0f, 83.0f / 255.0f, 83.0f / 255.0f);
+
+	ViewportBase::ViewportBase(float x, float y, float width, float height)
+         :mNormArea(x, y, width, height), mClearColor(DEFAULT_CLEAR_COLOR), mRequiresColorClear(true), 
+		 mRequiresDepthClear(true), mRequiresStencilClear(false), mStencilClearValue(0), mDepthClearValue(1.0f)
+    {
+
+    }
+
+	void ViewportBase::setArea(float x, float y, float width, float height)
+    {
+        mNormArea.x = x;
+        mNormArea.y = y;
+        mNormArea.width = width;
+        mNormArea.height = height;
+
+		_markCoreDirty();
+    }
+
+	Rect2I ViewportBase::getArea() const
+	{
+		float width = (float)getTargetWidth();
+		float height = (float)getTargetHeight();
+		
+		Rect2I area;
+		area.x = (int)(mNormArea.x * width);
+		area.y = (int)(mNormArea.y * height);
+		area.width = (int)(mNormArea.width * width);
+		area.height = (int)(mNormArea.height * height);
+
+		return area;
+	}
+
+	void ViewportBase::setRequiresClear(bool colorClear, bool depthClear, bool stencilClear)
+	{
+		mRequiresColorClear = colorClear;
+		mRequiresDepthClear = depthClear;
+		mRequiresStencilClear = stencilClear;
+
+		_markCoreDirty();
+	}
+
+	void ViewportBase::setClearValues(const Color& clearColor, float clearDepth, UINT16 clearStencil)
+	{
+		mClearColor = clearColor;
+		mDepthClearValue = clearDepth;
+		mStencilClearValue = clearStencil;
+
+		_markCoreDirty();
+	}
+
+	INT32 ViewportBase::getX() const
+	{ 
+		return (INT32)(mNormArea.x * getTargetWidth());
+	}
+
+	INT32 ViewportBase::getY() const
+	{ 
+		return (INT32)(mNormArea.y * getTargetHeight());
+	}
+
+	INT32 ViewportBase::getWidth() const
+	{ 
+		return (INT32)(mNormArea.width * getTargetWidth());
+	}
+
+	INT32 ViewportBase::getHeight() const
+	{ 
+		return (INT32)(mNormArea.height * getTargetHeight());
+	}
+
+	ViewportCore::ViewportCore(const SPtr<RenderTargetCore>& target, float x, float y, float width, float height)
+		:ViewportBase(x, y, width, height), mTarget(target)
+	{
+
+	}
+
+	SPtr<ViewportCore> ViewportCore::create(const SPtr<RenderTargetCore>& target, float x, float y, float width, float height)
+	{
+		ViewportCore* viewport = new (bs_alloc<Viewport>()) ViewportCore(target, x, y, width, height);
+
+		SPtr<ViewportCore> viewportPtr = bs_shared_ptr<ViewportCore>(viewport);
+		viewportPtr->_setThisPtr(viewportPtr);
+		viewportPtr->initialize();
+
+		return viewportPtr;
+	}
+
+	UINT32 ViewportCore::getTargetWidth() const
+	{
+		if (mTarget != nullptr)
+			return mTarget->getProperties().getWidth();
+
+		return 0;
+	}
+
+	UINT32 ViewportCore::getTargetHeight() const
+	{
+		if (mTarget != nullptr)
+			return mTarget->getProperties().getHeight();
+
+		return 0;
+	}
+
+	void ViewportCore::syncToCore(const CoreSyncData& data)
+	{
+		char* dataPtr = (char*)data.getBuffer();
+		dataPtr = rttiReadElem(mNormArea, dataPtr);
+		dataPtr = rttiReadElem(mRequiresColorClear, dataPtr);
+		dataPtr = rttiReadElem(mRequiresDepthClear, dataPtr);
+		dataPtr = rttiReadElem(mRequiresStencilClear, dataPtr);
+		dataPtr = rttiReadElem(mClearColor, dataPtr);
+		dataPtr = rttiReadElem(mDepthClearValue, dataPtr);
+		dataPtr = rttiReadElem(mStencilClearValue, dataPtr);
+
+		SPtr<RenderTargetCore>* rtPtr = (SPtr<RenderTargetCore>*)dataPtr;
+		mTarget = *rtPtr;
+
+		rtPtr->~SPtr<RenderTargetCore>();
+	}
+
+	Viewport::Viewport()
+		:ViewportBase()
+	{ }
+
+	Viewport::Viewport(const RenderTargetPtr& target, float x, float y, float width, float height)
+		:ViewportBase(x, y, width, height), mTarget(target)
+	{
+
+	}
+
+	void Viewport::setTarget(const RenderTargetPtr& target)
+	{
+		mTarget = target; 
+		
+		markDependenciesDirty();
+		_markCoreDirty();
+	}
+
+	SPtr<ViewportCore> Viewport::getCore() const
+	{
+		return std::static_pointer_cast<ViewportCore>(mCoreSpecific);
+	}
+
+	void Viewport::_markCoreDirty()
+	{
+		markCoreDirty();
+	}
+
+	UINT32 Viewport::getTargetWidth() const
+	{
+		if(mTarget != nullptr)
+			return mTarget->getProperties().getWidth();
+
+		return 0;
+	}
+
+	UINT32 Viewport::getTargetHeight() const
+	{
+		if(mTarget != nullptr)
+			return mTarget->getProperties().getHeight();
+
+		return 0;
+	}
+
+	SPtr<CoreObjectCore> Viewport::createCore() const
+	{
+		SPtr<RenderTargetCore> targetCore;
+		if (mTarget != nullptr)
+			targetCore = mTarget->getCore();
+
+		ViewportCore* viewport = new (bs_alloc<Viewport>()) 
+			ViewportCore(targetCore, mNormArea.x, mNormArea.y, mNormArea.width, mNormArea.height);
+
+		SPtr<ViewportCore> viewportPtr = bs_shared_ptr<ViewportCore>(viewport);
+		viewportPtr->_setThisPtr(viewportPtr);
+
+		return viewportPtr;
+	}
+
+	CoreSyncData Viewport::syncToCore(FrameAlloc* allocator)
+	{
+		UINT32 size = 0;
+		size += rttiGetElemSize(mNormArea);
+		size += rttiGetElemSize(mRequiresColorClear);
+		size += rttiGetElemSize(mRequiresDepthClear);
+		size += rttiGetElemSize(mRequiresStencilClear);
+		size += rttiGetElemSize(mClearColor);
+		size += rttiGetElemSize(mDepthClearValue);
+		size += rttiGetElemSize(mStencilClearValue);
+		size += sizeof(SPtr<RenderTargetCore>);
+
+		UINT8* buffer = allocator->alloc(size);
+
+		char* dataPtr = (char*)buffer;
+		dataPtr = rttiWriteElem(mNormArea, dataPtr);
+		dataPtr = rttiWriteElem(mRequiresColorClear, dataPtr);
+		dataPtr = rttiWriteElem(mRequiresDepthClear, dataPtr);
+		dataPtr = rttiWriteElem(mRequiresStencilClear, dataPtr);
+		dataPtr = rttiWriteElem(mClearColor, dataPtr);
+		dataPtr = rttiWriteElem(mDepthClearValue, dataPtr);
+		dataPtr = rttiWriteElem(mStencilClearValue, dataPtr);
+
+		SPtr<RenderTargetCore>* rtPtr = new (dataPtr) SPtr<RenderTargetCore>();
+		if (mTarget != nullptr)
+			*rtPtr = mTarget->getCore();
+		else
+			*rtPtr = nullptr;
+
+		return CoreSyncData(buffer, size);
+	}
+
+	void Viewport::getCoreDependencies(Vector<CoreObject*>& dependencies)
+	{
+		if (mTarget != nullptr)
+			dependencies.push_back(mTarget.get());
+	}
+
+	ViewportPtr Viewport::create(const RenderTargetPtr& target, float x, float y, float width, float height)
+	{
+		Viewport* viewport = new (bs_alloc<Viewport>()) Viewport(target, x, y, width, height);
+		ViewportPtr viewportPtr = bs_core_ptr<Viewport>(viewport);
+		viewportPtr->_setThisPtr(viewportPtr);
+		viewportPtr->initialize();
+
+		return viewportPtr;
+	}
+
+	ViewportPtr Viewport::createEmpty()
+	{
+		Viewport* viewport = new (bs_alloc<Viewport>()) Viewport();
+		ViewportPtr viewportPtr = bs_core_ptr<Viewport>(viewport);
+		viewportPtr->_setThisPtr(viewportPtr);
+
+		return viewportPtr;
+	}
+
+	RTTITypeBase* Viewport::getRTTIStatic()
+	{
+		return ViewportRTTI::instance();
+	}
+
+	RTTITypeBase* Viewport::getRTTI() const
+	{
+		return Viewport::getRTTIStatic();
+	}
+}

+ 232 - 236
BansheeD3D11RenderAPI/BansheeD3D11RenderAPI.vcxproj.filters

@@ -1,237 +1,233 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsD3D11VideoModeInfo.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11VertexBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11TimerQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11TextureView.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11TextureManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11Texture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11SamplerState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderWindowManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderWindow.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderUtility.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderTexture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderStateManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RasterizerState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11QueryManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11Prerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11OcclusionQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11MultiRenderTexture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11Mappings.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11InputLayoutManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11IndexBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11HLSLProgramFactory.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11HLSLParamParser.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11HardwareBufferManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11HardwareBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11GpuProgram.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11GpuParamBlockBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11GpuBufferView.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11GpuBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11EventQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11DriverList.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11Driver.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11Device.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11DepthStencilState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11BlendState.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderAPI.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsD3D11RenderAPIFactory.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsD3D11VideoModeInfo.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11VertexBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11TimerQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11TextureView.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11TextureManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11Texture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11SamplerState.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderWindowManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderWindow.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderUtility.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderTexture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderStateManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RasterizerState.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11QueryManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11Plugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11OcclusionQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11MultiRenderTexture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11Mappings.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11InputLayoutManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11IndexBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11HLSLProgramFactory.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11HLSLParamParser.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11HardwareBufferManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11HardwareBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11GpuProgram.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11GpuParamBlockBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11GpuBufferView.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11GpuBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11EventQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11DriverList.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11Driver.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11Device.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11DepthStencilState.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11BlendState.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderAPI.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsD3D11RenderAPIFactory.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsD3D11VideoModeInfo.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11VertexBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11TimerQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11TextureView.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11TextureManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11Texture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11SamplerState.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderWindowManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderWindow.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderUtility.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderTexture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderStateManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RasterizerState.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11QueryManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11Prerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11OcclusionQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11MultiRenderTexture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11Mappings.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11InputLayoutManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11IndexBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11HLSLProgramFactory.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11HLSLParamParser.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11HardwareBufferManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11HardwareBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11GpuProgram.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11GpuParamBlockBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11GpuBufferView.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11GpuBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11EventQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11DriverList.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11Driver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11Device.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11DepthStencilState.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11BlendState.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderAPI.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsD3D11RenderAPIFactory.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsD3D11VideoModeInfo.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11VertexBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11TimerQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11TextureView.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11TextureManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11Texture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11SamplerState.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderWindowManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderWindow.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderUtility.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderTexture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderStateManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RasterizerState.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11QueryManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11Plugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11OcclusionQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11MultiRenderTexture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11Mappings.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11InputLayoutManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11IndexBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11HLSLProgramFactory.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11HLSLParamParser.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11HardwareBufferManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11HardwareBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11GpuProgram.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11GpuParamBlockBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11GpuBufferView.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11GpuBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11EventQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11DriverList.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11Driver.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11Device.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11DepthStencilState.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11BlendState.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderAPI.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsD3D11RenderAPIFactory.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 0 - 4
BansheeD3D9RenderAPI/BansheeD3D9RenderAPI.vcxproj.filters

@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsD3D9VideoModeInfo.h">

+ 0 - 4
BansheeEditor/BansheeEditor.vcxproj.filters

@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
     <Filter Include="Header Files\Commands">
       <UniqueIdentifier>{c23d8d16-3a53-4e53-9e87-a15e33d5758c}</UniqueIdentifier>
     </Filter>

+ 1 - 1
BansheeEditor/Include/BsEditorWidget.h

@@ -190,7 +190,7 @@ namespace BansheeEngine
 		 * @brief	Returns the parent GUI widget. Before calling this you must ensure
 		 *			the widget has a container parent otherwise this method will fail.
 		 */
-		CGUIWidget& getParentWidget() const;
+		GUIWidget& getParentWidget() const;
 
 		/**
 		 * @brief	Frees widget resources and deletes the instance.

+ 3 - 3
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -15,7 +15,7 @@ namespace BansheeEngine
 	class BS_ED_EXPORT EditorWidgetContainer
 	{
 	public:
-		EditorWidgetContainer(CGUIWidget* parent, EditorWindowBase* parentEditorWindow);
+		EditorWidgetContainer(GUIWidget* parent, EditorWindowBase* parentEditorWindow);
 		virtual ~EditorWidgetContainer();
 
 		/**
@@ -75,7 +75,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Returns the parent GUI widget the container is using to render the GUI on.
 		 */
-		CGUIWidget& getParentWidget() const { return *mParent; }
+		GUIWidget& getParentWidget() const { return *mParent; }
 
 		/**
 		 * @brief	Returns the parent editor window the container is docked in.
@@ -130,7 +130,7 @@ namespace BansheeEngine
 		EditorWindowBase* mParentWindow;
 		GUITabbedTitleBar* mTitleBar;
 		GUIPanel* mTitleBarPanel;
-		CGUIWidget* mParent;
+		GUIWidget* mParent;
 		INT32 mX, mY;
 		UINT32 mWidth, mHeight;
 		UnorderedMap<UINT32, EditorWidgetBase*> mWidgets;

+ 2 - 2
BansheeEditor/Include/BsGUIMenuBar.h

@@ -76,7 +76,7 @@ namespace BansheeEngine
 		 * @param	parent			Parent GUI widget the menu bar will be docked in.
 		 * @param	parentWindow	Window to trigger the min/max/close events on.
 		 */
-		GUIMenuBar(CGUIWidget* parent, RenderWindow* parentWindow);
+		GUIMenuBar(GUIWidget* parent, RenderWindow* parentWindow);
 		virtual ~GUIMenuBar();
 
 		/**
@@ -243,7 +243,7 @@ namespace BansheeEngine
 		static const UINT32 ELEMENT_SPACING;
 
 		RenderWindow* mParentWindow;
-		CGUIWidget* mParentWidget;
+		GUIWidget* mParentWidget;
 		GUIPanel* mMainPanel;
 		GUIPanel* mBgPanel;
 		GUILayout* mMenuItemLayout;

+ 1 - 1
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -182,7 +182,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUITreeView::_changeParentWidget
 		 */	
-		void _changeParentWidget(CGUIWidget* widget) override;
+		void _changeParentWidget(GUIWidget* widget) override;
 
 		/**
 		 * @brief	Triggered when a drag and drop operation that was started by the tree view

+ 16 - 26
BansheeEditor/Include/BsGUIWindowFrameWidget.h

@@ -7,45 +7,35 @@
 namespace BansheeEngine
 {
 	/**
-	 * @brief	A GUIWidget specialization that when attached to a window will
-	 *			create a window border, window background and provide resize
-	 *			functionality.
+	 * A GUIWidget specialization that when attached to a window will create a window border, window background and provide 
+	 * resize functionality.
 	 */
 	class WindowFrameWidget : public CGUIWidget
 	{
 	public:
 		/**
-		 * @brief	Constructs a new window frame.
+		 * Constructs a new window frame.
 		 *
-		 * @param	parent			Parent SceneObject to attach the Component to.
-		 * @param	allowResize		Should the widget set up resize handles that can be dragged by the user.
-		 * @param	camera			Camera to draw the GUI elements in.
-		 * @param	ownerWindow		Window that the frame widget will act on.
-		 * @param	skin			GUI skin used for the GUI child elements.
+		 * @param[in]	parent			Parent SceneObject to attach the Component to.
+		 * @param[in]	allowResize		Should the widget set up resize handles that can be dragged by the user.
+		 * @param[in]	camera			Camera to draw the GUI elements in.
+		 * @param[in]	ownerWindow		Window that the frame widget will act on.
+		 * @param[in]	skin			GUI skin used for the GUI child elements.
 		 */
-		WindowFrameWidget(const HSceneObject& parent, bool allowResize, const CameraPtr& camera, RenderWindow* ownerWindow, const HGUISkin& skin);
+		WindowFrameWidget(const HSceneObject& parent, bool allowResize, const CameraPtr& camera, RenderWindow* ownerWindow, 
+			const HGUISkin& skin);
 		virtual ~WindowFrameWidget();
 
 	protected:
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update() override;
+		/** @copydoc GUIWidget::ownerWindowFocusChanged */
+		void ownerWindowFocusChanged() override;
 
-		/**
-		 * @copydoc	GUIWidget::ownerWindowFocusChanged
-		 */
-		virtual void ownerWindowFocusChanged() override;
-
-		/**
-		 * @copydoc	GUIWidget::ownerTargetResized
-		 */
-		virtual void ownerTargetResized() override;
+		/** @copydoc GUIWidget::ownerTargetResized */
+		void ownerTargetResized() override;
 
 		/**
-		 * @brief	Updates the non-client areas that notify the OS where the interactable elements
-		 *			used for window resize operations are. This should be called after any resize
-		 *			operations.
+		 * Updates the non-client areas that notify the OS where the interactable elements used for window resize 
+		 * operations are. This should be called after any resize operations.
 		 */
 		void refreshNonClientAreas() const;
 

+ 33 - 33
BansheeEditor/Include/BsGUIWindowFrameWidgetRTTI.h

@@ -1,34 +1,34 @@
-#pragma once
-
-#include "BsEditorPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsGUIWindowFrameWidget.h"
-#include "BsGameObjectRTTI.h"
-
-namespace BansheeEngine
-{
-	class BS_ED_EXPORT WindowFrameWidgetRTTI : public RTTIType <WindowFrameWidget, CGUIWidget, WindowFrameWidgetRTTI>
-	{
-	private:
-
-	public:
-		WindowFrameWidgetRTTI()
-		{ }
-
-		virtual const String& getRTTIName() override
-		{
-			static String name = "WindowFrameWidget";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() override
-		{
-			return TID_WindowFrameWidget;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() override
-		{
-			return GameObjectRTTI::createGameObject<WindowFrameWidget>();
-		}
-	};
+#pragma once
+
+#include "BsEditorPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsGUIWindowFrameWidget.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	class BS_ED_EXPORT WindowFrameWidgetRTTI : public RTTIType <WindowFrameWidget, CGUIWidget, WindowFrameWidgetRTTI>
+	{
+	private:
+
+	public:
+		WindowFrameWidgetRTTI()
+		{ }
+
+		virtual const String& getRTTIName() override
+		{
+			static String name = "WindowFrameWidget";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() override
+		{
+			return TID_WindowFrameWidget;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<WindowFrameWidget>();
+		}
+	};
 }

+ 3 - 8
BansheeEditor/Source/BsDockManager.cpp

@@ -18,16 +18,11 @@
 #include "BsDragAndDropManager.h"
 #include "BsGUIDockSlider.h"
 #include "BsVertexDataDesc.h"
-#include "BsGUISkin.h"
-#include "BsBuiltinResources.h"
 #include "BsDockManagerLayout.h"
 #include "BsEditorWindow.h"
 #include "BsGUIPanel.h"
 #include "BsCoreThread.h"
 #include "BsRendererUtility.h"
-#include "BsGUISkin.h"
-#include "BsGUIButton.h"
-#include <BsSelectionRenderer.h>
 
 using namespace std::placeholders;
 
@@ -139,7 +134,7 @@ namespace BansheeEngine
 		guiWidget->setSkin(BuiltinEditorResources::instance().getSkin());
 
 		mIsLeaf = true;
-		mWidgets = bs_new<EditorWidgetContainer>(guiWidget.get(), parentWindow);
+		mWidgets = bs_new<EditorWidgetContainer>(guiWidget->_getInternal(), parentWindow);
 
 		mWidgets->onWidgetClosed.connect(std::bind(&DockManager::DockContainer::widgetRemoved, this));
 		mWidgets->onMaximized.connect(std::bind(&DockManager::DockContainer::maximizeClicked, this));
@@ -1006,7 +1001,7 @@ namespace BansheeEngine
 
 			const Vector2I& widgetRelPos = event.getPosition();
 
-			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
+			const Matrix4& worldTfrm = _getParentWidget()->getWorldTfrm();
 
 			Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);
@@ -1064,7 +1059,7 @@ namespace BansheeEngine
 			EditorWidgetBase* draggedWidget = reinterpret_cast<EditorWidgetBase*>(DragAndDropManager::instance().getDragData());
 
 			const Vector2I& widgetRelPos = event.getPosition();
-			const Matrix4& worldTfrm = _getParentWidget()->SO()->getWorldTfrm();
+			const Matrix4& worldTfrm = _getParentWidget()->getWorldTfrm();
 
 			Vector4 tfrmdPos = worldTfrm.multiplyAffine(Vector4((float)widgetRelPos.x, (float)widgetRelPos.y, 0.0f, 1.0f));
 			Vector2 windowPosVec(tfrmdPos.x, tfrmdPos.y);

+ 119 - 119
BansheeEditor/Source/BsDropDownWindow.cpp

@@ -1,120 +1,120 @@
-#include "BsDropDownWindow.h"
-#include "BsSceneObject.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIPanel.h"
-#include "BsGUITexture.h"
-#include "BsGUIWindowFrame.h"
-#include "BsDropDownAreaPlacement.h"
-#include "BsBuiltinEditorResources.h"
-#include "BsGUIDropDownHitBox.h"
-#include "BsDropDownWindowManager.h"
-#include "BsCamera.h"
-
-namespace BansheeEngine
-{
-	DropDownWindow::DropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
-		const Vector2I& position, UINT32 width, UINT32 height)
-		:mRootPanel(nullptr), mPosition(position), mWidth(width), mHeight(height), 
-		mRenderWindow(parent), mFrontHitBox(nullptr), mBackHitBox(nullptr)
-	{
-		mSceneObject = SceneObject::create("EditorWindow", SOF_Internal | SOF_Persistent | SOF_DontSave);
-
-		mGUI = mSceneObject->addComponent<CGUIWidget>(camera);
-
-		mGUI->setDepth(0); // Needs to be in front of everything
-		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());
-
-		mRootPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
-		
-		GUIPanel* frontHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::min());
-		mFrontHitBox = GUIDropDownHitBox::create(false, false);
-		mFrontHitBox->onFocusLost.connect(std::bind(&DropDownWindow::dropDownFocusLost, this));
-		mFrontHitBox->setFocus(true);
-		frontHitBoxPanel->addElement(mFrontHitBox);
-
-		GUIPanel* backHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
-		mBackHitBox = GUIDropDownHitBox::create(false, true);
-		backHitBoxPanel->addElement(mBackHitBox);
-		
-		ViewportPtr viewport = camera->getViewport();
-		GUIPanel* captureHitBoxPanel = mGUI->getPanel()->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
-		GUIDropDownHitBox* captureHitBox = GUIDropDownHitBox::create(true, false);
-		captureHitBox->setBounds(Rect2I(0, 0, viewport->getWidth(), viewport->getHeight()));
-		captureHitBoxPanel->addElement(captureHitBox);
-
-		setSize(width, height);
-
-		GUIPanel* backgroundPanel = mRootPanel->addNewElement<GUIPanel>(500);
-		backgroundPanel->addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit,
-			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));
-
-		GUIPanel* windowFramePanel = mRootPanel->addNewElement<GUIPanel>(499);
-
-		GUIWindowFrame* windowFrame = GUIWindowFrame::create("WindowFrame");
-		windowFramePanel->addElement(windowFrame);
-
-		mContents = mRootPanel->addNewElement<GUIPanel>();
-		mContents->setPosition(1, 1);
-		mContents->setWidth(width - 2);
-		mContents->setHeight(height - 2);
-	}
-
-	DropDownWindow::~DropDownWindow()
-	{
-		mSceneObject->destroy();
-	}
-
-	Vector2I DropDownWindow::screenToWindowPos(const Vector2I& screenPos) const
-	{
-		Vector2I renderWindowPos = mRenderWindow->screenToWindowPos(screenPos);
-
-		Vector2I contentsPos = renderWindowPos;
-		Rect2I contentArea = mContents->getGlobalBounds();
-
-		contentsPos.x -= contentArea.x;
-		contentsPos.y -= contentArea.y;
-
-		return contentsPos;
-	}
-
-	Vector2I DropDownWindow::windowToScreenPos(const Vector2I& windowPos) const
-	{
-		Vector2I contentsPos = windowPos;
-		Rect2I contentArea = mContents->getGlobalBounds();
-
-		contentsPos.x += contentArea.x;
-		contentsPos.y += contentArea.y;
-
-		return mRenderWindow->windowToScreenPos(contentsPos);
-	}
-
-	void DropDownWindow::setSize(UINT32 width, UINT32 height)
-	{
-		Rect2I availableBounds(0, 0, mGUI->getTarget()->getWidth(), mGUI->getTarget()->getHeight());
-		DropDownAreaPlacement dropDownPlacement = DropDownAreaPlacement::aroundPosition(mPosition);
-
-		DropDownAreaPlacement::HorzDir horzDir;
-		DropDownAreaPlacement::VertDir vertDir;
-		Rect2I placementBounds = dropDownPlacement.getOptimalBounds(width, height, availableBounds, horzDir, vertDir);
-
-		mRootPanel->setPosition(placementBounds.x, placementBounds.y);
-		mRootPanel->setWidth(width);
-		mRootPanel->setHeight(height);
-
-		mFrontHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
-		mBackHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
-
-		mWidth = width;
-		mHeight = height;
-	}
-
-	void DropDownWindow::close()
-	{
-		DropDownWindowManager::instance().close();
-	}
-
-	void DropDownWindow::dropDownFocusLost()
-	{
-		close();
-	}
+#include "BsDropDownWindow.h"
+#include "BsSceneObject.h"
+#include "BsCGUIWidget.h"
+#include "BsGUIPanel.h"
+#include "BsGUITexture.h"
+#include "BsGUIWindowFrame.h"
+#include "BsDropDownAreaPlacement.h"
+#include "BsBuiltinEditorResources.h"
+#include "BsGUIDropDownHitBox.h"
+#include "BsDropDownWindowManager.h"
+#include "BsCamera.h"
+
+namespace BansheeEngine
+{
+	DropDownWindow::DropDownWindow(const RenderWindowPtr& parent, const CameraPtr& camera,
+		const Vector2I& position, UINT32 width, UINT32 height)
+		:mRootPanel(nullptr), mPosition(position), mWidth(width), mHeight(height), 
+		mRenderWindow(parent), mFrontHitBox(nullptr), mBackHitBox(nullptr)
+	{
+		mSceneObject = SceneObject::create("EditorWindow", SOF_Internal | SOF_Persistent | SOF_DontSave);
+
+		mGUI = mSceneObject->addComponent<CGUIWidget>(camera);
+
+		mGUI->setDepth(0); // Needs to be in front of everything
+		mGUI->setSkin(BuiltinEditorResources::instance().getSkin());
+
+		mRootPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
+		
+		GUIPanel* frontHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::min());
+		mFrontHitBox = GUIDropDownHitBox::create(false, false);
+		mFrontHitBox->onFocusLost.connect(std::bind(&DropDownWindow::dropDownFocusLost, this));
+		mFrontHitBox->setFocus(true);
+		frontHitBoxPanel->addElement(mFrontHitBox);
+
+		GUIPanel* backHitBoxPanel = mRootPanel->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
+		mBackHitBox = GUIDropDownHitBox::create(false, true);
+		backHitBoxPanel->addElement(mBackHitBox);
+		
+		ViewportPtr viewport = camera->getViewport();
+		GUIPanel* captureHitBoxPanel = mGUI->getPanel()->addNewElement<GUIPanel>(std::numeric_limits<INT16>::max());
+		GUIDropDownHitBox* captureHitBox = GUIDropDownHitBox::create(true, false);
+		captureHitBox->setBounds(Rect2I(0, 0, viewport->getWidth(), viewport->getHeight()));
+		captureHitBoxPanel->addElement(captureHitBox);
+
+		setSize(width, height);
+
+		GUIPanel* backgroundPanel = mRootPanel->addNewElement<GUIPanel>(500);
+		backgroundPanel->addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit,
+			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));
+
+		GUIPanel* windowFramePanel = mRootPanel->addNewElement<GUIPanel>(499);
+
+		GUIWindowFrame* windowFrame = GUIWindowFrame::create("WindowFrame");
+		windowFramePanel->addElement(windowFrame);
+
+		mContents = mRootPanel->addNewElement<GUIPanel>();
+		mContents->setPosition(1, 1);
+		mContents->setWidth(width - 2);
+		mContents->setHeight(height - 2);
+	}
+
+	DropDownWindow::~DropDownWindow()
+	{
+		mSceneObject->destroy();
+	}
+
+	Vector2I DropDownWindow::screenToWindowPos(const Vector2I& screenPos) const
+	{
+		Vector2I renderWindowPos = mRenderWindow->screenToWindowPos(screenPos);
+
+		Vector2I contentsPos = renderWindowPos;
+		Rect2I contentArea = mContents->getGlobalBounds();
+
+		contentsPos.x -= contentArea.x;
+		contentsPos.y -= contentArea.y;
+
+		return contentsPos;
+	}
+
+	Vector2I DropDownWindow::windowToScreenPos(const Vector2I& windowPos) const
+	{
+		Vector2I contentsPos = windowPos;
+		Rect2I contentArea = mContents->getGlobalBounds();
+
+		contentsPos.x += contentArea.x;
+		contentsPos.y += contentArea.y;
+
+		return mRenderWindow->windowToScreenPos(contentsPos);
+	}
+
+	void DropDownWindow::setSize(UINT32 width, UINT32 height)
+	{
+		Rect2I availableBounds(0, 0, mGUI->getTarget()->getWidth(), mGUI->getTarget()->getHeight());
+		DropDownAreaPlacement dropDownPlacement = DropDownAreaPlacement::aroundPosition(mPosition);
+
+		DropDownAreaPlacement::HorzDir horzDir;
+		DropDownAreaPlacement::VertDir vertDir;
+		Rect2I placementBounds = dropDownPlacement.getOptimalBounds(width, height, availableBounds, horzDir, vertDir);
+
+		mRootPanel->setPosition(placementBounds.x, placementBounds.y);
+		mRootPanel->setWidth(width);
+		mRootPanel->setHeight(height);
+
+		mFrontHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
+		mBackHitBox->setBounds(Rect2I(placementBounds.x, placementBounds.y, width, height));
+
+		mWidth = width;
+		mHeight = height;
+	}
+
+	void DropDownWindow::close()
+	{
+		DropDownWindowManager::instance().close();
+	}
+
+	void DropDownWindow::dropDownFocusLost()
+	{
+		close();
+	}
 }

+ 2 - 4
BansheeEditor/Source/BsEditorWidget.cpp

@@ -1,11 +1,9 @@
 #include "BsEditorWidget.h"
 #include "BsGUIManager.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUITexture.h"
-#include "BsGUISkin.h"
 #include "BsGUILayout.h"
 #include "BsGUIPanel.h"
-#include "BsBuiltinResources.h"
 #include "BsEditorWidgetContainer.h"
 #include "BsEditorWidgetManager.h"
 #include "BsEditorWindow.h"
@@ -171,7 +169,7 @@ namespace BansheeEngine
 		mIsActive = true;
 	}
 
-	CGUIWidget& EditorWidgetBase::getParentWidget() const
+	GUIWidget& EditorWidgetBase::getParentWidget() const
 	{
 		return mParent->getParentWidget();
 	}

+ 2 - 3
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -4,9 +4,8 @@
 #include "BsDragAndDropManager.h"
 #include "BsEditorWindow.h"
 #include "BsGUIPanel.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsMath.h"
-#include "BsInput.h"
 #include "BsGUILayoutX.h"
 #include "BsCursor.h"
 
@@ -16,7 +15,7 @@ namespace BansheeEngine
 {
 	const UINT32 EditorWidgetContainer::TitleBarHeight = 16;
 
-	EditorWidgetContainer::EditorWidgetContainer(CGUIWidget* parent, EditorWindowBase* parentEditorWindow)
+	EditorWidgetContainer::EditorWidgetContainer(GUIWidget* parent, EditorWindowBase* parentEditorWindow)
 		:mParent(parent), mX(0), mY(0), mWidth(0), mHeight(0), mTitleBar(nullptr), mActiveWidget(-1),
 		mTitleBarPanel(nullptr), mParentWindow(parentEditorWindow)
 	{

+ 2 - 1
BansheeEditor/Source/BsEditorWindow.cpp

@@ -3,12 +3,13 @@
 #include "BsEditorWindowManager.h"
 #include "BsDragAndDropManager.h"
 #include "BsRenderWindow.h"
+#include "BsCGUIWidget.h"
 #include "BsCoreThread.h"
 
 namespace BansheeEngine
 {
 	EditorWindow::EditorWindow()
-		:EditorWindowBase(), mWidgets(bs_new<EditorWidgetContainer>(mGUI.get(), this))
+		:EditorWindowBase(), mWidgets(bs_new<EditorWidgetContainer>(mGUI->_getInternal(), this))
 	{
 		updateSize();
 		

+ 0 - 1
BansheeEditor/Source/BsEditorWindowBase.cpp

@@ -4,7 +4,6 @@
 #include "BsSceneObject.h"
 #include "BsRenderWindow.h"
 #include "BsMainEditorWindow.h"
-
 #include "BsEditorWindowManager.h"
 #include "BsCCamera.h"
 #include "BsGUIWindowFrameWidget.h"

+ 1 - 4
BansheeEditor/Source/BsGUIColor.cpp

@@ -1,13 +1,10 @@
 #include "BsGUIColor.h"
 #include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIHelper.h"
 #include "BsBuiltinResources.h"
-#include "BsTexture.h"
+#include "BsSpriteTexture.h"
 
 namespace BansheeEngine
 {

+ 0 - 5
BansheeEditor/Source/BsGUIColorField.cpp

@@ -2,11 +2,6 @@
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIColor.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
-#include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;
 

+ 0 - 5
BansheeEditor/Source/BsGUIDockSlider.cpp

@@ -1,11 +1,6 @@
 #include "BsGUIDockSlider.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUITabbedTitleBar.h"
-#include "BsCursor.h"
-#include "BsPlatform.h"
 
 namespace BansheeEngine
 {

+ 0 - 7
BansheeEditor/Source/BsGUIDropButton.cpp

@@ -1,13 +1,6 @@
 #include "BsGUIDropButton.h"
-#include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
-#include "BsTextSprite.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
-#include "BsGUIHelper.h"
-#include "BsTexture.h"
 #include "BsDragAndDropManager.h"
 
 namespace BansheeEngine

+ 0 - 2
BansheeEditor/Source/BsGUIFieldBase.cpp

@@ -1,8 +1,6 @@
 #include "BsGUIFieldBase.h"
 #include "BsGUILabel.h"
 #include "BsGUILayoutX.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 #include "BsGUILayoutUtility.h"
 
 namespace BansheeEngine

+ 2 - 5
BansheeEditor/Source/BsGUIFloatField.cpp

@@ -2,13 +2,10 @@
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"
-#include "BsGUISpace.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsCursor.h"
-#include "BsCGUIWidget.h"
 #include "BsViewport.h"
+#include "BsCursor.h"
 #include "BsCmdInputFieldValueChange.h"
 #include <regex>
 

+ 49 - 52
BansheeEditor/Source/BsGUIHoverHitBox.cpp

@@ -1,53 +1,50 @@
-#include "BsGUIHoverHitBox.h"
-#include "BsGUICommandEvent.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-
-namespace BansheeEngine
-{
-	const String& GUIHoverHitBox::getGUITypeName()
-	{
-		static String name = "HoverHitBox";
-		return name;
-	}
-
-	GUIHoverHitBox* GUIHoverHitBox::create()
-	{
-		return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create());
-	}
-
-	GUIHoverHitBox* GUIHoverHitBox::create(const GUIOptions& options)
-	{
-		return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create(options));
-	}
-
-	GUIHoverHitBox::GUIHoverHitBox(const GUIDimensions& dimensions)
-		:GUIElementContainer(dimensions)
-	{
-
-	}
-
-	void GUIHoverHitBox::updateClippedBounds()
-	{
-		mClippedBounds = mLayoutData.area;
-	}
-
-	bool GUIHoverHitBox::_mouseEvent(const GUIMouseEvent& ev)
-	{
-		bool processed = GUIElementContainer::_mouseEvent(ev);
-
-		if (ev.getType() == GUIMouseEventType::MouseOver)
-		{
-			onHover();
-			return false;
-		}
-		else if (ev.getType() == GUIMouseEventType::MouseOut)
-		{
-			onOut();
-			return false;
-		}
-
-		return processed;
-	}
+#include "BsGUIHoverHitBox.h"
+#include "BsGUIMouseEvent.h"
+
+namespace BansheeEngine
+{
+	const String& GUIHoverHitBox::getGUITypeName()
+	{
+		static String name = "HoverHitBox";
+		return name;
+	}
+
+	GUIHoverHitBox* GUIHoverHitBox::create()
+	{
+		return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create());
+	}
+
+	GUIHoverHitBox* GUIHoverHitBox::create(const GUIOptions& options)
+	{
+		return new (bs_alloc<GUIHoverHitBox>()) GUIHoverHitBox(GUIDimensions::create(options));
+	}
+
+	GUIHoverHitBox::GUIHoverHitBox(const GUIDimensions& dimensions)
+		:GUIElementContainer(dimensions)
+	{
+
+	}
+
+	void GUIHoverHitBox::updateClippedBounds()
+	{
+		mClippedBounds = mLayoutData.area;
+	}
+
+	bool GUIHoverHitBox::_mouseEvent(const GUIMouseEvent& ev)
+	{
+		bool processed = GUIElementContainer::_mouseEvent(ev);
+
+		if (ev.getType() == GUIMouseEventType::MouseOver)
+		{
+			onHover();
+			return false;
+		}
+		else if (ev.getType() == GUIMouseEventType::MouseOut)
+		{
+			onOut();
+			return false;
+		}
+
+		return processed;
+	}
 };

+ 1 - 4
BansheeEditor/Source/BsGUIIntField.cpp

@@ -2,11 +2,8 @@
 #include "BsGUILayout.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"
-#include "BsGUISpace.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
 #include "BsCursor.h"
 #include "BsUndoRedo.h"
 #include "BsViewport.h"

+ 223 - 227
BansheeEditor/Source/BsGUIListBoxField.cpp

@@ -1,228 +1,224 @@
-#include "BsGUIListBoxField.h"
-#include "BsGUILayoutX.h"
-#include "BsGUILabel.h"
-#include "BsGUIListBox.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	const UINT32 GUIListBoxField::DEFAULT_LABEL_WIDTH = 100;
-
-	GUIListBoxField::GUIListBoxField(const PrivatelyConstruct& dummy, const Vector<HString>& elements, bool multiselect,
-		const GUIContent& labelContent, UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel)
-		:GUIElementContainer(dimensions, style), mListBox(nullptr), mLayout(nullptr), mLabel(nullptr)
-	{
-		mLayout = GUILayoutX::create();
-		_registerChildElement(mLayout);
-
-		if (withLabel)
-		{
-			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(getLabelStyleType()));
-			mLayout->addElement(mLabel);
-		}
-
-		mListBox = GUIListBox::create(elements, multiselect, getSubStyleName(getListBoxStyleType()));
-		mLayout->addElement(mListBox);
-
-		mListBox->onSelectionToggled.connect(std::bind(&GUIListBoxField::selectionChanged, this, _1, _2));
-	}
-
-	GUIListBoxField::~GUIListBoxField()
-	{
-
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, 
-		UINT32 labelWidth, const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, 
-		const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, 
-		UINT32 labelWidth, const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, 
-		const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), 
-			DEFAULT_LABEL_WIDTH, *curStyle, GUIDimensions::create(options), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIOptions& options, 
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(options), false);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIListBoxField::getGUITypeName();
-
-		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(), false);
-	}
-
-	bool GUIListBoxField::isMultiselect() const
-	{
-		return mListBox->isMultiselect();
-	}
-
-	void GUIListBoxField::setElements(const Vector<HString>& elements)
-	{
-		mListBox->setElements(elements);
-	}
-
-	void GUIListBoxField::selectElement(UINT32 index)
-	{
-		mListBox->selectElement(index);
-	}
-
-	void GUIListBoxField::deselectElement(UINT32 idx)
-	{
-		mListBox->deselectElement(idx);
-	}
-
-	const Vector<bool>& GUIListBoxField::getElementStates() const
-	{
-		return mListBox->getElementStates();
-	}
-
-	void GUIListBoxField::setElementStates(const Vector<bool>& states)
-	{
-		mListBox->setElementStates(states);
-	}
-
-	void GUIListBoxField::setTint(const Color& color)
-	{
-		if (mLabel != nullptr)
-			mLabel->setTint(color);
-
-		mListBox->setTint(color);
-	}
-
-	void GUIListBoxField::_updateLayoutInternal(const GUILayoutData& data)
-	{
-		mLayout->_setLayoutData(data);
-		mLayout->_updateLayoutInternal(data);
-	}
-
-	Vector2I GUIListBoxField::_getOptimalSize() const
-	{
-		return mLayout->_getOptimalSize();
-	}
-
-	void GUIListBoxField::styleUpdated()
-	{
-		if (mLabel != nullptr)
-			mLabel->setStyle(getSubStyleName(getLabelStyleType()));
-
-		mListBox->setStyle(getSubStyleName(getListBoxStyleType()));
-	}
-
-	void GUIListBoxField::selectionChanged(UINT32 newIndex, bool enabled)
-	{
-		onSelectionChanged(newIndex, enabled);
-	}
-
-	const String& GUIListBoxField::getGUITypeName()
-	{
-		static String typeName = "GUIListBoxField";
-		return typeName;
-	}
-
-	const String& GUIListBoxField::getListBoxStyleType()
-	{
-		static String LISTBOX_STYLE_TYPE = "EditorFieldListBox";
-		return LISTBOX_STYLE_TYPE;
-	}
-
-	const String& GUIListBoxField::getLabelStyleType()
-	{
-		static String LABEL_STYLE_TYPE = "EditorFieldLabel";
-		return LABEL_STYLE_TYPE;
-	}
+#include "BsGUIListBoxField.h"
+#include "BsGUILayoutX.h"
+#include "BsGUILabel.h"
+#include "BsGUIListBox.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	const UINT32 GUIListBoxField::DEFAULT_LABEL_WIDTH = 100;
+
+	GUIListBoxField::GUIListBoxField(const PrivatelyConstruct& dummy, const Vector<HString>& elements, bool multiselect,
+		const GUIContent& labelContent, UINT32 labelWidth, const String& style, const GUIDimensions& dimensions, bool withLabel)
+		:GUIElementContainer(dimensions, style), mListBox(nullptr), mLayout(nullptr), mLabel(nullptr)
+	{
+		mLayout = GUILayoutX::create();
+		_registerChildElement(mLayout);
+
+		if (withLabel)
+		{
+			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(getLabelStyleType()));
+			mLayout->addElement(mLabel);
+		}
+
+		mListBox = GUIListBox::create(elements, multiselect, getSubStyleName(getListBoxStyleType()));
+		mLayout->addElement(mListBox);
+
+		mListBox->onSelectionToggled.connect(std::bind(&GUIListBoxField::selectionChanged, this, _1, _2));
+	}
+
+	GUIListBoxField::~GUIListBoxField()
+	{
+
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, 
+		UINT32 labelWidth, const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, labelWidth, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, 
+		const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, 
+		UINT32 labelWidth, const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), labelWidth, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, 
+		const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), 
+			DEFAULT_LABEL_WIDTH, *curStyle, GUIDimensions::create(options), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIOptions& options, 
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(), 0, *curStyle,
+			GUIDimensions::create(options), false);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent, UINT32 labelWidth,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, labelWidth, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const GUIContent& labelContent,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText, UINT32 labelWidth,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), labelWidth, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const HString& labelText,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIListBoxField* GUIListBoxField::create(const Vector<HString>& elements, bool multiselect, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIListBoxField::getGUITypeName();
+
+		return bs_new<GUIListBoxField>(PrivatelyConstruct(), elements, multiselect, GUIContent(), 0, *curStyle,
+			GUIDimensions::create(), false);
+	}
+
+	bool GUIListBoxField::isMultiselect() const
+	{
+		return mListBox->isMultiselect();
+	}
+
+	void GUIListBoxField::setElements(const Vector<HString>& elements)
+	{
+		mListBox->setElements(elements);
+	}
+
+	void GUIListBoxField::selectElement(UINT32 index)
+	{
+		mListBox->selectElement(index);
+	}
+
+	void GUIListBoxField::deselectElement(UINT32 idx)
+	{
+		mListBox->deselectElement(idx);
+	}
+
+	const Vector<bool>& GUIListBoxField::getElementStates() const
+	{
+		return mListBox->getElementStates();
+	}
+
+	void GUIListBoxField::setElementStates(const Vector<bool>& states)
+	{
+		mListBox->setElementStates(states);
+	}
+
+	void GUIListBoxField::setTint(const Color& color)
+	{
+		if (mLabel != nullptr)
+			mLabel->setTint(color);
+
+		mListBox->setTint(color);
+	}
+
+	void GUIListBoxField::_updateLayoutInternal(const GUILayoutData& data)
+	{
+		mLayout->_setLayoutData(data);
+		mLayout->_updateLayoutInternal(data);
+	}
+
+	Vector2I GUIListBoxField::_getOptimalSize() const
+	{
+		return mLayout->_getOptimalSize();
+	}
+
+	void GUIListBoxField::styleUpdated()
+	{
+		if (mLabel != nullptr)
+			mLabel->setStyle(getSubStyleName(getLabelStyleType()));
+
+		mListBox->setStyle(getSubStyleName(getListBoxStyleType()));
+	}
+
+	void GUIListBoxField::selectionChanged(UINT32 newIndex, bool enabled)
+	{
+		onSelectionChanged(newIndex, enabled);
+	}
+
+	const String& GUIListBoxField::getGUITypeName()
+	{
+		static String typeName = "GUIListBoxField";
+		return typeName;
+	}
+
+	const String& GUIListBoxField::getListBoxStyleType()
+	{
+		static String LISTBOX_STYLE_TYPE = "EditorFieldListBox";
+		return LISTBOX_STYLE_TYPE;
+	}
+
+	const String& GUIListBoxField::getLabelStyleType()
+	{
+		static String LABEL_STYLE_TYPE = "EditorFieldLabel";
+		return LABEL_STYLE_TYPE;
+	}
 }

+ 2 - 2
BansheeEditor/Source/BsGUIMenuBar.cpp

@@ -57,7 +57,7 @@ namespace BansheeEngine
 		return type;
 	}
 
-	GUIMenuBar::GUIMenuBar(CGUIWidget* parent, RenderWindow* parentWindow)
+	GUIMenuBar::GUIMenuBar(GUIWidget* parent, RenderWindow* parentWindow)
 		:mParentWidget(parent), mParentWindow(parentWindow), mMainPanel(nullptr), mMenuItemLayout(nullptr),
 		mBgTexture(nullptr), mLogoTexture(nullptr), mSubMenuOpen(false), mSubMenuButton(nullptr), mBgPanel(nullptr)
 	{
@@ -467,7 +467,7 @@ namespace BansheeEngine
 				return;
 		}
 
-		CGUIWidget* widget = subMenu->button->_getParentWidget();
+		GUIWidget* widget = subMenu->button->_getParentWidget();
 
 		DROP_DOWN_BOX_DESC desc;
 		desc.camera = widget->getCamera();

+ 2 - 7
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -1,16 +1,11 @@
 #include "BsGUIResourceTreeView.h"
-#include "BsGUISkin.h"
 #include "BsProjectLibrary.h"
 #include "BsDragAndDropManager.h"
-#include "BsResources.h"
-#include "BsResourceManifest.h"
-#include "BsProjectLibrary.h"
 #include "BsFileSystem.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsViewport.h"
 #include "BsRenderWindow.h"
 #include "BsPlatform.h"
-#include "BsSelection.h"
 
 using namespace std::placeholders;
 
@@ -453,7 +448,7 @@ namespace BansheeEngine
 		}
 	}
 
-	void GUIResourceTreeView::_changeParentWidget(CGUIWidget* widget)
+	void GUIResourceTreeView::_changeParentWidget(GUIWidget* widget)
 	{
 		GUITreeView::_changeParentWidget(widget);
 

+ 1 - 7
BansheeEditor/Source/BsGUISliderField.cpp

@@ -1,15 +1,9 @@
 #include "BsGUISliderField.h"
 #include "BsGUILayout.h"
-#include "BsGUILabel.h"
 #include "BsGUIInputBox.h"
 #include "BsGUISpace.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCursor.h"
-#include "BsCGUIWidget.h"
-#include "BsViewport.h"
 #include "BsGUISlider.h"
+#include "BsGUILabel.h"
 #include "BsCmdInputFieldValueChange.h"
 #include <regex>
 

+ 0 - 5
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -1,17 +1,12 @@
 #include "BsGUITabbedTitleBar.h"
-#include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIButton.h"
 #include "BsGUITabButton.h"
-#include "BsGUISpace.h"
 #include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
 #include "BsGUIMouseEvent.h"
 #include "BsDragAndDropManager.h"
 #include "BsEditorWidget.h"
 #include "BsMath.h"
-#include "BsPlatform.h"
-#include "BsRenderTarget.h"
 
 using namespace std::placeholders;
 

+ 0 - 4
BansheeEditor/Source/BsGUITextField.cpp

@@ -2,10 +2,6 @@
 #include "BsGUILayoutX.h"
 #include "BsGUILabel.h"
 #include "BsGUIInputBox.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
 #include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;

+ 1 - 5
BansheeEditor/Source/BsGUIToggleField.cpp

@@ -1,11 +1,7 @@
 #include "BsGUIToggleField.h"
 #include "BsGUILayout.h"
-#include "BsGUILabel.h"
 #include "BsGUIToggle.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
+#include "BsGUILabel.h"
 #include "BsCmdInputFieldValueChange.h"
 
 using namespace std::placeholders;

+ 0 - 2
BansheeEditor/Source/BsGUITreeViewEditBox.cpp

@@ -1,7 +1,5 @@
 #include "BsGUITreeViewEditBox.h"
 #include "BsGUICommandEvent.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 
 namespace BansheeEngine
 {

+ 1 - 6
BansheeEditor/Source/BsGUIVector2Field.cpp

@@ -1,13 +1,8 @@
 #include "BsGUIVector2Field.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
-#include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUISpace.h"
-#include "BsCGUIWidget.h"
+#include "BsGUILabel.h"
 
 using namespace std::placeholders;
 

+ 1 - 6
BansheeEditor/Source/BsGUIVector3Field.cpp

@@ -1,13 +1,8 @@
 #include "BsGUIVector3Field.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
-#include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUISpace.h"
-#include "BsCGUIWidget.h"
+#include "BsGUILabel.h"
 
 using namespace std::placeholders;
 

+ 1 - 6
BansheeEditor/Source/BsGUIVector4Field.cpp

@@ -1,13 +1,8 @@
 #include "BsGUIVector4Field.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
-#include "BsGUILabel.h"
 #include "BsGUIFloatField.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUISpace.h"
-#include "BsCGUIWidget.h"
+#include "BsGUILabel.h"
 
 using namespace std::placeholders;
 

+ 0 - 8
BansheeEditor/Source/BsGUIWindowFrame.cpp

@@ -1,14 +1,6 @@
 #include "BsGUIWindowFrame.h"
-#include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
-#include "BsGUIMouseEvent.h"
-#include "BsCoreApplication.h"
-#include "BsPlatform.h"
-#include "BsTexture.h"
-#include "BsRenderWindow.h"
 
 namespace BansheeEngine
 {

+ 1 - 9
BansheeEditor/Source/BsGUIWindowFrameWidget.cpp

@@ -5,10 +5,7 @@
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIWindowFrame.h"
-#include "BsBuiltinResources.h"
-#include "BsGUIMouseEvent.h"
 #include "BsRenderWindow.h"
-#include "BsMath.h"
 #include "BsPlatform.h"
 
 namespace BansheeEngine
@@ -21,7 +18,7 @@ namespace BansheeEngine
 		setSkin(skin);
 
 		GUIPanel* backgroundPanel = getPanel()->addNewElement<GUIPanel>(500);
-		backgroundPanel->addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit, 
+		backgroundPanel->addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit,
 			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));
 
 		mWindowFramePanel = getPanel()->addNewElement<GUIPanel>(499);
@@ -37,11 +34,6 @@ namespace BansheeEngine
 
 	}
 
-	void WindowFrameWidget::update()
-	{
-
-	}
-
 	void WindowFrameWidget::ownerWindowFocusChanged()
 	{
 		mWindowFrame->setFocused(mParentWindow->getProperties().hasFocus());

+ 1 - 1
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -20,7 +20,7 @@ namespace BansheeEngine
 
 	MainEditorWindow::MainEditorWindow(const RenderWindowPtr& renderWindow)
 		:EditorWindowBase(renderWindow), mDockManager(nullptr), 
-		mMenuBar(bs_new<GUIMenuBar>(mGUI.get(), mRenderWindow.get()))
+		mMenuBar(bs_new<GUIMenuBar>(mGUI->_getInternal(), mRenderWindow.get()))
 	{
 		mDockManager = DockManager::create(this);
 		mGUI->getPanel()->addElement(mDockManager);

+ 4 - 2
BansheeEngine/BansheeEngine.vcxproj

@@ -251,6 +251,7 @@
   </ItemDefinitionGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCamera.cpp" />
+    <ClCompile Include="Source\BsCGUIWidget.cpp" />
     <ClCompile Include="Source\BsCursor.cpp" />
     <ClCompile Include="Source\BsDrawHelper.cpp" />
     <ClCompile Include="Source\BsDropDownAreaPlacement.cpp" />
@@ -288,6 +289,7 @@
     <ClInclude Include="Include\BsApplication.h" />
     <ClInclude Include="Include\BsCamera.h" />
     <ClInclude Include="Include\BsCameraRTTI.h" />
+    <ClInclude Include="Include\BsCGUIWidget.h" />
     <ClInclude Include="Include\BsCursor.h" />
     <ClInclude Include="Include\BsDrawHelper.h" />
     <ClInclude Include="Include\BsDropDownAreaPlacement.h" />
@@ -370,7 +372,7 @@
     <ClInclude Include="Include\BsGUIManager.h" />
     <ClInclude Include="Include\BsGUIMouseEvent.h" />
     <ClInclude Include="Include\BsGUISkin.h" />
-    <ClInclude Include="Include\BsCGUIWidget.h" />
+    <ClInclude Include="Include\BsGUIWidget.h" />
     <ClInclude Include="Include\BsImageSprite.h" />
     <ClInclude Include="Include\BsProfilerOverlay.h" />
     <ClInclude Include="Include\BsRectOffset.h" />
@@ -433,7 +435,7 @@
     <ClCompile Include="Source\BsGUITexture.cpp" />
     <ClCompile Include="Source\BsGUIToggle.cpp" />
     <ClCompile Include="Source\BsGUIToggleGroup.cpp" />
-    <ClCompile Include="Source\BsCGUIWidget.cpp" />
+    <ClCompile Include="Source\BsGUIWidget.cpp" />
     <ClCompile Include="Source\BsImageSprite.cpp" />
     <ClCompile Include="Source\BsProfilerOverlay.cpp" />
     <ClCompile Include="Source\BsSceneManager.cpp" />

+ 12 - 6
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -332,9 +332,6 @@
     <ClInclude Include="Include\BsLightRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsCGUIWidget.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsCGUIWidgetRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
@@ -365,6 +362,12 @@
     <ClInclude Include="Include\BsGUITooltip.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIWidget.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCGUIWidget.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -601,9 +604,6 @@
     <ClCompile Include="Source\BsLight.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsCGUIWidget.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsRenderableHandler.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -628,5 +628,11 @@
     <ClCompile Include="Source\BsGUITooltip.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIWidget.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCGUIWidget.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 103 - 210
BansheeEngine/Include/BsCGUIWidget.h

@@ -1,211 +1,104 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsComponent.h"
-#include "BsRect2I.h"
-#include "BsVector3.h"
-#include "BsQuaternion.h"
-#include "BsEvent.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	A top level container for all types of GUI elements. Every GUI element, layout or area
-	 *			must be assigned to a widget in order to be rendered.
-	 *
-	 *			Widgets are the only GUI objects that may be arbitrarily transformed, allowing you to create
-	 *			3D interfaces.
-	 */
-	class BS_EXPORT CGUIWidget : public Component
-	{
-	public:
-		virtual ~CGUIWidget();
-
-		/**
-		 * @brief	Sets the skin used for all GUI elements in the widget. This will update
-		 *			the look of all current elements.
-		 */
-		void setSkin(const HGUISkin& skin);
-
-		/**
-		 * @brief	Returns the currently active GUI skin.
-		 */
-		const GUISkin& getSkin() const;
-
-		/**
-		 * @brief	Returns the currently active GUI skin resource.
-		 */
-		const HGUISkin& getSkinResource() const { return mSkin; }
-
-		/**
-		 * @brief	Returns the root GUI panel for the widget.
-		 */
-		GUIPanel* getPanel() const { return mPanel; }
-
-		/**
-		 * @brief	Returns the depth to render the widget at. If two widgets overlap the
-		 *			widget with the lower depth will be rendered in front.
-		 */
-		UINT8 getDepth() const { return mDepth; }
-
-		/**
-		 * @brief	Changes the depth to render the widget at. If two widgets overlap the
-		 *			widget with the lower depth will be rendered in front.
-		 */
-		void setDepth(UINT8 depth);
-
-		/**
-		 * @brief	Checks are the specified coordinates within widget bounds. Coordinates should
-		 *			be relative to the parent window.
-		 */
-		bool inBounds(const Vector2I& position) const;
-
-		/**
-		 * @brief	Returns bounds of the widget, relative to the parent window.
-		 */
-		const Rect2I& getBounds() const { return mBounds; }
-
-		/**
-		 * @brief	Return true if widget or any of its elements are dirty.
-		 *
-		 * @param	cleanIfDirty	If true, all dirty elements will be updated and widget will be marked as clean.
-		 *
-		 * @return	True if dirty, false if not. If "cleanIfDirty" is true, the returned state is the one before cleaning.
-		 */
-		bool isDirty(bool cleanIfDirty);
-
-		/**
-		 * @brief	Returns the viewport that this widget will be rendered on.
-		 */
-		Viewport* getTarget() const;
-
-		/**
-		 * @brief	Returns the camera this widget is being rendered to.
-		 */
-		CameraPtr getCamera() const { return mCamera; }
-
-		/**
-		 * @brief	Returns a list of all elements parented to this widget.
-		 */
-		const Vector<GUIElement*>& getElements() const { return mElements; }
-
-		/**
-		 * @brief	Registers a new element as a child of the widget.
-		 *
-		 * @note	Internal method.
-		 */
-		void _registerElement(GUIElementBase* elem);
-		
-		/**
-		 * @brief	Unregisters an element from the widget. Usually called when the element
-		 *			is destroyed, or reparented to another widget.
-		 *
-		 * @note	Internal method.
-		 */
-		void _unregisterElement(GUIElementBase* elem);
-
-		/**
-		 * @brief	Marks the widget mesh dirty requiring a mesh rebuild. Provided element
-		 *			is the one that requested the mesh update.
-		 */
-		void _markMeshDirty(GUIElementBase* elem);
-
-		/**
-		 * @brief	Marks the elements content as dirty, meaning its internal mesh will need to be
-		 *			rebuilt (this implies the entire widget mesh will be rebuilt as well).
-		 */
-		void _markContentDirty(GUIElementBase* elem);
-
-		/**
-		 * @brief	Updates the layout of all child elements, repositioning and resizing them as needed.
-		 */
-		void _updateLayout();
-
-		/**
-		 * @brief	Updates the layout of the provided element, and queues content updates.
-		 */
-		void _updateLayout(GUIElementBase* elem);
-
-	protected:
-		friend class SceneObject;
-		friend class GUIElementBase;
-		friend class GUIManager;
-
-		/**
-		 * @brief	Constructs a new GUI widget attached to the specified parent scene object.
-		 *			Widget elements will be rendered on the provided camera.
-		 */
-		CGUIWidget(const HSceneObject& parent, const CameraPtr& camera);
-
-		/**
-		 * @brief	Constructs a new GUI widget attached to the specified parent scene object.
-		 *			Widget elements will be rendered on the provided camera.
-		 */
-		CGUIWidget(const HSceneObject& parent, const HCamera& camera);
-
-		/**
-		 * @brief	Common code for constructors.
-		 */
-		void construct(const CameraPtr& camera);
-
-		/**
-		 * @brief	Called when the viewport size changes and widget elements need to be updated.
-		 */
-		virtual void ownerTargetResized();
-
-		/**
-		 * @brief	Called when the parent window gained or lost focus.
-		 */
-		virtual void ownerWindowFocusChanged();
-
-		/**
-		 * @copydoc	Component::update
-		 */
-		virtual void update() override;
-
-		/**
-		 * @copydoc	Component::onDestroyed
-		 */
-		virtual void onDestroyed() override;
-	private:
-		CGUIWidget(const CGUIWidget& other) { }
-
-		/**
-		 * @brief	Calculates widget bounds using the bounds of all child elements.
-		 */
-		void updateBounds() const;
-
-		/**
-		 * @brief	Updates the size of the primary GUI panel based on the viewport.
-		 */
-		void updateRootPanel();
-
-		CameraPtr mCamera;
-		Vector<GUIElement*> mElements;
-		GUIPanel* mPanel;
-		UINT8 mDepth;
-
-		Vector3 mLastFramePosition;
-		Quaternion mLastFrameRotation;
-		Vector3 mLastFrameScale;
-
-		HEvent mOwnerTargetResizedConn;
-
-		Set<GUIElement*> mDirtyContents;
-
-		mutable bool mWidgetIsDirty;
-		mutable Rect2I mBounds;
-
-		HGUISkin mSkin;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class CGUIWidgetRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-
-		CGUIWidget() { } // Serialization only
-	};
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsComponent.h"
+#include "BsRect2I.h"
+#include "BsGUIWidget.h"
+
+namespace BansheeEngine
+{
+	/** Component wrapper for GUIWidget. */
+	class BS_EXPORT CGUIWidget : public Component
+	{
+	public:
+		virtual ~CGUIWidget();
+
+		/** @copydoc GUIWidget::setSkin */
+		void setSkin(const HGUISkin& skin);
+
+		/** @copydoc GUIWidget::getSkin */
+		const GUISkin& getSkin() const;
+
+		/** @copydoc GUIWidget::getSkinResource */
+		const HGUISkin& getSkinResource() const;
+
+		/** @copydoc GUIWidget::getPanel */
+		GUIPanel* getPanel() const;
+
+		/** @copydoc GUIWidget::getDepth */
+		UINT8 getDepth() const;
+
+		/** @copydoc GUIWidget::setDepth */
+		void setDepth(UINT8 depth);
+
+		/** @copydoc GUIWidget::inBounds */
+		bool inBounds(const Vector2I& position) const;
+
+		/** @copydoc GUIWidget::getBounds */
+		const Rect2I& getBounds() const;
+
+		/** @copydoc GUIWidget::isDirty */
+		bool isDirty(bool cleanIfDirty);
+
+		/** @copydoc GUIWidget::getTarget */
+		Viewport* getTarget() const;
+
+		/** @copydoc GUIWidget::getCamera */
+		CameraPtr getCamera() const;
+
+		/** @copydoc GUIWidget::getSkin */
+		const Vector<GUIElement*>& getElements() const;
+
+		/** Returns the internal GUIWidget that is wrapped by this component. */
+		GUIWidget* _getInternal() const { return mInternal.get(); };
+
+	protected:
+		friend class SceneObject;
+		friend class GUIElementBase;
+		friend class GUIManager;
+
+		/**
+		 * Constructs a new GUI widget attached to the specified parent scene object. Widget elements will be rendered on
+		 * the provided camera.
+		 */
+		CGUIWidget(const HSceneObject& parent, const CameraPtr& camera);
+
+		/**
+		 * Constructs a new GUI widget attached to the specified parent scene object. Widget elements will be rendered on
+		 * the provided camera.
+		 */
+		CGUIWidget(const HSceneObject& parent, const HCamera& camera);
+
+		/** @copydoc Component::update */
+		void update() override;
+
+		/** @copydoc Component::onDestroyed */
+		void onDestroyed() override;
+
+		/**	Called when the viewport size changes and widget elements need to be updated. */
+		virtual void ownerTargetResized() { }
+
+		/**	Called when the parent window gained or lost focus. */
+		virtual void ownerWindowFocusChanged() { }
+
+	private:
+		CGUIWidget(const CGUIWidget& other) { }
+
+		SPtr<GUIWidget> mInternal;
+		HEvent mOwnerTargetResizedConn;
+		HEvent mOwnerWindowFocusChangedConn;
+
+		CameraPtr mCamera;
+		UINT32 mParentHash;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CGUIWidgetRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		virtual RTTITypeBase* getRTTI() const override;
+
+		CGUIWidget() { } // Serialization only
+	};
 }

+ 33 - 33
BansheeEngine/Include/BsCGUIWidgetRTTI.h

@@ -1,34 +1,34 @@
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsCGUIWidget.h"
-#include "BsGameObjectRTTI.h"
-
-namespace BansheeEngine
-{
-	class BS_EXPORT CGUIWidgetRTTI : public RTTIType <CGUIWidget, Component, CGUIWidgetRTTI>
-	{
-	private:
-
-	public:
-		CGUIWidgetRTTI()
-		{ }
-
-		virtual const String& getRTTIName() override
-		{
-			static String name = "CGUIWidget";
-			return name;
-		}
-
-		virtual UINT32 getRTTIId() override
-		{
-			return TID_CGUIWidget;
-		}
-
-		virtual std::shared_ptr<IReflectable> newRTTIObject() override
-		{
-			return GameObjectRTTI::createGameObject<CGUIWidget>();
-		}
-	};
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCGUIWidget.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT CGUIWidgetRTTI : public RTTIType <CGUIWidget, Component, CGUIWidgetRTTI>
+	{
+	private:
+
+	public:
+		CGUIWidgetRTTI()
+		{ }
+
+		virtual const String& getRTTIName() override
+		{
+			static String name = "CGUIWidget";
+			return name;
+		}
+
+		virtual UINT32 getRTTIId() override
+		{
+			return TID_CGUIWidget;
+		}
+
+		virtual std::shared_ptr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<CGUIWidget>();
+		}
+	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUIContextMenu.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		 * @brief	Opens a context menu at the specified position relative
 		 *			to the provided widget.
 		 */
-		void open(const Vector2I& position, CGUIWidget& widget);
+		void open(const Vector2I& position, GUIWidget& widget);
 
 	private:
 		/**

+ 305 - 307
BansheeEngine/Include/BsGUIDropDownMenu.h

@@ -1,308 +1,306 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsCGUIWidget.h"
-#include "BsVector2I.h"
-#include "BsRect2I.h"
-#include "BsEvent.h"
-#include "BsDropDownAreaPlacement.h"
-
-namespace BansheeEngine
-{
-	/**
-	 * @brief	Contains items used for initializing one level in a drop down box hierarchy.
-	 */
-	struct BS_EXPORT GUIDropDownData
-	{
-		Vector<GUIDropDownDataEntry> entries;
-		Vector<bool> states;
-		UnorderedMap<WString, HString> localizedNames;
-	};
-
-	/**
-	 * @brief	A set of parameters used for initializing a drop down box.
-	 */
-	struct DROP_DOWN_BOX_DESC
-	{
-		CameraPtr camera; /**< Camera on which to open the drop down box. */
-		DropDownAreaPlacement placement; /**< Determines how is the drop down box positioned in the visible area. */
-		GUIDropDownData dropDownData; /**< Data to use for initializing menu items of the drop down box. */
-		HGUISkin skin; /**< Skin to use for drop down box GUI elements. */
-		Vector<Rect2I> additionalBounds; /**< Additional bounds that control what is considered the inside or the outside of the drop down box. */
-	};
-
-	/**
-	 * @brief	Represents a single entry in a drop down box.
-	 */
-	class BS_EXPORT GUIDropDownDataEntry
-	{
-		enum class Type
-		{
-			Separator,
-			Entry,
-			SubMenu
-		};
-
-	public:
-		/**
-		 * @brief	Creates a new separator entry.
-		 */
-		static GUIDropDownDataEntry separator();
-
-		/**
-		 * @brief	Creates a new button entry with the specified callback that is triggered
-		 *			when button is selected.
-		 */
-		static GUIDropDownDataEntry button(const WString& label, std::function<void()> callback, const WString& shortcutTag = StringUtil::WBLANK);
-
-		/**
-		 * @brief	Creates a new sub-menu entry that will open the provided drop down data
-		 *			sub-menu when activated.
-		 */
-		static GUIDropDownDataEntry subMenu(const WString& label, const GUIDropDownData& data);
-
-		/**
-		 * @brief	Check is the entry a separator.
-		 */
-		bool isSeparator() const { return mType == Type::Separator; }
-
-		/**
-		 * @brief	Check is the entry a sub menu.
-		 */
-		bool isSubMenu() const { return mType == Type::SubMenu; }
-
-		/**
-		 * @brief	Returns display label of the entry (if an entry is a button or a sub-menu).
-		 */
-		const WString& getLabel() const { return mLabel; }
-
-		/**
-		 * @brief	Returns the shortcut key combination string that is to be displayed along the entry label.
-		 */
-		const WString& getShortcutTag() const { return mShortcutTag; }
-
-		/**
-		 * @brief	Returns a button callback if the entry (if an entry is a button).
-		 */
-		std::function<void()> getCallback() const { return mCallback; }
-
-		/**
-		 * @brief	Returns sub-menu data that is used for creating a sub-menu (if an entry is a sub-menu).
-		 */
-		const GUIDropDownData& getSubMenuData() const { return mChildData; }
-	private:
-		GUIDropDownDataEntry() { }
-
-		std::function<void()> mCallback;
-		GUIDropDownData mChildData;
-		WString mLabel;
-		WString mShortcutTag;
-		Type mType; 
-	};
-
-	/**
-	 * @brief	Type of drop down box types.
-	 */
-	enum class GUIDropDownType
-	{
-		ListBox,
-		MultiListBox,
-		ContextMenu,
-		MenuBar
-	};
-
-	/**
-	 * @brief	This is a generic GUI drop down box class that can be used for:
-	 * 			list boxes, menu bars or context menus.
-	 */
-	class BS_EXPORT GUIDropDownMenu : public CGUIWidget
-	{
-	public:
-		/**
-		 * @brief	Creates a new drop down box widget.
-		 *
-		 * @param	parent			Parent scene object to attach the drop down box to.
-		 * @param	desc			Various parameters that control the drop down menu features and content.
-		 * @param	type			Specific type of drop down box to display.
-		 */
-		GUIDropDownMenu(const HSceneObject& parent, const DROP_DOWN_BOX_DESC& desc, GUIDropDownType type);
-		~GUIDropDownMenu();
-
-	private:
-		/**
-		 * @brief	Contains data about a single drop down box sub-menu
-		 */
-		struct DropDownSubMenu
-		{
-			/**
-			 * @brief	Represents a single sub-menu page.
-			 */
-			struct PageInfo
-			{
-				UINT32 idx;
-				UINT32 start;
-				UINT32 end;
-				UINT32 height;
-			};
-
-		public:
-			/**
-			 * @brief	Creates a new drop down box sub-menu
-			 *
-			 * @param	owner			Owner drop down box this sub menu belongs to.
-			 * @param	parent			Parent sub-menu. Can be null.
-			 * @param	placement		Determines how is the sub-menu positioned in the visible area.
-			 * @param	availableBounds	Available bounds (in pixels) in which the sub-menu may be opened.
-			 * @param	dropDownData	Data to use for initializing menu items of the sub-menu.
-			 * @param	skin			Skin to use for sub-menu GUI elements.
-			 * @param	depthOffset		How much to offset the sub-menu depth. We want deeper levels of the
-			 *							sub-menu hierarchy to be in front of lower levels, so you should
-			 *							increase this value for each level of the sub-menu hierarchy.
-			 */
-			DropDownSubMenu(GUIDropDownMenu* owner, DropDownSubMenu* parent, const DropDownAreaPlacement& placement, 
-				const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset);
-			~DropDownSubMenu();
-
-			/**
-			 * @brief	Recreates all internal GUI elements for the entries of the current sub-menu page.
-			 */
-			void updateGUIElements();
-
-			/**
-			 * @brief	Moves the sub-menu to the previous page and displays its elements, if available.
-			 */
-			void scrollDown();
-
-			/**
-			 * @brief	Moves the sub-menu to the next page and displays its elements, if available.
-			 */
-			void scrollUp();
-
-			/**
-			 * @brief	Moves the sub-menu to the first page and displays its elements.
-			 */
-			void scrollToTop();
-
-			/**
-			 * @brief	Moves the sub-menu to the last page and displays its elements.
-			 */
-			void scrollToBottom();
-
-			/**
-			 * @brief	Calculates ranges for all the pages of the sub-menu.
-			 */
-			Vector<PageInfo> getPageInfos() const;
-
-			/**
-			 * @brief	Called when the user activates an element with the specified index.
-			 *
-			 * @param	bounds	Bounds of the GUI element that is used as a visual representation
-			 *					of this drop down element.
-			 */
-			void elementActivated(UINT32 idx, const Rect2I& bounds);
-
-			/**
-			 * @brief	Called when the user selects an element with the specified index.
-			 * 
-			 * @param	idx		Index of the element that was selected.
-			 */
-			void elementSelected(UINT32 idx);
-
-			/**
-			 * @brief	Called when the user wants to close the currently open sub-menu.
-			 */
-			void closeSubMenu();
-
-			/**
-			 * @brief	Closes this sub-menu.
-			 */
-			void close();
-
-			/**
-			 * @brief	Returns the type of the displayed drop down menu.
-			 */
-			GUIDropDownType getType() const { return mType; }
-
-			/**
-			 * @brief	Returns actual visible bounds of the sub-menu.
-			 */
-			Rect2I getVisibleBounds() const { return mVisibleBounds; }
-
-			/**
-			 * @brief	Returns the drop box object that owns this sub-menu.
-			 */
-			GUIDropDownMenu* getOwner() const { return mOwner; }
-
-		public:
-			GUIDropDownMenu* mOwner;
-
-			GUIDropDownType mType;
-			GUIDropDownData mData;
-			UINT32 mPage;
-			INT32 x, y;
-			UINT32 width, height;
-			Rect2I mVisibleBounds;
-			Rect2I mAvailableBounds;
-			UINT32 mDepthOffset;
-			bool mOpenedUpward;
-
-			GUIDropDownContent* mContent;
-			GUITexture* mBackgroundFrame;
-			GUIButton* mScrollUpBtn;
-			GUIButton* mScrollDownBtn;
-			GUITexture* mHandle;
-
-			GUIPanel* mBackgroundPanel;
-			GUIPanel* mContentPanel;
-			GUILayout* mContentLayout;
-			GUIPanel* mSidebarPanel;
-
-			DropDownSubMenu* mParent;
-			DropDownSubMenu* mSubMenu;
-		};
-
-	private:
-		friend class GUIDropDownContent;
-
-		/**
-		 * @brief	Called when the specified sub-menu is opened.
-		 */
-		void notifySubMenuOpened(DropDownSubMenu* subMenu);
-
-		/**
-		 * @brief	Called when the specified sub-menu is opened.
-		 */
-		void notifySubMenuClosed(DropDownSubMenu* subMenu);
-
-		/**
-		 * @brief	Called when the drop down box loses focus (and should be closed).
-		 */
-		void dropDownFocusLost();
-
-		/**
-		 * @copydoc	GUIWidget::onDestroyed
-		 */
-		void onDestroyed() override;
-
-	private:
-		static const UINT32 DROP_DOWN_BOX_WIDTH;
-
-		String mScrollUpStyle;
-		String mScrollDownStyle;
-		String mBackgroundStyle;
-		String mContentStyle;
-		String mSideBackgroundStyle;
-		String mHandleStyle;
-
-		DropDownSubMenu* mRootMenu;
-		GUIDropDownHitBox* mFrontHitBox;
-		GUIDropDownHitBox* mBackHitBox;
-
-		// Captures mouse clicks so that we don't trigger elements outside the drop down box when we just want to close it.
-		// (Particular example is clicking on the button that opened the drop down box in the first place. Clicking will cause
-		// the drop down to lose focus and close, but if the button still processes the mouse click it will be immediately opened again)
-		GUIDropDownHitBox* mCaptureHitBox;
-
-		Vector<Rect2I> mAdditionalCaptureBounds;
-	};
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsCGUIWidget.h"
+#include "BsRect2I.h"
+#include "BsDropDownAreaPlacement.h"
+
+namespace BansheeEngine
+{
+	/**
+	 * @brief	Contains items used for initializing one level in a drop down box hierarchy.
+	 */
+	struct BS_EXPORT GUIDropDownData
+	{
+		Vector<GUIDropDownDataEntry> entries;
+		Vector<bool> states;
+		UnorderedMap<WString, HString> localizedNames;
+	};
+
+	/**
+	 * @brief	A set of parameters used for initializing a drop down box.
+	 */
+	struct DROP_DOWN_BOX_DESC
+	{
+		CameraPtr camera; /**< Camera on which to open the drop down box. */
+		DropDownAreaPlacement placement; /**< Determines how is the drop down box positioned in the visible area. */
+		GUIDropDownData dropDownData; /**< Data to use for initializing menu items of the drop down box. */
+		HGUISkin skin; /**< Skin to use for drop down box GUI elements. */
+		Vector<Rect2I> additionalBounds; /**< Additional bounds that control what is considered the inside or the outside of the drop down box. */
+	};
+
+	/**
+	 * @brief	Represents a single entry in a drop down box.
+	 */
+	class BS_EXPORT GUIDropDownDataEntry
+	{
+		enum class Type
+		{
+			Separator,
+			Entry,
+			SubMenu
+		};
+
+	public:
+		/**
+		 * @brief	Creates a new separator entry.
+		 */
+		static GUIDropDownDataEntry separator();
+
+		/**
+		 * @brief	Creates a new button entry with the specified callback that is triggered
+		 *			when button is selected.
+		 */
+		static GUIDropDownDataEntry button(const WString& label, std::function<void()> callback, const WString& shortcutTag = StringUtil::WBLANK);
+
+		/**
+		 * @brief	Creates a new sub-menu entry that will open the provided drop down data
+		 *			sub-menu when activated.
+		 */
+		static GUIDropDownDataEntry subMenu(const WString& label, const GUIDropDownData& data);
+
+		/**
+		 * @brief	Check is the entry a separator.
+		 */
+		bool isSeparator() const { return mType == Type::Separator; }
+
+		/**
+		 * @brief	Check is the entry a sub menu.
+		 */
+		bool isSubMenu() const { return mType == Type::SubMenu; }
+
+		/**
+		 * @brief	Returns display label of the entry (if an entry is a button or a sub-menu).
+		 */
+		const WString& getLabel() const { return mLabel; }
+
+		/**
+		 * @brief	Returns the shortcut key combination string that is to be displayed along the entry label.
+		 */
+		const WString& getShortcutTag() const { return mShortcutTag; }
+
+		/**
+		 * @brief	Returns a button callback if the entry (if an entry is a button).
+		 */
+		std::function<void()> getCallback() const { return mCallback; }
+
+		/**
+		 * @brief	Returns sub-menu data that is used for creating a sub-menu (if an entry is a sub-menu).
+		 */
+		const GUIDropDownData& getSubMenuData() const { return mChildData; }
+	private:
+		GUIDropDownDataEntry() { }
+
+		std::function<void()> mCallback;
+		GUIDropDownData mChildData;
+		WString mLabel;
+		WString mShortcutTag;
+		Type mType; 
+	};
+
+	/**
+	 * @brief	Type of drop down box types.
+	 */
+	enum class GUIDropDownType
+	{
+		ListBox,
+		MultiListBox,
+		ContextMenu,
+		MenuBar
+	};
+
+	/**
+	 * @brief	This is a generic GUI drop down box class that can be used for:
+	 * 			list boxes, menu bars or context menus.
+	 */
+	class BS_EXPORT GUIDropDownMenu : public CGUIWidget
+	{
+	public:
+		/**
+		 * @brief	Creates a new drop down box widget.
+		 *
+		 * @param	parent			Parent scene object to attach the drop down box to.
+		 * @param	desc			Various parameters that control the drop down menu features and content.
+		 * @param	type			Specific type of drop down box to display.
+		 */
+		GUIDropDownMenu(const HSceneObject& parent, const DROP_DOWN_BOX_DESC& desc, GUIDropDownType type);
+		~GUIDropDownMenu();
+
+	private:
+		/**
+		 * @brief	Contains data about a single drop down box sub-menu
+		 */
+		struct DropDownSubMenu
+		{
+			/**
+			 * @brief	Represents a single sub-menu page.
+			 */
+			struct PageInfo
+			{
+				UINT32 idx;
+				UINT32 start;
+				UINT32 end;
+				UINT32 height;
+			};
+
+		public:
+			/**
+			 * @brief	Creates a new drop down box sub-menu
+			 *
+			 * @param	owner			Owner drop down box this sub menu belongs to.
+			 * @param	parent			Parent sub-menu. Can be null.
+			 * @param	placement		Determines how is the sub-menu positioned in the visible area.
+			 * @param	availableBounds	Available bounds (in pixels) in which the sub-menu may be opened.
+			 * @param	dropDownData	Data to use for initializing menu items of the sub-menu.
+			 * @param	skin			Skin to use for sub-menu GUI elements.
+			 * @param	depthOffset		How much to offset the sub-menu depth. We want deeper levels of the
+			 *							sub-menu hierarchy to be in front of lower levels, so you should
+			 *							increase this value for each level of the sub-menu hierarchy.
+			 */
+			DropDownSubMenu(GUIDropDownMenu* owner, DropDownSubMenu* parent, const DropDownAreaPlacement& placement, 
+				const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset);
+			~DropDownSubMenu();
+
+			/**
+			 * @brief	Recreates all internal GUI elements for the entries of the current sub-menu page.
+			 */
+			void updateGUIElements();
+
+			/**
+			 * @brief	Moves the sub-menu to the previous page and displays its elements, if available.
+			 */
+			void scrollDown();
+
+			/**
+			 * @brief	Moves the sub-menu to the next page and displays its elements, if available.
+			 */
+			void scrollUp();
+
+			/**
+			 * @brief	Moves the sub-menu to the first page and displays its elements.
+			 */
+			void scrollToTop();
+
+			/**
+			 * @brief	Moves the sub-menu to the last page and displays its elements.
+			 */
+			void scrollToBottom();
+
+			/**
+			 * @brief	Calculates ranges for all the pages of the sub-menu.
+			 */
+			Vector<PageInfo> getPageInfos() const;
+
+			/**
+			 * @brief	Called when the user activates an element with the specified index.
+			 *
+			 * @param	bounds	Bounds of the GUI element that is used as a visual representation
+			 *					of this drop down element.
+			 */
+			void elementActivated(UINT32 idx, const Rect2I& bounds);
+
+			/**
+			 * @brief	Called when the user selects an element with the specified index.
+			 * 
+			 * @param	idx		Index of the element that was selected.
+			 */
+			void elementSelected(UINT32 idx);
+
+			/**
+			 * @brief	Called when the user wants to close the currently open sub-menu.
+			 */
+			void closeSubMenu();
+
+			/**
+			 * @brief	Closes this sub-menu.
+			 */
+			void close();
+
+			/**
+			 * @brief	Returns the type of the displayed drop down menu.
+			 */
+			GUIDropDownType getType() const { return mType; }
+
+			/**
+			 * @brief	Returns actual visible bounds of the sub-menu.
+			 */
+			Rect2I getVisibleBounds() const { return mVisibleBounds; }
+
+			/**
+			 * @brief	Returns the drop box object that owns this sub-menu.
+			 */
+			GUIDropDownMenu* getOwner() const { return mOwner; }
+
+		public:
+			GUIDropDownMenu* mOwner;
+
+			GUIDropDownType mType;
+			GUIDropDownData mData;
+			UINT32 mPage;
+			INT32 x, y;
+			UINT32 width, height;
+			Rect2I mVisibleBounds;
+			Rect2I mAvailableBounds;
+			UINT32 mDepthOffset;
+			bool mOpenedUpward;
+
+			GUIDropDownContent* mContent;
+			GUITexture* mBackgroundFrame;
+			GUIButton* mScrollUpBtn;
+			GUIButton* mScrollDownBtn;
+			GUITexture* mHandle;
+
+			GUIPanel* mBackgroundPanel;
+			GUIPanel* mContentPanel;
+			GUILayout* mContentLayout;
+			GUIPanel* mSidebarPanel;
+
+			DropDownSubMenu* mParent;
+			DropDownSubMenu* mSubMenu;
+		};
+
+	private:
+		friend class GUIDropDownContent;
+
+		/**
+		 * @brief	Called when the specified sub-menu is opened.
+		 */
+		void notifySubMenuOpened(DropDownSubMenu* subMenu);
+
+		/**
+		 * @brief	Called when the specified sub-menu is opened.
+		 */
+		void notifySubMenuClosed(DropDownSubMenu* subMenu);
+
+		/**
+		 * @brief	Called when the drop down box loses focus (and should be closed).
+		 */
+		void dropDownFocusLost();
+
+		/**
+		 * @copydoc	GUIWidget::onDestroyed
+		 */
+		void onDestroyed() override;
+
+	private:
+		static const UINT32 DROP_DOWN_BOX_WIDTH;
+
+		String mScrollUpStyle;
+		String mScrollDownStyle;
+		String mBackgroundStyle;
+		String mContentStyle;
+		String mSideBackgroundStyle;
+		String mHandleStyle;
+
+		DropDownSubMenu* mRootMenu;
+		GUIDropDownHitBox* mFrontHitBox;
+		GUIDropDownHitBox* mBackHitBox;
+
+		// Captures mouse clicks so that we don't trigger elements outside the drop down box when we just want to close it.
+		// (Particular example is clicking on the button that opened the drop down box in the first place. Clicking will cause
+		// the drop down to lose focus and close, but if the button still processes the mouse click it will be immediately opened again)
+		GUIDropDownHitBox* mCaptureHitBox;
+
+		Vector<Rect2I> mAdditionalCaptureBounds;
+	};
 }

+ 1 - 1
BansheeEngine/Include/BsGUIElement.h

@@ -214,7 +214,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElementBase::_changeParentWidget
 		 */
-		virtual void _changeParentWidget(CGUIWidget* widget) override;
+		virtual void _changeParentWidget(GUIWidget* widget) override;
 
 		/**
 		 * @brief	Returns depth for a specific render element. This contains a combination

+ 3 - 3
BansheeEngine/Include/BsGUIElementBase.h

@@ -283,7 +283,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		CGUIWidget* _getParentWidget() const { return mParentWidget; }
+		GUIWidget* _getParentWidget() const { return mParentWidget; }
 
 		/**
 		 * @brief	Checks if element is visible or hidden.
@@ -339,7 +339,7 @@ namespace BansheeEngine
 		 *
 		 * @note	Internal method.
 		 */
-		virtual void _changeParentWidget(CGUIWidget* widget);
+		virtual void _changeParentWidget(GUIWidget* widget);
 
 		/**
 		 * @brief	Registers a new child element.
@@ -432,7 +432,7 @@ namespace BansheeEngine
 		 */
 		void setUpdateParent(GUIElementBase* updateParent);
 
-		CGUIWidget* mParentWidget;
+		GUIWidget* mParentWidget;
 		GUIPanel* mAnchorParent;
 		GUIElementBase* mUpdateParent;
 		GUIElementBase* mParentElement;

+ 13 - 13
BansheeEngine/Include/BsGUIManager.h

@@ -54,8 +54,8 @@ namespace BansheeEngine
 
 			Vector<TransientMeshPtr> cachedMeshes;
 			Vector<SpriteMaterialInfo> cachedMaterials;
-			Vector<CGUIWidget*> cachedWidgetsPerMesh;
-			Vector<CGUIWidget*> widgets;
+			Vector<GUIWidget*> cachedWidgetsPerMesh;
+			Vector<GUIWidget*> widgets;
 			bool isDirty;
 		};
 
@@ -76,11 +76,11 @@ namespace BansheeEngine
 		 */
 		struct WidgetInfo
 		{
-			WidgetInfo(CGUIWidget* _widget)
+			WidgetInfo(GUIWidget* _widget)
 				:widget(_widget)
 			{ }
 
-			CGUIWidget* widget;
+			GUIWidget* widget;
 		};
 
 		/**
@@ -88,12 +88,12 @@ namespace BansheeEngine
 		 */
 		struct ElementInfo
 		{
-			ElementInfo(GUIElement* element, CGUIWidget* widget)
+			ElementInfo(GUIElement* element, GUIWidget* widget)
 				:element(element), widget(widget)
 			{ }
 
 			GUIElement* element;
-			CGUIWidget* widget;
+			GUIWidget* widget;
 		};
 
 		/**
@@ -101,13 +101,13 @@ namespace BansheeEngine
 		 */
 		struct ElementInfoUnderPointer
 		{
-			ElementInfoUnderPointer(GUIElement* element, CGUIWidget* widget)
+			ElementInfoUnderPointer(GUIElement* element, GUIWidget* widget)
 				:element(element), widget(widget), usesMouseOver(false), 
 				receivedMouseOver(false), isHovering(false)
 			{ }
 
 			GUIElement* element;
-			CGUIWidget* widget;
+			GUIWidget* widget;
 			bool usesMouseOver;
 			bool receivedMouseOver;
 			bool isHovering;
@@ -130,13 +130,13 @@ namespace BansheeEngine
 		 * @brief	Registers a newly created widget with the GUI manager.
 		 *			This should be called by every GUI widget on creation.
 		 */
-		void registerWidget(CGUIWidget* widget);
+		void registerWidget(GUIWidget* widget);
 
 		/**
 		 * @brief	Unregisters a GUI widget from the GUI manager.
 		 *			This should be called by every GUI widget before getting deleted.
 		 */
-		void unregisterWidget(CGUIWidget* widget);
+		void unregisterWidget(GUIWidget* widget);
 
 		/**
 		 * @brief	Called once per frame.
@@ -323,7 +323,7 @@ namespace BansheeEngine
 		/**
 		 * @brief	Converts screen coordinates to coordinates relative to the specified widget.
 		 */
-		Vector2I getWidgetRelativePos(const CGUIWidget* widget, const Vector2I& screenPos) const;
+		Vector2I getWidgetRelativePos(const GUIWidget* widget, const Vector2I& screenPos) const;
 
 		/**
 		 * @brief	Converts window coordinates to coordinates relative to the specified bridged widget.
@@ -331,12 +331,12 @@ namespace BansheeEngine
 		 *
 		 * @param	If provided widget has no bridge, coordinates are returned as is.
 		 */
-		Vector2I windowToBridgedCoords(const CGUIWidget& widget, const Vector2I& windowPos) const;
+		Vector2I windowToBridgedCoords(const GUIWidget& widget, const Vector2I& windowPos) const;
 
 		/**
 		 * @brief	Returns the parent render window of the specified widget.
 		 */
-		const RenderWindow* getWidgetWindow(const CGUIWidget& widget) const;
+		const RenderWindow* getWidgetWindow(const GUIWidget& widget) const;
 
 		/**
 		 * @brief	Hides the tooltip if any is shown.

+ 1 - 1
BansheeEngine/Include/BsGUITooltip.h

@@ -24,7 +24,7 @@ namespace BansheeEngine
 		 * @param	position		Position of the tooltip, relative to the overlaid widget position.
 		 * @param	text			Text to display in the tooltip.
 		 */
-		GUITooltip(const HSceneObject& parent, const CGUIWidget& overlaidWidget, const Vector2I& position, const WString& text);
+		GUITooltip(const HSceneObject& parent, const GUIWidget& overlaidWidget, const Vector2I& position, const WString& text);
 		~GUITooltip();
 
 	private:

+ 1 - 1
BansheeEngine/Include/BsGUITooltipManager.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		 * @param	position	Position of the tooltip, relative to the parent GUI widget.
 		 * @param	text		Text to display on the tooltip.
 		 */
-		void show(const CGUIWidget& widget, const Vector2I& position, const WString& text);
+		void show(const GUIWidget& widget, const Vector2I& position, const WString& text);
 
 		/**
 		 * @brief	Hides the currently shown tooltip.

+ 1 - 1
BansheeEngine/Include/BsGUIViewport.h

@@ -95,7 +95,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	GUIElement::_changeParentWidget
 		 */
-		void _changeParentWidget(CGUIWidget* widget) override;
+		void _changeParentWidget(GUIWidget* widget) override;
 
 		HCamera mCamera;
 		float mAspectRatio;

+ 2 - 1
BansheeEngine/Include/BsPrerequisites.h

@@ -37,8 +37,9 @@ namespace BansheeEngine
 	struct ShortcutKey;
 
 	// GUI
-	class GUIManager;
 	class CGUIWidget;
+	class GUIManager;
+	class GUIWidget;
 	class GUIElementBase;
 	class GUIElement;
 	class GUILabel;

+ 1 - 1
BansheeEngine/Include/BsProfilerOverlay.h

@@ -215,7 +215,7 @@ namespace BansheeEngine
 		ViewportPtr mTarget;
 
 		HSceneObject mWidgetSO;
-		GameObjectHandle<CGUIWidget> mWidget;
+		HGUIWidget mWidget;
 
 		GUILayout* mBasicLayoutLabels = nullptr;
 		GUILayout* mPreciseLayoutLabels = nullptr;

+ 113 - 350
BansheeEngine/Source/BsCGUIWidget.cpp

@@ -1,351 +1,114 @@
-#include "BsCGUIWidget.h"
-#include "BsGUIManager.h"
-#include "BsGUISkin.h"
-#include "BsGUILabel.h"
-#include "BsGUIPanel.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsVector2I.h"
-#include "BsCCamera.h"
-#include "BsViewport.h"
-#include "BsSceneObject.h"
-#include "BsCGUIWidgetRTTI.h"
-#include "BsBuiltinResources.h"
-
-namespace BansheeEngine
-{
-	CGUIWidget::CGUIWidget(const HSceneObject& parent, const CameraPtr& camera)
-		:Component(parent), mWidgetIsDirty(false), mCamera(camera), mDepth(0), mPanel(nullptr)
-	{
-		setName("GUIWidget");
-
-		construct(camera);
-	}
-
-	CGUIWidget::CGUIWidget(const HSceneObject& parent, const HCamera& camera)
-		:Component(parent), mWidgetIsDirty(false), mCamera(camera->_getCamera()), mDepth(0), mPanel(nullptr)
-	{
-		setName("GUIWidget");
-
-		construct(mCamera);
-	}
-
-	void CGUIWidget::construct(const CameraPtr& camera)
-	{
-		mLastFramePosition = SO()->getWorldPosition();
-		mLastFrameRotation = SO()->getWorldRotation();
-		mLastFrameScale = SO()->getWorldScale();
-
-		assert(camera != nullptr);
-
-		mOwnerTargetResizedConn = mCamera->getViewport()->getTarget()->onResized.connect(std::bind(&CGUIWidget::ownerTargetResized, this));
-
-		GUIManager::instance().registerWidget(this);
-
-		mPanel = GUIPanel::create();
-		mPanel->_changeParentWidget(this);
-		updateRootPanel();
-	}
-
-	CGUIWidget::~CGUIWidget()
-	{ }
-
-	void CGUIWidget::setDepth(UINT8 depth)
-	{
-		mDepth = depth; 
-		mWidgetIsDirty = true;
-
-		updateRootPanel();
-	}
-
-	void CGUIWidget::onDestroyed()
-	{
-		GUILayout::destroy(mPanel);
-		mPanel = nullptr;
-
-		if (mCamera != nullptr)
-		{
-			GUIManager::instance().unregisterWidget(this);
-
-			mOwnerTargetResizedConn.disconnect();
-		}
-
-		mElements.clear();
-		mDirtyContents.clear();
-	}
-
-	Viewport* CGUIWidget::getTarget() const
-	{
-		return mCamera->getViewport().get();
-	}
-
-	void CGUIWidget::update()
-	{
-		// If the widgets parent scene object moved, we need to mark it as dirty
-		// as the GUIManager batching relies on object positions, so it needs to be updated.
-		const float diffEpsilon = 0.0001f;
-
-		Vector3 position = SO()->getWorldPosition();
-		Quaternion rotation = SO()->getWorldRotation();
-		Vector3 scale = SO()->getWorldScale();
-
-		if(!mWidgetIsDirty)
-		{
-			Vector3 posDiff = mLastFramePosition - position;
-			if(Math::abs(posDiff.x) > diffEpsilon || Math::abs(posDiff.y) > diffEpsilon || Math::abs(posDiff.z) > diffEpsilon)
-			{
-				mWidgetIsDirty = true;
-			}
-			else
-			{
-				Quaternion rotDiff = mLastFrameRotation - rotation;
-				if(Math::abs(rotDiff.x) > diffEpsilon || Math::abs(rotDiff.y) > diffEpsilon || 
-					Math::abs(rotDiff.z) > diffEpsilon || Math::abs(rotDiff.w) > diffEpsilon)
-				{
-					mWidgetIsDirty = true;
-				}
-				else
-				{
-					Vector3 scaleDiff = mLastFrameScale - scale;
-					if(Math::abs(scaleDiff.x) > diffEpsilon || Math::abs(scaleDiff.y) > diffEpsilon || Math::abs(scaleDiff.z) > diffEpsilon)
-					{
-						mWidgetIsDirty = true;
-					}
-				}
-			}
-		}
-
-		mLastFramePosition = position;
-		mLastFrameRotation = rotation;
-		mLastFrameScale = scale;
-	}
-
-	void CGUIWidget::_updateLayout()
-	{
-		bs_frame_mark();
-
-		// Determine dirty contents and layouts
-		FrameStack<GUIElementBase*> todo;
-		todo.push(mPanel);
-
-		while (!todo.empty())
-		{
-			GUIElementBase* currentElem = todo.top();
-			todo.pop();
-
-			if (currentElem->_isDirty())
-			{
-				GUIElementBase* updateParent = currentElem->_getUpdateParent();
-				assert(updateParent != nullptr || currentElem == mPanel);
-
-				if (updateParent != nullptr)
-					_updateLayout(updateParent);
-				else // Must be root panel
-					_updateLayout(mPanel);
-			}
-			else
-			{
-				UINT32 numChildren = currentElem->_getNumChildren();
-				for (UINT32 i = 0; i < numChildren; i++)
-					todo.push(currentElem->_getChild(i));
-			}
-		}
-
-		bs_frame_clear();
-	}
-
-	void CGUIWidget::_updateLayout(GUIElementBase* elem)
-	{
-		GUIElementBase* parent = elem->_getParent();
-		bool isPanelOptimized = parent != nullptr && parent->_getType() == GUIElementBase::Type::Panel;
-
-		GUIElementBase* updateParent = nullptr;
-
-		if (isPanelOptimized)
-			updateParent = parent;
-		else
-			updateParent = elem;
-
-		// For GUIPanel we can do a an optimization and update only the element in question instead
-		// of all the children
-		if (isPanelOptimized)
-		{
-			GUIPanel* panel = static_cast<GUIPanel*>(updateParent);
-
-			GUIElementBase* dirtyElement = elem;
-			dirtyElement->_updateOptimalLayoutSizes();
-
-			LayoutSizeRange elementSizeRange = panel->_getElementSizeRange(dirtyElement);
-			Rect2I elementArea = panel->_getElementArea(panel->_getLayoutData().area, dirtyElement, elementSizeRange);
-
-			GUILayoutData childLayoutData = panel->_getLayoutData();
-			panel->_updateDepthRange(childLayoutData);
-			childLayoutData.area = elementArea;
-
-			panel->_updateChildLayout(dirtyElement, childLayoutData);
-		}
-		else
-		{
-			GUILayoutData childLayoutData = updateParent->_getLayoutData();
-			updateParent->_updateLayout(childLayoutData);
-		}
-		
-		// Mark dirty contents
-		bs_frame_mark();
-		{
-			FrameStack<GUIElementBase*> todo;
-			todo.push(elem);
-
-			while (!todo.empty())
-			{
-				GUIElementBase* currentElem = todo.top();
-				todo.pop();
-
-				if (currentElem->_getType() == GUIElementBase::Type::Element)
-					mDirtyContents.insert(static_cast<GUIElement*>(currentElem));
-
-				currentElem->_markAsClean();
-
-				UINT32 numChildren = currentElem->_getNumChildren();
-				for (UINT32 i = 0; i < numChildren; i++)
-					todo.push(currentElem->_getChild(i));
-			}
-		}
-		bs_frame_clear();
-	}
-
-	void CGUIWidget::_registerElement(GUIElementBase* elem)
-	{
-		assert(elem != nullptr && !elem->_isDestroyed());
-
-		if (elem->_getType() == GUIElementBase::Type::Element)
-		{
-			mElements.push_back(static_cast<GUIElement*>(elem));
-			mWidgetIsDirty = true;
-		}
-	}
-
-	void CGUIWidget::_unregisterElement(GUIElementBase* elem)
-	{
-		assert(elem != nullptr);
-
-		auto iterFind = std::find(begin(mElements), end(mElements), elem);
-
-		if (iterFind != mElements.end())
-		{
-			mElements.erase(iterFind);
-			mWidgetIsDirty = true;
-		}
-
-		if (elem->_getType() == GUIElementBase::Type::Element)
-			mDirtyContents.erase(static_cast<GUIElement*>(elem));
-	}
-
-	void CGUIWidget::_markMeshDirty(GUIElementBase* elem)
-	{
-		mWidgetIsDirty = true;
-	}
-
-	void CGUIWidget::_markContentDirty(GUIElementBase* elem)
-	{
-		if (elem->_getType() == GUIElementBase::Type::Element)
-			mDirtyContents.insert(static_cast<GUIElement*>(elem));
-	}
-
-	void CGUIWidget::setSkin(const HGUISkin& skin)
-	{
-		mSkin = skin;
-
-		for(auto& element : mElements)
-			element->_refreshStyle();
-	}
-
-	const GUISkin& CGUIWidget::getSkin() const
-	{
-		if(mSkin.isLoaded())
-			return *mSkin;
-		else
-			return *BuiltinResources::instance().getEmptyGUISkin();
-	}
-
-	bool CGUIWidget::isDirty(bool cleanIfDirty)
-	{
-		bool dirty = mWidgetIsDirty || mDirtyContents.size() > 0;
-
-		if(cleanIfDirty && dirty)
-		{
-			mWidgetIsDirty = false;
-
-			for (auto& dirtyElement : mDirtyContents)
-				dirtyElement->_updateRenderElements();
-
-			mDirtyContents.clear();
-			updateBounds();
-		}
-		
-		return dirty;
-	}
-
-	bool CGUIWidget::inBounds(const Vector2I& position) const
-	{
-		// Technically GUI widget bounds can be larger than the viewport, so make sure we clip to viewport first
-		if(!getTarget()->getArea().contains(position))
-			return false;
-
-		const Matrix4& worldTfrm = SO()->getWorldTfrm();
-		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
-		vecPos = worldTfrm.inverse().multiplyAffine(vecPos);
-
-		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
-		return mBounds.contains(localPos);
-	}
-
-	void CGUIWidget::updateBounds() const
-	{
-		if(mElements.size() > 0)
-			mBounds = mElements[0]->_getClippedBounds();
-
-		for(auto& elem : mElements)
-		{
-			Rect2I elemBounds = elem->_getClippedBounds();
-			mBounds.encapsulate(elemBounds);
-		}
-	}
-
-	void CGUIWidget::ownerTargetResized()
-	{
-		updateRootPanel();
-	}
-
-	void CGUIWidget::updateRootPanel()
-	{
-		UINT32 width = getTarget()->getWidth();
-		UINT32 height = getTarget()->getHeight();
-
-		GUILayoutData layoutData;
-		layoutData.area.width = width;
-		layoutData.area.height = height;
-		layoutData.clipRect = Rect2I(0, 0, width, height);
-		layoutData.setWidgetDepth(mDepth);
-
-		mPanel->setWidth(width);
-		mPanel->setHeight(height);
-
-		mPanel->_setLayoutData(layoutData);
-		mPanel->_markLayoutAsDirty();
-	}
-
-	void CGUIWidget::ownerWindowFocusChanged()
-	{
-
-	}
-
-	RTTITypeBase* CGUIWidget::getRTTIStatic()
-	{
-		return CGUIWidgetRTTI::instance();
-	}
-
-	RTTITypeBase* CGUIWidget::getRTTI() const
-	{
-		return CGUIWidget::getRTTIStatic();
-	}
+#include "BsCGUIWidget.h"
+#include "BsCGUIWidgetRTTI.h"
+#include "BsGUIWidget.h"
+#include "BsSceneObject.h"
+#include "BsCCamera.h"
+
+namespace BansheeEngine
+{
+	CGUIWidget::CGUIWidget(const HSceneObject& parent, const CameraPtr& camera)
+		:Component(parent), mCamera(camera), mParentHash((UINT32)-1)
+	{
+		mInternal = GUIWidget::create(camera);
+		mOwnerTargetResizedConn = mInternal->onOwnerTargetResized.connect(
+			std::bind(&CGUIWidget::ownerTargetResized, this));
+		mOwnerWindowFocusChangedConn = mInternal->onOwnerWindowFocusChanged.connect(
+			std::bind(&CGUIWidget::ownerWindowFocusChanged, this));
+	}
+
+	CGUIWidget::CGUIWidget(const HSceneObject& parent, const HCamera& camera)
+		:CGUIWidget(parent, camera->_getCamera())
+	{ }
+
+	CGUIWidget::~CGUIWidget()
+	{ }
+
+	void CGUIWidget::setSkin(const HGUISkin& skin)
+	{
+		mInternal->setSkin(skin);
+	}
+
+	const GUISkin& CGUIWidget::getSkin() const
+	{
+		return mInternal->getSkin();
+	}
+
+	const HGUISkin& CGUIWidget::getSkinResource() const
+	{
+		return mInternal->getSkinResource();
+	}
+
+	GUIPanel* CGUIWidget::getPanel() const
+	{
+		return mInternal->getPanel();
+	}
+
+	UINT8 CGUIWidget::getDepth() const
+	{
+		return mInternal->getDepth();
+	}
+
+	void CGUIWidget::setDepth(UINT8 depth)
+	{
+		mInternal->setDepth(depth);
+	}
+
+	bool CGUIWidget::inBounds(const Vector2I& position) const
+	{
+		return mInternal->inBounds(position);
+	}
+
+	const Rect2I& CGUIWidget::getBounds() const
+	{
+		return mInternal->getBounds();
+	}
+
+	bool CGUIWidget::isDirty(bool cleanIfDirty)
+	{
+		return mInternal->isDirty(cleanIfDirty);
+	}
+
+	Viewport* CGUIWidget::getTarget() const
+	{
+		return mInternal->getTarget();
+	}
+
+	CameraPtr CGUIWidget::getCamera() const
+	{
+		return mInternal->getCamera();
+	}
+
+	const Vector<GUIElement*>& CGUIWidget::getElements() const
+	{
+		return mInternal->getElements();
+	}
+
+	void CGUIWidget::update()
+	{
+		HSceneObject parent = SO();
+
+		UINT32 curHash = parent->getTransformHash();
+		if (curHash != mParentHash)
+		{
+			mInternal->_updateTransform(parent);
+			mParentHash = curHash;
+		}
+	}
+
+	void CGUIWidget::onDestroyed()
+	{
+		mOwnerTargetResizedConn.disconnect();
+		mOwnerWindowFocusChangedConn.disconnect();
+		mInternal = nullptr;
+	}
+
+	RTTITypeBase* CGUIWidget::getRTTIStatic()
+	{
+		return CGUIWidgetRTTI::instance();
+	}
+
+	RTTITypeBase* CGUIWidget::getRTTI() const
+	{
+		return CGUIWidget::getRTTIStatic();
+	}
 }

+ 0 - 8
BansheeEngine/Source/BsGUIButton.cpp

@@ -1,13 +1,5 @@
 #include "BsGUIButton.h"
-#include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
-#include "BsTextSprite.h"
 #include "BsGUIDimensions.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUIHelper.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {

+ 0 - 2
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -1,13 +1,11 @@
 #include "BsGUIButtonBase.h"
 #include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIHelper.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {

+ 1 - 1
BansheeEngine/Source/BsGUIContextMenu.cpp

@@ -15,7 +15,7 @@ namespace BansheeEngine
 		close();
 	}
 
-	void GUIContextMenu::open(const Vector2I& position, CGUIWidget& widget)
+	void GUIContextMenu::open(const Vector2I& position, GUIWidget& widget)
 	{
 		DROP_DOWN_BOX_DESC desc;
 		desc.camera = widget.getCamera();

+ 418 - 420
BansheeEngine/Source/BsGUIDropDownContent.cpp

@@ -1,421 +1,419 @@
-#include "BsGUIDropDownContent.h"
-#include "BsGUILayout.h"
-#include "BsGUITexture.h"
-#include "BsGUIButton.h"
-#include "BsGUILabel.h"
-#include "BsGUISpace.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIToggle.h"
-#include "BsGUISkin.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUICommandEvent.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	const String GUIDropDownContent::ENTRY_TOGGLE_STYLE_TYPE = "DropDownEntryToggleBtn";
-	const String GUIDropDownContent::ENTRY_STYLE_TYPE = "DropDownEntryBtn";
-	const String GUIDropDownContent::ENTRY_EXP_STYLE_TYPE = "DropDownEntryExpBtn";
-	const String GUIDropDownContent::SEPARATOR_STYLE_TYPE = "DropDownSeparator";
-
-	GUIDropDownContent::GUIDropDownContent(GUIDropDownMenu::DropDownSubMenu* parent, const GUIDropDownData& dropDownData, 
-		const String& style, const GUIDimensions& dimensions)
-		:GUIElementContainer(dimensions, style), mDropDownData(dropDownData), mKeyboardFocus(true), 
-		mStates(dropDownData.states), mSelectedIdx(UINT_MAX), mRangeStart(0), mRangeEnd(0), mParent(parent), 
-		mIsToggle(parent->getType() == GUIDropDownType::MultiListBox)
-	{
-
-	}
-
-	GUIDropDownContent::~GUIDropDownContent()
-	{
-
-	}
-
-	GUIDropDownContent* GUIDropDownContent::create(GUIDropDownMenu::DropDownSubMenu* parent, 
-		const GUIDropDownData& dropDownData, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIDropDownContent::getGUITypeName();
-
-		return new (bs_alloc<GUIDropDownContent>()) GUIDropDownContent(parent, dropDownData, *curStyle, GUIDimensions::create());
-	}
-
-	GUIDropDownContent* GUIDropDownContent::create(GUIDropDownMenu::DropDownSubMenu* parent, 
-		const GUIDropDownData& dropDownData, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &GUIDropDownContent::getGUITypeName();
-
-		return new (bs_alloc<GUIDropDownContent>()) GUIDropDownContent(parent, dropDownData, *curStyle, GUIDimensions::create(options));
-	}
-
-	void GUIDropDownContent::styleUpdated()
-	{
-		for (auto& visElem : mVisibleElements)
-		{
-			GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
-
-			if (element.isSeparator())
-				visElem.separator->setStyle(getSubStyleName(SEPARATOR_STYLE_TYPE));
-			else if (element.isSubMenu())
-				visElem.button->setStyle(getSubStyleName(ENTRY_EXP_STYLE_TYPE));
-			else
-			{
-				if (mIsToggle)
-					visElem.button->setStyle(getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE));
-				else
-					visElem.button->setStyle(getSubStyleName(ENTRY_STYLE_TYPE));
-			}
-		}
-	}
-
-	void GUIDropDownContent::setRange(UINT32 start, UINT32 end)
-	{
-		std::function<void(UINT32, UINT32)> onHover = 
-			[&](UINT32 idx, UINT32 visIdx) 
-		{ 
-			setSelected(visIdx);
-			mParent->elementSelected(idx); 
-		};
-
-		std::function<void(UINT32, UINT32)> onClick =
-			[&](UINT32 idx, UINT32 visIdx)
-		{ 
-			setSelected(visIdx);
-
-			if (mIsToggle)
-				mStates[idx] = !mStates[idx];
-
-			mParent->elementActivated(idx, mVisibleElements[visIdx].button->_getLayoutData().area);
-		};
-
-		// Remove all elements
-		while (_getNumChildren() > 0)
-		{
-			GUIElementBase* child = _getChild(_getNumChildren() - 1);
-			assert(child->_getType() == GUIElementBase::Type::Element);
-
-			GUIElement::destroy(static_cast<GUIElement*>(child));
-		}
-
-		mRangeStart = start;
-		mRangeEnd = end;
-		
-		UINT32 range = end - start;
-		if (mSelectedIdx != UINT_MAX && mSelectedIdx > range)
-			mSelectedIdx = UINT_MAX;
-
-		mVisibleElements.clear();
-		UINT32 curVisIdx = 0;
-		for (UINT32 i = start; i < end; i++)
-		{
-			mVisibleElements.push_back(VisibleElement());
-			VisibleElement& visElem = mVisibleElements.back();
-			visElem.idx = i;
-			GUIDropDownDataEntry& element = mDropDownData.entries[i];
-
-			if (element.isSeparator())
-			{
-				visElem.separator = GUITexture::create(GUIImageScaleMode::StretchToFit, getSubStyleName(SEPARATOR_STYLE_TYPE));
-				_registerChildElement(visElem.separator);
-			}
-			else if (element.isSubMenu())
-			{
-				visElem.button = GUIButton::create(getElementLocalizedName(i), getSubStyleName(ENTRY_EXP_STYLE_TYPE));
-				visElem.button->onHover.connect(std::bind(onClick, i, curVisIdx));
-				_registerChildElement(visElem.button);
-			}
-			else
-			{
-				if (mIsToggle)
-				{
-					GUIToggle* toggle = GUIToggle::create(getElementLocalizedName(i), getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE));
-					if (mStates[i])
-						toggle->toggleOn();
-
-					visElem.button = toggle;					
-				}
-				else
-					visElem.button = GUIButton::create(getElementLocalizedName(i), getSubStyleName(ENTRY_STYLE_TYPE));
-
-				visElem.button->onHover.connect(std::bind(onHover, i, curVisIdx));
-				visElem.button->onClick.connect(std::bind(onClick, i, curVisIdx));
-				_registerChildElement(visElem.button);
-
-				const WString& shortcutTag = element.getShortcutTag();
-				if (!shortcutTag.empty())
-				{
-					visElem.shortcutLabel = GUILabel::create(HString(shortcutTag), "RightAlignedLabel");
-					_registerChildElement(visElem.shortcutLabel);
-				}
-			}
-
-			curVisIdx++;
-		}
-
-		_markLayoutAsDirty();
-	}
-
-	UINT32 GUIDropDownContent::getElementHeight(UINT32 idx) const
-	{
-		if (_getParentWidget() == nullptr)
-			return 14; // Arbitrary
-
-		if (mDropDownData.entries[idx].isSeparator())
-			return _getParentWidget()->getSkin().getStyle(getSubStyleName(SEPARATOR_STYLE_TYPE))->height;
-		else if (mDropDownData.entries[idx].isSubMenu())
-			return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_EXP_STYLE_TYPE))->height;
-		else
-		{
-			if (mIsToggle)
-				return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE))->height;
-			else
-				return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_STYLE_TYPE))->height;
-		}
-	}
-
-	HString GUIDropDownContent::getElementLocalizedName(UINT32 idx) const
-	{
-		const WString& label = mDropDownData.entries[idx].getLabel();
-
-		auto findLocalizedName = mDropDownData.localizedNames.find(label);
-		if (findLocalizedName != mDropDownData.localizedNames.end())
-			return findLocalizedName->second;
-		else
-			return HString(label);
-	}
-
-	void GUIDropDownContent::setKeyboardFocus(bool focus) 
-	{ 
-		mKeyboardFocus = focus; 
-		setFocus(focus);
-	}
-
-	bool GUIDropDownContent::_commandEvent(const GUICommandEvent& ev)
-	{
-		bool baseReturn = GUIElementContainer::_commandEvent(ev);
-
-		if (!mKeyboardFocus)
-			return baseReturn;
-
-		UINT32 maxElemIdx = (UINT32)mDropDownData.entries.size();
-
-		switch (ev.getType())
-		{
-		case GUICommandEventType::MoveDown:
-			if (mSelectedIdx == UINT_MAX)
-				selectNext(0);
-			else
-				selectNext(mVisibleElements[mSelectedIdx].idx + 1);
-			return true;
-		case GUICommandEventType::MoveUp:
-			if (mSelectedIdx == UINT_MAX)
-				selectNext(0);
-			else
-				selectPrevious(mVisibleElements[mSelectedIdx].idx - 1);
-			return true;
-		case GUICommandEventType::Escape:
-		case GUICommandEventType::MoveLeft:
-			mParent->close();
-			return true;
-		case GUICommandEventType::MoveRight:
-		{
-			if (mSelectedIdx == UINT_MAX)
-				selectNext(0);
-			else
-			{
-				GUIDropDownDataEntry& entry = mDropDownData.entries[mVisibleElements[mSelectedIdx].idx];
-				if (entry.isSubMenu())
-					mParent->elementActivated(mVisibleElements[mSelectedIdx].idx, mVisibleElements[mSelectedIdx].button->_getLayoutData().area);
-			}
-		}
-			return true;
-		case GUICommandEventType::Confirm:
-			if (mSelectedIdx == UINT_MAX)
-				selectNext(0);
-			else
-			{
-				if (mIsToggle)
-					mVisibleElements[mSelectedIdx].button->_setOn(!mVisibleElements[mSelectedIdx].button->_isOn());
-
-				mParent->elementActivated(mVisibleElements[mSelectedIdx].idx, mVisibleElements[mSelectedIdx].button->_getLayoutData().area);
-			}
-			return true;
-		}
-
-		return baseReturn;
-	}
-
-	bool GUIDropDownContent::_mouseEvent(const GUIMouseEvent& ev)
-	{
-		if (ev.getType() == GUIMouseEventType::MouseWheelScroll)
-		{
-			if (ev.getWheelScrollAmount() < 0)
-				mParent->scrollDown();
-			else
-				mParent->scrollUp();
-
-			return true;
-		}
-
-		return false;
-	}
-
-	void GUIDropDownContent::setSelected(UINT32 idx)
-	{
-		if (mSelectedIdx != UINT_MAX)
-		{
-			if (mVisibleElements[mSelectedIdx].button->_isOn())
-				mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::NormalOn);
-			else
-				mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::Normal);
-		}
-
-		mSelectedIdx = idx;
-		if (mVisibleElements[mSelectedIdx].button->_isOn())
-			mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::HoverOn);
-		else
-			mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::Hover);
-
-		mParent->elementSelected(mVisibleElements[mSelectedIdx].idx);
-	}
-
-	void GUIDropDownContent::selectNext(UINT32 startIdx)
-	{
-		UINT32 numElements = (UINT32)mDropDownData.entries.size();
-
-		bool gotNextIndex = false;
-		UINT32 nextIdx = startIdx;
-		for (UINT32 i = 0; i < numElements; i++)
-		{
-			if (nextIdx >= numElements)
-				nextIdx = 0; // Wrap around
-
-			GUIDropDownDataEntry& entry = mDropDownData.entries[nextIdx];
-			if (!entry.isSeparator())
-			{
-				gotNextIndex = true;
-				break;
-			}
-
-			nextIdx++;
-		}
-
-		if (gotNextIndex)
-		{
-			while (nextIdx < mRangeStart || nextIdx >= mRangeEnd)
-				mParent->scrollDown();
-
-			UINT32 visIdx = 0;
-			for (auto& visElem : mVisibleElements)
-			{
-				if (visElem.idx == nextIdx)
-				{
-					setSelected(visIdx);
-					break;
-				}
-
-				visIdx++;
-			}
-		}
-	}
-
-	void GUIDropDownContent::selectPrevious(UINT32 startIdx)
-	{
-		UINT32 numElements = (UINT32)mDropDownData.entries.size();
-
-		bool gotNextIndex = false;
-		INT32 prevIdx = (INT32)startIdx;
-
-		for (UINT32 i = 0; i < numElements; i++)
-		{
-			if (prevIdx < 0)
-				prevIdx = numElements - 1; // Wrap around
-
-			GUIDropDownDataEntry& entry = mDropDownData.entries[prevIdx];
-			if (!entry.isSeparator())
-			{
-				gotNextIndex = true;
-				break;
-			}
-
-			prevIdx--;
-		}
-
-		if (gotNextIndex)
-		{
-			while (prevIdx < (INT32)mRangeStart || prevIdx >= (INT32)mRangeEnd)
-				mParent->scrollUp();
-
-			UINT32 visIdx = 0;
-			for (auto& visElem : mVisibleElements)
-			{
-				if (visElem.idx == prevIdx)
-				{
-					setSelected(visIdx);
-					break;
-				}
-
-				visIdx++;
-			}
-		}
-	}
-
-	Vector2I GUIDropDownContent::_getOptimalSize() const
-	{
-		Vector2I optimalSize;
-		for (auto& visElem : mVisibleElements)
-		{
-			const GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
-
-			optimalSize.y += (INT32)getElementHeight(visElem.idx);
-
-			if (element.isSeparator())
-				optimalSize.x = std::max(optimalSize.x, visElem.separator->_getOptimalSize().x);
-			else
-				optimalSize.x = std::max(optimalSize.x, visElem.button->_getOptimalSize().x);
-		}
-
-		return optimalSize;
-	}
-
-	void GUIDropDownContent::_updateLayoutInternal(const GUILayoutData& data)
-	{
-		GUILayoutData childData = data;
-		INT32 yOffset = data.area.y;
-
-		for (auto& visElem : mVisibleElements)
-		{
-			const GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
-
-			GUIElement* guiMainElement = nullptr;
-			if (element.isSeparator())
-				guiMainElement = visElem.separator;
-			else
-				guiMainElement = visElem.button;
-
-			childData.area.y = yOffset;
-			childData.area.height = getElementHeight(visElem.idx);
-
-			yOffset += childData.area.height;
-
-			guiMainElement->_setLayoutData(childData);
-
-			// Shortcut label
-			GUILabel* shortcutLabel = visElem.shortcutLabel;
-			if (shortcutLabel != nullptr)
-				shortcutLabel->_setLayoutData(childData);
-		}
-	}
-
-	const String& GUIDropDownContent::getGUITypeName()
-	{
-		static String typeName = "GUIDropDownContent";
-		return typeName;
-	}
+#include "BsGUIDropDownContent.h"
+#include "BsGUITexture.h"
+#include "BsGUIButton.h"
+#include "BsGUILabel.h"
+#include "BsGUIWidget.h"
+#include "BsGUIToggle.h"
+#include "BsGUISkin.h"
+#include "BsGUIMouseEvent.h"
+#include "BsGUICommandEvent.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	const String GUIDropDownContent::ENTRY_TOGGLE_STYLE_TYPE = "DropDownEntryToggleBtn";
+	const String GUIDropDownContent::ENTRY_STYLE_TYPE = "DropDownEntryBtn";
+	const String GUIDropDownContent::ENTRY_EXP_STYLE_TYPE = "DropDownEntryExpBtn";
+	const String GUIDropDownContent::SEPARATOR_STYLE_TYPE = "DropDownSeparator";
+
+	GUIDropDownContent::GUIDropDownContent(GUIDropDownMenu::DropDownSubMenu* parent, const GUIDropDownData& dropDownData, 
+		const String& style, const GUIDimensions& dimensions)
+		:GUIElementContainer(dimensions, style), mDropDownData(dropDownData), mKeyboardFocus(true), 
+		mStates(dropDownData.states), mSelectedIdx(UINT_MAX), mRangeStart(0), mRangeEnd(0), mParent(parent), 
+		mIsToggle(parent->getType() == GUIDropDownType::MultiListBox)
+	{
+
+	}
+
+	GUIDropDownContent::~GUIDropDownContent()
+	{
+
+	}
+
+	GUIDropDownContent* GUIDropDownContent::create(GUIDropDownMenu::DropDownSubMenu* parent, 
+		const GUIDropDownData& dropDownData, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIDropDownContent::getGUITypeName();
+
+		return new (bs_alloc<GUIDropDownContent>()) GUIDropDownContent(parent, dropDownData, *curStyle, GUIDimensions::create());
+	}
+
+	GUIDropDownContent* GUIDropDownContent::create(GUIDropDownMenu::DropDownSubMenu* parent, 
+		const GUIDropDownData& dropDownData, const GUIOptions& options,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &GUIDropDownContent::getGUITypeName();
+
+		return new (bs_alloc<GUIDropDownContent>()) GUIDropDownContent(parent, dropDownData, *curStyle, GUIDimensions::create(options));
+	}
+
+	void GUIDropDownContent::styleUpdated()
+	{
+		for (auto& visElem : mVisibleElements)
+		{
+			GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
+
+			if (element.isSeparator())
+				visElem.separator->setStyle(getSubStyleName(SEPARATOR_STYLE_TYPE));
+			else if (element.isSubMenu())
+				visElem.button->setStyle(getSubStyleName(ENTRY_EXP_STYLE_TYPE));
+			else
+			{
+				if (mIsToggle)
+					visElem.button->setStyle(getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE));
+				else
+					visElem.button->setStyle(getSubStyleName(ENTRY_STYLE_TYPE));
+			}
+		}
+	}
+
+	void GUIDropDownContent::setRange(UINT32 start, UINT32 end)
+	{
+		std::function<void(UINT32, UINT32)> onHover = 
+			[&](UINT32 idx, UINT32 visIdx) 
+		{ 
+			setSelected(visIdx);
+			mParent->elementSelected(idx); 
+		};
+
+		std::function<void(UINT32, UINT32)> onClick =
+			[&](UINT32 idx, UINT32 visIdx)
+		{ 
+			setSelected(visIdx);
+
+			if (mIsToggle)
+				mStates[idx] = !mStates[idx];
+
+			mParent->elementActivated(idx, mVisibleElements[visIdx].button->_getLayoutData().area);
+		};
+
+		// Remove all elements
+		while (_getNumChildren() > 0)
+		{
+			GUIElementBase* child = _getChild(_getNumChildren() - 1);
+			assert(child->_getType() == GUIElementBase::Type::Element);
+
+			GUIElement::destroy(static_cast<GUIElement*>(child));
+		}
+
+		mRangeStart = start;
+		mRangeEnd = end;
+		
+		UINT32 range = end - start;
+		if (mSelectedIdx != UINT_MAX && mSelectedIdx > range)
+			mSelectedIdx = UINT_MAX;
+
+		mVisibleElements.clear();
+		UINT32 curVisIdx = 0;
+		for (UINT32 i = start; i < end; i++)
+		{
+			mVisibleElements.push_back(VisibleElement());
+			VisibleElement& visElem = mVisibleElements.back();
+			visElem.idx = i;
+			GUIDropDownDataEntry& element = mDropDownData.entries[i];
+
+			if (element.isSeparator())
+			{
+				visElem.separator = GUITexture::create(GUIImageScaleMode::StretchToFit, getSubStyleName(SEPARATOR_STYLE_TYPE));
+				_registerChildElement(visElem.separator);
+			}
+			else if (element.isSubMenu())
+			{
+				visElem.button = GUIButton::create(getElementLocalizedName(i), getSubStyleName(ENTRY_EXP_STYLE_TYPE));
+				visElem.button->onHover.connect(std::bind(onClick, i, curVisIdx));
+				_registerChildElement(visElem.button);
+			}
+			else
+			{
+				if (mIsToggle)
+				{
+					GUIToggle* toggle = GUIToggle::create(getElementLocalizedName(i), getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE));
+					if (mStates[i])
+						toggle->toggleOn();
+
+					visElem.button = toggle;					
+				}
+				else
+					visElem.button = GUIButton::create(getElementLocalizedName(i), getSubStyleName(ENTRY_STYLE_TYPE));
+
+				visElem.button->onHover.connect(std::bind(onHover, i, curVisIdx));
+				visElem.button->onClick.connect(std::bind(onClick, i, curVisIdx));
+				_registerChildElement(visElem.button);
+
+				const WString& shortcutTag = element.getShortcutTag();
+				if (!shortcutTag.empty())
+				{
+					visElem.shortcutLabel = GUILabel::create(HString(shortcutTag), "RightAlignedLabel");
+					_registerChildElement(visElem.shortcutLabel);
+				}
+			}
+
+			curVisIdx++;
+		}
+
+		_markLayoutAsDirty();
+	}
+
+	UINT32 GUIDropDownContent::getElementHeight(UINT32 idx) const
+	{
+		if (_getParentWidget() == nullptr)
+			return 14; // Arbitrary
+
+		if (mDropDownData.entries[idx].isSeparator())
+			return _getParentWidget()->getSkin().getStyle(getSubStyleName(SEPARATOR_STYLE_TYPE))->height;
+		else if (mDropDownData.entries[idx].isSubMenu())
+			return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_EXP_STYLE_TYPE))->height;
+		else
+		{
+			if (mIsToggle)
+				return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_TOGGLE_STYLE_TYPE))->height;
+			else
+				return _getParentWidget()->getSkin().getStyle(getSubStyleName(ENTRY_STYLE_TYPE))->height;
+		}
+	}
+
+	HString GUIDropDownContent::getElementLocalizedName(UINT32 idx) const
+	{
+		const WString& label = mDropDownData.entries[idx].getLabel();
+
+		auto findLocalizedName = mDropDownData.localizedNames.find(label);
+		if (findLocalizedName != mDropDownData.localizedNames.end())
+			return findLocalizedName->second;
+		else
+			return HString(label);
+	}
+
+	void GUIDropDownContent::setKeyboardFocus(bool focus) 
+	{ 
+		mKeyboardFocus = focus; 
+		setFocus(focus);
+	}
+
+	bool GUIDropDownContent::_commandEvent(const GUICommandEvent& ev)
+	{
+		bool baseReturn = GUIElementContainer::_commandEvent(ev);
+
+		if (!mKeyboardFocus)
+			return baseReturn;
+
+		UINT32 maxElemIdx = (UINT32)mDropDownData.entries.size();
+
+		switch (ev.getType())
+		{
+		case GUICommandEventType::MoveDown:
+			if (mSelectedIdx == UINT_MAX)
+				selectNext(0);
+			else
+				selectNext(mVisibleElements[mSelectedIdx].idx + 1);
+			return true;
+		case GUICommandEventType::MoveUp:
+			if (mSelectedIdx == UINT_MAX)
+				selectNext(0);
+			else
+				selectPrevious(mVisibleElements[mSelectedIdx].idx - 1);
+			return true;
+		case GUICommandEventType::Escape:
+		case GUICommandEventType::MoveLeft:
+			mParent->close();
+			return true;
+		case GUICommandEventType::MoveRight:
+		{
+			if (mSelectedIdx == UINT_MAX)
+				selectNext(0);
+			else
+			{
+				GUIDropDownDataEntry& entry = mDropDownData.entries[mVisibleElements[mSelectedIdx].idx];
+				if (entry.isSubMenu())
+					mParent->elementActivated(mVisibleElements[mSelectedIdx].idx, mVisibleElements[mSelectedIdx].button->_getLayoutData().area);
+			}
+		}
+			return true;
+		case GUICommandEventType::Confirm:
+			if (mSelectedIdx == UINT_MAX)
+				selectNext(0);
+			else
+			{
+				if (mIsToggle)
+					mVisibleElements[mSelectedIdx].button->_setOn(!mVisibleElements[mSelectedIdx].button->_isOn());
+
+				mParent->elementActivated(mVisibleElements[mSelectedIdx].idx, mVisibleElements[mSelectedIdx].button->_getLayoutData().area);
+			}
+			return true;
+		}
+
+		return baseReturn;
+	}
+
+	bool GUIDropDownContent::_mouseEvent(const GUIMouseEvent& ev)
+	{
+		if (ev.getType() == GUIMouseEventType::MouseWheelScroll)
+		{
+			if (ev.getWheelScrollAmount() < 0)
+				mParent->scrollDown();
+			else
+				mParent->scrollUp();
+
+			return true;
+		}
+
+		return false;
+	}
+
+	void GUIDropDownContent::setSelected(UINT32 idx)
+	{
+		if (mSelectedIdx != UINT_MAX)
+		{
+			if (mVisibleElements[mSelectedIdx].button->_isOn())
+				mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::NormalOn);
+			else
+				mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::Normal);
+		}
+
+		mSelectedIdx = idx;
+		if (mVisibleElements[mSelectedIdx].button->_isOn())
+			mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::HoverOn);
+		else
+			mVisibleElements[mSelectedIdx].button->_setState(GUIElementState::Hover);
+
+		mParent->elementSelected(mVisibleElements[mSelectedIdx].idx);
+	}
+
+	void GUIDropDownContent::selectNext(UINT32 startIdx)
+	{
+		UINT32 numElements = (UINT32)mDropDownData.entries.size();
+
+		bool gotNextIndex = false;
+		UINT32 nextIdx = startIdx;
+		for (UINT32 i = 0; i < numElements; i++)
+		{
+			if (nextIdx >= numElements)
+				nextIdx = 0; // Wrap around
+
+			GUIDropDownDataEntry& entry = mDropDownData.entries[nextIdx];
+			if (!entry.isSeparator())
+			{
+				gotNextIndex = true;
+				break;
+			}
+
+			nextIdx++;
+		}
+
+		if (gotNextIndex)
+		{
+			while (nextIdx < mRangeStart || nextIdx >= mRangeEnd)
+				mParent->scrollDown();
+
+			UINT32 visIdx = 0;
+			for (auto& visElem : mVisibleElements)
+			{
+				if (visElem.idx == nextIdx)
+				{
+					setSelected(visIdx);
+					break;
+				}
+
+				visIdx++;
+			}
+		}
+	}
+
+	void GUIDropDownContent::selectPrevious(UINT32 startIdx)
+	{
+		UINT32 numElements = (UINT32)mDropDownData.entries.size();
+
+		bool gotNextIndex = false;
+		INT32 prevIdx = (INT32)startIdx;
+
+		for (UINT32 i = 0; i < numElements; i++)
+		{
+			if (prevIdx < 0)
+				prevIdx = numElements - 1; // Wrap around
+
+			GUIDropDownDataEntry& entry = mDropDownData.entries[prevIdx];
+			if (!entry.isSeparator())
+			{
+				gotNextIndex = true;
+				break;
+			}
+
+			prevIdx--;
+		}
+
+		if (gotNextIndex)
+		{
+			while (prevIdx < (INT32)mRangeStart || prevIdx >= (INT32)mRangeEnd)
+				mParent->scrollUp();
+
+			UINT32 visIdx = 0;
+			for (auto& visElem : mVisibleElements)
+			{
+				if (visElem.idx == prevIdx)
+				{
+					setSelected(visIdx);
+					break;
+				}
+
+				visIdx++;
+			}
+		}
+	}
+
+	Vector2I GUIDropDownContent::_getOptimalSize() const
+	{
+		Vector2I optimalSize;
+		for (auto& visElem : mVisibleElements)
+		{
+			const GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
+
+			optimalSize.y += (INT32)getElementHeight(visElem.idx);
+
+			if (element.isSeparator())
+				optimalSize.x = std::max(optimalSize.x, visElem.separator->_getOptimalSize().x);
+			else
+				optimalSize.x = std::max(optimalSize.x, visElem.button->_getOptimalSize().x);
+		}
+
+		return optimalSize;
+	}
+
+	void GUIDropDownContent::_updateLayoutInternal(const GUILayoutData& data)
+	{
+		GUILayoutData childData = data;
+		INT32 yOffset = data.area.y;
+
+		for (auto& visElem : mVisibleElements)
+		{
+			const GUIDropDownDataEntry& element = mDropDownData.entries[visElem.idx];
+
+			GUIElement* guiMainElement = nullptr;
+			if (element.isSeparator())
+				guiMainElement = visElem.separator;
+			else
+				guiMainElement = visElem.button;
+
+			childData.area.y = yOffset;
+			childData.area.height = getElementHeight(visElem.idx);
+
+			yOffset += childData.area.height;
+
+			guiMainElement->_setLayoutData(childData);
+
+			// Shortcut label
+			GUILabel* shortcutLabel = visElem.shortcutLabel;
+			if (shortcutLabel != nullptr)
+				shortcutLabel->_setLayoutData(childData);
+		}
+	}
+
+	const String& GUIDropDownContent::getGUITypeName()
+	{
+		static String typeName = "GUIDropDownContent";
+		return typeName;
+	}
 }

+ 0 - 2
BansheeEngine/Source/BsGUIDropDownHitBox.cpp

@@ -1,8 +1,6 @@
 #include "BsGUIDropDownHitBox.h"
 #include "BsGUICommandEvent.h"
 #include "BsGUIMouseEvent.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 
 namespace BansheeEngine
 {

+ 497 - 497
BansheeEngine/Source/BsGUIDropDownMenu.cpp

@@ -1,498 +1,498 @@
-#include "BsGUIDropDownMenu.h"
-#include "BsGUIPanel.h"
-#include "BsGUILayoutY.h"
-#include "BsGUILayoutX.h"
-#include "BsGUITexture.h"
-#include "BsGUILabel.h"
-#include "BsGUIButton.h"
-#include "BsGUISpace.h"
-#include "BsGUIContent.h"
-#include "BsGUISkin.h"
-#include "BsViewport.h"
-#include "BsGUIListBox.h"
-#include "BsGUIDropDownBoxManager.h"
-#include "BsSceneObject.h"
-#include "BsGUIDropDownHitBox.h"
-#include "BsGUIDropDownContent.h"
-#include "BsCamera.h"
-#include "BsDebug.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	const UINT32 GUIDropDownMenu::DROP_DOWN_BOX_WIDTH = 250;
-
-	GUIDropDownDataEntry GUIDropDownDataEntry::separator()
-	{
-		GUIDropDownDataEntry data;
-		data.mType = Type::Separator;
-		data.mCallback = nullptr;
-
-		return data;
-	}
-
-	GUIDropDownDataEntry GUIDropDownDataEntry::button(const WString& label, std::function<void()> callback, const WString& shortcutTag)
-	{
-		GUIDropDownDataEntry data;
-		data.mLabel = label;
-		data.mType = Type::Entry;
-		data.mCallback = callback;
-		data.mShortcutTag = shortcutTag;
-
-		return data;
-	}
-
-	GUIDropDownDataEntry GUIDropDownDataEntry::subMenu(const WString& label, const GUIDropDownData& data)
-	{
-		GUIDropDownDataEntry dataEntry;
-		dataEntry.mLabel = label;
-		dataEntry.mType = Type::SubMenu;
-		dataEntry.mChildData = data;
-
-		return dataEntry;
-	}
-
-	GUIDropDownMenu::GUIDropDownMenu(const HSceneObject& parent, const DROP_DOWN_BOX_DESC& desc, GUIDropDownType type)
-		:CGUIWidget(parent, desc.camera), mRootMenu(nullptr), mFrontHitBox(nullptr), mCaptureHitBox(nullptr), mBackHitBox(nullptr)
-	{
-		String stylePrefix = "";
-		switch(type)
-		{
-		case GUIDropDownType::ContextMenu:
-			stylePrefix = "ContextMenu";
-			break;
-		case GUIDropDownType::ListBox:
-		case GUIDropDownType::MultiListBox:
-			stylePrefix = "ListBox";
-			break;
-		case GUIDropDownType::MenuBar:
-			stylePrefix = "MenuBar";
-			break;
-		}
-
-		mScrollUpStyle = stylePrefix + "ScrollUpBtn";
-		mScrollDownStyle = stylePrefix + "ScrollDownBtn";
-		mBackgroundStyle = stylePrefix + "Frame";
-		mContentStyle = stylePrefix + "Content";
-		mSideBackgroundStyle = stylePrefix + "SidebarBg";
-		mHandleStyle = stylePrefix + "Handle";
-
-		setDepth(0); // Needs to be in front of everything
-		setSkin(desc.skin);
-
-		mFrontHitBox = GUIDropDownHitBox::create(false, false);
-		mFrontHitBox->onFocusLost.connect(std::bind(&GUIDropDownMenu::dropDownFocusLost, this));
-		mFrontHitBox->setFocus(true);
-		GUILayoutData hitboxLayoutData = mFrontHitBox->_getLayoutData();
-		hitboxLayoutData.setWidgetDepth(0);
-		hitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::min());
-		mFrontHitBox->_setLayoutData(hitboxLayoutData);
-		mFrontHitBox->_changeParentWidget(this);
-		mFrontHitBox->_markLayoutAsDirty();
-
-		mBackHitBox = GUIDropDownHitBox::create(false, true);
-		GUILayoutData backHitboxLayoutData = mBackHitBox->_getLayoutData();
-		backHitboxLayoutData.setWidgetDepth(0);
-		backHitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::max());
-		mBackHitBox->_setLayoutData(backHitboxLayoutData);
-		mBackHitBox->_changeParentWidget(this);
-		mBackHitBox->_markLayoutAsDirty();
-
-		ViewportPtr viewport = desc.camera->getViewport();
-
-		Rect2I targetBounds(0, 0, viewport->getWidth(), viewport->getHeight());
-		Vector<Rect2I> captureBounds;
-		targetBounds.cut(desc.additionalBounds, captureBounds);
-
-		mCaptureHitBox = GUIDropDownHitBox::create(true, false);
-		mCaptureHitBox->setBounds(captureBounds);
-		GUILayoutData captureHitboxLayoutData = mCaptureHitBox->_getLayoutData();
-		captureHitboxLayoutData.setWidgetDepth(0);
-		captureHitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::max());
-		mCaptureHitBox->_setLayoutData(captureHitboxLayoutData);
-		mCaptureHitBox->_changeParentWidget(this);
-		mCaptureHitBox->_markLayoutAsDirty();
-
-		mAdditionalCaptureBounds = desc.additionalBounds;
-
-		Rect2I availableBounds(viewport->getX(), viewport->getY(), viewport->getWidth(), viewport->getHeight());
-		mRootMenu = bs_new<DropDownSubMenu>(this, nullptr, desc.placement, availableBounds, desc.dropDownData, type, 0);
-	}
-
-	GUIDropDownMenu::~GUIDropDownMenu()
-	{
-
-	}
-
-	void GUIDropDownMenu::onDestroyed()
-	{
-		GUIElement::destroy(mFrontHitBox);
-		GUIElement::destroy(mBackHitBox);
-		GUIElement::destroy(mCaptureHitBox);
-		bs_delete(mRootMenu);
-		mRootMenu = nullptr;
-
-		CGUIWidget::onDestroyed();
-	}
-
-	void GUIDropDownMenu::dropDownFocusLost()
-	{
-		mRootMenu->closeSubMenu();
-		GUIDropDownBoxManager::instance().closeDropDownBox();
-	}
-
-	void GUIDropDownMenu::notifySubMenuOpened(DropDownSubMenu* subMenu)
-	{
-		Vector<Rect2I> bounds;
-		while(subMenu != nullptr)
-		{
-			bounds.push_back(subMenu->getVisibleBounds());
-
-			subMenu = subMenu->mParent;
-		}
-
-		mBackHitBox->setBounds(bounds);
-
-		for (auto& additionalBound : mAdditionalCaptureBounds)
-			bounds.push_back(additionalBound);
-
-		mFrontHitBox->setBounds(bounds);
-	}
-
-	void GUIDropDownMenu::notifySubMenuClosed(DropDownSubMenu* subMenu)
-	{
-		Vector<Rect2I> bounds;
-		while(subMenu != nullptr)
-		{
-			bounds.push_back(subMenu->getVisibleBounds());
-
-			subMenu = subMenu->mParent;
-		}
-
-		mBackHitBox->setBounds(bounds);
-		
-		for (auto& additionalBound : mAdditionalCaptureBounds)
-			bounds.push_back(additionalBound);
-
-		mFrontHitBox->setBounds(bounds);
-	}
-
-	GUIDropDownMenu::DropDownSubMenu::DropDownSubMenu(GUIDropDownMenu* owner, DropDownSubMenu* parent, const DropDownAreaPlacement& placement,
-		const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset)
-		:mOwner(owner), mParent(parent), mPage(0), mBackgroundFrame(nullptr), mBackgroundPanel(nullptr), mContentPanel(nullptr),
-		mContentLayout(nullptr), x(0), y(0), width(0), height(0), mSidebarPanel(nullptr), mType(type), mSubMenu(nullptr), 
-		mData(dropDownData), mOpenedUpward(false), mDepthOffset(depthOffset), mContent(nullptr)
-	{
-		mAvailableBounds = availableBounds;
-
-		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
-		const GUIElementStyle* sideBarStyle = mOwner->getSkin().getStyle(mOwner->mSideBackgroundStyle);
-
-		// Create content GUI element
-		mContent = GUIDropDownContent::create(this, dropDownData, mOwner->mContentStyle);
-		mContent->setKeyboardFocus(true);
-
-		// Content area
-		mContentPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
-		mContentPanel->setWidth(width);
-		mContentPanel->setHeight(height);
-		mContentPanel->setDepthRange(100 - depthOffset * 2 - 1);
-
-		// Background frame
-		mBackgroundPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
-		mBackgroundPanel->setWidth(width);
-		mBackgroundPanel->setHeight(height);
-		mBackgroundPanel->setDepthRange(100 - depthOffset * 2);
-
-		GUILayout* backgroundLayout = mBackgroundPanel->addNewElement<GUILayoutX>();
-
-		mBackgroundFrame = GUITexture::create(GUIImageScaleMode::StretchToFit, mOwner->mBackgroundStyle);
-		backgroundLayout->addElement(mBackgroundFrame);
-
-		mContentLayout = mContentPanel->addNewElement<GUILayoutY>();
-		mContentLayout->addElement(mContent); // Note: It's important this is added to the layout before we 
-		// use it for size calculations, in order for its skin to be assigned
-
-		UINT32 dropDownBoxWidth = DROP_DOWN_BOX_WIDTH + sideBarStyle->width;
-
-		UINT32 maxNeededHeight = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
-		UINT32 numElements = (UINT32)dropDownData.entries.size();
-		for (UINT32 i = 0; i < numElements; i++)
-			maxNeededHeight += mContent->getElementHeight(i);
-
-		DropDownAreaPlacement::HorzDir horzDir;
-		DropDownAreaPlacement::VertDir vertDir;
-		Rect2I placementBounds = placement.getOptimalBounds(dropDownBoxWidth, maxNeededHeight, availableBounds, horzDir, vertDir);
-
-		mOpenedUpward = vertDir == DropDownAreaPlacement::VertDir::Up;
-
-		UINT32 actualY = placementBounds.y;
-		if (mOpenedUpward)
-			y = placementBounds.y + placementBounds.height;
-		else
-			y = placementBounds.y;
-
-		x = placementBounds.x;
-		width = placementBounds.width;
-		height = placementBounds.height;
-
-		mContentPanel->setPosition(x, actualY);
-		mBackgroundPanel->setPosition(x, actualY);
-
-		updateGUIElements();
-
-		mOwner->notifySubMenuOpened(this);
-	}
-
-	GUIDropDownMenu::DropDownSubMenu::~DropDownSubMenu()
-	{
-		closeSubMenu();
-
-		mOwner->notifySubMenuClosed(this);
-
-		GUIElement::destroy(mContent);
-
-		GUIElement::destroy(mBackgroundFrame);
-
-		GUILayout::destroy(mBackgroundPanel);
-		GUILayout::destroy(mContentPanel);
-
-		if (mSidebarPanel != nullptr)
-			GUIPanel::destroy(mSidebarPanel);
-	}
-
-	Vector<GUIDropDownMenu::DropDownSubMenu::PageInfo> GUIDropDownMenu::DropDownSubMenu::getPageInfos() const
-	{
-		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
-
-		INT32 numElements = (INT32)mData.entries.size();
-
-		PageInfo curPageInfo;
-		curPageInfo.start = 0;
-		curPageInfo.end = 0;
-		curPageInfo.idx = 0;
-		curPageInfo.height = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
-		
-		Vector<PageInfo> pageInfos;
-		for (INT32 i = 0; i < numElements; i++)
-		{
-			curPageInfo.height += mContent->getElementHeight((UINT32)i);
-			curPageInfo.end++;
-
-			if (curPageInfo.height > height)
-			{
-				// Remove last few elements until we fit again
-				while (curPageInfo.height > height && i >= 0)
-				{
-					curPageInfo.height -= mContent->getElementHeight((UINT32)i);
-					curPageInfo.end--;
-
-					i--;
-				}
-
-				// Nothing fits, break out of infinite loop
-				if (curPageInfo.start >= curPageInfo.end)
-					break;
-
-				pageInfos.push_back(curPageInfo);
-
-				curPageInfo.start = curPageInfo.end;
-				curPageInfo.height = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
-
-				curPageInfo.idx++;
-			}
-		}
-
-		if (curPageInfo.start < curPageInfo.end)
-			pageInfos.push_back(curPageInfo);
-
-		return pageInfos;
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::updateGUIElements()
-	{
-		// Remove all elements from content layout
-		while(mContentLayout->getNumChildren() > 0)
-			mContentLayout->removeElementAt(mContentLayout->getNumChildren() - 1);
-
-		mContentLayout->addElement(mContent); // Note: Needs to be added first so that size calculations have proper skin to work with
-
-		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
-		const GUIElementStyle* sideBarStyle = mOwner->getSkin().getStyle(mOwner->mSideBackgroundStyle);
-		const GUIElementStyle* scrollUpStyle = mOwner->getSkin().getStyle(mOwner->mScrollUpStyle);
-		const GUIElementStyle* scrollDownStyle = mOwner->getSkin().getStyle(mOwner->mScrollDownStyle);
-		const GUIElementStyle* handleStyle = mOwner->getSkin().getStyle(mOwner->mHandleStyle);
-
-		Vector<PageInfo> pageInfos = getPageInfos();
-
-		UINT32 pageStart = 0, pageEnd = 0;
-		UINT32 pageHeight = 0;
-		UINT32 pageCount = (UINT32)pageInfos.size();
-		if (pageCount > mPage)
-		{
-			pageStart = pageInfos[mPage].start;
-			pageEnd = pageInfos[mPage].end;
-			pageHeight = pageInfos[mPage].height;
-		}
-
-		INT32 actualY = y;
-
-		if (mOpenedUpward)
-			actualY -= (INT32)pageHeight;
-
-		// Add sidebar if needed
-		UINT32 contentOffset = 0;
-		if (pageInfos.size() > 1)
-		{
-			UINT32 sidebarHeight = pageHeight - 2;
-			contentOffset = sideBarStyle->width;
-
-			if (mSidebarPanel == nullptr)
-			{
-				mSidebarPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
-
-				mScrollUpBtn = GUIButton::create(HString(L""), mOwner->mScrollUpStyle);
-				mScrollUpBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollUp, this));
-
-				mScrollDownBtn = GUIButton::create(HString(L""), mOwner->mScrollDownStyle);
-				mScrollDownBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollDown, this));
-
-				mHandle = GUITexture::create(mOwner->mHandleStyle);
-				GUITexture* background = GUITexture::create(mOwner->mSideBackgroundStyle);
-				background->_setElementDepth(2);
-
-				mSidebarPanel->addElement(background);
-				mSidebarPanel->addElement(mScrollUpBtn);
-				mSidebarPanel->addElement(mScrollDownBtn);
-				mSidebarPanel->addElement(mHandle);
-			}
-
-			mScrollUpBtn->setPosition(1, 1);
-			mScrollDownBtn->setPosition(1, sidebarHeight - 1 - scrollDownStyle->height);
-
-			UINT32 maxHandleSize = std::max(0, (INT32)sidebarHeight - (INT32)scrollDownStyle->height - (INT32)scrollUpStyle->height - 2);
-			UINT32 handleSize = maxHandleSize / pageCount;
-
-			INT32 handlePos = 1 + scrollUpStyle->height + mPage * handleSize;
-
-			mHandle->setPosition(1, handlePos);
-			mHandle->setHeight(handleSize);
-
-			mSidebarPanel->setPosition(x, actualY);
-			mSidebarPanel->setWidth(sideBarStyle->width);
-			mSidebarPanel->setHeight(sidebarHeight);
-		}
-		else
-		{
-			if (mSidebarPanel != nullptr)
-			{
-				GUIPanel::destroy(mSidebarPanel);
-				mSidebarPanel = nullptr;
-			}
-		}
-
-		mContent->setRange(pageStart, pageEnd);
-
-		if (mSubMenu == nullptr)
-			mContent->setKeyboardFocus(true);
-
-		// Resize and reposition areas
-		mBackgroundPanel->setWidth(width - contentOffset);
-		mBackgroundPanel->setHeight(pageHeight);
-		mBackgroundPanel->setPosition(x + contentOffset, actualY);
-
-		mVisibleBounds = Rect2I(x, actualY, width, pageHeight);
-
-		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)backgroundStyle->margins.left - (INT32)backgroundStyle->margins.right - (INT32)contentOffset);
-		UINT32 contentHeight = (UINT32)std::max(0, (INT32)pageHeight - (INT32)backgroundStyle->margins.top - (INT32)backgroundStyle->margins.bottom);
-
-		mContentPanel->setWidth(contentWidth);
-		mContentPanel->setHeight(contentHeight);
-		mContentPanel->setPosition(x + contentOffset + backgroundStyle->margins.left, actualY + backgroundStyle->margins.top);
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::scrollDown()
-	{
-		mPage++;
-		if (mPage == (UINT32)getPageInfos().size())
-			mPage = 0;
-
-		updateGUIElements();
-
-		closeSubMenu();
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::scrollUp()
-	{
-		if (mPage > 0)
-			mPage--;
-		else
-			mPage = (UINT32)getPageInfos().size() - 1;
-
-		updateGUIElements();
-		closeSubMenu();
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::scrollToTop()
-	{
-		mPage = 0;
-		updateGUIElements();
-
-		closeSubMenu();
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::scrollToBottom()
-	{
-		mPage = (UINT32)(getPageInfos().size() - 1);
-		updateGUIElements();
-
-		closeSubMenu();
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::closeSubMenu()
-	{
-		if(mSubMenu != nullptr)
-		{
-			bs_delete(mSubMenu);
-			mSubMenu = nullptr;
-
-			mContent->setKeyboardFocus(true);
-		}
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::elementActivated(UINT32 idx, const Rect2I& bounds)
-	{
-		closeSubMenu();
-
-		if (!mData.entries[idx].isSubMenu())
-		{
-			auto callback = mData.entries[idx].getCallback();
-			if (callback != nullptr)
-				callback();
-
-			if (mType != GUIDropDownType::MultiListBox)
-				GUIDropDownBoxManager::instance().closeDropDownBox();
-		}
-		else
-		{
-			mContent->setKeyboardFocus(false);
-
-			mSubMenu = bs_new<DropDownSubMenu>(mOwner, this, DropDownAreaPlacement::aroundBoundsVert(bounds),
-				mAvailableBounds, mData.entries[idx].getSubMenuData(), mType, mDepthOffset + 1);
-		}
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::close()
-	{
-		if (mParent != nullptr)
-			mParent->closeSubMenu();
-		else // We're the last sub-menu, close the whole thing
-			GUIDropDownBoxManager::instance().closeDropDownBox();
-	}
-
-	void GUIDropDownMenu::DropDownSubMenu::elementSelected(UINT32 idx)
-	{
-		closeSubMenu();
-	}
+#include "BsGUIDropDownMenu.h"
+#include "BsGUIPanel.h"
+#include "BsGUILayoutY.h"
+#include "BsGUILayoutX.h"
+#include "BsGUITexture.h"
+#include "BsGUILabel.h"
+#include "BsGUIButton.h"
+#include "BsGUISpace.h"
+#include "BsGUIContent.h"
+#include "BsGUISkin.h"
+#include "BsViewport.h"
+#include "BsGUIListBox.h"
+#include "BsGUIDropDownBoxManager.h"
+#include "BsSceneObject.h"
+#include "BsGUIDropDownHitBox.h"
+#include "BsGUIDropDownContent.h"
+#include "BsCamera.h"
+#include "BsDebug.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	const UINT32 GUIDropDownMenu::DROP_DOWN_BOX_WIDTH = 250;
+
+	GUIDropDownDataEntry GUIDropDownDataEntry::separator()
+	{
+		GUIDropDownDataEntry data;
+		data.mType = Type::Separator;
+		data.mCallback = nullptr;
+
+		return data;
+	}
+
+	GUIDropDownDataEntry GUIDropDownDataEntry::button(const WString& label, std::function<void()> callback, const WString& shortcutTag)
+	{
+		GUIDropDownDataEntry data;
+		data.mLabel = label;
+		data.mType = Type::Entry;
+		data.mCallback = callback;
+		data.mShortcutTag = shortcutTag;
+
+		return data;
+	}
+
+	GUIDropDownDataEntry GUIDropDownDataEntry::subMenu(const WString& label, const GUIDropDownData& data)
+	{
+		GUIDropDownDataEntry dataEntry;
+		dataEntry.mLabel = label;
+		dataEntry.mType = Type::SubMenu;
+		dataEntry.mChildData = data;
+
+		return dataEntry;
+	}
+
+	GUIDropDownMenu::GUIDropDownMenu(const HSceneObject& parent, const DROP_DOWN_BOX_DESC& desc, GUIDropDownType type)
+		:CGUIWidget(parent, desc.camera), mRootMenu(nullptr), mFrontHitBox(nullptr), mCaptureHitBox(nullptr), mBackHitBox(nullptr)
+	{
+		String stylePrefix = "";
+		switch(type)
+		{
+		case GUIDropDownType::ContextMenu:
+			stylePrefix = "ContextMenu";
+			break;
+		case GUIDropDownType::ListBox:
+		case GUIDropDownType::MultiListBox:
+			stylePrefix = "ListBox";
+			break;
+		case GUIDropDownType::MenuBar:
+			stylePrefix = "MenuBar";
+			break;
+		}
+
+		mScrollUpStyle = stylePrefix + "ScrollUpBtn";
+		mScrollDownStyle = stylePrefix + "ScrollDownBtn";
+		mBackgroundStyle = stylePrefix + "Frame";
+		mContentStyle = stylePrefix + "Content";
+		mSideBackgroundStyle = stylePrefix + "SidebarBg";
+		mHandleStyle = stylePrefix + "Handle";
+
+		setDepth(0); // Needs to be in front of everything
+		setSkin(desc.skin);
+
+		mFrontHitBox = GUIDropDownHitBox::create(false, false);
+		mFrontHitBox->onFocusLost.connect(std::bind(&GUIDropDownMenu::dropDownFocusLost, this));
+		mFrontHitBox->setFocus(true);
+		GUILayoutData hitboxLayoutData = mFrontHitBox->_getLayoutData();
+		hitboxLayoutData.setWidgetDepth(0);
+		hitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::min());
+		mFrontHitBox->_setLayoutData(hitboxLayoutData);
+		mFrontHitBox->_changeParentWidget(_getInternal());
+		mFrontHitBox->_markLayoutAsDirty();
+
+		mBackHitBox = GUIDropDownHitBox::create(false, true);
+		GUILayoutData backHitboxLayoutData = mBackHitBox->_getLayoutData();
+		backHitboxLayoutData.setWidgetDepth(0);
+		backHitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::max());
+		mBackHitBox->_setLayoutData(backHitboxLayoutData);
+		mBackHitBox->_changeParentWidget(_getInternal());
+		mBackHitBox->_markLayoutAsDirty();
+
+		ViewportPtr viewport = desc.camera->getViewport();
+
+		Rect2I targetBounds(0, 0, viewport->getWidth(), viewport->getHeight());
+		Vector<Rect2I> captureBounds;
+		targetBounds.cut(desc.additionalBounds, captureBounds);
+
+		mCaptureHitBox = GUIDropDownHitBox::create(true, false);
+		mCaptureHitBox->setBounds(captureBounds);
+		GUILayoutData captureHitboxLayoutData = mCaptureHitBox->_getLayoutData();
+		captureHitboxLayoutData.setWidgetDepth(0);
+		captureHitboxLayoutData.setPanelDepth(std::numeric_limits<INT16>::max());
+		mCaptureHitBox->_setLayoutData(captureHitboxLayoutData);
+		mCaptureHitBox->_changeParentWidget(_getInternal());
+		mCaptureHitBox->_markLayoutAsDirty();
+
+		mAdditionalCaptureBounds = desc.additionalBounds;
+
+		Rect2I availableBounds(viewport->getX(), viewport->getY(), viewport->getWidth(), viewport->getHeight());
+		mRootMenu = bs_new<DropDownSubMenu>(this, nullptr, desc.placement, availableBounds, desc.dropDownData, type, 0);
+	}
+
+	GUIDropDownMenu::~GUIDropDownMenu()
+	{
+
+	}
+
+	void GUIDropDownMenu::onDestroyed()
+	{
+		GUIElement::destroy(mFrontHitBox);
+		GUIElement::destroy(mBackHitBox);
+		GUIElement::destroy(mCaptureHitBox);
+		bs_delete(mRootMenu);
+		mRootMenu = nullptr;
+
+		CGUIWidget::onDestroyed();
+	}
+
+	void GUIDropDownMenu::dropDownFocusLost()
+	{
+		mRootMenu->closeSubMenu();
+		GUIDropDownBoxManager::instance().closeDropDownBox();
+	}
+
+	void GUIDropDownMenu::notifySubMenuOpened(DropDownSubMenu* subMenu)
+	{
+		Vector<Rect2I> bounds;
+		while(subMenu != nullptr)
+		{
+			bounds.push_back(subMenu->getVisibleBounds());
+
+			subMenu = subMenu->mParent;
+		}
+
+		mBackHitBox->setBounds(bounds);
+
+		for (auto& additionalBound : mAdditionalCaptureBounds)
+			bounds.push_back(additionalBound);
+
+		mFrontHitBox->setBounds(bounds);
+	}
+
+	void GUIDropDownMenu::notifySubMenuClosed(DropDownSubMenu* subMenu)
+	{
+		Vector<Rect2I> bounds;
+		while(subMenu != nullptr)
+		{
+			bounds.push_back(subMenu->getVisibleBounds());
+
+			subMenu = subMenu->mParent;
+		}
+
+		mBackHitBox->setBounds(bounds);
+		
+		for (auto& additionalBound : mAdditionalCaptureBounds)
+			bounds.push_back(additionalBound);
+
+		mFrontHitBox->setBounds(bounds);
+	}
+
+	GUIDropDownMenu::DropDownSubMenu::DropDownSubMenu(GUIDropDownMenu* owner, DropDownSubMenu* parent, const DropDownAreaPlacement& placement,
+		const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset)
+		:mOwner(owner), mParent(parent), mPage(0), mBackgroundFrame(nullptr), mBackgroundPanel(nullptr), mContentPanel(nullptr),
+		mContentLayout(nullptr), x(0), y(0), width(0), height(0), mSidebarPanel(nullptr), mType(type), mSubMenu(nullptr), 
+		mData(dropDownData), mOpenedUpward(false), mDepthOffset(depthOffset), mContent(nullptr)
+	{
+		mAvailableBounds = availableBounds;
+
+		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
+		const GUIElementStyle* sideBarStyle = mOwner->getSkin().getStyle(mOwner->mSideBackgroundStyle);
+
+		// Create content GUI element
+		mContent = GUIDropDownContent::create(this, dropDownData, mOwner->mContentStyle);
+		mContent->setKeyboardFocus(true);
+
+		// Content area
+		mContentPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
+		mContentPanel->setWidth(width);
+		mContentPanel->setHeight(height);
+		mContentPanel->setDepthRange(100 - depthOffset * 2 - 1);
+
+		// Background frame
+		mBackgroundPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
+		mBackgroundPanel->setWidth(width);
+		mBackgroundPanel->setHeight(height);
+		mBackgroundPanel->setDepthRange(100 - depthOffset * 2);
+
+		GUILayout* backgroundLayout = mBackgroundPanel->addNewElement<GUILayoutX>();
+
+		mBackgroundFrame = GUITexture::create(GUIImageScaleMode::StretchToFit, mOwner->mBackgroundStyle);
+		backgroundLayout->addElement(mBackgroundFrame);
+
+		mContentLayout = mContentPanel->addNewElement<GUILayoutY>();
+		mContentLayout->addElement(mContent); // Note: It's important this is added to the layout before we 
+		// use it for size calculations, in order for its skin to be assigned
+
+		UINT32 dropDownBoxWidth = DROP_DOWN_BOX_WIDTH + sideBarStyle->width;
+
+		UINT32 maxNeededHeight = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
+		UINT32 numElements = (UINT32)dropDownData.entries.size();
+		for (UINT32 i = 0; i < numElements; i++)
+			maxNeededHeight += mContent->getElementHeight(i);
+
+		DropDownAreaPlacement::HorzDir horzDir;
+		DropDownAreaPlacement::VertDir vertDir;
+		Rect2I placementBounds = placement.getOptimalBounds(dropDownBoxWidth, maxNeededHeight, availableBounds, horzDir, vertDir);
+
+		mOpenedUpward = vertDir == DropDownAreaPlacement::VertDir::Up;
+
+		UINT32 actualY = placementBounds.y;
+		if (mOpenedUpward)
+			y = placementBounds.y + placementBounds.height;
+		else
+			y = placementBounds.y;
+
+		x = placementBounds.x;
+		width = placementBounds.width;
+		height = placementBounds.height;
+
+		mContentPanel->setPosition(x, actualY);
+		mBackgroundPanel->setPosition(x, actualY);
+
+		updateGUIElements();
+
+		mOwner->notifySubMenuOpened(this);
+	}
+
+	GUIDropDownMenu::DropDownSubMenu::~DropDownSubMenu()
+	{
+		closeSubMenu();
+
+		mOwner->notifySubMenuClosed(this);
+
+		GUIElement::destroy(mContent);
+
+		GUIElement::destroy(mBackgroundFrame);
+
+		GUILayout::destroy(mBackgroundPanel);
+		GUILayout::destroy(mContentPanel);
+
+		if (mSidebarPanel != nullptr)
+			GUIPanel::destroy(mSidebarPanel);
+	}
+
+	Vector<GUIDropDownMenu::DropDownSubMenu::PageInfo> GUIDropDownMenu::DropDownSubMenu::getPageInfos() const
+	{
+		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
+
+		INT32 numElements = (INT32)mData.entries.size();
+
+		PageInfo curPageInfo;
+		curPageInfo.start = 0;
+		curPageInfo.end = 0;
+		curPageInfo.idx = 0;
+		curPageInfo.height = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
+		
+		Vector<PageInfo> pageInfos;
+		for (INT32 i = 0; i < numElements; i++)
+		{
+			curPageInfo.height += mContent->getElementHeight((UINT32)i);
+			curPageInfo.end++;
+
+			if (curPageInfo.height > height)
+			{
+				// Remove last few elements until we fit again
+				while (curPageInfo.height > height && i >= 0)
+				{
+					curPageInfo.height -= mContent->getElementHeight((UINT32)i);
+					curPageInfo.end--;
+
+					i--;
+				}
+
+				// Nothing fits, break out of infinite loop
+				if (curPageInfo.start >= curPageInfo.end)
+					break;
+
+				pageInfos.push_back(curPageInfo);
+
+				curPageInfo.start = curPageInfo.end;
+				curPageInfo.height = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
+
+				curPageInfo.idx++;
+			}
+		}
+
+		if (curPageInfo.start < curPageInfo.end)
+			pageInfos.push_back(curPageInfo);
+
+		return pageInfos;
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::updateGUIElements()
+	{
+		// Remove all elements from content layout
+		while(mContentLayout->getNumChildren() > 0)
+			mContentLayout->removeElementAt(mContentLayout->getNumChildren() - 1);
+
+		mContentLayout->addElement(mContent); // Note: Needs to be added first so that size calculations have proper skin to work with
+
+		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
+		const GUIElementStyle* sideBarStyle = mOwner->getSkin().getStyle(mOwner->mSideBackgroundStyle);
+		const GUIElementStyle* scrollUpStyle = mOwner->getSkin().getStyle(mOwner->mScrollUpStyle);
+		const GUIElementStyle* scrollDownStyle = mOwner->getSkin().getStyle(mOwner->mScrollDownStyle);
+		const GUIElementStyle* handleStyle = mOwner->getSkin().getStyle(mOwner->mHandleStyle);
+
+		Vector<PageInfo> pageInfos = getPageInfos();
+
+		UINT32 pageStart = 0, pageEnd = 0;
+		UINT32 pageHeight = 0;
+		UINT32 pageCount = (UINT32)pageInfos.size();
+		if (pageCount > mPage)
+		{
+			pageStart = pageInfos[mPage].start;
+			pageEnd = pageInfos[mPage].end;
+			pageHeight = pageInfos[mPage].height;
+		}
+
+		INT32 actualY = y;
+
+		if (mOpenedUpward)
+			actualY -= (INT32)pageHeight;
+
+		// Add sidebar if needed
+		UINT32 contentOffset = 0;
+		if (pageInfos.size() > 1)
+		{
+			UINT32 sidebarHeight = pageHeight - 2;
+			contentOffset = sideBarStyle->width;
+
+			if (mSidebarPanel == nullptr)
+			{
+				mSidebarPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
+
+				mScrollUpBtn = GUIButton::create(HString(L""), mOwner->mScrollUpStyle);
+				mScrollUpBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollUp, this));
+
+				mScrollDownBtn = GUIButton::create(HString(L""), mOwner->mScrollDownStyle);
+				mScrollDownBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollDown, this));
+
+				mHandle = GUITexture::create(mOwner->mHandleStyle);
+				GUITexture* background = GUITexture::create(mOwner->mSideBackgroundStyle);
+				background->_setElementDepth(2);
+
+				mSidebarPanel->addElement(background);
+				mSidebarPanel->addElement(mScrollUpBtn);
+				mSidebarPanel->addElement(mScrollDownBtn);
+				mSidebarPanel->addElement(mHandle);
+			}
+
+			mScrollUpBtn->setPosition(1, 1);
+			mScrollDownBtn->setPosition(1, sidebarHeight - 1 - scrollDownStyle->height);
+
+			UINT32 maxHandleSize = std::max(0, (INT32)sidebarHeight - (INT32)scrollDownStyle->height - (INT32)scrollUpStyle->height - 2);
+			UINT32 handleSize = maxHandleSize / pageCount;
+
+			INT32 handlePos = 1 + scrollUpStyle->height + mPage * handleSize;
+
+			mHandle->setPosition(1, handlePos);
+			mHandle->setHeight(handleSize);
+
+			mSidebarPanel->setPosition(x, actualY);
+			mSidebarPanel->setWidth(sideBarStyle->width);
+			mSidebarPanel->setHeight(sidebarHeight);
+		}
+		else
+		{
+			if (mSidebarPanel != nullptr)
+			{
+				GUIPanel::destroy(mSidebarPanel);
+				mSidebarPanel = nullptr;
+			}
+		}
+
+		mContent->setRange(pageStart, pageEnd);
+
+		if (mSubMenu == nullptr)
+			mContent->setKeyboardFocus(true);
+
+		// Resize and reposition areas
+		mBackgroundPanel->setWidth(width - contentOffset);
+		mBackgroundPanel->setHeight(pageHeight);
+		mBackgroundPanel->setPosition(x + contentOffset, actualY);
+
+		mVisibleBounds = Rect2I(x, actualY, width, pageHeight);
+
+		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)backgroundStyle->margins.left - (INT32)backgroundStyle->margins.right - (INT32)contentOffset);
+		UINT32 contentHeight = (UINT32)std::max(0, (INT32)pageHeight - (INT32)backgroundStyle->margins.top - (INT32)backgroundStyle->margins.bottom);
+
+		mContentPanel->setWidth(contentWidth);
+		mContentPanel->setHeight(contentHeight);
+		mContentPanel->setPosition(x + contentOffset + backgroundStyle->margins.left, actualY + backgroundStyle->margins.top);
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::scrollDown()
+	{
+		mPage++;
+		if (mPage == (UINT32)getPageInfos().size())
+			mPage = 0;
+
+		updateGUIElements();
+
+		closeSubMenu();
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::scrollUp()
+	{
+		if (mPage > 0)
+			mPage--;
+		else
+			mPage = (UINT32)getPageInfos().size() - 1;
+
+		updateGUIElements();
+		closeSubMenu();
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::scrollToTop()
+	{
+		mPage = 0;
+		updateGUIElements();
+
+		closeSubMenu();
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::scrollToBottom()
+	{
+		mPage = (UINT32)(getPageInfos().size() - 1);
+		updateGUIElements();
+
+		closeSubMenu();
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::closeSubMenu()
+	{
+		if(mSubMenu != nullptr)
+		{
+			bs_delete(mSubMenu);
+			mSubMenu = nullptr;
+
+			mContent->setKeyboardFocus(true);
+		}
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::elementActivated(UINT32 idx, const Rect2I& bounds)
+	{
+		closeSubMenu();
+
+		if (!mData.entries[idx].isSubMenu())
+		{
+			auto callback = mData.entries[idx].getCallback();
+			if (callback != nullptr)
+				callback();
+
+			if (mType != GUIDropDownType::MultiListBox)
+				GUIDropDownBoxManager::instance().closeDropDownBox();
+		}
+		else
+		{
+			mContent->setKeyboardFocus(false);
+
+			mSubMenu = bs_new<DropDownSubMenu>(mOwner, this, DropDownAreaPlacement::aroundBoundsVert(bounds),
+				mAvailableBounds, mData.entries[idx].getSubMenuData(), mType, mDepthOffset + 1);
+		}
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::close()
+	{
+		if (mParent != nullptr)
+			mParent->closeSubMenu();
+		else // We're the last sub-menu, close the whole thing
+			GUIDropDownBoxManager::instance().closeDropDownBox();
+	}
+
+	void GUIDropDownMenu::DropDownSubMenu::elementSelected(UINT32 idx)
+	{
+		closeSubMenu();
+	}
 }

+ 2 - 6
BansheeEngine/Source/BsGUIElement.cpp

@@ -1,11 +1,7 @@
 #include "BsGUIElement.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUISkin.h"
-#include "BsGUILayout.h"
 #include "BsGUIManager.h"
-#include "BsException.h"
-#include "BsGUILayoutUtility.h"
-#include "BsDebug.h"
 
 namespace BansheeEngine
 {
@@ -100,7 +96,7 @@ namespace BansheeEngine
 		updateClippedBounds();
 	}
 
-	void GUIElement::_changeParentWidget(CGUIWidget* widget)
+	void GUIElement::_changeParentWidget(GUIWidget* widget)
 	{
 		if (_isDestroyed())
 			return;

+ 2 - 6
BansheeEngine/Source/BsGUIElementBase.cpp

@@ -1,14 +1,10 @@
 #include "BsGUIElementBase.h"
 #include "BsGUILayout.h"
-#include "BsGUILayoutX.h"
-#include "BsGUILayoutY.h"
 #include "BsGUIPanel.h"
 #include "BsGUISpace.h"
 #include "BsGUIElement.h"
 #include "BsException.h"
-#include "BsCGUIWidget.h"
-#include "BsGUILayoutUtility.h"
-#include "BsProfilerCPU.h"
+#include "BsGUIWidget.h"
 
 namespace BansheeEngine
 {
@@ -480,7 +476,7 @@ namespace BansheeEngine
 			BS_EXCEPT(InvalidParametersException, "Provided element is not a part of this element.");
 	}
 
-	void GUIElementBase::_changeParentWidget(CGUIWidget* widget)
+	void GUIElementBase::_changeParentWidget(GUIWidget* widget)
 	{
 		assert(!_isDestroyed());
 

+ 0 - 6
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -1,7 +1,6 @@
 #include "BsGUIInputBox.h"
 #include "BsGUIManager.h"
 #include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsTextSprite.h"
@@ -9,13 +8,8 @@
 #include "BsGUITextInputEvent.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUICommandEvent.h"
-#include "BsFont.h"
-#include "BsTextData.h"
-#include "BsTexture.h"
-#include "BsPlatform.h"
 #include "BsGUIInputCaret.h"
 #include "BsGUIInputSelection.h"
-#include "BsDragAndDropManager.h"
 #include "BsGUIContextMenu.h"
 #include "BsGUIHelper.h"
 

+ 1 - 1
BansheeEngine/Source/BsGUIInputCaret.cpp

@@ -54,7 +54,7 @@ namespace BansheeEngine
 		mCaretDesc.height = getCaretHeight();
 		mCaretDesc.texture = GUIManager::instance().getCaretTexture().getInternalPtr();
 
-		CGUIWidget* widget = nullptr;
+		GUIWidget* widget = nullptr;
 		if (mElement != nullptr)
 			widget = mElement->_getParentWidget();
 

+ 1 - 1
BansheeEngine/Source/BsGUIInputSelection.cpp

@@ -38,7 +38,7 @@ namespace BansheeEngine
 			}
 		}
 
-		const CGUIWidget* widget = nullptr;
+		const GUIWidget* widget = nullptr;
 		if (mElement != nullptr)
 			widget = mElement->_getParentWidget();
 

+ 0 - 3
BansheeEngine/Source/BsGUILabel.cpp

@@ -1,11 +1,8 @@
 #include "BsGUILabel.h"
 #include "BsGUIElementStyle.h"
 #include "BsTextSprite.h"
-#include "BsGUISkin.h"
-#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIHelper.h"
-#include "BsTextData.h"
 
 namespace BansheeEngine
 {

+ 88 - 94
BansheeEngine/Source/BsGUILayoutUtility.cpp

@@ -1,95 +1,89 @@
-#include "BsGUILayoutUtility.h"
-#include "BsGUIElementBase.h"
-#include "BsGUILayout.h"
-#include "BsGUIElement.h"
-#include "BsGUIElementStyle.h"
-#include "BsCGUIWidget.h"
-#include "BsViewport.h"
-#include "BsGUIPanel.h"
-#include "BsProfilerCPU.h"
-
-namespace BansheeEngine
-{
-	Vector2I GUILayoutUtility::calcOptimalSize(const GUIElementBase* elem)
-	{
-		return elem->_calculateLayoutSizeRange().optimal;
-	}
-
-	Vector2I GUILayoutUtility::calcActualSize(UINT32 width, UINT32 height, GUILayout* layout, bool updateOptimalSizes)
-	{
-		if (updateOptimalSizes)
-			layout->_updateOptimalLayoutSizes();
-
-		return calcActualSizeInternal(width, height, layout);
-	}
-
-	Vector2I GUILayoutUtility::calcActualSizeInternal(UINT32 width, UINT32 height, GUILayout* layout)
-	{
-		UINT32 numElements = (UINT32)layout->_getNumChildren();
-		Rect2I* elementAreas = nullptr;
-
-		if (numElements > 0)
-			elementAreas = bs_stack_new<Rect2I>(numElements);
-
-		Rect2I parentArea;
-		parentArea.width = width;
-		parentArea.height = height;
-
-		layout->_getElementAreas(parentArea, elementAreas, numElements, layout->_getCachedChildSizeRanges(), layout->_getCachedSizeRange());
-
-		Rect2I* actualAreas = elementAreas; // We re-use the same array
-		for (UINT32 i = 0; i < numElements; i++)
-		{
-			GUIElementBase* child = layout->_getChild(i);
-			Rect2I childArea = elementAreas[i];
-
-			if (child->_getType() == GUIElementBase::Type::Layout || child->_getType() == GUIElementBase::Type::Panel)
-			{
-				Vector2I childActualSize = calcActualSizeInternal(childArea.width, childArea.height, static_cast<GUILayout*>(child));
-				actualAreas[i].width = (UINT32)childActualSize.x;
-				actualAreas[i].height = (UINT32)childActualSize.y;
-			}
-			else if (child->_getType() == GUIElementBase::Type::Element)
-			{
-				RectOffset padding = child->_getPadding();
-
-				actualAreas[i].width = elementAreas[i].width + padding.left + padding.right;
-				actualAreas[i].height = elementAreas[i].height + padding.top + padding.bottom;
-			}
-			else
-			{
-				actualAreas[i].width = elementAreas[i].width;
-				actualAreas[i].height = elementAreas[i].height;
-			}
-		}
-
-		Vector2I min;
-		Vector2I max;
-
-		if (numElements > 0)
-		{
-			Rect2I childArea = actualAreas[0];
-
-			min = Vector2I(childArea.x, childArea.y);
-			max = Vector2I(childArea.x + childArea.width, childArea.y + childArea.height);
-		}
-
-		for (UINT32 i = 1; i < numElements; i++)
-		{
-			Rect2I childArea = actualAreas[i];
-
-			min.x = std::min(min.x, childArea.x);
-			min.y = std::min(min.y, childArea.y);
-
-			max.x = std::max(max.x, childArea.x + childArea.width);
-			max.y = std::max(max.y, childArea.y + childArea.height);
-		}
-
-		Vector2I actualSize = max - min;
-
-		if (elementAreas != nullptr)
-			bs_stack_free(elementAreas);
-
-		return actualSize;
-	}
+#include "BsGUILayoutUtility.h"
+#include "BsGUIElementBase.h"
+#include "BsGUILayout.h"
+
+namespace BansheeEngine
+{
+	Vector2I GUILayoutUtility::calcOptimalSize(const GUIElementBase* elem)
+	{
+		return elem->_calculateLayoutSizeRange().optimal;
+	}
+
+	Vector2I GUILayoutUtility::calcActualSize(UINT32 width, UINT32 height, GUILayout* layout, bool updateOptimalSizes)
+	{
+		if (updateOptimalSizes)
+			layout->_updateOptimalLayoutSizes();
+
+		return calcActualSizeInternal(width, height, layout);
+	}
+
+	Vector2I GUILayoutUtility::calcActualSizeInternal(UINT32 width, UINT32 height, GUILayout* layout)
+	{
+		UINT32 numElements = (UINT32)layout->_getNumChildren();
+		Rect2I* elementAreas = nullptr;
+
+		if (numElements > 0)
+			elementAreas = bs_stack_new<Rect2I>(numElements);
+
+		Rect2I parentArea;
+		parentArea.width = width;
+		parentArea.height = height;
+
+		layout->_getElementAreas(parentArea, elementAreas, numElements, layout->_getCachedChildSizeRanges(), layout->_getCachedSizeRange());
+
+		Rect2I* actualAreas = elementAreas; // We re-use the same array
+		for (UINT32 i = 0; i < numElements; i++)
+		{
+			GUIElementBase* child = layout->_getChild(i);
+			Rect2I childArea = elementAreas[i];
+
+			if (child->_getType() == GUIElementBase::Type::Layout || child->_getType() == GUIElementBase::Type::Panel)
+			{
+				Vector2I childActualSize = calcActualSizeInternal(childArea.width, childArea.height, static_cast<GUILayout*>(child));
+				actualAreas[i].width = (UINT32)childActualSize.x;
+				actualAreas[i].height = (UINT32)childActualSize.y;
+			}
+			else if (child->_getType() == GUIElementBase::Type::Element)
+			{
+				RectOffset padding = child->_getPadding();
+
+				actualAreas[i].width = elementAreas[i].width + padding.left + padding.right;
+				actualAreas[i].height = elementAreas[i].height + padding.top + padding.bottom;
+			}
+			else
+			{
+				actualAreas[i].width = elementAreas[i].width;
+				actualAreas[i].height = elementAreas[i].height;
+			}
+		}
+
+		Vector2I min;
+		Vector2I max;
+
+		if (numElements > 0)
+		{
+			Rect2I childArea = actualAreas[0];
+
+			min = Vector2I(childArea.x, childArea.y);
+			max = Vector2I(childArea.x + childArea.width, childArea.y + childArea.height);
+		}
+
+		for (UINT32 i = 1; i < numElements; i++)
+		{
+			Rect2I childArea = actualAreas[i];
+
+			min.x = std::min(min.x, childArea.x);
+			min.y = std::min(min.y, childArea.y);
+
+			max.x = std::max(max.x, childArea.x + childArea.width);
+			max.y = std::max(max.y, childArea.y + childArea.height);
+		}
+
+		Vector2I actualSize = max - min;
+
+		if (elementAreas != nullptr)
+			bs_stack_free(elementAreas);
+
+		return actualSize;
+	}
 }

+ 2 - 8
BansheeEngine/Source/BsGUIListBox.cpp

@@ -1,15 +1,9 @@
 #include "BsGUIListBox.h"
-#include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
-#include "BsTextSprite.h"
+#include "BsGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIManager.h"
-#include "BsGUIHelper.h"
 #include "BsGUIDropDownBoxManager.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {
@@ -196,7 +190,7 @@ namespace BansheeEngine
 			i++;
 		}
 
-		CGUIWidget* widget = _getParentWidget();
+		GUIWidget* widget = _getParentWidget();
 
 		desc.camera = widget->getCamera();
 		desc.skin = widget->getSkinResource();

+ 23 - 22
BansheeEngine/Source/BsGUIManager.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIManager.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUIElement.h"
 #include "BsSpriteTexture.h"
 #include "BsTime.h"
@@ -126,7 +126,7 @@ namespace BansheeEngine
 		// we can't iterate over an array thats getting modified
 		Vector<WidgetInfo> widgetCopy = mWidgets;
 		for(auto& widget : widgetCopy)
-			widget.widget->destroy();
+			widget.widget->_destroy();
 
 		// Ensure everything queued get destroyed, loop until queue empties
 		while (processDestroyQueue())
@@ -160,12 +160,13 @@ namespace BansheeEngine
 		bs_delete(core);
 	}
 
-	void GUIManager::registerWidget(CGUIWidget* widget)
+	void GUIManager::registerWidget(GUIWidget* widget)
 	{
-		mWidgets.push_back(WidgetInfo(widget));
-
 		const Viewport* renderTarget = widget->getTarget();
+		if (renderTarget == nullptr)
+			return;
 
+		mWidgets.push_back(WidgetInfo(widget));
 		auto findIter = mCachedGUIData.find(renderTarget);
 
 		if(findIter == end(mCachedGUIData))
@@ -176,7 +177,7 @@ namespace BansheeEngine
 		windowData.isDirty = true;
 	}
 
-	void GUIManager::unregisterWidget(CGUIWidget* widget)
+	void GUIManager::unregisterWidget(GUIWidget* widget)
 	{
 		{
 			auto findIter = std::find_if(begin(mWidgets), end(mWidgets), [=] (const WidgetInfo& x) { return x.widget == widget; } );
@@ -244,7 +245,7 @@ namespace BansheeEngine
 				for(auto& entry : mElementsUnderPointer)
 				{
 					const WString& tooltipText = entry.element->_getTooltip();
-					CGUIWidget* parentWidget = entry.element->_getParentWidget();
+					GUIWidget* parentWidget = entry.element->_getParentWidget();
 
 					if (!tooltipText.empty() && parentWidget != nullptr)
 					{
@@ -388,7 +389,7 @@ namespace BansheeEngine
 				for (auto& mesh : renderData.cachedMeshes)
 				{
 					SpriteMaterialInfo materialInfo = renderData.cachedMaterials[meshIdx];
-					CGUIWidget* widget = renderData.cachedWidgetsPerMesh[meshIdx];
+					GUIWidget* widget = renderData.cachedWidgetsPerMesh[meshIdx];
 
 					if (materialInfo.texture == nullptr || !materialInfo.texture.isLoaded())
 					{
@@ -409,7 +410,7 @@ namespace BansheeEngine
 					newEntry.texture = materialInfo.texture->getCore();
 					newEntry.tint = materialInfo.tint;
 					newEntry.mesh = mesh->getCore();
-					newEntry.worldTransform = widget->SO()->getWorldTfrm();
+					newEntry.worldTransform = widget->getWorldTfrm();
 
 					meshIdx++;
 				}
@@ -489,7 +490,7 @@ namespace BansheeEngine
 					UINT32 elemDepth = guiElem->_getRenderElementDepth(renderElemIdx);
 
 					Rect2I tfrmedBounds = guiElem->_getClippedBounds();
-					tfrmedBounds.transform(guiElem->_getParentWidget()->SO()->getWorldTfrm());
+					tfrmedBounds.transform(guiElem->_getParentWidget()->getWorldTfrm());
 
 					const SpriteMaterialInfo& matInfo = guiElem->_getMaterial(renderElemIdx);
 					FrameVector<GUIMaterialGroup>& groupsPerMaterial = materialGroups[std::cref(matInfo)];
@@ -1240,7 +1241,7 @@ namespace BansheeEngine
 					continue;
 				}
 
-				CGUIWidget* widget = widgetInfo.widget;
+				GUIWidget* widget = widgetInfo.widget;
 				if(widgetWindows[widgetIdx] == windowUnderPointer && widget->inBounds(windowToBridgedCoords(*widget, windowPos)))
 				{
 					const Vector<GUIElement*>& elements = widget->getElements();
@@ -1285,7 +1286,7 @@ namespace BansheeEngine
 		for (auto& elementInfo : mNewElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			CGUIWidget* widget = elementInfo.widget;
+			GUIWidget* widget = elementInfo.widget;
 
 			if (elementInfo.receivedMouseOver)
 			{
@@ -1344,7 +1345,7 @@ namespace BansheeEngine
 		for(auto& elementInfo : mElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			CGUIWidget* widget = elementInfo.widget;
+			GUIWidget* widget = elementInfo.widget;
 
 			auto iterFind = std::find_if(mNewElementsUnderPointer.begin(), mNewElementsUnderPointer.end(),
 				[=](const ElementInfoUnderPointer& x) { return x.element == element; });
@@ -1400,7 +1401,7 @@ namespace BansheeEngine
 	{
 		for(auto& widgetInfo : mWidgets)
 		{
-			CGUIWidget* widget = widgetInfo.widget;
+			GUIWidget* widget = widgetInfo.widget;
 			if(getWidgetWindow(*widget) == &win)
 				widget->ownerWindowFocusChanged();
 		}
@@ -1410,7 +1411,7 @@ namespace BansheeEngine
 	{
 		for(auto& widgetInfo : mWidgets)
 		{
-			CGUIWidget* widget = widgetInfo.widget;
+			GUIWidget* widget = widgetInfo.widget;
 			if(getWidgetWindow(*widget) == &win)
 				widget->ownerWindowFocusChanged();
 		}
@@ -1449,7 +1450,7 @@ namespace BansheeEngine
 		for(auto& elementInfo : mElementsUnderPointer)
 		{
 			GUIElement* element = elementInfo.element;
-			CGUIWidget* widget = elementInfo.widget;
+			GUIWidget* widget = elementInfo.widget;
 
 			if (widget != nullptr && widget->getTarget()->getTarget().get() != &win)
 			{
@@ -1537,7 +1538,7 @@ namespace BansheeEngine
 		BS_EXCEPT(InvalidParametersException, "Provided button is not a GUI supported mouse button.");
 	}
 
-	Vector2I GUIManager::getWidgetRelativePos(const CGUIWidget* widget, const Vector2I& screenPos) const
+	Vector2I GUIManager::getWidgetRelativePos(const GUIWidget* widget, const Vector2I& screenPos) const
 	{
 		if (widget == nullptr)
 			return screenPos;
@@ -1549,7 +1550,7 @@ namespace BansheeEngine
 		Vector2I windowPos = window->screenToWindowPos(screenPos);
 		windowPos = windowToBridgedCoords(*widget, windowPos);
 
-		const Matrix4& worldTfrm = widget->SO()->getWorldTfrm();
+		const Matrix4& worldTfrm = widget->getWorldTfrm();
 
 		Vector4 vecLocalPos = worldTfrm.inverse().multiplyAffine(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
 		Vector2I curLocalPos(Math::roundToInt(vecLocalPos.x), Math::roundToInt(vecLocalPos.y));
@@ -1557,7 +1558,7 @@ namespace BansheeEngine
 		return curLocalPos;
 	}
 
-	Vector2I GUIManager::windowToBridgedCoords(const CGUIWidget& widget, const Vector2I& windowPos) const
+	Vector2I GUIManager::windowToBridgedCoords(const GUIWidget& widget, const Vector2I& windowPos) const
 	{
 		// This cast might not be valid (the render target could be a window), but we only really need to cast
 		// so that mInputBridge map allows us to search through it - we don't access anything unless the target is bridged
@@ -1570,7 +1571,7 @@ namespace BansheeEngine
 		{
 			const GUIElement* bridgeElement = iterFind->second;
 
-			const Matrix4& worldTfrm = bridgeElement->_getParentWidget()->SO()->getWorldTfrm();
+			const Matrix4& worldTfrm = bridgeElement->_getParentWidget()->getWorldTfrm();
 
 			Vector4 vecLocalPos = worldTfrm.inverse().multiplyAffine(Vector4((float)windowPos.x, (float)windowPos.y, 0.0f, 1.0f));
 			Rect2I bridgeBounds = bridgeElement->_getLayoutData().area;
@@ -1588,7 +1589,7 @@ namespace BansheeEngine
 		return windowPos;
 	}
 
-	const RenderWindow* GUIManager::getWidgetWindow(const CGUIWidget& widget) const
+	const RenderWindow* GUIManager::getWidgetWindow(const GUIWidget& widget) const
 	{
 		// This cast might not be valid (the render target could be a window), but we only really need to cast
 		// so that mInputBridge map allows us to search through it - we don't access anything unless the target is bridged
@@ -1598,7 +1599,7 @@ namespace BansheeEngine
 		auto iterFind = mInputBridge.find(renderTexture);
 		if(iterFind != mInputBridge.end())
 		{
-			CGUIWidget* parentWidget = iterFind->second->_getParentWidget();
+			GUIWidget* parentWidget = iterFind->second->_getParentWidget();
 			if(parentWidget != &widget)
 			{
 				return getWidgetWindow(*parentWidget);

+ 98 - 99
BansheeEngine/Source/BsGUIProgressBar.cpp

@@ -1,100 +1,99 @@
-#include "BsGUIProgressBar.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsGUITexture.h"
-#include "BsSpriteTexture.h"
-#include "BsGUIDimensions.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	GUIProgressBar::GUIProgressBar(const String& styleName, const GUIDimensions& dimensions)
-		:GUIElementContainer(dimensions, styleName), mPercent(0)
-	{
-		mBar = GUITexture::create(getSubStyleName(getBarStyleType()));
-		mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType()));
-
-		mBackground->_setElementDepth(mBar->_getRenderElementDepthRange());
-
-		_registerChildElement(mBar);
-		_registerChildElement(mBackground);
-	}
-
-	const String& GUIProgressBar::getBarStyleType()
-	{
-		static String HANDLE_STYLE_TYPE = "ProgressBarFill";
-		return HANDLE_STYLE_TYPE;
-	}
-
-	const String& GUIProgressBar::getBackgroundStyleType()
-	{
-		static String BACKGROUND_STYLE_TYPE = "ProgressBarBackground";
-		return BACKGROUND_STYLE_TYPE;
-	}
-
-	Vector2I GUIProgressBar::_getOptimalSize() const
-	{
-		Vector2I optimalSize = mBar->_getOptimalSize();
-
-		Vector2I backgroundSize = mBackground->_getOptimalSize();
-		optimalSize.x = std::max(optimalSize.x, backgroundSize.x);
-		optimalSize.y = std::max(optimalSize.y, backgroundSize.y);
-
-		return optimalSize;
-	}
-
-	void GUIProgressBar::_updateLayoutInternal(const GUILayoutData& data)
-	{
-		mBackground->_setLayoutData(data);
-
-		const GUIElementStyle* style = _getStyle();
-		
-		GUILayoutData barLayoutData = data;
-
-		barLayoutData.area.x += style->margins.left;
-		barLayoutData.area.y += style->margins.top;
-
-		UINT32 maxProgressBarWidth = std::max((UINT32)0, (UINT32)(data.area.width - style->margins.left - style->margins.right));
-		UINT32 progressBarHeight = std::max((UINT32)0, (UINT32)(data.area.height - style->margins.top - style->margins.bottom));
-
-		barLayoutData.area.width = (UINT32)Math::floorToInt(maxProgressBarWidth * mPercent);
-		barLayoutData.area.height = progressBarHeight;
-
-		mBar->_setLayoutData(barLayoutData);
-	}
-
-	void GUIProgressBar::styleUpdated()
-	{
-		mBar->setStyle(getSubStyleName(getBarStyleType()));
-		mBackground->setStyle(getSubStyleName(getBackgroundStyleType()));
-	}
-
-	void GUIProgressBar::setPercent(float pct)
-	{
-		mPercent = pct;
-		_markLayoutAsDirty();
-	}
-
-	void GUIProgressBar::setTint(const Color& color)
-	{
-		mBar->setTint(color);
-		mBackground->setTint(color);
-	}
-
-	GUIProgressBar* GUIProgressBar::create(const String& styleName)
-	{
-		return new (bs_alloc<GUIProgressBar>()) GUIProgressBar(getStyleName<GUIProgressBar>(styleName), GUIDimensions::create());
-	}
-
-	GUIProgressBar* GUIProgressBar::create(const GUIOptions& options, const String& styleName)
-	{
-		return new (bs_alloc<GUIProgressBar>()) GUIProgressBar(getStyleName<GUIProgressBar>(styleName), GUIDimensions::create(options));
-	}
-
-	const String& GUIProgressBar::getGUITypeName()
-	{
-		static String typeName = "ProgressBar";
-		return typeName;
-	}
+#include "BsGUIProgressBar.h"
+#include "BsGUIWidget.h"
+#include "BsGUISkin.h"
+#include "BsGUITexture.h"
+#include "BsGUIDimensions.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	GUIProgressBar::GUIProgressBar(const String& styleName, const GUIDimensions& dimensions)
+		:GUIElementContainer(dimensions, styleName), mPercent(0)
+	{
+		mBar = GUITexture::create(getSubStyleName(getBarStyleType()));
+		mBackground = GUITexture::create(getSubStyleName(getBackgroundStyleType()));
+
+		mBackground->_setElementDepth(mBar->_getRenderElementDepthRange());
+
+		_registerChildElement(mBar);
+		_registerChildElement(mBackground);
+	}
+
+	const String& GUIProgressBar::getBarStyleType()
+	{
+		static String HANDLE_STYLE_TYPE = "ProgressBarFill";
+		return HANDLE_STYLE_TYPE;
+	}
+
+	const String& GUIProgressBar::getBackgroundStyleType()
+	{
+		static String BACKGROUND_STYLE_TYPE = "ProgressBarBackground";
+		return BACKGROUND_STYLE_TYPE;
+	}
+
+	Vector2I GUIProgressBar::_getOptimalSize() const
+	{
+		Vector2I optimalSize = mBar->_getOptimalSize();
+
+		Vector2I backgroundSize = mBackground->_getOptimalSize();
+		optimalSize.x = std::max(optimalSize.x, backgroundSize.x);
+		optimalSize.y = std::max(optimalSize.y, backgroundSize.y);
+
+		return optimalSize;
+	}
+
+	void GUIProgressBar::_updateLayoutInternal(const GUILayoutData& data)
+	{
+		mBackground->_setLayoutData(data);
+
+		const GUIElementStyle* style = _getStyle();
+		
+		GUILayoutData barLayoutData = data;
+
+		barLayoutData.area.x += style->margins.left;
+		barLayoutData.area.y += style->margins.top;
+
+		UINT32 maxProgressBarWidth = std::max((UINT32)0, (UINT32)(data.area.width - style->margins.left - style->margins.right));
+		UINT32 progressBarHeight = std::max((UINT32)0, (UINT32)(data.area.height - style->margins.top - style->margins.bottom));
+
+		barLayoutData.area.width = (UINT32)Math::floorToInt(maxProgressBarWidth * mPercent);
+		barLayoutData.area.height = progressBarHeight;
+
+		mBar->_setLayoutData(barLayoutData);
+	}
+
+	void GUIProgressBar::styleUpdated()
+	{
+		mBar->setStyle(getSubStyleName(getBarStyleType()));
+		mBackground->setStyle(getSubStyleName(getBackgroundStyleType()));
+	}
+
+	void GUIProgressBar::setPercent(float pct)
+	{
+		mPercent = pct;
+		_markLayoutAsDirty();
+	}
+
+	void GUIProgressBar::setTint(const Color& color)
+	{
+		mBar->setTint(color);
+		mBackground->setTint(color);
+	}
+
+	GUIProgressBar* GUIProgressBar::create(const String& styleName)
+	{
+		return new (bs_alloc<GUIProgressBar>()) GUIProgressBar(getStyleName<GUIProgressBar>(styleName), GUIDimensions::create());
+	}
+
+	GUIProgressBar* GUIProgressBar::create(const GUIOptions& options, const String& styleName)
+	{
+		return new (bs_alloc<GUIProgressBar>()) GUIProgressBar(getStyleName<GUIProgressBar>(styleName), GUIDimensions::create(options));
+	}
+
+	const String& GUIProgressBar::getGUITypeName()
+	{
+		static String typeName = "ProgressBar";
+		return typeName;
+	}
 }

+ 0 - 2
BansheeEngine/Source/BsGUIRenderTexture.cpp

@@ -1,6 +1,4 @@
 #include "BsGUIRenderTexture.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 #include "BsGUIManager.h"
 #include "BsRenderTexture.h"
 #include "BsSpriteTexture.h"

+ 0 - 6
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -1,17 +1,11 @@
 #include "BsGUIScrollArea.h"
 #include "BsGUIElementStyle.h"
-#include "BsGUISkin.h"
-#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUILayoutY.h"
-#include "BsGUISkin.h"
 #include "BsGUIScrollBarVert.h"
 #include "BsGUIScrollBarHorz.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUILayoutUtility.h"
-#include "BsGUISpace.h"
-#include "BsException.h"
-#include "BsProfilerCPU.h"
 
 using namespace std::placeholders;
 

+ 0 - 4
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -1,16 +1,12 @@
 #include "BsGUIScrollBar.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIElementStyle.h"
-#include "BsGUISkin.h"
-#include "BsCGUIWidget.h"
 #include "BsGUIDimensions.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
-#include "BsGUISkin.h"
 #include "BsGUIButton.h"
 #include "BsGUISliderHandle.h"
 #include "BsGUISpace.h"
-#include "BsException.h"
 
 using namespace std::placeholders;
 

+ 0 - 3
BansheeEngine/Source/BsGUISlider.cpp

@@ -1,9 +1,6 @@
 #include "BsGUISlider.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
 #include "BsGUISliderHandle.h"
 #include "BsGUITexture.h"
-#include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
 
 using namespace std::placeholders;

+ 0 - 4
BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -1,13 +1,9 @@
 #include "BsGUISliderHandle.h"
 #include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
-#include "BsTextSprite.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
-#include "BsDebug.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {

+ 0 - 2
BansheeEngine/Source/BsGUITexture.cpp

@@ -1,10 +1,8 @@
 #include "BsGUITexture.h"
 #include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {

+ 0 - 7
BansheeEngine/Source/BsGUIToggle.cpp

@@ -1,14 +1,7 @@
 #include "BsGUIToggle.h"
-#include "BsImageSprite.h"
-#include "BsCGUIWidget.h"
-#include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
-#include "BsTextSprite.h"
 #include "BsGUIDimensions.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIToggleGroup.h"
-#include "BsGUIHelper.h"
-#include "BsTexture.h"
 
 namespace BansheeEngine
 {

+ 1 - 2
BansheeEngine/Source/BsGUITooltip.cpp

@@ -1,5 +1,4 @@
 #include "BsGUITooltip.h"
-#include "BsCGUIWidget.h"
 #include "BsGUIPanel.h"
 #include "BsCamera.h"
 #include "BsViewport.h"
@@ -24,7 +23,7 @@ namespace BansheeEngine
 		return "TooltipFrame";
 	}
 
-	GUITooltip::GUITooltip(const HSceneObject& parent, const CGUIWidget& overlaidWidget, const Vector2I& position, const WString& text)
+	GUITooltip::GUITooltip(const HSceneObject& parent, const GUIWidget& overlaidWidget, const Vector2I& position, const WString& text)
 		:CGUIWidget(parent, overlaidWidget.getCamera())
 	{
 		setDepth(0); // Needs to be in front of everything

+ 1 - 1
BansheeEngine/Source/BsGUITooltipManager.cpp

@@ -9,7 +9,7 @@ namespace BansheeEngine
 		hide();
 	}
 
-	void GUITooltipManager::show(const CGUIWidget& widget, const Vector2I& position, const WString& text)
+	void GUITooltipManager::show(const GUIWidget& widget, const Vector2I& position, const WString& text)
 	{
 		hide();
 

+ 2 - 3
BansheeEngine/Source/BsGUIViewport.cpp

@@ -1,7 +1,6 @@
 #include "BsGUIViewport.h"
-#include "BsCGUIWidget.h"
+#include "BsGUIWidget.h"
 #include "BsGUISkin.h"
-#include "BsSpriteTexture.h"
 #include "BsGUIDimensions.h"
 #include "BsCCamera.h"
 #include "BsViewport.h"
@@ -92,7 +91,7 @@ namespace BansheeEngine
 		viewport->setArea(x, y, width, height);
 	}
 
-	void GUIViewport::_changeParentWidget(CGUIWidget* widget)
+	void GUIViewport::_changeParentWidget(GUIWidget* widget)
 	{
 		GUIElement::_changeParentWidget(widget);
 

+ 387 - 0
BansheeEngine/Source/BsGUIWidget.cpp

@@ -0,0 +1,387 @@
+#include "BsGUIWidget.h"
+#include "BsGUIManager.h"
+#include "BsGUISkin.h"
+#include "BsGUILabel.h"
+#include "BsGUIPanel.h"
+#include "BsCoreThreadAccessor.h"
+#include "BsVector2I.h"
+#include "BsCCamera.h"
+#include "BsViewport.h"
+#include "BsSceneObject.h"
+#include "BsBuiltinResources.h"
+
+namespace BansheeEngine
+{
+	GUIWidget::GUIWidget(const CameraPtr& camera)
+		:mWidgetIsDirty(false), mCamera(camera), mDepth(0), mPanel(nullptr), mIsActive(true)
+	{
+		construct(camera);
+	}
+
+	GUIWidget::GUIWidget(const HCamera& camera)
+		:mWidgetIsDirty(false), mCamera(camera->_getCamera()), mDepth(0), mPanel(nullptr), mIsActive(true)
+	{
+		construct(mCamera);
+	}
+
+	void GUIWidget::construct(const CameraPtr& camera)
+	{
+		if(mCamera != nullptr)
+			mOwnerTargetResizedConn = mCamera->getViewport()->getTarget()->onResized.connect(std::bind(&GUIWidget::ownerTargetResized, this));
+
+		GUIManager::instance().registerWidget(this);
+
+		mPanel = GUIPanel::create();
+		mPanel->_changeParentWidget(this);
+		updateRootPanel();
+	}
+
+	GUIWidget::~GUIWidget()
+	{
+		_destroy();
+	}
+
+	SPtr<GUIWidget> GUIWidget::create(const CameraPtr& camera)
+	{
+		return bs_shared_ptr(new (bs_alloc<GUIWidget>()) GUIWidget(camera));
+	}
+
+	SPtr<GUIWidget> GUIWidget::create(const HCamera& camera)
+	{
+		return bs_shared_ptr(new (bs_alloc<GUIWidget>()) GUIWidget(camera));
+	}
+
+	void GUIWidget::_destroy()
+	{
+		if (mPanel != nullptr)
+		{
+			GUILayout::destroy(mPanel);
+			mPanel = nullptr;
+		}
+
+		if (mCamera != nullptr)
+		{
+			GUIManager::instance().unregisterWidget(this);
+			mOwnerTargetResizedConn.disconnect();
+
+			mCamera = nullptr;
+		}
+
+		mElements.clear();
+		mDirtyContents.clear();
+	}
+
+	void GUIWidget::setDepth(UINT8 depth)
+	{
+		mDepth = depth; 
+		mWidgetIsDirty = true;
+
+		updateRootPanel();
+	}
+
+	Viewport* GUIWidget::getTarget() const
+	{
+		if(mCamera != nullptr)
+			return mCamera->getViewport().get();
+
+		return nullptr;
+	}
+
+	void GUIWidget::_updateTransform(const HSceneObject& parent)
+	{
+		// If the widgets parent scene object moved, we need to mark it as dirty
+		// as the GUIManager batching relies on object positions, so it needs to be updated.
+		const float diffEpsilon = 0.0001f;
+
+		Vector3 position = parent->getWorldPosition();
+		Quaternion rotation = parent->getWorldRotation();
+		Vector3 scale = parent->getWorldScale();
+
+		if(!mWidgetIsDirty)
+		{
+			Vector3 posDiff = mPosition - position;
+			if(!Math::approxEquals(mPosition, position, diffEpsilon))
+			{
+				mWidgetIsDirty = true;
+			}
+			else
+			{
+				Quaternion rotDiff = mRotation - rotation;
+				if(!Math::approxEquals(mRotation, rotation, diffEpsilon))
+				{
+					mWidgetIsDirty = true;
+				}
+				else
+				{
+					Vector3 scaleDiff = mScale - scale;
+					if(Math::approxEquals(mScale, scale))
+					{
+						mWidgetIsDirty = true;
+					}
+				}
+			}
+		}
+
+		mPosition = position;
+		mRotation = rotation;
+		mScale = scale;
+		mTransform = parent->getWorldTfrm();
+	}
+
+	void GUIWidget::_updateLayout()
+	{
+		bs_frame_mark();
+
+		// Determine dirty contents and layouts
+		FrameStack<GUIElementBase*> todo;
+		todo.push(mPanel);
+
+		while (!todo.empty())
+		{
+			GUIElementBase* currentElem = todo.top();
+			todo.pop();
+
+			if (currentElem->_isDirty())
+			{
+				GUIElementBase* updateParent = currentElem->_getUpdateParent();
+				assert(updateParent != nullptr || currentElem == mPanel);
+
+				if (updateParent != nullptr)
+					_updateLayout(updateParent);
+				else // Must be root panel
+					_updateLayout(mPanel);
+			}
+			else
+			{
+				UINT32 numChildren = currentElem->_getNumChildren();
+				for (UINT32 i = 0; i < numChildren; i++)
+					todo.push(currentElem->_getChild(i));
+			}
+		}
+
+		bs_frame_clear();
+	}
+
+	void GUIWidget::_updateLayout(GUIElementBase* elem)
+	{
+		GUIElementBase* parent = elem->_getParent();
+		bool isPanelOptimized = parent != nullptr && parent->_getType() == GUIElementBase::Type::Panel;
+
+		GUIElementBase* updateParent = nullptr;
+
+		if (isPanelOptimized)
+			updateParent = parent;
+		else
+			updateParent = elem;
+
+		// For GUIPanel we can do a an optimization and update only the element in question instead
+		// of all the children
+		if (isPanelOptimized)
+		{
+			GUIPanel* panel = static_cast<GUIPanel*>(updateParent);
+
+			GUIElementBase* dirtyElement = elem;
+			dirtyElement->_updateOptimalLayoutSizes();
+
+			LayoutSizeRange elementSizeRange = panel->_getElementSizeRange(dirtyElement);
+			Rect2I elementArea = panel->_getElementArea(panel->_getLayoutData().area, dirtyElement, elementSizeRange);
+
+			GUILayoutData childLayoutData = panel->_getLayoutData();
+			panel->_updateDepthRange(childLayoutData);
+			childLayoutData.area = elementArea;
+
+			panel->_updateChildLayout(dirtyElement, childLayoutData);
+		}
+		else
+		{
+			GUILayoutData childLayoutData = updateParent->_getLayoutData();
+			updateParent->_updateLayout(childLayoutData);
+		}
+		
+		// Mark dirty contents
+		bs_frame_mark();
+		{
+			FrameStack<GUIElementBase*> todo;
+			todo.push(elem);
+
+			while (!todo.empty())
+			{
+				GUIElementBase* currentElem = todo.top();
+				todo.pop();
+
+				if (currentElem->_getType() == GUIElementBase::Type::Element)
+					mDirtyContents.insert(static_cast<GUIElement*>(currentElem));
+
+				currentElem->_markAsClean();
+
+				UINT32 numChildren = currentElem->_getNumChildren();
+				for (UINT32 i = 0; i < numChildren; i++)
+					todo.push(currentElem->_getChild(i));
+			}
+		}
+		bs_frame_clear();
+	}
+
+	void GUIWidget::_registerElement(GUIElementBase* elem)
+	{
+		assert(elem != nullptr && !elem->_isDestroyed());
+
+		if (elem->_getType() == GUIElementBase::Type::Element)
+		{
+			mElements.push_back(static_cast<GUIElement*>(elem));
+			mWidgetIsDirty = true;
+		}
+	}
+
+	void GUIWidget::_unregisterElement(GUIElementBase* elem)
+	{
+		assert(elem != nullptr);
+
+		auto iterFind = std::find(begin(mElements), end(mElements), elem);
+
+		if (iterFind != mElements.end())
+		{
+			mElements.erase(iterFind);
+			mWidgetIsDirty = true;
+		}
+
+		if (elem->_getType() == GUIElementBase::Type::Element)
+			mDirtyContents.erase(static_cast<GUIElement*>(elem));
+	}
+
+	void GUIWidget::_markMeshDirty(GUIElementBase* elem)
+	{
+		mWidgetIsDirty = true;
+	}
+
+	void GUIWidget::_markContentDirty(GUIElementBase* elem)
+	{
+		if (elem->_getType() == GUIElementBase::Type::Element)
+			mDirtyContents.insert(static_cast<GUIElement*>(elem));
+	}
+
+	void GUIWidget::setSkin(const HGUISkin& skin)
+	{
+		mSkin = skin;
+
+		for(auto& element : mElements)
+			element->_refreshStyle();
+	}
+
+	const GUISkin& GUIWidget::getSkin() const
+	{
+		if(mSkin.isLoaded())
+			return *mSkin;
+		else
+			return *BuiltinResources::instance().getEmptyGUISkin();
+	}
+
+	void GUIWidget::setCamera(const CameraPtr& camera)
+	{
+		if (mCamera == camera)
+			return;
+
+		GUIManager::instance().unregisterWidget(this);
+
+		mOwnerTargetResizedConn.disconnect();
+
+		mCamera = camera;
+
+		Viewport* viewport = getTarget();
+		if (viewport != nullptr && viewport->getTarget() != nullptr)
+			mOwnerTargetResizedConn = viewport->getTarget()->onResized.connect(std::bind(&GUIWidget::ownerTargetResized, this));
+
+		GUIManager::instance().registerWidget(this);
+
+		updateRootPanel();
+	}
+
+	void GUIWidget::setIsActive(bool active)
+	{
+		mIsActive = active;
+	}
+
+	bool GUIWidget::isDirty(bool cleanIfDirty)
+	{
+		if (!mIsActive)
+			return false;
+
+		bool dirty = mWidgetIsDirty || mDirtyContents.size() > 0;
+
+		if(cleanIfDirty && dirty)
+		{
+			mWidgetIsDirty = false;
+
+			for (auto& dirtyElement : mDirtyContents)
+				dirtyElement->_updateRenderElements();
+
+			mDirtyContents.clear();
+			updateBounds();
+		}
+		
+		return dirty;
+	}
+
+	bool GUIWidget::inBounds(const Vector2I& position) const
+	{
+		Viewport* target = getTarget();
+		if (target == nullptr)
+			return false;
+
+		// Technically GUI widget bounds can be larger than the viewport, so make sure we clip to viewport first
+		if(!target->getArea().contains(position))
+			return false;
+
+		Vector3 vecPos((float)position.x, (float)position.y, 0.0f);
+		vecPos = mTransform.inverse().multiplyAffine(vecPos);
+
+		Vector2I localPos(Math::roundToInt(vecPos.x), Math::roundToInt(vecPos.y));
+		return mBounds.contains(localPos);
+	}
+
+	void GUIWidget::updateBounds() const
+	{
+		if(mElements.size() > 0)
+			mBounds = mElements[0]->_getClippedBounds();
+
+		for(auto& elem : mElements)
+		{
+			Rect2I elemBounds = elem->_getClippedBounds();
+			mBounds.encapsulate(elemBounds);
+		}
+	}
+
+	void GUIWidget::ownerTargetResized()
+	{
+		updateRootPanel();
+
+		onOwnerTargetResized();
+	}
+
+	void GUIWidget::ownerWindowFocusChanged()
+	{
+		onOwnerWindowFocusChanged();
+	}
+
+	void GUIWidget::updateRootPanel()
+	{
+		Viewport* target = getTarget();
+		if (target == nullptr)
+			return;
+
+		UINT32 width = target->getWidth();
+		UINT32 height = target->getHeight();
+
+		GUILayoutData layoutData;
+		layoutData.area.width = width;
+		layoutData.area.height = height;
+		layoutData.clipRect = Rect2I(0, 0, width, height);
+		layoutData.setWidgetDepth(mDepth);
+
+		mPanel->setWidth(width);
+		mPanel->setHeight(height);
+
+		mPanel->_setLayoutData(layoutData);
+		mPanel->_markLayoutAsDirty();
+	}
+}

+ 10 - 10
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -1,10 +1,10 @@
 #include "BsProfilerOverlay.h"
 #include "BsSceneObject.h"
 #include "BsCGUIWidget.h"
-#include "BsGUIPanel.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
+#include "BsGUIPanel.h"
 #include "BsGUIElement.h"
 #include "BsGUILabel.h"
 #include "BsGUISpace.h"
@@ -27,10 +27,10 @@ namespace BansheeEngine
 		UINT32 curIdx;
 		GUILayout& labelLayout;
 		GUILayout& contentLayout;
-		CGUIWidget& widget;
+		GUIWidget& widget;
 		Vector<ProfilerOverlayInternal::BasicRow>& rows;
 
-		BasicRowFiller(Vector<ProfilerOverlayInternal::BasicRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, CGUIWidget& _widget)
+		BasicRowFiller(Vector<ProfilerOverlayInternal::BasicRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, GUIWidget& _widget)
 			:rows(_rows), curIdx(0), labelLayout(_labelLayout), contentLayout(_contentLayout), widget(_widget)
 		{ }
 
@@ -128,10 +128,10 @@ namespace BansheeEngine
 		UINT32 curIdx;
 		GUILayout& labelLayout;
 		GUILayout& contentLayout;
-		CGUIWidget& widget;
+		GUIWidget& widget;
 		Vector<ProfilerOverlayInternal::PreciseRow>& rows;
 
-		PreciseRowFiller(Vector<ProfilerOverlayInternal::PreciseRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, CGUIWidget& _widget)
+		PreciseRowFiller(Vector<ProfilerOverlayInternal::PreciseRow>& _rows, GUILayout& _labelLayout, GUILayout& _contentLayout, GUIWidget& _widget)
 			:rows(_rows), curIdx(0), labelLayout(_labelLayout), contentLayout(_contentLayout), widget(_widget)
 		{ }
 
@@ -228,10 +228,10 @@ namespace BansheeEngine
 	public:
 		UINT32 curIdx;
 		GUILayout& layout;
-		CGUIWidget& widget;
+		GUIWidget& widget;
 		Vector<ProfilerOverlayInternal::GPUSampleRow>& rows;
 
-		GPUSampleRowFiller(Vector<ProfilerOverlayInternal::GPUSampleRow>& _rows, GUILayout& _layout, CGUIWidget& _widget)
+		GPUSampleRowFiller(Vector<ProfilerOverlayInternal::GPUSampleRow>& _rows, GUILayout& _layout, GUIWidget& _widget)
 			:rows(_rows), curIdx(0), layout(_layout), widget(_widget)
 		{ }
 
@@ -646,7 +646,7 @@ namespace BansheeEngine
 			UINT32 depth;
 		};
 
-		BasicRowFiller basicRowFiller(mBasicRows, *mBasicLayoutLabels, *mBasicLayoutContents, *mWidget);
+		BasicRowFiller basicRowFiller(mBasicRows, *mBasicLayoutLabels, *mBasicLayoutContents, *mWidget->_getInternal());
 		Stack<TodoBasic> todoBasic;
 
 		const CPUProfilerBasicSamplingEntry* basicRootEntries[NUM_ROOT_ENTRIES];
@@ -676,7 +676,7 @@ namespace BansheeEngine
 			}
 		}
 
-		PreciseRowFiller preciseRowFiller(mPreciseRows, *mBasicLayoutLabels, *mBasicLayoutContents, *mWidget);
+		PreciseRowFiller preciseRowFiller(mPreciseRows, *mBasicLayoutLabels, *mBasicLayoutContents, *mWidget->_getInternal());
 		Stack<TodoPrecise> todoPrecise;
 
 		const CPUProfilerPreciseSamplingEntry* preciseRootEntries[NUM_ROOT_ENTRIES];
@@ -733,7 +733,7 @@ namespace BansheeEngine
 		mGPUGPUProgramBufferBindsStr.setParameter(0, toWString(gpuReport.frameSample.numGpuParamBufferBinds));
 		mGPUGPUProgramBindsStr.setParameter(0, toWString(gpuReport.frameSample.numGpuProgramBinds));
 
-		GPUSampleRowFiller sampleRowFiller(mGPUSampleRows, *mGPULayoutSampleContents, *mWidget);
+		GPUSampleRowFiller sampleRowFiller(mGPUSampleRows, *mGPULayoutSampleContents, *mWidget->_getInternal());
 		for (auto& sample : gpuReport.samples)
 		{
 			sampleRowFiller.addData(sample.name, sample.timeMs);

+ 40 - 44
BansheeFBXImporter/BansheeFBXImporter.vcxproj.filters

@@ -1,45 +1,41 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsFBXPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsFBXImporter.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsFBXImportData.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsFBXUtility.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsFBXPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsFBXImporter.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsFBXUtility.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsFBXImportData.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsFBXPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFBXImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFBXImportData.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFBXUtility.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsFBXPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFBXImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFBXUtility.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFBXImportData.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 28 - 32
BansheeFontImporter/BansheeFontImporter.vcxproj.filters

@@ -1,33 +1,29 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsFontPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsFontImporter.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsFontPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsFontImporter.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsFontPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFontImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsFontPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFontImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 28 - 32
BansheeFreeImgImporter/BansheeFreeImgImporter.vcxproj.filters

@@ -1,33 +1,29 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsFreeImgPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsFreeImgImporter.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsFreeImgPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsFreeImgImporter.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsFreeImgPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFreeImgImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsFreeImgPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFreeImgImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 223 - 227
BansheeGLRenderAPI/BansheeGLRenderAPI.vcxproj.filters

@@ -1,228 +1,224 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-    <Filter Include="Header Files\GLSL">
-      <UniqueIdentifier>{4a04e68e-bddd-41da-a32c-b50d628cd689}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Header Files\Win32">
-      <UniqueIdentifier>{e5ed7756-6562-4fda-b111-fbc35d54fb7c}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\Win32">
-      <UniqueIdentifier>{ba3de2cb-a789-41d9-918b-ecffa74967c3}</UniqueIdentifier>
-    </Filter>
-    <Filter Include="Source Files\GLSL">
-      <UniqueIdentifier>{5a08232d-f612-44f5-b9f5-3bad262a935c}</UniqueIdentifier>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsGLVertexArrayObjectManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLVertexBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLTimerQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLTextureManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLTexture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLSupport.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLRenderWindowManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLRenderTexture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLQueryManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLPixelFormat.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLPixelBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLOcclusionQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLMultiRenderTexture.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLIndexBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLHardwareBufferManager.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLGpuParamBlockBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLGpuBuffer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLFrameBufferObject.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLEventQuery.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLContext.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsWin32VideoModeInfo.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsWin32Prerequisites.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsWin32GLSupport.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsWin32Context.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\BsGLSLProgramPipelineManager.h">
-      <Filter>Header Files\GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\BsGLSLProgramFactory.h">
-      <Filter>Header Files\GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\BsGLSLParamParser.h">
-      <Filter>Header Files\GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\GLSL\include\BsGLSLGpuProgram.h">
-      <Filter>Header Files\GLSL</Filter>
-    </ClInclude>
-    <ClInclude Include="Source\win32\BsGLUtil.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLRenderAPI.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsGLRenderAPIFactory.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsWin32RenderWindow.h">
-      <Filter>Header Files\Win32</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\glew.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLVertexArrayObjectManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLVertexBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLTimerQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLTextureManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLTexture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLSupport.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLRenderWindowManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLRenderTexture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLQueryManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="BsGLPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLPixelFormat.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLPixelBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLOcclusionQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLMultiRenderTexture.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLIndexBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLHardwareBufferManager.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLGpuParamBlockBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLGpuBuffer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLFrameBufferObject.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLEventQuery.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLContext.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsWin32VideoModeInfo.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsWin32GLSupport.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\win32\BsWin32Context.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\BsGLSLProgramPipelineManager.cpp">
-      <Filter>Source Files\GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\BsGLSLProgramFactory.cpp">
-      <Filter>Source Files\GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\GLSL\src\BsGLSLGpuProgram.cpp">
-      <Filter>Source Files\GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLSLParamParser.cpp">
-      <Filter>Source Files\GLSL</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLRenderAPI.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsGLRenderAPIFactory.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsWin32RenderWindow.cpp">
-      <Filter>Source Files\Win32</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="Header Files\GLSL">
+      <UniqueIdentifier>{4a04e68e-bddd-41da-a32c-b50d628cd689}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Header Files\Win32">
+      <UniqueIdentifier>{e5ed7756-6562-4fda-b111-fbc35d54fb7c}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Win32">
+      <UniqueIdentifier>{ba3de2cb-a789-41d9-918b-ecffa74967c3}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\GLSL">
+      <UniqueIdentifier>{5a08232d-f612-44f5-b9f5-3bad262a935c}</UniqueIdentifier>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsGLVertexArrayObjectManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLVertexBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLTimerQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLTextureManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLTexture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLSupport.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLRenderWindowManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLRenderTexture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLQueryManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLPixelFormat.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLPixelBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLOcclusionQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLMultiRenderTexture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLIndexBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLHardwareBufferManager.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLGpuParamBlockBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLGpuBuffer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLFrameBufferObject.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLEventQuery.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLContext.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsWin32VideoModeInfo.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsWin32Prerequisites.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsWin32GLSupport.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsWin32Context.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\BsGLSLProgramPipelineManager.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\BsGLSLProgramFactory.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\BsGLSLParamParser.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\GLSL\include\BsGLSLGpuProgram.h">
+      <Filter>Header Files\GLSL</Filter>
+    </ClInclude>
+    <ClInclude Include="Source\win32\BsGLUtil.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLRenderAPI.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsGLRenderAPIFactory.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsWin32RenderWindow.h">
+      <Filter>Header Files\Win32</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\glew.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLVertexArrayObjectManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLVertexBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLTimerQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLTextureManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLTexture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLSupport.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLRenderWindowManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLRenderTexture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLQueryManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="BsGLPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLPixelFormat.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLPixelBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLOcclusionQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLMultiRenderTexture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLIndexBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLHardwareBufferManager.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLGpuParamBlockBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLGpuBuffer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLFrameBufferObject.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLEventQuery.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLContext.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsWin32VideoModeInfo.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsWin32GLSupport.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\win32\BsWin32Context.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\BsGLSLProgramPipelineManager.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\BsGLSLProgramFactory.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\GLSL\src\BsGLSLGpuProgram.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLSLParamParser.cpp">
+      <Filter>Source Files\GLSL</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLRenderAPI.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGLRenderAPIFactory.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsWin32RenderWindow.cpp">
+      <Filter>Source Files\Win32</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 0 - 4
BansheeMono/BansheeMono.vcxproj.filters

@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsMonoPrerequisites.h">

+ 28 - 32
BansheeOISInput/BansheeOISInput.vcxproj.filters

@@ -1,33 +1,29 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsInputHandlerOIS.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsOISPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsInputHandlerOIS.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsOISPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsInputHandlerOIS.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsOISPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsInputHandlerOIS.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsOISPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 62 - 66
BansheeSL/BansheeSL.vcxproj.filters

@@ -1,67 +1,63 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsSLPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="BsLexerFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="BsParserFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsASTFX.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsMMAlloc.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsSLImporter.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsSLFXCompiler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="BsLexerFX.l" />
-    <None Include="BsParserFX.y" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="BsLexerFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="BsParserFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsSLPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsASTFX.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BSMMAlloc.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsSLImporter.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsSLFXCompiler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsSLPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="BsLexerFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="BsParserFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsASTFX.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsMMAlloc.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsSLImporter.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsSLFXCompiler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="BsLexerFX.l" />
+    <None Include="BsParserFX.y" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="BsLexerFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="BsParserFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsSLPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsASTFX.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BSMMAlloc.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsSLImporter.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsSLFXCompiler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 20 - 5
BansheeUtility/Include/BsMath.h

@@ -87,19 +87,34 @@ namespace BansheeEngine
 		}
 
         /** Compare two floats, using tolerance for inaccuracies. */
-        static bool approxEquals(float a, float b, float tolerance = std::numeric_limits<float>::epsilon());
+        static bool approxEquals(float a, float b, 
+			float tolerance = std::numeric_limits<float>::epsilon())
+		{
+			return fabs(b - a) <= tolerance;
+		}
 
         /** Compare two doubles, using tolerance for inaccuracies. */
-		static bool approxEquals(double a, double b, double tolerance = std::numeric_limits<double>::epsilon());
+		static bool approxEquals(double a, double b, 
+			double tolerance = std::numeric_limits<double>::epsilon())
+		{
+			return fabs(b - a) <= tolerance;
+		}
 
 		/** Compare two 2D vectors, using tolerance for inaccuracies. */
-		static bool approxEquals(const Vector2& a, const Vector2& b, float tolerance = std::numeric_limits<float>::epsilon());
+		static bool approxEquals(const Vector2& a, const Vector2& b, 
+			float tolerance = std::numeric_limits<float>::epsilon());
 
 		/** Compare two 3D vectors, using tolerance for inaccuracies. */
-		static bool approxEquals(const Vector3& a, const Vector3& b, float tolerance = std::numeric_limits<float>::epsilon());
+		static bool approxEquals(const Vector3& a, const Vector3& b, 
+			float tolerance = std::numeric_limits<float>::epsilon());
 
 		/** Compare two 4D vectors, using tolerance for inaccuracies. */
-		static bool approxEquals(const Vector4& a, const Vector4& b, float tolerance = std::numeric_limits<float>::epsilon());
+		static bool approxEquals(const Vector4& a, const Vector4& b, 
+			float tolerance = std::numeric_limits<float>::epsilon());
+
+		/** Compare two quaternions, using tolerance for inaccuracies. */
+		static bool approxEquals(const Quaternion& a, const Quaternion& b, 
+			float tolerance = std::numeric_limits<float>::epsilon());
 
         /** Calculates the tangent space vector for a given set of positions / texture coords. */
         static Vector3 calculateTriTangent(const Vector3& position1, const Vector3& position2, 

+ 35 - 0
BansheeUtility/Include/BsStdHeaders.h

@@ -165,6 +165,13 @@ namespace BansheeEngine
 	template <typename T>
 	using SPtr = std::shared_ptr<T>;
 
+	/** 
+	 * Smart pointer that retains shared ownership of an project through a pointer. Reference to the object must be unique.
+	 * The object is destroyed automatically when the pointer to the object is destroyed.
+	 */
+	template <typename T, typename Alloc = GenAlloc>
+	using UPtr = std::unique_ptr<T, decltype(&bs_delete<T, Alloc>)>;
+
 	/** Create a new shared pointer using a custom allocator category. */
 	template<class Type, class AllocCategory, class... Args> 
 	SPtr<Type> bs_shared_ptr_new(Args &&... args)
@@ -189,5 +196,33 @@ namespace BansheeEngine
 		return std::shared_ptr<Type>(data, &bs_delete<Type, MainAlloc>, StdAlloc<Type, PtrDataAlloc>());
 	}
 
+	/** Create a new unique pointer using a custom allocator category. */
+	template<class Type, class Alloc, class... Args>
+	UPtr<Type> bs_unique_ptr_new(Args &&... args)
+	{
+		Type* rawPtr = bs_new<Type, Alloc>(std::forward<Args>(args)...);
+
+		return bs_unique_ptr<Type, Alloc>(rawPtr);
+	}
+
+	/** Create a new unique pointer using the default allocator category. */
+	template<class Type, class... Args>
+	UPtr<Type> bs_unique_ptr_new(Args &&... args)
+	{
+		Type* rawPtr = bs_new<Type, GenAlloc>(std::forward<Args>(args)...);
+
+		return bs_unique_ptr<Type, GenAlloc>(rawPtr);
+	}
+
+	/**
+	* Create a new unique pointer from a previously constructed object.
+	* Pointer specific data will be allocated using the provided allocator category.
+	*/
+	template<class Type, class Alloc = GenAlloc>
+	UPtr<Type, Alloc> bs_unique_ptr(Type* data)
+	{
+		return std::unique_ptr<Type, decltype(&bs_delete<Type, Alloc>)>(data, bs_delete<Type, Alloc>);
+	}
+
 	/** @} */
 }

+ 328 - 349
BansheeUtility/Source/BsMath.cpp

@@ -1,349 +1,328 @@
-#include "BsMath.h"
-#include "BsVector2.h"
-#include "BsVector3.h"
-#include "BsVector4.h"
-#include "BsRay.h"
-#include "BsSphere.h"
-#include "BsAABox.h"
-#include "BsPlane.h"
-
-namespace BansheeEngine
-{
-    const float Math::POS_INFINITY = std::numeric_limits<float>::infinity();
-    const float Math::NEG_INFINITY = -std::numeric_limits<float>::infinity();
-    const float Math::PI = (float)4.0f * std::atan(1.0f);
-    const float Math::TWO_PI = (float)(2.0f * PI);
-    const float Math::HALF_PI = (float)(0.5f * PI);
-	const float Math::DEG2RAD = PI / 180.0f;
-	const float Math::RAD2DEG = 180.0f / PI;
-	const float Math::LOG2 = std::log(2.0f);
-
-    Radian Math::acos(float val)
-    {
-        if (-1.0f < val)
-        {
-            if (val < 1.0f)
-                return Radian(std::acos(val));
-            else
-                return Radian(0.0f);
-        }
-        else
-        {
-            return Radian(PI);
-        }
-    }
-
-    Radian Math::asin(float val)
-    {
-        if (-1.0f < val)
-        {
-            if (val < 1.0f)
-                return Radian(std::asin(val));
-            else
-                return Radian(HALF_PI);
-        }
-        else
-        {
-            return Radian(-HALF_PI);
-        }
-    }
-
-    float Math::sign(float val)
-    {
-        if (val > 0.0f)
-            return 1.0f;
-
-        if (val < 0.0f)
-            return -1.0f;
-
-        return 0.0f;
-    }
-
-	float Math::invSqrt(float val)
-	{
-		return 1.0f/sqrt(val);
-	}
-
-	float Math::fastSin0(float val)
-	{
-		float angleSqr = val*val;
-		float result = 7.61e-03f;
-		result *= angleSqr;
-		result -= 1.6605e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-		result *= val;
-		return result;
-	}
-
-	float Math::fastSin1(float val)
-	{
-		float angleSqr = val*val;
-		float result = -2.39e-08f;
-		result *= angleSqr;
-		result += 2.7526e-06f;
-		result *= angleSqr;
-		result -= 1.98409e-04f;
-		result *= angleSqr;
-		result += 8.3333315e-03f;
-		result *= angleSqr;
-		result -= 1.666666664e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-		result *= val;
-
-		return result;
-	}
-
-	float Math::fastCos0(float val)
-	{
-		float angleSqr = val*val;
-		float result = 3.705e-02f;
-		result *= angleSqr;
-		result -= 4.967e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-
-		return result;
-	}
-
-	float Math::fastCos1(float val)
-	{
-		float angleSqr = val*val;
-		float result = -2.605e-07f;
-		result *= angleSqr;
-		result += 2.47609e-05f;
-		result *= angleSqr;
-		result -= 1.3888397e-03f;
-		result *= angleSqr;
-		result += 4.16666418e-02f;
-		result *= angleSqr;
-		result -= 4.999999963e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-
-		return result;
-	}
-
-	float Math::fastTan0(float val)
-	{
-		float angleSqr = val*val;
-		float result = 2.033e-01f;
-		result *= angleSqr;
-		result += 3.1755e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-		result *= val;
-		return result;
-	}
-
-	float Math::fastTan1(float val)
-	{
-		float angleSqr = val*val;
-		float result = 9.5168091e-03f;
-		result *= angleSqr;
-		result += 2.900525e-03f;
-		result *= angleSqr;
-		result += 2.45650893e-02f;
-		result *= angleSqr;
-		result += 5.33740603e-02f;
-		result *= angleSqr;
-		result += 1.333923995e-01f;
-		result *= angleSqr;
-		result += 3.333314036e-01f;
-		result *= angleSqr;
-		result += 1.0f;
-		result *= val;
-		return result;
-	}
-
-	float Math::fastASin0(float val)
-	{
-		float root = sqrt(abs(1.0f - val));
-		float result = -0.0187293f;
-		result *= val;
-		result += 0.0742610f;
-		result *= val;
-		result -= 0.2121144f;
-		result *= val;
-		result += 1.5707288f;
-		result = HALF_PI - root*result;
-		return result;
-	}
-
-	float Math::fastASin1(float val)
-	{
-		float root = sqrt(abs(1.0f - val));
-		float result = -0.0012624911f;
-		result *= val;
-		result += 0.0066700901f;
-		result *= val;
-		result -= 0.0170881256f;
-		result *= val;
-		result += 0.0308918810f;
-		result *= val;
-		result -= 0.0501743046f;
-		result *= val;
-		result += 0.0889789874f;
-		result *= val;
-		result -= 0.2145988016f;
-		result *= val;
-		result += 1.5707963050f;
-		result = HALF_PI - root*result;
-		return result;
-	}
-
-	float Math::fastACos0(float val)
-	{
-		float root = sqrt(abs(1.0f - val));
-		float result = -0.0187293f;
-		result *= val;
-		result += 0.0742610f;
-		result *= val;
-		result -= 0.2121144f;
-		result *= val;
-		result += 1.5707288f;
-		result *= root;
-		return result;
-	}
-
-	float Math::fastACos1(float val)
-	{
-		float root = sqrt(abs(1.0f - val));
-		float result = -0.0012624911f;
-		result *= val;
-		result += 0.0066700901f;
-		result *= val;
-		result -= 0.0170881256f;
-		result *= val;
-		result += 0.0308918810f;
-		result *= val;
-		result -= 0.0501743046f;
-		result *= val;
-		result += 0.0889789874f;
-		result *= val;
-		result -= 0.2145988016f;
-		result *= val;
-		result += 1.5707963050f;
-		result *= root;
-		return result;
-	}
-
-	float Math::fastATan0(float val)
-	{
-		float valueSqr = val*val;
-		float result = 0.0208351f;
-		result *= valueSqr;
-		result -= 0.085133f;
-		result *= valueSqr;
-		result += 0.180141f;
-		result *= valueSqr;
-		result -= 0.3302995f;
-		result *= valueSqr;
-		result += 0.999866f;
-		result *= val;
-		return result;
-	}
-
-	float Math::fastATan1(float val)
-	{
-		float valueSqr = val*val;
-		float result = 0.0028662257f;
-		result *= valueSqr;
-		result -= 0.0161657367f;
-		result *= valueSqr;
-		result += 0.0429096138f;
-		result *= valueSqr;
-		result -= 0.0752896400f;
-		result *= valueSqr;
-		result += 0.1065626393f;
-		result *= valueSqr;
-		result -= 0.1420889944f;
-		result *= valueSqr;
-		result += 0.1999355085f;
-		result *= valueSqr;
-		result -= 0.3333314528f;
-		result *= valueSqr;
-		result += 1.0f;
-		result *= val;
-		return result;
-	}
-
-    bool Math::approxEquals(float a, float b, float tolerance)
-    {
-        if (fabs(b-a) <= tolerance)
-            return true;
-        else
-            return false;
-    }
-
-	bool Math::approxEquals(double a, double b, double tolerance)
-	{
-		if (fabs(b - a) <= tolerance)
-			return true;
-		else
-			return false;
-	}
-
-	bool Math::approxEquals(const Vector2& a, const Vector2& b, float tolerance)
-	{
-		if (fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance)
-			return true;
-		else
-			return false;
-	}
-
-	bool Math::approxEquals(const Vector3& a, const Vector3& b, float tolerance)
-	{
-		if (fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance && fabs(b.z - a.z) <= tolerance)
-			return true;
-		else
-			return false;
-	}
-
-	bool Math::approxEquals(const Vector4& a, const Vector4& b, float tolerance)
-	{
-		if (fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance && fabs(b.z - a.z) <= tolerance && fabs(b.w - a.w) <= tolerance)
-			return true;
-		else
-			return false;
-	}
-
-	Vector3 Math::calculateTriTangent(const Vector3& position1, const Vector3& position2, 
-		const Vector3& position3, float u1, float v1, float u2, float v2, float u3, float v3)
-	{
-		Vector3 side0 = position1 - position2;
-		Vector3 side1 = position3 - position1;
-
-		// Calculate face normal
-		Vector3 normal = side1.cross(side0);
-		normal.normalize();
-
-		// Now we use a formula to calculate the tangent. 
-		float deltaV0 = v1 - v2;
-		float deltaV1 = v3 - v1;
-		Vector3 tangent = deltaV1 * side0 - deltaV0 * side1;
-		tangent.normalize();
-
-		// Calculate binormal
-		float deltaU0 = u1 - u2;
-		float deltaU1 = u3 - u1;
-		Vector3 binormal = deltaU1 * side0 - deltaU0 * side1;
-		binormal.normalize();
-
-		// Now, we take the cross product of the tangents to get a vector which 
-		// should point in the same direction as our normal calculated above. 
-		// If it points in the opposite direction (the dot product between the normals is less than zero), 
-		// then we need to reverse the s and t tangents. 
-		// This is because the triangle has been mirrored when going from tangent space to object space.
-		// reverse tangents if necessary.
-		Vector3 tangentCross = tangent.cross(binormal);
-		if (tangentCross.dot(normal) < 0.0f)
-		{
-			tangent = -tangent;
-			binormal = -binormal;
-		}
-
-		return tangent;
-	}
-}
+#include "BsMath.h"
+#include "BsVector2.h"
+#include "BsVector3.h"
+#include "BsVector4.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+    const float Math::POS_INFINITY = std::numeric_limits<float>::infinity();
+    const float Math::NEG_INFINITY = -std::numeric_limits<float>::infinity();
+    const float Math::PI = (float)4.0f * std::atan(1.0f);
+    const float Math::TWO_PI = (float)(2.0f * PI);
+    const float Math::HALF_PI = (float)(0.5f * PI);
+	const float Math::DEG2RAD = PI / 180.0f;
+	const float Math::RAD2DEG = 180.0f / PI;
+	const float Math::LOG2 = std::log(2.0f);
+
+    Radian Math::acos(float val)
+    {
+        if (-1.0f < val)
+        {
+            if (val < 1.0f)
+                return Radian(std::acos(val));
+            else
+                return Radian(0.0f);
+        }
+        else
+        {
+            return Radian(PI);
+        }
+    }
+
+    Radian Math::asin(float val)
+    {
+        if (-1.0f < val)
+        {
+            if (val < 1.0f)
+                return Radian(std::asin(val));
+            else
+                return Radian(HALF_PI);
+        }
+        else
+        {
+            return Radian(-HALF_PI);
+        }
+    }
+
+    float Math::sign(float val)
+    {
+        if (val > 0.0f)
+            return 1.0f;
+
+        if (val < 0.0f)
+            return -1.0f;
+
+        return 0.0f;
+    }
+
+	float Math::invSqrt(float val)
+	{
+		return 1.0f/sqrt(val);
+	}
+
+	float Math::fastSin0(float val)
+	{
+		float angleSqr = val*val;
+		float result = 7.61e-03f;
+		result *= angleSqr;
+		result -= 1.6605e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+		result *= val;
+		return result;
+	}
+
+	float Math::fastSin1(float val)
+	{
+		float angleSqr = val*val;
+		float result = -2.39e-08f;
+		result *= angleSqr;
+		result += 2.7526e-06f;
+		result *= angleSqr;
+		result -= 1.98409e-04f;
+		result *= angleSqr;
+		result += 8.3333315e-03f;
+		result *= angleSqr;
+		result -= 1.666666664e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+		result *= val;
+
+		return result;
+	}
+
+	float Math::fastCos0(float val)
+	{
+		float angleSqr = val*val;
+		float result = 3.705e-02f;
+		result *= angleSqr;
+		result -= 4.967e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+
+		return result;
+	}
+
+	float Math::fastCos1(float val)
+	{
+		float angleSqr = val*val;
+		float result = -2.605e-07f;
+		result *= angleSqr;
+		result += 2.47609e-05f;
+		result *= angleSqr;
+		result -= 1.3888397e-03f;
+		result *= angleSqr;
+		result += 4.16666418e-02f;
+		result *= angleSqr;
+		result -= 4.999999963e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+
+		return result;
+	}
+
+	float Math::fastTan0(float val)
+	{
+		float angleSqr = val*val;
+		float result = 2.033e-01f;
+		result *= angleSqr;
+		result += 3.1755e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+		result *= val;
+		return result;
+	}
+
+	float Math::fastTan1(float val)
+	{
+		float angleSqr = val*val;
+		float result = 9.5168091e-03f;
+		result *= angleSqr;
+		result += 2.900525e-03f;
+		result *= angleSqr;
+		result += 2.45650893e-02f;
+		result *= angleSqr;
+		result += 5.33740603e-02f;
+		result *= angleSqr;
+		result += 1.333923995e-01f;
+		result *= angleSqr;
+		result += 3.333314036e-01f;
+		result *= angleSqr;
+		result += 1.0f;
+		result *= val;
+		return result;
+	}
+
+	float Math::fastASin0(float val)
+	{
+		float root = sqrt(abs(1.0f - val));
+		float result = -0.0187293f;
+		result *= val;
+		result += 0.0742610f;
+		result *= val;
+		result -= 0.2121144f;
+		result *= val;
+		result += 1.5707288f;
+		result = HALF_PI - root*result;
+		return result;
+	}
+
+	float Math::fastASin1(float val)
+	{
+		float root = sqrt(abs(1.0f - val));
+		float result = -0.0012624911f;
+		result *= val;
+		result += 0.0066700901f;
+		result *= val;
+		result -= 0.0170881256f;
+		result *= val;
+		result += 0.0308918810f;
+		result *= val;
+		result -= 0.0501743046f;
+		result *= val;
+		result += 0.0889789874f;
+		result *= val;
+		result -= 0.2145988016f;
+		result *= val;
+		result += 1.5707963050f;
+		result = HALF_PI - root*result;
+		return result;
+	}
+
+	float Math::fastACos0(float val)
+	{
+		float root = sqrt(abs(1.0f - val));
+		float result = -0.0187293f;
+		result *= val;
+		result += 0.0742610f;
+		result *= val;
+		result -= 0.2121144f;
+		result *= val;
+		result += 1.5707288f;
+		result *= root;
+		return result;
+	}
+
+	float Math::fastACos1(float val)
+	{
+		float root = sqrt(abs(1.0f - val));
+		float result = -0.0012624911f;
+		result *= val;
+		result += 0.0066700901f;
+		result *= val;
+		result -= 0.0170881256f;
+		result *= val;
+		result += 0.0308918810f;
+		result *= val;
+		result -= 0.0501743046f;
+		result *= val;
+		result += 0.0889789874f;
+		result *= val;
+		result -= 0.2145988016f;
+		result *= val;
+		result += 1.5707963050f;
+		result *= root;
+		return result;
+	}
+
+	float Math::fastATan0(float val)
+	{
+		float valueSqr = val*val;
+		float result = 0.0208351f;
+		result *= valueSqr;
+		result -= 0.085133f;
+		result *= valueSqr;
+		result += 0.180141f;
+		result *= valueSqr;
+		result -= 0.3302995f;
+		result *= valueSqr;
+		result += 0.999866f;
+		result *= val;
+		return result;
+	}
+
+	float Math::fastATan1(float val)
+	{
+		float valueSqr = val*val;
+		float result = 0.0028662257f;
+		result *= valueSqr;
+		result -= 0.0161657367f;
+		result *= valueSqr;
+		result += 0.0429096138f;
+		result *= valueSqr;
+		result -= 0.0752896400f;
+		result *= valueSqr;
+		result += 0.1065626393f;
+		result *= valueSqr;
+		result -= 0.1420889944f;
+		result *= valueSqr;
+		result += 0.1999355085f;
+		result *= valueSqr;
+		result -= 0.3333314528f;
+		result *= valueSqr;
+		result += 1.0f;
+		result *= val;
+		return result;
+	}
+
+	inline bool Math::approxEquals(const Vector2& a, const Vector2& b, float tolerance)
+	{
+		return fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance;
+	}
+
+	inline bool Math::approxEquals(const Vector3& a, const Vector3& b, float tolerance)
+	{
+		return fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance && fabs(b.z - a.z) <= tolerance;
+	}
+
+	inline bool Math::approxEquals(const Vector4& a, const Vector4& b, float tolerance)
+	{
+		return fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance && fabs(b.z - a.z) <= tolerance && 
+			fabs(b.w - a.w) <= tolerance;
+	}
+
+	inline bool Math::approxEquals(const Quaternion& a, const Quaternion& b, float tolerance)
+	{
+		return fabs(b.x - a.x) <= tolerance && fabs(b.y - a.y) <= tolerance && fabs(b.z - a.z) <= tolerance && 
+			fabs(b.w - a.w) <= tolerance;
+	}
+
+	Vector3 Math::calculateTriTangent(const Vector3& position1, const Vector3& position2, 
+		const Vector3& position3, float u1, float v1, float u2, float v2, float u3, float v3)
+	{
+		Vector3 side0 = position1 - position2;
+		Vector3 side1 = position3 - position1;
+
+		// Calculate face normal
+		Vector3 normal = side1.cross(side0);
+		normal.normalize();
+
+		// Now we use a formula to calculate the tangent. 
+		float deltaV0 = v1 - v2;
+		float deltaV1 = v3 - v1;
+		Vector3 tangent = deltaV1 * side0 - deltaV0 * side1;
+		tangent.normalize();
+
+		// Calculate binormal
+		float deltaU0 = u1 - u2;
+		float deltaU1 = u3 - u1;
+		Vector3 binormal = deltaU1 * side0 - deltaU0 * side1;
+		binormal.normalize();
+
+		// Now, we take the cross product of the tangents to get a vector which 
+		// should point in the same direction as our normal calculated above. 
+		// If it points in the opposite direction (the dot product between the normals is less than zero), 
+		// then we need to reverse the s and t tangents. 
+		// This is because the triangle has been mirrored when going from tangent space to object space.
+		// reverse tangents if necessary.
+		Vector3 tangentCross = tangent.cross(binormal);
+		if (tangentCross.dot(normal) < 0.0f)
+		{
+			tangent = -tangent;
+			binormal = -binormal;
+		}
+
+		return tangent;
+	}
+}

+ 150 - 150
BansheeUtility/Source/Win32/BsWin32PlatformUtility.cpp

@@ -1,151 +1,151 @@
-#include "BsPrerequisitesUtil.h"
-#include <windows.h>
-#include <iphlpapi.h>
-
-namespace BansheeEngine
-{
-	void PlatformUtility::terminate(bool force)
-	{
-		if (!force)
-			PostQuitMessage(0);
-		else
-			TerminateProcess(GetCurrentProcess(), 0);
-	}
-
-	double PlatformUtility::queryPerformanceTimerMs()
-	{
-		LARGE_INTEGER counterValue;
-		QueryPerformanceCounter(&counterValue);
-
-		LARGE_INTEGER counterFreq;
-		QueryPerformanceFrequency(&counterFreq);
-
-		return (double)counterValue.QuadPart / (counterFreq.QuadPart * 0.001);
-	}
-
-
-	void PlatformUtility::copyToClipboard(const WString& string)
-	{
-		HANDLE hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (string.size() + 1) * sizeof(WString::value_type));
-		WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
-
-		string.copy(buffer, string.size());
-		buffer[string.size()] = '\0';
-
-		GlobalUnlock(hData);
-
-		if (OpenClipboard(NULL))
-		{
-			EmptyClipboard();
-			SetClipboardData(CF_UNICODETEXT, hData);
-			CloseClipboard();
-		}
-		else
-		{
-			GlobalFree(hData);
-		}
-	}
-
-	WString PlatformUtility::copyFromClipboard()
-	{
-		if (OpenClipboard(NULL))
-		{
-			HANDLE hData = GetClipboardData(CF_UNICODETEXT);
-
-			if (hData != NULL)
-			{
-				WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
-				WString string(buffer);
-				GlobalUnlock(hData);
-
-				CloseClipboard();
-				return string;
-			}
-			else
-			{
-				CloseClipboard();
-				return L"";
-			}
-		}
-
-		return L"";
-	}
-
-	WString PlatformUtility::keyCodeToUnicode(UINT32 keyCode)
-	{
-		static HKL keyboardLayout = GetKeyboardLayout(0);
-		static UINT8 keyboarState[256];
-
-		if (GetKeyboardState(keyboarState) == FALSE)
-			return 0;
-
-		UINT virtualKey = MapVirtualKeyExW(keyCode, 1, keyboardLayout);
-
-		wchar_t output[2];
-		int count = ToUnicodeEx(virtualKey, keyCode, keyboarState, output, 2, 0, keyboardLayout);
-		if (count > 0)
-			return WString(output, count);
-
-		return StringUtil::WBLANK;
-	}
-
-	bool PlatformUtility::getMACAddress(MACAddress& address)
-	{
-		std::memset(&address, 0, sizeof(address));
-
-		PIP_ADAPTER_INFO adapterInfo = bs_alloc<IP_ADAPTER_INFO>();
-
-		ULONG len = sizeof(IP_ADAPTER_INFO);
-		DWORD rc = GetAdaptersInfo(adapterInfo, &len);
-
-		if (rc == ERROR_BUFFER_OVERFLOW)
-		{
-			bs_free(adapterInfo);
-			adapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(bs_alloc(len));
-		}
-		else if (rc != ERROR_SUCCESS)
-		{
-			bs_free(adapterInfo);
-			return false;
-		}
-
-		if (GetAdaptersInfo(adapterInfo, &len) == NO_ERROR)
-		{
-			PIP_ADAPTER_INFO curAdapter = nullptr;
-			curAdapter = adapterInfo;
-
-			while (curAdapter)
-			{
-				if (curAdapter->Type == MIB_IF_TYPE_ETHERNET && curAdapter->AddressLength == sizeof(address))
-				{
-					std::memcpy(&address, curAdapter->Address, curAdapter->AddressLength);
-					return true;
-				}
-
-				curAdapter = curAdapter->Next;
-			}
-		}
-
-		bs_free(adapterInfo);
-		return false;
-	}
-
-	String PlatformUtility::generateUUID()
-	{
-		UUID uuid;
-		UuidCreate(&uuid);
-
-		UINT8* uuidStr;
-		UuidToStringA(&uuid, &uuidStr);
-
-		String output((char*)uuidStr);
-		RpcStringFreeA(&uuidStr);
-
-		return output;
-	}
-
-	void PlatformUtility::open(const Path& path)
-	{
-		ShellExecute(nullptr, "open", path.toString().c_str(), nullptr, nullptr, SW_SHOWNORMAL);
-	}
+#include "BsPrerequisitesUtil.h"
+#include <windows.h>
+#include <iphlpapi.h>
+
+namespace BansheeEngine
+{
+	void PlatformUtility::terminate(bool force)
+	{
+		if (!force)
+			PostQuitMessage(0);
+		else
+			TerminateProcess(GetCurrentProcess(), 0);
+	}
+
+	double PlatformUtility::queryPerformanceTimerMs()
+	{
+		LARGE_INTEGER counterValue;
+		QueryPerformanceCounter(&counterValue);
+
+		LARGE_INTEGER counterFreq;
+		QueryPerformanceFrequency(&counterFreq);
+
+		return (double)counterValue.QuadPart / (counterFreq.QuadPart * 0.001);
+	}
+
+
+	void PlatformUtility::copyToClipboard(const WString& string)
+	{
+		HANDLE hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (string.size() + 1) * sizeof(WString::value_type));
+		WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
+
+		string.copy(buffer, string.size());
+		buffer[string.size()] = '\0';
+
+		GlobalUnlock(hData);
+
+		if (OpenClipboard(NULL))
+		{
+			EmptyClipboard();
+			SetClipboardData(CF_UNICODETEXT, hData);
+			CloseClipboard();
+		}
+		else
+		{
+			GlobalFree(hData);
+		}
+	}
+
+	WString PlatformUtility::copyFromClipboard()
+	{
+		if (OpenClipboard(NULL))
+		{
+			HANDLE hData = GetClipboardData(CF_UNICODETEXT);
+
+			if (hData != NULL)
+			{
+				WString::value_type* buffer = (WString::value_type*)GlobalLock(hData);
+				WString string(buffer);
+				GlobalUnlock(hData);
+
+				CloseClipboard();
+				return string;
+			}
+			else
+			{
+				CloseClipboard();
+				return L"";
+			}
+		}
+
+		return L"";
+	}
+
+	WString PlatformUtility::keyCodeToUnicode(UINT32 keyCode)
+	{
+		static HKL keyboardLayout = GetKeyboardLayout(0);
+		static UINT8 keyboarState[256];
+
+		if (GetKeyboardState(keyboarState) == FALSE)
+			return 0;
+
+		UINT virtualKey = MapVirtualKeyExW(keyCode, 1, keyboardLayout);
+
+		wchar_t output[2];
+		int count = ToUnicodeEx(virtualKey, keyCode, keyboarState, output, 2, 0, keyboardLayout);
+		if (count > 0)
+			return WString(output, count);
+
+		return StringUtil::WBLANK;
+	}
+
+	bool PlatformUtility::getMACAddress(MACAddress& address)
+	{
+		std::memset(&address, 0, sizeof(address));
+
+		PIP_ADAPTER_INFO adapterInfo = bs_alloc<IP_ADAPTER_INFO>();
+
+		ULONG len = sizeof(IP_ADAPTER_INFO);
+		DWORD rc = GetAdaptersInfo(adapterInfo, &len);
+
+		if (rc == ERROR_BUFFER_OVERFLOW)
+		{
+			bs_free(adapterInfo);
+			adapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(bs_alloc(len));
+		}
+		else if (rc != ERROR_SUCCESS)
+		{
+			bs_free(adapterInfo);
+			return false;
+		}
+
+		if (GetAdaptersInfo(adapterInfo, &len) == NO_ERROR)
+		{
+			PIP_ADAPTER_INFO curAdapter = nullptr;
+			curAdapter = adapterInfo;
+
+			while (curAdapter)
+			{
+				if (curAdapter->Type == MIB_IF_TYPE_ETHERNET && curAdapter->AddressLength == sizeof(address))
+				{
+					std::memcpy(&address, curAdapter->Address, curAdapter->AddressLength);
+					return true;
+				}
+
+				curAdapter = curAdapter->Next;
+			}
+		}
+
+		bs_free(adapterInfo);
+		return false;
+	}
+
+	String PlatformUtility::generateUUID()
+	{
+		UUID uuid;
+		UuidCreate(&uuid);
+
+		UINT8* uuidStr;
+		UuidToStringA(&uuid, &uuidStr);
+
+		String output((char*)uuidStr);
+		RpcStringFreeA(&uuidStr);
+
+		return output;
+	}
+
+	void PlatformUtility::open(const Path& path)
+	{
+		ShellExecute(nullptr, "open", path.toString().c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+	}
 }

+ 504 - 509
ExampleProject/Main/Main.cpp

@@ -1,509 +1,504 @@
-#include <windows.h>
-
-#include "BsApplication.h"
-#include "BsImporter.h"
-#include "BsTextureImportOptions.h"
-#include "BsMaterial.h"
-#include "BsShader.h"
-#include "BsTechnique.h"
-#include "BsPass.h"
-#include "BsCoreThreadAccessor.h"
-#include "BsApplication.h"
-#include "BsVirtualInput.h"
-#include "BsCCamera.h"
-#include "BsCRenderable.h"
-#include "BsCGUIWidget.h"
-#include "BsGUILayoutX.h"
-#include "BsGUILayoutY.h"
-#include "BsGUISpace.h"
-#include "BsGUILabel.h"
-#include "BsGUIButton.h"
-#include "BsGUIListBox.h"
-#include "BsBuiltinResources.h"
-#include "BsRTTIType.h"
-#include "BsHString.h"
-#include "BsRenderWindow.h"
-#include "BsSceneObject.h"
-#include "BsCoreThread.h"
-#include "BsProfilerOverlay.h"
-#include "BsCoreRenderer.h"
-#include "BsResources.h"
-#include "BsGUIPanel.h"
-
-#include "CameraFlyer.h"
-
-namespace BansheeEngine
-{
-	UINT32 windowResWidth = 1280;
-	UINT32 windowResHeight = 720;
-
-	/**
-	 * Imports all of our assets and prepares GameObject that handle the example logic.
-	 */
-	void setUpExample();
-
-	/**
-	 * Import mesh/texture/GPU programs used by the example.
-	 */
-	void importAssets(HMesh& model, HTexture& texture, HShader& shader);
-
-	/**
-	 * Create a material used by our example model.
-	 */
-	HMaterial createMaterial(const HTexture& texture, const HShader& shader);
-
-	/**
-	 * Set up example scene objects.
-	 */
-	void setUp3DScene(const HMesh& mesh, const HMaterial& material);
-
-	/**
-	 * Set up example GUI.
-	 */
-	void setUpGUI();
-
-	/**
-	 * Set up input configuration and callbacks.
-	 */
-	void setUpInput();
-
-	/**
-	 * Toggles the primary window between full-screen and windowed mode.
-	 */
-	void toggleFullscreen();
-
-	/**
-	 * Called whenever the main render window is resized.
-	 */
-	void renderWindowResized();
-
-	/**
-	 * Called when the selected video mode changes in the video mode list box.
-	 */
-	void videoModeChanged(UINT32 idx, bool enabled);
-
-	/**
-	 * Triggered whenever a virtual button is released.
-	 */
-	void buttonUp(const VirtualButton& button, UINT32 deviceIdx);
-}
-
-using namespace BansheeEngine;
-
-/**
- * Main entry point into the application.
- */
-int CALLBACK WinMain(
-	_In_  HINSTANCE hInstance,
-	_In_  HINSTANCE hPrevInstance,
-	_In_  LPSTR lpCmdLine,
-	_In_  int nCmdShow
-	)
-{
-	// Descriptor used for initializing the primary application window.
-	RENDER_WINDOW_DESC renderWindowDesc;
-	renderWindowDesc.videoMode = VideoMode(windowResWidth, windowResHeight);
-	renderWindowDesc.title = "Banshee Example App";
-	renderWindowDesc.fullscreen = false;
-
-	// List of importer plugins we plan on using for importing various resources
-	Vector<String> importers;
-	importers.push_back("BansheeFreeImgImporter"); // For importing textures
-	importers.push_back("BansheeFBXImporter"); // For importing meshes
-	importers.push_back("BansheeFontImporter"); // For importing fonts
-	importers.push_back("BansheeSL"); // For importing shaders
-
-	// Initializes the application with primary window defined as above and DirectX 11 render system.
-	// You may use other render systems than DirectX 11, however this example for simplicity only uses DirectX 11.
-	// If you wanted other render systems you would need to create separate shaders for them and import them
-	// along with (or replace) the DX11 ones.
-	Application::startUp(renderWindowDesc, RenderAPIPlugin::DX11, RendererPlugin::Default, importers);
-
-	// Imports all of ours assets and prepares GameObject that handle the example logic.
-	setUpExample();
-	
-	// Runs the main loop that does most of the work. This method will exit when user closes the main
-	// window or exits in some other way.
-	Application::instance().runMainLoop();
-
-	Application::shutDown();
-
-	return 0;
-}
-
-namespace BansheeEngine
-{
-	Path dataPath = Paths::getRuntimeDataPath();
-	Path exampleModelPath = dataPath + "Examples\\Dragon.fbx";
-	Path exampleTexturePath = dataPath + "Examples\\Dragon.tga";
-	Path exampleShaderPath = dataPath + "Examples\\Example.bsl";
-
-	GUIButton* toggleFullscreenButton = nullptr;
-	bool fullscreen = false;
-
-	const VideoMode* selectedVideoMode = nullptr;
-	Vector<const VideoMode*> videoModes;
-
-	HCamera sceneCamera;
-	HProfilerOverlay profilerOverlay;
-
-	VirtualButton toggleCPUProfilerBtn;
-	VirtualButton toggleGPUProfilerBtn;
-
-	bool cpuProfilerActive = false;
-	bool gpuProfilerActive = false;
-
-	void setUpExample()
-	{
-		HMesh exampleModel;
-		HTexture exampleTexture;
-		HShader exampleShader;
-
-		importAssets(exampleModel, exampleTexture, exampleShader);
-		HMaterial exampleMaterial = createMaterial(exampleTexture, exampleShader);
-
-		setUp3DScene(exampleModel, exampleMaterial);
-		setUpGUI();
-		setUpInput();
-	}
-
-	void importAssets(HMesh& model, HTexture& texture, HShader& shader)
-	{
-		// Import mesh, texture and shader from the disk. In a normal application you would want to save the imported assets
-		// so next time the application is ran you can just load them directly. This can be done with Resources::save/load.
-
-		// Import an FBX mesh.
-		model = Importer::instance().import<Mesh>(exampleModelPath);
-
-		// When importing you may specify optional import options that control how is the asset imported.
-		ImportOptionsPtr textureImportOptions = Importer::instance().createImportOptions(exampleTexturePath);
-
-		// rtti_is_of_type checks if the import options are of valid type, in case the provided path is pointing to a non-texture resource.
-		// This is similar to dynamic_cast but uses Banshee internal RTTI system for type checking.
-		if (rtti_is_of_type<TextureImportOptions>(textureImportOptions))
-		{
-			TextureImportOptions* importOptions = static_cast<TextureImportOptions*>(textureImportOptions.get());
-
-			// We want maximum number of mipmaps to be generated
-			importOptions->setGenerateMipmaps(true);
-		}
-
-		// Import texture with specified import options
-		texture = Importer::instance().import<Texture>(exampleTexturePath, textureImportOptions);
-
-		// Import shader
-		shader = Importer::instance().import<Shader>(exampleShaderPath);
-	}
-
-	HMaterial createMaterial(const HTexture& texture, const HShader& shader)
-	{
-		// And finally create a material with the newly created shader
-		HMaterial exampleMaterial = Material::create(shader);
-
-		// And set the texture to be used by the "tex" shader parameter. We leave the "samp"
-		// parameter at its defaults.
-		exampleMaterial->setTexture("tex", texture);
-
-		return exampleMaterial;
-	}
-
-	void setUp3DScene(const HMesh& mesh, const HMaterial& material)
-	{
-		/************************************************************************/
-		/* 								SCENE OBJECT                      		*/
-		/************************************************************************/
-
-		// Now we create a scene object that has a position, orientation, scale and optionally
-		// components to govern its logic. In this particular case we are creating a SceneObject
-		// with a Renderable component which will render a mesh at the position of the scene object
-		// with the provided material.
-
-		// Create new scene object at (0, 0, 0)
-		HSceneObject dragonSO = SceneObject::create("Dragon");
-
-		// Attach the Renderable component and hook up the mesh we imported earlier,
-		// and the material we created in the previous section.
-		HRenderable renderable = dragonSO->addComponent<CRenderable>();
-		renderable->setMesh(mesh);
-		renderable->setMaterial(material);
-
-		/************************************************************************/
-		/* 									CAMERA	                     		*/
-		/************************************************************************/
-
-		// In order something to render on screen we need at least one camera.
-
-		// Like before, we create a new scene object at (0, 0, 0).
-		HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
-
-		// Get the primary render window we need for creating the camera. Additionally
-		// hook up a callback so we are notified when user resizes the window.
-		RenderWindowPtr window = gApplication().getPrimaryWindow();
-		window->onResized.connect(&renderWindowResized);
-
-		// Add a Camera component that will output whatever it sees into that window 
-		// (You could also use a render texture or another window you created).
-		sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
-
-		// Set up camera component properties
-
-		// Priority determines in what order are cameras rendered in case multiple cameras render to the same render target.
-		// We raise the priority slightly because later in code we have defined a GUI camera that we want to render second.
-		sceneCamera->setPriority(1);
-
-		// Set closest distance that is visible. Anything below that is clipped.
-		sceneCamera->setNearClipDistance(5);
-
-		// Set aspect ratio depending on the current resolution
-		sceneCamera->setAspectRatio(windowResWidth / (float)windowResHeight);
-
-		// Add a CameraFlyer component that allows us to move the camera. See CameraFlyer for more information.
-		sceneCameraSO->addComponent<CameraFlyer>();
-
-		// Position and orient the camera scene object
-		sceneCameraSO->setPosition(Vector3(-130.0f, 140.0f, 650.0f));
-		sceneCameraSO->lookAt(Vector3(0, 0, 0));
-	}
-
-	void setUpInput()
-	{
-		// Register input configuration
-		// Banshee allows you to use VirtualInput system which will map input device buttons
-		// and axes to arbitrary names, which allows you to change input buttons without affecting
-		// the code that uses it, since the code is only aware of the virtual names. 
-		// If you want more direct input, see Input class.
-		auto inputConfig = VirtualInput::instance().getConfiguration();
-
-		// Camera controls for buttons (digital 0-1 input, e.g. keyboard or gamepad button)
-		inputConfig->registerButton("Forward", BC_W);
-		inputConfig->registerButton("Back", BC_S);
-		inputConfig->registerButton("Left", BC_A);
-		inputConfig->registerButton("Right", BC_D);
-		inputConfig->registerButton("Forward", BC_UP);
-		inputConfig->registerButton("Back", BC_BACK);
-		inputConfig->registerButton("Left", BC_LEFT);
-		inputConfig->registerButton("Right", BC_RIGHT);
-		inputConfig->registerButton("FastMove", BC_LSHIFT);
-		inputConfig->registerButton("RotateCam", BC_MOUSE_RIGHT);
-
-		// Camera controls for axes (analog input, e.g. mouse or gamepad thumbstick)
-		// These return values in [-1.0, 1.0] range.
-		inputConfig->registerAxis("Horizontal", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseX));
-		inputConfig->registerAxis("Vertical", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseY));
-
-		// Controls that toggle the profiler overlays
-		inputConfig->registerButton("CPUProfilerOverlay", BC_F1);
-		inputConfig->registerButton("GPUProfilerOverlay", BC_F2);
-
-		// Cache the profiler overlay buttons so when a button is pressed we can quickly
-		// use these to determine its the one we want
-		toggleCPUProfilerBtn = VirtualButton("CPUProfilerOverlay");
-		toggleGPUProfilerBtn = VirtualButton("GPUProfilerOverlay");
-
-		// Hook up a callback that gets triggered whenever a virtual button is released
-		VirtualInput::instance().onButtonUp.connect(&buttonUp);
-	}
-
-	void setUpGUI()
-	{
-		// Create a scene object that will contain GUI components
-		HSceneObject guiSO = SceneObject::create("Example");
-
-		// Get the primary render window we need for creating the camera. 
-		RenderWindowPtr window = gApplication().getPrimaryWindow();
-
-		// First we want another camera that is responsible for rendering GUI
-		HCamera guiCamera = guiSO->addComponent<CCamera>(window);
-
-		// Notify the renderer that the camera will only be used for overlays (e.g. GUI) so it can optimize its usage
-		guiCamera->setFlags(CameraFlags::Overlay);
-
-		// Set up GUI camera properties. 
-		// We don't care about aspect ratio for GUI camera.
-		guiCamera->setAspectRatio(1.0f);
-
-		// This camera should ignore any Renderable objects in the scene
-		guiCamera->setLayers(0);
-
-		// Don't clear this camera as that would clear anything the main camera has rendered.
-		guiCamera->getViewport()->setRequiresClear(false, false, false);
-
-		// Add a GUIWidget, the top-level GUI component, parent to all GUI elements. GUI widgets
-		// require you to specify a viewport that they will output rendered GUI elements to.
-		HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
-
-		// Depth allows you to control how is a GUI widget rendered in relation to other widgets
-		// Lower depth means the widget will be rendered in front of those with higher. In this case we just
-		// make the depth mid-range as there are no other widgets.
-		gui->setDepth(128);
-
-		// GUI skin defines how are all child elements of the GUI widget renderered. It contains all their styles
-		// and default layout properties. We use the default skin that comes built into Banshee.
-		gui->setSkin(BuiltinResources::instance().getGUISkin());
-
-		// Get the primary GUI panel that stretches over the entire window and add to it a vertical layout
-		// that will be using for vertically positioning messages about toggling profiler overlay.
-		GUILayout* bottomLayout = gui->getPanel()->addNewElement<GUILayoutY>();
-
-		// Add a flexible space that fills up any remaining area in the layout, making the two labels above be aligned
-		// to the bottom of the GUI widget (and the screen).
-		bottomLayout->addNewElement<GUIFlexibleSpace>();
-
-		// Add a couple of labels to the layout with the needed messages. Labels expect a HString object that
-		// maps into a string table and allows for easily localization. 
-		bottomLayout->addElement(GUILabel::create(HString(L"Press F1 to toggle CPU profiler overlay")));
-		bottomLayout->addElement(GUILabel::create(HString(L"Press F2 to toggle GPU profiler overlay")));
-
-		// Create a GUI panel that is used for displaying resolution and fullscreen options.
-		GUILayout* rightLayout = gui->getPanel()->addNewElement<GUILayoutX>();
-		rightLayout->setPosition(30, 30);
-
-		// We want all the GUI elements be right aligned, so we add a flexible space first.
-		rightLayout->addNewElement<GUIFlexibleSpace>();
-
-		// And we want the elements to be vertically placed, top to bottom
-		GUILayout* elemLayout = rightLayout->addNewElement<GUILayoutY>();
-
-		// Add a button that will trigger a callback when clicked
-		toggleFullscreenButton = GUIButton::create(HString(L"Toggle fullscreen"));
-		toggleFullscreenButton->onClick.connect(&toggleFullscreen);
-		elemLayout->addElement(toggleFullscreenButton);
-
-		// Leave 30 pixels to the right free
-		rightLayout->addNewElement<GUIFixedSpace>(30);
-
-		// Add a profiler overlay object that is responsible for displaying CPU and GPU profiling GUI
-		profilerOverlay = guiSO->addComponent<ProfilerOverlay>(guiCamera->_getCamera());
-
-		// Set up video mode list box
-		// First get a list of output devices
-		const VideoModeInfo& videoModeInfo = RenderAPI::getVideoModeInfo();
-
-		// Get video mode info for the primary monitor
-		const VideoOutputInfo& primaryMonitorInfo = videoModeInfo.getOutputInfo(0);
-
-		// Make the current desktop mode the default video mode
-		selectedVideoMode = &primaryMonitorInfo.getDesktopVideoMode();
-
-		// Create list box elements for each available video mode
-		UINT32 numVideoModes = primaryMonitorInfo.getNumVideoModes();
-		Vector<HString> videoModeLabels(numVideoModes);
-		UINT32 selectedVideoModeIdx = 0;
-		for (UINT32 i = 0; i < numVideoModes; i++)
-		{
-			const VideoMode& curVideoMode = primaryMonitorInfo.getVideoMode(i);
-
-			HString videoModeLabel(L"{0} x {1} at {2}Hz");
-			videoModeLabel.setParameter(0, toWString(curVideoMode.getWidth()));
-			videoModeLabel.setParameter(1, toWString(curVideoMode.getHeight()));
-			videoModeLabel.setParameter(2, toWString(Math::roundToInt(curVideoMode.getRefreshRate())));
-
-			videoModeLabels[i] = videoModeLabel;
-			videoModes.push_back(&curVideoMode);
-
-			if (curVideoMode == *selectedVideoMode)
-				selectedVideoModeIdx = i;
-		}
-
-		// Create the list box
-		GUIListBox* videoModeListBox = GUIListBox::create(videoModeLabels);
-		rightLayout->addElement(videoModeListBox);
-
-		// Select the default (desktop) video mode
-		videoModeListBox->selectElement(selectedVideoModeIdx);
-
-		// Set up a callback to be notified when video mode changes
-		videoModeListBox->onSelectionToggled.connect(&videoModeChanged);
-	}
-
-	void toggleFullscreen()
-	{
-		RenderWindowPtr window = gApplication().getPrimaryWindow();
-
-		// In order to toggle between full-screen and windowed mode we need to use a CoreAccessor.
-		// Banshee is a multi-threaded engine and when you need to communicate between simulation and
-		// core thread you will use a CoreAccessor. Calling a core accessor method will essentially
-		// queue the method to be executed later. Since RenderWindow is a core object you need to use
-		// CoreAccessor to modify and access it from simulation thread, except where noted otherwise.
-
-		// Classes where it is not clear if they are to be used on the core or simulation thread have
-		// it noted in their documentation. e.g. RenderWindow::setWindowed method is marked as "Core only".
-		// Additional asserts are normally in place for debug builds which make it harder for you to accidentally
-		// call something from the wrong thread.
-		if (fullscreen)
-		{
-			window->setWindowed(gCoreAccessor(), windowResWidth, windowResHeight);
-		}
-		else
-		{
-			window->setFullscreen(gCoreAccessor(), *selectedVideoMode);
-		}
-
-		fullscreen = !fullscreen;
-	}
-
-	void renderWindowResized()
-	{
-		RenderWindowPtr window = gApplication().getPrimaryWindow();
-		const RenderWindowProperties& rwProps = window->getProperties();
-
-		if (!fullscreen)
-		{
-			windowResWidth = rwProps.getWidth();
-			windowResHeight = rwProps.getHeight();
-		}
-
-		sceneCamera->setAspectRatio(rwProps.getWidth() / (float)rwProps.getHeight());
-	}
-
-	void videoModeChanged(UINT32 idx, bool enabled)
-	{
-		if (!enabled)
-			return;
-
-		selectedVideoMode = videoModes[idx];
-
-		if (fullscreen)
-		{
-			RenderWindowPtr window = gApplication().getPrimaryWindow();
-			window->setFullscreen(gCoreAccessor(), *selectedVideoMode);
-		}
-	}
-
-	void buttonUp(const VirtualButton& button, UINT32 deviceIdx)
-	{
-		// Check if the pressed button is one of the either buttons we defined
-		// in "setUpExample", and toggle profiler overlays accordingly.
-		// Device index is ignored for now, as it is assumed the user is using a single keyboard,
-		// but if you wanted support for multiple gamepads you would check deviceIdx.
-		if (button == toggleCPUProfilerBtn)
-		{
-			if (cpuProfilerActive)
-			{
-				profilerOverlay->hide();
-				cpuProfilerActive = false;
-			}
-			else
-			{
-				profilerOverlay->show(ProfilerOverlayType::CPUSamples);
-				cpuProfilerActive = true;
-				gpuProfilerActive = false;
-			}
-		}
-		else if (button == toggleGPUProfilerBtn)
-		{
-			if (gpuProfilerActive)
-			{
-				profilerOverlay->hide();
-				gpuProfilerActive = false;
-			}
-			else
-			{
-				profilerOverlay->show(ProfilerOverlayType::GPUSamples);
-				gpuProfilerActive = true;
-				cpuProfilerActive = false;
-			}
-		}
-	}
-}
-
+#include <windows.h>
+
+#include "BsApplication.h"
+#include "BsImporter.h"
+#include "BsTextureImportOptions.h"
+#include "BsMaterial.h"
+#include "BsShader.h"
+#include "BsVirtualInput.h"
+#include "BsCCamera.h"
+#include "BsCRenderable.h"
+#include "BsCGUIWidget.h"
+#include "BsGUILayoutX.h"
+#include "BsGUILayoutY.h"
+#include "BsGUISpace.h"
+#include "BsGUILabel.h"
+#include "BsGUIButton.h"
+#include "BsGUIPanel.h"
+#include "BsRenderAPI.h"
+#include "BsGUIListBox.h"
+#include "BsBuiltinResources.h"
+#include "BsRTTIType.h"
+#include "BsHString.h"
+#include "BsRenderWindow.h"
+#include "BsSceneObject.h"
+#include "BsCoreThread.h"
+#include "BsProfilerOverlay.h"
+
+#include "CameraFlyer.h"
+
+namespace BansheeEngine
+{
+	UINT32 windowResWidth = 1280;
+	UINT32 windowResHeight = 720;
+
+	/**
+	 * Imports all of our assets and prepares GameObject that handle the example logic.
+	 */
+	void setUpExample();
+
+	/**
+	 * Import mesh/texture/GPU programs used by the example.
+	 */
+	void importAssets(HMesh& model, HTexture& texture, HShader& shader);
+
+	/**
+	 * Create a material used by our example model.
+	 */
+	HMaterial createMaterial(const HTexture& texture, const HShader& shader);
+
+	/**
+	 * Set up example scene objects.
+	 */
+	void setUp3DScene(const HMesh& mesh, const HMaterial& material);
+
+	/**
+	 * Set up example GUI.
+	 */
+	void setUpGUI();
+
+	/**
+	 * Set up input configuration and callbacks.
+	 */
+	void setUpInput();
+
+	/**
+	 * Toggles the primary window between full-screen and windowed mode.
+	 */
+	void toggleFullscreen();
+
+	/**
+	 * Called whenever the main render window is resized.
+	 */
+	void renderWindowResized();
+
+	/**
+	 * Called when the selected video mode changes in the video mode list box.
+	 */
+	void videoModeChanged(UINT32 idx, bool enabled);
+
+	/**
+	 * Triggered whenever a virtual button is released.
+	 */
+	void buttonUp(const VirtualButton& button, UINT32 deviceIdx);
+}
+
+using namespace BansheeEngine;
+
+/**
+ * Main entry point into the application.
+ */
+int CALLBACK WinMain(
+	_In_  HINSTANCE hInstance,
+	_In_  HINSTANCE hPrevInstance,
+	_In_  LPSTR lpCmdLine,
+	_In_  int nCmdShow
+	)
+{
+	// Descriptor used for initializing the primary application window.
+	RENDER_WINDOW_DESC renderWindowDesc;
+	renderWindowDesc.videoMode = VideoMode(windowResWidth, windowResHeight);
+	renderWindowDesc.title = "Banshee Example App";
+	renderWindowDesc.fullscreen = false;
+
+	// List of importer plugins we plan on using for importing various resources
+	Vector<String> importers;
+	importers.push_back("BansheeFreeImgImporter"); // For importing textures
+	importers.push_back("BansheeFBXImporter"); // For importing meshes
+	importers.push_back("BansheeFontImporter"); // For importing fonts
+	importers.push_back("BansheeSL"); // For importing shaders
+
+	// Initializes the application with primary window defined as above and DirectX 11 render system.
+	// You may use other render systems than DirectX 11, however this example for simplicity only uses DirectX 11.
+	// If you wanted other render systems you would need to create separate shaders for them and import them
+	// along with (or replace) the DX11 ones.
+	Application::startUp(renderWindowDesc, RenderAPIPlugin::DX11, RendererPlugin::Default, importers);
+
+	// Imports all of ours assets and prepares GameObject that handle the example logic.
+	setUpExample();
+	
+	// Runs the main loop that does most of the work. This method will exit when user closes the main
+	// window or exits in some other way.
+	Application::instance().runMainLoop();
+
+	Application::shutDown();
+
+	return 0;
+}
+
+namespace BansheeEngine
+{
+	Path dataPath = Paths::getRuntimeDataPath();
+	Path exampleModelPath = dataPath + "Examples\\Dragon.fbx";
+	Path exampleTexturePath = dataPath + "Examples\\Dragon.tga";
+	Path exampleShaderPath = dataPath + "Examples\\Example.bsl";
+
+	GUIButton* toggleFullscreenButton = nullptr;
+	bool fullscreen = false;
+
+	const VideoMode* selectedVideoMode = nullptr;
+	Vector<const VideoMode*> videoModes;
+
+	HCamera sceneCamera;
+	HProfilerOverlay profilerOverlay;
+
+	VirtualButton toggleCPUProfilerBtn;
+	VirtualButton toggleGPUProfilerBtn;
+
+	bool cpuProfilerActive = false;
+	bool gpuProfilerActive = false;
+
+	void setUpExample()
+	{
+		HMesh exampleModel;
+		HTexture exampleTexture;
+		HShader exampleShader;
+
+		importAssets(exampleModel, exampleTexture, exampleShader);
+		HMaterial exampleMaterial = createMaterial(exampleTexture, exampleShader);
+
+		setUp3DScene(exampleModel, exampleMaterial);
+		setUpGUI();
+		setUpInput();
+	}
+
+	void importAssets(HMesh& model, HTexture& texture, HShader& shader)
+	{
+		// Import mesh, texture and shader from the disk. In a normal application you would want to save the imported assets
+		// so next time the application is ran you can just load them directly. This can be done with Resources::save/load.
+
+		// Import an FBX mesh.
+		model = Importer::instance().import<Mesh>(exampleModelPath);
+
+		// When importing you may specify optional import options that control how is the asset imported.
+		ImportOptionsPtr textureImportOptions = Importer::instance().createImportOptions(exampleTexturePath);
+
+		// rtti_is_of_type checks if the import options are of valid type, in case the provided path is pointing to a non-texture resource.
+		// This is similar to dynamic_cast but uses Banshee internal RTTI system for type checking.
+		if (rtti_is_of_type<TextureImportOptions>(textureImportOptions))
+		{
+			TextureImportOptions* importOptions = static_cast<TextureImportOptions*>(textureImportOptions.get());
+
+			// We want maximum number of mipmaps to be generated
+			importOptions->setGenerateMipmaps(true);
+		}
+
+		// Import texture with specified import options
+		texture = Importer::instance().import<Texture>(exampleTexturePath, textureImportOptions);
+
+		// Import shader
+		shader = Importer::instance().import<Shader>(exampleShaderPath);
+	}
+
+	HMaterial createMaterial(const HTexture& texture, const HShader& shader)
+	{
+		// And finally create a material with the newly created shader
+		HMaterial exampleMaterial = Material::create(shader);
+
+		// And set the texture to be used by the "tex" shader parameter. We leave the "samp"
+		// parameter at its defaults.
+		exampleMaterial->setTexture("tex", texture);
+
+		return exampleMaterial;
+	}
+
+	void setUp3DScene(const HMesh& mesh, const HMaterial& material)
+	{
+		/************************************************************************/
+		/* 								SCENE OBJECT                      		*/
+		/************************************************************************/
+
+		// Now we create a scene object that has a position, orientation, scale and optionally
+		// components to govern its logic. In this particular case we are creating a SceneObject
+		// with a Renderable component which will render a mesh at the position of the scene object
+		// with the provided material.
+
+		// Create new scene object at (0, 0, 0)
+		HSceneObject dragonSO = SceneObject::create("Dragon");
+
+		// Attach the Renderable component and hook up the mesh we imported earlier,
+		// and the material we created in the previous section.
+		HRenderable renderable = dragonSO->addComponent<CRenderable>();
+		renderable->setMesh(mesh);
+		renderable->setMaterial(material);
+
+		/************************************************************************/
+		/* 									CAMERA	                     		*/
+		/************************************************************************/
+
+		// In order something to render on screen we need at least one camera.
+
+		// Like before, we create a new scene object at (0, 0, 0).
+		HSceneObject sceneCameraSO = SceneObject::create("SceneCamera");
+
+		// Get the primary render window we need for creating the camera. Additionally
+		// hook up a callback so we are notified when user resizes the window.
+		RenderWindowPtr window = gApplication().getPrimaryWindow();
+		window->onResized.connect(&renderWindowResized);
+
+		// Add a Camera component that will output whatever it sees into that window 
+		// (You could also use a render texture or another window you created).
+		sceneCamera = sceneCameraSO->addComponent<CCamera>(window);
+
+		// Set up camera component properties
+
+		// Priority determines in what order are cameras rendered in case multiple cameras render to the same render target.
+		// We raise the priority slightly because later in code we have defined a GUI camera that we want to render second.
+		sceneCamera->setPriority(1);
+
+		// Set closest distance that is visible. Anything below that is clipped.
+		sceneCamera->setNearClipDistance(5);
+
+		// Set aspect ratio depending on the current resolution
+		sceneCamera->setAspectRatio(windowResWidth / (float)windowResHeight);
+
+		// Add a CameraFlyer component that allows us to move the camera. See CameraFlyer for more information.
+		sceneCameraSO->addComponent<CameraFlyer>();
+
+		// Position and orient the camera scene object
+		sceneCameraSO->setPosition(Vector3(-130.0f, 140.0f, 650.0f));
+		sceneCameraSO->lookAt(Vector3(0, 0, 0));
+	}
+
+	void setUpInput()
+	{
+		// Register input configuration
+		// Banshee allows you to use VirtualInput system which will map input device buttons
+		// and axes to arbitrary names, which allows you to change input buttons without affecting
+		// the code that uses it, since the code is only aware of the virtual names. 
+		// If you want more direct input, see Input class.
+		auto inputConfig = VirtualInput::instance().getConfiguration();
+
+		// Camera controls for buttons (digital 0-1 input, e.g. keyboard or gamepad button)
+		inputConfig->registerButton("Forward", BC_W);
+		inputConfig->registerButton("Back", BC_S);
+		inputConfig->registerButton("Left", BC_A);
+		inputConfig->registerButton("Right", BC_D);
+		inputConfig->registerButton("Forward", BC_UP);
+		inputConfig->registerButton("Back", BC_BACK);
+		inputConfig->registerButton("Left", BC_LEFT);
+		inputConfig->registerButton("Right", BC_RIGHT);
+		inputConfig->registerButton("FastMove", BC_LSHIFT);
+		inputConfig->registerButton("RotateCam", BC_MOUSE_RIGHT);
+
+		// Camera controls for axes (analog input, e.g. mouse or gamepad thumbstick)
+		// These return values in [-1.0, 1.0] range.
+		inputConfig->registerAxis("Horizontal", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseX));
+		inputConfig->registerAxis("Vertical", VIRTUAL_AXIS_DESC((UINT32)InputAxis::MouseY));
+
+		// Controls that toggle the profiler overlays
+		inputConfig->registerButton("CPUProfilerOverlay", BC_F1);
+		inputConfig->registerButton("GPUProfilerOverlay", BC_F2);
+
+		// Cache the profiler overlay buttons so when a button is pressed we can quickly
+		// use these to determine its the one we want
+		toggleCPUProfilerBtn = VirtualButton("CPUProfilerOverlay");
+		toggleGPUProfilerBtn = VirtualButton("GPUProfilerOverlay");
+
+		// Hook up a callback that gets triggered whenever a virtual button is released
+		VirtualInput::instance().onButtonUp.connect(&buttonUp);
+	}
+
+	void setUpGUI()
+	{
+		// Create a scene object that will contain GUI components
+		HSceneObject guiSO = SceneObject::create("Example");
+
+		// Get the primary render window we need for creating the camera. 
+		RenderWindowPtr window = gApplication().getPrimaryWindow();
+
+		// First we want another camera that is responsible for rendering GUI
+		HCamera guiCamera = guiSO->addComponent<CCamera>(window);
+
+		// Notify the renderer that the camera will only be used for overlays (e.g. GUI) so it can optimize its usage
+		guiCamera->setFlags(CameraFlags::Overlay);
+
+		// Set up GUI camera properties. 
+		// We don't care about aspect ratio for GUI camera.
+		guiCamera->setAspectRatio(1.0f);
+
+		// This camera should ignore any Renderable objects in the scene
+		guiCamera->setLayers(0);
+
+		// Don't clear this camera as that would clear anything the main camera has rendered.
+		guiCamera->getViewport()->setRequiresClear(false, false, false);
+
+		// Add a GUIWidget, the top-level GUI component, parent to all GUI elements. GUI widgets
+		// require you to specify a viewport that they will output rendered GUI elements to.
+		HGUIWidget gui = guiSO->addComponent<CGUIWidget>(guiCamera);
+
+		// Depth allows you to control how is a GUI widget rendered in relation to other widgets
+		// Lower depth means the widget will be rendered in front of those with higher. In this case we just
+		// make the depth mid-range as there are no other widgets.
+		gui->setDepth(128);
+
+		// GUI skin defines how are all child elements of the GUI widget renderered. It contains all their styles
+		// and default layout properties. We use the default skin that comes built into Banshee.
+		gui->setSkin(BuiltinResources::instance().getGUISkin());
+
+		// Get the primary GUI panel that stretches over the entire window and add to it a vertical layout
+		// that will be using for vertically positioning messages about toggling profiler overlay.
+		GUILayout* bottomLayout = gui->getPanel()->addNewElement<GUILayoutY>();
+
+		// Add a flexible space that fills up any remaining area in the layout, making the two labels above be aligned
+		// to the bottom of the GUI widget (and the screen).
+		bottomLayout->addNewElement<GUIFlexibleSpace>();
+
+		// Add a couple of labels to the layout with the needed messages. Labels expect a HString object that
+		// maps into a string table and allows for easily localization. 
+		bottomLayout->addElement(GUILabel::create(HString(L"Press F1 to toggle CPU profiler overlay")));
+		bottomLayout->addElement(GUILabel::create(HString(L"Press F2 to toggle GPU profiler overlay")));
+
+		// Create a GUI panel that is used for displaying resolution and fullscreen options.
+		GUILayout* rightLayout = gui->getPanel()->addNewElement<GUILayoutX>();
+		rightLayout->setPosition(30, 30);
+
+		// We want all the GUI elements be right aligned, so we add a flexible space first.
+		rightLayout->addNewElement<GUIFlexibleSpace>();
+
+		// And we want the elements to be vertically placed, top to bottom
+		GUILayout* elemLayout = rightLayout->addNewElement<GUILayoutY>();
+
+		// Add a button that will trigger a callback when clicked
+		toggleFullscreenButton = GUIButton::create(HString(L"Toggle fullscreen"));
+		toggleFullscreenButton->onClick.connect(&toggleFullscreen);
+		elemLayout->addElement(toggleFullscreenButton);
+
+		// Leave 30 pixels to the right free
+		rightLayout->addNewElement<GUIFixedSpace>(30);
+
+		// Add a profiler overlay object that is responsible for displaying CPU and GPU profiling GUI
+		profilerOverlay = guiSO->addComponent<ProfilerOverlay>(guiCamera->_getCamera());
+
+		// Set up video mode list box
+		// First get a list of output devices
+		const VideoModeInfo& videoModeInfo = RenderAPI::getVideoModeInfo();
+
+		// Get video mode info for the primary monitor
+		const VideoOutputInfo& primaryMonitorInfo = videoModeInfo.getOutputInfo(0);
+
+		// Make the current desktop mode the default video mode
+		selectedVideoMode = &primaryMonitorInfo.getDesktopVideoMode();
+
+		// Create list box elements for each available video mode
+		UINT32 numVideoModes = primaryMonitorInfo.getNumVideoModes();
+		Vector<HString> videoModeLabels(numVideoModes);
+		UINT32 selectedVideoModeIdx = 0;
+		for (UINT32 i = 0; i < numVideoModes; i++)
+		{
+			const VideoMode& curVideoMode = primaryMonitorInfo.getVideoMode(i);
+
+			HString videoModeLabel(L"{0} x {1} at {2}Hz");
+			videoModeLabel.setParameter(0, toWString(curVideoMode.getWidth()));
+			videoModeLabel.setParameter(1, toWString(curVideoMode.getHeight()));
+			videoModeLabel.setParameter(2, toWString(Math::roundToInt(curVideoMode.getRefreshRate())));
+
+			videoModeLabels[i] = videoModeLabel;
+			videoModes.push_back(&curVideoMode);
+
+			if (curVideoMode == *selectedVideoMode)
+				selectedVideoModeIdx = i;
+		}
+
+		// Create the list box
+		GUIListBox* videoModeListBox = GUIListBox::create(videoModeLabels);
+		rightLayout->addElement(videoModeListBox);
+
+		// Select the default (desktop) video mode
+		videoModeListBox->selectElement(selectedVideoModeIdx);
+
+		// Set up a callback to be notified when video mode changes
+		videoModeListBox->onSelectionToggled.connect(&videoModeChanged);
+	}
+
+	void toggleFullscreen()
+	{
+		RenderWindowPtr window = gApplication().getPrimaryWindow();
+
+		// In order to toggle between full-screen and windowed mode we need to use a CoreAccessor.
+		// Banshee is a multi-threaded engine and when you need to communicate between simulation and
+		// core thread you will use a CoreAccessor. Calling a core accessor method will essentially
+		// queue the method to be executed later. Since RenderWindow is a core object you need to use
+		// CoreAccessor to modify and access it from simulation thread, except where noted otherwise.
+
+		// Classes where it is not clear if they are to be used on the core or simulation thread have
+		// it noted in their documentation. e.g. RenderWindow::setWindowed method is marked as "Core only".
+		// Additional asserts are normally in place for debug builds which make it harder for you to accidentally
+		// call something from the wrong thread.
+		if (fullscreen)
+		{
+			window->setWindowed(gCoreAccessor(), windowResWidth, windowResHeight);
+		}
+		else
+		{
+			window->setFullscreen(gCoreAccessor(), *selectedVideoMode);
+		}
+
+		fullscreen = !fullscreen;
+	}
+
+	void renderWindowResized()
+	{
+		RenderWindowPtr window = gApplication().getPrimaryWindow();
+		const RenderWindowProperties& rwProps = window->getProperties();
+
+		if (!fullscreen)
+		{
+			windowResWidth = rwProps.getWidth();
+			windowResHeight = rwProps.getHeight();
+		}
+
+		sceneCamera->setAspectRatio(rwProps.getWidth() / (float)rwProps.getHeight());
+	}
+
+	void videoModeChanged(UINT32 idx, bool enabled)
+	{
+		if (!enabled)
+			return;
+
+		selectedVideoMode = videoModes[idx];
+
+		if (fullscreen)
+		{
+			RenderWindowPtr window = gApplication().getPrimaryWindow();
+			window->setFullscreen(gCoreAccessor(), *selectedVideoMode);
+		}
+	}
+
+	void buttonUp(const VirtualButton& button, UINT32 deviceIdx)
+	{
+		// Check if the pressed button is one of the either buttons we defined
+		// in "setUpExample", and toggle profiler overlays accordingly.
+		// Device index is ignored for now, as it is assumed the user is using a single keyboard,
+		// but if you wanted support for multiple gamepads you would check deviceIdx.
+		if (button == toggleCPUProfilerBtn)
+		{
+			if (cpuProfilerActive)
+			{
+				profilerOverlay->hide();
+				cpuProfilerActive = false;
+			}
+			else
+			{
+				profilerOverlay->show(ProfilerOverlayType::CPUSamples);
+				cpuProfilerActive = true;
+				gpuProfilerActive = false;
+			}
+		}
+		else if (button == toggleGPUProfilerBtn)
+		{
+			if (gpuProfilerActive)
+			{
+				profilerOverlay->hide();
+				gpuProfilerActive = false;
+			}
+			else
+			{
+				profilerOverlay->show(ProfilerOverlayType::GPUSamples);
+				gpuProfilerActive = true;
+				cpuProfilerActive = false;
+			}
+		}
+	}
+}
+

+ 5 - 4
MBansheeEngine/GUI/GUI.cs

@@ -10,14 +10,18 @@ namespace BansheeEngine
     /// </summary>
     public static class GUI
     {
+        private static GUISkin skin;
+
         /// <summary>
         /// Skin used for rendering all the GUI elements.
         /// </summary>
         public static GUISkin Skin
         {
-            get { return Internal_GetSkin(); }
+            get { return skin; }
             set
             {
+                skin = value;
+
                 IntPtr skinPtr = IntPtr.Zero;
                 if (value != null)
                     skinPtr = value.GetCachedPtr();
@@ -34,9 +38,6 @@ namespace BansheeEngine
             get { return Internal_GetPanel(); }
         }
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern GUISkin Internal_GetSkin();
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetSkin(IntPtr skin);
 

+ 10 - 2
MBansheeEngine/GUI/GUIWidget.cs

@@ -16,7 +16,7 @@
         /// </summary>
         internal GUISkin Skin
         {
-            get { return nativeGUIWidget.Skin; }
+            get { return serializableData.skin; }
             set
             {
                 serializableData.skin = value;
@@ -30,7 +30,7 @@
         /// </summary>
         internal Camera Camera
         {
-            get { return nativeGUIWidget.Camera; }
+            get { return serializableData.camera; }
             set
             {
                 serializableData.camera = value;
@@ -58,6 +58,14 @@
             nativeGUIWidget.Camera = serializableData.camera;
         }
 
+        private void OnUpdate()
+        {
+            nativeGUIWidget.UpdateTransform(SceneObject);
+
+            if (serializableData.camera == null)
+                nativeGUIWidget.UpdateMainCamera(Scene.Camera);
+        }
+
         private void OnDestroy()
         {
             nativeGUIWidget.Destroy();

+ 39 - 6
MBansheeEngine/NativeGUIWidget.cs

@@ -14,7 +14,6 @@ namespace BansheeEngine
         /// </summary>
         internal GUISkin Skin
         {
-            get { return Internal_GetSkin(mCachedPtr); }
             set
             {
                 IntPtr skinPtr = IntPtr.Zero;
@@ -31,12 +30,11 @@ namespace BansheeEngine
         /// </summary>
         internal Camera Camera
         {
-            get { return Internal_GetCamera(mCachedPtr); }
             set
             {
                 IntPtr cameraPtr = IntPtr.Zero;
                 if (value != null)
-                    cameraPtr = value.GetCachedPtr();
+                    cameraPtr = value.Native.GetCachedPtr();
 
                 Internal_SetCamera(mCachedPtr, cameraPtr);
             }
@@ -50,6 +48,38 @@ namespace BansheeEngine
             get { return Internal_GetPanel(mCachedPtr); }
         }
 
+        /// <summary>
+        /// Creates a new native GUI widget and its wrapper.
+        /// </summary>
+        internal NativeGUIWidget()
+        {
+            Internal_Create(this);
+        }
+
+        /// <summary>
+        /// Updates the transform of the GUI widget with the latest transform from the parent SceneObject.
+        /// </summary>
+        /// <param name="parentSO">Scene object the GUI widget component is attached to.</param>
+        internal void UpdateTransform(SceneObject parentSO)
+        {
+            if (parentSO != null)
+                Internal_UpdateTransform(mCachedPtr, parentSO.GetCachedPtr());
+        }
+
+        /// <summary>
+        /// Updates the main camera, in case it changes. This is only relevant if the GUI widget is not rendering to a
+        /// specific camera.
+        /// </summary>
+        /// <param name="camera">New main camera.</param>
+        internal void UpdateMainCamera(Camera camera)
+        {
+            IntPtr cameraPtr = IntPtr.Zero;
+            if (camera != null)
+                cameraPtr = camera.Native.GetCachedPtr();
+
+            Internal_UpdateMainCamera(mCachedPtr, cameraPtr);
+        }
+
         /// <summary>
         /// Deletes the GUI widget and all child GUI elements.
         /// </summary>
@@ -59,13 +89,16 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern GUISkin Internal_GetSkin(IntPtr instance);
+        private static extern void Internal_Create(NativeGUIWidget instance);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetSkin(IntPtr instance, IntPtr skin);
+        private static extern void Internal_UpdateTransform(IntPtr instance, IntPtr parentSO);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern Camera Internal_GetCamera(IntPtr instance);
+        private static extern void Internal_UpdateMainCamera(IntPtr instance, IntPtr camera);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetSkin(IntPtr instance, IntPtr skin);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetCamera(IntPtr instance, IntPtr camera);

+ 67 - 71
RenderBeast/RenderBeast.vcxproj.filters

@@ -1,72 +1,68 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="Include\BsRenderTexturePool.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderBeastOptions.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsSamplerOverrides.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderBeast.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderBeastFactory.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderBeastPrerequisites.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsRenderTargets.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsStaticRenderableHandler.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Include\BsLightRendering.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="Source\BsRenderTexturePool.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsSamplerOverrides.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRenderBeast.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRenderBeastFactory.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRenderBeastPlugin.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsRenderTargets.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsStaticRenderableHandler.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source\BsLightRendering.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="Include\BsRenderTexturePool.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderBeastOptions.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsSamplerOverrides.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderBeast.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderBeastFactory.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderBeastPrerequisites.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsRenderTargets.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsStaticRenderableHandler.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsLightRendering.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="Source\BsRenderTexturePool.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsSamplerOverrides.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRenderBeast.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRenderBeastFactory.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRenderBeastPlugin.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsRenderTargets.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsStaticRenderableHandler.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsLightRendering.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
 </Project>

+ 0 - 4
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
       <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
     </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsScriptEditorPrerequisites.h">

+ 302 - 305
SBansheeEditor/Source/BsGUIGameObjectField.cpp

@@ -1,306 +1,303 @@
-#include "BsGUIGameObjectField.h"
-#include "BsGUILayoutX.h"
-#include "BsGUILabel.h"
-#include "BsGUIDropButton.h"
-#include "BsGUIButton.h"
-#include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
-#include "BsGUISceneTreeView.h"
-#include "BsCGUIWidget.h"
-#include "BsGameObjectManager.h"
-#include "BsScriptAssemblyManager.h"
-#include "BsMonoClass.h"
-#include "BsSceneObject.h"
-#include "BsManagedComponent.h"
-#include "BsMonoManager.h"
-#include "BsBuiltinEditorResources.h"
-#include "BsComponent.h"
-#include "BsSelection.h"
-
-using namespace std::placeholders;
-
-namespace BansheeEngine
-{
-	const UINT32 GUIGameObjectField::DEFAULT_LABEL_WIDTH = 100;
-
-	GUIGameObjectField::GUIGameObjectField(const PrivatelyConstruct& dummy, const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style, const GUIDimensions& dimensions, bool withLabel)
-		:GUIElementContainer(dimensions, style), mLabel(nullptr), mClearButton(nullptr), mDropButton(nullptr), mInstanceId(0), mType(type), mNamespace(typeNamespace)
-	{
-		mLayout = GUILayoutX::create();
-		_registerChildElement(mLayout);
-
-		if(withLabel)
-		{
-			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(BuiltinEditorResources::ObjectFieldLabelStyleName));
-			mLayout->addElement(mLabel);
-		}
-
-		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::SceneObject, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(BuiltinEditorResources::ObjectFieldDropBtnStyleName));
-		mClearButton = GUIButton::create(HString(L""), getSubStyleName(BuiltinEditorResources::ObjectFieldClearBtnStyleName));
-		mClearButton->onClick.connect(std::bind(&GUIGameObjectField::onClearButtonClicked, this));
-
-		mLayout->addElement(mDropButton);
-		mLayout->addElement(mClearButton);
-
-		mDropButton->onDataDropped.connect(std::bind(&GUIGameObjectField::dataDropped, this, _1));
-		mDropButton->onClick.connect(std::bind(&GUIGameObjectField::onDropButtonClicked, this));
-	}
-
-	GUIGameObjectField::~GUIGameObjectField()
-	{
-
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, const GUIOptions& options,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(options), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIOptions& options, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(options), false);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText,
-		const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
-			GUIDimensions::create(), true);
-	}
-
-	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const String& style)
-	{
-		const String* curStyle = &style;
-		if (*curStyle == StringUtil::BLANK)
-			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
-
-		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
-			GUIDimensions::create(), false);
-	}
-
-	HGameObject GUIGameObjectField::getValue() const
-	{
-		HGameObject obj;
-
-		if(mInstanceId != 0)
-			GameObjectManager::instance().tryGetObject(mInstanceId, obj);
-
-		return obj;
-	}
-
-	void GUIGameObjectField::setValue(const HGameObject& value)
-	{
-		setValue(value, false);
-	}
-
-	void GUIGameObjectField::setValue(const HGameObject& value, bool triggerEvent)
-	{
-		if (value)
-		{
-			if (mInstanceId == value.getInstanceId())
-				return;
-
-			mInstanceId = value->getInstanceId();
-			mDropButton->setContent(GUIContent(HString(toWString(value->getName()) + L" (" + toWString(mType) + L")")));
-		}
-		else
-		{
-			if (mInstanceId == 0)
-				return;
-
-			mInstanceId = 0;
-			mDropButton->setContent(GUIContent(HString(L"None (" + toWString(mType) + L")")));
-		}
-
-		if (triggerEvent)
-			onValueChanged(value);
-	}
-
-	void GUIGameObjectField::setTint(const Color& color)
-	{
-		if (mLabel != nullptr)
-			mLabel->setTint(color);
-
-		mDropButton->setTint(color);
-		mClearButton->setTint(color);
-	}
-
-	void GUIGameObjectField::_updateLayoutInternal(const GUILayoutData& data)
-	{
-		mLayout->_setLayoutData(data);
-		mLayout->_updateLayoutInternal(data);
-	}
-
-	Vector2I GUIGameObjectField::_getOptimalSize() const
-	{
-		return mLayout->_getOptimalSize();
-	}
-
-	void GUIGameObjectField::onDropButtonClicked()
-	{
-		if (mInstanceId == 0)
-			return;
-
-		HGameObject go;
-		if (GameObjectManager::instance().tryGetObject(mInstanceId, go))
-		{
-			HSceneObject so;
-			if (rtti_is_of_type<SceneObject>(go.get()))
-			{
-				so = static_object_cast<SceneObject>(go);
-			}
-			else if(rtti_is_subclass<Component>(go.get()))
-			{
-				HComponent component = static_object_cast<Component>(go);
-				so = component->SO();
-			}
-
-			Selection::instance().ping(so);
-		}
-	}
-
-	void GUIGameObjectField::dataDropped(void* data)
-	{
-		DraggedSceneObjects* draggedSceneObjects = reinterpret_cast<DraggedSceneObjects*>(data);
-
-		if (draggedSceneObjects->numObjects <= 0)
-			return;
-
-		MonoClass* sceneObjectClass = ScriptAssemblyManager::instance().getSceneObjectClass();
-
-		if (mType == sceneObjectClass->getFullName()) // A scene object
-		{
-			setValue(draggedSceneObjects->objects[0], true);
-		}
-		else // A component
-		{
-			for (UINT32 i = 0; i < draggedSceneObjects->numObjects; i++)
-			{
-				HSceneObject so = draggedSceneObjects->objects[i];
-
-				const Vector<HComponent>& components = so->getComponents();
-				for (auto& component : components)
-				{
-					if (component->getTypeId() == TID_ManagedComponent) // We only care about managed components
-					{
-						HManagedComponent managedComponent = static_object_cast<ManagedComponent>(component);
-
-						MonoClass* acceptedClass = MonoManager::instance().findClass(mNamespace, mType);
-						MonoClass* providedClass = MonoManager::instance().findClass(managedComponent->getManagedNamespace(), managedComponent->getManagedTypeName());
-
-						if (acceptedClass != nullptr && providedClass != nullptr)
-						{
-							if (providedClass->isSubClassOf(acceptedClass))
-							{
-								setValue(managedComponent, true);
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-
-	void GUIGameObjectField::styleUpdated()
-	{
-		if (mLabel != nullptr)
-			mLabel->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldLabelStyleName));
-
-		mDropButton->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldDropBtnStyleName));
-		mClearButton->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldClearBtnStyleName));
-	}
-
-	void GUIGameObjectField::onClearButtonClicked()
-	{
-		setValue(HGameObject(), true);
-	}
-
-	const String& GUIGameObjectField::getGUITypeName()
-	{
-		static String typeName = "GUIGameObjectField";
-		return typeName;
-	}
+#include "BsGUIGameObjectField.h"
+#include "BsGUILayoutX.h"
+#include "BsGUILabel.h"
+#include "BsGUIDropButton.h"
+#include "BsGUIButton.h"
+#include "BsBuiltinResources.h"
+#include "BsGUISceneTreeView.h"
+#include "BsGameObjectManager.h"
+#include "BsScriptAssemblyManager.h"
+#include "BsMonoClass.h"
+#include "BsSceneObject.h"
+#include "BsManagedComponent.h"
+#include "BsMonoManager.h"
+#include "BsBuiltinEditorResources.h"
+#include "BsComponent.h"
+#include "BsSelection.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	const UINT32 GUIGameObjectField::DEFAULT_LABEL_WIDTH = 100;
+
+	GUIGameObjectField::GUIGameObjectField(const PrivatelyConstruct& dummy, const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
+		const String& style, const GUIDimensions& dimensions, bool withLabel)
+		:GUIElementContainer(dimensions, style), mLabel(nullptr), mClearButton(nullptr), mDropButton(nullptr), mInstanceId(0), mType(type), mNamespace(typeNamespace)
+	{
+		mLayout = GUILayoutX::create();
+		_registerChildElement(mLayout);
+
+		if(withLabel)
+		{
+			mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(BuiltinEditorResources::ObjectFieldLabelStyleName));
+			mLayout->addElement(mLabel);
+		}
+
+		mDropButton = GUIDropButton::create((UINT32)DragAndDropType::SceneObject, GUIOptions(GUIOption::flexibleWidth()), getSubStyleName(BuiltinEditorResources::ObjectFieldDropBtnStyleName));
+		mClearButton = GUIButton::create(HString(L""), getSubStyleName(BuiltinEditorResources::ObjectFieldClearBtnStyleName));
+		mClearButton->onClick.connect(std::bind(&GUIGameObjectField::onClearButtonClicked, this));
+
+		mLayout->addElement(mDropButton);
+		mLayout->addElement(mClearButton);
+
+		mDropButton->onDataDropped.connect(std::bind(&GUIGameObjectField::dataDropped, this, _1));
+		mDropButton->onClick.connect(std::bind(&GUIGameObjectField::onDropButtonClicked, this));
+	}
+
+	GUIGameObjectField::~GUIGameObjectField()
+	{
+
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth, const GUIOptions& options,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, const GUIOptions& options,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth, const GUIOptions& options,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, const GUIOptions& options,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(options), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIOptions& options, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
+			GUIDimensions::create(options), false);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent, UINT32 labelWidth,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, labelWidth, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const GUIContent& labelContent,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, labelContent, DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText, UINT32 labelWidth,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), labelWidth, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const HString& labelText,
+		const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(labelText), DEFAULT_LABEL_WIDTH, *curStyle,
+			GUIDimensions::create(), true);
+	}
+
+	GUIGameObjectField* GUIGameObjectField::create(const String& typeNamespace, const String& type, const String& style)
+	{
+		const String* curStyle = &style;
+		if (*curStyle == StringUtil::BLANK)
+			curStyle = &BuiltinEditorResources::ObjectFieldStyleName;
+
+		return bs_new<GUIGameObjectField>(PrivatelyConstruct(), typeNamespace, type, GUIContent(), 0, *curStyle,
+			GUIDimensions::create(), false);
+	}
+
+	HGameObject GUIGameObjectField::getValue() const
+	{
+		HGameObject obj;
+
+		if(mInstanceId != 0)
+			GameObjectManager::instance().tryGetObject(mInstanceId, obj);
+
+		return obj;
+	}
+
+	void GUIGameObjectField::setValue(const HGameObject& value)
+	{
+		setValue(value, false);
+	}
+
+	void GUIGameObjectField::setValue(const HGameObject& value, bool triggerEvent)
+	{
+		if (value)
+		{
+			if (mInstanceId == value.getInstanceId())
+				return;
+
+			mInstanceId = value->getInstanceId();
+			mDropButton->setContent(GUIContent(HString(toWString(value->getName()) + L" (" + toWString(mType) + L")")));
+		}
+		else
+		{
+			if (mInstanceId == 0)
+				return;
+
+			mInstanceId = 0;
+			mDropButton->setContent(GUIContent(HString(L"None (" + toWString(mType) + L")")));
+		}
+
+		if (triggerEvent)
+			onValueChanged(value);
+	}
+
+	void GUIGameObjectField::setTint(const Color& color)
+	{
+		if (mLabel != nullptr)
+			mLabel->setTint(color);
+
+		mDropButton->setTint(color);
+		mClearButton->setTint(color);
+	}
+
+	void GUIGameObjectField::_updateLayoutInternal(const GUILayoutData& data)
+	{
+		mLayout->_setLayoutData(data);
+		mLayout->_updateLayoutInternal(data);
+	}
+
+	Vector2I GUIGameObjectField::_getOptimalSize() const
+	{
+		return mLayout->_getOptimalSize();
+	}
+
+	void GUIGameObjectField::onDropButtonClicked()
+	{
+		if (mInstanceId == 0)
+			return;
+
+		HGameObject go;
+		if (GameObjectManager::instance().tryGetObject(mInstanceId, go))
+		{
+			HSceneObject so;
+			if (rtti_is_of_type<SceneObject>(go.get()))
+			{
+				so = static_object_cast<SceneObject>(go);
+			}
+			else if(rtti_is_subclass<Component>(go.get()))
+			{
+				HComponent component = static_object_cast<Component>(go);
+				so = component->SO();
+			}
+
+			Selection::instance().ping(so);
+		}
+	}
+
+	void GUIGameObjectField::dataDropped(void* data)
+	{
+		DraggedSceneObjects* draggedSceneObjects = reinterpret_cast<DraggedSceneObjects*>(data);
+
+		if (draggedSceneObjects->numObjects <= 0)
+			return;
+
+		MonoClass* sceneObjectClass = ScriptAssemblyManager::instance().getSceneObjectClass();
+
+		if (mType == sceneObjectClass->getFullName()) // A scene object
+		{
+			setValue(draggedSceneObjects->objects[0], true);
+		}
+		else // A component
+		{
+			for (UINT32 i = 0; i < draggedSceneObjects->numObjects; i++)
+			{
+				HSceneObject so = draggedSceneObjects->objects[i];
+
+				const Vector<HComponent>& components = so->getComponents();
+				for (auto& component : components)
+				{
+					if (component->getTypeId() == TID_ManagedComponent) // We only care about managed components
+					{
+						HManagedComponent managedComponent = static_object_cast<ManagedComponent>(component);
+
+						MonoClass* acceptedClass = MonoManager::instance().findClass(mNamespace, mType);
+						MonoClass* providedClass = MonoManager::instance().findClass(managedComponent->getManagedNamespace(), managedComponent->getManagedTypeName());
+
+						if (acceptedClass != nullptr && providedClass != nullptr)
+						{
+							if (providedClass->isSubClassOf(acceptedClass))
+							{
+								setValue(managedComponent, true);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+
+	void GUIGameObjectField::styleUpdated()
+	{
+		if (mLabel != nullptr)
+			mLabel->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldLabelStyleName));
+
+		mDropButton->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldDropBtnStyleName));
+		mClearButton->setStyle(getSubStyleName(BuiltinEditorResources::ObjectFieldClearBtnStyleName));
+	}
+
+	void GUIGameObjectField::onClearButtonClicked()
+	{
+		setValue(HGameObject(), true);
+	}
+
+	const String& GUIGameObjectField::getGUITypeName()
+	{
+		static String typeName = "GUIGameObjectField";
+		return typeName;
+	}
 }

+ 0 - 5
SBansheeEditor/Source/BsGUIResourceField.cpp

@@ -4,12 +4,7 @@
 #include "BsGUIDropButton.h"
 #include "BsGUIButton.h"
 #include "BsBuiltinResources.h"
-#include "BsCGUIWidget.h"
-#include "BsGUIMouseEvent.h"
 #include "BsGUIResourceTreeView.h"
-#include "BsCGUIWidget.h"
-#include "BsGameObjectManager.h"
-#include "BsScriptAssemblyManager.h"
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
 #include "BsResources.h"

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio