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

Work on tabbed title bar
Removed common types from BansheeEngine namespace - Use CM instead
Removed windows.h header from Cursor header

Marko Pintera 12 лет назад
Родитель
Сommit
b08adffb6c
44 измененных файлов с 619 добавлено и 321 удалено
  1. 2 2
      BansheeEngine/BansheeEngine.vcxproj
  2. 2 2
      BansheeEngine/BansheeEngine.vcxproj.filters
  3. 1 1
      BansheeEngine/Include/BsCameraRTTI.h
  4. 3 3
      BansheeEngine/Include/BsDebugDraw.h
  5. 5 3
      BansheeEngine/Include/BsEngineGUI.h
  6. 7 7
      BansheeEngine/Include/BsGUIArea.h
  7. 9 9
      BansheeEngine/Include/BsGUIButton.h
  8. 17 17
      BansheeEngine/Include/BsGUIElement.h
  9. 6 6
      BansheeEngine/Include/BsGUIElementStyle.h
  10. 7 7
      BansheeEngine/Include/BsGUILabel.h
  11. 13 13
      BansheeEngine/Include/BsGUILayout.h
  12. 6 6
      BansheeEngine/Include/BsGUILayoutOptions.h
  13. 1 1
      BansheeEngine/Include/BsGUILayoutX.h
  14. 1 1
      BansheeEngine/Include/BsGUILayoutY.h
  15. 1 1
      BansheeEngine/Include/BsGUIMaterialManager.h
  16. 3 3
      BansheeEngine/Include/BsGUISpace.h
  17. 13 9
      BansheeEngine/Include/BsGUITexture.h
  18. 0 59
      BansheeEngine/Include/BsGUITitleBar.h
  19. 62 0
      BansheeEngine/Include/BsGUIToggle.h
  20. 11 5
      BansheeEngine/Include/BsGUIWidget.h
  21. 7 7
      BansheeEngine/Include/BsGUIWindowFrame.h
  22. 3 3
      BansheeEngine/Include/BsImageSprite.h
  23. 3 3
      BansheeEngine/Include/BsOverlay.h
  24. 3 16
      BansheeEngine/Include/BsPrerequisites.h
  25. 1 1
      BansheeEngine/Include/BsRenderableRTTI.h
  26. 9 8
      BansheeEngine/Include/BsSprite.h
  27. 3 3
      BansheeEngine/Include/BsTextSprite.h
  28. 65 5
      BansheeEngine/Source/BsEngineGUI.cpp
  29. 17 5
      BansheeEngine/Source/BsGUIButton.cpp
  30. 2 2
      BansheeEngine/Source/BsGUILabel.cpp
  31. 5 5
      BansheeEngine/Source/BsGUIManager.cpp
  32. 30 5
      BansheeEngine/Source/BsGUITexture.cpp
  33. 70 20
      BansheeEngine/Source/BsGUIToggle.cpp
  34. 6 1
      BansheeEngine/Source/BsGUIWidget.cpp
  35. 2 2
      BansheeEngine/Source/BsGUIWindowFrame.cpp
  36. 89 0
      CamelotClient/BsGUITabbedTitleBar.cpp
  37. 37 0
      CamelotClient/BsGUITabbedTitleBar.h
  38. 2 0
      CamelotClient/CamelotClient.vcxproj
  39. 6 0
      CamelotClient/CamelotClient.vcxproj.filters
  40. 7 2
      CamelotClient/CmEditorWindow.cpp
  41. 18 3
      CamelotCore/Include/Win32/CmCursorImpl.h
  42. 2 2
      CamelotCore/Source/CmWindowEventUtilities.cpp
  43. 38 73
      CamelotCore/Source/Win32/CmCursorImpl.cpp
  44. 24 0
      TODO.txt

+ 2 - 2
BansheeEngine/BansheeEngine.vcxproj

@@ -157,7 +157,7 @@
     <ClInclude Include="Include\BsGUILayoutY.h" />
     <ClInclude Include="Include\BsGUILayoutY.h" />
     <ClInclude Include="Include\BsGUISpace.h" />
     <ClInclude Include="Include\BsGUISpace.h" />
     <ClInclude Include="Include\BsGUITexture.h" />
     <ClInclude Include="Include\BsGUITexture.h" />
-    <ClInclude Include="Include\BsGUITitleBar.h" />
+    <ClInclude Include="Include\BsGUIToggle.h" />
     <ClInclude Include="Include\BsPrerequisites.h" />
     <ClInclude Include="Include\BsPrerequisites.h" />
     <ClInclude Include="Include\BsGUIElement.h" />
     <ClInclude Include="Include\BsGUIElement.h" />
     <ClInclude Include="Include\BsGUIElementStyle.h" />
     <ClInclude Include="Include\BsGUIElementStyle.h" />
@@ -199,7 +199,7 @@
     <ClCompile Include="Source\BsGUIMaterialManager.cpp" />
     <ClCompile Include="Source\BsGUIMaterialManager.cpp" />
     <ClCompile Include="Source\BsGUISkin.cpp" />
     <ClCompile Include="Source\BsGUISkin.cpp" />
     <ClCompile Include="Source\BsGUITexture.cpp" />
     <ClCompile Include="Source\BsGUITexture.cpp" />
-    <ClCompile Include="Source\BsGUITitleBar.cpp" />
+    <ClCompile Include="Source\BsGUIToggle.cpp" />
     <ClCompile Include="Source\BsGUIWidget.cpp" />
     <ClCompile Include="Source\BsGUIWidget.cpp" />
     <ClCompile Include="Source\BsGUIWindowFrame.cpp" />
     <ClCompile Include="Source\BsGUIWindowFrame.cpp" />
     <ClCompile Include="Source\BsImageSprite.cpp" />
     <ClCompile Include="Source\BsImageSprite.cpp" />

+ 2 - 2
BansheeEngine/BansheeEngine.vcxproj.filters

@@ -147,7 +147,7 @@
     <ClInclude Include="Include\BsGUITexture.h">
     <ClInclude Include="Include\BsGUITexture.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
-    <ClInclude Include="Include\BsGUITitleBar.h">
+    <ClInclude Include="Include\BsGUIToggle.h">
       <Filter>Header Files\GUI</Filter>
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
     </ClInclude>
   </ItemGroup>
   </ItemGroup>
@@ -242,7 +242,7 @@
     <ClCompile Include="Source\BsGUITexture.cpp">
     <ClCompile Include="Source\BsGUITexture.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>
-    <ClCompile Include="Source\BsGUITitleBar.cpp">
+    <ClCompile Include="Source\BsGUIToggle.cpp">
       <Filter>Source Files\GUI</Filter>
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
     </ClCompile>
   </ItemGroup>
   </ItemGroup>

+ 1 - 1
BansheeEngine/Include/BsCameraRTTI.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 			return name;
 			return name;
 		}
 		}
 
 
-		virtual UINT32 getRTTIId()
+		virtual CM::UINT32 getRTTIId()
 		{
 		{
 			return TID_Camera;
 			return TID_Camera;
 		}
 		}

+ 3 - 3
BansheeEngine/Include/BsDebugDraw.h

@@ -26,9 +26,9 @@ namespace BansheeEngine
 			DebugDrawType type;
 			DebugDrawType type;
 			float timeEnds;
 			float timeEnds;
 
 
-			UINT32* indices;
-			UINT8* vertices;
-			UINT32 numElements;
+			CM::UINT32* indices;
+			CM::UINT8* vertices;
+			CM::UINT32 numElements;
 		};
 		};
 
 
 	public:
 	public:

+ 5 - 3
BansheeEngine/Include/BsEngineGUI.h

@@ -6,20 +6,19 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	// TODO - This class is very Editor related, so move it there?
 	class BS_EXPORT EngineGUI : public CamelotFramework::Module<EngineGUI>
 	class BS_EXPORT EngineGUI : public CamelotFramework::Module<EngineGUI>
 	{
 	{
 	public:
 	public:
 		EngineGUI();
 		EngineGUI();
 
 
 		const GUISkin& getSkin() const { return mSkin; }
 		const GUISkin& getSkin() const { return mSkin; }
-		const SpriteTexturePtr& getWindowBgTex() const { return mWindowBgTex; }
 
 
 	private:
 	private:
 		GUISkin mSkin;
 		GUISkin mSkin;
-		SpriteTexturePtr mWindowBgTex;
 
 
 		static const CM::String DefaultFontPath;
 		static const CM::String DefaultFontPath;
-		static const UINT32 DefaultFontSize;
+		static const CM::UINT32 DefaultFontSize;
 
 
 		static const CM::String WindowBackgroundTexture;
 		static const CM::String WindowBackgroundTexture;
 
 
@@ -34,6 +33,9 @@ namespace BansheeEngine
 		static const CM::String WindowMinButtonNormal;
 		static const CM::String WindowMinButtonNormal;
 		static const CM::String WindowMinButtonHover;
 		static const CM::String WindowMinButtonHover;
 
 
+		static const CM::String TabbedBarBtnNormal;
+		static const CM::String TabbedBarBtnActive;
+
 		static const CM::String ButtonNormalTex;
 		static const CM::String ButtonNormalTex;
 		static const CM::String ButtonHoverTex;
 		static const CM::String ButtonHoverTex;
 	};
 	};

+ 7 - 7
BansheeEngine/Include/BsGUIArea.h

@@ -16,31 +16,31 @@ namespace BansheeEngine
 		 *			If you want the area to expand vertically or horizontally, together with its parent
 		 *			If you want the area to expand vertically or horizontally, together with its parent
 		 *			widget, set height or width to 0, respectively.
 		 *			widget, set height or width to 0, respectively.
 		 */
 		 */
-		static GUIArea* create(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width = 0, UINT32 height = 0, UINT16 depth = 0);
+		static GUIArea* create(GUIWidget& widget, CM::UINT32 x, CM::UINT32 y, CM::UINT32 width = 0, CM::UINT32 height = 0, CM::UINT16 depth = 0);
 		static void destroy(GUIArea* area);
 		static void destroy(GUIArea* area);
 
 
 		GUILayout& getLayout() const { return *mLayout; }
 		GUILayout& getLayout() const { return *mLayout; }
 
 
-		UINT16 getDepth() const { return mDepth; }
-		void setDepth(UINT16 depth) { mDepth = depth; }
+		CM::UINT16 getDepth() const { return mDepth; }
+		void setDepth(CM::UINT16 depth) { mDepth = depth; }
 
 
 		void _update();
 		void _update();
 	private:
 	private:
 		friend class GUIWidget;
 		friend class GUIWidget;
 
 
 		GUIWidget& mWidget;
 		GUIWidget& mWidget;
-		UINT32 mX, mY, mWidth, mHeight;
-		UINT16 mDepth;
+		CM::UINT32 mX, mY, mWidth, mHeight;
+		CM::UINT16 mDepth;
 		bool mResizeWidthWithWindow, mResizeHeightWithWindow;
 		bool mResizeWidthWithWindow, mResizeHeightWithWindow;
 		bool mIsDirty;
 		bool mIsDirty;
 
 
 		GUILayout* mLayout;
 		GUILayout* mLayout;
 
 
-		GUIArea(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT16 depth);
+		GUIArea(GUIWidget& widget, CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth);
 
 
 		bool isDirty() const;
 		bool isDirty() const;
 
 
