Просмотр исходного кода

Completely changed how layout options are specified in order to make overriding GUIElementStyles more easy
(Previously you has to either override it completely, or not at all, which made certain things difficult)

Marko Pintera 12 лет назад
Родитель
Сommit
7721cbbd15
49 измененных файлов с 399 добавлено и 212 удалено
  1. 3 0
      BansheeEngine/BansheeEngine.vcxproj
  2. 9 0
      BansheeEngine/BansheeEngine.vcxproj.filters
  3. 2 2
      BansheeEngine/Include/BsGUIButton.h
  4. 1 3
      BansheeEngine/Include/BsGUIElement.h
  5. 1 1
      BansheeEngine/Include/BsGUIInputBox.h
  6. 2 2
      BansheeEngine/Include/BsGUILabel.h
  7. 4 76
      BansheeEngine/Include/BsGUILayoutOptions.h
  8. 1 1
      BansheeEngine/Include/BsGUIListBox.h
  9. 58 0
      BansheeEngine/Include/BsGUIOptions.h
  10. 1 1
      BansheeEngine/Include/BsGUIScrollArea.h
  11. 1 1
      BansheeEngine/Include/BsGUIScrollBarHandle.h
  12. 1 1
      BansheeEngine/Include/BsGUIScrollBarHorz.h
  13. 1 1
      BansheeEngine/Include/BsGUIScrollBarVert.h
  14. 2 2
      BansheeEngine/Include/BsGUITexture.h
  15. 4 4
      BansheeEngine/Include/BsGUIToggle.h
  16. 1 1
      BansheeEngine/Include/BsGUIViewport.h
  17. 1 0
      BansheeEngine/Include/BsPrerequisites.h
  18. 22 0
      BansheeEngine/Include/BsProfilerOverlay.h
  19. 4 4
      BansheeEngine/Source/BsGUIButton.cpp
  20. 0 16
      BansheeEngine/Source/BsGUIElement.cpp
  21. 3 3
      BansheeEngine/Source/BsGUIInputBox.cpp
  22. 4 4
      BansheeEngine/Source/BsGUILabel.cpp
  23. 72 0
      BansheeEngine/Source/BsGUILayoutOptions.cpp
  24. 3 3
      BansheeEngine/Source/BsGUIListBox.cpp
  25. 54 0
      BansheeEngine/Source/BsGUIOptions.cpp
  26. 3 3
      BansheeEngine/Source/BsGUIScrollArea.cpp
  27. 4 2
      BansheeEngine/Source/BsGUIScrollBar.cpp
  28. 3 3
      BansheeEngine/Source/BsGUIScrollBarHandle.cpp
  29. 3 3
      BansheeEngine/Source/BsGUIScrollBarHorz.cpp
  30. 3 3
      BansheeEngine/Source/BsGUIScrollBarVert.cpp
  31. 6 6
      BansheeEngine/Source/BsGUITexture.cpp
  32. 8 8
      BansheeEngine/Source/BsGUIToggle.cpp
  33. 3 3
      BansheeEngine/Source/BsGUIViewport.cpp
  34. 32 1
      BansheeEngine/Source/BsProfilerOverlay.cpp
  35. 2 2
      CamelotClient/Include/BsGUITabButton.h
  36. 1 1
      CamelotClient/Include/BsGUIWindowDropArea.h
  37. 1 1
      CamelotClient/Include/BsGUIWindowFrame.h
  38. 2 1
      CamelotClient/Source/BsGUIMenuBar.cpp
  39. 6 6
      CamelotClient/Source/BsGUITabButton.cpp
  40. 1 1
      CamelotClient/Source/BsGUITabbedTitleBar.cpp
  41. 3 3
      CamelotClient/Source/BsGUIWindowDropArea.cpp
  42. 3 3
      CamelotClient/Source/BsGUIWindowFrame.cpp
  43. 2 1
      CamelotClient/Source/BsGUIWindowFrameWidget.cpp
  44. 2 2
      CamelotClient/Source/CmTestTextSprite.cpp
  45. 3 3
      CamelotClient/Source/DbgEditorWidget1.cpp
  46. 2 0
      CamelotCore/Include/CmProfiler.h
  47. 6 0
      CamelotCore/Source/CmApplication.cpp
  48. 5 0
      CamelotCore/Source/CmProfiler.cpp
  49. 40 30
      CamelotUtility/Source/CmCPUProfiler.cpp

+ 3 - 0
BansheeEngine/BansheeEngine.vcxproj

@@ -245,6 +245,7 @@
     <ClInclude Include="Include\BsGUIElementBase.h" />
     <ClInclude Include="Include\BsGUIInputTool.h" />
     <ClInclude Include="Include\BsGUIInputBox.h" />
+    <ClInclude Include="Include\BsGUIOptions.h" />
     <ClInclude Include="Include\BsGUITextInputEvent.h" />
     <ClInclude Include="Include\BsGUIInputCaret.h" />
     <ClInclude Include="Include\BsGUIInputSelection.h" />
@@ -305,10 +306,12 @@
     <ClCompile Include="Source\BsGUIDropDownBox.cpp" />
     <ClCompile Include="Source\BsGUIDropDownBoxManager.cpp" />
     <ClCompile Include="Source\BsGUIHelper.cpp" />
+    <ClCompile Include="Source\BsGUILayoutOptions.cpp" />
     <ClCompile Include="Source\BsGUIListBox.cpp" />
     <ClCompile Include="Source\BsGUIElement.cpp" />
     <ClCompile Include="Source\BsGUIElementBase.cpp" />
     <ClCompile Include="Source\BsGUIInputBox.cpp" />
+    <ClCompile Include="Source\BsGUIOptions.cpp" />
     <ClCompile Include="Source\BsGUITextInputEvent.cpp" />
     <ClCompile Include="Source\BsGUIInputCaret.cpp" />
     <ClCompile Include="Source\BsGUIInputSelection.cpp" />

+ 9 - 0
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -225,6 +225,9 @@
     <ClInclude Include="Include\BsProfilerOverlay.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsGUIOptions.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsGUIElement.cpp">
@@ -395,5 +398,11 @@
     <ClCompile Include="Source\BsProfilerOverlay.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsGUIOptions.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsGUILayoutOptions.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 2 - 2
BansheeEngine/Include/BsGUIButton.h

