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

Refactored C# GUI so it uses GUIPanels
More documentation
Timer refactor so it doesn't mess with thread affinities

Marko Pintera 12 лет назад
Родитель
Сommit
b47fd717dd
44 измененных файлов с 745 добавлено и 1239 удалено
  1. 11 0
      BansheeEditor/Include/BsEditorWidget.h
  2. 18 7
      BansheeEditor/Source/BsEditorWidget.cpp
  3. 1 0
      BansheeMono/Include/BsMonoClass.h
  4. 1 0
      BansheeMono/Include/BsMonoMethod.h
  5. 7 0
      BansheeMono/Source/BsMonoMethod.cpp
  6. 2 2
      CamelotCore/Source/CmWin32FolderMonitor.cpp
  7. 1 1
      CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp
  8. 1 1
      CamelotD3D9Renderer/Include/CmD3D9Texture.h
  9. 1 1
      CamelotD3D9Renderer/Source/CmD3D9RenderWindowManager.cpp
  10. 2 2
      CamelotD3D9Renderer/Source/CmD3D9Texture.cpp
  11. 1 1
      CamelotGLRenderer/Source/CmWin32GLSupport.cpp
  12. 1 1
      CamelotOISInput/Source/CmInputHandlerOIS.cpp
  13. 355 324
      CamelotUtility/Include/CmString.h
  14. 23 0
      CamelotUtility/Include/CmStringTable.h
  15. 33 4
      CamelotUtility/Include/CmTexAtlasGenerator.h
  16. 7 5
      CamelotUtility/Include/CmTime.h
  17. 0 31
      CamelotUtility/Include/CmTimer.h
  18. 0 79
      CamelotUtility/Include/GLX/CmTimerImp.h
  19. 0 78
      CamelotUtility/Include/OSX/CmTimerImp.h
  20. 34 78
      CamelotUtility/Include/Win32/CmTimerImp.h
  21. 0 79
      CamelotUtility/Source/GLX/CmTimer.cpp
  22. 0 79
      CamelotUtility/Source/OSX/CmTimer.cpp
  23. 44 166
      CamelotUtility/Source/Win32/CmTimer.cpp
  24. 9 18
      Inspector.txt
  25. 8 6
      MBansheeEditor/EditorWindow.cs
  26. 3 0
      MBansheeEngine/Component.cs
  27. 2 38
      MBansheeEngine/GUI/GUIArea.cs
  28. 2 2
      MBansheeEngine/GUI/GUIPanel.cs
  29. 1 1
      MBansheeEngine/SceneObject.cs
  30. 0 25
      SBansheeEditor/Include/BsScriptEditorGUI.h
  31. 16 1
      SBansheeEditor/Include/BsScriptEditorWindow.h
  32. 0 2
      SBansheeEditor/SBansheeEditor.vcxproj
  33. 0 6
      SBansheeEditor/SBansheeEditor.vcxproj.filters
  34. 0 60
      SBansheeEditor/Source/BsScriptEditorGUI.cpp
  35. 72 5
      SBansheeEditor/Source/BsScriptEditorWindow.cpp
  36. 1 0
      SBansheeEngine/Include/BsScriptComponent.h
  37. 1 1
      SBansheeEngine/Include/BsScriptEnginePrerequisites.h
  38. 12 16
      SBansheeEngine/Include/BsScriptGUIArea.h
  39. 0 34
      SBansheeEngine/Include/BsScriptGUIBase.h
  40. 2 2
      SBansheeEngine/SBansheeEngine.vcxproj
  41. 6 6
      SBansheeEngine/SBansheeEngine.vcxproj.filters
  42. 31 0
      SBansheeEngine/Source/BsScriptComponent.cpp
  43. 36 52
      SBansheeEngine/Source/BsScriptGUIArea.cpp
  44. 0 25
      SBansheeEngine/Source/BsScriptGUIBase.cpp

+ 11 - 0
BansheeEditor/Include/BsEditorWidget.h

@@ -12,6 +12,11 @@ namespace BansheeEditor
 		const CM::String& getName() const { return mName; }
 		const CM::HString& getDisplayName() const { return mDisplayName; }
 
+		CM::INT32 getX() const { return mX; }
+		CM::INT32 getY() const { return mY; }
+		CM::UINT32 getWidth() const { return mWidth; }
+		CM::UINT32 getHeight() const { return mHeight; }
+
 		void _setSize(CM::UINT32 width, CM::UINT32 height);
 		void _setPosition(CM::INT32 x, CM::INT32 y);
 		void _changeParent(EditorWidgetContainer* parent);
@@ -21,6 +26,10 @@ namespace BansheeEditor
 		void _enable();
 
 		void close();
+
+		boost::signal<void(CM::UINT32, CM::UINT32)> onResized;
+		boost::signal<void(CM::INT32, CM::INT32)> onMoved;
+		boost::signal<void(EditorWidgetContainer*)> onParentChanged;
 	protected:
 		friend class EditorWidgetManager;
 
@@ -30,6 +39,8 @@ namespace BansheeEditor
 		CM::String mName;
 		CM::HString mDisplayName;
 		EditorWidgetContainer* mParent;
+		CM::INT32 mX, mY;
+		CM::UINT32 mWidth, mHeight;
 		BS::GUIArea* mContent;
 
 		BS::GUIWidget& getParentWidget() const;

+ 18 - 7
BansheeEditor/Source/BsEditorWidget.cpp

@@ -15,7 +15,7 @@ using namespace BansheeEngine;
 namespace BansheeEditor
 {
 	EditorWidgetBase::EditorWidgetBase(const HString& displayName, const CM::String& name, EditorWidgetContainer& parentContainer)
-		:mDisplayName(displayName), mName(name), mParent(nullptr), mContent(nullptr)
+		:mDisplayName(displayName), mName(name), mParent(nullptr), mContent(nullptr), mX(0), mY(0), mWidth(0), mHeight(0)
 	{
 		parentContainer.add(*this);
 	}
@@ -38,18 +38,26 @@ namespace BansheeEditor
 
 	void EditorWidgetBase::_setPosition(INT32 x, INT32 y)
 	{
-		if(mContent == nullptr)
-			return;
+		mX = x;
+		mY = y;
 
-		mContent->setPosition(x, y);
+		if(mContent != nullptr)
+			mContent->setPosition(x, y);
+
+		if(!onMoved.empty())
+			onMoved(x, y);
 	}
 
 	void EditorWidgetBase::_setSize(UINT32 width, UINT32 height)
 	{
-		if(mContent == nullptr)
-			return;
+		mWidth = width;
+		mHeight = height;
+
+		if(mContent != nullptr)
+			mContent->setSize(width, height);
 
-		mContent->setSize(width, height);
+		if(!onResized.empty())
+			onResized(width, height);
 	}
 
 	// Note: Must not be virtual as parent container uses it in constructor
@@ -71,6 +79,9 @@ namespace BansheeEditor
 			}
 
 			mParent = parent;
+
+			if(!onParentChanged.empty())
+				onParentChanged(mParent);
 		}
 	}
 

+ 1 - 0
BansheeMono/Include/BsMonoClass.h

@@ -33,6 +33,7 @@ namespace BansheeEngine
 		const CM::String& getFullName() const { return mFullName; }
 
 		MonoMethod& getMethod(const CM::String& name, CM::UINT32 numParams = 0);
+
 		MonoField* getField(const CM::String& name) const;
 		MonoProperty& getProperty(const CM::String& name);
 		MonoObject* getAttribute(MonoClass* monoClass) const;

+ 1 - 0
BansheeMono/Include/BsMonoMethod.h