-		void notifyWindowResized(UINT32 newWidth, UINT32 newHeight);
+		void notifyWindowResized(CM::UINT32 newWidth, CM::UINT32 newHeight);
 
 
 		static void destroyInternal(GUIArea* area);
 		static void destroyInternal(GUIArea* area);
 	};
 	};

+ 9 - 9
BansheeEngine/Include/BsGUIButton.h

@@ -19,37 +19,37 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc GUIElement::getNumRenderElements()
 		 * @copydoc GUIElement::getNumRenderElements()
 		 */
 		 */
-		virtual UINT32 getNumRenderElements() const;
+		virtual CM::UINT32 getNumRenderElements() const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getMaterial()
 		 * @copydoc GUIElement::getMaterial()
 		 */
 		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumQuads()
 		 * @copydoc GUIElement::getNumQuads()
 		 */
 		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const;
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::fillBuffer()
 		 * @copydoc GUIElement::fillBuffer()
 		 */
 		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 */
 		 */
 		virtual void updateRenderElementsInternal();
 		virtual void updateRenderElementsInternal();
 
 
-		virtual UINT32 _getOptimalWidth() const;
-		virtual UINT32 _getOptimalHeight() const;
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
 
 
-		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
+		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const;
 	private:
 	private:
 		ImageSprite* mImageSprite;
 		ImageSprite* mImageSprite;
 		TextSprite* mTextSprite;
 		TextSprite* mTextSprite;
-		UINT32 mNumImageRenderElements;
+		CM::UINT32 mNumImageRenderElements;
 
 
 		IMAGE_SPRITE_DESC mImageDesc;
 		IMAGE_SPRITE_DESC mImageDesc;
 		CM::String mText;
 		CM::String mText;

+ 17 - 17
BansheeEngine/Include/BsGUIElement.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @return	The number render elements.
 		 * @return	The number render elements.
 		 */
 		 */
-		virtual UINT32 getNumRenderElements() const = 0;
+		virtual CM::UINT32 getNumRenderElements() const = 0;
 
 
 		/**
 		/**
 		 * @brief	Gets a material for the specified render element index.
 		 * @brief	Gets a material for the specified render element index.
@@ -31,7 +31,7 @@ namespace BansheeEngine
 		 * 		
 		 * 		
 		 * @return	Handle to the material.
 		 * @return	Handle to the material.
 		 */
 		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const = 0;
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const = 0;
 
 
 		/**
 		/**
 		 * @brief	Returns the number of quads that the specified render element will use. You will need this
 		 * @brief	Returns the number of quads that the specified render element will use. You will need this
@@ -45,7 +45,7 @@ namespace BansheeEngine
 		 *			
 		 *			
 		 * @return	Number of quads for the specified render element. 
 		 * @return	Number of quads for the specified render element. 
 		 */
 		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const = 0;
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const = 0;
 
 
 		/**
 		/**
 		 * @brief	Fill the pre-allocated vertex, uv and index buffers with the mesh data for the
 		 * @brief	Fill the pre-allocated vertex, uv and index buffers with the mesh data for the
@@ -64,8 +64,8 @@ namespace BansheeEngine
 		 * @param	indexStride			Number of bytes between two indexes in the provided index data.
 		 * @param	indexStride			Number of bytes between two indexes in the provided index data.
 		 * @param	renderElementIdx	Zero-based index of the render element.
 		 * @param	renderElementIdx	Zero-based index of the render element.
 		 */
 		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const = 0;
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const = 0;
 
 
 		/**
 		/**
 		 * @brief	Recreates the internal render elements. Must be called before fillBuffer if element is dirty. 
 		 * @brief	Recreates the internal render elements. Must be called before fillBuffer if element is dirty. 
@@ -84,22 +84,22 @@ namespace BansheeEngine
 		GUILayout* _getParentLayout() const { return mParentLayout; }
 		GUILayout* _getParentLayout() const { return mParentLayout; }
 		void _setParentLayout(GUILayout* layout) { mParentLayout = layout; }
 		void _setParentLayout(GUILayout* layout) { mParentLayout = layout; }
 
 
-		void _setWidgetDepth(UINT8 depth);
-		void _setAreaDepth(UINT16 depth);
+		void _setWidgetDepth(CM::UINT8 depth);
+		void _setAreaDepth(CM::UINT16 depth);
 		void _setOffset(const CM::Int2& offset);
 		void _setOffset(const CM::Int2& offset);
-		void _setWidth(UINT32 width);
-		void _setHeight(UINT32 height);
+		void _setWidth(CM::UINT32 width);
+		void _setHeight(CM::UINT32 height);
 		void _setClipRect(const CM::Rect& clipRect);
 		void _setClipRect(const CM::Rect& clipRect);
 
 
-		UINT32 _getWidth() const { return mWidth; }
-		UINT32 _getHeight() const { return mHeight; }
-		virtual UINT32 _getOptimalWidth() const = 0;
-		virtual UINT32 _getOptimalHeight() const = 0;
-		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const { return _getDepth(); }
+		CM::UINT32 _getWidth() const { return mWidth; }
+		CM::UINT32 _getHeight() const { return mHeight; }
+		virtual CM::UINT32 _getOptimalWidth() const = 0;
+		virtual CM::UINT32 _getOptimalHeight() const = 0;
+		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const { return _getDepth(); }
 
 
 		const CM::Rect& _getBounds() const { return mBounds; }
 		const CM::Rect& _getBounds() const { return mBounds; }
 		CM::Rect _getContentBounds() const;
 		CM::Rect _getContentBounds() const;
-		UINT32 _getDepth() const { return mDepth; }
+		CM::UINT32 _getDepth() const { return mDepth; }
 		GUIWidget& _getParentWidget() const { return mParent; }
 		GUIWidget& _getParentWidget() const { return mParent; }
 		bool _isDirty() const { return mIsDirty; }
 		bool _isDirty() const { return mIsDirty; }
 
 
@@ -128,9 +128,9 @@ namespace BansheeEngine
 		CM::Rect mBounds;
 		CM::Rect mBounds;
 
 
 		bool mIsDirty;
 		bool mIsDirty;
-		UINT32 mDepth;
+		CM::UINT32 mDepth;
 		CM::Int2 mOffset;
 		CM::Int2 mOffset;
-		UINT32 mWidth, mHeight;
+		CM::UINT32 mWidth, mHeight;
 		CM::Rect mClipRect;
 		CM::Rect mClipRect;
 		const GUIElementStyle* mStyle;
 		const GUIElementStyle* mStyle;
 	};
 	};

+ 6 - 6
BansheeEngine/Include/BsGUIElementStyle.h

@@ -13,7 +13,7 @@ namespace BansheeEngine
 			:left(0), right(0), top(0), bottom(0)
 			:left(0), right(0), top(0), bottom(0)
 		{ }
 		{ }
 
 
-		INT32 left, right, top, bottom;
+		CM::INT32 left, right, top, bottom;
 	};
 	};
 
 
 	struct BS_EXPORT GUIElementStyle
 	struct BS_EXPORT GUIElementStyle
@@ -33,7 +33,7 @@ namespace BansheeEngine
 		}
 		}
 
 
 		CM::HFont font;
 		CM::HFont font;
-		UINT32 fontSize;
+		CM::UINT32 fontSize;
 		TextHorzAlign textHorzAlign;
 		TextHorzAlign textHorzAlign;
 		TextVertAlign textVertAlign;
 		TextVertAlign textVertAlign;
 		bool wordWrap;
 		bool wordWrap;
@@ -53,10 +53,10 @@ namespace BansheeEngine
 		RectOffset margins; // Determines offset from the background graphics to the content. Input uses bounds offset by this value.
 		RectOffset margins; // Determines offset from the background graphics to the content. Input uses bounds offset by this value.
 		RectOffset contentOffset; // Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets.
 		RectOffset contentOffset; // Additional offset to the content, that doesn't effect the bounds. Applied on top of the margins offsets.
 
 
-		UINT32 width;
-		UINT32 height;
-		UINT32 minWidth, maxWidth;
-		UINT32 minHeight, maxHeight;
+		CM::UINT32 width;
+		CM::UINT32 height;
+		CM::UINT32 minWidth, maxWidth;
+		CM::UINT32 minHeight, maxHeight;
 		bool fixedWidth;
 		bool fixedWidth;
 		bool fixedHeight;
 		bool fixedHeight;
 	};
 	};

+ 7 - 7
BansheeEngine/Include/BsGUILabel.h

@@ -22,31 +22,31 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc GUIElement::getNumRenderElements()
 		 * @copydoc GUIElement::getNumRenderElements()
 		 */
 		 */
-		virtual UINT32 getNumRenderElements() const;
+		virtual CM::UINT32 getNumRenderElements() const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getMaterial()
 		 * @copydoc GUIElement::getMaterial()
 		 */
 		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumQuads()
 		 * @copydoc GUIElement::getNumQuads()
 		 */
 		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const;
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::fillBuffer()
 		 * @copydoc GUIElement::fillBuffer()
 		 */
 		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 */
 		 */
 		virtual void updateRenderElementsInternal();
 		virtual void updateRenderElementsInternal();
 
 
-		virtual UINT32 _getOptimalWidth() const;
-		virtual UINT32 _getOptimalHeight() const;
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
 	private:
 	private:
 		TextSprite* mTextSprite;
 		TextSprite* mTextSprite;
 		CM::String mText;
 		CM::String mText;

+ 13 - 13
BansheeEngine/Include/BsGUILayout.h

@@ -63,34 +63,34 @@ namespace BansheeEngine
 
 
 		void addElement(GUIElement* element);
 		void addElement(GUIElement* element);
 		void removeElement(GUIElement* element);
 		void removeElement(GUIElement* element);
-		void insertElement(UINT32 idx, GUIElement* element);
+		void insertElement(CM::UINT32 idx, GUIElement* element);
 
 
 		GUILayout& addLayoutX();
 		GUILayout& addLayoutX();
 		GUILayout& addLayoutY();
 		GUILayout& addLayoutY();
 		void removeLayout(GUILayout& layout);
 		void removeLayout(GUILayout& layout);
-		GUILayout& insertLayoutX(UINT32 idx);
-		GUILayout& insertLayoutY(UINT32 idx);
+		GUILayout& insertLayoutX(CM::UINT32 idx);
+		GUILayout& insertLayoutY(CM::UINT32 idx);
 
 
-		GUIFixedSpace& addSpace(UINT32 size);
+		GUIFixedSpace& addSpace(CM::UINT32 size);
 		void removeSpace(GUIFixedSpace& space);
 		void removeSpace(GUIFixedSpace& space);
-		GUIFixedSpace& insertSpace(UINT32 idx, UINT32 size);
+		GUIFixedSpace& insertSpace(CM::UINT32 idx, CM::UINT32 size);
 
 
 		GUIFlexibleSpace& addFlexibleSpace();
 		GUIFlexibleSpace& addFlexibleSpace();
 		void removeFlexibleSpace(GUIFlexibleSpace& space);
 		void removeFlexibleSpace(GUIFlexibleSpace& space);
-		GUIFlexibleSpace& insertFlexibleSpace(UINT32 idx);
+		GUIFlexibleSpace& insertFlexibleSpace(CM::UINT32 idx);
 
 
 		/**
 		/**
 		 * @brief	Returns a combined number of child elements and layouts.
 		 * @brief	Returns a combined number of child elements and layouts.
 		 */
 		 */
