Browse Source

WIP changing all uses of GUIArea to GUIPanel

Marko Pintera 10 years ago
parent
commit
36dd4706af

+ 1 - 1
BansheeEditor/Include/BsEditorWidget.h

@@ -54,7 +54,7 @@ namespace BansheeEngine
 		EditorWidgetContainer* mParent;
 		INT32 mX, mY;
 		UINT32 mWidth, mHeight;
-		GUIArea* mContent;
+		GUIPanel* mContent;
 		bool mHasFocus;
 
 		GUIWidget& getParentWidget() const;

+ 1 - 1
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -36,7 +36,7 @@ namespace BansheeEngine
 	private:
 		EditorWindowBase* mParentWindow;
 		GUITabbedTitleBar* mTitleBar;
-		GUIArea* mTitleBarArea;
+		GUIPanel* mTitleBarPanel;
 		GUIWidget* mParent;
 		INT32 mX, mY;
 		UINT32 mWidth, mHeight;

+ 2 - 2
BansheeEditor/Include/BsGUIMenuBar.h

@@ -29,8 +29,8 @@ namespace BansheeEngine
 
 		RenderWindow* mParentWindow;
 		GUIWidget* mParentWidget;
-		GUIArea* mMainArea;
-		GUIArea* mBgTextureArea;
+		GUIPanel* mMainPanel;
+		GUILayout* mMainLayout;
 		GUITexture* mBgTexture;
 		GUITexture* mLogoTexture;
 

+ 1 - 1
BansheeEditor/Include/BsGUIWindowFrameWidget.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 		static const UINT32 RESIZE_BORDER_WIDTH;
 
 		bool mAllowResize;
-		GUIArea* mWindowFrameArea;
+		GUIPanel* mWindowFramePanel;
 		RenderWindow* mParentWindow;
 		GUIWindowFrame* mWindowFrame;
 

+ 2 - 2
BansheeEditor/Include/BsModalWindow.h

@@ -25,8 +25,8 @@ namespace BansheeEngine
 		void updateSize();
 		UINT32 getTitleBarHeight() const;
 
-		GUIArea* mTitleBarArea;
-		GUIArea* mTitleBarBgArea;
+		GUIPanel* mTitleBarPanel;
+		GUIPanel* mTitleBarBgPanel;
 
 		GUILabel* mTitle;
 		GUIButton* mCloseButton;

+ 0 - 48
BansheeEditor/Source/BsEditorApplication.cpp

@@ -221,54 +221,6 @@ namespace BansheeEngine
 
 		testModelGO->destroy();
 
-		//Win32FolderMonitor* folderMonitor = bs_new<Win32FolderMonitor>();
-
-		//FolderChange folderChanges = (FolderChange)((UINT32)FolderChange::FileName | (UINT32)FolderChange::DirName | 
-		//	(UINT32)FolderChange::Creation | (UINT32)FolderChange::LastWrite);
-		//folderMonitor->startMonitor(L"D:\\TestDetect", true, folderChanges);
-
-		//HTexture dbgCursor = static_resource_cast<Texture>(Importer::instance().import(L"C:\\CursorDbg.psd"));
-		//PixelDataPtr cursorPixelData = dbgCursor->allocateSubresourceBuffer(0);
-
-		//gMainSyncedCA().readSubresource(dbgCursor.getInternalPtr(), 0, cursorPixelData);
-		//gMainSyncedCA().submitToCoreThread(true);
-
-		/************************************************************************/
-		/* 								MODAL WINDOW                      		*/
-		/************************************************************************/
-
-		//RENDER_WINDOW_DESC modalWindowDesc;
-		//modalWindowDesc.width = 200;
-		//modalWindowDesc.height = 200;
-		//modalWindowDesc.left = 0;
-		//modalWindowDesc.top = 0;
-		//modalWindowDesc.title = "ModalWindow";
-		//modalWindowDesc.fullscreen = false;
-		//modalWindowDesc.border = WindowBorder::None;
-		//modalWindowDesc.toolWindow = true;
-		//modalWindowDesc.modal = true;
-
-		//RenderWindowPtr modalWindow = RenderWindow::create(modalWindowDesc, gApplication().getPrimaryWindow());
-
-		//HSceneObject modalSceneObject = SceneObject::create("ModalWindow");
-
-		//HCamera modalCamera = modalSceneObject->addComponent<Camera>();
-		//modalCamera->initialize(modalWindow, 0.0f, 0.0f, 1.0f, 1.0f);
-		//modalCamera->setNearClipDistance(5);
-		//modalCamera->setAspectRatio(1.0f);
-		//modalCamera->setIgnoreSceneRenderables(true);
-
-		//HGUIWidget modalGUI = modalSceneObject->addComponent<GUIWidget>(modalCamera->getViewport().get());
-		//modalGUI->setDepth(128);
-
-		//modalGUI->setSkin(EditorGUI::instance().getSkin());
-
-		//GUIArea* modalArea = GUIArea::createStretchedXY(*modalGUI, 0, 0, 0, 0, 500);
-		//GUIButton* modalButton = GUIButton::create(*modalGUI, HString(L"Close"));
-		//modalButton->onClick.connect(std::bind(&EditorApplication::closeModalWindow, modalWindow, modalSceneObject));
-
-		//modalArea->getLayout().addElement(modalButton);
-
 		/************************************************************************/
 		/* 							END DEBUG CODE                      		*/
 		/************************************************************************/

+ 14 - 10
BansheeEditor/Source/BsEditorWidget.cpp

@@ -4,6 +4,7 @@
 #include "BsGUITexture.h"
 #include "BsGUISkin.h"
 #include "BsGUILayout.h"
+#include "BsGUIPanel.h"
 #include "BsBuiltinResources.h"
 #include "BsGUIArea.h"
 #include "BsEditorWidgetContainer.h"
@@ -22,7 +23,7 @@ namespace BansheeEngine
 	EditorWidgetBase::~EditorWidgetBase()
 	{
 		if (mContent != nullptr)
-			GUIArea::destroy(mContent);
+			GUILayout::destroy(mContent);
 	}
 
 	EditorWindowBase* EditorWidgetBase::getParentWindow() const
@@ -63,8 +64,11 @@ namespace BansheeEngine
 		mWidth = width;
 		mHeight = height;
 