@@ -9,6 +9,7 @@ namespace BansheeEngine
 	{
 	public:
 		MonoObject* invoke(MonoObject* instance, void** params);
+		MonoObject* invokeVirtual(MonoObject* instance, void** params);
 
 		/**
 		 * @brief	Gets a thunk for this method. A thunk is a C++ like function

+ 7 - 0
BansheeMono/Source/BsMonoMethod.cpp

@@ -16,6 +16,13 @@ namespace BansheeEngine
 		return mono_runtime_invoke(mMethod, instance, params, nullptr);
 	}		
 
+	MonoObject* MonoMethod::invokeVirtual(MonoObject* instance, void** params)
+	{
+		::MonoMethod* virtualMethod = mono_object_get_virtual_method(instance, mMethod);
+
+		return mono_runtime_invoke(virtualMethod, instance, params, nullptr);
+	}		
+
 	void* MonoMethod::getThunk() const
 	{
 		return mThunk;

+ 2 - 2
CamelotCore/Source/CmWin32FolderMonitor.cpp

@@ -339,7 +339,7 @@ namespace CamelotFramework
 
 		if(dirHandle == INVALID_HANDLE_VALUE)
 		{
-			CM_EXCEPT(InternalErrorException, "Failed to open folder \"" + toString(folderPath) + "\" for monitoring. Error code: " + toString(GetLastError()));
+			CM_EXCEPT(InternalErrorException, "Failed to open folder \"" + toString(folderPath) + "\" for monitoring. Error code: " + toString((UINT64)GetLastError()));
 		}
 
 		DWORD filterFlags = 0;
@@ -377,7 +377,7 @@ namespace CamelotFramework
 		{
 			mPimpl->mFoldersToWatch.erase(mPimpl->mFoldersToWatch.end() - 1);
 			cm_delete(watchInfo);
-			CM_EXCEPT(InternalErrorException, "Failed to open completition port for folder monitoring. Error code: " + toString(GetLastError()));
+			CM_EXCEPT(InternalErrorException, "Failed to open completition port for folder monitoring. Error code: " + toString((UINT64)GetLastError()));
 		}
 
 		if(mPimpl->mWorkerThread == nullptr)

+ 1 - 1
CamelotD3D11RenderSystem/Source/CmD3D11RenderWindowManager.cpp

@@ -20,7 +20,7 @@ namespace CamelotFramework
 		{
 			HWND hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
 		}
 
 		// Create the window

+ 1 - 1
CamelotD3D9Renderer/Include/CmD3D9Texture.h

@@ -188,7 +188,7 @@ namespace CamelotFramework {
 		void createInternalResources(IDirect3DDevice9* d3d9Device);
 		/// internal method, set Texture class final texture protected attributes
 		void _setFinalAttributes(IDirect3DDevice9* d3d9Device, TextureResources* textureResources, 
-			unsigned long width, unsigned long height, unsigned long depth, PixelFormat format);
+			UINT32 width, UINT32 height, UINT32 depth, PixelFormat format);
 		/// internal method, return the best by hardware supported filter method
 		D3DTEXTUREFILTERTYPE _getBestFilterMethod(IDirect3DDevice9* d3d9Device);
 		/// internal method, return true if the device/texture combination can use dynamic textures

+ 1 - 1
CamelotD3D9Renderer/Source/CmD3D9RenderWindowManager.cpp

@@ -17,7 +17,7 @@ namespace CamelotFramework
 		{
 			HWND hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
 		}
 
 		D3D9RenderWindow* window = new (cm_alloc<D3D9RenderWindow, PoolAlloc>()) D3D9RenderWindow(desc, mRenderSystem->getInstanceHandle());

+ 2 - 2
CamelotD3D9Renderer/Source/CmD3D9Texture.cpp

@@ -772,8 +772,8 @@ namespace CamelotFramework
 	
 	void D3D9Texture::_setFinalAttributes(IDirect3DDevice9* d3d9Device, 
 		TextureResources* textureResources,
-		unsigned long width, unsigned long height, 
-        unsigned long depth, PixelFormat format)
+		UINT32 width, UINT32 height, 
+        UINT32 depth, PixelFormat format)
 	{ 
 		if(width != mWidth || height != mHeight || depth != mDepth)
 		{

+ 1 - 1
CamelotGLRenderer/Source/CmWin32GLSupport.cpp

@@ -61,7 +61,7 @@ namespace CamelotFramework
 		{
 			HWND hWnd;
 			parentWindow->getCustomAttribute("WINDOW", &hWnd);
-			desc.platformSpecific["parentWindowHandle"] = toString((unsigned long)hWnd);
+			desc.platformSpecific["parentWindowHandle"] = toString((UINT64)hWnd);
 		}
 
 		Win32Window* window = new (cm_alloc<Win32Window, PoolAlloc>()) Win32Window(desc, *this);

+ 1 - 1
CamelotOISInput/Source/CmInputHandlerOIS.cpp

@@ -70,7 +70,7 @@ namespace CamelotFramework
 		unsigned long long hWnd;
 		win.getCustomAttribute("WINDOW", &hWnd);
 
-		std::string normalString = toString((unsigned long)hWnd).c_str();
+		std::string normalString = toString((UINT64)hWnd).c_str();
 		mKeyboard->setCaptureContext(normalString);
 		mMouse->setCaptureContext(normalString);
 	}

+ 355 - 324
CamelotUtility/Include/CmString.h

@@ -1,225 +1,201 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #pragma once
 
 #include "CmPrerequisitesUtil.h"
 
 namespace CamelotFramework 
 {
+	/**
+	 * @brief	Basic string that uses Banshee memory allocators.
+	 */
 	template <typename T>
 	struct BasicString 
 	{ 
 		typedef typename std::basic_string<T, std::char_traits<T>, StdAlloc<T>> type; 
 	}; 
 
+	/**
+	 * @brief	Basic string stream that uses Banshee memory allocators.
+	 */
 	template <typename T>
 	struct BasicStringStream
 	{ 
 		typedef typename std::basic_stringstream<T, std::char_traits<T>, StdAlloc<T>> type; 
 	}; 
 
+	/**
+	 * @brief	Wide string used primarily for handling Unicode text.
+	 */
 	typedef BasicString<wchar_t>::type WString;
+
+	/**
+	 * @brief	Narrow string used primarily for handling ASCII text.
+	 */
 	typedef BasicString<char>::type String;
 
+	/**
+	 * @brief	Wide string stream used for primarily for constructing
+	 * 			strings consisting of Unicode text.
+	 */
 	typedef BasicStringStream<wchar_t>::type WStringStream;
-	typedef BasicStringStream<char>::type StringStream;
 
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup General
-	*  @{
-	*/
+	/**
+	 * @brief	Wide string stream used for primarily for constructing
+	 * 			strings consisting of ASCII text.
+	 */
+	typedef BasicStringStream<char>::type StringStream;
 
-    /** Utility class for manipulating Strings.  */
+    /**
+     * @brief	Utility class for manipulating Strings.
+     */
     class CM_UTILITY_EXPORT StringUtil
     {
 	public:
-        /** Removes any whitespace characters, be it standard space or
-            TABs and so on.
-            @remarks
-                The user may specify wether they want to trim only the
-                beginning or the end of the String ( the default action is
-                to trim both).
-        */
+        /**
+         * @brief	Removes any whitespace characters from beginning or end of the string.
+         */
         static void trim(String& str, bool left = true, bool right = true);
 
-        /** Removes any whitespace characters, be it standard space or
-            TABs and so on.
-            @remarks
-                The user may specify wether they want to trim only the
-                beginning or the end of the String ( the default action is
-                to trim both).
-        */
+        /**
+         * @copydoc StringUtil::trim(String&, bool, bool)
+         */
         static void trim(WString& str, bool left = true, bool right = true);
 
-        /** Removes specified characters.
-            @remarks
-                The user may specify wether they want to trim only the
-                beginning or the end of the String ( the default action is
-                to trim both).
-        */
+        /**
+         * @brief	Removes specified characters from beginning or end of the string.
+         */
         static void trim(String& str, const String& delims, bool left = true, bool right = true);
 
-        /** Removes specified characters.
-            @remarks
-                The user may specify wether they want to trim only the
-                beginning or the end of the String ( the default action is
-                to trim both).
-        */
+		/**
+         * @copydoc StringUtil::trim(String&, const String&, bool, bool)
+         */
         static void trim(WString& str, const WString& delims, bool left = true, bool right = true);
 
-        /** Returns a StringVector that contains all the substrings delimited
-            by the characters in the passed <code>delims</code> argument.
-            @param
-                delims A list of delimiter characters to split by
-            @param
-                maxSplits The maximum number of splits to perform (0 for unlimited splits). If this
-                parameters is > 0, the splitting process will stop after this many splits, left to right.
-        */
+		/**
+		 * @brief	Returns a vector of strings containing all the substrings delimited
+		 * 			by the provided delimiter characters.
+		 *
+		 * @param	str		 	The string to split.
+		 * @param	delims   	(optional) Delimiter characters to split the string by. They will not
+		 * 						be included in resulting substrings.
+		 * @param	maxSplits	(optional) The maximum number of splits to perform (0 for unlimited splits). If this
+		 *						parameters is > 0, the splitting process will stop after this many splits, left to right.
+		 */
 		static Vector<String>::type split(const String& str, const String& delims = "\t\n ", unsigned int maxSplits = 0);
 
-		/** Returns a StringVector that contains all the substrings delimited
-            by the characters in the passed <code>delims</code> argument.
-            @param
-                delims A list of delimiter characters to split by
-            @param
-                maxSplits The maximum number of splits to perform (0 for unlimited splits). If this
-                parameters is > 0, the splitting process will stop after this many splits, left to right.
-        */
+		/**
+		 * @copydoc	StringUtil::split(const String&, const String&, unsigned int)
+		 */
 		static Vector<WString>::type split(const WString& str, const WString& delims = L"\t\n ", unsigned int maxSplits = 0);
 
-		/** Returns a StringVector that contains all the substrings delimited
-            by the characters in the passed <code>delims</code> argument, 
-			or in the <code>doubleDelims</code> argument, which is used to include (normal) 
-			delimeters in the tokenised string. For example, "strings like this".
-            @param
-                delims A list of delimiter characters to split by
-			@param
-                delims A list of double delimeters characters to tokenise by
-            @param
-                maxSplits The maximum number of splits to perform (0 for unlimited splits). If this
-                parameters is > 0, the splitting process will stop after this many splits, left to right.
-        */
+		/**
+		 * @brief	Returns a vector of strings containing all the substrings delimited
+		 *			by the provided delimiter characters, or the double delimiters used for including
+		 *			normal delimiter characters in the tokenized string. 
+		 *
+		 * @param	str		 	The string to split.
+		 * @param	delims   	(optional) Delimiter characters to split the string by. They will not
+		 * 						be included in resulting substrings.
+		 * @params	doubleDelims (optional) Delimiter character you may use to surround other normal delimiters, in order
+		 * 						to include them in the tokensized string.
+		 * @param	maxSplits	(optional) The maximum number of splits to perform (0 for unlimited splits). If this
+		 *						parameters is > 0, the splitting process will stop after this many splits, left to right.
+		 */
 		static Vector<String>::type tokenise(const String& str, const String& delims = "\t\n ", const String& doubleDelims = "\"", unsigned int maxSplits = 0);
 
-		/** Returns a StringVector that contains all the substrings delimited
-            by the characters in the passed <code>delims</code> argument, 
-			or in the <code>doubleDelims</code> argument, which is used to include (normal) 
-			delimeters in the tokenised string. For example, "strings like this".
-            @param
-                delims A list of delimiter characters to split by
-			@param
-                delims A list of double delimeters characters to tokenise by
-            @param
-                maxSplits The maximum number of splits to perform (0 for unlimited splits). If this
-                parameters is > 0, the splitting process will stop after this many splits, left to right.
-        */
+		/**
+		 * @copydoc	StringUtil::tokenise(const String&, const String&, const String&, unsigned int)
+		 */
 		static Vector<WString>::type tokenise(const WString& str, const WString& delims = L"\t\n ", const WString& doubleDelims = L"\"", unsigned int maxSplits = 0);
 
-		/** Lower-cases all the characters in the string.
-        */
+        /**
+         * @brief	Converts all the characters in the string to lower case.
+         */
         static void toLowerCase(String& str);
 
-		/** Lower-cases all the characters in the string.
-        */
+        /**
+         * @brief	Converts all the characters in the string to lower case.
+         */
         static void toLowerCase(WString& str);
 
-        /** Upper-cases all the characters in the string.
-        */
+        /**
+         * @brief	Converts all the characters in the string to upper case.
+         */
         static void toUpperCase(String& str);
 
-        /** Upper-cases all the characters in the string.
-        */
+        /**
+         * @brief	Converts all the characters in the string to upper case.
+         */
         static void toUpperCase(WString& str);
 
-        /** Returns whether the string begins with the pattern passed in.
-        @param pattern The pattern to compare with.
-        @param lowerCase If true, the start of the string will be lower cased before
-            comparison, pattern should also be in lower case.
-        */
+        /**
+         * @brief	Returns whether the string begins with the pattern passed in.
+         *
+         * @param	str		 	String to compare.
+         * @param	pattern		Pattern to compare with.
+		 * @param	lowerCase	(optional) If true, the start of the string will be lower cased before
+		 *						comparison, and the pattern should also be in lower case.
+         */
         static bool startsWith(const String& str, const String& pattern, bool lowerCase = true);
 
-        /** Returns whether the string begins with the pattern passed in.
-        @param pattern The pattern to compare with.
-        @param lowerCase If true, the start of the string will be lower cased before
-            comparison, pattern should also be in lower case.
-        */
+        /**
+         * @copydoc startsWidth(const String&, const String&, bool)
+         */
         static bool startsWith(const WString& str, const WString& pattern, bool lowerCase = true);
 
-        /** Returns whether the string ends with the pattern passed in.
-        @param pattern The pattern to compare with.
-        @param lowerCase If true, the end of the string will be lower cased before
-            comparison, pattern should also be in lower case.
-        */
+        /**
+         * @brief	Returns whether the string end with the pattern passed in.
+         *
+         * @param	str		 	String to compare.
+         * @param	pattern		Pattern to compare with.
+		 * @param	lowerCase	(optional) If true, the start of the string will be lower cased before
+		 *						comparison, and the pattern should also be in lower case.
+         */
         static bool endsWith(const String& str, const String& pattern, bool lowerCase = true);
 
-        /** Returns whether the string ends with the pattern passed in.
-        @param pattern The pattern to compare with.
-        @param lowerCase If true, the end of the string will be lower cased before
-            comparison, pattern should also be in lower case.
-        */
+        /**
+         * @copydoc endsWith(const String&, const String&, bool)
+         */
         static bool endsWith(const WString& str, const WString& pattern, bool lowerCase = true);
 
-        /** Simple pattern-matching routine allowing a wildcard pattern.
-        @param str String to test
-        @param pattern Pattern to match against; can include simple '*' wildcards
-        @param caseSensitive Whether the match is case sensitive or not
-        */
+        /**
+         * @brief	Returns true if the string matches the provided pattern. Pattern may use
+         * 			a "*" wildcard for matching any characters.
+         *
+         * @param	str			 	The string to test.
+         * @param	pattern		 	Patterns to look for.
+         * @param	caseSensitive	(optional) Should the match be case sensitive or not.
+         */
         static bool match(const String& str, const String& pattern, bool caseSensitive = true);
 
-		/** Simple pattern-matching routine allowing a wildcard pattern.
-        @param str String to test
-        @param pattern Pattern to match against; can include simple '*' wildcards
-        @param caseSensitive Whether the match is case sensitive or not
-        */
+		/**
+         * @copydoc match(const String&, const String&, bool)
+         */
         static bool match(const WString& str, const WString& pattern, bool caseSensitive = true);
 
-		/** Replace all instances of a sub-string with a another sub-string.
-		@param source Source string
-		@param replaceWhat Sub-string to find and replace
-		@param replaceWithWhat Sub-string to replace with (the new sub-string)
-		@returns An updated string with the sub-string replaced
-		*/
+		/**
+		 * @brief	 Replace all instances of a substring with a another substring.
+		 *
+		 * @param	source		   	String to search.
+		 * @param	replaceWhat	   	Substring to find and replace
+		 * @param	replaceWithWhat	Substring to replace with (the new sub-string)
+		 *
+		 * @return	An updated string with the substrings replaced.
+		 */
 		static const String replaceAll(const String& source, const String& replaceWhat, const String& replaceWithWhat);
 
-		/** Replace all instances of a sub-string with a another sub-string.
-		@param source Source string
-		@param replaceWhat Sub-string to find and replace
-		@param replaceWithWhat Sub-string to replace with (the new sub-string)
-		@returns An updated string with the sub-string replaced
-		*/
+		/**
+         * @copydoc match(const String&, const String&, const String&)
+         */
 		static const WString replaceAll(const WString& source, const WString& replaceWhat, const WString& replaceWithWhat);
 
-        /// Constant blank string, useful for returning by ref where local does not exist
+		/**
+		 * @brief	Constant blank string, useful for returning by ref where local does not exist.
+		 */
         static const String BLANK;
 
-		/// Constant blank string, useful for returning by ref where local does not exist
+		/**
+		 * @brief	Constant blank wide string, useful for returning by ref where local does not exist.
+		 */
 		static const WString WBLANK;
 
 	private:
@@ -447,115 +423,128 @@ namespace CamelotFramework
 		}
     };
 
-
 	/**
-	* @brief	Converts a narrow string to a wide string.
-	*/
+	 * @brief	Converts a narrow string to a wide string.
+	 */
 	CM_UTILITY_EXPORT WString toWString(const String& source);
 
-	/** Converts a float to a WString. */
+	/**
+	 * @brief	Converts a float to a string.
+	 */
     CM_UTILITY_EXPORT WString toWString(float val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts a double to a WString. */
+	/**
+	 * @brief	Converts a double to a string.
+	 */
 	CM_UTILITY_EXPORT WString toWString(double val, unsigned short precision = 6, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a Radian to a WString. */
+	/**
+	 * @brief	Converts a Radian to a string.
+	 */
     CM_UTILITY_EXPORT WString toWString(Radian val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a Degree to a WString. */
+	/**
+	 * @brief	Converts a Degree to a string.
+	 */
     CM_UTILITY_EXPORT WString toWString(Degree val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts an int to a WString. */
+	/**
+	 * @brief	Converts an int to a string.
+	 */
     CM_UTILITY_EXPORT WString toWString(int val, unsigned short width = 0, 
         char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts an unsigned int to a WString. */
+	/**
+	 * @brief	Converts an unsigned int to a string.
+	 */
     CM_UTILITY_EXPORT WString toWString(unsigned int val, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts a long to a WString. */
-	CM_UTILITY_EXPORT WString toWString(long val, 
-		unsigned short width = 0, char fill = ' ', 
-		std::ios::fmtflags flags = std::ios::fmtflags(0) );
-
-    /** Converts an unsigned long to a WString. */
-    CM_UTILITY_EXPORT WString toWString(unsigned long val, 
-        unsigned short width = 0, char fill = ' ', 
-        std::ios::fmtflags flags = std::ios::fmtflags(0) );
-
-	/** Converts an INT64 to a WString. */
+	/**
+	 * @brief	Converts an 64bit integer to a string.
+	 */
 	CM_UTILITY_EXPORT WString toWString(INT64 val, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts an UINT64 to a WString. */
+	/**
+	 * @brief	Converts an 64bit unsigned to a string.
+	 */
 	CM_UTILITY_EXPORT WString toWString(UINT64 val, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a boolean to a WString. 
-    @param yesNo If set to true, result is 'yes' or 'no' instead of 'true' or 'false'
-    */
+    /**
+     * @brief	Converts a boolean to a string.
+     *
+     * @param	val  	Value to convert.
+     * @param	yesNo	(optional) If set to true, result is "yes" or "no" instead of "true" or "false".
+     */
     CM_UTILITY_EXPORT WString toWString(bool val, bool yesNo = false);
 
-	/** Converts a Vector2 to a WString. 
-    @remarks
-        Format is "x y" (i.e. 2x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 2 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y".
+     */
     CM_UTILITY_EXPORT WString toWString(const Vector2& val);
 
-    /** Converts a Vector3 to a WString. 
-    @remarks
-        Format is "x y z" (i.e. 3x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 3 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y z".
+     */
     CM_UTILITY_EXPORT WString toWString(const Vector3& val);
 
-	/** Converts a Vector4 to a WString. 
-    @remarks
-        Format is "x y z w" (i.e. 4x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 4 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y z w".
+     */
     CM_UTILITY_EXPORT WString toWString(const Vector4& val);
 
-    /** Converts a Matrix3 to a WString. 
-    @remarks
-        Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc.
-    */
+    /**
+     * @brief	Converts a 3x3 matrix to a string.
+     * 			
+	 * @note	Format is "00 01 02 10 11 12 20 21 22".
+     */
     CM_UTILITY_EXPORT WString toWString(const Matrix3& val);
 
-    /** Converts a Matrix4 to a WString. 
-    @remarks
-        Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where 
-        '01' means row 0 column 1 etc.
-    */
+    /**
+     * @brief	Converts a 4x4 matrix to a string.
+     * 			
+	 * @note	Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33".
+     */
     CM_UTILITY_EXPORT WString toWString(const Matrix4& val);
 
-    /** Converts a Quaternion to a WString. 
-    @remarks
-        Format is "w x y z" (i.e. 4x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a Quaternion to a string.
+     * 			
+	 * @note	Format is "w x y z".
+     */
     CM_UTILITY_EXPORT WString toWString(const Quaternion& val);
 
-    /** Converts a ColourValue to a WString. 
-    @remarks
-        Format is "r g b a" (i.e. 4x float values, space delimited). 
-    */
+    /**
+     * @brief	Converts a color to a string.
+     * 			
+	 * @note	Format is "r g b a".
+     */
     CM_UTILITY_EXPORT WString toWString(const Color& val);
 
-    /** Converts a StringVector to a WString.
-    @remarks
-        Strings must not contain spaces since space is used as a delimiter in
-        the output.
-    */
+    /**
+     * @brief	Converts a vector of strings into a single string where the substrings are
+	 *			delimited by spaces.
+     */
     CM_UTILITY_EXPORT WString toWString(const Vector<CamelotFramework::WString>::type& val);
 
 	/**
@@ -563,197 +552,231 @@ namespace CamelotFramework
 	*/
 	CM_UTILITY_EXPORT String toString(const WString& source);
 
-	/** Converts a float to a String. */
+	/**
+	 * @brief	Converts a float to a string.
+	 */
     CM_UTILITY_EXPORT String toString(float val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts a double to a String. */
+	/**
+	 * @brief	Converts a double to a string.
+	 */
 	CM_UTILITY_EXPORT String toString(double val, unsigned short precision = 6, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a Radian to a String. */
+	/**
+	 * @brief	Converts a Radian to a string.
+	 */
     CM_UTILITY_EXPORT String toString(Radian val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a Degree to a String. */
+	/**
+	 * @brief	Converts a Degree to a string.
+	 */
     CM_UTILITY_EXPORT String toString(Degree val, unsigned short precision = 6, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts an int to a String. */
+	/**
+	 * @brief	Converts an int to a string.
+	 */
     CM_UTILITY_EXPORT String toString(int val, unsigned short width = 0, 
         char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts an unsigned int to a String. */
+	/**
+	 * @brief	Converts an unsigned int to a string.
+	 */
     CM_UTILITY_EXPORT String toString(unsigned int val, 
         unsigned short width = 0, char fill = ' ', 
         std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts a long to a String. */
-	CM_UTILITY_EXPORT String toString(long val, 
-		unsigned short width = 0, char fill = ' ', 
-		std::ios::fmtflags flags = std::ios::fmtflags(0) );
-
-    /** Converts an unsigned long to a String. */
-    CM_UTILITY_EXPORT String toString(unsigned long val, 
-        unsigned short width = 0, char fill = ' ', 
-        std::ios::fmtflags flags = std::ios::fmtflags(0) );
-
-	/** Converts an unsigned long to a String. */
+	/**
+	 * @brief	Converts a 64bit int to a string.
+	 */
 	CM_UTILITY_EXPORT String toString(INT64 val, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-	/** Converts an unsigned long to a String. */
+	/**
+	 * @brief	Converts an 64bit unsigned int to a string.
+	 */
 	CM_UTILITY_EXPORT String toString(UINT64 val, 
 		unsigned short width = 0, char fill = ' ', 
 		std::ios::fmtflags flags = std::ios::fmtflags(0) );
 
-    /** Converts a boolean to a String. 
-    @param yesNo If set to true, result is 'yes' or 'no' instead of 'true' or 'false'
-    */
+    /**
+     * @brief	Converts a boolean to a string.
+     *
+     * @param	val  	true to value.
+     * @param	yesNo	(optional) If set to true, result is "yes" or "no" instead of "true" or "false".
+     */
     CM_UTILITY_EXPORT String toString(bool val, bool yesNo = false);
 
-	/** Converts a Vector2 to a String. 
-    @remarks
-        Format is "x y" (i.e. 2x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 2 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y".
+     */
     CM_UTILITY_EXPORT String toString(const Vector2& val);
 
-    /** Converts a Vector3 to a String. 
-    @remarks
-        Format is "x y z" (i.e. 3x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 3 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y z".
+     */
     CM_UTILITY_EXPORT String toString(const Vector3& val);
 
-	/** Converts a Vector4 to a String. 
-    @remarks
-        Format is "x y z w" (i.e. 4x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a 4 dimensional vector to a string.
+     * 			
+	 * @note	Format is "x y z w".
+     */
     CM_UTILITY_EXPORT String toString(const Vector4& val);
 
-    /** Converts a Matrix3 to a String. 
-    @remarks
-        Format is "00 01 02 10 11 12 20 21 22" where '01' means row 0 column 1 etc.
-    */
+    /**
+     * @brief	Converts a 3x3 matrix to a string.
+     * 			
+	 * @note	Format is "00 01 02 10 11 12 20 21 22".
+     */
     CM_UTILITY_EXPORT String toString(const Matrix3& val);
 
-    /** Converts a Matrix4 to a String. 
-    @remarks
-        Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33" where 
-        '01' means row 0 column 1 etc.
-    */
+    /**
+     * @brief	Converts a 4x4 matrix to a string.
+     * 			
+	 * @note	Format is "00 01 02 03 10 11 12 13 20 21 22 23 30 31 32 33".
+     */
     CM_UTILITY_EXPORT String toString(const Matrix4& val);
 
-    /** Converts a Quaternion to a String. 
-    @remarks
-        Format is "w x y z" (i.e. 4x float values, space delimited)
-    */
+    /**
+     * @brief	Converts a Quaternion to a string.
+     * 			
+	 * @note	Format is "w x y z".
+     */
     CM_UTILITY_EXPORT String toString(const Quaternion& val);
 
-    /** Converts a ColourValue to a String. 
-    @remarks
-        Format is "r g b a" (i.e. 4x float values, space delimited). 
-    */
+    /**
+     * @brief	Converts a color to a string.
+     * 			
+	 * @note	Format is "r g b a".
+     */
     CM_UTILITY_EXPORT String toString(const Color& val);
 
-    /** Converts a StringVector to a string.
-    @remarks
-        Strings must not contain spaces since space is used as a delimiter in
-        the output.
-    */
+    /**
+     * @brief	Converts a vector of strings into a single string where the substrings are
+	 *			delimited by spaces.
+     */
     CM_UTILITY_EXPORT String toString(const Vector<CamelotFramework::String>::type& val);
 
-    /** Converts a String to a float. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the float version of the String.
-    */
+    /**
+     * @brief	Converts a String to a float.
+     *
+     * @note	0.0f if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT float parseFloat(const String& val, float defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a String to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT int parseInt(const String& val, int defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a String to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT unsigned int parseUnsignedInt(const String& val, unsigned int defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a String to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT long parseLong(const String& val, long defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a String to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT unsigned long parseUnsignedLong(const String& val, unsigned long defaultValue = 0);
 
-    /** Converts a String to a boolean. 
-    @remarks
-        Returns true if case-insensitive match of the start of the string
-		matches "true", "yes" or "1", false otherwise.
-    */
+    /**
+     * @brief	Converts a String to a boolean.
+     *
+	 * @note	Returns true if case-insensitive match of the start of the string
+	 *			matches "true", "yes" or "1", false otherwise.
+     */
     CM_UTILITY_EXPORT bool parseBool(const String& val, bool defaultValue = 0);
 
-    /** Checks the String is a valid number value. */
+    /**
+     * @brief	Checks the String is a valid number value.
+     */
     CM_UTILITY_EXPORT bool isNumber(const String& val);
 
-/** Converts a String to a float. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the float version of the String.
-    */
+    /**
+     * @brief	Converts a WString to a float.
+     *
+     * @note	0.0f if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT float parseFloat(const WString& val, float defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a WString to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT int parseInt(const WString& val, int defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a WString to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT unsigned int parseUnsignedInt(const WString& val, unsigned int defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a WString to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT long parseLong(const WString& val, long defaultValue = 0);
 
-    /** Converts a String to a whole number. 
-    @returns
-        0.0 if the value could not be parsed, otherwise the numeric version of the String.
-    */
+    /**
+     * @brief	Converts a WString to a whole number.
+     *
+     * @note	0 if the value could not be parsed, otherwise the numeric version of the string.
+     */
     CM_UTILITY_EXPORT unsigned long parseUnsignedLong(const WString& val, unsigned long defaultValue = 0);
 
-    /** Converts a String to a boolean. 
-    @remarks
-        Returns true if case-insensitive match of the start of the string
-		matches "true", "yes" or "1", false otherwise.
-    */
+    /**
+     * @brief	Converts a WString to a boolean.
+     *
+	 * @note	Returns true if case-insensitive match of the start of the string
+	 *			matches "true", "yes" or "1", false otherwise.
+     */
     CM_UTILITY_EXPORT bool parseBool(const WString& val, bool defaultValue = 0);
 
-    /** Checks the String is a valid number value. */
+    /**
+     * @brief	Checks the WString is a valid number value.
+     */
     CM_UTILITY_EXPORT bool isNumber(const WString& val);
 
-	/** @} */
-
+	/**
+	 * @brief	Helper method that throws an exception regarding a data overflow.
+	 */
 	void CM_UTILITY_EXPORT __string_throwDataOverflowException();
 
 	/**
-	 * @brief	Strings need to copy their data in a slightly more intricate way than just memcpy.
+	 * @brief	RTTIPlainType specialization for String that allows strings be serialized as
+	 * 			value types.
+	 * 			
+	 * @see		RTTIPlainType
 	 */
 	template<> struct RTTIPlainType<String>
 	{	
@@ -802,7 +825,10 @@ namespace CamelotFramework
 	}; 
 
 	/**
-	 * @brief	Strings need to copy their data in a slightly more intricate way than just memcpy.
+	 * @brief	RTTIPlainType specialization for WString that allows strings be serialized as
+	 * 			value types.
+	 * 			
+	 * @see		RTTIPlainType
 	 */
 	template<> struct RTTIPlainType<WString>
 	{	
@@ -852,9 +878,11 @@ namespace CamelotFramework
 			return (UINT32)dataSize;
 		}	
 	}; 
+}
 
-} // namespace CamelotFramework
-
+/**
+ * @brief	Hash value generator for SString.
+ */
 template<> 
 struct std::hash<CamelotFramework::String>
 {
@@ -867,6 +895,9 @@ struct std::hash<CamelotFramework::String>
 	}
 };
 
+/**
+ * @brief	Hash value generator for WString.
+ */
 template<> 
 struct std::hash<CamelotFramework::WString>
 {

+ 23 - 0
CamelotUtility/Include/CmStringTable.h

@@ -199,6 +199,10 @@ namespace CamelotFramework
 		Count // Number of entries
 	};
 
+	/**
+	 * @brief	Internal data used for representing a localized string instance.
+	 * 			e.g. a specific instance of a localized string using specific parameters.
+	 */
 	struct LocalizedStringData
 	{
 		struct Common
@@ -234,6 +238,10 @@ namespace CamelotFramework
 		void updateString(const WString& string);
 	};
 
+	/**
+	 * @brief	Class that handles string localization. Stores strings and their translations
+	 * 			in various languages, along with the ability to switch currently active language.
+	 */
 	class CM_UTILITY_EXPORT StringTable : public Module<StringTable>
 	{
 		// TODO - When editing string table I will need to ensure that all languages of the same string have the same number of parameters
@@ -246,10 +254,25 @@ namespace CamelotFramework
 		StringTable();
 		~StringTable();
 
+		/**
+		 * @brief	Gets the currently active language.
+		 */
 		Language getActiveLanguage() const { return mActiveLanguage; }
+
+		/**
+		 * @brief	Changes the currently active language.
+		 * 			This will update any localized string instances.
+		 */
 		void setActiveLanguage(Language language);
 
+		/**
+		 * @brief	Adds or modifies string translation for the specified language.
+		 */
 		void setString(const WString& identifier, Language language, const WString& string);
+
+		/**
+		 * @brief	Removes the string described by identifier, from all languages.
+		 */
 		void removeString(const WString& identifier);
 
 		/**

+ 33 - 4
CamelotUtility/Include/CmTexAtlasGenerator.h

@@ -9,9 +9,9 @@ namespace CamelotFramework
 	 * @brief	Represents a single element used as in input to
 	 * 			TexAtlasGenerator. Usually represents a single texture.
 	 * 			
-	 * @note	input is required to be filled in before passing it to
-	 * 			TexAtlasGenerator
-	 * 			output will be filled in by TexAtlasGenerator after a call to
+	 * @note	"input" is required to be filled in before passing it to
+	 * 			TexAtlasGenerator.
+	 * 			"output" will be filled in by TexAtlasGenerator after a call to
 	 * 			TexAtlasGenerator::createAtlasLayout
 	 */
 	struct TexAtlasElementDesc
@@ -38,11 +38,14 @@ namespace CamelotFramework
 
 	class TexAtlasNode;
 
+	/**
+	 * @brief	Organizes a set of textures into a single larger texture (an atlas) by minimizing empty space.
+	 */
 	class CM_UTILITY_EXPORT TexAtlasGenerator
 	{
 	public:
 		/**
-		 * @brief	Constructor.
+		 * @brief	Constructs a new texture atlas generator with the provided parameters.
 		 *
 		 * @param	square			(optional) Should the returned texture always be square. (width == height)
 		 * 							This option is only used if "fixedSize" parameter is set to false.
@@ -75,9 +78,35 @@ namespace CamelotFramework
 		UINT32 mMaxTexWidth;
 		UINT32 mMaxTexHeight;
 
+		/**
+		 * @brief	Organize all of the provide elements and place them into minimum number of pages with the specified width and height.
+		 * 			
+		 * 			Caller must ensure "elements" array has the page indexes reset to -1 before calling, otherwise it will be assumed
+		 * 			those elements already have assigned pages.
+		 * 			
+		 *			Using "startPage" parameter you may add an offset to the generated page indexes.
+		 *
+		 * @return	Number of pages generated.
+		 */
 		int generatePagesForSize(Vector<TexAtlasElementDesc>::type& elements, UINT32 width, UINT32 height, UINT32 startPage = 0) const;
+
+		/**
+		 * @brief	Finds the largest element without a page that fits within the provided node.
+		 *
+		 * @return	Array index of the found page, or -1 if all textures have a page.
+		 */
 		int addLargestTextureWithoutPageThatFits(Vector<TexAtlasElementDesc>::type& elements, TexAtlasNode& node) const;
+
+		/**
+		 * @brief	Scan all of the provided elements and find the largest one that still doesn't have a page assigned.
+		 * 			
+		 * @return	Array index of the found page, or -1 if all textures have a page.
+		 */
 		int findLargestTextureWithoutPage(const Vector<TexAtlasElementDesc>::type& elements) const;
+
+		/**
+		 * @brief	Sorts all the texture elements so that larget elements come first.
+		 */
 		void sortBySize(Vector<TexAtlasElementDesc>::type& elements) const;
 	};
 }

+ 7 - 5
CamelotUtility/Include/CmTime.h

@@ -6,7 +6,9 @@
 namespace CamelotFramework
 {
 	/**
-	 * @brief	Manages all time related functionality
+	 * @brief	Manages all time related functionality.
+	 * 			
+	 * @note	Not thread safe.
 	 */
 	class CM_UTILITY_EXPORT Time : public Module<Time>
 	{
@@ -72,12 +74,12 @@ namespace CamelotFramework
 		void update();
 
 	private:
-		float mFrameDelta; // Frame delta in seconds
-		float mTimeSinceStart; // Time since start in seconds
+		float mFrameDelta; /**< Frame delta in seconds */
+		float mTimeSinceStart; /**< Time since start in seconds */
 		UINT64 mTimeSinceStartMs;
 
-		UINT64 mAppStartTime; // Time the application started, in microseconds
-		unsigned long mLastFrameTime; // Time since last runOneFrame call, In microseconds
+		UINT64 mAppStartTime; /**< Time the application started, in microseconds */
+		unsigned long mLastFrameTime; /**< Time since last runOneFrame call, In microseconds */
 		unsigned long mCurrentFrame;
 
 		Timer* mTimer;

+ 0 - 31
CamelotUtility/Include/CmTimer.h

@@ -1,30 +1,3 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
 #pragma once
 
 #include "CmPrerequisitesUtil.h"
@@ -32,8 +5,4 @@ THE SOFTWARE.
 //Bring in the specific platform's header file
 #if CM_PLATFORM == CM_PLATFORM_WIN32
 # include "Win32/CmTimerImp.h"
-#elif (CM_PLATFORM == CM_PLATFORM_LINUX)
-# include "GLX/CmTimerImp.h"
-#elif CM_PLATFORM == CM_PLATFORM_APPLE
-# include "OSX/CmTimerImp.h"
 #endif

+ 0 - 79
CamelotUtility/Include/GLX/CmTimerImp.h

@@ -1,79 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#ifndef __GLXTimer_H__
-#define __GLXTimer_H__
-
-#include "../CmPrerequisitesUtil.h"
-
-namespace CamelotEngine
-{
-	/** Timer class */
-	class CM_UTILITY_EXPORT Timer
-	{
-	private:
-		struct timeval start;
-		clock_t zeroClock;
-	public:
-		Timer();
-		~Timer();
-
-		/** Method for setting a specific option of the Timer. These options are usually
-            specific for a certain implementation of the Timer class, and may (and probably
-            will) not exist across different implementations.  reset() must be called after
-			all setOption() calls.
-            @param
-                strKey The name of the option to set
-            @param
-                pValue A pointer to the value - the size should be calculated by the timer
-                based on the key
-            @return
-                On success, true is returned.
-            @par
-                On failure, false is returned.
-        */
-        bool setOption( const String& strKey, const void* pValue )
-        { (void)strKey; (void)pValue; return false; }
-
-		/** Resets timer */
-		void reset();
-
-		/** Returns milliseconds since initialisation or last reset */
-		unsigned long getMilliseconds();
-
-		/** Returns microseconds since initialisation or last reset */
-		unsigned long getMicroseconds();
-
-		/** Returns milliseconds since initialisation or last reset, only CPU time measured */	
-		unsigned long getMillisecondsCPU();
-
-		/** Returns microseconds since initialisation or last reset, only CPU time measured */	
-		unsigned long getMicrosecondsCPU();
-	};
-}
-#endif

+ 0 - 78
CamelotUtility/Include/OSX/CmTimerImp.h

@@ -1,78 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-
-#ifndef __OSXTimer_H__
-#define __OSXTimer_H__
-
-#include "../CmPrerequisitesUtil.h"
-
-namespace CamelotEngine
-{
-	/** Timer class */
-	class CM_UTILITY_EXPORT Timer
-	{
-	private:
-		struct timeval start;
-		clock_t zeroClock;
-	public:
-		Timer();
-		~Timer();
-
-		/** Method for setting a specific option of the Timer. These options are usually
-            specific for a certain implementation of the Timer class, and may (and probably
-            will) not exist across different implementations.  reset() must be called after
-			all setOption() calls.
-            @param
-                strKey The name of the option to set
-            @param
-                pValue A pointer to the value - the size should be calculated by the timer
-                based on the key
-            @return
-                On success, true is returned.
-            @par
-                On failure, false is returned.
-        */
-        bool setOption( const String& strKey, const void* pValue ) { return false; }
-
-		/** Resets timer */
-		void reset();
-
-		/** Returns milliseconds since initialisation or last reset */
-		unsigned long getMilliseconds();
-
-		/** Returns microseconds since initialisation or last reset */
-		unsigned long getMicroseconds();
-
-		/** Returns milliseconds since initialisation or last reset, only CPU time measured */	
-		unsigned long getMillisecondsCPU();
-
-		/** Returns microseconds since initialisation or last reset, only CPU time measured */	
-		unsigned long getMicrosecondsCPU();
-	};
-}
-#endif

+ 34 - 78
CamelotUtility/Include/Win32/CmTimerImp.h

@@ -1,32 +1,4 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#ifndef __Win32Timer_H__
-#define __Win32Timer_H__
+#pragma once
 
 #include "../CmPrerequisitesUtil.h"
 
@@ -34,70 +6,51 @@ THE SOFTWARE.
 #	define WIN32_LEAN_AND_MEAN
 #endif
 #if !defined(NOMINMAX) && defined(_MSC_VER)
-#	define NOMINMAX // required to stop windows.h messing up std::min
+#	define NOMINMAX // Required to stop windows.h messing up std::min
 #endif
 #include "windows.h"
 
 namespace CamelotFramework
 {
-	/** \addtogroup Core
-	*  @{
-	*/
-	/** \addtogroup General
-	*  @{
-	*/
-
+	/**
+	 * @brief	Timer class used for querying high precision timers.
+	 */
 	class CM_UTILITY_EXPORT Timer
     {
-    private:
-		clock_t mZeroClock;
-
-        DWORD mStartTick;
-		LONGLONG mLastTime;
-        LARGE_INTEGER mStartTime;
-        LARGE_INTEGER mFrequency;
-
-		DWORD_PTR mTimerMask;
     public:
-		/** Timer constructor.  MUST be called on same thread that calls getMilliseconds() */
+		/**
+		 * @brief	Construct the timer and start timing.
+		 */
 		Timer();
 		~Timer();
 
-		/** Method for setting a specific option of the Timer. These options are usually
-            specific for a certain implementation of the Timer class, and may (and probably
-            will) not exist across different implementations.  reset() must be called after
-			all setOption() calls.
-			@par
-			Current options supported are:
-			<ul><li>"QueryAffinityMask" (DWORD): Set the thread affinity mask to be used
-			to check the timer. If 'reset' has been called already this mask should
-			overlap with the process mask that was in force at that point, and should
-			be a power of two (a single core).</li></ul>
-            @param
-                strKey The name of the option to set
-            @param
-                pValue A pointer to the value - the size should be calculated by the timer
-                based on the key
-            @return
-                On success, true is returned.
-            @par
-                On failure, false is returned.
-        */
-        bool setOption( const String& strKey, const void* pValue );
-
-		/** Resets timer */
+		/**
+		 * @brief	Reset the timer to zero.
+		 */
 		void reset();
 
-		/** Returns milliseconds since initialisation or last reset */
+		/**
+		 * @brief	Returns time in milliseconds since timer was initialized or
+		 * 			last reset.
+		 */
 		unsigned long getMilliseconds();
 
-		/** Returns microseconds since initialisation or last reset */
+		/**
+		 * @brief	Returns time in microseconds since timer was initialized or
+		 * 			last reset.
+		 */
 		unsigned long getMicroseconds();
 
-		/** Returns milliseconds since initialisation or last reset, only CPU time measured */
+		/**
+		 * @brief	Returns time in milliseconds since timer was initialized or
+		 * 			last reset. Only CPU timer measured.
+		 */
 		unsigned long getMillisecondsCPU();
 
-		/** Returns microseconds since initialisation or last reset, only CPU time measured */
+		/**
+		 * @brief	Returns time in microseconds since timer was initialized or
+		 * 			last reset. Only CPU timer measured.
+		 */
 		unsigned long getMicrosecondsCPU();
 
 		/**
@@ -106,8 +59,11 @@ namespace CamelotFramework
 		 * @return	Time in milliseconds.
 		 */
 		unsigned long getStartMs() const;
+
+	private:
+		clock_t mZeroClock;
+
+		LARGE_INTEGER mStartTime;
+		LARGE_INTEGER mFrequency;
     };
-	/** @} */
-	/** @} */
-}
-#endif
+}

+ 0 - 79
CamelotUtility/Source/GLX/CmTimer.cpp

@@ -1,79 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmTimer.h"
-#include <sys/time.h>
-
-using namespace CamelotEngine;
-
-//--------------------------------------------------------------------------------//
-Timer::Timer()
-{
-	reset();
-}
-
-//--------------------------------------------------------------------------------//
-Timer::~Timer()
-{
-}
-
-//--------------------------------------------------------------------------------//
-void Timer::reset()
-{
-	zeroClock = clock();
-	gettimeofday(&start, NULL);
-}
-
-//--------------------------------------------------------------------------------//
-unsigned long Timer::getMilliseconds()
-{
-	struct timeval now;
-	gettimeofday(&now, NULL);
-	return (now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
-}
-
-//--------------------------------------------------------------------------------//
-unsigned long Timer::getMicroseconds()
-{
-	struct timeval now;
-	gettimeofday(&now, NULL);
-	return (now.tv_sec-start.tv_sec)*1000000+(now.tv_usec-start.tv_usec);
-}
-
-//-- Common Across All Timers ----------------------------------------------------//
-unsigned long Timer::getMillisecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)((float)(newClock-zeroClock) / ((float)CLOCKS_PER_SEC/1000.0)) ;
-}
-
-//-- Common Across All Timers ----------------------------------------------------//
-unsigned long Timer::getMicrosecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)((float)(newClock-zeroClock) / ((float)CLOCKS_PER_SEC/1000000.0)) ;
-}

+ 0 - 79
CamelotUtility/Source/OSX/CmTimer.cpp

@@ -1,79 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-(Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2011 Torus Knot Software Ltd
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include "CmTimer.h"
-#include <sys/time.h>
-
-using namespace CamelotEngine;
-
-//--------------------------------------------------------------------------------//
-Timer::Timer()
-{
-	reset();
-}
-
-//--------------------------------------------------------------------------------//
-Timer::~Timer()
-{
-}
-
-//--------------------------------------------------------------------------------//
-void Timer::reset()
-{
-	zeroClock = clock();
-	gettimeofday(&start, NULL);
-}
-
-//--------------------------------------------------------------------------------//
-unsigned long Timer::getMilliseconds()
-{
-	struct timeval now;
-	gettimeofday(&now, NULL);
-	return (now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
-}
-
-//--------------------------------------------------------------------------------//
-unsigned long Timer::getMicroseconds()
-{
-	struct timeval now;
-	gettimeofday(&now, NULL);
-	return (now.tv_sec-start.tv_sec)*1000000+(now.tv_usec-start.tv_usec);
-}
-
-//-- Common Across All Timers ----------------------------------------------------//
-unsigned long Timer::getMillisecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)((float)(newClock-zeroClock) / ((float)CLOCKS_PER_SEC/1000.0)) ;
-}
-
-//-- Common Across All Timers ----------------------------------------------------//
-unsigned long Timer::getMicrosecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)((float)(newClock-zeroClock) / ((float)CLOCKS_PER_SEC/1000000.0)) ;
-}

+ 44 - 166
CamelotUtility/Source/Win32/CmTimer.cpp

@@ -1,190 +1,68 @@
 #include "CmTimer.h"
 #include "CmBitwise.h"
 
-using namespace CamelotFramework;
-
-//-------------------------------------------------------------------------
-Timer::Timer()
-	: mTimerMask( 0 )
-{
-	reset();
-}
-
-//-------------------------------------------------------------------------
-Timer::~Timer()
+namespace CamelotFramework
 {
-}
-
-//-------------------------------------------------------------------------
-bool Timer::setOption( const String & key, const void * val )
-{
-	if ( key == "QueryAffinityMask" )
+	Timer::Timer()
 	{
-		// Telling timer what core to use for a timer read
-		DWORD newTimerMask = * static_cast < const DWORD * > ( val );
-
-		// Get the current process core mask
-		DWORD_PTR procMask;
-		DWORD_PTR sysMask;
-		GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
-
-		// If new mask is 0, then set to default behavior, otherwise check
-		// to make sure new timer core mask overlaps with process core mask
-		// and that new timer core mask is a power of 2 (i.e. a single core)
-		if( ( newTimerMask == 0 ) ||
-			( ( ( newTimerMask & procMask ) != 0 ) && Bitwise::isPO2( newTimerMask ) ) )
-		{
-			mTimerMask = newTimerMask;
-			return true;
-		}
+		reset();
 	}
 
-	return false;
-}
-
-//-------------------------------------------------------------------------
-void Timer::reset()
-{
-    // Get the current process core mask
-	DWORD_PTR procMask;
-	DWORD_PTR sysMask;
-	GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
-
-	// If procMask is 0, consider there is only one core available
-	// (using 0 as procMask will cause an infinite loop below)
-	if (procMask == 0)
-		procMask = 1;
-
-	// Find the lowest core that this process uses
-	if( mTimerMask == 0 )
+	Timer::~Timer()
 	{
-		mTimerMask = 1;
-		while( ( mTimerMask & procMask ) == 0 )
-		{
-			mTimerMask <<= 1;
-		}
 	}
 
-	HANDLE thread = GetCurrentThread();
-
-	// Set affinity to the first core
-	DWORD_PTR oldMask = SetThreadAffinityMask(thread, mTimerMask);
-
-	// Get the constant frequency
-	QueryPerformanceFrequency(&mFrequency);
-
-	// Query the timer
-	QueryPerformanceCounter(&mStartTime);
-	mStartTick = GetTickCount();
-
-	// Reset affinity
-	SetThreadAffinityMask(thread, oldMask);
-
-	mLastTime = 0;
-	mZeroClock = clock();
-}
-
-//-------------------------------------------------------------------------
-unsigned long Timer::getMilliseconds()
-{
-    LARGE_INTEGER curTime;
-
-	HANDLE thread = GetCurrentThread();
-
-	// Set affinity to the first core
-	DWORD_PTR oldMask = SetThreadAffinityMask(thread, mTimerMask);
+	void Timer::reset()
+	{
+		QueryPerformanceFrequency(&mFrequency);
+		QueryPerformanceCounter(&mStartTime);
 
-	// Query the timer
-	QueryPerformanceCounter(&curTime);
+		mZeroClock = clock();
+	}
 
-	// Reset affinity
-	SetThreadAffinityMask(thread, oldMask);
+	unsigned long Timer::getMilliseconds()
+	{
+		LARGE_INTEGER curTime;
+		QueryPerformanceCounter(&curTime);
 
-    LONGLONG newTime = curTime.QuadPart - mStartTime.QuadPart;
+		LONGLONG newTime = curTime.QuadPart - mStartTime.QuadPart;
     
-    // scale by 1000 for milliseconds
-    unsigned long newTicks = (unsigned long) (1000 * newTime / mFrequency.QuadPart);
+		// Scale by 1000 for milliseconds
+		unsigned long newTicks = (unsigned long) (1000 * newTime / mFrequency.QuadPart);
 
-    // detect and compensate for performance counter leaps
-    // (surprisingly common, see Microsoft KB: Q274323)
-    unsigned long check = GetTickCount() - mStartTick;
-    signed long msecOff = (signed long)(newTicks - check);
-    if (msecOff < -100 || msecOff > 100)
-    {
-        // We must keep the timer running forward :)
-        LONGLONG adjust = (std::min)(msecOff * mFrequency.QuadPart / 1000, newTime - mLastTime);
-        mStartTime.QuadPart += adjust;
-        newTime -= adjust;
-
-        // Re-calculate milliseconds
-        newTicks = (unsigned long) (1000 * newTime / mFrequency.QuadPart);
-    }
-
-    // Record last time for adjust
-    mLastTime = newTime;
-
-    return newTicks;
-}
-
-unsigned long Timer::getStartMs() const
-{
-	unsigned long newTicks = (unsigned long) (1000 * mStartTime.QuadPart / mFrequency.QuadPart);
-
-	return newTicks;
-}
-
-//-------------------------------------------------------------------------
-unsigned long Timer::getMicroseconds()
-{
-    LARGE_INTEGER curTime;
-
-	HANDLE thread = GetCurrentThread();
+		return newTicks;
+	}
 
-	// Set affinity to the first core
-	DWORD_PTR oldMask = SetThreadAffinityMask(thread, mTimerMask);
+	unsigned long Timer::getStartMs() const
+	{
+		unsigned long newTicks = (unsigned long) (1000 * mStartTime.QuadPart / mFrequency.QuadPart);
 
-	// Query the timer
-	QueryPerformanceCounter(&curTime);
+		return newTicks;
+	}
 
-	// Reset affinity
-	SetThreadAffinityMask(thread, oldMask);
+	unsigned long Timer::getMicroseconds()
+	{
+		LARGE_INTEGER curTime;
+		QueryPerformanceCounter(&curTime);
 
-	LONGLONG newTime = curTime.QuadPart - mStartTime.QuadPart;
-    
-    // get milliseconds to check against GetTickCount
-    unsigned long newTicks = (unsigned long) (1000 * newTime / mFrequency.QuadPart);
+		LONGLONG newTime = curTime.QuadPart - mStartTime.QuadPart;
     
-    // detect and compensate for performance counter leaps
-    // (surprisingly common, see Microsoft KB: Q274323)
-    unsigned long check = GetTickCount() - mStartTick;
-    signed long msecOff = (signed long)(newTicks - check);
-    if (msecOff < -100 || msecOff > 100)
-    {
-        // We must keep the timer running forward :)
-        LONGLONG adjust = (std::min)(msecOff * mFrequency.QuadPart / 1000, newTime - mLastTime);
-        mStartTime.QuadPart += adjust;
-        newTime -= adjust;
-    }
+		// Scale by 1000000 for microseconds
+		unsigned long newMicro = (unsigned long) (1000000 * newTime / mFrequency.QuadPart);
 
-    // Record last time for adjust
-    mLastTime = newTime;
-
-    // scale by 1000000 for microseconds
-    unsigned long newMicro = (unsigned long) (1000000 * newTime / mFrequency.QuadPart);
+		return newMicro;
+	}
 
-    return newMicro;
-}
+	unsigned long Timer::getMillisecondsCPU()
+	{
+		clock_t newClock = clock();
+		return (unsigned long)((float)(newClock - mZeroClock) / ((float)CLOCKS_PER_SEC / 1000.0f));
+	}
 
-//-------------------------------------------------------------------------
-unsigned long Timer::getMillisecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)( (float)( newClock - mZeroClock ) / ( (float)CLOCKS_PER_SEC / 1000.0 ) ) ;
-}
 
-//-------------------------------------------------------------------------
-unsigned long Timer::getMicrosecondsCPU()
-{
-	clock_t newClock = clock();
-	return (unsigned long)( (float)( newClock - mZeroClock ) / ( (float)CLOCKS_PER_SEC / 1000000.0 ) ) ;
-}
+	unsigned long Timer::getMicrosecondsCPU()
+	{
+		clock_t newClock = clock();
+		return (unsigned long)((float)(newClock - mZeroClock) / ((float)CLOCKS_PER_SEC / 1000000.0f));
+	}
+}

+ 9 - 18
Inspector.txt

@@ -6,13 +6,18 @@ GameObject field
 Resource field
 -------------
 
-Update C++ side of the GUI so it properly uses GUIPanels
- - (Remove current GUI and EditorGUI and replace them with GUIPanel)
- - Ensure GUI panel clips any of its child GUIAreas to the panel area
+A way to close a window & destroy a GUI panel!
+ - Will likely need to refactor ScriptEditorWindow as currently it performs initialization
+   in constructor and destroy in destructor, but open/close will be called within its lifetime
+ - Also a way to get notified if the window gets closed from C++
+ - Once closed the referenced GUIPanels should no longer work (set "destroyed" flag?)
+ - What about calling Destroy on a GUIPanel?
+   - It should notify owning EditorWindow
 
-Remove support for resizeable areas (Update ScriptGUIArea)
+Ensure that setting depth for GUIArea works properly. It's not properly implemented yet.
 
 Things to think about/do:
+ - Add EditorFields to C#
  - Inspectable fields need TAB support
   - Modify C++ GUIElement so I can do setNextTabElement(GUIElement*)
  - Inspectable fields need Undo/Redo support. Consider how to best implement it
@@ -28,26 +33,12 @@ Things to think about/do:
  - Currently I do not have a way to creating an Inspector field for just a single field, only for an entire object
  - Finally once all other things are done implement support for multi-rank arrays, lists and dictionaries
 
-
 How will UndoRedo keep a reference to the object? 
  - What if the object gets destroyed? 
  - Keeping a reference will prevent the object from being destroyed.
    - Although heavy stuff is destroyed manually via Destroy anyway
 
-
 STUBBED IN METHODS:
-EditorWindow
- WindowResized
- Internal_GetWidth
- Internal_GetHeight
- Internal_CreateGUIPanel
-GUIPanel
- Internal_SetArea
- Internal_Destroy
-SceneObject
- GetComponents
-GUIArea
- SetArea
 SerializableObject
 SerializableArray
 SerializableField

+ 8 - 6
MBansheeEditor/EditorWindow.cs

@@ -6,8 +6,8 @@ namespace BansheeEditor
 {
     public class EditorWindow : ScriptObject
     {
-        internal int width { get { return Internal_GetWidth(); } }
-        internal int height { get { return Internal_GetHeight(); } }
+        internal int width { get { return Internal_GetWidth(mCachedPtr); } }
+        internal int height { get { return Internal_GetHeight(mCachedPtr); } }
 
         protected GUIPanel GUI;
 
@@ -28,7 +28,9 @@ namespace BansheeEditor
 
         internal GUIPanel CreatePanel(int x, int y, int width, int height)
         {
-            GUIPanel newPanel = Internal_CreateGUIPanel(mCachedPtr);
+            GUIPanel newPanel = new GUIPanel();
+            Internal_InitializeGUIPanel(mCachedPtr, newPanel);
+            newPanel.Initialize();
             newPanel.SetArea(x, y, width, height);
 
             return newPanel;
@@ -38,12 +40,12 @@ namespace BansheeEditor
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern GUIPanel Internal_CreateGUIPanel(IntPtr nativeInstance);
+        private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern int Internal_GetWidth();
+        private static extern int Internal_GetWidth(IntPtr nativeInstance);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern int Internal_GetHeight();
+        private static extern int Internal_GetHeight(IntPtr nativeInstance);
     }
 }

+ 3 - 0
MBansheeEngine/Component.cs

@@ -15,6 +15,9 @@ namespace BansheeEngine
         [MethodImpl(MethodImplOptions.InternalCall)]
         internal static extern Component Internal_GetComponent(SceneObject parent, Type type);
 
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        internal static extern Component[] Internal_GetComponents(SceneObject parent);
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         internal static extern Component Internal_RemoveComponent(SceneObject parent, Type type);
     }

+ 2 - 38
MBansheeEngine/GUI/GUIArea.cs

@@ -36,36 +36,9 @@ namespace BansheeEngine
             return newArea;
         }
 
-        internal static GUIArea CreateResizableX(GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop, int height, short depth)
-        {
-            GUIArea newArea = new GUIArea();
-            Internal_CreateInstanceResizableX(newArea, parent, offsetLeft, offsetRight, offsetTop, height, depth);
-            newArea._layout = new GUILayoutX(newArea);
-
-            return newArea;
-        }
-
-        internal static GUIArea CreateResizableY(GUIPanel parent, int offsetTop, int offsetBottom, int offsetLeft, int width, short depth)
-        {
-            GUIArea newArea = new GUIArea();
-            Internal_CreateInstanceResizableY(newArea, parent, offsetTop, offsetBottom, offsetLeft, width, depth);
-            newArea._layout = new GUILayoutX(newArea);
-
-            return newArea;
-        }
-
-        internal static GUIArea CreateResizableXY(GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom, short depth)
-        {
-            GUIArea newArea = new GUIArea();
-            Internal_CreateInstanceResizableXY(newArea, parent, offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
-            newArea._layout = new GUILayoutX(newArea);
-
-            return newArea;
-        }
-
         public void SetArea(int x, int y, int width, int height, short depth = 0)
         {
-            // TODO
+            Internal_SetArea(mCachedPtr, x, y, width, height, depth);
         }
 
         public void SetVisible(bool visible)
@@ -91,16 +64,7 @@ namespace BansheeEngine
         private static extern void Internal_CreateInstance(GUIArea instance, GUIPanel parent, int x, int y, int width, int height, short depth);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstanceResizableX(GUIArea instance, GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop, 
-            int height, short depth);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstanceResizableY(GUIArea instance, GUIPanel parent, int offsetTop, int offsetBottom, int offsetLeft,
-            int width, short depth);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstanceResizableXY(GUIArea instance, GUIPanel parent, int offsetLeft, int offsetRight, int offsetTop,
-            int offsetBottom, short depth);
+        private static extern void Internal_SetArea(IntPtr nativeInstance, int x, int y, int width, int height, short depth);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_Destroy(IntPtr nativeInstance);

+ 2 - 2
MBansheeEngine/GUI/GUIPanel.cs

@@ -48,7 +48,7 @@ namespace BansheeEngine
 
         internal void SetArea(int x, int y, int width, int height)
         {
-            Internal_SetArea(x, y, width, height);
+            Internal_SetArea(mCachedPtr, x, y, width, height);
 
             mainArea.SetArea(x, y, width, height);
         }
@@ -65,7 +65,7 @@ namespace BansheeEngine
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetArea(int x, int y, int width, int height);
+        private static extern void Internal_SetArea(IntPtr nativeInstance, int x, int y, int width, int height);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(GUIPanel instance);

+ 1 - 1
MBansheeEngine/SceneObject.cs

@@ -35,7 +35,7 @@ namespace BansheeEngine
 
         public Component[] GetComponents()
         {
-            throw new NotImplementedException();
+            return Component.Internal_GetComponents(this);
         }
 
         public void RemoveComponent<T>() where T : Component

+ 0 - 25
SBansheeEditor/Include/BsScriptEditorGUI.h

@@ -1,25 +0,0 @@
-#pragma once
-
-#include "BsScriptEditorPrerequisites.h"
-#include "BsScriptObject.h"
-#include "BsScriptGUIBase.h"
-
-namespace BansheeEditor
-{
-	class BS_SCR_BED_EXPORT ScriptEditorGUI: public BS::ScriptGUIBase, public BS::ScriptObject<ScriptEditorGUI>
-	{
-	public:
-		static void initMetaData();
-
-		virtual BS::GUIWidget& getWidget() const;
-	private:
-		ScriptEditorGUI(ScriptEditorWindow* parentWindow);
-
-		static void internal_createInstance(MonoObject* instance, MonoObject* parentEditorWindow);
-		static void internal_destroyInstance(ScriptEditorGUI* nativeInstance);
-
-		static void initRuntimeData();
-
-		ScriptEditorWindow* mParentWindow;
-	};
-}

+ 16 - 1
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -29,12 +29,27 @@ namespace BansheeEditor
 		ScriptEditorWindow(const CM::String& windowName, const CM::String& displayName, EditorWidgetBase* editorWidget);
 
 		static MonoObject* internal_createOrGetInstance(MonoString* ns, MonoString* typeName);
-		static void internal_destroyInstance(ScriptEditorWindow* nativeInstance);
+		static void internal_destroyInstance(ScriptEditorWindow* thisPtr);
 
 		static void initRuntimeData();
 
+		static CM::UINT32 internal_getWidth(ScriptEditorWindow* thisPtr);
+		static CM::UINT32 internal_getHeight(ScriptEditorWindow* thisPtr);
+
+		static void internal_initializeGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel);
+
+		void onWidgetMoved(CM::INT32 x, CM::INT32 y);
+		void onWidgetResized(CM::UINT32 width, CM::UINT32 height);
+		void onWidgetParentChanged(EditorWidgetContainer* newParent);
+
 		CM::String mName;
 		EditorWidgetBase* mEditorWidget;
+		CM::Vector<BS::ScriptGUIPanel*>::type mPanels;
+		boost::signals::connection mOnWidgetMovedConn;
+		boost::signals::connection mOnWidgetResizedConn;
+		boost::signals::connection mOnParentChangedConn;
+
+		static BS::MonoMethod* onResizedMethod;
 
 		// Global editor window management methods
 		static void registerScriptEditorWindow(ScriptEditorWindow* editorWindow);

+ 0 - 2
SBansheeEditor/SBansheeEditor.vcxproj

@@ -226,12 +226,10 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClInclude Include="Include\BsScriptEditorGUI.h" />
     <ClInclude Include="Include\BsScriptEditorPrerequisites.h" />
     <ClInclude Include="Include\BsScriptEditorWindow.h" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="Source\BsScriptEditorGUI.cpp" />
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp" />
     <ClCompile Include="Source\BsScriptEditorWindow.cpp" />
   </ItemGroup>

+ 0 - 6
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -18,9 +18,6 @@
     <ClInclude Include="Include\BsScriptEditorPrerequisites.h">
       <Filter>Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptEditorGUI.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptEditorWindow.h">
       <Filter>Header Files</Filter>
     </ClInclude>
@@ -29,9 +26,6 @@
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptEditorGUI.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptEditorWindow.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>

+ 0 - 60
SBansheeEditor/Source/BsScriptEditorGUI.cpp

@@ -1,60 +0,0 @@
-#include "BsScriptEditorGUI.h"
-#include "BsMonoManager.h"
-#include "BsScriptMeta.h"
-#include "BsMonoClass.h"
-#include "BsScriptEditorWindow.h"
-#include "BsEditorWidget.h"
-#include "BsEditorWidgetContainer.h"
-#include "BsGUIWidget.h"
-#include "BsCamera.h"
-#include "CmSceneObject.h"
-#include "BsEditorGUI.h"
-
-using namespace CamelotFramework;
-using namespace BansheeEngine;
-
-namespace BansheeEditor
-{
-	ScriptEditorGUI::ScriptEditorGUI(ScriptEditorWindow* parentWindow)
-		:ScriptGUIBase(), mParentWindow(parentWindow)
-	{
-
-	}
-
-	void ScriptEditorGUI::initMetaData()
-	{
-		metaData = ScriptMeta(BansheeEditorAssemblyName, "BansheeEditor", "EditorGUI", &ScriptEditorGUI::initRuntimeData);
-
-		MonoManager::registerScriptType(&metaData);
-	}
-
-	void ScriptEditorGUI::initRuntimeData()
-	{
-		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptEditorGUI::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptEditorGUI::internal_destroyInstance);
-	}
-
-	void ScriptEditorGUI::internal_createInstance(MonoObject* instance, MonoObject* parentEditorWindow)
-	{
-		ScriptEditorWindow* nativeParentWindow = ScriptEditorWindow::toNative(parentEditorWindow);
-
-		ScriptEditorGUI* nativeInstance = new (cm_alloc<ScriptEditorGUI>()) ScriptEditorGUI(nativeParentWindow);
-		nativeInstance->createInstance(instance);
-
-		metaData.thisPtrField->setValue(instance, &nativeInstance);
-	}
-
-	void ScriptEditorGUI::internal_destroyInstance(ScriptEditorGUI* nativeInstance)
-	{
-		cm_delete(nativeInstance);
-	}
-
-	GUIWidget& ScriptEditorGUI::getWidget() const
-	{
-		EditorWidgetContainer* widgetContainer = mParentWindow->getEditorWidget()->_getParent();
-		if(widgetContainer == nullptr)
-			CM_EXCEPT(InternalErrorException, "Attempting to retrieve GUI widget of an unparented EditorWidget.");
-
-		return widgetContainer->getParentWidget();
-	}
-}

+ 72 - 5
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -1,11 +1,14 @@
 #include "BsScriptEditorWindow.h"
 #include "BsScriptMeta.h"
+#include "BsScriptGUIPanel.h"
 #include "BsMonoField.h"
 #include "BsMonoClass.h"
+#include "BsMonoMethod.h"
 #include "BsMonoManager.h"
 #include "BsMonoUtil.h"
 #include "BsEditorWidget.h"
 #include "BsEditorWidgetManager.h"
+#include "BsEditorWidgetContainer.h"
 #include "BsMonoAssembly.h"
 
 using namespace CamelotFramework;
@@ -15,16 +18,22 @@ using namespace std::placeholders;
 namespace BansheeEditor
 {
 	UnorderedMap<String, ScriptEditorWindow::EditorWindowHandle>::type ScriptEditorWindow::OpenScriptEditorWindows;
+	BS::MonoMethod* ScriptEditorWindow::onResizedMethod = nullptr;
 
 	ScriptEditorWindow::ScriptEditorWindow(const CM::String& windowName, const CM::String& displayName, EditorWidgetBase* editorWidget)
 		:mName(windowName), mEditorWidget(editorWidget)
 	{
-
+		mOnWidgetMovedConn = editorWidget->onMoved.connect(std::bind(&ScriptEditorWindow::onWidgetMoved, this, _1, _2));
+		mOnWidgetResizedConn = editorWidget->onResized.connect(std::bind(&ScriptEditorWindow::onWidgetResized, this, _1, _2));
+		mOnParentChangedConn = editorWidget->onParentChanged.connect(std::bind(&ScriptEditorWindow::onWidgetParentChanged, this, _1));
 	}
 
 	ScriptEditorWindow::~ScriptEditorWindow()
 	{
-
+		// TODO - This probably need to be called whenever we close a window, and not when script class is destructed
+		mOnWidgetMovedConn.disconnect();
+		mOnWidgetResizedConn.disconnect();
+		mOnParentChangedConn.disconnect();
 	}
 
 	void ScriptEditorWindow::initMetaData()
@@ -38,6 +47,11 @@ namespace BansheeEditor
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateOrGetInstance", &ScriptEditorWindow::internal_createOrGetInstance);
 		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptEditorWindow::internal_destroyInstance);
+		metaData.scriptClass->addInternalCall("Internal_InitializeGUIPanel", &ScriptEditorWindow::internal_initializeGUIPanel);
+		metaData.scriptClass->addInternalCall("Internal_GetWidth", &ScriptEditorWindow::internal_getWidth);
+		metaData.scriptClass->addInternalCall("Internal_GetHeight", &ScriptEditorWindow::internal_getHeight);
+
+		onResizedMethod = &metaData.scriptClass->getMethod("WindowResized", 2);
 	}
 
 	MonoObject* ScriptEditorWindow::internal_createOrGetInstance(MonoString* ns, MonoString* typeName)
@@ -59,10 +73,10 @@ namespace BansheeEditor
 		return nullptr;
 	}
 
-	void ScriptEditorWindow::internal_destroyInstance(ScriptEditorWindow* nativeInstance)
+	void ScriptEditorWindow::internal_destroyInstance(ScriptEditorWindow* thisPtr)
 	{
 #if CM_DEBUG_MODE
-		auto iterFind = OpenScriptEditorWindows.find(nativeInstance->mName);
+		auto iterFind = OpenScriptEditorWindows.find(thisPtr->mName);
 
 		// It is assumed that this method will only be called after "unregisterScriptEditorWindow" is called,
 		// since that is the only place keeping a reference to the managed editor window. So if window was
@@ -70,7 +84,60 @@ namespace BansheeEditor
 		assert(iterFind == OpenScriptEditorWindows.end());
 #endif
 
-		cm_delete(nativeInstance);
+		cm_delete(thisPtr);
+	}
+
+	CM::UINT32 ScriptEditorWindow::internal_getWidth(ScriptEditorWindow* thisPtr)
+	{
+		return thisPtr->mEditorWidget->getWidth();
+	}
+
+	CM::UINT32 ScriptEditorWindow::internal_getHeight(ScriptEditorWindow* thisPtr)
+	{
+		return thisPtr->mEditorWidget->getHeight();
+	}
+
+	void ScriptEditorWindow::internal_initializeGUIPanel(ScriptEditorWindow* thisPtr, MonoObject* panel)
+	{
+		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
+		thisPtr->mPanels.push_back(scriptGUIPanel);
+
+		scriptGUIPanel->setParentArea(thisPtr->mEditorWidget->getX(), thisPtr->mEditorWidget->getY(), 
+			thisPtr->mEditorWidget->getWidth(), thisPtr->mEditorWidget->getHeight());
+
+		scriptGUIPanel->setParentWidget(&thisPtr->mEditorWidget->_getParent()->getParentWidget());
+	}
+
+	void ScriptEditorWindow::onWidgetMoved(CM::INT32 x, CM::INT32 y)
+	{
+		for(auto& panel : mPanels)
+		{
+			panel->setParentArea(x, y, 
+				mEditorWidget->getWidth(), mEditorWidget->getHeight());
+		}
+	}
+
+	void ScriptEditorWindow::onWidgetResized(CM::UINT32 width, CM::UINT32 height)
+	{
+		for(auto& panel : mPanels)
+		{
+			panel->setParentArea(mEditorWidget->getX(), mEditorWidget->getY(), 
+				width, height);
+		}
+
+		void* params[2] = { &width, &height };
+		onResizedMethod->invokeVirtual(mManagedInstance, params);
+	}
+
+	void ScriptEditorWindow::onWidgetParentChanged(EditorWidgetContainer* newParent)
+	{
+		for(auto& panel : mPanels)
+		{
+			if(newParent != nullptr)
+				panel->setParentWidget(&newParent->getParentWidget());
+			else
+				panel->setParentWidget(nullptr);
+		}
 	}
 
 	void ScriptEditorWindow::registerManagedEditorWindows()

+ 1 - 0
SBansheeEngine/Include/BsScriptComponent.h

@@ -20,6 +20,7 @@ namespace BansheeEngine
 
 		static MonoObject* internal_addComponent(MonoObject* parentSceneObject, MonoReflectionType* type);
 		static MonoObject* internal_getComponent(MonoObject* parentSceneObject, MonoReflectionType* type);
+		static MonoArray* internal_getComponents(MonoObject* parentSceneObject);
 		static void internal_removeComponent(MonoObject* parentSceneObject, MonoReflectionType* type);
 		static void internal_destroyInstance(ScriptComponent* nativeInstance);
 

+ 1 - 1
SBansheeEngine/Include/BsScriptEnginePrerequisites.h

@@ -27,7 +27,7 @@ namespace BansheeEngine
 	class ScriptTexture2D;
 	class ScriptGUIElementStyle;
 	class ScriptGUIElementStateStyle;
-	class ScriptGUIBase;
+	class ScriptGUIPanel;
 	class ScriptGUIArea;
 	class ScriptGUILayout;
 	class ScriptGUILabel;

+ 12 - 16
SBansheeEngine/Include/BsScriptGUIArea.h

@@ -2,6 +2,7 @@
 
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptObject.h"
+#include "CmRectI.h"
 
 namespace BansheeEngine
 {
@@ -10,33 +11,28 @@ namespace BansheeEngine
 	public:
 		static void initMetaData();
 
-		GUIArea* getInternalValue() const { return mArea; }
-		void* getNativeRaw() const { return mArea; }
+		GUIArea* getInternalValue() const { return mGUIArea; }
+		void* getNativeRaw() const { return mGUIArea; }
+
+		void updateArea();
 
 	private:
 		static void internal_createInstance(MonoObject* instance, MonoObject* parentGUI, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth);
-		static void internal_createInstanceResizeableX(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetLeft, CM::UINT32 offsetRight, 
-			CM::UINT32 offsetTop, CM::UINT32 height, CM::UINT16 depth);
-
-		static void internal_createInstanceResizeableY(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetTop, 
-			CM::UINT32 offsetBottom, CM::UINT32 offsetLeft, CM::UINT32 width, CM::UINT16 depth);
-
-		static void internal_createInstanceResizeableXY(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetLeft, 
-			CM::UINT32 offsetRight, CM::UINT32 offsetTop, CM::UINT32 offsetBottom, CM::UINT16 depth);
-
 		static void internal_destroyInstance(ScriptGUIArea* nativeInstance);
 
-		static void internal_destroy(ScriptGUIArea* nativeInstance);
-		static void internal_setVisible(ScriptGUIArea* nativeInstance, bool visible);
+		static void internal_destroy(ScriptGUIArea* thisPtr);
+		static void internal_setVisible(ScriptGUIArea* thisPtr, bool visible);
+		static void internal_setArea(ScriptGUIArea* thisPtr, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth);
 
 		static void initRuntimeData();
 
-		ScriptGUIArea(GUIArea* area, ScriptGUIBase* parentGUI);
+		ScriptGUIArea(GUIArea* area, ScriptGUIPanel* panel);
 
 		void destroy();
 
-		GUIArea* mArea;
-		ScriptGUIBase* mParentGUI;
+		GUIArea* mGUIArea;
+		CM::RectI mArea;
+		ScriptGUIPanel* mParentPanel;
 		bool mIsDestroyed;
 	};
 }