-		UINT32 getNumChildren() const;
+		CM::UINT32 getNumChildren() const;
 
 
 		/**
 		/**
 		 * @brief	Re-arranges the elements to fit the layout. (Internal use only)
 		 * @brief	Re-arranges the elements to fit the layout. (Internal use only)
 		 */
 		 */
-		void _update(UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT8 widgetDepth, UINT16 areaDepth);
+		void _update(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
 
 
-		UINT32 _getOptimalWidth() const { return mOptimalWidth; }
-		UINT32 _getOptimalHeight() const { return mOptimalHeight; }
+		CM::UINT32 _getOptimalWidth() const { return mOptimalWidth; }
+		CM::UINT32 _getOptimalHeight() const { return mOptimalHeight; }
 
 
 		void _markAsDirty() { mIsDirty = true; }
 		void _markAsDirty() { mIsDirty = true; }
 		bool _isDirty();
 		bool _isDirty();
@@ -98,12 +98,12 @@ namespace BansheeEngine
 	protected:
 	protected:
 		CM::vector<GUILayoutEntry>::type mChildren;	
 		CM::vector<GUILayoutEntry>::type mChildren;	
 		CM::vector<CM::Int2>::type mOptimalSizes;
 		CM::vector<CM::Int2>::type mOptimalSizes;
-		UINT32 mOptimalWidth;
-		UINT32 mOptimalHeight;
+		CM::UINT32 mOptimalWidth;
+		CM::UINT32 mOptimalHeight;
 
 
 		bool mIsDirty;
 		bool mIsDirty;
 
 
 		virtual void updateOptimalSizes() = 0;
 		virtual void updateOptimalSizes() = 0;
-		virtual void updateInternal(UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT8 widgetDepth, UINT16 areaDepth) = 0;
+		virtual void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth) = 0;
 	};
 	};
 }
 }

+ 6 - 6
BansheeEngine/Include/BsGUILayoutOptions.h

@@ -20,7 +20,7 @@ namespace BansheeEngine
 		 * @brief	Element is fixed to the specified width/height and will not resize.
 		 * @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.
 		 * 			If elements doesn't fully fit in the layout it will be clipped.
 		 */
 		 */
-		static GUILayoutOptions fixed(UINT32 _width, UINT32 _height)
+		static GUILayoutOptions fixed(CM::UINT32 _width, CM::UINT32 _height)
 		{
 		{
 			GUILayoutOptions layoutOptions;
 			GUILayoutOptions layoutOptions;
 			layoutOptions.width = _width;
 			layoutOptions.width = _width;
@@ -37,7 +37,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			If constraints are zero they will not be used.
 		 *			If constraints are zero they will not be used.
 		 */
 		 */
-		static GUILayoutOptions expandableXY(UINT32 _minWidth = 0, UINT32 _minHeight = 0, UINT32 _maxWidth = 0, UINT32 _maxHeight = 0)
+		static GUILayoutOptions expandableXY(CM::UINT32 _minWidth = 0, CM::UINT32 _minHeight = 0, CM::UINT32 _maxWidth = 0, CM::UINT32 _maxHeight = 0)
 		{
 		{
 			GUILayoutOptions layoutOptions;
 			GUILayoutOptions layoutOptions;
 			layoutOptions.minWidth = _minWidth;
 			layoutOptions.minWidth = _minWidth;
@@ -56,7 +56,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			If constraints are zero they will not be used.
 		 *			If constraints are zero they will not be used.
 		 */
 		 */
-		static GUILayoutOptions expandableX(UINT32 _height, UINT32 _minWidth = 0, UINT32 _maxWidth = 0)
+		static GUILayoutOptions expandableX(CM::UINT32 _height, CM::UINT32 _minWidth = 0, CM::UINT32 _maxWidth = 0)
 		{
 		{
 			GUILayoutOptions layoutOptions;
 			GUILayoutOptions layoutOptions;
 			layoutOptions.height = _height;
 			layoutOptions.height = _height;
@@ -74,7 +74,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 *			If constraints are zero they will not be used.
 		 *			If constraints are zero they will not be used.
 		 */
 		 */
-		static GUILayoutOptions expandableY(UINT32 _width, UINT32 _minHeight = 0, UINT32 _maxHeight = 0)
+		static GUILayoutOptions expandableY(CM::UINT32 _width, CM::UINT32 _minHeight = 0, CM::UINT32 _maxHeight = 0)
 		{
 		{
 			GUILayoutOptions layoutOptions;
 			GUILayoutOptions layoutOptions;
 			layoutOptions.width = _width;
 			layoutOptions.width = _width;
@@ -86,8 +86,8 @@ namespace BansheeEngine
 			return layoutOptions;
 			return layoutOptions;
 		}
 		}
 
 
-		UINT32 width, height;
-		UINT32 minWidth, maxWidth, minHeight, maxHeight;
+		CM::UINT32 width, height;
+		CM::UINT32 minWidth, maxWidth, minHeight, maxHeight;
 		bool fixedWidth, fixedHeight;
 		bool fixedWidth, fixedHeight;
 	};
 	};
 }
 }

+ 1 - 1
BansheeEngine/Include/BsGUILayoutX.h

@@ -13,6 +13,6 @@ namespace BansheeEngine
 
 
 	protected:
 	protected:
 		void updateOptimalSizes();
 		void updateOptimalSizes();
-		void updateInternal(UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT8 widgetDepth, UINT16 areaDepth);
+		void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
 	};
 	};
 }
 }

+ 1 - 1
BansheeEngine/Include/BsGUILayoutY.h

@@ -13,6 +13,6 @@ namespace BansheeEngine
 
 
 	protected:
 	protected:
 		void updateOptimalSizes();
 		void updateOptimalSizes();
-		void updateInternal(UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT8 widgetDepth, UINT16 areaDepth);
+		void updateInternal(CM::UINT32 x, CM::UINT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT8 widgetDepth, CM::UINT16 areaDepth);
 	};
 	};
 }
 }

+ 1 - 1
BansheeEngine/Include/BsGUIMaterialManager.h

@@ -47,7 +47,7 @@ namespace BansheeEngine
 			{ }
 			{ }
 
 
 			CM::HMaterial handle;
 			CM::HMaterial handle;
-			UINT32 refCount;
+			CM::UINT32 refCount;
 		};
 		};
 
 
 		mutable CM::vector<GUIMaterial>::type mTextMaterials;
 		mutable CM::vector<GUIMaterial>::type mTextMaterials;

+ 3 - 3
BansheeEngine/Include/BsGUISpace.h

@@ -7,16 +7,16 @@ namespace BansheeEngine
 	class BS_EXPORT GUIFixedSpace
 	class BS_EXPORT GUIFixedSpace
 	{
 	{
 	public:
 	public:
-		GUIFixedSpace(UINT32 size)
+		GUIFixedSpace(CM::UINT32 size)
 			:mSize(size)
 			:mSize(size)
 		{
 		{
 
 
 		}
 		}
 
 
-		UINT32 getSize() const { return mSize; }
+		CM::UINT32 getSize() const { return mSize; }
 
 
 	protected:
 	protected:
-		UINT32 mSize;
+		CM::UINT32 mSize;
 	};
 	};
 
 
 	class BS_EXPORT GUIFlexibleSpace
 	class BS_EXPORT GUIFlexibleSpace

+ 13 - 9
BansheeEngine/Include/BsGUITexture.h

@@ -19,39 +19,43 @@ namespace BansheeEngine
 	public:
 	public:
 		static const CM::String& getGUITypeName();
 		static const CM::String& getGUITypeName();
 
 
-		static GUITexture* create(GUIWidget& parent, const SpriteTexturePtr& texture, GUIImageScaleMode scale, const GUIElementStyle* style = nullptr);
-		static GUITexture* create(GUIWidget& parent, const SpriteTexturePtr& texture, GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
+		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, 
+			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);
 	protected:
 	protected:
 		~GUITexture();
 		~GUITexture();
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumRenderElements()
 		 * @copydoc GUIElement::getNumRenderElements()
 		 */
 		 */
-		virtual UINT32 getNumRenderElements() const;
+		virtual CM::UINT32 getNumRenderElements() const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getMaterial()
 		 * @copydoc GUIElement::getMaterial()
 		 */
 		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumQuads()
 		 * @copydoc GUIElement::getNumQuads()
 		 */
 		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const;
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::fillBuffer()
 		 * @copydoc GUIElement::fillBuffer()
 		 */
 		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 */
 		 */
 		virtual void updateRenderElementsInternal();
 		virtual void updateRenderElementsInternal();
 
 
-		virtual UINT32 _getOptimalWidth() const;
-		virtual UINT32 _getOptimalHeight() const;
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
 
 
 	private:
 	private:
 		ImageSprite* mImageSprite;
 		ImageSprite* mImageSprite;

+ 0 - 59
BansheeEngine/Include/BsGUITitleBar.h

@@ -1,59 +0,0 @@
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsGUIElement.h"
-#include "BsImageSprite.h"
-
-namespace BansheeEngine
-{
-	class BS_EXPORT GUITitleBar : public GUIElement
-	{
-	public:
-		static const CM::String& getGUITypeName();
-
-		static GUITitleBar* create(GUIWidget& parent, const CM::String& title, const GUIElementStyle* style = nullptr);
-		static GUITitleBar* create(GUIWidget& parent, const CM::String& title, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style = nullptr);
-	protected:
-		~GUITitleBar();
-
-		/**
-		 * @copydoc GUIElement::getNumRenderElements()
-		 */
-		virtual UINT32 getNumRenderElements() const;
-
-		/**
-		 * @copydoc GUIElement::getMaterial()
-		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
-
-		/**
-		 * @copydoc GUIElement::getNumQuads()
-		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const;
-
-		/**
-		 * @copydoc GUIElement::fillBuffer()
-		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
-
-		/**
-		 * @copydoc GUIElement::updateRenderElementsInternal()
-		 */
-		virtual void updateRenderElementsInternal();
-
-		virtual UINT32 _getOptimalWidth() const;
-		virtual UINT32 _getOptimalHeight() const;
-
-		virtual UINT32 _getRenderElementDepth(UINT32 renderElementIdx) const;
-	private:
-		ImageSprite* mImageSprite;
-		TextSprite* mTextSprite;
-		UINT32 mNumImageRenderElements;
-
-		IMAGE_SPRITE_DESC mImageDesc;
-		CM::String mText;
-
-		GUITitleBar(GUIWidget& parent, const GUIElementStyle* style, const CM::String& title, const GUILayoutOptions& layoutOptions);
-	};
-}

+ 62 - 0
BansheeEngine/Include/BsGUIToggle.h

@@ -0,0 +1,62 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsGUIElement.h"
+#include "BsImageSprite.h"
+
+namespace BansheeEngine
+{
+	class BS_EXPORT GUIToggle : public GUIElement
+	{
+	public:
+		static const CM::String& getGUITypeName();
+
+		static GUIToggle* create(GUIWidget& parent, const CM::String& text, const GUIElementStyle* style = nullptr);
+		static GUIToggle* create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const CM::String& text, const GUIElementStyle* style = nullptr);
+	protected:
+		~GUIToggle();
+
+		/**
+		 * @copydoc GUIElement::getNumRenderElements()
+		 */
+		virtual CM::UINT32 getNumRenderElements() const;
+
+		/**
+		 * @copydoc GUIElement::getMaterial()
+		 */
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::getNumQuads()
+		 */
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::fillBuffer()
+		 */
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
+
+		/**
+		 * @copydoc GUIElement::updateRenderElementsInternal()
+		 */
+		virtual void updateRenderElementsInternal();
+
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
+
+		virtual CM::UINT32 _getRenderElementDepth(CM::UINT32 renderElementIdx) const;
+	private:
+		ImageSprite* mImageSprite;
+		TextSprite* mTextSprite;
+		CM::UINT32 mNumImageRenderElements;
+		bool mIsToggled;
+
+		IMAGE_SPRITE_DESC mImageDesc;
+		CM::String mText;
+
+		GUIToggle(GUIWidget& parent, const GUIElementStyle* style, const CM::String& text, const GUILayoutOptions& layoutOptions);
+
+		virtual bool mouseEvent(const GUIMouseEvent& ev);
+	};
+}