@@ -15,10 +15,10 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIButton* create(GUIWidget& parent, const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUIButton* create(GUIWidget& parent, const CM::HString& text, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIButton* create(GUIWidget& parent, const CM::HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 		static GUIButton* create(GUIWidget& parent, const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUIButton* create(GUIWidget& parent, const GUIContent& content, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIButton* create(GUIWidget& parent, const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 	private:
 		GUIButton(GUIWidget& parent, const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions);

+ 1 - 3
BansheeEngine/Include/BsGUIElement.h

@@ -2,7 +2,7 @@
 
 #include "BsPrerequisites.h"
 #include "BsGUIElementBase.h"
-#include "BsGUILayoutOptions.h"
+#include "BsGUIOptions.h"
 #include "CmRect.h"
 #include "CmInt2.h"
 
@@ -137,8 +137,6 @@ namespace BansheeEngine
 		CM::Rect getContentBounds() const;
 		CM::Rect getContentClipRect() const;
 
-		static GUILayoutOptions getDefaultLayoutOptions(const GUIElementStyle* style);
-
 		GUIWidget* mParent;
 		bool mIsDestroyed;
 		GUILayoutOptions mLayoutOptions;

+ 1 - 1
BansheeEngine/Include/BsGUIInputBox.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIInputBox* create(GUIWidget& parent, bool multiline = false, const GUIElementStyle* style = nullptr);
-		static GUIInputBox* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, bool multiline = false, const GUIElementStyle* style = nullptr);
+		static GUIInputBox* create(GUIWidget& parent, const GUIOptions& layoutOptions, bool multiline = false, const GUIElementStyle* style = nullptr);
 	protected:
 		~GUIInputBox();
 

+ 2 - 2
BansheeEngine/Include/BsGUILabel.h

@@ -13,10 +13,10 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUILabel* create(GUIWidget& parent, const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUILabel* create(GUIWidget& parent, const CM::HString& text, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUILabel* create(GUIWidget& parent, const CM::HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 		static GUILabel* create(GUIWidget& parent, const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUILabel* create(GUIWidget& parent, const GUIContent& content, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUILabel* create(GUIWidget& parent, const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 		void setContent(const GUIContent& content);
 

+ 4 - 76
BansheeEngine/Include/BsGUILayoutOptions.h

@@ -7,84 +7,12 @@ namespace BansheeEngine
 	/**
 	 * @brief	Options that control how an element is positioned and sized in a GUI layout.
 	 */
-	struct GUILayoutOptions
+	struct BS_EXPORT GUILayoutOptions
 	{
-		GUILayoutOptions()
-			:width(0), height(0), minWidth(0), maxWidth(0),
-			minHeight(0), maxHeight(0), fixedWidth(false), fixedHeight(false)
-		{
+		static GUILayoutOptions create(const GUIOptions& options, const GUIElementStyle* style);
+		static GUILayoutOptions create(const GUIElementStyle* style);
 
-		}
-
-		/**
-		 * @brief	Element is fixed to the specified width/height and will not resize.
-		 * 			If elements doesn't fully fit in the layout it will be clipped.
-		 */
-		static GUILayoutOptions fixed(CM::UINT32 _width, CM::UINT32 _height)
-		{
-			GUILayoutOptions layoutOptions;
-			layoutOptions.width = _width;
-			layoutOptions.height = _height;
-			layoutOptions.fixedWidth = true;
-			layoutOptions.fixedHeight = true;
-
-			return layoutOptions;
-		}
-
-		/**
-		 * @brief	Element will resize to fit the layout in both directions.
-		 * 			Optionally you may supply min and max constraints for both directions. 
-		 * 			
-		 *			If constraints are zero they will not be used.
-		 */
-		static GUILayoutOptions expandableXY(CM::UINT32 _minWidth = 0, CM::UINT32 _minHeight = 0, CM::UINT32 _maxWidth = 0, CM::UINT32 _maxHeight = 0)
-		{
-			GUILayoutOptions layoutOptions;
-			layoutOptions.minWidth = _minWidth;
-			layoutOptions.maxWidth = _maxWidth;
-			layoutOptions.minHeight = _minHeight;
-			layoutOptions.maxHeight = _maxHeight;
-			layoutOptions.fixedWidth = false;
-			layoutOptions.fixedHeight = false;
-
-			return layoutOptions;
-		}
-
-		/**
-		 * @brief	Element will resize to fit the layout in the X direction, while it will be fixed in the Y direction.
-		 * 			Optionally you may supply min and max constraints for width. 
-		 * 			
-		 *			If constraints are zero they will not be used.
-		 */
-		static GUILayoutOptions expandableX(CM::UINT32 _height, CM::UINT32 _minWidth = 0, CM::UINT32 _maxWidth = 0)
-		{
-			GUILayoutOptions layoutOptions;
-			layoutOptions.height = _height;
-			layoutOptions.minWidth = _minWidth;
-			layoutOptions.maxWidth = _maxWidth;
-			layoutOptions.fixedWidth = false;
-			layoutOptions.fixedHeight = true;
-
-			return layoutOptions;
-		}
-
-		/**
-		 * @brief	Element will resize to fit the layout in the Y direction, while it will be fixed in the X direction.
-		 * 			Optionally you may supply min and max constraints for height. 
-		 * 			
-		 *			If constraints are zero they will not be used.
-		 */
-		static GUILayoutOptions expandableY(CM::UINT32 _width, CM::UINT32 _minHeight = 0, CM::UINT32 _maxHeight = 0)
-		{
-			GUILayoutOptions layoutOptions;
-			layoutOptions.width = _width;
-			layoutOptions.minHeight = _minHeight;
-			layoutOptions.maxHeight = _maxHeight;
-			layoutOptions.fixedWidth = true;
-			layoutOptions.fixedHeight = false;
-
-			return layoutOptions;
-		}
+		GUILayoutOptions();
 
 		CM::UINT32 width, height;
 		CM::UINT32 minWidth, maxWidth, minHeight, maxHeight;

+ 1 - 1
BansheeEngine/Include/BsGUIListBox.h

@@ -14,7 +14,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIListBox* create(GUIWidget& parent, const CM::Vector<CM::HString>::type& elements, const GUIElementStyle* style = nullptr);
-		static GUIListBox* create(GUIWidget& parent, const CM::Vector<CM::HString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIListBox* create(GUIWidget& parent, const CM::Vector<CM::HString>::type& elements, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 		boost::signal<void(CM::UINT32)> onSelectionChanged;
 	protected:

+ 58 - 0
BansheeEngine/Include/BsGUIOptions.h

@@ -0,0 +1,58 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include <boost/preprocessor.hpp>
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUIOption
+	{
+		enum class Type
+		{
+			FixedWidth,
+			FlexibleWidth,
+			FixedHeight,
+			FlexibleHeight
+		};
+
+	public:
+		GUIOption();
+
+		static GUIOption fixedWidth(CM::UINT32 value);
+		static GUIOption flexibleWidth(CM::UINT32 min = 0, CM::UINT32 max = 0);
+
+		static GUIOption fixedHeight(CM::UINT32 value);
+		static GUIOption flexibleHeight(CM::UINT32 min = 0, CM::UINT32 max = 0);
+
+	private:
+		friend struct GUILayoutOptions;
+
+		CM::UINT32 min, max;
+		Type type;
+	};
+
+	class BS_EXPORT GUIOptions
+	{
+	public:
+		// Constructor that accepts an arbitrary number of parameters > 0
+#define MAKE_GUIOPTION_CONSTRUCTOR(z, n, unused)											\
+	GUIOptions(BOOST_PP_ENUM_PARAMS(n, const GUIOption& e) )	\
+	{			\
+			mOptions.push_back(e0);					\
+			BOOST_PP_REPEAT_FROM_TO(1, n, ADD_OPTION, ~) 									\
+	}
+
+#define ADD_OPTION(z, i, unused) \
+	mOptions.push_back(BOOST_PP_CAT(e, i));
+
+	BOOST_PP_REPEAT_FROM_TO(1, 15, MAKE_GUIOPTION_CONSTRUCTOR, ~)
+
+#undef ADD_OPTION
+#undef MAKE_GUIOPTION_CONSTRUCTOR
+
+	private:
+		friend struct GUILayoutOptions;
+
+		CM::Vector<GUIOption>::type mOptions;
+	};
+}

+ 1 - 1
BansheeEngine/Include/BsGUIScrollArea.h

@@ -11,7 +11,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIScrollArea* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
-		static GUIScrollArea* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIScrollArea* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 
 		GUILayout& getLayout() const { return *mContentLayout; }
 

+ 1 - 1
BansheeEngine/Include/BsGUIScrollBarHandle.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIScrollBarHandle* create(GUIWidget& parent, bool horizontal, const GUIElementStyle* style = nullptr);
-		static GUIScrollBarHandle* create(GUIWidget& parent, bool horizontal, const GUILayoutOptions& layoutOptions, 
+		static GUIScrollBarHandle* create(GUIWidget& parent, bool horizontal, const GUIOptions& layoutOptions, 
 			const GUIElementStyle* style = nullptr);
 
 		void setHandleSize(CM::UINT32 size);

+ 1 - 1
BansheeEngine/Include/BsGUIScrollBarHorz.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIScrollBarHorz* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
-		static GUIScrollBarHorz* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarHorz* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 	protected:
 		GUIScrollBarHorz(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
 		~GUIScrollBarHorz();

+ 1 - 1
BansheeEngine/Include/BsGUIScrollBarVert.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIScrollBarVert* create(GUIWidget& parent, const GUIElementStyle* style = nullptr);
-		static GUIScrollBarVert* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarVert* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
 	protected:
 		GUIScrollBarVert(GUIWidget& parent, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
 		~GUIScrollBarVert();

+ 2 - 2
BansheeEngine/Include/BsGUITexture.h

@@ -21,10 +21,10 @@ namespace BansheeEngine
 
 		static GUITexture* create(GUIWidget& parent, const SpriteTexturePtr& texture, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, 
 			const GUIElementStyle* style = nullptr);
-		static GUITexture* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const SpriteTexturePtr& texture, 
+		static GUITexture* create(GUIWidget& parent, const GUIOptions& layoutOptions, const SpriteTexturePtr& texture, 
 			GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
 		static GUITexture* create(GUIWidget& parent, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
-		static GUITexture* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
+		static GUITexture* create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIImageScaleMode scale = GUIImageScaleMode::StretchToFit, const GUIElementStyle* style = nullptr);
 	protected:
 		ImageSprite* mImageSprite;
 		IMAGE_SPRITE_DESC mDesc;

+ 4 - 4
BansheeEngine/Include/BsGUIToggle.h

@@ -16,16 +16,16 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIToggle* create(GUIWidget& parent, const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const CM::HString& text, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(GUIWidget& parent, const GUIOptions& layoutOptions, const CM::HString& text, const GUIElementStyle* style = nullptr);
 	
 		static GUIToggle* create(GUIWidget& parent, const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(GUIWidget& parent, const GUIOptions& layoutOptions, const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
 
 		static GUIToggle* create(GUIWidget& parent, const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIContent& content, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIContent& content, const GUIElementStyle* style = nullptr);
 
 		static GUIToggle* create(GUIWidget& parent, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
 
 		static std::shared_ptr<GUIToggleGroup> createToggleGroup();
 

+ 1 - 1
BansheeEngine/Include/BsGUIViewport.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 		/**
 		 * @note Render target used by the GUIWidget and Camera must be the same. 
 		 */
-		static GUIViewport* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const HCamera& camera, 
+		static GUIViewport* create(GUIWidget& parent, const GUIOptions& layoutOptions, const HCamera& camera, 
 			float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style = nullptr);
 	protected:
 		~GUIViewport();

+ 1 - 0
BansheeEngine/Include/BsPrerequisites.h

@@ -52,6 +52,7 @@ namespace BansheeEngine
 	class GUIInputCaret;
 	class GUIInputSelection;
 	struct GUILayoutOptions;
+	class GUIOptions;
 	class GUIToggleGroup;
 	class GUIListBox;
 	class GUIDropDownDataEntry;

+ 22 - 0
BansheeEngine/Include/BsProfilerOverlay.h

@@ -78,6 +78,28 @@ namespace BansheeEngine
 		GUILayout* mBasicLayoutContents;
 		GUILayout* mPreciseLayoutContents;
 
+		GUIElement* mTitleBasicName;
+		GUIElement* mTitleBasicPctOfParent;
+		GUIElement* mTitleBasicNumCalls;
+		GUIElement* mTitleBasicAvgTime;
+		GUIElement* mTitleBasicTotalTime;
+		GUIElement* mTitleBasicMaxTime;
+		GUIElement* mTitleBasicAvgTitleSelf;
+		GUIElement* mTitleBasicTotalTimeSelf;
+		GUIElement* mTitleBasicEstOverhead;
+		GUIElement* mTitleBasicEstOverheadSelf;
+
+		GUIElement* mTitlePreciseName;
+		GUIElement* mTitlePrecisePctOfParent;
+		GUIElement* mTitlePreciseNumCalls;
+		GUIElement* mTitlePreciseAvgTime;
+		GUIElement* mTitlePreciseTotalTime;
+		GUIElement* mTitlePreciseMaxTime;
+		GUIElement* mTitlePreciseAvgTitleSelf;
+		GUIElement* mTitlePreciseTotalTimeSelf;
+		GUIElement* mTitlePreciseEstOverhead;
+		GUIElement* mTitlePreciseEstOverheadSelf;
+
 		CM::Vector<BasicRow>::type mBasicRows;
 		CM::Vector<PreciseRow>::type mPreciseRows;
 

+ 4 - 4
BansheeEngine/Source/BsGUIButton.cpp

@@ -28,7 +28,7 @@ namespace BansheeEngine
 		return create(parent, GUIContent(text), style);
 	}
 
-	GUIButton* GUIButton::create(GUIWidget& parent, const HString& text, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(GUIWidget& parent, const HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		return create(parent, GUIContent(text), layoutOptions, style);
 	}
@@ -41,10 +41,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(parent, style, content, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(parent, style, content, GUILayoutOptions::create(style));
 	}
 
-	GUIButton* GUIButton::create(GUIWidget& parent, const GUIContent& content, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(GUIWidget& parent, const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -52,6 +52,6 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(parent, style, content, layoutOptions);
+		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(parent, style, content, GUILayoutOptions::create(layoutOptions, style));
 	}
 }

+ 0 - 16
BansheeEngine/Source/BsGUIElement.cpp

@@ -189,22 +189,6 @@ namespace BansheeEngine
 		return contentBounds.contains(position);
 	}
 
-	GUILayoutOptions GUIElement::getDefaultLayoutOptions(const GUIElementStyle* style)
-	{
-		GUILayoutOptions layoutOptions;
-
-		layoutOptions.fixedWidth = style->fixedWidth;
-		layoutOptions.fixedHeight = style->fixedHeight;
-		layoutOptions.width = style->width;
-		layoutOptions.height = style->height;
-		layoutOptions.minWidth = style->minWidth;
-		layoutOptions.maxWidth = style->maxWidth;
-		layoutOptions.minHeight = style->minHeight;
-		layoutOptions.maxHeight = style->maxHeight;
-
-		return layoutOptions;
-	}
-
 	void GUIElement::destroy(GUIElement* element)
 	{
 		if(element->mParent != nullptr)

+ 3 - 3
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -64,10 +64,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(parent, style, getDefaultLayoutOptions(style), multiline);
+		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(parent, style, GUILayoutOptions::create(style), multiline);
 	}
 
-	GUIInputBox* GUIInputBox::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, bool multiline, const GUIElementStyle* style)
+	GUIInputBox* GUIInputBox::create(GUIWidget& parent, const GUIOptions& layoutOptions, bool multiline, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -75,7 +75,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(parent, style, layoutOptions, multiline);
+		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(parent, style, GUILayoutOptions::create(layoutOptions, style), multiline);
 	}
 
 	UINT32 GUIInputBox::getNumRenderElements() const

+ 4 - 4
BansheeEngine/Source/BsGUILabel.cpp

@@ -88,7 +88,7 @@ namespace BansheeEngine
 		return create(parent, GUIContent(text), style);
 	}
 
-	GUILabel* GUILabel::create(GUIWidget& parent, const HString& text, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(GUIWidget& parent, const HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		return create(parent, GUIContent(text), layoutOptions, style);
 	}
@@ -101,10 +101,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(parent, style, content, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(parent, style, content, GUILayoutOptions::create(style));
 	}
 
-	GUILabel* GUILabel::create(GUIWidget& parent, const GUIContent& content, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(GUIWidget& parent, const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -112,7 +112,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(parent, style, content, layoutOptions);
+		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(parent, style, content, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	const String& GUILabel::getGUITypeName()

+ 72 - 0
BansheeEngine/Source/BsGUILayoutOptions.cpp

@@ -0,0 +1,72 @@
+#include "BsGUILayoutOptions.h"
+#include "BsGUIElementStyle.h"
+#include "BsGUIOptions.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	GUILayoutOptions GUILayoutOptions::create(const GUIOptions& options, const GUIElementStyle* style)
+	{
+		GUILayoutOptions layoutOptions;
+
+		layoutOptions.fixedWidth = style->fixedWidth;
+		layoutOptions.fixedHeight = style->fixedHeight;
+		layoutOptions.width = style->width;
+		layoutOptions.height = style->height;
+		layoutOptions.minWidth = style->minWidth;
+		layoutOptions.maxWidth = style->maxWidth;
+		layoutOptions.minHeight = style->minHeight;
+		layoutOptions.maxHeight = style->maxHeight;
+
+		for(auto& option : options.mOptions)
+		{
+			switch(option.type)
+			{
+			case GUIOption::Type::FixedWidth:
+				layoutOptions.fixedWidth = true;
+				layoutOptions.width = option.min;
+				break;
+			case GUIOption::Type::FixedHeight:
+				layoutOptions.fixedHeight = true;
+				layoutOptions.height = option.min;
+				break;
+			case GUIOption::Type::FlexibleWidth:
+				layoutOptions.fixedWidth = false;
+				layoutOptions.minWidth = option.min;
+				layoutOptions.maxWidth = option.max;
+				break;
+			case GUIOption::Type::FlexibleHeight:
+				layoutOptions.fixedHeight = false;
+				layoutOptions.minHeight = option.min;
+				layoutOptions.maxHeight = option.max;
+				break;
+			}
+		}
+
+		return layoutOptions;
+	}
+
+	GUILayoutOptions GUILayoutOptions::create(const GUIElementStyle* style)
+	{
+		GUILayoutOptions layoutOptions;
+
+		layoutOptions.fixedWidth = style->fixedWidth;
+		layoutOptions.fixedHeight = style->fixedHeight;
+		layoutOptions.width = style->width;
+		layoutOptions.height = style->height;
+		layoutOptions.minWidth = style->minWidth;
+		layoutOptions.maxWidth = style->maxWidth;
+		layoutOptions.minHeight = style->minHeight;
+		layoutOptions.maxHeight = style->maxHeight;
+
+		return layoutOptions;
+	}
+
+	GUILayoutOptions::GUILayoutOptions()
+		:width(0), height(0), minWidth(0), maxWidth(0),
+		minHeight(0), maxHeight(0), fixedWidth(false), fixedHeight(false)
+	{
+
+	}
+}

+ 3 - 3
BansheeEngine/Source/BsGUIListBox.cpp

@@ -41,10 +41,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, GUILayoutOptions::create(style));
 	}
 
-	GUIListBox* GUIListBox::create(GUIWidget& parent, const Vector<HString>::type& elements, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIListBox* GUIListBox::create(GUIWidget& parent, const Vector<HString>::type& elements, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -52,7 +52,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, layoutOptions);
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(parent, style, elements, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	bool GUIListBox::mouseEvent(const GUIMouseEvent& ev)

+ 54 - 0
BansheeEngine/Source/BsGUIOptions.cpp

@@ -0,0 +1,54 @@
+#include "BsGUIOptions.h"
+
+using namespace CamelotFramework;
+
+namespace BansheeEngine
+{
+	GUIOption::GUIOption()
+		:min(0), max(0), type(Type::FixedWidth)
+	{
+
+	}
+
+	GUIOption GUIOption::fixedWidth(CM::UINT32 value)
+	{
+		GUIOption option;
+
+		option.min = option.max = value;
+		option.type = Type::FixedWidth;
+
+		return option;
+	}
+
+	GUIOption GUIOption::flexibleWidth(CM::UINT32 min, CM::UINT32 max)
+	{
+		GUIOption option;
+
+		option.min = min;
+		option.max = max;
+		option.type = Type::FlexibleWidth;
+
+		return option;
+	}
+
+	GUIOption GUIOption::fixedHeight(CM::UINT32 value)
+	{
+		GUIOption option;
+
+		option.min = option.max = value;
+		option.type = Type::FixedHeight;
+
+		return option;
+	}
+
+	GUIOption GUIOption::flexibleHeight(CM::UINT32 min, CM::UINT32 max)
+	{
+		GUIOption option;
+
+		option.min = min;
+		option.max = max;
+		option.type = Type::FlexibleHeight;
+
+		return option;
+	}
+}

+ 3 - 3
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -262,10 +262,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(parent, style, GUILayoutOptions::create(style));
 	}
 
-	GUIScrollArea* GUIScrollArea::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollArea* GUIScrollArea::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -273,7 +273,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(parent, style, layoutOptions);
+		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(parent, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	const String& GUIScrollArea::getGUITypeName()

+ 4 - 2
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -28,7 +28,8 @@ namespace BansheeEngine
 			mUpBtn = GUIButton::create(parent, HString(L""), parent.getSkin().getStyle("ScrollLeftBtn"));
 			mDownBtn = GUIButton::create(parent, HString(L""), parent.getSkin().getStyle("ScrollRightBtn"));
 
-			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, GUILayoutOptions::expandableX(6), parent.getSkin().getStyle("ScrollBarHorzBtn"));
+			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, 
+				GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleWidth(6)), parent.getSkin().getStyle("ScrollBarHorzBtn"));
 		}
 		else
 		{
@@ -37,7 +38,8 @@ namespace BansheeEngine
 			mUpBtn = GUIButton::create(parent, HString(L""), parent.getSkin().getStyle("ScrollUpBtn"));
 			mDownBtn = GUIButton::create(parent, HString(L""), parent.getSkin().getStyle("ScrollDownBtn"));
 
-			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, GUILayoutOptions::expandableY(6), parent.getSkin().getStyle("ScrollBarVertBtn"));
+			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, 
+				GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleWidth(6)), parent.getSkin().getStyle("ScrollBarVertBtn"));
 		}
 
 		mLayout->addSpace(2);

+ 3 - 3
BansheeEngine/Source/BsGUIScrollBarHandle.cpp

@@ -40,10 +40,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(parent, horizontal, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(parent, horizontal, style, GUILayoutOptions::create(style));
 	}
 
-	GUIScrollBarHandle* GUIScrollBarHandle::create(GUIWidget& parent, bool horizontal, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarHandle* GUIScrollBarHandle::create(GUIWidget& parent, bool horizontal, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -51,7 +51,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(parent, horizontal, style, layoutOptions);
+		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(parent, horizontal, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	void GUIScrollBarHandle::setHandleSize(CM::UINT32 size)

+ 3 - 3
BansheeEngine/Source/BsGUIScrollBarHorz.cpp

@@ -33,10 +33,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, GUILayoutOptions::create(style));
 	}
 
-	GUIScrollBarHorz* GUIScrollBarHorz::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarHorz* GUIScrollBarHorz::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -44,7 +44,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, layoutOptions);
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(parent, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	const String& GUIScrollBarHorz::getGUITypeName()

+ 3 - 3
BansheeEngine/Source/BsGUIScrollBarVert.cpp

@@ -33,10 +33,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, GUILayoutOptions::create(style));
 	}
 
-	GUIScrollBarVert* GUIScrollBarVert::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarVert* GUIScrollBarVert::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -44,7 +44,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, layoutOptions);
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(parent, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	const String& GUIScrollBarVert::getGUITypeName()

+ 6 - 6
BansheeEngine/Source/BsGUITexture.cpp

@@ -47,10 +47,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, texture, scale, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, texture, scale, GUILayoutOptions::create(style));
 	}
 
-	GUITexture* GUITexture::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const SpriteTexturePtr& texture, 
+	GUITexture* GUITexture::create(GUIWidget& parent, const GUIOptions& layoutOptions, const SpriteTexturePtr& texture, 
 		GUIImageScaleMode scale, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
@@ -59,7 +59,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, texture, scale, layoutOptions);
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, texture, scale, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	GUITexture* GUITexture::create(GUIWidget& parent, GUIImageScaleMode scale, const GUIElementStyle* style)
@@ -70,10 +70,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, GUILayoutOptions::create(style));
 	}
 
-	GUITexture* GUITexture::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, GUIImageScaleMode scale, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUIImageScaleMode scale, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -81,7 +81,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, layoutOptions);
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	UINT32 GUITexture::getNumRenderElements() const

+ 8 - 8
BansheeEngine/Source/BsGUIToggle.cpp

@@ -40,7 +40,7 @@ namespace BansheeEngine
 		return create(parent, GUIContent(text), style);
 	}
 
-	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const HString& text, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUIOptions& layoutOptions, const HString& text, const GUIElementStyle* style)
 	{
 		return create(parent, layoutOptions, GUIContent(text), style);
 	}
@@ -50,7 +50,7 @@ namespace BansheeEngine
 		return create(parent, GUIContent(text), toggleGroup, style);
 	}
 
-	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUIOptions& layoutOptions, const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
 	{
 		return create(parent, layoutOptions, GUIContent(text), toggleGroup, style);
 	}
@@ -63,10 +63,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, nullptr, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, nullptr, GUILayoutOptions::create(style));
 	}
 
-	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIContent& content, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIContent& content, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -74,7 +74,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, nullptr, layoutOptions);
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, nullptr, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
@@ -85,10 +85,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, toggleGroup, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, toggleGroup, GUILayoutOptions::create(style));
 	}
 
