Bladeren bron

Made more GUIElement methods internal

Marko Pintera 12 jaren geleden
bovenliggende
commit
301aec0d46
5 gewijzigde bestanden met toevoegingen van 23 en 20 verwijderingen
  1. 5 5
      BansheeEngine/Include/BsGUIElement.h
  2. 10 10
      BansheeEngine/Source/BsGUIManager.cpp
  3. 4 4
      BansheeEngine/Source/BsGUIWidget.cpp
  4. 1 0
      TODO.txt
  5. 3 1
      TODODoc.txt

+ 5 - 5
BansheeEngine/Include/BsGUIElement.h

@@ -74,11 +74,6 @@ namespace BansheeEngine
 
 
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 		virtual bool mouseEvent(const GUIMouseEvent& ev);
 
 
-		const CM::Rect& getBounds() const { return mBounds; }
-		INT32 getDepth() const { return mDepth; }
-		GUIWidget& getParentWidget() const { return mParent; }
-		bool isDirty() const { return mIsDirty; }
-
 		static void destroy(GUIElement* element);
 		static void destroy(GUIElement* element);
 
 
 		/************************************************************************/
 		/************************************************************************/
@@ -99,6 +94,11 @@ namespace BansheeEngine
 		virtual UINT32 _getOptimalWidth() const = 0;
 		virtual UINT32 _getOptimalWidth() const = 0;
 		virtual UINT32 _getOptimalHeight() const = 0;
 		virtual UINT32 _getOptimalHeight() const = 0;
 
 
+		const CM::Rect& _getBounds() const { return mBounds; }
+		INT32 _getDepth() const { return mDepth; }
+		GUIWidget& _getParentWidget() const { return mParent; }
+		bool _isDirty() const { return mIsDirty; }
+
 		const GUI_LAYOUT_OPTIONS& _getLayoutOptions() const { return mLayoutOptions; }
 		const GUI_LAYOUT_OPTIONS& _getLayoutOptions() const { return mLayoutOptions; }
 
 
 		static void _destroyInternal(GUIElement* element);
 		static void _destroyInternal(GUIElement* element);

+ 10 - 10
BansheeEngine/Source/BsGUIManager.cpp

@@ -173,7 +173,7 @@ namespace BansheeEngine
 			// Make a list of all GUI elements, sorted from farthest to nearest (highest depth to lowest)
 			// Make a list of all GUI elements, sorted from farthest to nearest (highest depth to lowest)
 			auto elemComp = [](GUIElement* a, GUIElement* b)
 			auto elemComp = [](GUIElement* a, GUIElement* b)
 			{
 			{
-				return a->getDepth() > b->getDepth() || (a->getDepth() == b->getDepth() && a > b); 
+				return a->_getDepth() > b->_getDepth() || (a->_getDepth() == b->_getDepth() && a > b); 
 				// Compare pointers just to differentiate between two elements with the same depth, their order doesn't really matter, but std::set
 				// Compare pointers just to differentiate between two elements with the same depth, their order doesn't really matter, but std::set
 				// requires all elements to be unique
 				// requires all elements to be unique
 			};
 			};