+ 11 - 5
BansheeEngine/Include/BsGUIWidget.h

@@ -20,13 +20,13 @@ namespace BansheeEngine
 		 * @param	ownerWindow   	Window that contains the widget. This will be the source of all input
 		 * @param	ownerWindow   	Window that contains the widget. This will be the source of all input
 		 * 							for the widget. "target" and "ownerWindow" may be the same object.
 		 * 							for the widget. "target" and "ownerWindow" may be the same object.
 		 */
 		 */
-		void initialize(CM::Viewport* target, const CM::RenderWindow* ownerWindow);
+		virtual void initialize(CM::Viewport* target, const CM::RenderWindow* ownerWindow);
 
 
 		void setSkin(const GUISkin* skin);
 		void setSkin(const GUISkin* skin);
-		const GUISkin* getGUISkin() const;
+		const GUISkin* getSkin() const;
 
 
-		UINT8 getDepth() const { return mDepth; }
-		void setDepth(UINT8 depth) { mDepth = depth; }
+		CM::UINT8 getDepth() const { return mDepth; }
+		void setDepth(CM::UINT8 depth) { mDepth = depth; }
 
 
 		bool inBounds(const CM::Int2& position) const;
 		bool inBounds(const CM::Int2& position) const;
 
 
@@ -44,6 +44,12 @@ namespace BansheeEngine
 		const CM::vector<GUIElement*>::type& getElements() const { return mElements; }
 		const CM::vector<GUIElement*>::type& getElements() const { return mElements; }
 
 
 		void _updateLayout();
 		void _updateLayout();
+
+		/**
+		 * @brief	Forwards the specified mouse event to the specified element. The element
+		 * 			must be a child of this widget.
+		 */
+		virtual bool _mouseEvent(GUIElement* element, const GUIMouseEvent& ev);
 	protected:
 	protected:
 		friend class CM::SceneObject;
 		friend class CM::SceneObject;
 		friend class GUIElement;
 		friend class GUIElement;
@@ -67,7 +73,7 @@ namespace BansheeEngine
 		CM::Viewport* mTarget;
 		CM::Viewport* mTarget;
 		CM::vector<GUIElement*>::type mElements;
 		CM::vector<GUIElement*>::type mElements;
 		CM::vector<GUIArea*>::type mAreas;
 		CM::vector<GUIArea*>::type mAreas;
-		UINT8 mDepth;
+		CM::UINT8 mDepth;
 
 
 		CM::Vector3 mLastFramePosition;
 		CM::Vector3 mLastFramePosition;
 		CM::Quaternion mLastFrameRotation;
 		CM::Quaternion mLastFrameRotation;

+ 7 - 7
BansheeEngine/Include/BsGUIWindowFrame.h

@@ -19,31 +19,31 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @copydoc GUIElement::getNumRenderElements()
 		 * @copydoc GUIElement::getNumRenderElements()
 		 */
 		 */
-		virtual UINT32 getNumRenderElements() const;
+		virtual CM::UINT32 getNumRenderElements() const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getMaterial()
 		 * @copydoc GUIElement::getMaterial()
 		 */
 		 */
-		virtual const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
+		virtual const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::getNumQuads()
 		 * @copydoc GUIElement::getNumQuads()
 		 */
 		 */
-		virtual UINT32 getNumQuads(UINT32 renderElementIdx) const;
+		virtual CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::fillBuffer()
 		 * @copydoc GUIElement::fillBuffer()
 		 */
 		 */
-		virtual void fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, 
-			UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+		virtual void fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, 
+			CM::UINT32 maxNumQuads, CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 * @copydoc GUIElement::updateRenderElementsInternal()
 		 */
 		 */
 		virtual void updateRenderElementsInternal();
 		virtual void updateRenderElementsInternal();
 
 
-		virtual UINT32 _getOptimalWidth() const;
-		virtual UINT32 _getOptimalHeight() const;
+		virtual CM::UINT32 _getOptimalWidth() const;
+		virtual CM::UINT32 _getOptimalHeight() const;
 	private:
 	private:
 		ImageSprite* mImageSprite;
 		ImageSprite* mImageSprite;
 		IMAGE_SPRITE_DESC mDesc;
 		IMAGE_SPRITE_DESC mDesc;

+ 3 - 3
BansheeEngine/Include/BsImageSprite.h

@@ -14,15 +14,15 @@ namespace BansheeEngine
 		{ }
 		{ }
 
 
 		CM::Int2 offset;
 		CM::Int2 offset;
-		UINT32 width;
-		UINT32 height;
+		CM::UINT32 width;
+		CM::UINT32 height;
 		CM::Rect clipRect;
 		CM::Rect clipRect;
 		SpriteAnchor anchor;
 		SpriteAnchor anchor;
 		CM::Vector2 uvScale;
 		CM::Vector2 uvScale;
 		CM::Vector2 uvOffset;
 		CM::Vector2 uvOffset;
 
 
 		SpriteTexturePtr texture;
 		SpriteTexturePtr texture;
-		UINT32 borderLeft, borderRight, borderTop, borderBottom;
+		CM::UINT32 borderLeft, borderRight, borderTop, borderBottom;
 	};
 	};
 
 
 	class BS_EXPORT ImageSprite : public Sprite
 	class BS_EXPORT ImageSprite : public Sprite

+ 3 - 3
BansheeEngine/Include/BsOverlay.h

@@ -33,19 +33,19 @@ namespace BansheeEngine
 		 * @brief	Depth determines in which order the overlays render in case they overlap.
 		 * @brief	Depth determines in which order the overlays render in case they overlap.
 		 * 			Smaller depth means the overlay is in front of anything with larger depth.
 		 * 			Smaller depth means the overlay is in front of anything with larger depth.
 		 */
 		 */
-		INT32 getDepth() const { return mDepth; }
+		CM::INT32 getDepth() const { return mDepth; }
 
 
 		/**
 		/**
 		 * @brief	Depth determines in which order the overlays render in case they overlap.
 		 * @brief	Depth determines in which order the overlays render in case they overlap.
 		 * 			Smaller depth means the overlay is in front of anything with larger depth.
 		 * 			Smaller depth means the overlay is in front of anything with larger depth.
 		 */
 		 */
-		void setDepth(INT32 depth) { mDepth = depth; }
+		void setDepth(CM::INT32 depth) { mDepth = depth; }
 
 
 	protected:
 	protected:
 		friend class CM::SceneObject;
 		friend class CM::SceneObject;
 
 
 		CM::Viewport* mRenderTarget;
 		CM::Viewport* mRenderTarget;
-		INT32 mDepth;
+		CM::INT32 mDepth;
 
 
 		Overlay(const CM::HSceneObject& parent);
 		Overlay(const CM::HSceneObject& parent);
 	};
 	};

+ 3 - 16
BansheeEngine/Include/BsPrerequisites.h

@@ -25,27 +25,14 @@ namespace CM = CamelotFramework;
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	typedef char INT8;
-	typedef unsigned char UINT8;
-	typedef short INT16;
-	typedef unsigned short UINT16;
-	typedef int INT32;
-	typedef unsigned int UINT32;
-	typedef unsigned short WCHAR;
-
-#if CM_COMPILER == CM_COMPILER_MSVC
-	typedef unsigned __int64 UINT64;
-	typedef __int64 INT64;
-#else
-	typedef unsigned long long UINT64;
-	typedef long long INT64;
-#endif
-
 	// GUI
 	// GUI
 	class GUIManager;
 	class GUIManager;
 	class GUIWidget;
 	class GUIWidget;
 	class GUIElement;
 	class GUIElement;
 	class GUILabel;
 	class GUILabel;
+	class GUIButton;
+	class GUITexture;
+	class GUIToggle;
 	class GUISkin;
 	class GUISkin;
 	struct GUIElementStyle;
 	struct GUIElementStyle;
 	class GUIMouseEvent;
 	class GUIMouseEvent;

+ 1 - 1
BansheeEngine/Include/BsRenderableRTTI.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 			return name;
 			return name;
 		}
 		}
 
 
-		virtual UINT32 getRTTIId()
+		virtual CM::UINT32 getRTTIId()
 		{
 		{
 			return TID_Renderable;
 			return TID_Renderable;
 		}
 		}

+ 9 - 8
BansheeEngine/Include/BsSprite.h

@@ -27,8 +27,8 @@ namespace BansheeEngine
 
 
 		CM::Vector2* vertices;
 		CM::Vector2* vertices;
 		CM::Vector2* uvs;
 		CM::Vector2* uvs;
-		UINT32* indexes;
-		UINT32 numQuads;
+		CM::UINT32* indexes;
+		CM::UINT32 numQuads;
 		CM::HMaterial material;
 		CM::HMaterial material;
 	};
 	};
 
 
@@ -46,7 +46,7 @@ namespace BansheeEngine
 		 * 			
 		 * 			
 		 * @return	The number render elements.
 		 * @return	The number render elements.
 		 */
 		 */
-		UINT32 getNumRenderElements() const;
+		CM::UINT32 getNumRenderElements() const;
 
 
 		/**
 		/**
 		 * @brief	Gets a material for the specified render element index.
 		 * @brief	Gets a material for the specified render element index.
@@ -55,7 +55,7 @@ namespace BansheeEngine
 		 * 		
 		 * 		
 		 * @return	Handle to the material.
 		 * @return	Handle to the material.
 		 */
 		 */
-		const CM::HMaterial& getMaterial(UINT32 renderElementIdx) const;
+		const CM::HMaterial& getMaterial(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @brief	Returns the number of quads that the specified render element will use. You will need this
 		 * @brief	Returns the number of quads that the specified render element will use. You will need this
@@ -69,7 +69,7 @@ namespace BansheeEngine
 		 *			
 		 *			
 		 * @return	Number of quads for the specified render element. 
 		 * @return	Number of quads for the specified render element. 
 		 */
 		 */
-		UINT32 getNumQuads(UINT32 renderElementIdx) const;
+		CM::UINT32 getNumQuads(CM::UINT32 renderElementIdx) const;
 
 
 		/**
 		/**
 		 * @brief	Fill the pre-allocated vertex, uv and index buffers with the mesh data for the
 		 * @brief	Fill the pre-allocated vertex, uv and index buffers with the mesh data for the
@@ -88,7 +88,8 @@ namespace BansheeEngine
 		 * @param	indexStride			Number of bytes between two indexes in the provided index data.
 		 * @param	indexStride			Number of bytes between two indexes in the provided index data.
 		 * @param	renderElementIdx	Zero-based index of the render element.
 		 * @param	renderElementIdx	Zero-based index of the render element.
 		 */
 		 */
-		UINT32 fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
+		CM::UINT32 fillBuffer(CM::UINT8* vertices, CM::UINT8* uv, CM::UINT32* indices, CM::UINT32 startingQuad, CM::UINT32 maxNumQuads, 
+			CM::UINT32 vertexStride, CM::UINT32 indexStride, CM::UINT32 renderElementIdx) const;
 
 
 	protected:
 	protected:
 		mutable CM::Rect mBounds;
 		mutable CM::Rect mBounds;
@@ -97,7 +98,7 @@ namespace BansheeEngine
 		void updateBounds() const;
 		void updateBounds() const;
 		void clearMesh() const;
 		void clearMesh() const;
 
 
-		void clipToRect(CM::Vector2* vertices, CM::Vector2* uv, UINT32 numQuads, const CM::Rect& clipRect) const;
-		CM::Int2 getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height) const;
+		void clipToRect(CM::Vector2* vertices, CM::Vector2* uv, CM::UINT32 numQuads, const CM::Rect& clipRect) const;
+		CM::Int2 getAnchorOffset(SpriteAnchor anchor, CM::UINT32 width, CM::UINT32 height) const;
 	};
 	};
 }
 }