-	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -96,7 +96,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, toggleGroup, layoutOptions);
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, content, toggleGroup, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	std::shared_ptr<GUIToggleGroup> GUIToggle::createToggleGroup()

+ 3 - 3
BansheeEngine/Source/BsGUIViewport.cpp

@@ -45,10 +45,10 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(parent, style, camera, aspectRatio, fieldOfView, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(parent, style, camera, aspectRatio, fieldOfView, GUILayoutOptions::create(style));
 	}
 
-	GUIViewport* GUIViewport::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const HCamera& camera, 
+	GUIViewport* GUIViewport::create(GUIWidget& parent, const GUIOptions& layoutOptions, const HCamera& camera, 
 		float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
@@ -57,7 +57,7 @@ namespace BansheeEngine
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(parent, style, camera, aspectRatio, fieldOfView, layoutOptions);
+		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(parent, style, camera, aspectRatio, fieldOfView, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	UINT32 GUIViewport::getNumRenderElements() const

+ 32 - 1
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -7,6 +7,7 @@
 #include "BsGUIElement.h"
 #include "BsGUILabel.h"
 #include "BsGUISpace.h"
+#include "BsEngineGUI.h"
 #include "CmProfiler.h"
 
 using namespace CamelotFramework;
@@ -233,7 +234,12 @@ namespace BansheeEngine
 
 	ProfilerOverlay::ProfilerOverlay(const CM::ViewportPtr& target, const CM::RenderWindowPtr& ownerWindow)
 		:mIsShown(false), mBasicAreaLabels(nullptr), mPreciseAreaLabels(nullptr), mBasicAreaContents(nullptr), mPreciseAreaContents(nullptr),
-		mBasicLayoutLabels(nullptr), mPreciseLayoutLabels(nullptr), mBasicLayoutContents(nullptr), mPreciseLayoutContents(nullptr)
+		mBasicLayoutLabels(nullptr), mPreciseLayoutLabels(nullptr), mBasicLayoutContents(nullptr), mPreciseLayoutContents(nullptr),
+		mTitleBasicName(nullptr), mTitleBasicPctOfParent(nullptr), mTitleBasicNumCalls(nullptr), mTitleBasicAvgTime(nullptr), 
+		mTitleBasicTotalTime(nullptr), mTitleBasicMaxTime(nullptr), mTitleBasicAvgTitleSelf(nullptr), mTitleBasicTotalTimeSelf(nullptr), 
+		mTitleBasicEstOverhead(nullptr), mTitleBasicEstOverheadSelf(nullptr), mTitlePreciseName(nullptr), mTitlePrecisePctOfParent(nullptr), 
+		mTitlePreciseNumCalls(nullptr), mTitlePreciseAvgTime(nullptr), mTitlePreciseTotalTime(nullptr), mTitlePreciseMaxTime(nullptr), 
+		mTitlePreciseAvgTitleSelf(nullptr), mTitlePreciseTotalTimeSelf(nullptr), mTitlePreciseEstOverhead(nullptr), mTitlePreciseEstOverheadSelf(nullptr)
 	{
 		setTarget(target, ownerWindow);
 
@@ -265,6 +271,8 @@ namespace BansheeEngine
 
 		mWidgetSO = SceneObject::create("ProfilerOverlay");
 		mWidget = mWidgetSO->addComponent<GUIWidget>(mTarget.get(), mOwnerWindow.get());
+		mWidget->setDepth(127);
+		mWidget->setSkin(EngineGUI::instance().getSkin());
 
 		mBasicAreaLabels = GUIArea::create(*mWidget, 0, 0);
 		mPreciseAreaLabels = GUIArea::create(*mWidget, 0, 0);
@@ -276,6 +284,29 @@ namespace BansheeEngine
 		mBasicLayoutContents = &mBasicAreaContents->getLayout().addLayoutY();
 		mPreciseLayoutContents = &mPreciseAreaContents->getLayout().addLayoutY();
 
+		// Set up title bars
+		//mTitleBasicName = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::fixed(200, 20));
+		//mTitleBasicPctOfParent = GUILabel::create(*mWidget, HString(L"% parent"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicNumCalls = GUILabel::create(*mWidget, HString(L"Num. calls"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicAvgTime = GUILabel::create(*mWidget, HString(L"Avg. time"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicTotalTime = GUILabel::create(*mWidget, HString(L"Total time"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicMaxTime = GUILabel::create(*mWidget, HString(L"Max time"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicAvgTitleSelf = GUILabel::create(*mWidget, HString(L"Avg. self time"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicTotalTimeSelf = GUILabel::create(*mWidget, HString(L"Total self time"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicEstOverhead = GUILabel::create(*mWidget, HString(L"Est. overhead"), GUILayoutOptions::expandableY(100));
+		//mTitleBasicEstOverheadSelf = GUILabel::create(*mWidget, HString(L"Est. self overhead"), GUILayoutOptions::expandableY(100));
+
+		//mTitlePreciseName = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePrecisePctOfParent = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseNumCalls = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseAvgTime = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseTotalTime = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseMaxTime = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseAvgTitleSelf = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseTotalTimeSelf = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseEstOverhead = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+		//mTitlePreciseEstOverheadSelf = GUILabel::create(*mWidget, HString(L"Name"), GUILayoutOptions::expandableY(200));
+
 		updateAreaSizes();
 	}
 

+ 2 - 2
CamelotClient/Include/BsGUITabButton.h

@@ -14,10 +14,10 @@ namespace BansheeEditor
 		static const CM::String& getGUITypeName();
 
 		static GUITabButton* create(BS::GUIWidget& parent, GUITabbedTitleBar* titleBar, CM::UINT32 index, const CM::HString& text, const BS::GUIElementStyle* style = nullptr);
-		static GUITabButton* create(BS::GUIWidget& parent, const BS::GUILayoutOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const CM::HString& text, const BS::GUIElementStyle* style = nullptr);
+		static GUITabButton* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const CM::HString& text, const BS::GUIElementStyle* style = nullptr);
 	
 		static GUITabButton* create(BS::GUIWidget& parent, GUITabbedTitleBar* titleBar, CM::UINT32 index, const BS::GUIContent& content, const BS::GUIElementStyle* style = nullptr);
-		static GUITabButton* create(BS::GUIWidget& parent, const BS::GUILayoutOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const BS::GUIContent& content, const BS::GUIElementStyle* style = nullptr);
+		static GUITabButton* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const BS::GUIContent& content, const BS::GUIElementStyle* style = nullptr);
 
 		CM::UINT32 getIndex() const { return mIndex; }
 