-		if(mContent != nullptr)
-			mContent->setSize(width, height);
+		if (mContent != nullptr)
+		{
+			mContent->setWidth(width);
+			mContent->setHeight(height);
+		}
 
 		doOnResized(width, height);
 	}
@@ -125,15 +129,15 @@ namespace BansheeEngine
 		{
 			if(parent != nullptr)
 			{
-				if(mContent == nullptr)
-					mContent = GUIArea::create(parent->getParentWidget(), 0, 0, 0, 0, 0);
+				if (mContent == nullptr)
+					mContent = parent->getParentWidget().getPanel()->addNewElement<GUIPanel>();
 				else
-					mContent->changeParentWidget(&parent->getParentWidget());
+					parent->getParentWidget().getPanel()->addElement(mContent);
 			}
 			else
 			{
-				if(mContent != nullptr)
-					mContent->changeParentWidget(nullptr);
+				if (mContent != nullptr)
+					mParent->getParentWidget().getPanel()->removeElement(mContent);
 			}
 
 			mParent = parent;
@@ -147,12 +151,12 @@ namespace BansheeEngine
 
 	void EditorWidgetBase::_disable()
 	{
-		mContent->disable();
+		mContent->disableRecursively();
 	}
 
 	void EditorWidgetBase::_enable()
 	{
-		mContent->enable();
+		mContent->enableRecursively();
 	}
 
 	GUIWidget& EditorWidgetBase::getParentWidget() const

+ 11 - 9
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -3,11 +3,11 @@
 #include "BsEditorWidget.h"
 #include "BsDragAndDropManager.h"
 #include "BsEditorWindow.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
+#include "BsGUIWidget.h"
 #include "BsMath.h"
 #include "BsInput.h"
-#include "BsGUIWidget.h"
-#include "BsGUILayout.h"
+#include "BsGUILayoutX.h"
 #include "BsCursor.h"
 
 using namespace std::placeholders;
@@ -18,9 +18,9 @@ namespace BansheeEngine
 
 	EditorWidgetContainer::EditorWidgetContainer(GUIWidget* parent, EditorWindowBase* parentEditorWindow)
 		:mParent(parent), mX(0), mY(0), mWidth(0), mHeight(0), mTitleBar(nullptr), mActiveWidget(-1),
-		mTitleBarArea(nullptr), mParentWindow(parentEditorWindow)
+		mTitleBarPanel(nullptr), mParentWindow(parentEditorWindow)
 	{
-		mTitleBarArea = GUIArea::create(*parent, 0, 0, 0, 0, 0);
+		mTitleBarPanel = parent->getPanel()->addNewElement<GUIPanel>();
 
 		mTitleBar = GUITabbedTitleBar::create();
 		mTitleBar->onTabActivated.connect(std::bind(&EditorWidgetContainer::tabActivated, this, _1));
@@ -28,7 +28,8 @@ namespace BansheeEngine
 		mTitleBar->onTabDraggedOff.connect(std::bind(&EditorWidgetContainer::tabDraggedOff, this, _1));
 		mTitleBar->onTabDraggedOn.connect(std::bind(&EditorWidgetContainer::tabDraggedOn, this, _1));
 
-		mTitleBarArea->getLayout().addElement(mTitleBar);
+		GUILayout* titleBarLayout = mTitleBarPanel->addNewElement<GUILayoutX>();
+		titleBarLayout->addElement(mTitleBar);
 	}
 
 	EditorWidgetContainer::~EditorWidgetContainer()
@@ -38,7 +39,7 @@ namespace BansheeEngine
 			widget.second->close();
 		}
 
-		GUIArea::destroy(mTitleBarArea);
+		GUILayout::destroy(mTitleBarPanel);
 		GUIElement::destroy(mTitleBar);
 	}
 
