Browse Source

GUI refactor Engine compiles

Marko Pintera 12 years ago
parent
commit
52456d3772
41 changed files with 413 additions and 354 deletions
  1. 5 5
      BansheeEngine/Include/BsGUIButton.h
  2. 1 2
      BansheeEngine/Include/BsGUIButtonBase.h
  3. 6 6
      BansheeEngine/Include/BsGUIDropDownBox.h
  4. 3 3
      BansheeEngine/Include/BsGUIDropDownHitBox.h
  5. 9 0
      BansheeEngine/Include/BsGUIElement.h
  6. 4 5
      BansheeEngine/Include/BsGUIInputBox.h
  7. 5 5
      BansheeEngine/Include/BsGUILabel.h
  8. 5 2
      BansheeEngine/Include/BsGUILayoutOptions.h
  9. 3 3
      BansheeEngine/Include/BsGUIListBox.h
  10. 3 3
      BansheeEngine/Include/BsGUIRenderTexture.h
  11. 9 8
      BansheeEngine/Include/BsGUIScrollArea.h
  12. 1 1
      BansheeEngine/Include/BsGUIScrollBar.h
  13. 12 4
      BansheeEngine/Include/BsGUIScrollBarHandle.h
  14. 3 3
      BansheeEngine/Include/BsGUIScrollBarHorz.h
  15. 3 3
      BansheeEngine/Include/BsGUIScrollBarVert.h
  16. 11 10
      BansheeEngine/Include/BsGUITexture.h
  17. 16 9
      BansheeEngine/Include/BsGUIToggle.h
  18. 5 3
      BansheeEngine/Include/BsGUIViewport.h
  19. 2 0
      BansheeEngine/Include/BsSpriteTexture.h
  20. 10 10
      BansheeEngine/Source/BsGUIButton.cpp
  21. 7 16
      BansheeEngine/Source/BsGUIButtonBase.cpp
  22. 35 29
      BansheeEngine/Source/BsGUIDropDownBox.cpp
  23. 5 5
      BansheeEngine/Source/BsGUIDropDownHitBox.cpp
  24. 2 0
      BansheeEngine/Source/BsGUIElement.cpp
  25. 1 1
      BansheeEngine/Source/BsGUIElementContainer.cpp
  26. 13 21
      BansheeEngine/Source/BsGUIInputBox.cpp
  27. 10 10
      BansheeEngine/Source/BsGUILabel.cpp
  28. 1 1
      BansheeEngine/Source/BsGUILayout.cpp
  29. 27 23
      BansheeEngine/Source/BsGUILayoutOptions.cpp
  30. 6 6
      BansheeEngine/Source/BsGUIListBox.cpp
  31. 6 6
      BansheeEngine/Source/BsGUIRenderTexture.cpp
  32. 15 20
      BansheeEngine/Source/BsGUIScrollArea.cpp
  33. 10 10
      BansheeEngine/Source/BsGUIScrollBar.cpp
  34. 37 22
      BansheeEngine/Source/BsGUIScrollBarHandle.cpp
  35. 6 6
      BansheeEngine/Source/BsGUIScrollBarHorz.cpp
  36. 6 6
      BansheeEngine/Source/BsGUIScrollBarVert.cpp
  37. 28 20
      BansheeEngine/Source/BsGUITexture.cpp
  38. 20 18
      BansheeEngine/Source/BsGUIToggle.cpp
  39. 20 12
      BansheeEngine/Source/BsGUIViewport.cpp
  40. 37 37
      BansheeEngine/Source/BsProfilerOverlay.cpp
  41. 5 0
      BansheeEngine/Source/BsSpriteTexture.cpp

+ 5 - 5
BansheeEngine/Include/BsGUIButton.h