+ 1 - 1
CamelotClient/Include/BsGUIWindowDropArea.h

@@ -12,7 +12,7 @@ namespace BansheeEditor
 		static const CM::String& getGUITypeName();
 
 		static GUIWindowDropArea* create(BS::GUIWidget& parent, const BS::GUIElementStyle* style = nullptr);
-		static GUIWindowDropArea* create(BS::GUIWidget& parent, const BS::GUILayoutOptions& layoutOptions, const BS::GUIElementStyle* style = nullptr);
+		static GUIWindowDropArea* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, const BS::GUIElementStyle* style = nullptr);
 
 		void setFocused(bool focused);
 

+ 1 - 1
CamelotClient/Include/BsGUIWindowFrame.h

@@ -12,7 +12,7 @@ namespace BansheeEditor
 		static const CM::String& getGUITypeName();
 
 		static GUIWindowFrame* create(BS::GUIWidget& parent, const BS::GUIElementStyle* style = nullptr);
-		static GUIWindowFrame* create(BS::GUIWidget& parent, const BS::GUILayoutOptions& layoutOptions, const BS::GUIElementStyle* style = nullptr);
+		static GUIWindowFrame* create(BS::GUIWidget& parent, const BS::GUIOptions& layoutOptions, const BS::GUIElementStyle* style = nullptr);
 
 		void setFocused(bool focused);
 	protected:

+ 2 - 1
CamelotClient/Source/BsGUIMenuBar.cpp

@@ -25,7 +25,8 @@ namespace BansheeEditor
 		mBackgroundArea = GUIArea::create(*parent, 0, 0, 1, 13, 9900);
 		mMainArea = GUIArea::create(*parent, 0, 0, 1, 13, 9899);
 
-		mBgTexture = GUITexture::create(*parent, GUILayoutOptions::expandableXY(), GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("MenuBarBg"));
+		mBgTexture = GUITexture::create(*parent, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), 
+			GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("MenuBarBg"));
 		mBackgroundArea->getLayout().addElement(mBgTexture);
 
 		mLogoTexture = GUITexture::create(*parent, GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("MenuBarBansheeLogo"));

+ 6 - 6
CamelotClient/Source/BsGUITabButton.cpp

@@ -32,10 +32,10 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, GUIContent(text), getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, GUIContent(text), GUILayoutOptions::create(style));
 	}
 
-	GUITabButton* GUITabButton::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const HString& text, const GUIElementStyle* style)
+	GUITabButton* GUITabButton::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const HString& text, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -43,7 +43,7 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, GUIContent(text), layoutOptions);
+		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, GUIContent(text), GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	GUITabButton* GUITabButton::create(GUIWidget& parent, GUITabbedTitleBar* titleBar, CM::UINT32 index, const GUIContent& content, const GUIElementStyle* style)
@@ -54,10 +54,10 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, content, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, content, GUILayoutOptions::create(style));
 	}
 