+ 0 - 34
SBansheeEngine/Include/BsScriptGUIBase.h

@@ -1,34 +0,0 @@
-#pragma once
-
-#include "BsScriptEnginePrerequisites.h"
-#include "BsScriptObject.h"
-
-namespace BansheeEngine
-{
-	class BS_SCR_BE_EXPORT ScriptGUIBaseMeta : public ScriptObject<ScriptGUIBaseMeta>
-	{
-	public:
-		friend class ScriptGUIBase;
-
-		static void initMetaData();
-	};
-
-	class BS_SCR_BE_EXPORT ScriptGUIBase
-	{
-	public:
-		virtual GUIWidget& getWidget() const = 0;
-
-		static void initRuntimeData() { }
-
-		static ScriptGUIBase* toNative(MonoObject* managedInstance)
-		{
-			ScriptGUIBase* nativeInstance = nullptr;
-			ScriptGUIBaseMeta::metaData.thisPtrField->getValue(managedInstance, &nativeInstance);
-
-			return nativeInstance;
-		}
-
-	protected:
-		ScriptGUIBase();
-	};
-}

+ 2 - 2
SBansheeEngine/SBansheeEngine.vcxproj

@@ -247,7 +247,7 @@
     <ClInclude Include="Include\BsScriptGUIFlexibleSpace.h" />
     <ClInclude Include="Include\BsScriptFont.h" />
     <ClInclude Include="Include\BsScriptGUIArea.h" />