@@ -14,14 +14,14 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIButton* create(const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUIButton* create(const CM::HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIButton* create(const CM::HString& text, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIButton* create(const CM::HString& text, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
-		static GUIButton* create(const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUIButton* create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIButton* create(const GUIContent& content, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIButton* create(const GUIContent& content, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		virtual ElementType getElementType() const { return ElementType::Button; }
 	private:
-		GUIButton(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions);
+		GUIButton(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions);
 	};
 }

+ 1 - 2
BansheeEngine/Include/BsGUIButtonBase.h

@@ -35,7 +35,7 @@ namespace BansheeEngine
 		boost::signal<void()> onHover;
 		boost::signal<void()> onOut;
 	protected:
-		GUIButtonBase(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions);
+		GUIButtonBase(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions);
 		virtual ~GUIButtonBase();
 
 		/**
@@ -79,7 +79,6 @@ namespace BansheeEngine
 		GUIButtonState getState() const { return mActiveState; }
 
 		const HSpriteTexture& getActiveTexture() const;
-		bool isActiveTextureLoaded() const;
 	private:
 		ImageSprite* mImageSprite;
 		ImageSprite* mContentImageSprite;

+ 6 - 6
BansheeEngine/Include/BsGUIDropDownBox.h

@@ -161,12 +161,12 @@ namespace BansheeEngine
 
 		static const CM::UINT32 DROP_DOWN_BOX_WIDTH;
 
-		const GUIElementStyle* mScrollUpStyle;
-		const GUIElementStyle* mScrollDownStyle;
-		const GUIElementStyle* mEntryBtnStyle;
-		const GUIElementStyle* mEntryExpBtnStyle;
-		const GUIElementStyle* mSeparatorStyle;
-		const GUIElementStyle* mBackgroundStyle;
+		CM::String mScrollUpStyle;
+		CM::String mScrollDownStyle;
+		CM::String mEntryBtnStyle;
+		CM::String mEntryExpBtnStyle;
+		CM::String mSeparatorStyle;
+		CM::String mBackgroundStyle;
 		HSpriteTexture mScrollUpBtnArrow;
 		HSpriteTexture mScrollDownBtnArrow;
 

+ 3 - 3
BansheeEngine/Include/BsGUIDropDownHitBox.h

@@ -10,8 +10,8 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIDropDownHitBox* create(bool captureMouse, const GUIElementStyle* style = nullptr);
-		static GUIDropDownHitBox* create(bool captureMouse, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIDropDownHitBox* create(bool captureMouse);
+		static GUIDropDownHitBox* create(bool captureMouse, const GUIOptions& layoutOptions);
 
 		void setBounds(const CM::RectI& bounds) { mBounds.clear(); mBounds.push_back(bounds); }
 		void setBounds(const CM::Vector<CM::RectI>::type& bounds) { mBounds = bounds; }
@@ -20,7 +20,7 @@ namespace BansheeEngine
 		boost::signal<void()> onFocusGained;
 
 	private:
-		GUIDropDownHitBox(bool captureMouse, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		GUIDropDownHitBox(bool captureMouse, const GUILayoutOptions& layoutOptions);
 
 		virtual bool commandEvent(const GUICommandEvent& ev);
 		virtual bool mouseEvent(const GUIMouseEvent& ev);

+ 9 - 0
BansheeEngine/Include/BsGUIElement.h

@@ -157,6 +157,15 @@ namespace BansheeEngine
 
 		void setLayoutOptions(const GUILayoutOptions& layoutOptions);
 		
+		template<class T>
+		static const CM::String& getStyleName(const CM::String& overrideStyle)
+		{
+			if(overrideStyle == CM::StringUtil::BLANK)
+				return T::getGUITypeName();
+
+			return overrideStyle;
+		}
+
 		CM::RectI getVisibleBounds() const;
 		CM::RectI getContentBounds() const;
 		CM::RectI getContentClipRect() const;

+ 4 - 5
BansheeEngine/Include/BsGUIInputBox.h

@@ -20,9 +20,9 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIInputBox* create(bool multiline = false, const GUIElementStyle* style = nullptr);
-		static GUIInputBox* create(bool multiline, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
-		static GUIInputBox* create(const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIInputBox* create(bool multiline = false, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIInputBox* create(bool multiline, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIInputBox* create(const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		const CM::WString& getText() const { return mText; }
 		void setText(const CM::WString& text);
@@ -33,7 +33,7 @@ namespace BansheeEngine
 
 		virtual CM::Vector2I _getOptimalSize() const;
 	protected:
-		GUIInputBox(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline);
+		GUIInputBox(const CM::String& styleName, const GUILayoutOptions& layoutOptions, bool multiline);
 		virtual ~GUIInputBox();
 
 		/**
@@ -128,7 +128,6 @@ namespace BansheeEngine
 		CM::RectI getTextClipRect() const;
 		TEXT_SPRITE_DESC getTextDesc() const;
 		const HSpriteTexture& getActiveTexture() const;
-		bool isActiveTextureLoaded() const;
 		
 		void cutText();
 		void copyText();

+ 5 - 5
BansheeEngine/Include/BsGUILabel.h

@@ -12,11 +12,11 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUILabel* create(const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUILabel* create(const CM::HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUILabel* create(const CM::HString& text, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUILabel* create(const CM::HString& text, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
-		static GUILabel* create(const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUILabel* create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUILabel* create(const GUIContent& content, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUILabel* create(const GUIContent& content, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		void setContent(const GUIContent& content);
 
@@ -62,6 +62,6 @@ namespace BansheeEngine
 
 		TEXT_SPRITE_DESC mDesc;
 		
-		GUILabel(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions);
+		GUILabel(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions);
 	};
 }

+ 5 - 2
BansheeEngine/Include/BsGUILayoutOptions.h

@@ -9,13 +9,16 @@ namespace BansheeEngine
 	 */
 	struct BS_EXPORT GUILayoutOptions
 	{
-		static GUILayoutOptions create(const GUIOptions& options, const GUIElementStyle* style);
-		static GUILayoutOptions create(const GUIElementStyle* style);
+		static GUILayoutOptions create();
+		static GUILayoutOptions create(const GUIOptions& options);
 
 		GUILayoutOptions();
 
+		void updateWithStyle(const GUIElementStyle* style);
+
 		CM::UINT32 width, height;
 		CM::UINT32 minWidth, maxWidth, minHeight, maxHeight;
 		bool fixedWidth, fixedHeight;
+		bool overridenWidth, overridenHeight;
 	};
 }

+ 3 - 3
BansheeEngine/Include/BsGUIListBox.h

@@ -13,8 +13,8 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIListBox* create(const CM::Vector<CM::HString>::type& elements, const GUIElementStyle* style = nullptr);
-		static GUIListBox* create(const CM::Vector<CM::HString>::type& elements, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIListBox* create(const CM::Vector<CM::HString>::type& elements, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIListBox* create(const CM::Vector<CM::HString>::type& elements, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		void setElements(const CM::Vector<CM::HString>::type& elements);
 
@@ -29,7 +29,7 @@ namespace BansheeEngine
 		CM::Vector<CM::HString>::type mElements;
 		bool mIsListBoxOpen;
 
-		GUIListBox(const GUIElementStyle* style, const CM::Vector<CM::HString>::type& elements, const GUILayoutOptions& layoutOptions);
+		GUIListBox(const CM::String& styleName, const CM::Vector<CM::HString>::type& elements, const GUILayoutOptions& layoutOptions);
 
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 

+ 3 - 3
BansheeEngine/Include/BsGUIRenderTexture.h

@@ -16,13 +16,13 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIRenderTexture* create(const CM::RenderTexturePtr& texture, const GUIElementStyle* style = nullptr);
-		static GUIRenderTexture* create(const CM::RenderTexturePtr& texture, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIRenderTexture* create(const CM::RenderTexturePtr& texture, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIRenderTexture* create(const CM::RenderTexturePtr& texture, const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 	protected:
 		const CM::RenderTexture* mSourceTexture;
 
-		GUIRenderTexture(const GUIElementStyle* style, const CM::RenderTexturePtr& texture, const GUILayoutOptions& layoutOptions);
+		GUIRenderTexture(const CM::String& styleName, const CM::RenderTexturePtr& texture, const GUILayoutOptions& layoutOptions);
 		virtual ~GUIRenderTexture();
 
 		/**

+ 9 - 8
BansheeEngine/Include/BsGUIScrollArea.h

@@ -18,16 +18,17 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUIScrollArea* create(ScrollBarType vertBarType, ScrollBarType horzBarType, 
-			const GUIElementStyle* scrollBarStyle = nullptr, const GUIElementStyle* scrollAreaStyle = nullptr);
+			const CM::String& scrollBarStyle = CM::StringUtil::BLANK, const CM::String& scrollAreaStyle = CM::StringUtil::BLANK);
 
 		static GUIScrollArea* create(ScrollBarType vertBarType, ScrollBarType horzBarType, 
-			const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle = nullptr, 
-			const GUIElementStyle* scrollAreaStyle = nullptr);
+			const GUIOptions& layoutOptions, const CM::String& scrollBarStyle = CM::StringUtil::BLANK, 
+			const CM::String& scrollAreaStyle = CM::StringUtil::BLANK);
 
-		static GUIScrollArea* create(const GUIElementStyle* scrollBarStyle = nullptr, const GUIElementStyle* scrollAreaStyle = nullptr);
+		static GUIScrollArea* create(const CM::String& scrollBarStyle = CM::StringUtil::BLANK, 
+			const CM::String& scrollAreaStyle = CM::StringUtil::BLANK);
 
-		static GUIScrollArea* create(const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle = nullptr, 
-			const GUIElementStyle* scrollAreaStyle = nullptr);
+		static GUIScrollArea* create(const GUIOptions& layoutOptions, const CM::String& scrollBarStyle = CM::StringUtil::BLANK, 
+			const CM::String& scrollAreaStyle = CM::StringUtil::BLANK);
 
 		virtual ElementType getElementType() const { return ElementType::ScrollArea; }
 
@@ -53,11 +54,11 @@ namespace BansheeEngine
 		virtual void updateClippedBounds();
 	private:
 		GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, 
-			const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle, const GUILayoutOptions& layoutOptions);
+			const CM::String& scrollBarStyle, const CM::String& scrollAreaStyle, const GUILayoutOptions& layoutOptions);
 
 		ScrollBarType mVertBarType;
 		ScrollBarType mHorzBarType;
-		const GUIElementStyle* mScrollBarStyle;
+		CM::String mScrollBarStyle;
 
 		GUILayout* mContentLayout;
 		GUIScrollBarVert* mVertScroll;

+ 1 - 1
BansheeEngine/Include/BsGUIScrollBar.h

@@ -28,7 +28,7 @@ namespace BansheeEngine
 
 		virtual CM::Vector2I _getOptimalSize() const;
 	protected:
-		GUIScrollBar(bool horizontal, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		GUIScrollBar(bool horizontal, const CM::String& styleName, const GUILayoutOptions& layoutOptions);
 		virtual ~GUIScrollBar();
 
 		/**

+ 12 - 4
BansheeEngine/Include/BsGUIScrollBarHandle.h

@@ -9,12 +9,17 @@ namespace BansheeEngine
 {
 	class BS_EXPORT GUIScrollBarHandle : public GUIElement
 	{
+		enum class State
+		{
+			Normal, Hover, Active
+		};
+
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIScrollBarHandle* create(bool horizontal, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarHandle* create(bool horizontal, const CM::String& styleName = CM::StringUtil::BLANK);
 		static GUIScrollBarHandle* create(bool horizontal, const GUIOptions& layoutOptions, 
-			const GUIElementStyle* style = nullptr);
+			const CM::String& styleName = CM::StringUtil::BLANK);
 
 		void setHandleSize(CM::UINT32 size);
 		void setHandlePos(float pct);
@@ -63,16 +68,19 @@ namespace BansheeEngine
 	private:
 		ImageSprite* mImageSprite;
 		CM::UINT32 mHandleSize;
-		HSpriteTexture mCurTexture;
+		
 		bool mHorizontal; // Otherwise its vertical
 		float mHandlePos;
 		CM::INT32 mDragStartPos;
 		bool mMouseOverHandle;
 		bool mHandleDragged;
+		State mState;
 
-		GUIScrollBarHandle(bool horizontal, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		GUIScrollBarHandle(bool horizontal, const CM::String& styleName, const GUILayoutOptions& layoutOptions);
 
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 		bool isOnHandle(const CM::Vector2I& pos) const;
+
+		const HSpriteTexture& getActiveTexture() const;
 	};
 }

+ 3 - 3
BansheeEngine/Include/BsGUIScrollBarHorz.h

@@ -12,10 +12,10 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIScrollBarHorz* create(const GUIElementStyle* style = nullptr);
-		static GUIScrollBarHorz* create(const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarHorz* create(const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIScrollBarHorz* create(const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 	protected:
-		GUIScrollBarHorz(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		GUIScrollBarHorz(const CM::String& styleName, const GUILayoutOptions& layoutOptions);
 		~GUIScrollBarHorz();
 	};
 }

+ 3 - 3
BansheeEngine/Include/BsGUIScrollBarVert.h

@@ -12,10 +12,10 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIScrollBarVert* create(const GUIElementStyle* style = nullptr);
-		static GUIScrollBarVert* create(const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIScrollBarVert* create(const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIScrollBarVert* create(const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 	protected:
-		GUIScrollBarVert(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions);
+		GUIScrollBarVert(const CM::String& styleName, const GUILayoutOptions& layoutOptions);
 		~GUIScrollBarVert();
 	};
 }

+ 11 - 10
BansheeEngine/Include/BsGUITexture.h

@@ -20,20 +20,21 @@ namespace BansheeEngine
 		static const CM::String& getGUITypeName();
 
 		static GUITexture* create(const HSpriteTexture& texture, GUIImageScaleMode scale, 
-			const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+			const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 		static GUITexture* create(const HSpriteTexture& texture, GUIImageScaleMode scale, 
-			const GUIElementStyle* style = nullptr);
+			const CM::String& styleName = CM::StringUtil::BLANK);
 
 		static GUITexture* create(const HSpriteTexture& texture, 
-			const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
-		static GUITexture* create(const HSpriteTexture& texture, const GUIElementStyle* style = nullptr);
+			const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUITexture* create(const HSpriteTexture& texture, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
 
-		
-		static GUITexture* create(GUIImageScaleMode scale, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
-		static GUITexture* create(GUIImageScaleMode scale, const GUIElementStyle* style = nullptr);
+		static GUITexture* create(GUIImageScaleMode scale, const GUIOptions& layoutOptions, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUITexture* create(GUIImageScaleMode scale, const CM::String& styleName = CM::StringUtil::BLANK);
 
-		static GUITexture* create(const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
-		static GUITexture* create(const GUIElementStyle* style = nullptr);
+		static GUITexture* create(const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUITexture* create(const CM::String& styleName = CM::StringUtil::BLANK);
 
 		void setTexture(const HSpriteTexture& texture);
 		
@@ -47,7 +48,7 @@ namespace BansheeEngine
 		GUIImageScaleMode mScaleMode;
 		bool mUsingStyleTexture;
 
-		GUITexture(const GUIElementStyle* style, const HSpriteTexture& texture, GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions);
+		GUITexture(const CM::String& styleName, const HSpriteTexture& texture, GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions);
 		virtual ~GUITexture();
 
 		/**

+ 16 - 9
BansheeEngine/Include/BsGUIToggle.h

@@ -15,17 +15,23 @@ namespace BansheeEngine
 	public:
 		static const CM::String& getGUITypeName();
 
-		static GUIToggle* create(const CM::HString& text, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(const CM::HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(const CM::HString& text, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIToggle* create(const CM::HString& text, const GUIOptions& layoutOptions, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
 	
-		static GUIToggle* create(const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIToggle* create(const CM::HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+			const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
-		static GUIToggle* create(const GUIContent& content, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(const GUIContent& content, const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIToggle* create(const GUIContent& content, const GUIOptions& layoutOptions, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
 
-		static GUIToggle* create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style = nullptr);
-		static GUIToggle* create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+			const CM::String& styleName = CM::StringUtil::BLANK);
+		static GUIToggle* create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+			const GUIOptions& layoutOptions, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		static std::shared_ptr<GUIToggleGroup> createToggleGroup();
 
@@ -43,7 +49,8 @@ namespace BansheeEngine
 		virtual ~GUIToggle();
 
 	protected:
-		GUIToggle(const GUIElementStyle* style, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUILayoutOptions& layoutOptions);
+		GUIToggle(const CM::String& styleName, const GUIContent& content, 
+			std::shared_ptr<GUIToggleGroup> toggleGroup, const GUILayoutOptions& layoutOptions);
 
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 

+ 5 - 3
BansheeEngine/Include/BsGUIViewport.h

@@ -17,13 +17,13 @@ namespace BansheeEngine
 		/**
 		 * @note Render target used by the GUIWidget and Camera must be the same. 
 		 */
-		static GUIViewport* create(const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style = nullptr);
+		static GUIViewport* create(const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		/**
 		 * @note Render target used by the GUIWidget and Camera must be the same. 
 		 */
 		static GUIViewport* create(const GUIOptions& layoutOptions, const HCamera& camera, 
-			float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style = nullptr);
+			float aspectRatio, CM::Degree fieldOfView, const CM::String& styleName = CM::StringUtil::BLANK);
 
 		virtual CM::Vector2I _getOptimalSize() const;
 
@@ -67,6 +67,8 @@ namespace BansheeEngine
 		CM::Degree mFieldOfView;
 		CM::Radian mVerticalFOV;
 
-		GUIViewport(const GUIElementStyle* style, const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const GUILayoutOptions& layoutOptions);
+		GUIViewport(const CM::String& styleName, const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const GUILayoutOptions& layoutOptions);
+
+		void _changeParentWidget(BS::GUIWidget* widget);
 	};
 }

+ 2 - 0
BansheeEngine/Include/BsSpriteTexture.h

@@ -20,6 +20,8 @@ namespace BansheeEngine
 		static const HSpriteTexture& dummy();
 		static HSpriteTexture create(const CM::HTexture& texture);
 		static HSpriteTexture create(const CM::Vector2& uvOffset, const CM::Vector2& uvScale, const CM::HTexture& texture);
+
+		static bool checkIsLoaded(const HSpriteTexture& tex);
 	private:
 		friend class SpriteTextureRTTI;
 

+ 10 - 10
BansheeEngine/Source/BsGUIButton.cpp

@@ -19,27 +19,27 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIButton::GUIButton(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions)
-		:GUIButtonBase(style, content, layoutOptions)
+	GUIButton::GUIButton(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions)
+		:GUIButtonBase(styleName, content, layoutOptions)
 	{ }
 
-	GUIButton* GUIButton::create(const HString& text, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(const HString& text, const String& styleName)
 	{
-		return create(GUIContent(text), style);
+		return create(GUIContent(text), styleName);
 	}
 
-	GUIButton* GUIButton::create(const HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(const HString& text, const GUIOptions& layoutOptions, const String& styleName)
 	{
-		return create(GUIContent(text), layoutOptions, style);
+		return create(GUIContent(text), layoutOptions, styleName);
 	}
 
-	GUIButton* GUIButton::create(const GUIContent& content, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(const GUIContent& content, const String& styleName)
 	{
-		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(style, content, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(getStyleName<GUIButton>(styleName), content, GUILayoutOptions::create());
 	}
 
-	GUIButton* GUIButton::create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIButton* GUIButton::create(const GUIContent& content, const GUIOptions& layoutOptions, const String& styleName)
 	{
-		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(style, content, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIButton, PoolAlloc>()) GUIButton(getStyleName<GUIButton>(styleName), content, GUILayoutOptions::create(layoutOptions));
 	}
 }

+ 7 - 16
BansheeEngine/Source/BsGUIButtonBase.cpp

@@ -13,14 +13,14 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	GUIButtonBase::GUIButtonBase(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mContent(content), mContentImageSprite(nullptr), mActiveState(GUIButtonState::Normal)
+	GUIButtonBase::GUIButtonBase(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions)
+		:GUIElement(styleName, layoutOptions), mContent(content), mContentImageSprite(nullptr), mActiveState(GUIButtonState::Normal)
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 
 		HSpriteTexture contentTex = content.getImage();
-		if(contentTex != nullptr && contentTex.isLoaded())
+		if(SpriteTexture::checkIsLoaded(contentTex))
 			mContentImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
 		mLocStringUpdatedConn = mContent.getText().addOnStringModifiedCallback(std::bind(&GUIButtonBase::markContentAsDirty, this));
@@ -105,10 +105,9 @@ namespace BansheeEngine
 		mImageDesc.width = mWidth;
 		mImageDesc.height = mHeight;
 
-		if(isActiveTextureLoaded())
+		const HSpriteTexture& activeTex = getActiveTexture();
+		if(SpriteTexture::checkIsLoaded(activeTex))
 		{
-			const HSpriteTexture& activeTex = getActiveTexture();
-
 			mImageDesc.width = activeTex->getTexture()->getWidth();
 			mImageDesc.height = activeTex->getTexture()->getHeight();
 			mImageDesc.texture = activeTex.getInternalPtr();
@@ -146,10 +145,9 @@ namespace BansheeEngine
 		UINT32 imageWidth = 0;
 		UINT32 imageHeight = 0;
 
-		if(isActiveTextureLoaded())
+		const HSpriteTexture& activeTex = getActiveTexture();
+		if(SpriteTexture::checkIsLoaded(activeTex))
 		{
-			const HSpriteTexture& activeTex = getActiveTexture();
-
 			imageWidth = activeTex->getTexture()->getWidth();
 			imageHeight = activeTex->getTexture()->getHeight();
 		}
@@ -338,11 +336,4 @@ namespace BansheeEngine
 
 		return _getStyle()->normal.texture;
 	}
-
-	bool GUIButtonBase::isActiveTextureLoaded() const
-	{
-		const HSpriteTexture& activeTex = getActiveTexture();
-
-		return activeTex != nullptr && activeTex.isLoaded() && activeTex->getTexture() != nullptr && activeTex->getTexture().isLoaded();
-	}
 }

+ 35 - 29
BansheeEngine/Source/BsGUIDropDownBox.cpp

@@ -75,9 +75,7 @@ namespace BansheeEngine
 
 	GUIDropDownBox::GUIDropDownBox(const HSceneObject& parent, CM::Viewport* target, const GUIDropDownAreaPlacement& placement,
 		const GUIDropDownData& dropDownData, const GUISkin& skin, GUIDropDownType type)
-		:GUIWidget(parent, target), mScrollUpStyle(nullptr), mRootMenu(nullptr),
-		mScrollDownStyle(nullptr), mEntryBtnStyle(nullptr), mEntryExpBtnStyle(nullptr), 
-		mSeparatorStyle(nullptr), mBackgroundStyle(nullptr), mHitBox(nullptr), mCaptureHitBox(nullptr)
+		:GUIWidget(parent, target), mRootMenu(nullptr), mHitBox(nullptr), mCaptureHitBox(nullptr)
 	{
 		String stylePrefix = "";
 		switch(type)
@@ -93,12 +91,12 @@ namespace BansheeEngine
 			break;
 		}
 
-		mScrollUpStyle = skin.getStyle(stylePrefix + "ScrollUpBtn");
-		mScrollDownStyle = skin.getStyle(stylePrefix + "ScrollDownBtn");
-		mEntryBtnStyle = skin.getStyle(stylePrefix + "EntryBtn");
-		mEntryExpBtnStyle = skin.getStyle(stylePrefix + "EntryExpBtn");
-		mSeparatorStyle = skin.getStyle(stylePrefix + "Separator");
-		mBackgroundStyle = skin.getStyle(stylePrefix + "Frame");
+		mScrollUpStyle = stylePrefix + "ScrollUpBtn";
+		mScrollDownStyle = stylePrefix + "ScrollDownBtn";
+		mEntryBtnStyle = stylePrefix + "EntryBtn";
+		mEntryExpBtnStyle = stylePrefix + "EntryExpBtn";
+		mSeparatorStyle = stylePrefix + "Separator";
+		mBackgroundStyle = stylePrefix + "Frame";
 
 		mScrollUpBtnArrow = skin.getStyle(stylePrefix + "ScrollUpBtnArrow")->normal.texture;
 		mScrollDownBtnArrow = skin.getStyle(stylePrefix + "ScrollDownBtnArrow")->normal.texture;
@@ -108,13 +106,13 @@ namespace BansheeEngine
 
 		mLocalizedEntryNames = dropDownData.localizedNames;
 
-		mHitBox = GUIDropDownHitBox::create(*this, false);
+		mHitBox = GUIDropDownHitBox::create(false);
 		mHitBox->onFocusLost.connect(std::bind(&GUIDropDownBox::dropDownFocusLost, this));
 		mHitBox->setFocus(true);
 		mHitBox->_setWidgetDepth(0);
 		mHitBox->_setAreaDepth(0);
 
-		mCaptureHitBox = GUIDropDownHitBox::create(*this, true);
+		mCaptureHitBox = GUIDropDownHitBox::create(true);
 		mCaptureHitBox->setBounds(RectI(0, 0, target->getWidth(), target->getHeight()));
 		mCaptureHitBox->_setWidgetDepth(0);
 		mCaptureHitBox->_setAreaDepth(200);
@@ -172,6 +170,10 @@ namespace BansheeEngine
 	{
 		mAvailableBounds = availableBounds;
 
+		const GUIElementStyle* scrollUpStyle = mOwner->getSkin().getStyle(mOwner->mScrollUpStyle);
+		const GUIElementStyle* scrollDownStyle = mOwner->getSkin().getStyle(mOwner->mScrollDownStyle);
+		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
+
 		RectI dropDownListBounds = placement.getBounds();
 		int potentialLeftStart = 0;
 		int potentialRightStart = 0;
@@ -227,8 +229,8 @@ namespace BansheeEngine
 		UINT32 availableUpwardHeight = (UINT32)std::max(0, potentialTopStart - availableBounds.y);
 
 		//// Prefer down if possible
-		UINT32 helperElementHeight = mOwner->mScrollUpStyle->height + mOwner->mScrollDownStyle->height + 
-			mOwner->mBackgroundStyle->margins.top + mOwner->mBackgroundStyle->margins.bottom;
+		UINT32 helperElementHeight = scrollUpStyle->height + scrollDownStyle->height + 
+			backgroundStyle->margins.top + backgroundStyle->margins.bottom;
 
 		UINT32 maxNeededHeight = helperElementHeight;
 		UINT32 numElements = (UINT32)dropDownData.entries.size();
@@ -272,7 +274,7 @@ namespace BansheeEngine
 		mBackgroundArea = GUIArea::create(*mOwner, x, actualY, width, height);
 		mBackgroundArea->setDepth(100 - depthOffset * 2);
 
-		mBackgroundFrame = GUITexture::create(*mOwner, GUIImageScaleMode::StretchToFit, mOwner->mBackgroundStyle);
+		mBackgroundFrame = GUITexture::create(GUIImageScaleMode::StretchToFit, mOwner->mBackgroundStyle);
 		mBackgroundArea->getLayout().addElement(mBackgroundFrame);
 
 		updateGUIElements();
@@ -313,11 +315,15 @@ namespace BansheeEngine
 		while(mContentLayout->getNumChildren() > 0)
 			mContentLayout->removeChildAt(mContentLayout->getNumChildren() - 1);
 
+		const GUIElementStyle* scrollUpStyle = mOwner->getSkin().getStyle(mOwner->mScrollUpStyle);
+		const GUIElementStyle* scrollDownStyle = mOwner->getSkin().getStyle(mOwner->mScrollDownStyle);
+		const GUIElementStyle* backgroundStyle = mOwner->getSkin().getStyle(mOwner->mBackgroundStyle);
+
 		// Determine if we need scroll up and/or down buttons, number of visible elements and actual height
 		bool needsScrollUp = mPage > 0;
 		UINT32 numElements = (UINT32)mData.entries.size();
 
-		UINT32 usedHeight = mOwner->mBackgroundStyle->margins.top + mOwner->mBackgroundStyle->margins.bottom;
+		UINT32 usedHeight = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
 
 		UINT32 pageStart = 0, pageEnd = 0;
 		UINT32 curPage = 0;
@@ -329,7 +335,7 @@ namespace BansheeEngine
 
 			if(usedHeight > height)
 			{
-				usedHeight += mOwner->mScrollDownStyle->height;
+				usedHeight += scrollDownStyle->height;
 
 				// Remove last few elements until we fit again
 				while(usedHeight > height && i >= 0)
@@ -355,8 +361,8 @@ namespace BansheeEngine
 				}
 
 				pageStart = pageEnd;
-				usedHeight = mOwner->mBackgroundStyle->margins.top + mOwner->mBackgroundStyle->margins.bottom;
-				usedHeight += mOwner->mScrollUpStyle->height;
+				usedHeight = backgroundStyle->margins.top + backgroundStyle->margins.bottom;
+				usedHeight += scrollUpStyle->height;
 
 				curPage++;
 			}
@@ -367,7 +373,7 @@ namespace BansheeEngine
 		{
 			if(mScrollUpBtn == nullptr)
 			{
-				mScrollUpBtn = GUIButton::create(*mOwner, GUIContent(HString(L""), mOwner->mScrollUpBtnArrow), mOwner->mScrollUpStyle);
+				mScrollUpBtn = GUIButton::create(GUIContent(HString(L""), mOwner->mScrollUpBtnArrow), mOwner->mScrollUpStyle);
 				mScrollUpBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollUp, this));
 			}
 
@@ -399,7 +405,7 @@ namespace BansheeEngine
 				}
 				else
 				{
-					separator = GUITexture::create(*mOwner, GUIImageScaleMode::StretchToFit, mOwner->mSeparatorStyle);
+					separator = GUITexture::create(GUIImageScaleMode::StretchToFit, mOwner->mSeparatorStyle);
 				}
 
 				mContentLayout->addElement(separator);
@@ -415,7 +421,7 @@ namespace BansheeEngine
 				}
 				else
 				{
-					expEntryBtn = GUIButton::create(*mOwner, getElementLocalizedName(i), mOwner->mEntryExpBtnStyle);
+					expEntryBtn = GUIButton::create(getElementLocalizedName(i), mOwner->mEntryExpBtnStyle);
 					expEntryBtn->onHover.connect(std::bind(&DropDownSubMenu::openSubMenu, this, expEntryBtn, i));
 				}
 
@@ -432,7 +438,7 @@ namespace BansheeEngine
 				}
 				else
 				{
-					entryBtn = GUIButton::create(*mOwner, getElementLocalizedName(i), mOwner->mEntryBtnStyle);
+					entryBtn = GUIButton::create(getElementLocalizedName(i), mOwner->mEntryBtnStyle);
 					entryBtn->onHover.connect(std::bind(&DropDownSubMenu::closeSubMenu, this));
 					entryBtn->onClick.connect(std::bind(&DropDownSubMenu::elementClicked, this,  i));
 				}
@@ -461,7 +467,7 @@ namespace BansheeEngine
 		{
 			if(mScrollDownBtn == nullptr)
 			{
-				mScrollDownBtn = GUIButton::create(*mOwner, GUIContent(HString(L""), mOwner->mScrollDownBtnArrow), mOwner->mScrollDownStyle);
+				mScrollDownBtn = GUIButton::create(GUIContent(HString(L""), mOwner->mScrollDownBtnArrow), mOwner->mScrollDownStyle);
 				mScrollDownBtn->onClick.connect(std::bind(&DropDownSubMenu::scrollDown, this));
 			}
 
@@ -487,20 +493,20 @@ namespace BansheeEngine
 
 		mVisibleBounds = RectI(x, actualY, width, usedHeight);
 
-		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)mOwner->mBackgroundStyle->margins.left - (INT32)mOwner->mBackgroundStyle->margins.right);
-		UINT32 contentHeight = (UINT32)std::max(0, (INT32)usedHeight - (INT32)mOwner->mBackgroundStyle->margins.top - (INT32)mOwner->mBackgroundStyle->margins.bottom);
+		UINT32 contentWidth = (UINT32)std::max(0, (INT32)width - (INT32)backgroundStyle->margins.left - (INT32)backgroundStyle->margins.right);
+		UINT32 contentHeight = (UINT32)std::max(0, (INT32)usedHeight - (INT32)backgroundStyle->margins.top - (INT32)backgroundStyle->margins.bottom);
 		mContentArea->setSize(contentWidth, contentHeight);
-		mContentArea->setPosition(x + mOwner->mBackgroundStyle->margins.left, actualY + mOwner->mBackgroundStyle->margins.top);
+		mContentArea->setPosition(x + backgroundStyle->margins.left, actualY + backgroundStyle->margins.top);
 	}
 
 	UINT32 GUIDropDownBox::DropDownSubMenu::getElementHeight(CM::UINT32 idx) const
 	{
 		if(mData.entries[idx].isSeparator())
-			return mOwner->mSeparatorStyle->height;
+			return mOwner->getSkin().getStyle(mOwner->mSeparatorStyle)->height;
 		else if(mData.entries[idx].isSubMenu())
-			return mOwner->mEntryExpBtnStyle->height;
+			return mOwner->getSkin().getStyle(mOwner->mEntryExpBtnStyle)->height;
 		else
-			return mOwner->mEntryBtnStyle->height;
+			return mOwner->getSkin().getStyle(mOwner->mEntryBtnStyle)->height;
 	}
 
 	HString GUIDropDownBox::DropDownSubMenu::getElementLocalizedName(CM::UINT32 idx) const

+ 5 - 5
BansheeEngine/Source/BsGUIDropDownHitBox.cpp

@@ -14,17 +14,17 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIDropDownHitBox* GUIDropDownHitBox::create(bool captureMouse, const GUIElementStyle* style)
+	GUIDropDownHitBox* GUIDropDownHitBox::create(bool captureMouse)
 	{
-		return new (cm_alloc<GUIDropDownHitBox, PoolAlloc>()) GUIDropDownHitBox(captureMouse, style, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIDropDownHitBox, PoolAlloc>()) GUIDropDownHitBox(captureMouse, GUILayoutOptions::create());
 	}
 
-	GUIDropDownHitBox* GUIDropDownHitBox::create(bool captureMouse, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIDropDownHitBox* GUIDropDownHitBox::create(bool captureMouse, const GUIOptions& layoutOptions)
 	{
-		return new (cm_alloc<GUIDropDownHitBox, PoolAlloc>()) GUIDropDownHitBox(captureMouse, style, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIDropDownHitBox, PoolAlloc>()) GUIDropDownHitBox(captureMouse, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUIDropDownHitBox::GUIDropDownHitBox(bool captureMouse, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
+	GUIDropDownHitBox::GUIDropDownHitBox(bool captureMouse, const GUILayoutOptions& layoutOptions)
 		:GUIElementContainer(layoutOptions), mCaptureMouse(captureMouse)
 	{
 

+ 2 - 0
BansheeEngine/Source/BsGUIElement.cpp

@@ -219,6 +219,8 @@ namespace BansheeEngine
 		if(newStyle != mStyle)
 		{
 			mStyle = newStyle;
+			mLayoutOptions.updateWithStyle(mStyle);
+
 			markContentAsDirty();
 		}
 	}

+ 1 - 1
BansheeEngine/Source/BsGUIElementContainer.cpp

@@ -7,7 +7,7 @@ using namespace BansheeEngine;
 namespace BansheeEngine
 {
 	GUIElementContainer::GUIElementContainer(const GUILayoutOptions& layoutOptions)
-		:GUIElement(&GUISkin::DefaultStyle, layoutOptions)
+		:GUIElement(StringUtil::BLANK, layoutOptions)
 	{ }
 
 	GUIElementContainer::~GUIElementContainer()

+ 13 - 21
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -34,8 +34,8 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIInputBox::GUIInputBox(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions, bool multiline)
-		:GUIElement(style, layoutOptions), mDragInProgress(false),
+	GUIInputBox::GUIInputBox(const CM::String& styleName, const GUILayoutOptions& layoutOptions, bool multiline)
+		:GUIElement(styleName, layoutOptions), mDragInProgress(false),
 		mCaretShown(false), mSelectionShown(false), mIsMultiline(multiline), mHasFocus(false), mIsMouseOver(false),
 		mState(State::Normal)
 	{
@@ -49,19 +49,19 @@ namespace BansheeEngine
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 
-	GUIInputBox* GUIInputBox::create(bool multiline, const GUIElementStyle* style)
+	GUIInputBox* GUIInputBox::create(bool multiline, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(style, GUILayoutOptions::create(style), multiline);
+		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(getStyleName<GUIInputBox>(styleName), GUILayoutOptions::create(), multiline);
 	}
 
-	GUIInputBox* GUIInputBox::create(bool multiline, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIInputBox* GUIInputBox::create(bool multiline, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(style, GUILayoutOptions::create(layoutOptions, style), multiline);
+		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(getStyleName<GUIInputBox>(styleName), GUILayoutOptions::create(layoutOptions), multiline);
 	}
 
-	GUIInputBox* GUIInputBox::create(const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIInputBox* GUIInputBox::create(const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(style, GUILayoutOptions::create(layoutOptions, style), false);
+		return new (cm_alloc<GUIInputBox, PoolAlloc>()) GUIInputBox(getStyleName<GUIInputBox>(styleName), GUILayoutOptions::create(layoutOptions), false);
 	}
 
 	void GUIInputBox::setText(const CM::WString& text)
@@ -138,10 +138,9 @@ namespace BansheeEngine
 		mImageDesc.borderTop = _getStyle()->border.top;
 		mImageDesc.borderBottom = _getStyle()->border.bottom;
 
-		if(isActiveTextureLoaded())
+		const HSpriteTexture& activeTex = getActiveTexture();
+		if(SpriteTexture::checkIsLoaded(activeTex))
 		{
-			const HSpriteTexture& activeTex = getActiveTexture();
-
 			mImageDesc.width = activeTex->getTexture()->getWidth();
 			mImageDesc.height = activeTex->getTexture()->getHeight();
 			mImageDesc.texture = activeTex.getInternalPtr();
@@ -315,10 +314,10 @@ namespace BansheeEngine
 	{
 		UINT32 imageWidth = 0;
 		UINT32 imageHeight = 0;
-		if(isActiveTextureLoaded())
-		{
-			const HSpriteTexture& activeTex = getActiveTexture();
 
+		const HSpriteTexture& activeTex = getActiveTexture();
+		if(SpriteTexture::checkIsLoaded(activeTex))
+		{
 			imageWidth = activeTex->getTexture()->getWidth();
 			imageHeight = activeTex->getTexture()->getHeight();
 		}
@@ -1055,13 +1054,6 @@ namespace BansheeEngine
 		return _getStyle()->normal.texture;
 	}
 
-	bool GUIInputBox::isActiveTextureLoaded() const
-	{
-		const HSpriteTexture& activeTex = getActiveTexture();
-
-		return activeTex != nullptr && activeTex.isLoaded() && activeTex->getTexture() != nullptr && activeTex->getTexture().isLoaded();
-	}
-
 	GUIContextMenu* GUIInputBox::getContextMenu() const
 	{
 		static bool initialized = false;

+ 10 - 10
BansheeEngine/Source/BsGUILabel.cpp

@@ -11,8 +11,8 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	GUILabel::GUILabel(const GUIElementStyle* style, const GUIContent& content, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mContent(content)
+	GUILabel::GUILabel(const CM::String& styleName, const GUIContent& content, const GUILayoutOptions& layoutOptions)
+		:GUIElement(styleName, layoutOptions), mContent(content)
 	{
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 
@@ -82,24 +82,24 @@ namespace BansheeEngine
 		markContentAsDirty();
 	}
 
-	GUILabel* GUILabel::create(const HString& text, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(const HString& text, const CM::String& styleName)
 	{
-		return create(GUIContent(text), style);
+		return create(GUIContent(text), styleName);
 	}
 
-	GUILabel* GUILabel::create(const HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(const HString& text, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return create(GUIContent(text), layoutOptions, style);
+		return create(GUIContent(text), layoutOptions, styleName);
 	}
 
-	GUILabel* GUILabel::create(const GUIContent& content, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(const GUIContent& content, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(style, content, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(getStyleName<GUILabel>(styleName), content, GUILayoutOptions::create());
 	}
 
-	GUILabel* GUILabel::create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUILabel* GUILabel::create(const GUIContent& content, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(style, content, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUILabel, PoolAlloc>()) GUILabel(getStyleName<GUILabel>(styleName), content, GUILayoutOptions::create(layoutOptions));
 	}
 
 	const String& GUILabel::getGUITypeName()

+ 1 - 1
BansheeEngine/Source/BsGUILayout.cpp

@@ -10,7 +10,7 @@ using namespace CamelotFramework;
 namespace BansheeEngine
 {
 	GUILayout::GUILayout()
-		:mOptimalWidth(0), mOptimalHeight(0), mActualWidth(0), mActualHeight(0), mWidgetParent(nullptr)
+		:mOptimalWidth(0), mOptimalHeight(0), mActualWidth(0), mActualHeight(0)
 	{
 
 	}

+ 27 - 23
BansheeEngine/Source/BsGUILayoutOptions.cpp

@@ -6,18 +6,14 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	GUILayoutOptions GUILayoutOptions::create(const GUIOptions& options, const GUIElementStyle* style)
+	GUILayoutOptions GUILayoutOptions::create()
 	{
-		GUILayoutOptions layoutOptions;
+		return GUILayoutOptions();
+	}
 
-		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;
+	GUILayoutOptions GUILayoutOptions::create(const GUIOptions& options)
+	{
+		GUILayoutOptions layoutOptions;
 
 		for(auto& option : options.mOptions)
 		{
@@ -26,20 +22,24 @@ namespace BansheeEngine
 			case GUIOption::Type::FixedWidth:
 				layoutOptions.fixedWidth = true;
 				layoutOptions.width = option.min;
+				layoutOptions.overridenWidth = true;
 				break;
 			case GUIOption::Type::FixedHeight:
 				layoutOptions.fixedHeight = true;
 				layoutOptions.height = option.min;
+				layoutOptions.overridenHeight = true;
 				break;
 			case GUIOption::Type::FlexibleWidth:
 				layoutOptions.fixedWidth = false;
 				layoutOptions.minWidth = option.min;
 				layoutOptions.maxWidth = option.max;
+				layoutOptions.overridenWidth = true;
 				break;
 			case GUIOption::Type::FlexibleHeight:
 				layoutOptions.fixedHeight = false;
 				layoutOptions.minHeight = option.min;
 				layoutOptions.maxHeight = option.max;
+				layoutOptions.overridenHeight = true;
 				break;
 			}
 		}
@@ -47,25 +47,29 @@ namespace BansheeEngine
 		return layoutOptions;
 	}
 
-	GUILayoutOptions GUILayoutOptions::create(const GUIElementStyle* style)
+	void GUILayoutOptions::updateWithStyle(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;
+		if(!overridenWidth)
+		{
+			fixedWidth = style->fixedWidth;
+			width = style->width;
+			minWidth = style->minWidth;
+			maxWidth = style->maxWidth;
+		}
 
-		return layoutOptions;
+		if(!overridenHeight)
+		{
+			fixedHeight = style->fixedHeight;
+			height = style->height;
+			minHeight = style->minHeight;
+			maxHeight = style->maxHeight;
+		}
 	}
 
 	GUILayoutOptions::GUILayoutOptions()
 		:width(0), height(0), minWidth(0), maxWidth(0),
-		minHeight(0), maxHeight(0), fixedWidth(false), fixedHeight(false)
+		minHeight(0), maxHeight(0), fixedWidth(false), fixedHeight(false),
+		overridenWidth(false), overridenHeight(false)
 	{
 
 	}

+ 6 - 6
BansheeEngine/Source/BsGUIListBox.cpp

@@ -21,8 +21,8 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIListBox::GUIListBox(const GUIElementStyle* style, const Vector<HString>::type& elements, const GUILayoutOptions& layoutOptions)
-		:GUIButtonBase(style, GUIContent(HString(L"")), layoutOptions), mElements(elements), mSelectedIdx(0), mIsListBoxOpen(false)
+	GUIListBox::GUIListBox(const CM::String& styleName, const Vector<HString>::type& elements, const GUILayoutOptions& layoutOptions)
+		:GUIButtonBase(styleName, GUIContent(HString(L"")), layoutOptions), mElements(elements), mSelectedIdx(0), mIsListBoxOpen(false)
 	{
 		if(elements.size() > 0)
 			setContent(GUIContent(mElements[mSelectedIdx]));
@@ -33,14 +33,14 @@ namespace BansheeEngine
 		closeListBox();
 	}
 
-	GUIListBox* GUIListBox::create(const Vector<HString>::type& elements, const GUIElementStyle* style)
+	GUIListBox* GUIListBox::create(const Vector<HString>::type& elements, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(style, elements, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(getStyleName<GUIListBox>(styleName), elements, GUILayoutOptions::create());
 	}
 
-	GUIListBox* GUIListBox::create(const Vector<HString>::type& elements, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIListBox* GUIListBox::create(const Vector<HString>::type& elements, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(style, elements, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIListBox, PoolAlloc>()) GUIListBox(getStyleName<GUIListBox>(styleName), elements, GUILayoutOptions::create(layoutOptions));
 	}
 
 	void GUIListBox::setElements(const CM::Vector<CM::HString>::type& elements)

+ 6 - 6
BansheeEngine/Source/BsGUIRenderTexture.cpp

@@ -15,8 +15,8 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIRenderTexture::GUIRenderTexture(const GUIElementStyle* style, const RenderTexturePtr& texture, const GUILayoutOptions& layoutOptions)
-		:GUITexture(style, HSpriteTexture(), GUIImageScaleMode::StretchToFit, layoutOptions), mSourceTexture(texture.get())
+	GUIRenderTexture::GUIRenderTexture(const CM::String& styleName, const RenderTexturePtr& texture, const GUILayoutOptions& layoutOptions)
+		:GUITexture(styleName, HSpriteTexture(), GUIImageScaleMode::StretchToFit, layoutOptions), mSourceTexture(texture.get())
 	{
 		if(mSourceTexture->requiresTextureFlipping())
 		{
@@ -33,14 +33,14 @@ namespace BansheeEngine
 		GUIManager::instance().setInputBridge(mSourceTexture, nullptr);
 	}
 
-	GUIRenderTexture* GUIRenderTexture::create(const RenderTexturePtr& texture, const GUIElementStyle* style)
+	GUIRenderTexture* GUIRenderTexture::create(const RenderTexturePtr& texture, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIRenderTexture, PoolAlloc>()) GUIRenderTexture(style, texture, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIRenderTexture, PoolAlloc>()) GUIRenderTexture(getStyleName<GUIRenderTexture>(styleName), texture, GUILayoutOptions::create());
 	}
 
-	GUIRenderTexture* GUIRenderTexture::create(const RenderTexturePtr& texture, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIRenderTexture* GUIRenderTexture::create(const RenderTexturePtr& texture, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIRenderTexture, PoolAlloc>()) GUIRenderTexture(style, texture, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIRenderTexture, PoolAlloc>()) GUIRenderTexture(getStyleName<GUIRenderTexture>(styleName), texture, GUILayoutOptions::create(layoutOptions));
 	}
 
 	void GUIRenderTexture::updateRenderElementsInternal()

+ 15 - 20
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -20,8 +20,8 @@ namespace BansheeEngine
 	const UINT32 GUIScrollArea::WheelScrollAmount = 50;
 
 	GUIScrollArea::GUIScrollArea(ScrollBarType vertBarType, ScrollBarType horzBarType, 
-		const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle, const GUILayoutOptions& layoutOptions)
-		:GUIElementContainer(parent, layoutOptions), mVertScroll(nullptr), mHorzScroll(nullptr), mVertOffset(0), mHorzOffset(0),
+		const CM::String& scrollBarStyle, const CM::String& scrollAreaStyle, const GUILayoutOptions& layoutOptions)
+		:GUIElementContainer(layoutOptions), mVertScroll(nullptr), mHorzScroll(nullptr), mVertOffset(0), mHorzOffset(0),
 		mContentWidth(0), mContentHeight(0), mClippedContentWidth(0), mClippedContentHeight(0), mVertBarType(vertBarType), mHorzBarType(horzBarType),
 		mScrollBarStyle(scrollBarStyle)
 	{
@@ -146,10 +146,7 @@ namespace BansheeEngine
 		{
 			if(mVertScroll == nullptr)
 			{
-				if(mScrollBarStyle != nullptr)
-					mVertScroll = GUIScrollBarVert::create(mScrollBarStyle);
-				else
-					mVertScroll = GUIScrollBarVert::create();
+				mVertScroll = GUIScrollBarVert::create(mScrollBarStyle);
 
 				_registerChildElement(mVertScroll);
 
@@ -206,10 +203,7 @@ namespace BansheeEngine
 		{ 
 			if(mHorzScroll == nullptr)
 			{
-				if(mScrollBarStyle != nullptr)
-					mHorzScroll = GUIScrollBarHorz::create(mScrollBarStyle);
-				else
-					mHorzScroll = GUIScrollBarHorz::create();
+				mHorzScroll = GUIScrollBarHorz::create(mScrollBarStyle);
 
 				_registerChildElement(mHorzScroll);
 
@@ -386,30 +380,31 @@ namespace BansheeEngine
 	}
 
 	GUIScrollArea* GUIScrollArea::create(ScrollBarType vertBarType, ScrollBarType horzBarType, 
-		const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle)
+		const CM::String& scrollBarStyle, const CM::String& scrollAreaStyle)
 	{
 		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(vertBarType, horzBarType, scrollBarStyle, 
-			scrollAreaStyle, GUILayoutOptions::create(scrollAreaStyle));
+			getStyleName<GUIScrollArea>(scrollAreaStyle), GUILayoutOptions::create());
 	}
 
-	GUIScrollArea* GUIScrollArea::create(const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle, 
-		const GUIElementStyle* scrollAreaStyle)
+	GUIScrollArea* GUIScrollArea::create(const GUIOptions& layoutOptions, const CM::String& scrollBarStyle, 
+		const CM::String& scrollAreaStyle)
 	{
 		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(ScrollBarType::ShowIfDoesntFit, 
-			ScrollBarType::ShowIfDoesntFit, scrollBarStyle, scrollAreaStyle, GUILayoutOptions::create(layoutOptions, scrollAreaStyle));
+			ScrollBarType::ShowIfDoesntFit, scrollBarStyle, getStyleName<GUIScrollArea>(scrollAreaStyle), GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUIScrollArea* GUIScrollArea::create(const GUIElementStyle* scrollBarStyle, const GUIElementStyle* scrollAreaStyle)
+	GUIScrollArea* GUIScrollArea::create(const CM::String& scrollBarStyle, const CM::String& scrollAreaStyle)
 	{
 		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(ScrollBarType::ShowIfDoesntFit, ScrollBarType::ShowIfDoesntFit, scrollBarStyle, 
-			scrollAreaStyle, GUILayoutOptions::create(scrollAreaStyle));
+			getStyleName<GUIScrollArea>(scrollAreaStyle), GUILayoutOptions::create());
 	}
 
 	GUIScrollArea* GUIScrollArea::create(ScrollBarType vertBarType, 
-		ScrollBarType horzBarType, const GUIOptions& layoutOptions, const GUIElementStyle* scrollBarStyle, 
-		const GUIElementStyle* scrollAreaStyle)
+		ScrollBarType horzBarType, const GUIOptions& layoutOptions, const CM::String& scrollBarStyle, 
+		const CM::String& scrollAreaStyle)
 	{
-		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(vertBarType, horzBarType, scrollBarStyle, scrollAreaStyle, GUILayoutOptions::create(layoutOptions, scrollAreaStyle));
+		return new (cm_alloc<GUIScrollArea, PoolAlloc>()) GUIScrollArea(vertBarType, horzBarType, scrollBarStyle, 
+			getStyleName<GUIScrollArea>(scrollAreaStyle), GUILayoutOptions::create(layoutOptions));
 	}
 
 	const String& GUIScrollArea::getGUITypeName()

+ 10 - 10
BansheeEngine/Source/BsGUIScrollBar.cpp

@@ -18,8 +18,8 @@ namespace BansheeEngine
 {
 	const UINT32 GUIScrollBar::ButtonScrollAmount = 10;
 
-	GUIScrollBar::GUIScrollBar(bool horizontal, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mHorizontal(horizontal)
+	GUIScrollBar::GUIScrollBar(bool horizontal, const CM::String& styleName, const GUILayoutOptions& layoutOptions)
+		:GUIElement(styleName, layoutOptions), mHorizontal(horizontal)
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
@@ -27,21 +27,21 @@ namespace BansheeEngine
 		{
 			mLayout = &addLayoutXInternal(this);
 
-			mUpBtn = GUIButton::create(HString(L""), parent.getSkin().getStyle("ScrollLeftBtn"));
-			mDownBtn = GUIButton::create(HString(L""), parent.getSkin().getStyle("ScrollRightBtn"));
+			mUpBtn = GUIButton::create(HString(L""), "ScrollLeftBtn");
+			mDownBtn = GUIButton::create(HString(L""), "ScrollRightBtn");
 
-			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, 
-				GUIOptions(GUIOption::flexibleWidth(), GUIOption::fixedHeight(6)), parent.getSkin().getStyle("ScrollBarHorzBtn"));
+			mHandleBtn = GUIScrollBarHandle::create(mHorizontal, 
+				GUIOptions(GUIOption::flexibleWidth(), GUIOption::fixedHeight(6)), "ScrollBarHorzBtn");
 		}
 		else
 		{
 			mLayout = &addLayoutYInternal(this);
 
-			mUpBtn = GUIButton::create(HString(L""), parent.getSkin().getStyle("ScrollUpBtn"));
-			mDownBtn = GUIButton::create(HString(L""), parent.getSkin().getStyle("ScrollDownBtn"));
+			mUpBtn = GUIButton::create(HString(L""), "ScrollUpBtn");
+			mDownBtn = GUIButton::create(HString(L""), "ScrollDownBtn");
 
-			mHandleBtn = GUIScrollBarHandle::create(parent, mHorizontal, 
-				GUIOptions(GUIOption::fixedWidth(6), GUIOption::flexibleHeight()), parent.getSkin().getStyle("ScrollBarVertBtn"));
+			mHandleBtn = GUIScrollBarHandle::create(mHorizontal, 
+				GUIOptions(GUIOption::fixedWidth(6), GUIOption::flexibleHeight()), "ScrollBarVertBtn");
 		}
 
 		mLayout->addSpace(2);

+ 37 - 22
BansheeEngine/Source/BsGUIScrollBarHandle.cpp

@@ -19,12 +19,11 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIScrollBarHandle::GUIScrollBarHandle(bool horizontal, const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mHorizontal(horizontal), mHandleSize(2), mMouseOverHandle(false), mHandlePos(0), mDragStartPos(0),
-		mHandleDragged(false)
+	GUIScrollBarHandle::GUIScrollBarHandle(bool horizontal, const CM::String& styleName, const GUILayoutOptions& layoutOptions)
+		:GUIElement(styleName, layoutOptions), mHorizontal(horizontal), mHandleSize(2), mMouseOverHandle(false), mHandlePos(0), mDragStartPos(0),
+		mHandleDragged(false), mState(State::Normal)
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
-		mCurTexture = style->normal.texture;
 	}
 
 	GUIScrollBarHandle::~GUIScrollBarHandle()
@@ -32,14 +31,14 @@ namespace BansheeEngine
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 
-	GUIScrollBarHandle* GUIScrollBarHandle::create(bool horizontal, const GUIElementStyle* style)
+	GUIScrollBarHandle* GUIScrollBarHandle::create(bool horizontal, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(horizontal, style, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(horizontal, getStyleName<GUIScrollBarHandle>(styleName), GUILayoutOptions::create());
 	}
 
-	GUIScrollBarHandle* GUIScrollBarHandle::create(bool horizontal, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarHandle* GUIScrollBarHandle::create(bool horizontal, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(horizontal, style, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIScrollBarHandle, PoolAlloc>()) GUIScrollBarHandle(horizontal, getStyleName<GUIScrollBarHandle>(styleName), GUILayoutOptions::create(layoutOptions));
 	}
 
 	void GUIScrollBarHandle::setHandleSize(CM::UINT32 size)
@@ -92,8 +91,9 @@ namespace BansheeEngine
 	{		
 		IMAGE_SPRITE_DESC desc;
 
-		if(mCurTexture != nullptr && mCurTexture.isLoaded())
-			desc.texture = mCurTexture.getInternalPtr();
+		HSpriteTexture activeTex = getActiveTexture();
+		if(SpriteTexture::checkIsLoaded(activeTex))
+			desc.texture = activeTex.getInternalPtr();
 
 		if(mHorizontal)
 		{
@@ -121,10 +121,10 @@ namespace BansheeEngine
 
 	Vector2I GUIScrollBarHandle::_getOptimalSize() const
 	{
-		if(mCurTexture != nullptr)
-		{
-			return Vector2I(mCurTexture->getTexture()->getWidth(), mCurTexture->getTexture()->getHeight());
-		}
+		HSpriteTexture activeTex = getActiveTexture();
+
+		if(SpriteTexture::checkIsLoaded(activeTex))
+			return Vector2I(activeTex->getTexture()->getWidth(), activeTex->getTexture()->getHeight());
 
 		return Vector2I();
 	}
@@ -158,7 +158,7 @@ namespace BansheeEngine
 				{
 					mMouseOverHandle = false;
 
-					mCurTexture = _getStyle()->normal.texture;
+					mState = State::Normal;
 					markContentAsDirty();
 
 					return true;
@@ -170,7 +170,7 @@ namespace BansheeEngine
 				{
 					mMouseOverHandle = true;
 
-					mCurTexture = _getStyle()->hover.texture;
+					mState = State::Hover;
 					markContentAsDirty();
 
 					return true;
@@ -180,7 +180,7 @@ namespace BansheeEngine
 
 		if(ev.getType() == GUIMouseEventType::MouseDown && mMouseOverHandle)
 		{
-			mCurTexture = _getStyle()->active.texture;
+			mState = State::Active;
 			markContentAsDirty();
 
 			if(mHorizontal)
@@ -227,7 +227,7 @@ namespace BansheeEngine
 
 		if(ev.getType() == GUIMouseEventType::MouseOut && !mHandleDragged)
 		{
-			mCurTexture = _getStyle()->normal.texture;
+			mState = State::Normal;
 			mMouseOverHandle = false;
 			markContentAsDirty();
 
@@ -237,9 +237,9 @@ namespace BansheeEngine
 		if(ev.getType() == GUIMouseEventType::MouseUp)
 		{
 			if(mMouseOverHandle)
-				mCurTexture = _getStyle()->hover.texture;
+				mState = State::Hover;
 			else
-				mCurTexture = _getStyle()->normal.texture;
+				mState = State::Normal;
 
 			// If we clicked above or below the scroll handle, scroll by one page
 			INT32 handleOffset = 0;
@@ -287,9 +287,9 @@ namespace BansheeEngine
 			mHandleDragged = false;
 
 			if(mMouseOverHandle)
-				mCurTexture = _getStyle()->hover.texture;
+				mState = State::Hover;
 			else
-				mCurTexture = _getStyle()->normal.texture;
+				mState = State::Normal;
 
 			markContentAsDirty();
 			return true;
@@ -328,4 +328,19 @@ namespace BansheeEngine
 
 		return maxSize;
 	}
+
+	const HSpriteTexture& GUIScrollBarHandle::getActiveTexture() const
+	{
+		switch(mState)
+		{
+		case State::Active:
+			return _getStyle()->active.texture;
+		case State::Hover:
+			return _getStyle()->hover.texture;
+		case State::Normal:
+			return _getStyle()->normal.texture;
+		}
+
+		return _getStyle()->normal.texture;
+	}
 }

+ 6 - 6
BansheeEngine/Source/BsGUIScrollBarHorz.cpp

@@ -14,8 +14,8 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	GUIScrollBarHorz::GUIScrollBarHorz(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUIScrollBar(true, style, layoutOptions)
+	GUIScrollBarHorz::GUIScrollBarHorz(const CM::String& styleName, const GUILayoutOptions& layoutOptions)
+		:GUIScrollBar(true, styleName, layoutOptions)
 	{
 
 	}
@@ -25,14 +25,14 @@ namespace BansheeEngine
 
 	}
 
-	GUIScrollBarHorz* GUIScrollBarHorz::create(const GUIElementStyle* style)
+	GUIScrollBarHorz* GUIScrollBarHorz::create(const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(style, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(getStyleName<GUIScrollBarHorz>(styleName), GUILayoutOptions::create());
 	}
 
-	GUIScrollBarHorz* GUIScrollBarHorz::create(const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarHorz* GUIScrollBarHorz::create(const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(style, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIScrollBarHorz, PoolAlloc>()) GUIScrollBarHorz(getStyleName<GUIScrollBarHorz>(styleName), GUILayoutOptions::create(layoutOptions));
 	}
 
 	const String& GUIScrollBarHorz::getGUITypeName()

+ 6 - 6
BansheeEngine/Source/BsGUIScrollBarVert.cpp

@@ -14,8 +14,8 @@ using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	GUIScrollBarVert::GUIScrollBarVert(const GUIElementStyle* style, const GUILayoutOptions& layoutOptions)
-		:GUIScrollBar(false, style, layoutOptions)
+	GUIScrollBarVert::GUIScrollBarVert(const CM::String& styleName, const GUILayoutOptions& layoutOptions)
+		:GUIScrollBar(false, styleName, layoutOptions)
 	{
 
 	}
@@ -25,14 +25,14 @@ namespace BansheeEngine
 
 	}
 
-	GUIScrollBarVert* GUIScrollBarVert::create(const GUIElementStyle* style)
+	GUIScrollBarVert* GUIScrollBarVert::create(const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(style, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(getStyleName<GUIScrollBarVert>(styleName), GUILayoutOptions::create());
 	}
 
-	GUIScrollBarVert* GUIScrollBarVert::create(const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIScrollBarVert* GUIScrollBarVert::create(const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(style, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIScrollBarVert, PoolAlloc>()) GUIScrollBarVert(getStyleName<GUIScrollBarVert>(styleName), GUILayoutOptions::create(layoutOptions));
 	}
 
 	const String& GUIScrollBarVert::getGUITypeName()

+ 28 - 20
BansheeEngine/Source/BsGUITexture.cpp

@@ -16,9 +16,9 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUITexture::GUITexture(const GUIElementStyle* style, const HSpriteTexture& texture, 
+	GUITexture::GUITexture(const CM::String& styleName, const HSpriteTexture& texture, 
 		GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mScaleMode(scale), mUsingStyleTexture(false)
+		:GUIElement(styleName, layoutOptions), mScaleMode(scale), mUsingStyleTexture(false)
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
@@ -36,47 +36,55 @@ namespace BansheeEngine
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 
-	GUITexture* GUITexture::create(const HSpriteTexture& texture, 
-		GUIImageScaleMode scale, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(const HSpriteTexture& texture, GUIImageScaleMode scale, 
+		const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, texture, scale, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			texture, scale, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUITexture* GUITexture::create(const HSpriteTexture& texture, 
-		GUIImageScaleMode scale, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(const HSpriteTexture& texture, GUIImageScaleMode scale, 
+		const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, texture, scale, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			texture, scale, GUILayoutOptions::create());
 	}
 
 	GUITexture* GUITexture::create(const HSpriteTexture& texture, 
-		const GUIOptions& layoutOptions, const GUIElementStyle* style)
+		const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, texture, GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			texture, GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUITexture* GUITexture::create(const HSpriteTexture& texture, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(const HSpriteTexture& texture, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, texture, GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName),
+			texture, GUIImageScaleMode::StretchToFit, GUILayoutOptions::create());
 	}
 
-	GUITexture* GUITexture::create(GUIImageScaleMode scale, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(GUIImageScaleMode scale, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, HTexture(), scale, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			HTexture(), scale, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUITexture* GUITexture::create(GUIImageScaleMode scale, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(GUIImageScaleMode scale, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, HSpriteTexture(), scale, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			HSpriteTexture(), scale, GUILayoutOptions::create());
 	}
 
-	GUITexture* GUITexture::create(const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, HTexture(), GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			HTexture(), GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUITexture* GUITexture::create(const GUIElementStyle* style)
+	GUITexture* GUITexture::create(const CM::String& styleName)
 	{
-		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(style, HTexture(), GUIImageScaleMode::StretchToFit, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(getStyleName<GUITexture>(styleName), 
+			HTexture(), GUIImageScaleMode::StretchToFit, GUILayoutOptions::create());
 	}
 
 	void GUITexture::setTexture(const HSpriteTexture& texture)

+ 20 - 18
BansheeEngine/Source/BsGUIToggle.cpp

@@ -20,8 +20,8 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIToggle::GUIToggle(const GUIElementStyle* style, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUILayoutOptions& layoutOptions)
-		:GUIButtonBase(style, content, layoutOptions), mIsToggled(false), mToggleGroup(nullptr)
+	GUIToggle::GUIToggle(const CM::String& styleName, const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUILayoutOptions& layoutOptions)
+		:GUIButtonBase(styleName, content, layoutOptions), mIsToggled(false), mToggleGroup(nullptr)
 	{
 		if(toggleGroup != nullptr)
 			toggleGroup->add(this);
@@ -35,44 +35,46 @@ namespace BansheeEngine
 		}
 	}
 
-	GUIToggle* GUIToggle::create(const HString& text, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const HString& text, const CM::String& styleName)
 	{
-		return create(GUIContent(text), style);
+		return create(GUIContent(text), styleName);
 	}
 
-	GUIToggle* GUIToggle::create(const HString& text, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const HString& text, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return create(GUIContent(text), layoutOptions, style);
+		return create(GUIContent(text), layoutOptions, styleName);
 	}
 
-	GUIToggle* GUIToggle::create(const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const CM::String& styleName)
 	{
-		return create(GUIContent(text), toggleGroup, style);
+		return create(GUIContent(text), toggleGroup, styleName);
 	}
 
-	GUIToggle* GUIToggle::create(const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const HString& text, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+		const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return create(GUIContent(text), toggleGroup, layoutOptions, style);
+		return create(GUIContent(text), toggleGroup, layoutOptions, styleName);
 	}
 
-	GUIToggle* GUIToggle::create(const GUIContent& content, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const GUIContent& content, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(style, content, nullptr, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, nullptr, GUILayoutOptions::create());
 	}
 
-	GUIToggle* GUIToggle::create(const GUIContent& content, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const GUIContent& content, const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(style, content, nullptr, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, nullptr, GUILayoutOptions::create(layoutOptions));
 	}
 
-	GUIToggle* GUIToggle::create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(style, content, toggleGroup, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, toggleGroup, GUILayoutOptions::create());
 	}
 
-	GUIToggle* GUIToggle::create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, const GUIOptions& layoutOptions, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(const GUIContent& content, std::shared_ptr<GUIToggleGroup> toggleGroup, 
+		const GUIOptions& layoutOptions, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(style, content, toggleGroup, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, toggleGroup, GUILayoutOptions::create(layoutOptions));
 	}
 
 	std::shared_ptr<GUIToggleGroup> GUIToggle::createToggleGroup()

+ 20 - 12
BansheeEngine/Source/BsGUIViewport.cpp

@@ -18,17 +18,11 @@ namespace BansheeEngine
 		return name;
 	}
 
-	GUIViewport::GUIViewport(const GUIElementStyle* style, const HCamera& camera, 
+	GUIViewport::GUIViewport(const CM::String& styleName, const HCamera& camera, 
 		float aspectRatio, CM::Degree fieldOfView, const GUILayoutOptions& layoutOptions)
-		:GUIElement(style, layoutOptions), mCamera(camera), mAspectRatio(aspectRatio),
+		:GUIElement(styleName, layoutOptions), mCamera(camera), mAspectRatio(aspectRatio),
 		mFieldOfView(fieldOfView)
 	{
-		RenderTargetPtr guiRenderTarget = parent.getTarget()->getTarget();
-		RenderTargetPtr cameraRenderTarget = camera->getViewport()->getTarget();
-
-		if(guiRenderTarget != cameraRenderTarget)
-			CM_EXCEPT(InvalidParametersException, "Camera provided to GUIViewport must use the same render target as the GUIWidget this element is located on.")
-
 		mVerticalFOV = 2.0f * Math::atan(Math::tan(mFieldOfView.valueRadians() * 0.5f) * (1.0f / mAspectRatio));
 	}
 
@@ -37,15 +31,15 @@ namespace BansheeEngine
 
 	}
 
-	GUIViewport* GUIViewport::create(const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style)
+	GUIViewport* GUIViewport::create(const HCamera& camera, float aspectRatio, CM::Degree fieldOfView, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(style, camera, aspectRatio, fieldOfView, GUILayoutOptions::create(style));
+		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(getStyleName<GUIViewport>(styleName), camera, aspectRatio, fieldOfView, GUILayoutOptions::create());
 	}
 
 	GUIViewport* GUIViewport::create(const GUIOptions& layoutOptions, const HCamera& camera, 
-		float aspectRatio, CM::Degree fieldOfView, const GUIElementStyle* style)
+		float aspectRatio, CM::Degree fieldOfView, const CM::String& styleName)
 	{
-		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(style, camera, aspectRatio, fieldOfView, GUILayoutOptions::create(layoutOptions, style));
+		return new (cm_alloc<GUIViewport, PoolAlloc>()) GUIViewport(getStyleName<GUIViewport>(styleName), camera, aspectRatio, fieldOfView, GUILayoutOptions::create(layoutOptions));
 	}
 
 	UINT32 GUIViewport::getNumRenderElements() const
@@ -100,4 +94,18 @@ namespace BansheeEngine
 
 		viewport->setArea(x, y, width, height);
 	}
+
+	void GUIViewport::_changeParentWidget(GUIWidget* widget)
+	{
+		GUIElement::_changeParentWidget(widget);
+
+		if(widget != nullptr)
+		{
+			RenderTargetPtr guiRenderTarget = widget->getTarget()->getTarget();
+			RenderTargetPtr cameraRenderTarget = mCamera->getViewport()->getTarget();
+
+			if(guiRenderTarget != cameraRenderTarget)
+				CM_EXCEPT(InvalidParametersException, "Camera provided to GUIViewport must use the same render target as the GUIWidget this element is located on.")
+		}
+	}
 }

+ 37 - 37
BansheeEngine/Source/BsProfilerOverlay.cpp

@@ -66,15 +66,15 @@ namespace BansheeEngine
 				newRow.labelLayout = &labelLayout.insertLayoutX(labelLayout.getNumChildren() - 1); // Insert before flexible space
 				newRow.contentLayout = &contentLayout.insertLayoutX(contentLayout.getNumChildren() - 1); // Insert before flexible space
 
-				GUILabel* name = GUILabel::create(widget, newRow.name, GUIOptions(GUIOption::fixedWidth(200)));
-				GUILabel* pctOfParent = GUILabel::create(widget, newRow.pctOfParent, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numCalls = GUILabel::create(widget, newRow.numCalls, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numAllocs = GUILabel::create(widget, newRow.numAllocs, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numFrees = GUILabel::create(widget, newRow.numFrees, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* avgTime = GUILabel::create(widget, newRow.avgTime, GUIOptions(GUIOption::fixedWidth(60)));
-				GUILabel* totalTime = GUILabel::create(widget, newRow.totalTime, GUIOptions(GUIOption::fixedWidth(60)));
-				GUILabel* avgTimeSelf = GUILabel::create(widget, newRow.avgTimeSelf, GUIOptions(GUIOption::fixedWidth(100)));
-				GUILabel* totalTimeSelf = GUILabel::create(widget, newRow.totalTimeSelf, GUIOptions(GUIOption::fixedWidth(100)));
+				GUILabel* name = GUILabel::create(newRow.name, GUIOptions(GUIOption::fixedWidth(200)));
+				GUILabel* pctOfParent = GUILabel::create(newRow.pctOfParent, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numCalls = GUILabel::create(newRow.numCalls, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numAllocs = GUILabel::create(newRow.numAllocs, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numFrees = GUILabel::create(newRow.numFrees, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* avgTime = GUILabel::create(newRow.avgTime, GUIOptions(GUIOption::fixedWidth(60)));
+				GUILabel* totalTime = GUILabel::create(newRow.totalTime, GUIOptions(GUIOption::fixedWidth(60)));
+				GUILabel* avgTimeSelf = GUILabel::create(newRow.avgTimeSelf, GUIOptions(GUIOption::fixedWidth(100)));
+				GUILabel* totalTimeSelf = GUILabel::create(newRow.totalTimeSelf, GUIOptions(GUIOption::fixedWidth(100)));
 
 				newRow.labelLayout->addSpace(0);
 				newRow.labelLayout->addElement(name);
@@ -170,15 +170,15 @@ namespace BansheeEngine
 				newRow.labelLayout = &labelLayout.insertLayoutX(labelLayout.getNumChildren() - 1); // Insert before flexible space
 				newRow.contentLayout = &contentLayout.insertLayoutX(contentLayout.getNumChildren() - 1); // Insert before flexible space
 
-				GUILabel* name = GUILabel::create(widget, newRow.name, GUIOptions(GUIOption::fixedWidth(200)));
-				GUILabel* pctOfParent = GUILabel::create(widget, newRow.pctOfParent, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numCalls = GUILabel::create(widget, newRow.numCalls, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numAllocs = GUILabel::create(widget, newRow.numAllocs, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* numFrees = GUILabel::create(widget, newRow.numFrees, GUIOptions(GUIOption::fixedWidth(50)));
-				GUILabel* avgCycles = GUILabel::create(widget, newRow.avgCycles,GUIOptions(GUIOption::fixedWidth(60)));
-				GUILabel* totalCycles = GUILabel::create(widget, newRow.totalCycles, GUIOptions(GUIOption::fixedWidth(60)));
-				GUILabel* avgCyclesSelf = GUILabel::create(widget, newRow.avgCyclesSelf, GUIOptions(GUIOption::fixedWidth(100)));
-				GUILabel* totalCyclesSelf = GUILabel::create(widget, newRow.totalCyclesSelf, GUIOptions(GUIOption::fixedWidth(100)));
+				GUILabel* name = GUILabel::create(newRow.name, GUIOptions(GUIOption::fixedWidth(200)));
+				GUILabel* pctOfParent = GUILabel::create(newRow.pctOfParent, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numCalls = GUILabel::create(newRow.numCalls, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numAllocs = GUILabel::create(newRow.numAllocs, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* numFrees = GUILabel::create(newRow.numFrees, GUIOptions(GUIOption::fixedWidth(50)));
+				GUILabel* avgCycles = GUILabel::create(newRow.avgCycles,GUIOptions(GUIOption::fixedWidth(60)));
+				GUILabel* totalCycles = GUILabel::create(newRow.totalCycles, GUIOptions(GUIOption::fixedWidth(60)));
+				GUILabel* avgCyclesSelf = GUILabel::create(newRow.avgCyclesSelf, GUIOptions(GUIOption::fixedWidth(100)));
+				GUILabel* totalCyclesSelf = GUILabel::create(newRow.totalCyclesSelf, GUIOptions(GUIOption::fixedWidth(100)));
 
 				newRow.labelLayout->addSpace(0);
 				newRow.labelLayout->addElement(name);
@@ -276,25 +276,25 @@ namespace BansheeEngine
 		mPreciseLayoutContents = &mPreciseAreaContents->getLayout().addLayoutY();
 
 		// Set up title bars
-		mTitleBasicName = GUILabel::create(*mWidget, HString(L"Name"), GUIOptions(GUIOption::fixedWidth(200)));
-		mTitleBasicPctOfParent = GUILabel::create(*mWidget, HString(L"% parent"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitleBasicNumCalls = GUILabel::create(*mWidget, HString(L"# calls"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitleBasicNumAllocs = GUILabel::create(*mWidget, HString(L"# allocs"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitleBasicNumFrees = GUILabel::create(*mWidget, HString(L"# frees"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitleBasicAvgTime = GUILabel::create(*mWidget, HString(L"Avg. time"), GUIOptions(GUIOption::fixedWidth(60)));
-		mTitleBasicTotalTime = GUILabel::create(*mWidget, HString(L"Total time"), GUIOptions(GUIOption::fixedWidth(60)));
-		mTitleBasicAvgTitleSelf = GUILabel::create(*mWidget, HString(L"Avg. self time"), GUIOptions(GUIOption::fixedWidth(100)));
-		mTitleBasicTotalTimeSelf = GUILabel::create(*mWidget, HString(L"Total self time"), GUIOptions(GUIOption::fixedWidth(100)));
-
-		mTitlePreciseName = GUILabel::create(*mWidget, HString(L"Name"), GUIOptions(GUIOption::fixedWidth(200)));
-		mTitlePrecisePctOfParent = GUILabel::create(*mWidget, HString(L"% parent"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitlePreciseNumCalls = GUILabel::create(*mWidget, HString(L"# calls"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitlePreciseNumAllocs = GUILabel::create(*mWidget, HString(L"# allocs"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitlePreciseNumFrees = GUILabel::create(*mWidget, HString(L"# frees"), GUIOptions(GUIOption::fixedWidth(50)));
-		mTitlePreciseAvgCycles = GUILabel::create(*mWidget, HString(L"Avg. cycles"), GUIOptions(GUIOption::fixedWidth(60)));
-		mTitlePreciseTotalCycles = GUILabel::create(*mWidget, HString(L"Total cycles"), GUIOptions(GUIOption::fixedWidth(60)));
-		mTitlePreciseAvgCyclesSelf = GUILabel::create(*mWidget, HString(L"Avg. self cycles"), GUIOptions(GUIOption::fixedWidth(100)));
-		mTitlePreciseTotalCyclesSelf = GUILabel::create(*mWidget, HString(L"Total self cycles"), GUIOptions(GUIOption::fixedWidth(100)));
+		mTitleBasicName = GUILabel::create(HString(L"Name"), GUIOptions(GUIOption::fixedWidth(200)));
+		mTitleBasicPctOfParent = GUILabel::create(HString(L"% parent"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitleBasicNumCalls = GUILabel::create(HString(L"# calls"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitleBasicNumAllocs = GUILabel::create(HString(L"# allocs"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitleBasicNumFrees = GUILabel::create(HString(L"# frees"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitleBasicAvgTime = GUILabel::create(HString(L"Avg. time"), GUIOptions(GUIOption::fixedWidth(60)));
+		mTitleBasicTotalTime = GUILabel::create(HString(L"Total time"), GUIOptions(GUIOption::fixedWidth(60)));
+		mTitleBasicAvgTitleSelf = GUILabel::create(HString(L"Avg. self time"), GUIOptions(GUIOption::fixedWidth(100)));
+		mTitleBasicTotalTimeSelf = GUILabel::create(HString(L"Total self time"), GUIOptions(GUIOption::fixedWidth(100)));
+
+		mTitlePreciseName = GUILabel::create(HString(L"Name"), GUIOptions(GUIOption::fixedWidth(200)));
+		mTitlePrecisePctOfParent = GUILabel::create(HString(L"% parent"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitlePreciseNumCalls = GUILabel::create(HString(L"# calls"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitlePreciseNumAllocs = GUILabel::create(HString(L"# allocs"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitlePreciseNumFrees = GUILabel::create(HString(L"# frees"), GUIOptions(GUIOption::fixedWidth(50)));
+		mTitlePreciseAvgCycles = GUILabel::create(HString(L"Avg. cycles"), GUIOptions(GUIOption::fixedWidth(60)));
+		mTitlePreciseTotalCycles = GUILabel::create(HString(L"Total cycles"), GUIOptions(GUIOption::fixedWidth(60)));
+		mTitlePreciseAvgCyclesSelf = GUILabel::create(HString(L"Avg. self cycles"), GUIOptions(GUIOption::fixedWidth(100)));
+		mTitlePreciseTotalCyclesSelf = GUILabel::create(HString(L"Total self cycles"), GUIOptions(GUIOption::fixedWidth(100)));
 
 		GUILayout& basicTitleLabelLayout = mBasicLayoutLabels->addLayoutX();
 		GUILayout& preciseTitleLabelLayout = mPreciseLayoutLabels->addLayoutX();

+ 5 - 0
BansheeEngine/Source/BsSpriteTexture.cpp

@@ -30,6 +30,11 @@ namespace BansheeEngine
 		return dummyTex;
 	}
 
+	bool SpriteTexture::checkIsLoaded(const HSpriteTexture& tex)
+	{
+		return tex != nullptr && tex.isLoaded() && tex->getTexture() != nullptr && tex.isLoaded();
+	}
+
 	HSpriteTexture SpriteTexture::create(const HTexture& texture)
 	{
 		SpriteTexturePtr texturePtr = cm_core_ptr<SpriteTexture, PoolAlloc>