-	GUITabButton* GUITabButton::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const GUIContent& content, const GUIElementStyle* style)
+	GUITabButton* GUITabButton::create(GUIWidget& parent, const GUIOptions& layoutOptions, GUITabbedTitleBar* titleBar, CM::UINT32 index, const GUIContent& content, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -65,7 +65,7 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, content, layoutOptions);
+		return new (cm_alloc<GUITabButton, PoolAlloc>()) GUITabButton(parent, style, titleBar, index, content, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	bool GUITabButton::mouseEvent(const GUIMouseEvent& ev)

+ 1 - 1
CamelotClient/Source/BsGUITabbedTitleBar.cpp

@@ -28,7 +28,7 @@ namespace BansheeEditor
 
 		mMainArea = GUIArea::create(*parent, 0, 0, 1, 13, 9899);
 
-		GUIWindowDropArea* dragDropElement = GUIWindowDropArea::create(*parent, GUILayoutOptions::expandableX(13, 20), parent->getSkin().getStyle("TabbedBarDropArea"));
+		GUIWindowDropArea* dragDropElement = GUIWindowDropArea::create(*parent, GUIOptions(GUIOption::flexibleWidth(20)), parent->getSkin().getStyle("TabbedBarDropArea"));
 		mLastDropElement = dragDropElement;
 
 		mMinBtn = GUIButton::create(*parent, HString(L""), parent->getSkin().getStyle("WinMinimizeBtn"));

+ 3 - 3
CamelotClient/Source/BsGUIWindowDropArea.cpp

@@ -33,10 +33,10 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, GUILayoutOptions::create(style));
 	}
 