-    <ClInclude Include="Include\BsScriptGUIBase.h" />
+    <ClInclude Include="Include\BsScriptGUIPanel.h" />
     <ClInclude Include="Include\BsScriptGUIElementStateStyle.h" />
     <ClInclude Include="Include\BsScriptGUIElementStyle.h" />
     <ClInclude Include="Include\BsScriptGUIInputBox.h" />
@@ -283,7 +283,7 @@
     <ClCompile Include="Source\BsScriptGUIFlexibleSpace.cpp" />
     <ClCompile Include="Source\BsScriptFont.cpp" />
     <ClCompile Include="Source\BsScriptGUIArea.cpp" />
-    <ClCompile Include="Source\BsScriptGUIBase.cpp" />
+    <ClCompile Include="Source\BsScriptGUIPanel.cpp" />
     <ClCompile Include="Source\BsScriptGUIElementStateStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUIElementStyle.cpp" />
     <ClCompile Include="Source\BsScriptGUILabel.cpp" />

+ 6 - 6
SBansheeEngine/SBansheeEngine.vcxproj.filters

@@ -111,9 +111,6 @@
     <ClInclude Include="Include\BsScriptGUIArea.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
-    <ClInclude Include="Include\BsScriptGUIBase.h">
-      <Filter>Header Files\GUI</Filter>
-    </ClInclude>
     <ClInclude Include="Include\BsScriptGUIButton.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