+ 3 - 3
BansheeEngine/Include/BsTextSprite.h

@@ -23,14 +23,14 @@ namespace BansheeEngine
 		{ }
 		{ }
 
 
 		CM::Int2 offset;
 		CM::Int2 offset;
-		UINT32 width;
-		UINT32 height;
+		CM::UINT32 width;
+		CM::UINT32 height;
 		CM::Rect clipRect;
 		CM::Rect clipRect;
 		SpriteAnchor anchor;
 		SpriteAnchor anchor;
 
 
 		CM::String text;
 		CM::String text;
 		CM::HFont font;
 		CM::HFont font;
-		UINT32 fontSize;
+		CM::UINT32 fontSize;
 		TextHorzAlign horzAlign;
 		TextHorzAlign horzAlign;
 		TextVertAlign vertAlign;
 		TextVertAlign vertAlign;
 		bool wordWrap;
 		bool wordWrap;

+ 65 - 5
BansheeEngine/Source/BsEngineGUI.cpp

@@ -35,6 +35,9 @@ namespace BansheeEngine
 	const String EngineGUI::WindowMinButtonNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnNormal.psd";
 	const String EngineGUI::WindowMinButtonNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnNormal.psd";
 	const String EngineGUI::WindowMinButtonHover = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnHover.psd";
 	const String EngineGUI::WindowMinButtonHover = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\WindowMinBtnHover.psd";
 
 
+	const String EngineGUI::TabbedBarBtnNormal = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\TabbedButtonNormal.psd";
+	const String EngineGUI::TabbedBarBtnActive = "C:\\Projects\\BansheeEngine\\Data\\Editor\\Skin\\TabbedButtonActive.psd";
+
 	EngineGUI::EngineGUI()
 	EngineGUI::EngineGUI()
 	{
 	{
 		// TODO - Normally I want to load this from some file
 		// TODO - Normally I want to load this from some file
@@ -110,15 +113,72 @@ namespace BansheeEngine
 
 
 		// Window background texture
 		// Window background texture
 		HTexture windowBgTexture = static_resource_cast<Texture>(Importer::instance().import(WindowBackgroundTexture));
 		HTexture windowBgTexture = static_resource_cast<Texture>(Importer::instance().import(WindowBackgroundTexture));
-		mWindowBgTex = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowBgTexture));
+
+		GUIElementStyle windowBgStyle;
+		windowBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowBgTexture));
+
+		mSkin.setStyle("WindowBackground", windowBgStyle);
 
 
 		// Window title bar background
 		// Window title bar background
 		HTexture windowTitleBarBg = static_resource_cast<Texture>(Importer::instance().import(WindowTitleBarBg));
 		HTexture windowTitleBarBg = static_resource_cast<Texture>(Importer::instance().import(WindowTitleBarBg));
 
 
-		GUIElementStyle titleBarStyle;
-		titleBarStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowTitleBarBg));
-		titleBarStyle.fixedHeight = true;
-		titleBarStyle.height = 11;
+		GUIElementStyle titleBarBgStyle;
+		titleBarBgStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(windowTitleBarBg));
+		titleBarBgStyle.fixedHeight = true;
+		titleBarBgStyle.height = 13;
+
+		mSkin.setStyle("TitleBarBackground", titleBarBgStyle);
+
+		// Tabbed title bar tab button
+		HTexture tabbedBarBtnNormal = static_resource_cast<Texture>(Importer::instance().import(TabbedBarBtnNormal));
+		HTexture tabbedBarBtnActive = static_resource_cast<Texture>(Importer::instance().import(TabbedBarBtnActive));
+
+		GUIElementStyle tabbedBarButton;
+		tabbedBarButton.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnNormal));
+		tabbedBarButton.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(tabbedBarBtnActive));
+		tabbedBarButton.active.texture = tabbedBarButton.hover.texture;
+		tabbedBarButton.normalOn.texture = tabbedBarButton.hover.texture;
+		tabbedBarButton.hoverOn.texture = tabbedBarButton.hover.texture;
+		tabbedBarButton.activeOn.texture = tabbedBarButton.hover.texture;
+		tabbedBarButton.fixedHeight = true;
+		tabbedBarButton.height = 13;
+
+		mSkin.setStyle("TabbedBarBtn", tabbedBarButton);
+
+		// Tabbed title bar drag/drop button
+		GUIElementStyle tabbedBarDropButton;
+		tabbedBarDropButton.fixedHeight = true;
+		tabbedBarDropButton.fixedWidth = true;
+		tabbedBarDropButton.height = 13;
+		tabbedBarDropButton.width = 15;
+
+		mSkin.setStyle("TabbedBarDropArea", tabbedBarDropButton);
+
+		// Window minimize button
+		HTexture winMinBtnNormal = static_resource_cast<Texture>(Importer::instance().import(WindowMinButtonNormal));
+		HTexture winMinBtnHover = static_resource_cast<Texture>(Importer::instance().import(WindowMinButtonHover));
+
+		GUIElementStyle winMinButtonStyle;
+		winMinButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnNormal));
+		winMinButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winMinBtnHover));
+		winMinButtonStyle.active.texture = winMinButtonStyle.hover.texture;
+		winMinButtonStyle.fixedHeight = true;
+		winMinButtonStyle.height = 13;
+
+		mSkin.setStyle("WinMinimizeBtn", winMinButtonStyle);
+
+		// Window close button
+		HTexture winCloseBtnNormal = static_resource_cast<Texture>(Importer::instance().import(WindowCloseButtonNormal));
+		HTexture winCloseBtnHover = static_resource_cast<Texture>(Importer::instance().import(WindowCloseButtonHover));
+
+		GUIElementStyle winCloseButtonStyle;
+		winCloseButtonStyle.normal.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnNormal));
+		winCloseButtonStyle.hover.texture = cm_shared_ptr<SpriteTexture, PoolAlloc>(std::cref(winCloseBtnHover));
+		winCloseButtonStyle.active.texture = winCloseButtonStyle.active.texture;
+		winCloseButtonStyle.fixedHeight = true;
+		winCloseButtonStyle.height = 13;
+
+		mSkin.setStyle("WinCloseBtn", winCloseButtonStyle);
 	}
 	}
 
 
 }
 }

+ 17 - 5
BansheeEngine/Source/BsGUIButton.cpp

@@ -48,7 +48,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
@@ -59,7 +59,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
@@ -171,15 +171,27 @@ namespace BansheeEngine
 		{
 		{
 			mImageDesc.texture = mStyle->hover.texture;
 			mImageDesc.texture = mStyle->hover.texture;
 			markAsDirty();
 			markAsDirty();
-			// TODO - What happens when a texture is not set?
-			// 
+
 			return true;
 			return true;
 		}
 		}
 		else if(ev.getType() == GUIMouseEventType::MouseOut)
 		else if(ev.getType() == GUIMouseEventType::MouseOut)
 		{
 		{
 			mImageDesc.texture = mStyle->normal.texture;
 			mImageDesc.texture = mStyle->normal.texture;
 			markAsDirty();
 			markAsDirty();
-			// TODO - What happens when a texture is not set?
+
+			return true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseDown)
+		{
+			mImageDesc.texture = mStyle->active.texture;
+			markAsDirty();
+
+			return true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseUp)
+		{
+			mImageDesc.texture = mStyle->normal.texture;
+			markAsDirty();
 
 
 			return true;
 			return true;
 		}
 		}

+ 2 - 2
BansheeEngine/Source/BsGUILabel.cpp

@@ -112,7 +112,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
@@ -123,7 +123,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 

+ 5 - 5
BansheeEngine/Source/BsGUIManager.cpp

@@ -480,14 +480,14 @@ namespace BansheeEngine
 				Int2 oldScreenPos = Cursor::getWindowPosition(*window);
 				Int2 oldScreenPos = Cursor::getWindowPosition(*window);
 
 
 				GUIMouseEvent event(GUIMouseEventType::MouseOut, oldScreenPos); // TODO - This pos will be wrong as it might be related to completely other window
 				GUIMouseEvent event(GUIMouseEventType::MouseOut, oldScreenPos); // TODO - This pos will be wrong as it might be related to completely other window
-				mMouseOverElement->mouseEvent(event);
+				mMouseOverWidget->_mouseEvent(mMouseOverElement, event);
 			}
 			}
 
 
 			if(topMostElement != nullptr)
 			if(topMostElement != nullptr)
 			{
 			{
 				// Send MouseOver event
 				// Send MouseOver event
 				GUIMouseEvent event(GUIMouseEventType::MouseOver, screenPos);
 				GUIMouseEvent event(GUIMouseEventType::MouseOver, screenPos);
-				topMostElement->mouseEvent(event);
+				widgetInFocus->_mouseEvent(topMostElement, event);
 			}
 			}
 
 
 			mMouseOverElement = topMostElement;
 			mMouseOverElement = topMostElement;
@@ -500,7 +500,7 @@ namespace BansheeEngine
 			if(mLastCursorPos != screenPos)
 			if(mLastCursorPos != screenPos)
 			{
 			{
 				GUIMouseEvent event(GUIMouseEventType::MouseMove, screenPos);
 				GUIMouseEvent event(GUIMouseEventType::MouseMove, screenPos);
-				mMouseOverElement->mouseEvent(event);
+				mMouseOverWidget->_mouseEvent(mMouseOverElement, event);
 			}
 			}
 
 
 			// Send MouseDown and MouseUp events
 			// Send MouseDown and MouseUp events
@@ -512,12 +512,12 @@ namespace BansheeEngine
 					if(buttonDown)
 					if(buttonDown)
 					{
 					{
 						GUIMouseEvent event(GUIMouseEventType::MouseDown, screenPos, (MouseButton)i);
 						GUIMouseEvent event(GUIMouseEventType::MouseDown, screenPos, (MouseButton)i);
-						mMouseOverElement->mouseEvent(event);
+						mMouseOverWidget->_mouseEvent(mMouseOverElement, event);
 					}
 					}
 					else
 					else
 					{
 					{
 						GUIMouseEvent event(GUIMouseEventType::MouseUp, screenPos, (MouseButton)i);
 						GUIMouseEvent event(GUIMouseEventType::MouseUp, screenPos, (MouseButton)i);
-						mMouseOverElement->mouseEvent(event);
+						mMouseOverWidget->_mouseEvent(mMouseOverElement, event);
 					}
 					}
 
 
 					mLastFrameButtonState[i] = buttonDown;
 					mLastFrameButtonState[i] = buttonDown;