@@ -151,7 +152,8 @@ namespace BansheeEngine
 	void EditorWidgetContainer::setSize(UINT32 width, UINT32 height)
 	{
 		// TODO - Title bar is always TitleBarHeight size, so what happens when the container area is smaller than that?
-		mTitleBarArea->setSize(width, TitleBarHeight);
+		mTitleBarPanel->setWidth(width);
+		mTitleBarPanel->setHeight(TitleBarHeight);
 
 		if(mActiveWidget >= 0)
 		{
@@ -167,7 +169,7 @@ namespace BansheeEngine
 
 	void EditorWidgetContainer::setPosition(INT32 x, INT32 y)
 	{
-		mTitleBarArea->setPosition(x, y);
+		mTitleBarPanel->setPosition(x, y);
 
 		if(mActiveWidget >= 0)
 		{

+ 32 - 40
BansheeEditor/Source/BsGUIMenuBar.cpp

@@ -1,9 +1,9 @@
 #include "BsGUIMenuBar.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
 #include "BsGUIElement.h"
 #include "BsGUIButton.h"
 #include "BsGUITexture.h"
-#include "BsGUILayout.h"
+#include "BsGUILayoutX.h"
 #include "BsGUISpace.h"
 #include "BsGUIMenu.h"
 #include "BsGUIManager.h"
@@ -18,33 +18,36 @@ namespace BansheeEngine
 	const UINT32 GUIMenuBar::NUM_ELEMENTS_AFTER_CONTENT = 8;
 
 	GUIMenuBar::GUIMenuBar(GUIWidget* parent, RenderWindow* parentWindow)
-		:mParentWidget(parent), mParentWindow(parentWindow), mMainArea(nullptr), mBgTextureArea(nullptr), 
+		:mParentWidget(parent), mParentWindow(parentWindow), mMainPanel(nullptr), mMainLayout(nullptr),
 		mBgTexture(nullptr), mLogoTexture(nullptr), mSubMenuOpen(false), mSubMenuButton(nullptr)
 	{
-		mBgTextureArea = GUIArea::create(*parent, 0, 0, 1, 13, 1);
-		mMainArea = GUIArea::create(*parent, 0, 0, 1, 13, 0);
+		mMainPanel = parent->getPanel()->addNewElement<GUIPanel>(0);
+		mMainPanel->setWidth(1);
+		mMainPanel->setHeight(13);
+
+		mMainLayout = mMainPanel->addNewElement<GUILayoutX>();
+		GUILayoutX* bgLayout = mMainPanel->addNewElement<GUILayoutX>();
 
 		mBgTexture = GUITexture::create(GUIImageScaleMode::StretchToFit, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "MenuBarBg");
-		mBgTextureArea->getLayout().addElement(mBgTexture);
+		bgLayout->addElement(mBgTexture);
 
 		mLogoTexture = GUITexture::create(GUIImageScaleMode::StretchToFit, "MenuBarBansheeLogo");
-		GUILayout& mainLayout = mMainArea->getLayout();
 
-		mainLayout.addElement(mLogoTexture);
-		mainLayout.addNewElement<GUIFixedSpace>(5);
-		mainLayout.addNewElement<GUIFlexibleSpace>();
+		mMainLayout->addElement(mLogoTexture);
+		mMainLayout->addNewElement<GUIFixedSpace>(5);
+		mMainLayout->addNewElement<GUIFlexibleSpace>();
 
 		mMinBtn = GUIButton::create(HString(L""), "WinMinimizeBtn");
 		mMaxBtn = GUIButton::create(HString(L""), "WinMaximizeBtn");
 		mCloseBtn = GUIButton::create(HString(L""), "WinCloseBtn");
 
-		mainLayout.addNewElement<GUIFixedSpace>(3);
-		mainLayout.addElement(mMinBtn);
-		mainLayout.addNewElement<GUIFixedSpace>(3);
-		mainLayout.addElement(mMaxBtn);
-		mainLayout.addNewElement<GUIFixedSpace>(3);
-		mainLayout.addElement(mCloseBtn);
-		mainLayout.addNewElement<GUIFixedSpace>(3);
+		mMainLayout->addNewElement<GUIFixedSpace>(3);
+		mMainLayout->addElement(mMinBtn);
+		mMainLayout->addNewElement<GUIFixedSpace>(3);
+		mMainLayout->addElement(mMaxBtn);
+		mMainLayout->addNewElement<GUIFixedSpace>(3);
+		mMainLayout->addElement(mCloseBtn);
+		mMainLayout->addNewElement<GUIFixedSpace>(3);
 
 		mMinBtn->onClick.connect(std::bind(&GUIMenuBar::onMinimizeClicked, this));
 		mMaxBtn->onClick.connect(std::bind(&GUIMenuBar::onMaximizeClicked, this));
@@ -63,24 +66,15 @@ namespace BansheeEngine
 			GUIElement::destroy(menu.button);
 		}
 
-		GUIElement::destroy(mMinBtn);
-		GUIElement::destroy(mMaxBtn);
-		GUIElement::destroy(mCloseBtn);
-
-		GUIElement::destroy(mBgTexture);
-		GUIElement::destroy(mLogoTexture);
-
-		GUIArea::destroy(mMainArea);
-		GUIArea::destroy(mBgTextureArea);
+		GUILayout::destroy(mMainPanel);
 	}
 
 	void GUIMenuBar::setArea(INT32 x, INT32 y, UINT32 width, UINT32 height)
 	{
-		mMainArea->setPosition(x, y);
-		mBgTextureArea->setPosition(x, y);
+		mMainPanel->setPosition(x, y);
 
-		mMainArea->setSize(width, height);
-		mBgTextureArea->setSize(width, height);
+		mMainPanel->setWidth(width);
+		mMainPanel->setHeight(height);
 
 		refreshNonClientAreas();
 	}
@@ -135,7 +129,7 @@ namespace BansheeEngine
 		GUIButton* newButton = GUIButton::create(HString(name), "MenuBarBtn");
 		newButton->onClick.connect(std::bind(&GUIMenuBar::openSubMenu, this, name));
 		newButton->onHover.connect(std::bind(&GUIMenuBar::onSubMenuHover, this, name));
-		mMainArea->getLayout().insertElement(mMainArea->getLayout().getNumChildren() - NUM_ELEMENTS_AFTER_CONTENT, newButton);
+		mMainLayout->insertElement(mMainLayout->getNumChildren() - NUM_ELEMENTS_AFTER_CONTENT, newButton);
 
 		newSubMenu.button = newButton;
 
@@ -183,7 +177,7 @@ namespace BansheeEngine
 			if(subMenuToRemove == nullptr)
 				return;
 
-			mMainArea->getLayout().removeElement(subMenuToRemove->button);
+			mMainLayout->removeElement(subMenuToRemove->button);
 			GUIElement::destroy(subMenuToRemove->button);
 			bs_delete<PoolAlloc>(subMenuToRemove->menu);
 
@@ -311,20 +305,18 @@ namespace BansheeEngine
 
 	void GUIMenuBar::refreshNonClientAreas()
 	{
-		// If the size or contents of the area changed this frame the layout won't be updated yet,
-		// so force the update right away so we get correct element bounds
-		mMainArea->_update();
+		Rect2I mainArea = mMainLayout->getBounds();
 
 		Vector<Rect2I> nonClientAreas;
-		nonClientAreas.push_back(mLogoTexture->_getCachedBounds());
+		nonClientAreas.push_back(mLogoTexture->getBounds());
 
 		if(mChildMenus.size() > 0)
 		{
-			Rect2I lastButtonBounds = mChildMenus.back().button->_getCachedBounds();
-			Rect2I minButtonBounds = mMinBtn->_getCachedBounds();
+			Rect2I lastButtonBounds = mChildMenus.back().button->getBounds();
+			Rect2I minButtonBounds = mMinBtn->getBounds();
 
-			Rect2I emptyArea(lastButtonBounds.x + lastButtonBounds.width, mMainArea->y(), 
-				minButtonBounds.x - (lastButtonBounds.x + lastButtonBounds.width), mMainArea->height());
+			Rect2I emptyArea(lastButtonBounds.x + lastButtonBounds.width, mainArea.y,
+				minButtonBounds.x - (lastButtonBounds.x + lastButtonBounds.width), mainArea.height);
 
 			nonClientAreas.push_back(emptyArea);
 		}

+ 13 - 10
BansheeEditor/Source/BsGUIWindowFrameWidget.cpp

@@ -1,5 +1,6 @@
 #include "BsGUIWindowFrameWidget.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
+#include "BsGUIWidget.h"
 #include "BsGUILayout.h"
 #include "BsGUITexture.h"
 #include "BsGUIWindowFrame.h"
@@ -14,18 +15,18 @@ namespace BansheeEngine
 	const UINT32 WindowFrameWidget::RESIZE_BORDER_WIDTH = 3;
 
 	WindowFrameWidget::WindowFrameWidget(const HSceneObject& parent, bool allowResize, Viewport* target, RenderWindow* parentWindow, const HGUISkin& skin)
-		:GUIWidget(parent, target), mWindowFrameArea(nullptr), mParentWindow(parentWindow), mAllowResize(allowResize)
+		:GUIWidget(parent, target), mWindowFramePanel(nullptr), mParentWindow(parentWindow), mAllowResize(allowResize)
 	{
 		setSkin(skin);
 
-		GUIArea* backgroundArea = GUIArea::createStretchedXY(*this, 0, 0, 0, 0, 500);
-		backgroundArea->getLayout().addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit, 
+		GUIPanel* backgroundPanel = getPanel()->addNewElement<GUIPanel>(500);
+		backgroundPanel->addElement(GUITexture::create(GUIImageScaleMode::RepeatToFit, 
 			GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), "WindowBackground"));
 
-		mWindowFrameArea = GUIArea::createStretchedXY(*this, 0, 0, 0, 0, 499);
+		mWindowFramePanel = getPanel()->addNewElement<GUIPanel>(499);
 
 		mWindowFrame = GUIWindowFrame::create("WindowFrame");
-		mWindowFrameArea->getLayout().addElement(mWindowFrame);
+		mWindowFramePanel->addElement(mWindowFrame);
 
 		refreshNonClientAreas();
 	}
@@ -64,11 +65,13 @@ namespace BansheeEngine
 		if (!mAllowResize)
 			return;
 
-		INT32 x = mWindowFrameArea->x();
-		INT32 y = mWindowFrameArea->y();
+		Rect2I bounds = mWindowFramePanel->getBounds();
 
-		UINT32 width = mWindowFrameArea->width();
-		UINT32 height = mWindowFrameArea->height();
+		INT32 x = bounds.x;
+		INT32 y = bounds.y;
+
+		UINT32 width = bounds.width;
+		UINT32 height = bounds.height;
 
 		Vector<NonClientResizeArea> nonClientAreas(8);
 

+ 2 - 4
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -7,7 +7,7 @@
 #include "BsRenderTexture.h"
 #include "BsApplication.h"
 #include "BsProfilingManager.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
 #include "BsGUILayout.h"
 #include "BsEditorTestSuite.h"
 #include "BsTestOutput.h"
@@ -33,9 +33,7 @@ namespace BansheeEngine
 		mMenuBar(bs_new<GUIMenuBar>(mGUI.get(), mRenderWindow.get()))
 	{
 		mDockManager = DockManager::create(this);
-
-		GUIArea* dockArea = GUIArea::createStretchedXY(*mGUI.get(), 0, 0, 0, 0);
-		dockArea->getLayout().addElement(mDockManager);
+		mGUI->getPanel()->addElement(mDockManager);
 
 		updateAreas();
 

+ 19 - 7
BansheeEditor/Source/BsModalWindow.cpp

@@ -9,26 +9,36 @@
 #include "BsGUIButton.h"
 #include "BsGUITexture.h"
 #include "BsGUILabel.h"
+#include "BsGUIPanel.h"
+#include "BsGUIWidget.h"
 
 namespace BansheeEngine
 {
 	ModalWindow::ModalWindow(const HString& title, bool hasCloseButton)
-		:EditorWindowBase(true), mTitleBarArea(nullptr), mTitleBarBgArea(nullptr), 
+		:EditorWindowBase(true), mTitleBarPanel(nullptr), mTitleBarBgPanel(nullptr), 
 		mCloseButton(nullptr), mTitleBarBg(nullptr), mTitle(nullptr)
 	{
 		EditorWindowManager::instance().registerWindow(this);
 
-		mTitleBarBgArea = GUIArea::createStretchedXY(*mGUI, 1, 1, 1, 1, std::numeric_limits<UINT16>::max() - 1);
-		mTitleBarArea = GUIArea::createStretchedXY(*mGUI, 1, 1, 1, 1, 0);
+		mTitleBarBgPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
+		mTitleBarBgPanel->setDepthRange(std::numeric_limits<UINT16>::max() - 1);
+		mTitleBarBgPanel->setPosition(1, 1);
+
+		mTitleBarPanel = mGUI->getPanel()->addNewElement<GUIPanel>();
+		mTitleBarPanel->setDepthRange(0);
+		mTitleBarPanel->setPosition(1, 1);
 
 		mTitleBarBg = GUITexture::create(GUIOptions(GUIOption::flexibleWidth()), "TitleBarBackground");
 		mTitle = GUILabel::create(title);
 
-		GUILayout* bgLayout = mTitleBarBgArea->getLayout().addNewElement<GUILayoutY>();
-		bgLayout->addElement(mTitleBarBg);
+		GUILayout* bgLayout = mTitleBarBgPanel->addNewElement<GUILayoutY>();
+		GUILayout* bgLayoutX = bgLayout->addNewElement<GUILayoutX>();
+		bgLayoutX->addElement(mTitleBarBg);
+		bgLayoutX->addNewElement<GUIFixedSpace>(1);
 		bgLayout->addNewElement<GUIFlexibleSpace>();
+		bgLayout->addNewElement<GUIFixedSpace>(1);
 
-		GUILayout* contentLayoutY = mTitleBarArea->getLayout().addNewElement<GUILayoutY>();
+		GUILayout* contentLayoutY = mTitleBarPanel->addNewElement<GUILayoutY>();
 		GUILayout* contentLayoutX = contentLayoutY->addNewElement<GUILayoutX>();
 		contentLayoutX->addNewElement<GUIFlexibleSpace>();
 		GUILayout* titleLayout = contentLayoutX->addNewElement<GUILayoutY>();
@@ -45,8 +55,10 @@ namespace BansheeEngine
 			mCloseButton->onClick.connect(std::bind(&ModalWindow::close, this));
 		}
 
+		contentLayoutX->addNewElement<GUIFixedSpace>(1);
 		contentLayoutY->addNewElement<GUIFlexibleSpace>();
-		
+		contentLayoutY->addNewElement<GUIFixedSpace>(1);
+
 		updateSize();
 	}
 

+ 1 - 26
BansheeEditor/Source/BsTestTextSprite.cpp

@@ -58,35 +58,10 @@ namespace BansheeEngine
 		SceneObject::create("FILLER_J");
 		SceneObject::create("FILLER_K");
 		SceneObject::create("FILLER_L");
-
-		//GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
-		//area->getLayout().addElement(GUIRenderTexture::create(*this, sceneView, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600))));
-
-		//GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
-
-		//mSceneTreeView = GUISceneTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
-		//mResourceTreeView = GUIResourceTreeView::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()));
-		//GUILayout& sceneTreeViewLayout = area->getLayout().addLayoutY();
-
-		//GUIScrollArea* scrollArea = GUIScrollArea::create(*this, GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)));
-		//sceneTreeViewLayout.addFlexibleSpace();
-		//area->getLayout().addElement(scrollArea);
-		//sceneTreeViewLayout.addFlexibleSpace();
-
-		//scrollArea->getLayout().addElement(mSceneTreeView);
-		//area->getLayout().addElement(mResourceTreeView);
-
-		//GUIIntField* intField = GUIIntField::create(*this, HString(L"Int Field"), GUIOptions(GUIOption::fixedWidth(200)));
-		//GUIFloatField* floatField = GUIFloatField::create(*this, HString(L"Float Field"), GUIOptions(GUIOption::fixedWidth(200)));
-		//area->getLayout().addElement(intField);
-		//area->getLayout().addElement(floatField);
-
-		//area->getLayout().addFlexibleSpace();
 	}
 
 	void TestTextSprite::update()
 	{
-		//mSceneTreeView->update();
-		//mResourceTreeView->update();
+
 	}
 }

+ 2 - 3
BansheeEditor/Source/DbgEditorWidget1.cpp

@@ -7,6 +7,7 @@
 #include "BsGUIArea.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutY.h"
+#include "BsGUIPanel.h"
 #include "BsEditorWidgetManager.h"
 #include "BsGUISceneTreeView.h"
 #include "BsGUIResourceTreeView.h"
@@ -18,10 +19,8 @@ namespace BansheeEngine
 	DbgEditorWidget1::DbgEditorWidget1(const ConstructPrivately& dummy, EditorWidgetContainer& parentContainer)
 		:EditorWidget<DbgEditorWidget1>(HString(L"DbgEditorWidget1"), parentContainer)
 	{
-		GUILayout& layout = mContent->getLayout();
-
 		GUIScrollArea* scrollArea = GUIScrollArea::create();
-		layout.addElement(scrollArea);
+		mContent->addElement(scrollArea);
 
 		GUILayout* treeViewLayout = scrollArea->getLayout().addNewElement<GUILayoutY>();
 

+ 2 - 1
BansheeEditor/Source/DbgEditorWidget2.cpp

@@ -4,6 +4,7 @@
 #include "BsGUIScrollArea.h"
 #include "BsGUIArea.h"
 #include "BsGUILayoutY.h"
+#include "BsGUIPanel.h"
 #include "BsGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUIIntField.h"
@@ -49,7 +50,7 @@ namespace BansheeEngine
 	DbgEditorWidget2::DbgEditorWidget2(const ConstructPrivately& dummy, EditorWidgetContainer& parentContainer)
 		:EditorWidget<DbgEditorWidget2>(HString(L"DbgEditorWidget2"), parentContainer)
 	{
-		GUILayout* layout = mContent->getLayout().addNewElement<GUILayoutY>();
+		GUILayout* layout = mContent->addNewElement<GUILayoutY>();
 
 		GUIIntField* intField = GUIIntField::create(GUIContent(HString(L"Int Field")), 100, GUIOptions(GUIOption::fixedWidth(200)));
 		GUIFloatField* floatField = GUIFloatField::create(HString(L"Float Field"), GUIOptions(GUIOption::fixedWidth(200)));

+ 2 - 2
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -301,8 +301,8 @@ namespace BansheeEngine
 			GUIDropDownContent* mContent;
 			GUITexture* mBackgroundFrame;
 
-			GUIArea* mBackgroundArea;
-			GUIArea* mContentArea;
+			GUIPanel* mBackgroundPanel;
+			GUIPanel* mContentPanel;
 			GUILayout* mContentLayout;
 
 			DropDownSubMenu* mParent;

+ 6 - 0
BansheeEngine/Include/BsGUIWidget.h

@@ -37,6 +37,11 @@ namespace BansheeEngine
 		 */
 		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.
@@ -171,6 +176,7 @@ namespace BansheeEngine
 		Viewport* mTarget;
 		Vector<GUIElement*> mElements;
 		Vector<GUIArea*> mAreas;
+		GUIPanel* mPanel;
 		UINT8 mDepth;
 
 		Vector3 mLastFramePosition;

+ 2 - 6
BansheeEngine/Include/BsProfilerOverlay.h

@@ -143,10 +143,6 @@ namespace BansheeEngine
 
 		HSceneObject mWidgetSO;
 		GameObjectHandle<GUIWidget> mWidget;
-		GUIArea* mCPUBasicAreaLabels = nullptr;
-		GUIArea* mCPUPreciseAreaLabels = nullptr;
-		GUIArea* mCPUBasicAreaContents = nullptr;
-		GUIArea* mCPUPreciseAreaContents = nullptr;
 
 		GUILayout* mBasicLayoutLabels = nullptr;
 		GUILayout* mPreciseLayoutLabels = nullptr;
@@ -173,11 +169,11 @@ namespace BansheeEngine
 		GUIElement* mTitlePreciseAvgCyclesSelf = nullptr;
 		GUIElement* mTitlePreciseTotalCyclesSelf = nullptr;
 
-		GUIArea* mGPUAreaFrameContents = nullptr;
-		GUIArea* mGPUAreaFrameSamples = nullptr;
+		GUILayout* mGPULayoutFrameContents = nullptr;
 		GUILayout* mGPULayoutFrameContentsLeft = nullptr;
 		GUILayout* mGPULayoutFrameContentsRight = nullptr;
 		GUILayout* mGPULayoutSamples = nullptr;
+		GUILayout* mGPULayoutSampleContents = nullptr;
 
 		HString mGPUFrameNumStr;
 		HString mGPUTimeStr;

+ 26 - 16
BansheeEngine/Source/BsGUIDropDownBox.cpp

@@ -1,5 +1,5 @@
 #include "BsGUIDropDownBox.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
 #include "BsGUILayoutY.h"
 #include "BsGUILayoutX.h"
 #include "BsGUITexture.h"
@@ -174,7 +174,7 @@ namespace BansheeEngine
 
 	GUIDropDownBox::DropDownSubMenu::DropDownSubMenu(GUIDropDownBox* owner, DropDownSubMenu* parent, const GUIDropDownAreaPlacement& placement,
 		const Rect2I& availableBounds, const GUIDropDownData& dropDownData, GUIDropDownType type, UINT32 depthOffset)
-		:mOwner(owner), mParent(parent), mPage(0), mBackgroundFrame(nullptr), mBackgroundArea(nullptr), mContentArea(nullptr),
+		:mOwner(owner), mParent(parent), mPage(0), mBackgroundFrame(nullptr), mBackgroundPanel(nullptr), mContentPanel(nullptr),
 		mContentLayout(nullptr), mScrollUpBtn(nullptr), mScrollDownBtn(nullptr), x(0), y(0), width(0), height(0), 
 		mType(type), mSubMenu(nullptr), mData(dropDownData), mOpenedUpward(false), mDepthOffset(depthOffset), mContent(nullptr)
 	{
@@ -215,16 +215,23 @@ namespace BansheeEngine
 		mContent->setKeyboardFocus(true);
 
 		// Content area
-		mContentArea = GUIArea::create(*mOwner, 0, 0, width, height);
-		mContentArea->setDepth(100 - depthOffset * 2 - 1);
-		mContentLayout = mContentArea->getLayout().addNewElement<GUILayoutY>();
+		mContentPanel = mOwner->getPanel()->addNewElement<GUIPanel>();
+		mContentPanel->setWidth(width);
+		mContentPanel->setHeight(height);
+		mContentPanel->setDepthRange(100 - depthOffset * 2 - 1);
+
+		mContentLayout = mContentPanel->addNewElement<GUILayoutY>();
 
 		// Background frame
-		mBackgroundArea = GUIArea::create(*mOwner, 0, 0, width, height);
-		mBackgroundArea->setDepth(100 - depthOffset * 2);
+		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);
-		mBackgroundArea->getLayout().addElement(mBackgroundFrame);
+		backgroundLayout->addElement(mBackgroundFrame);
 
 		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
@@ -294,8 +301,8 @@ namespace BansheeEngine
 		if(mOpenedUpward)	
 			actualY -= (INT32)std::min(maxNeededHeight, availableUpwardHeight);
 
-		mContentArea->setPosition(x, actualY);
-		mBackgroundArea->setPosition(x, actualY);
+		mContentPanel->setPosition(x, actualY);
+		mBackgroundPanel->setPosition(x, actualY);
 
 		updateGUIElements();
 
@@ -318,8 +325,8 @@ namespace BansheeEngine
 
 		GUIElement::destroy(mBackgroundFrame);
 
-		GUIArea::destroy(mBackgroundArea);
-		GUIArea::destroy(mContentArea);
+		GUILayout::destroy(mBackgroundPanel);
+		GUILayout::destroy(mContentPanel);
 	}
 
 	Vector<GUIDropDownBox::DropDownSubMenu::PageInfo> GUIDropDownBox::DropDownSubMenu::getPageInfos() const
@@ -452,15 +459,18 @@ namespace BansheeEngine
 		if(mOpenedUpward)	
 			actualY -= (INT32)pageHeight;
 
-		mBackgroundArea->setSize(width, pageHeight);
-		mBackgroundArea->setPosition(x, actualY);
+		mBackgroundPanel->setWidth(width);
+		mBackgroundPanel->setHeight(pageHeight);
+		mBackgroundPanel->setPosition(x, actualY);
 
 		mVisibleBounds = Rect2I(x, actualY, width, pageHeight);
 
 		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)backgroundStyle->margins.left - (INT32)backgroundStyle->margins.right);
 		UINT32 contentHeight = (UINT32)std::max(0, (INT32)pageHeight - (INT32)backgroundStyle->margins.top - (INT32)backgroundStyle->margins.bottom);
-		mContentArea->setSize(contentWidth, contentHeight);
-		mContentArea->setPosition(x + backgroundStyle->margins.left, actualY + backgroundStyle->margins.top);
+
+		mContentPanel->setWidth(contentWidth);
+		mContentPanel->setHeight(contentHeight);
+		mContentPanel->setPosition(x + backgroundStyle->margins.left, actualY + backgroundStyle->margins.top);
 	}
 
 	void GUIDropDownBox::DropDownSubMenu::scrollDown()