@@ -156,6 +153,9 @@
     <ClInclude Include="Include\BsScriptGUIToggleGroup.h">
       <Filter>Header Files\GUI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptGUIPanel.h">
+      <Filter>Header Files\GUI</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptTexture2D.cpp">
@@ -215,9 +215,6 @@
     <ClCompile Include="Source\BsScriptGUIArea.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
-    <ClCompile Include="Source\BsScriptGUIBase.cpp">
-      <Filter>Source Files\GUI</Filter>
-    </ClCompile>
     <ClCompile Include="Source\BsScriptGUIButton.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
@@ -260,5 +257,8 @@
     <ClCompile Include="Source\BsScriptGUIToggleGroup.cpp">
       <Filter>Source Files\GUI</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptGUIPanel.cpp">
+      <Filter>Source Files\GUI</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 31 - 0
SBansheeEngine/Source/BsScriptComponent.cpp

@@ -30,6 +30,7 @@ namespace BansheeEngine
 	{
 		metaData.scriptClass->addInternalCall("Internal_AddComponent", &ScriptComponent::internal_addComponent);
 		metaData.scriptClass->addInternalCall("Internal_GetComponent", &ScriptComponent::internal_getComponent);
+		metaData.scriptClass->addInternalCall("Internal_GetComponents", &ScriptComponent::internal_getComponents);
 		metaData.scriptClass->addInternalCall("Internal_RemoveComponent", &ScriptComponent::internal_removeComponent);
 		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptComponent::internal_destroyInstance);
 	}