+ 30 - 5
BansheeEngine/Source/BsGUITexture.cpp

@@ -22,7 +22,10 @@ namespace BansheeEngine
 	{
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 
 
-		mDesc.texture = texture;
+		if(texture != nullptr)
+			mDesc.texture = texture;
+		else
+			mDesc.texture = style->normal.texture;
 	
 	
 		mDesc.borderLeft = mStyle->border.left;
 		mDesc.borderLeft = mStyle->border.left;
 		mDesc.borderRight = mStyle->border.right;
 		mDesc.borderRight = mStyle->border.right;
@@ -40,25 +43,47 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			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, getDefaultLayoutOptions(style));
 	}
 	}
 
 
-	GUITexture* GUITexture::create(GUIWidget& parent, const SpriteTexturePtr& texture, 
-		GUIImageScaleMode scale, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUITexture* GUITexture::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const SpriteTexturePtr& texture, 
+		GUIImageScaleMode scale, const GUIElementStyle* style)
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			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, layoutOptions);
 	}
 	}
 
 
+	GUITexture* GUITexture::create(GUIWidget& parent, GUIImageScaleMode scale, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, getDefaultLayoutOptions(style));
+	}
+
+	GUITexture* GUITexture::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, GUIImageScaleMode scale, const GUIElementStyle* style)
+	{
+		if(style == nullptr)
+		{
+			const GUISkin* skin = parent.getSkin();
+			style = skin->getStyle(getGUITypeName());
+		}
+
+		return new (cm_alloc<GUITexture, PoolAlloc>()) GUITexture(parent, style, nullptr, scale, layoutOptions);
+	}
+
 	UINT32 GUITexture::getNumRenderElements() const
 	UINT32 GUITexture::getNumRenderElements() const
 	{
 	{
 		return mImageSprite->getNumRenderElements();
 		return mImageSprite->getNumRenderElements();

+ 70 - 20
BansheeEngine/Source/BsGUITitleBar.cpp → BansheeEngine/Source/BsGUIToggle.cpp

@@ -1,4 +1,4 @@
-#include "BsGUITitleBar.h"
+#include "BsGUIToggle.h"
 #include "BsImageSprite.h"
 #include "BsImageSprite.h"
 #include "BsGUIWidget.h"
 #include "BsGUIWidget.h"
 #include "BsGUISkin.h"
 #include "BsGUISkin.h"
@@ -12,14 +12,14 @@ using namespace CamelotFramework;
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	const String& GUITitleBar::getGUITypeName()
+	const String& GUIToggle::getGUITypeName()
 	{
 	{
-		static String name = "TitleBar";
+		static String name = "Toggle";
 		return name;
 		return name;
 	}
 	}
 
 
-	GUITitleBar::GUITitleBar(GUIWidget& parent, const GUIElementStyle* style, const String& title, const GUILayoutOptions& layoutOptions)
-		:GUIElement(parent, style, layoutOptions), mText(title), mNumImageRenderElements(0)
+	GUIToggle::GUIToggle(GUIWidget& parent, const GUIElementStyle* style, const String& text, const GUILayoutOptions& layoutOptions)
+		:GUIElement(parent, style, layoutOptions), mText(text), mNumImageRenderElements(0), mIsToggled(false)
 	{
 	{
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mImageSprite = cm_new<ImageSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
 		mTextSprite = cm_new<TextSprite, PoolAlloc>();
@@ -38,35 +38,35 @@ namespace BansheeEngine
 		mImageDesc.borderBottom = mStyle->border.bottom;
 		mImageDesc.borderBottom = mStyle->border.bottom;
 	}
 	}
 
 
-	GUITitleBar::~GUITitleBar()
+	GUIToggle::~GUIToggle()
 	{
 	{
 		cm_delete<PoolAlloc>(mTextSprite);
 		cm_delete<PoolAlloc>(mTextSprite);
 		cm_delete<PoolAlloc>(mImageSprite);
 		cm_delete<PoolAlloc>(mImageSprite);
 	}
 	}
 
 
-	GUITitleBar* GUITitleBar::create(GUIWidget& parent, const String& title, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const String& text, const GUIElementStyle* style)
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
-		return new (cm_alloc<GUITitleBar, PoolAlloc>()) GUITitleBar(parent, style, title, getDefaultLayoutOptions(style));
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, text, getDefaultLayoutOptions(style));
 	}
 	}
 
 
-	GUITitleBar* GUITitleBar::create(GUIWidget& parent, const String& title, const GUILayoutOptions& layoutOptions, const GUIElementStyle* style)
+	GUIToggle* GUIToggle::create(GUIWidget& parent, const GUILayoutOptions& layoutOptions, const String& text, const GUIElementStyle* style)
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
-		return new (cm_alloc<GUITitleBar, PoolAlloc>()) GUITitleBar(parent, style, title, layoutOptions);
+		return new (cm_alloc<GUIToggle, PoolAlloc>()) GUIToggle(parent, style, text, layoutOptions);
 	}
 	}
 
 
-	UINT32 GUITitleBar::getNumRenderElements() const
+	UINT32 GUIToggle::getNumRenderElements() const
 	{
 	{
 		UINT32 numElements = mImageSprite->getNumRenderElements();
 		UINT32 numElements = mImageSprite->getNumRenderElements();
 		numElements += mTextSprite->getNumRenderElements();
 		numElements += mTextSprite->getNumRenderElements();
@@ -74,7 +74,7 @@ namespace BansheeEngine
 		return numElements;
 		return numElements;
 	}
 	}
 
 
-	const HMaterial& GUITitleBar::getMaterial(UINT32 renderElementIdx) const
+	const HMaterial& GUIToggle::getMaterial(UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
 			return mTextSprite->getMaterial(mNumImageRenderElements - renderElementIdx);
 			return mTextSprite->getMaterial(mNumImageRenderElements - renderElementIdx);
@@ -82,7 +82,7 @@ namespace BansheeEngine
 			return mImageSprite->getMaterial(renderElementIdx);
 			return mImageSprite->getMaterial(renderElementIdx);
 	}
 	}
 
 
-	UINT32 GUITitleBar::getNumQuads(UINT32 renderElementIdx) const
+	UINT32 GUIToggle::getNumQuads(UINT32 renderElementIdx) const
 	{
 	{
 		UINT32 numQuads = 0;
 		UINT32 numQuads = 0;
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
@@ -93,7 +93,7 @@ namespace BansheeEngine
 		return numQuads;
 		return numQuads;
 	}
 	}
 
 
-	void GUITitleBar::updateRenderElementsInternal()
+	void GUIToggle::updateRenderElementsInternal()
 	{		
 	{		
 		mImageDesc.offset = mOffset;
 		mImageDesc.offset = mOffset;
 		mImageDesc.width = mWidth;
 		mImageDesc.width = mWidth;
@@ -128,7 +128,7 @@ namespace BansheeEngine
 		mTextSprite->update(textDesc);
 		mTextSprite->update(textDesc);
 	}
 	}
 
 
-	UINT32 GUITitleBar::_getOptimalWidth() const
+	UINT32 GUIToggle::_getOptimalWidth() const
 	{
 	{
 		if(mImageDesc.texture != nullptr)
 		if(mImageDesc.texture != nullptr)
 		{
 		{
@@ -138,7 +138,7 @@ namespace BansheeEngine
 		return 0;
 		return 0;
 	}
 	}
 
 
-	UINT32 GUITitleBar::_getOptimalHeight() const
+	UINT32 GUIToggle::_getOptimalHeight() const
 	{
 	{
 		if(mImageDesc.texture != nullptr)
 		if(mImageDesc.texture != nullptr)
 		{
 		{
@@ -148,7 +148,7 @@ namespace BansheeEngine
 		return 0;
 		return 0;
 	}
 	}
 
 
-	UINT32 GUITitleBar::_getRenderElementDepth(UINT32 renderElementIdx) const
+	UINT32 GUIToggle::_getRenderElementDepth(UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
 			return _getDepth();
 			return _getDepth();
@@ -156,7 +156,7 @@ namespace BansheeEngine
 			return _getDepth() + 1;
 			return _getDepth() + 1;
 	}
 	}
 
 
-	void GUITitleBar::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
+	void GUIToggle::fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad, UINT32 maxNumQuads, 
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 		UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const
 	{
 	{
 		if(renderElementIdx >= mNumImageRenderElements)
 		if(renderElementIdx >= mNumImageRenderElements)
@@ -164,4 +164,54 @@ namespace BansheeEngine
 		else
 		else
 			mImageSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, vertexStride, indexStride, renderElementIdx);
 			mImageSprite->fillBuffer(vertices, uv, indices, startingQuad, maxNumQuads, vertexStride, indexStride, renderElementIdx);
 	}
 	}
+
+	bool GUIToggle::mouseEvent(const GUIMouseEvent& ev)
+	{
+		if(ev.getType() == GUIMouseEventType::MouseOver)
+		{
+			if(mIsToggled)
+				mImageDesc.texture = mStyle->hoverOn.texture;
+			else
+				mImageDesc.texture = mStyle->hover.texture;
+
+			markAsDirty();
+			return true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseOut)
+		{
+			if(mIsToggled)
+				mImageDesc.texture = mStyle->normalOn.texture;
+			else
+				mImageDesc.texture = mStyle->normal.texture;
+
+			markAsDirty();
+			return true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseDown)
+		{
+			if(mIsToggled)
+				mImageDesc.texture = mStyle->activeOn.texture;
+			else
+				mImageDesc.texture = mStyle->active.texture;
+
+			mIsToggled = !mIsToggled;
+
+			markAsDirty();
+			return true;
+		}
+		else if(ev.getType() == GUIMouseEventType::MouseUp)
+		{
+			if(mIsToggled)
+				mImageDesc.texture = mStyle->normalOn.texture;
+			else
+				mImageDesc.texture = mStyle->normal.texture;
+
+			mIsToggled = !mIsToggled;
+
+			markAsDirty();
+			return true;
+		}
+
+		return false;
+	}
 }
 }

+ 6 - 1
BansheeEngine/Source/BsGUIWidget.cpp

@@ -113,6 +113,11 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
+	bool GUIWidget::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
+	{
+		return element->mouseEvent(ev);
+	}
+
 	void GUIWidget::registerElement(GUIElement* elem)
 	void GUIWidget::registerElement(GUIElement* elem)
 	{
 	{
 		assert(elem != nullptr);
 		assert(elem != nullptr);
@@ -162,7 +167,7 @@ namespace BansheeEngine
 		mSkin = skin;
 		mSkin = skin;
 	}
 	}
 
 