-	GUIWindowDropArea* GUIWindowDropArea::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIWindowDropArea* GUIWindowDropArea::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -44,7 +44,7 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, layoutOptions);
+		return new (cm_alloc<GUIWindowDropArea, PoolAlloc>()) GUIWindowDropArea(parent, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	void GUIWindowDropArea::setFocused(bool focused)

+ 3 - 3
CamelotClient/Source/BsGUIWindowFrame.cpp

@@ -38,10 +38,10 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, GUILayoutOptions::create(style));
 	}
 
-	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIWindowFrame* GUIWindowFrame::create(GUIWidget& parent, const GUIOptions& layoutOptions, const GUIElementStyle* style)
 	{
 		if(style == nullptr)
 		{
@@ -49,7 +49,7 @@ namespace BansheeEditor
 			style = skin.getStyle(getGUITypeName());
 		}
 
-		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, layoutOptions);
+		return new (cm_alloc<GUIWindowFrame, PoolAlloc>()) GUIWindowFrame(parent, style, GUILayoutOptions::create(layoutOptions, style));
 	}
 
 	void GUIWindowFrame::setFocused(bool focused)

+ 2 - 1
CamelotClient/Source/BsGUIWindowFrameWidget.cpp

@@ -22,7 +22,8 @@ namespace BansheeEditor
 		setSkin(skin);
 
 		GUIArea* backgroundArea = GUIArea::createStretchedXY(*this, 0, 0, 0, 0, 500);
-		backgroundArea->getLayout().addElement(GUITexture::create(*this, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, getSkin().getStyle("WindowBackground")));
+		backgroundArea->getLayout().addElement(GUITexture::create(*this, GUIOptions(GUIOption::flexibleWidth(), GUIOption::flexibleHeight()), 
+			GUIImageScaleMode::RepeatToFit, getSkin().getStyle("WindowBackground")));
 
 		mWindowFrameArea = GUIArea::createStretchedXY(*this, 0, 0, 0, 0, 499);
 

+ 2 - 2
CamelotClient/Source/CmTestTextSprite.cpp

@@ -45,7 +45,7 @@ namespace CamelotFramework
 		GUIArea* area = GUIArea::createStretchedXY(*this, 0, 0, 0, 0);
 
 		SpriteTexturePtr spriteTex = std::make_shared<SpriteTexture>(sceneView->getBindableColorTexture());
-		area->getLayout().addElement(GUITexture::create(*this, GUILayoutOptions::fixed(800, 600), spriteTex));
+		area->getLayout().addElement(GUITexture::create(*this, GUIOptions(GUIOption::fixedWidth(800), GUIOption::fixedHeight(600)), spriteTex));
 		mLabel = GUILabel::create(*this, HString(L""));
 		area->getLayout().addElement(mLabel);
 
@@ -53,7 +53,7 @@ namespace CamelotFramework
 		dropDownElements.push_back(HString(L"Ejlement #1"));
 		dropDownElements.push_back(HString(L"Element #2"));
 		dropDownElements.push_back(HString(L"Element #3"));