@@ -83,6 +84,36 @@ namespace BansheeEngine
 		return nullptr;
 	}
 
+	MonoArray* ScriptComponent::internal_getComponents(MonoObject* parentSceneObject)
+	{
+		ScriptSceneObject* scriptSO = ScriptSceneObject::toNative(parentSceneObject);
+		HSceneObject so = static_object_cast<SceneObject>(scriptSO->getNativeHandle());
+
+		const Vector<HComponent>::type& mComponents = so->getComponents();
+		Vector<MonoObject*>::type managedComponents;
+
+		for(auto& component : mComponents)
+		{
+			if(component->getTypeId() == TID_ManagedComponent)
+			{
+				GameObjectHandle<ManagedComponent> managedComponent = static_object_cast<ManagedComponent>(component);
+
+				managedComponents.push_back(managedComponent->getManagedInstance());
+			}
+		}
+
+		MonoArray* componentArray = mono_array_new(MonoManager::instance().getDomain(), 
+			metaData.scriptClass->_getInternalClass(), (UINT32)managedComponents.size());
+
+		for(UINT32 i = 0; i < (UINT32)managedComponents.size(); i++)
+		{
+			void* elemAddr = mono_array_addr_with_size(componentArray, sizeof(MonoObject*), i);
+			memcpy(elemAddr, &managedComponents[i], sizeof(MonoObject*));
+		}
+
+		return componentArray;
+	}
+
 	void ScriptComponent::internal_removeComponent(MonoObject* parentSceneObject, MonoReflectionType* type)
 	{
 		ScriptSceneObject* scriptSO = ScriptSceneObject::toNative(parentSceneObject);

+ 36 - 52
SBansheeEngine/Source/BsScriptGUIArea.cpp

@@ -6,16 +6,16 @@
 #include "BsScriptGUIArea.h"
 #include "BsGUIArea.h"
 #include "BsGUILayout.h"
-#include "BsScriptGUIBase.h"
+#include "BsScriptGUIPanel.h"
 
 using namespace CamelotFramework;
 
 namespace BansheeEngine
 {
-	ScriptGUIArea::ScriptGUIArea(GUIArea* area, ScriptGUIBase* parentGUI)
-		:mArea(area), mParentGUI(parentGUI), mIsDestroyed(false)
+	ScriptGUIArea::ScriptGUIArea(GUIArea* area, ScriptGUIPanel* parentGUI)
+		:mGUIArea(area), mParentPanel(parentGUI), mIsDestroyed(false)
 	{
-
+		mParentPanel->registerArea(this);
 	}
 
 	void ScriptGUIArea::initMetaData()
@@ -28,9 +28,7 @@ namespace BansheeEngine
 	void ScriptGUIArea::initRuntimeData()
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIArea::internal_createInstance);
-		metaData.scriptClass->addInternalCall("Internal_CreateInstanceResizableX", &ScriptGUIArea::internal_createInstanceResizeableX);
-		metaData.scriptClass->addInternalCall("Internal_CreateInstanceResizableY", &ScriptGUIArea::internal_createInstanceResizeableY);
-		metaData.scriptClass->addInternalCall("Internal_CreateInstanceResizableXY", &ScriptGUIArea::internal_createInstanceResizeableXY);
+		metaData.scriptClass->addInternalCall("Internal_SetArea", &ScriptGUIArea::internal_setArea);
 		metaData.scriptClass->addInternalCall("Internal_DestroyInstance", &ScriptGUIArea::internal_destroyInstance);
 		metaData.scriptClass->addInternalCall("Internal_Destroy", &ScriptGUIArea::internal_destroy);
 		metaData.scriptClass->addInternalCall("Internal_SetVisible", &ScriptGUIArea::internal_setVisible);
@@ -40,76 +38,62 @@ namespace BansheeEngine
 	{
 		if(!mIsDestroyed)
 		{
-			GUIArea::destroy(mArea);
-			mArea = nullptr;
+			mParentPanel->unregisterArea(this);
+
+			GUIArea::destroy(mGUIArea);
+			mGUIArea = nullptr;
 
 			mIsDestroyed = true;
 		}
 	}
 
-	void ScriptGUIArea::internal_createInstance(MonoObject* instance, MonoObject* parentGUI, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth)
+	void ScriptGUIArea::internal_createInstance(MonoObject* instance, MonoObject* panel, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth)
 	{
-		ScriptGUIBase* scriptGUIBase = ScriptGUIBase::toNative(parentGUI);
-		GUIArea* nativeArea = GUIArea::create(scriptGUIBase->getWidget(), x, y, width, height, depth);
+		ScriptGUIPanel* scriptGUIPanel = ScriptGUIPanel::toNative(panel);
+		GUIArea* nativeArea = GUIArea::create(scriptGUIPanel->getWidget(), x, y, width, height, depth);
 
-		ScriptGUIArea* nativeInstance = new (cm_alloc<ScriptGUIArea>()) ScriptGUIArea(nativeArea, scriptGUIBase);
+		ScriptGUIArea* nativeInstance = new (cm_alloc<ScriptGUIArea>()) ScriptGUIArea(nativeArea, scriptGUIPanel);
 		nativeInstance->createInstance(instance);
 
 		metaData.thisPtrField->setValue(instance, &nativeInstance);
 	}
 
-	void ScriptGUIArea::internal_createInstanceResizeableX(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetLeft, CM::UINT32 offsetRight, 
-		CM::UINT32 offsetTop, CM::UINT32 height, CM::UINT16 depth)
+	void ScriptGUIArea::internal_destroyInstance(ScriptGUIArea* thisPtr)
 	{
-		ScriptGUIBase* scriptGUIBase = ScriptGUIBase::toNative(parentGUI);
-		GUIArea* nativeArea = GUIArea::createStretchedX(scriptGUIBase->getWidget(), offsetLeft, offsetRight, offsetTop, height, depth);
-		
-		ScriptGUIArea* nativeInstance = new (cm_alloc<ScriptGUIArea>()) ScriptGUIArea(nativeArea, scriptGUIBase);
-		nativeInstance->createInstance(instance);
-
-		metaData.thisPtrField->setValue(instance, &nativeInstance);
+		thisPtr->destroy();
+		cm_delete(thisPtr);
 	}
 
-	void ScriptGUIArea::internal_createInstanceResizeableY(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetTop, 
-		CM::UINT32 offsetBottom, CM::UINT32 offsetLeft, CM::UINT32 width, CM::UINT16 depth)
+	void ScriptGUIArea::internal_destroy(ScriptGUIArea* thisPtr)
 	{
-		ScriptGUIBase* scriptGUIBase = ScriptGUIBase::toNative(parentGUI);
-		GUIArea* nativeArea = GUIArea::createStretchedY(scriptGUIBase->getWidget(), offsetTop, offsetBottom, offsetLeft, width, depth);
-
-		ScriptGUIArea* nativeInstance = new (cm_alloc<ScriptGUIArea>()) ScriptGUIArea(nativeArea, scriptGUIBase);
-		nativeInstance->createInstance(instance);
-
-		metaData.thisPtrField->setValue(instance, &nativeInstance);
+		thisPtr->destroy();
 	}
 
-	void ScriptGUIArea::internal_createInstanceResizeableXY(MonoObject* instance, MonoObject* parentGUI, CM::UINT32 offsetLeft, 
-		CM::UINT32 offsetRight, CM::UINT32 offsetTop, CM::UINT32 offsetBottom, CM::UINT16 depth)
+	void ScriptGUIArea::internal_setVisible(ScriptGUIArea* thisPtr, bool visible)
 	{
-		ScriptGUIBase* scriptGUIBase = ScriptGUIBase::toNative(parentGUI);
-		GUIArea* nativeArea = GUIArea::createStretchedXY(scriptGUIBase->getWidget(), offsetLeft, offsetRight, offsetTop, offsetBottom, depth);
-
-		ScriptGUIArea* nativeInstance = new (cm_alloc<ScriptGUIArea>()) ScriptGUIArea(nativeArea, scriptGUIBase);
-		nativeInstance->createInstance(instance);
-
-		metaData.thisPtrField->setValue(instance, &nativeInstance);
+		if(visible)
+			thisPtr->mGUIArea->enable();
+		else
+			thisPtr->mGUIArea->disable();
 	}
 
-	void ScriptGUIArea::internal_destroyInstance(ScriptGUIArea* nativeInstance)
+	void ScriptGUIArea::internal_setArea(ScriptGUIArea* thisPtr, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height, CM::UINT16 depth)
 	{
-		nativeInstance->destroy();
-		cm_delete(nativeInstance);
-	}
+		thisPtr->mArea.x = x;
+		thisPtr->mArea.y = y;
+		thisPtr->mArea.width = width;
+		thisPtr->mArea.height = height;
 
-	void ScriptGUIArea::internal_destroy(ScriptGUIArea* nativeInstance)
-	{
-		nativeInstance->destroy();
+		thisPtr->updateArea();
 	}
 
-	void ScriptGUIArea::internal_setVisible(ScriptGUIArea* nativeInstance, bool visible)
+	void ScriptGUIArea::updateArea()
 	{
-		if(visible)
-			nativeInstance->getInternalValue()->enable();
-		else
-			nativeInstance->getInternalValue()->disable();
+		RectI parentArea = mParentPanel->getClippedArea();
+		RectI myClippedArea = mArea;
+		myClippedArea.clip(parentArea);
+		
+		mGUIArea->setPosition(myClippedArea.x, myClippedArea.y);
+		mGUIArea->setSize(myClippedArea.width, myClippedArea.height);
 	}
 }

+ 0 - 25
SBansheeEngine/Source/BsScriptGUIBase.cpp

@@ -1,25 +0,0 @@
-#include "BsScriptGUIBase.h"
-#include "BsScriptMeta.h"
-#include "BsMonoField.h"
-#include "BsMonoClass.h"
-#include "BsMonoManager.h"
-#include "BsScriptGUIArea.h"
-#include "BsGUIArea.h"
-#include "BsGUILayout.h"
-
-using namespace CamelotFramework;
-
-namespace BansheeEngine
-{
-	ScriptGUIBase::ScriptGUIBase()
-	{
-
-	}
-
-	void ScriptGUIBaseMeta::initMetaData()
-	{
-		metaData = ScriptMeta(BansheeEngineAssemblyName, "BansheeEngine", "GUIBase", &ScriptGUIBase::initRuntimeData);
-
-		MonoManager::registerScriptType(&metaData);
-	}
-}