-	const GUISkin* GUIWidget::getGUISkin() const
+	const GUISkin* GUIWidget::getSkin() const
 	{
 	{
 		if(mSkin != nullptr)
 		if(mSkin != nullptr)
 			return mSkin;
 			return mSkin;

+ 2 - 2
BansheeEngine/Source/BsGUIWindowFrame.cpp

@@ -44,7 +44,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 
@@ -55,7 +55,7 @@ namespace BansheeEngine
 	{
 	{
 		if(style == nullptr)
 		if(style == nullptr)
 		{
 		{
-			const GUISkin* skin = parent.getGUISkin();
+			const GUISkin* skin = parent.getSkin();
 			style = skin->getStyle(getGUITypeName());
 			style = skin->getStyle(getGUITypeName());
 		}
 		}
 
 

+ 89 - 0
CamelotClient/BsGUITabbedTitleBar.cpp

@@ -0,0 +1,89 @@
+#include "BsGUITabbedTitleBar.h"
+#include "BsGUIArea.h"
+#include "BsGUILayout.h"
+#include "BsGUITexture.h"
+#include "BsGUIButton.h"
+#include "BsGUIToggle.h"
+#include "BsEngineGUI.h"
+#include "CmMath.h"
+
+using namespace CamelotFramework;
+using namespace BansheeEngine;
+
+namespace BansheeEditor
+{
+	TabbedTitleBar::TabbedTitleBar(const HSceneObject& parent)
+		:GUIWidget(parent), mLastDropElement(nullptr), mMinBtn(nullptr), mCloseBtn(nullptr), mMainArea(nullptr)
+	{
+
+	}
+
+	TabbedTitleBar::~TabbedTitleBar()
+	{
+
+	}
+
+	void TabbedTitleBar::addTab(const CM::String& name)
+	{
+		insertTab((UINT32)mTabButtons.size(), name);
+	}
+
+	void TabbedTitleBar::insertTab(UINT32 idx, const CM::String& name)
+	{
+		GUIToggle* newTabToggle = GUIToggle::create(*this, GUILayoutOptions::expandableX(13, 100, 200), name);
+		GUITexture* newDragDropElement = GUITexture::create(*this, GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TabbedBarDropArea"));
+
+		idx = Math::Clamp(idx, 0U, (UINT32)mTabButtons.size());
+
+		mTabButtons.insert(mTabButtons.begin() + idx, newTabToggle);
+		mDragDropElements.insert(mDragDropElements.begin() + idx, newDragDropElement);
+
+		mMainArea->getLayout().insertElement(idx * 2, newTabToggle);
+		mMainArea->getLayout().insertElement(idx * 2, newTabToggle);
+	}
+
+	void TabbedTitleBar::removeTab(UINT32 idx)
+	{
+		if(mTabButtons.size() == 0)
+			return;
+
+		idx = Math::Clamp(idx, 0U, (UINT32)mTabButtons.size() - 1);
+
+		mMainArea->getLayout().removeElement(mTabButtons[idx]);
+		mMainArea->getLayout().removeElement(mDragDropElements[idx]);
+
+		mTabButtons.erase(mTabButtons.begin() + idx);
+		mDragDropElements.erase(mDragDropElements.begin() + idx);
+	}
+
+	void TabbedTitleBar::initialize(CM::Viewport* target, const CM::RenderWindow* ownerWindow)
+	{
+		GUIWidget::initialize(target, ownerWindow);
+
+		GUIArea* backgroundArea = GUIArea::create(*this, 0, 0, 0, 0, 500);
+		GUITexture* titleBarBg = GUITexture::create(*this, GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TitleBarBackground"));
+		backgroundArea->getLayout().addElement(titleBarBg);
+
+		GUIArea* mainArea = GUIArea::create(*this, 0, 0, 0, 0, 499);
+
+		GUITexture* dragDropElement = GUITexture::create(*this, GUILayoutOptions::expandableX(13, 20), GUIImageScaleMode::StretchToFit, EngineGUI::instance().getSkin().getStyle("TabbedBarDropArea"));
+		mLastDropElement = dragDropElement;
+
+		mMinBtn = GUIButton::create(*this, "");
+		mCloseBtn = GUIButton::create(*this, "");
+
+		mainArea->getLayout().addElement(dragDropElement);
+		mainArea->getLayout().addElement(mMinBtn);
+		mainArea->getLayout().addElement(mCloseBtn);
+	}
+
+	void TabbedTitleBar::update()
+	{
+
+	}
+
+	bool TabbedTitleBar::_mouseEvent(GUIElement* element, const GUIMouseEvent& ev)
+	{
+		return GUIWidget::_mouseEvent(element, ev);
+	}
+}

+ 37 - 0
CamelotClient/BsGUITabbedTitleBar.h

@@ -0,0 +1,37 @@
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsGUIWidget.h"
+#include <boost/signal.hpp>
+
+namespace BansheeEditor
+{
+	class TabbedTitleBar : public BS::GUIWidget
+	{
+	public:
+		TabbedTitleBar(const CM::HSceneObject& parent);
+		virtual ~TabbedTitleBar();
+
+		virtual void initialize(CM::Viewport* target, const CM::RenderWindow* ownerWindow);
+
+		void addTab(const CM::String& name);
+		void insertTab(CM::UINT32 idx, const CM::String& name);
+		void removeTab(CM::UINT32 idx);
+
+		boost::signal<void(CM::UINT32)> onTabActivated;
+		boost::signal<void(CM::UINT32)> onTabAdded;
+		boost::signal<void(CM::UINT32)> onTabRemoved;
+	protected:
+		CM::vector<BS::GUITexture*>::type mDragDropElements;
+		CM::vector<BS::GUIToggle*>::type mTabButtons;
+
+		BS::GUIArea* mMainArea;
+		BS::GUIButton* mMinBtn;
+		BS::GUIButton* mCloseBtn;
+		BS::GUITexture* mLastDropElement;
+
+		virtual void update();
+
+		virtual bool _mouseEvent(BS::GUIElement* element, const BS::GUIMouseEvent& ev);
+	};
+}

+ 2 - 0
CamelotClient/CamelotClient.vcxproj

@@ -167,6 +167,7 @@
     <Text Include="ReadMe.txt" />
     <Text Include="ReadMe.txt" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClInclude Include="BsGUITabbedTitleBar.h" />
     <ClInclude Include="CmDebugCamera.h" />
     <ClInclude Include="CmDebugCamera.h" />
     <ClInclude Include="CmEditorWindow.h" />
     <ClInclude Include="CmEditorWindow.h" />
     <ClInclude Include="CmTestTextSprite.h" />
     <ClInclude Include="CmTestTextSprite.h" />
@@ -174,6 +175,7 @@
     <ClInclude Include="targetver.h" />
     <ClInclude Include="targetver.h" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClCompile Include="BsGUITabbedTitleBar.cpp" />
     <ClCompile Include="CamelotClient.cpp" />
     <ClCompile Include="CamelotClient.cpp" />
     <ClCompile Include="CmDebugCamera.cpp" />
     <ClCompile Include="CmDebugCamera.cpp" />
     <ClCompile Include="CmEditorWindow.cpp" />
     <ClCompile Include="CmEditorWindow.cpp" />

+ 6 - 0
CamelotClient/CamelotClient.vcxproj.filters

@@ -33,6 +33,9 @@
     <ClInclude Include="CmEditorWindow.h">
     <ClInclude Include="CmEditorWindow.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="BsGUITabbedTitleBar.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="stdafx.cpp">
     <ClCompile Include="stdafx.cpp">
@@ -50,5 +53,8 @@
     <ClCompile Include="CmEditorWindow.cpp">
     <ClCompile Include="CmEditorWindow.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="BsGUITabbedTitleBar.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 7 - 2
CamelotClient/CmEditorWindow.cpp

@@ -16,6 +16,7 @@
 #include "BsUpdateCallback.h"
 #include "BsUpdateCallback.h"
 #include "BsEngineGUI.h"
 #include "BsEngineGUI.h"
 #include "BsGUIArea.h"
 #include "BsGUIArea.h"
+#include "BsGUITabbedTitleBar.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 using namespace BansheeEngine;
 using namespace BansheeEngine;
@@ -48,9 +49,13 @@ namespace BansheeEditor
 		mGUI = so->addComponent<GUIWidget>();
 		mGUI = so->addComponent<GUIWidget>();
 		mGUI->initialize(camera->getViewport().get(), mRenderWindow.get());
 		mGUI->initialize(camera->getViewport().get(), mRenderWindow.get());
 
 
-		//// DEBUG
 		mGUI->setSkin(&EngineGUI::instance().getSkin());
 		mGUI->setSkin(&EngineGUI::instance().getSkin());
 
 
+		GameObjectHandle<TabbedTitleBar> titleBar = so->addComponent<TabbedTitleBar>();
+		titleBar->initialize(camera->getViewport().get(), mRenderWindow.get());
+
+		//// DEBUG
+		
 		//GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 0);
 		//GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 0);
 		//GUILayout& layout = backgroundArea->getLayout();
 		//GUILayout& layout = backgroundArea->getLayout();
 		
 		
@@ -69,7 +74,7 @@ namespace BansheeEditor
 		//otherLayout.addElement(GUIWindowFrame::create(*mGUI));
 		//otherLayout.addElement(GUIWindowFrame::create(*mGUI));
 		
 		
 		GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
 		GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
-		backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, EngineGUI::instance().getWindowBgTex(), GUIImageScaleMode::RepeatToFit, GUILayoutOptions::expandableXY()));
+		backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
 
 
 		GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
 		GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
 		windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
 		windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));

+ 18 - 3
CamelotCore/Include/Win32/CmCursorImpl.h

@@ -3,16 +3,29 @@
 #include "CmPrerequisites.h"
 #include "CmPrerequisites.h"
 #include "CmInt2.h"
 #include "CmInt2.h"
 #include "CmRect.h"
 #include "CmRect.h"
-#include <windows.h>
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
+	// Encapsulate native cursor type so we can avoid including windows.h as it pollutes the global namespace
+	struct CM_EXPORT NativeCursorData
+	{
+		struct Pimpl;
+
+		NativeCursorData();
+		~NativeCursorData();
+
+		Pimpl* data;
+	};
+
 	/**
 	/**
 	 * @brief	Provides controls for Windows operating system cursor.
 	 * @brief	Provides controls for Windows operating system cursor.
 	 */
 	 */
 	class CM_EXPORT Cursor
 	class CM_EXPORT Cursor
 	{
 	{
 	public:
 	public:
+		Cursor();
+		~Cursor();
+
 		static Int2 getScreenPosition();
 		static Int2 getScreenPosition();
 		static void setScreenPosition(const Int2& pos);
 		static void setScreenPosition(const Int2& pos);
 
 
@@ -30,11 +43,13 @@ namespace CamelotFramework
 		
 		
 		static void setCursor(CursorType type);
 		static void setCursor(CursorType type);
 		static void setCustomCursor(PixelData& pixelData, const Int2& hotSpot);
 		static void setCustomCursor(PixelData& pixelData, const Int2& hotSpot);
-		static HCURSOR getHCursor() { return mCursor; }
 
 
+		static void _win32ShowCursor();
+		static void _win32HideCursor();
+		
 	private:
 	private:
 		static bool mIsHidden;
 		static bool mIsHidden;
-		static HCURSOR mCursor;
+		static NativeCursorData mCursor;
 		static bool mUsingCustom;
 		static bool mUsingCustom;
 	};
 	};
 }
 }

+ 2 - 2
CamelotCore/Source/CmWindowEventUtilities.cpp