+ 14 - 1
BansheeEngine/Source/BsGUIWidget.cpp

@@ -4,6 +4,7 @@
 #include "BsGUILabel.h"
 #include "BsGUIMouseEvent.h"
 #include "BsGUIArea.h"
+#include "BsGUIPanel.h"
 #include "BsCoreApplication.h"
 #include "BsCoreThreadAccessor.h"
 #include "BsMaterial.h"
@@ -19,7 +20,7 @@
 namespace BansheeEngine
 {
 	GUIWidget::GUIWidget(const HSceneObject& parent, Viewport* target)
-		:Component(parent), mWidgetIsDirty(false), mTarget(nullptr), mDepth(0)
+		:Component(parent), mWidgetIsDirty(false), mTarget(nullptr), mDepth(0), mPanel(nullptr)
 	{
 		setName("GUIWidget");
 
@@ -34,6 +35,8 @@ namespace BansheeEngine
 		mOwnerTargetResizedConn = mTarget->getTarget()->onResized.connect(std::bind(&GUIWidget::ownerTargetResized, this));
 
 		GUIManager::instance().registerWidget(this);
+
+		mPanel = GUIPanel::create();
 	}
 
 	GUIWidget::~GUIWidget()
@@ -41,6 +44,9 @@ namespace BansheeEngine
 
 	void GUIWidget::onDestroyed()
 	{
+		GUILayout::destroy(mPanel);
+		mPanel = nullptr;
+
 		if (mTarget != nullptr)
 		{
 			GUIManager::instance().unregisterWidget(this);
@@ -103,6 +109,10 @@ namespace BansheeEngine
 		{
 			area->_update();
 		}
+
+		Rect2I clipRect(0, 0, getTarget()->getWidth(), getTarget()->getHeight());
+		mPanel->_updateLayout(0, 0, getTarget()->getWidth(), getTarget()->getHeight(), clipRect, 
+			getDepth(), 0, -1);
 	}
 
 	bool GUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
@@ -263,6 +273,9 @@ namespace BansheeEngine
 		{
 			area->updateSizeBasedOnParent(getTarget()->getWidth(), getTarget()->getHeight());
 		}
+
+		mPanel->setWidth(getTarget()->getWidth());
+		mPanel->setHeight(getTarget()->getHeight());
 	}
 
 	void GUIWidget::ownerWindowFocusChanged()

+ 49 - 49
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -1,7 +1,7 @@
 #include "BsProfilerOverlay.h"
 #include "BsSceneObject.h"
 #include "BsGUIWidget.h"
-#include "BsGUIArea.h"
+#include "BsGUIPanel.h"
 #include "BsGUILayout.h"
 #include "BsGUILayoutX.h"
 #include "BsGUILayoutY.h"
@@ -309,15 +309,10 @@ namespace BansheeEngine
 		mWidget->setSkin(BuiltinResources::instance().getGUISkin());
 
 		// Set up CPU sample areas
-		mCPUBasicAreaLabels = GUIArea::create(*mWidget, 0, 0);
-		mCPUPreciseAreaLabels = GUIArea::create(*mWidget, 0, 0);
-		mCPUBasicAreaContents = GUIArea::create(*mWidget, 0, 0);
-		mCPUPreciseAreaContents = GUIArea::create(*mWidget, 0, 0);
-
-		mBasicLayoutLabels = mCPUBasicAreaLabels->getLayout().addNewElement<GUILayoutY>();
-		mPreciseLayoutLabels = mCPUPreciseAreaLabels->getLayout().addNewElement<GUILayoutY>();
-		mBasicLayoutContents = mCPUBasicAreaContents->getLayout().addNewElement<GUILayoutY>();
-		mPreciseLayoutContents = mCPUPreciseAreaContents->getLayout().addNewElement<GUILayoutY>();
+		mBasicLayoutLabels = mWidget->getPanel()->addNewElement<GUILayoutY>();
+		mPreciseLayoutLabels = mWidget->getPanel()->addNewElement<GUILayoutY>();
+		mBasicLayoutContents = mWidget->getPanel()->addNewElement<GUILayoutY>();
+		mPreciseLayoutContents = mWidget->getPanel()->addNewElement<GUILayoutY>();
 
 		// Set up CPU sample title bars
 		mTitleBasicName = GUILabel::create(HString(L"Name"), GUIOptions(GUIOption::fixedWidth(200)));
@@ -371,16 +366,15 @@ namespace BansheeEngine
 		mPreciseLayoutContents->addNewElement<GUIFlexibleSpace>();
 
 		// Set up GPU sample areas
-		mGPUAreaFrameContents = GUIArea::create(*mWidget, 0, 0);
-		mGPUAreaFrameSamples = GUIArea::create(*mWidget, 0, 0);
-		mGPULayoutFrameContentsLeft = mGPUAreaFrameContents->getLayout().addNewElement<GUILayoutY>();
-		mGPULayoutFrameContentsRight = mGPUAreaFrameContents->getLayout().addNewElement<GUILayoutY>();
+		mGPULayoutFrameContents = mWidget->getPanel()->addNewElement<GUILayoutX>();
+		mGPULayoutFrameContentsLeft = mGPULayoutFrameContents->addNewElement<GUILayoutY>();
+		mGPULayoutFrameContentsRight = mGPULayoutFrameContents->addNewElement<GUILayoutY>();
 
-		GUILayout* gpuSamplesMain = mGPUAreaFrameSamples->getLayout().addNewElement<GUILayoutY>();
+		mGPULayoutSamples = mWidget->getPanel()->addNewElement<GUILayoutY>();
 
-		GUILayout* gpuSampleTitle = gpuSamplesMain->addNewElement<GUILayoutY>();
-		mGPULayoutSamples = gpuSamplesMain->addNewElement<GUILayoutY>();
-		gpuSamplesMain->addNewElement<GUIFlexibleSpace>();
+		GUILayout* gpuSampleTitle = mGPULayoutSamples->addNewElement<GUILayoutY>();
+		mGPULayoutSampleContents = mGPULayoutSamples->addNewElement<GUILayoutY>();
+		mGPULayoutSamples->addNewElement<GUIFlexibleSpace>();
 
 		HString gpuSamplesStr(L"__ProfOvGPUSamples", L"Samples");
 		gpuSampleTitle->addElement(GUILabel::create(gpuSamplesStr));
@@ -461,21 +455,21 @@ namespace BansheeEngine
 	{
 		if (type == ProfilerOverlayType::CPUSamples)
 		{
-			mCPUBasicAreaLabels->enable();
-			mCPUPreciseAreaLabels->enable();
-			mCPUBasicAreaContents->enable();
-			mCPUPreciseAreaContents->enable();
-			mGPUAreaFrameContents->disable();
-			mGPUAreaFrameSamples->disable();
+			mBasicLayoutLabels->enableRecursively();
+			mPreciseLayoutLabels->enableRecursively();
+			mBasicLayoutContents->enableRecursively();
+			mPreciseLayoutContents->enableRecursively();
+			mGPULayoutFrameContents->disableRecursively();
+			mGPULayoutSamples->disableRecursively();
 		}
 		else
 		{
-			mGPUAreaFrameContents->enable();
-			mGPUAreaFrameSamples->enable();
-			mCPUBasicAreaLabels->disable();
-			mCPUPreciseAreaLabels->disable();
-			mCPUBasicAreaContents->disable();
-			mCPUPreciseAreaContents->disable();
+			mGPULayoutFrameContents->enableRecursively();
+			mGPULayoutSamples->enableRecursively();
+			mBasicLayoutLabels->disableRecursively();
+			mPreciseLayoutLabels->disableRecursively();
+			mBasicLayoutContents->disableRecursively();
+			mPreciseLayoutContents->disableRecursively();
 		}
 
 		mType = type;
@@ -484,12 +478,12 @@ namespace BansheeEngine
 
 	void ProfilerOverlay::hide()
 	{
-		mCPUBasicAreaLabels->disable();
-		mCPUPreciseAreaLabels->disable();
-		mCPUBasicAreaContents->disable();
-		mCPUPreciseAreaContents->disable();
-		mGPUAreaFrameContents->disable();
-		mGPUAreaFrameSamples->disable();
+		mBasicLayoutLabels->disableRecursively();
+		mPreciseLayoutLabels->disableRecursively();
+		mBasicLayoutContents->disableRecursively();
+		mPreciseLayoutContents->disableRecursively();
+		mGPULayoutFrameContents->disableRecursively();
+		mGPULayoutSamples->disableRecursively();
 		mIsShown = false;
 	}
 
@@ -526,17 +520,21 @@ namespace BansheeEngine
 		UINT32 labelsWidth = Math::ceilToInt(width * LABELS_CONTENT_RATIO);
 		UINT32 contentWidth = width - labelsWidth;
 
-		mCPUBasicAreaLabels->setPosition(PADDING, PADDING);
-		mCPUBasicAreaLabels->setSize(labelsWidth, height);
+		mBasicLayoutLabels->setPosition(PADDING, PADDING);
+		mBasicLayoutLabels->setWidth(labelsWidth);
+		mBasicLayoutLabels->setHeight(height);
 
-		mCPUPreciseAreaLabels->setPosition(PADDING, height + PADDING * 2);
-		mCPUPreciseAreaLabels->setSize(labelsWidth, height);
+		mPreciseLayoutLabels->setPosition(PADDING, height + PADDING * 2);
+		mPreciseLayoutLabels->setWidth(labelsWidth);
+		mPreciseLayoutLabels->setHeight(height);
 
-		mCPUBasicAreaContents->setPosition(PADDING + labelsWidth, PADDING);
-		mCPUBasicAreaContents->setSize(contentWidth, height);
+		mBasicLayoutContents->setPosition(PADDING + labelsWidth, PADDING);
+		mBasicLayoutContents->setWidth(contentWidth);
+		mBasicLayoutContents->setHeight(height);
 
-		mCPUPreciseAreaContents->setPosition(PADDING + labelsWidth, height + PADDING * 2);
-		mCPUPreciseAreaContents->setSize(contentWidth, height);
+		mPreciseLayoutContents->setPosition(PADDING + labelsWidth, height + PADDING * 2);
+		mPreciseLayoutContents->setWidth(contentWidth);
+		mPreciseLayoutContents->setHeight(height);
 	}
 
 	void ProfilerOverlay::updateGPUSampleAreaSizes()
@@ -550,11 +548,13 @@ namespace BansheeEngine
 		UINT32 frameHeight = Math::ceilToInt(height * SAMPLES_FRAME_RATIO);
 		UINT32 samplesHeight = height - frameHeight;
 
-		mGPUAreaFrameContents->setPosition(PADDING, PADDING);
-		mGPUAreaFrameContents->setSize(width, frameHeight);
+		mGPULayoutFrameContents->setPosition(PADDING, PADDING);
+		mGPULayoutFrameContents->setWidth(width);
+		mGPULayoutFrameContents->setHeight(frameHeight);
 
-		mGPUAreaFrameSamples->setPosition(PADDING, PADDING + frameHeight + PADDING);
-		mGPUAreaFrameSamples->setSize(width, samplesHeight);
+		mGPULayoutSamples->setPosition(PADDING, PADDING + frameHeight + PADDING);
+		mGPULayoutSamples->setWidth(width);
+		mGPULayoutSamples->setHeight(samplesHeight);
 	}
 
 	void ProfilerOverlay::updateCPUSampleContents(const ProfilerReport& simReport, const ProfilerReport& coreReport)