@@ -193,8 +193,8 @@ namespace BansheeEngine
 			std::unordered_map<UINT64, std::vector<GUIMaterialGroup>> materialGroups;
 			std::unordered_map<UINT64, std::vector<GUIMaterialGroup>> materialGroups;
 			for(auto& elem : allElements)
 			for(auto& elem : allElements)
 			{
 			{
-				Rect tfrmedBounds = elem->getBounds();
-				tfrmedBounds.transform(elem->getParentWidget().SO()->getWorldTfrm());
+				Rect tfrmedBounds = elem->_getBounds();
+				tfrmedBounds.transform(elem->_getParentWidget().SO()->getWorldTfrm());
 
 
 				UINT32 numRenderElems = elem->getNumRenderElements();
 				UINT32 numRenderElems = elem->getNumRenderElements();
 
 
@@ -220,14 +220,14 @@ namespace BansheeEngine
 					{
 					{
 						GUIMaterialGroup& group = *groupIter;
 						GUIMaterialGroup& group = *groupIter;
 
 
-						if(group.depth == elem->getDepth() || group.depth == (elem->getDepth() - 1))
+						if(group.depth == elem->_getDepth() || group.depth == (elem->_getDepth() - 1))
 						{
 						{
 							foundGroup = &group;
 							foundGroup = &group;
 							break;
 							break;
 						}
 						}
 						else
 						else
 						{
 						{
-							UINT32 startDepth = elem->getDepth();
+							UINT32 startDepth = elem->_getDepth();
 							UINT32 endDepth = group.depth;
 							UINT32 endDepth = group.depth;
 
 
 							bool foundOverlap = false;
 							bool foundOverlap = false;
@@ -259,7 +259,7 @@ namespace BansheeEngine
 						allGroups.push_back(GUIMaterialGroup());
 						allGroups.push_back(GUIMaterialGroup());
 						foundGroup = &allGroups[allGroups.size() - 1];
 						foundGroup = &allGroups[allGroups.size() - 1];
 
 
-						foundGroup->depth = elem->getDepth();
+						foundGroup->depth = elem->_getDepth();
 						foundGroup->bounds = tfrmedBounds;
 						foundGroup->bounds = tfrmedBounds;
 						foundGroup->elements.push_back(GUIGroupElement(elem, i));
 						foundGroup->elements.push_back(GUIGroupElement(elem, i));
 						foundGroup->material = mat;
 						foundGroup->material = mat;
@@ -393,19 +393,19 @@ namespace BansheeEngine
 					std::sort(sortedElements.begin(), sortedElements.end(), 
 					std::sort(sortedElements.begin(), sortedElements.end(), 
 						[](GUIElement* a, GUIElement* b)
 						[](GUIElement* a, GUIElement* b)
 					{
 					{
-						return a->getDepth() < b->getDepth();
+						return a->_getDepth() < b->_getDepth();
 					});
 					});
 
 
 					// Elements with lowest depth (most to the front) get handled first
 					// Elements with lowest depth (most to the front) get handled first
 					for(auto iter = sortedElements.begin(); iter != sortedElements.end(); ++iter)
 					for(auto iter = sortedElements.begin(); iter != sortedElements.end(); ++iter)
 					{
 					{
 						GUIElement* element = *iter;
 						GUIElement* element = *iter;
-						const Rect& bounds = element->getBounds();
+						const Rect& bounds = element->_getBounds();
 
 
-						if(bounds.contains(localPos) && element->getDepth() < topMostDepth)
+						if(bounds.contains(localPos) && element->_getDepth() < topMostDepth)
 						{
 						{
 							topMostElement = element;
 							topMostElement = element;
-							topMostDepth = element->getDepth();
+							topMostDepth = element->_getDepth();
 
 
 							break;
 							break;
 						}
 						}

+ 4 - 4
BansheeEngine/Source/BsGUIWidget.cpp

@@ -126,7 +126,7 @@ namespace BansheeEngine
 
 
 			for(auto& elem : mElements)
 			for(auto& elem : mElements)
 			{
 			{
-				if(elem->isDirty())
+				if(elem->_isDirty())
 				{
 				{
 					dirty = true;
 					dirty = true;
 					elem->updateRenderElements();
 					elem->updateRenderElements();
@@ -143,7 +143,7 @@ namespace BansheeEngine
 
 
 			for(auto& elem : mElements)
 			for(auto& elem : mElements)
 			{
 			{
-				if(elem->isDirty())
+				if(elem->_isDirty())
 				{
 				{
 					return true;
 					return true;
 				}
 				}
@@ -170,11 +170,11 @@ namespace BansheeEngine
 	void GUIWidget::updateBounds() const
 	void GUIWidget::updateBounds() const
 	{
 	{
 		if(mElements.size() > 0)
 		if(mElements.size() > 0)
-			mBounds = mElements[0]->getBounds();
+			mBounds = mElements[0]->_getBounds();
 
 
 		for(auto& elem : mElements)
 		for(auto& elem : mElements)
 		{
 		{
-			Rect elemBounds = elem->getBounds();
+			Rect elemBounds = elem->_getBounds();
 			mBounds.encapsulate(elemBounds);
 			mBounds.encapsulate(elemBounds);
 		}
 		}
 	}
 	}

+ 1 - 0
TODO.txt

@@ -22,6 +22,7 @@ I call waitUntilLoaded too many times. Sometimes 5-6 times in a single function.
 GUIWidget::updateMeshes leaks. If I leave the game running I can see memory continously going up
 GUIWidget::updateMeshes leaks. If I leave the game running I can see memory continously going up
 
 
 IMMEDIATE:
 IMMEDIATE:
+ - Calling GUIElement::getBounds before element was updated
  - I'm not setting worldTransform of GUI material in GUIManager::render
  - I'm not setting worldTransform of GUI material in GUIManager::render
    - I need to separate meshes per-widget and later implement some kind of smart batching using multiple transforms per mesh
    - I need to separate meshes per-widget and later implement some kind of smart batching using multiple transforms per mesh
  - Widgets should probably have their own depth. Make widget and area depths UINT16, and element depth UINT32, a combination of those two.
  - Widgets should probably have their own depth. Make widget and area depths UINT16, and element depth UINT32, a combination of those two.

+ 3 - 1
TODODoc.txt

@@ -15,4 +15,6 @@
  - Multiple inheritance is not supported on any class that is serialized with the help of RTTI. If you use it you can expect
  - Multiple inheritance is not supported on any class that is serialized with the help of RTTI. If you use it you can expect
    very weird issues.
    very weird issues.
  - If you're creating a hierarchy of classes with RTTI support, ALL classes in the hierarchy must have RTTI implementations. You cannot just leave
  - If you're creating a hierarchy of classes with RTTI support, ALL classes in the hierarchy must have RTTI implementations. You cannot just leave
-   some out, even if they contain no data. This would create incomplete RTTI class hierarchy which can cause various issues.
+   some out, even if they contain no data. This would create incomplete RTTI class hierarchy which can cause various issues.
+ - Methods prefixed with "_" are methods you should not normally call. They are used internally by some subset of classes that form a system and are not meant
+   to be called by the user, unless you are working internally with that system. The only reason they are part of the public interface is to avoid friend classes.