-		area->getLayout().addElement(GUIListBox::create(*this, dropDownElements, GUILayoutOptions::fixed(50, 13)));
+		area->getLayout().addElement(GUIListBox::create(*this, dropDownElements, GUIOptions(GUIOption::fixedWidth(50), GUIOption::fixedHeight(13))));
 
 		GUIButton* button = GUIButton::create(*this, HString(L"dbgBtn"));
 		button->onClick.connect(boost::bind(&TestTextSprite::dbgBtn, this));

+ 3 - 3
CamelotClient/Source/DbgEditorWidget1.cpp

@@ -55,9 +55,9 @@ namespace BansheeEditor
 		//scrollLayout.addElement(GUIButton::create(*mGUI, L"Test K"));
 		//scrollLayout.addElement(GUIButton::create(*mGUI, L"Test L"));
 
-		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUILayoutOptions::fixed(100, 100), true));
-		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUILayoutOptions::fixed(100, 100), true));
-		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUILayoutOptions::fixed(100, 100), true));
+		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)), true));
+		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)), true));
+		scrollLayout.addElement(GUIInputBox::create(getParentWidget(), GUIOptions(GUIOption::fixedWidth(100), GUIOption::fixedHeight(100)), true));
 
 		//GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
 		//otherLayout.addElement(mDbgLabel);

+ 2 - 0
CamelotCore/Include/CmProfiler.h

@@ -101,4 +101,6 @@ namespace CamelotFramework
 
 		CPUProfiler* mCPUProfiler;
 	};
+
+	CM_EXPORT Profiler& gProfiler();
 }

+ 6 - 0
CamelotCore/Source/CmApplication.cpp

@@ -29,6 +29,7 @@
 #include "CmDeferredCallManager.h"
 #include "CmCoreThread.h"
 #include "CmStringTable.h"
+#include "CmProfiler.h"
 
 #include "CmMaterial.h"
 #include "CmShader.h"
@@ -93,6 +94,8 @@ namespace CamelotFramework
 
 		while(mRunMainLoop)
 		{
+			gProfiler().beginThread("Sim");
+
 			Platform::update();
 			DeferredCallManager::instance().update();
 			RenderWindowManager::instance().update();
@@ -122,6 +125,9 @@ namespace CamelotFramework
 			gCoreThread().queueCommand(boost::bind(&Application::frameRenderingFinishedCallback, this));
 
 			gTime().update();
+
+			gProfiler().endThread();
+			gProfiler().update();
 		}
 	}
 

+ 5 - 0
CamelotCore/Source/CmProfiler.cpp

@@ -41,4 +41,9 @@ namespace CamelotFramework
 
 		return mSavedReports[idx];
 	}
+
+	Profiler& gProfiler()
+	{
+		return Profiler::instance();
+	}
 }

+ 40 - 30
CamelotUtility/Source/CmCPUProfiler.cpp

@@ -586,26 +586,31 @@ namespace CamelotFramework
 			}
 		}
 
-		Vector<CPUProfilerBasicSamplingEntry*>::type finalBasicEntries;
-		finalBasicEntries.push_back(&report.mBasicSamplingRootEntry);
-		
-		UINT32 curEntryIdx = 0;
-		for(auto& curEntry : newBasicEntries)
+		if(newBasicEntries.size() > 0)
 		{
-			CPUProfilerBasicSamplingEntry* basicEntry = finalBasicEntries[curEntryIdx];
+			Vector<CPUProfilerBasicSamplingEntry*>::type finalBasicEntries;
 
-			basicEntry->childEntries.resize(curEntry.childIndexes.size());
-			UINT32 idx = 0;
-			for(auto& childIdx : curEntry.childIndexes)
+			report.mBasicSamplingRootEntry = basicEntries[newBasicEntries[0].entryIdx];
+			finalBasicEntries.push_back(&report.mBasicSamplingRootEntry);
+
+			UINT32 curEntryIdx = 0;
+			for(auto& curEntry : newBasicEntries)
 			{
-				TempEntry& childEntry = newBasicEntries[childIdx];
-				basicEntry->childEntries[idx] = basicEntries[childEntry.entryIdx];
+				CPUProfilerBasicSamplingEntry* basicEntry = finalBasicEntries[curEntryIdx];
 
-				finalBasicEntries.push_back(&(basicEntry->childEntries[idx]));
-				idx++;
-			}
+				basicEntry->childEntries.resize(curEntry.childIndexes.size());
+				UINT32 idx = 0;
+				for(auto& childIdx : curEntry.childIndexes)
+				{
+					TempEntry& childEntry = newBasicEntries[childIdx];
+					basicEntry->childEntries[idx] = basicEntries[childEntry.entryIdx];
+
+					finalBasicEntries.push_back(&(basicEntry->childEntries[idx]));
+					idx++;
+				}
 
-			curEntryIdx++;
+				curEntryIdx++;
+			}
 		}
 
 		// Prune empty precise entries
@@ -649,26 +654,31 @@ namespace CamelotFramework
 			}
 		}
 
-		Vector<CPUProfilerPreciseSamplingEntry*>::type finalPreciseEntries;
-		finalPreciseEntries.push_back(&report.mPreciseSamplingRootEntry);
-
-		curEntryIdx = 0;
-		for(auto& curEntry : newPreciseEntries)
+		if(newPreciseEntries.size() > 0)
 		{
-			CPUProfilerPreciseSamplingEntry* preciseEntry = finalPreciseEntries[curEntryIdx];
+			Vector<CPUProfilerPreciseSamplingEntry*>::type finalPreciseEntries;
 
-			preciseEntry->childEntries.resize(curEntry.childIndexes.size());
-			UINT32 idx = 0;
-			for(auto& childIdx : curEntry.childIndexes)
+			report.mPreciseSamplingRootEntry = preciseEntries[newPreciseEntries[0].entryIdx];
+			finalPreciseEntries.push_back(&report.mPreciseSamplingRootEntry);
+
+			UINT32 curEntryIdx = 0;
+			for(auto& curEntry : newPreciseEntries)
 			{
-				TempEntry& childEntry = newPreciseEntries[childIdx];
-				preciseEntry->childEntries[idx] = preciseEntries[childEntry.entryIdx];
+				CPUProfilerPreciseSamplingEntry* preciseEntry = finalPreciseEntries[curEntryIdx];
 
-				finalPreciseEntries.push_back(&preciseEntry->childEntries.back());
-				idx++;
-			}
+				preciseEntry->childEntries.resize(curEntry.childIndexes.size());
+				UINT32 idx = 0;
+				for(auto& childIdx : curEntry.childIndexes)
+				{
+					TempEntry& childEntry = newPreciseEntries[childIdx];
+					preciseEntry->childEntries[idx] = preciseEntries[childEntry.entryIdx];
+
+					finalPreciseEntries.push_back(&preciseEntry->childEntries.back());
+					idx++;
+				}
 
-			curEntryIdx++;
+				curEntryIdx++;
+			}
 		}
 
 		return report;