@@ -674,7 +674,7 @@ namespace BansheeEngine
 		mGPUGPUProgramBufferBindsStr.setParameter(0, toWString(gpuReport.frameSample.numGpuParamBufferBinds));
 		mGPUGPUProgramBindsStr.setParameter(0, toWString(gpuReport.frameSample.numGpuProgramBinds));
 
-		GPUSampleRowFiller sampleRowFiller(mGPUSampleRows, *mGPULayoutSamples, *mWidget);
+		GPUSampleRowFiller sampleRowFiller(mGPUSampleRows, *mGPULayoutSampleContents, *mWidget);
 		for (auto& sample : gpuReport.samples)
 		{
 			sampleRowFiller.addData(sample.name, sample.timeMs);

+ 13 - 11
ExampleProject/Main/Main.cpp

@@ -29,6 +29,7 @@
 #include "BsProfilerOverlay.h"
 #include "BsCoreRenderer.h"
 #include "BsResources.h"
+#include "BsGUIPanel.h"
 
 #include "CameraFlyer.h"
 
@@ -330,12 +331,9 @@ namespace BansheeEngine
 		// and default layout properties. We use the default skin that comes built into Banshee.
 		gui->setSkin(BuiltinResources::instance().getGUISkin());
 
-		// Create a GUI area that is used for displaying messages about toggling profiler overlays.
-		// This area will stretch the entire surface of its parent widget, even if the widget is resized.
-		GUIArea* bottomArea = GUIArea::createStretchedXY(*gui, 0, 0, 0, 0);
-
-		// Add a vertical layout that will automatically position any child elements top to bottom.
-		GUILayout* bottomLayout = bottomArea->getLayout().addNewElement<GUILayoutY>();
+		// 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).
@@ -346,19 +344,23 @@ namespace BansheeEngine
 		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 area that is used for displaying resolution and fullscreen options.
-		GUIArea* rightArea = GUIArea::createStretchedXY(*gui, 30, 30, 30, 30);
+		// 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.
-		rightArea->getLayout().addNewElement<GUIFlexibleSpace>();
+		rightLayout->addNewElement<GUIFlexibleSpace>();
 
 		// And we want the elements to be vertically placed, top to bottom
-		GUILayout* rightLayout = rightArea->getLayout().addNewElement<GUILayoutY>();
+		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);
-		rightLayout->addElement(toggleFullscreenButton);
+		elemLayout->addElement(toggleFullscreenButton);
+
+		// Leave 30 pixels to the right free
+		rightLayout->addNewElement<GUIFixedSpace>(30);
 
 		// Add a profiler overlay object that is resposible for displaying CPU and GPU profiling GUI
 		profilerOverlay = guiSO->addComponent<ProfilerOverlay>(guiCamera->getViewport());