@@ -234,9 +234,9 @@ LRESULT CALLBACK WindowEventUtilities::_WndProc(HWND hWnd, UINT uMsg, WPARAM wPa
 		break;
 		break;
 	case WM_SETCURSOR:
 	case WM_SETCURSOR:
 		if(Cursor::isHidden())
 		if(Cursor::isHidden())
-			SetCursor(0);
+			Cursor::_win32HideCursor();
 		else
 		else
-			SetCursor(Cursor::getHCursor());
+			Cursor::_win32ShowCursor();
 		return true;
 		return true;
 	case WM_GETMINMAXINFO:
 	case WM_GETMINMAXINFO:
 		// Prevent the window from going smaller than some minimu size
 		// Prevent the window from going smaller than some minimu size

+ 38 - 73
CamelotCore/Source/Win32/CmCursorImpl.cpp

@@ -3,11 +3,27 @@
 #include "CmWindowEventUtilities.h"
 #include "CmWindowEventUtilities.h"
 #include "CmPixelUtil.h"
 #include "CmPixelUtil.h"
 #include "CmApplication.h"
 #include "CmApplication.h"
+#include <windows.h>
 
 
 namespace CamelotFramework
 namespace CamelotFramework
 {
 {
+	struct NativeCursorData::Pimpl
+	{
+		HCURSOR cursor;
+	};
+
+	NativeCursorData::NativeCursorData()
+	{
+		data = cm_new<Pimpl>();
+	}
+
+	NativeCursorData::~NativeCursorData()
+	{
+		cm_delete(data);
+	}
+
 	bool Cursor::mIsHidden = false;
 	bool Cursor::mIsHidden = false;
-	HCURSOR Cursor::mCursor;
+	NativeCursorData Cursor::mCursor;
 	bool Cursor::mUsingCustom = false;
 	bool Cursor::mUsingCustom = false;
 
 
 	Int2 Cursor::getWindowPosition(const RenderWindow& window)
 	Int2 Cursor::getWindowPosition(const RenderWindow& window)
@@ -119,41 +135,41 @@ namespace CamelotFramework
 		if(mUsingCustom)
 		if(mUsingCustom)
 		{
 		{
 			SetCursor(0);
 			SetCursor(0);
-			DestroyIcon(mCursor);
+			DestroyIcon(mCursor.data->cursor);
 			mUsingCustom = false;
 			mUsingCustom = false;
 		}
 		}
 
 
 		switch(type)
 		switch(type)
 		{
 		{
 		case CursorType::Arrow:
 		case CursorType::Arrow:
-			mCursor = LoadCursor(0, IDC_ARROW);
+			mCursor.data->cursor = LoadCursor(0, IDC_ARROW);
 			break;
 			break;
 		case CursorType::Wait:
 		case CursorType::Wait:
-			mCursor = LoadCursor(0, IDC_WAIT);
+			mCursor.data->cursor = LoadCursor(0, IDC_WAIT);
 			break;
 			break;
 		case CursorType::IBeam:
 		case CursorType::IBeam:
-			mCursor = LoadCursor(0, IDC_IBEAM);
+			mCursor.data->cursor = LoadCursor(0, IDC_IBEAM);
 			break;
 			break;
 		case CursorType::Help:
 		case CursorType::Help:
-			mCursor = LoadCursor(0, IDC_HELP);
+			mCursor.data->cursor = LoadCursor(0, IDC_HELP);
 			break;
 			break;
 		case CursorType::Hand:
 		case CursorType::Hand:
-			mCursor = LoadCursor(0, IDC_HAND);
+			mCursor.data->cursor = LoadCursor(0, IDC_HAND);
 			break;
 			break;
 		case CursorType::SizeAll:
 		case CursorType::SizeAll:
-			mCursor = LoadCursor(0, IDC_SIZEALL);
+			mCursor.data->cursor = LoadCursor(0, IDC_SIZEALL);
 			break;
 			break;
 		case CursorType::SizeNESW:
 		case CursorType::SizeNESW:
-			mCursor = LoadCursor(0, IDC_SIZENESW);
+			mCursor.data->cursor = LoadCursor(0, IDC_SIZENESW);
 			break;
 			break;
 		case CursorType::SizeNS:
 		case CursorType::SizeNS:
-			mCursor = LoadCursor(0, IDC_SIZENS);
+			mCursor.data->cursor = LoadCursor(0, IDC_SIZENS);
 			break;
 			break;
 		case CursorType::SizeNWSE:
 		case CursorType::SizeNWSE:
-			mCursor = LoadCursor(0, IDC_SIZENWSE);
+			mCursor.data->cursor = LoadCursor(0, IDC_SIZENWSE);
 			break;
 			break;
 		case CursorType::SizeWE:
 		case CursorType::SizeWE:
-			mCursor = LoadCursor(0, IDC_SIZEWE);
+			mCursor.data->cursor = LoadCursor(0, IDC_SIZEWE);
 			break;
 			break;
 		}
 		}
 
 
@@ -171,7 +187,7 @@ namespace CamelotFramework
 		if(mUsingCustom)
 		if(mUsingCustom)
 		{
 		{
 			SetCursor(0);
 			SetCursor(0);
-			DestroyIcon(mCursor);
+			DestroyIcon(mCursor.data->cursor);
 		}
 		}
 
 
 		mUsingCustom = true;
 		mUsingCustom = true;
@@ -230,7 +246,7 @@ namespace CamelotFramework
 		iconinfo.hbmMask = hMonoBitmap;
 		iconinfo.hbmMask = hMonoBitmap;
 		iconinfo.hbmColor = hBitmap;
 		iconinfo.hbmColor = hBitmap;
 
 
-		mCursor = CreateIconIndirect(&iconinfo);
+		mCursor.data->cursor = CreateIconIndirect(&iconinfo);
 
 
 		DeleteObject(hBitmap);          
 		DeleteObject(hBitmap);          
 		DeleteObject(hMonoBitmap);
 		DeleteObject(hMonoBitmap);
@@ -241,66 +257,15 @@ namespace CamelotFramework
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 		primaryWindow->getCustomAttribute("WINDOW", &hwnd);
 
 
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
 		PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
+	}
 
 
+	void Cursor::_win32ShowCursor()
+	{
+		SetCursor(mCursor.data->cursor);
+	}
 
 
-		//HDC hDC = GetDC(NULL);
-		//HDC hAndMaskDC = CreateCompatibleDC(hDC); 
-		//HDC hXorMaskDC = CreateCompatibleDC(hDC); 
-
-		////Get the dimensions of the source bitmap
-		//HBITMAP hAndMaskBitmap  = CreateCompatibleBitmap(hDC, pixelData.getWidth(), pixelData.getHeight());
-		//HBITMAP hXorMaskBitmap  = CreateCompatibleBitmap(hDC, pixelData.getWidth(), pixelData.getHeight());
-
-		////Select the bitmaps to DC
-		//HBITMAP hOldAndMaskBitmap  = (HBITMAP)SelectObject(hAndMaskDC, hAndMaskBitmap);
-		//HBITMAP hOldXorMaskBitmap  = (HBITMAP)SelectObject(hXorMaskDC, hXorMaskBitmap);
-
-		////Scan each pixel of the souce bitmap and create the masks
-		//Color pixel;
-		//for(UINT32 x = 0; x < pixelData.getWidth(); ++x)
-		//{
-		//	for(UINT32 y = 0; y < pixelData.getHeight(); ++y)
-		//	{
-		//		pixel = pixelData.getColorAt(x, y);
-		//		DWORD pixel32 = pixel.getAsRGBA();
-
-		//		if(pixel.a < 1.0f)
-		//		{
-		//			SetPixel(hAndMaskDC, x, y, RGB(255,255,255));
-		//			/*SetPixel(hXorMaskDC, x, y, RGB(pixel32 & 0xFF, (pixel32 >> 8) & 0xFF, (pixel32 >> 16) & 0xFF));*/
-		//			SetPixel(hXorMaskDC, x, y, RGB(255,255,255));
-		//		}
-		//		else
-		//		{
-		//			SetPixel(hAndMaskDC, x, y, RGB(0,0,0));
-		//			//SetPixel(hXorMaskDC, x, y, RGB(pixel32 & 0xFF, (pixel32 >> 8) & 0xFF, (pixel32 >> 16) & 0xFF));
-		//			SetPixel(hXorMaskDC, x, y, RGB(255,255,255));
-		//		}
-		//	}
-		//}
-
-		//SelectObject(hAndMaskDC, hOldAndMaskBitmap);
-		//SelectObject(hXorMaskDC, hOldXorMaskBitmap);
-
-		//DeleteDC(hXorMaskDC);
-		//DeleteDC(hAndMaskDC);
-
-		//ReleaseDC(NULL, hDC);
-
-		//ICONINFO iconinfo = {0};
-		//iconinfo.fIcon = FALSE;
-		//iconinfo.xHotspot = (DWORD)hotSpot.x;
-		//iconinfo.yHotspot = (DWORD)hotSpot.y;
-		//iconinfo.hbmMask = hAndMaskBitmap;
-		//iconinfo.hbmColor = hXorMaskBitmap;
-
-		//mCursor = CreateIconIndirect(&iconinfo);
-
-		//// Make sure we notify the message loop to perform the actual cursor update
-		//RenderWindowPtr primaryWindow = gApplication().getPrimaryWindow();
-		//HWND hwnd;
-		//primaryWindow->getCustomAttribute("WINDOW", &hwnd);
-
-		//PostMessage(hwnd, WM_SETCURSOR, WPARAM(hwnd), (LPARAM)MAKELONG(HTCLIENT, WM_MOUSEMOVE));
+	void Cursor::_win32HideCursor()
+	{
+		SetCursor(nullptr);
 	}
 	}
 }
 }

+ 24 - 0
TODO.txt

@@ -28,6 +28,7 @@ IMMEDIATE:
   - Icon image
   - Icon image
   - Support for text color in GUIStyles
   - Support for text color in GUIStyles
  - I have disabled linear filtering because it doesn't look good on scale9grid textures. (Add another material so it works with stretched textures?)
  - I have disabled linear filtering because it doesn't look good on scale9grid textures. (Add another material so it works with stretched textures?)
+ - Enable alpha test so I don't render completely transparent pixels.
  - What happens when I don't set a texture for a state of a GUI element. Use a dummy white texture probably?
  - What happens when I don't set a texture for a state of a GUI element. Use a dummy white texture probably?
     - Make sure GUI system uses a dummy texture if one isn't available
     - Make sure GUI system uses a dummy texture if one isn't available
 	- SpriteTexture keeps a static reference to DUmmyTexture which I need to release before shutdown
 	- SpriteTexture keeps a static reference to DUmmyTexture which I need to release before shutdown
@@ -36,6 +37,29 @@ IMMEDIATE:
   - Add support for bold (and maybe italic) fonts in Font importer
   - Add support for bold (and maybe italic) fonts in Font importer
   - Add support to disable aliasing when importing font
   - Add support to disable aliasing when importing font
 
 
+Window needed systems:
+EditorWindowContainer
+ - TabbedTitleBar widget 
+   - contains minimize/maximize/close buttons
+   - contains window toggle buttons, and in between them invisible buttons that serve as drag drop points and for moving the window
+     - dragging the in-between button will cause the window to move
+     - droping another window will cause the window to be docked at that location
+     - dragging the window toggle button will cause the window to undock. (or if the window is already undocked and is the only one in the titlebar, it will cause the window to move)
+    - contains title bar background
+ - Window frame
+   - contains tiled window background
+   - contains scale9grid frame
+   - frame allows for resize
+   - frame changes color when window is in focus
+ - Contents
+   - Actual Editor Window with custom contents
+
+
+GUIDragManager
+ - GUI system sends startdrag/enddrag/drag events to all elements
+ - startDrag(void* userPtr) changes cursor
+ - releasing the cursor sends enddrag event and then the control can retrieve the user ptr
+
 -----------
 -----------
 
 
 I need to be able to provide smaller bounds used for UI input 
 I need to be able to provide smaller bounds used for UI input