Explorar o código

Added margins to GUIElementStyle

Marko Pintera %!s(int64=12) %!d(string=hai) anos
pai
achega
d432179ec1

+ 1 - 0
BansheeEngine/Include/BsGUIElement.h

@@ -95,6 +95,7 @@ namespace BansheeEngine
 		virtual UINT32 _getOptimalHeight() const = 0;
 
 		const CM::Rect& _getBounds() const { return mBounds; }
+		const CM::Rect _getContentBounds() const;
 		INT32 _getDepth() const { return mDepth; }
 		GUIWidget& _getParentWidget() const { return mParent; }
 		bool _isDirty() const { return mIsDirty; }

+ 2 - 1
BansheeEngine/Include/BsGUIElementStyle.h

@@ -44,7 +44,8 @@ namespace BansheeEngine
 		GUIElementStateStyle activeOn;
 		GUIElementStateStyle focusedOn;
 
-		RectOffset border;
+		RectOffset border; // Determines how the element is scaled (using the typical Scale9Grid approach)
+		RectOffset margins; // Determines offset from the background graphics to the content. Input uses bounds offset by this value.
 
 		UINT32 width;
 		UINT32 height;

+ 4 - 0
BansheeEngine/Source/BsEngineGUI.cpp

@@ -81,6 +81,10 @@ namespace BansheeEngine
 		buttonStyle.border.right = 5;
 		buttonStyle.border.top = 5;
 		buttonStyle.border.bottom = 5;
+		buttonStyle.margins.left = 4;
+		buttonStyle.margins.right = 4;
+		buttonStyle.margins.top = 4;
+		buttonStyle.margins.bottom = 4;
 		buttonStyle.fixedHeight = true;
 		buttonStyle.height = 21;
 		buttonStyle.minWidth = 10;

+ 2 - 2
BansheeEngine/Source/BsGUIButton.cpp

@@ -113,7 +113,7 @@ namespace BansheeEngine
 	{
 		if(ev.getType() == GUIMouseEventType::MouseOver)
 		{
-			mDesc.texture = mStyle->normal.texture;
+			mDesc.texture = mStyle->hover.texture;
 			markAsDirty();
 			// TODO - What happens when a texture is not set?
 			// 
@@ -121,7 +121,7 @@ namespace BansheeEngine
 		}
 		else if(ev.getType() == GUIMouseEventType::MouseOut)
 		{
-			mDesc.texture = mStyle->hover.texture;
+			mDesc.texture = mStyle->normal.texture;
 			markAsDirty();
 			// TODO - What happens when a texture is not set?
 

+ 12 - 0
BansheeEngine/Source/BsGUIElement.cpp

@@ -79,6 +79,18 @@ namespace BansheeEngine
 		markAsDirty();
 	}
 
+	const Rect GUIElement::_getContentBounds() const
+	{
+		Rect bounds = _getBounds();
+		
+		bounds.x += mStyle->margins.left;
+		bounds.y += mStyle->margins.top;
+		bounds.width = (UINT32)std::max(0, (INT32)bounds.width - (INT32)(mStyle->margins.left + mStyle->margins.right));
+		bounds.height = (UINT32)std::max(0, (INT32)bounds.height - (INT32)(mStyle->margins.top + mStyle->margins.bottom));
+
+		return bounds;
+	}
+
 	void GUIElement::markAsDirty() 
 	{ 
 		if(!mIsDirty)

+ 1 - 1
BansheeEngine/Source/BsGUIManager.cpp

@@ -450,7 +450,7 @@ namespace BansheeEngine
 					for(auto iter = sortedElements.begin(); iter != sortedElements.end(); ++iter)
 					{
 						GUIElement* element = *iter;
-						const Rect& bounds = element->_getBounds();
+						const Rect& bounds = element->_getContentBounds();
 
 						if(bounds.contains(localPos) && element->_getDepth() < topMostDepth)
 						{

+ 1 - 1
CamelotClient/CamelotClient.cpp

@@ -281,7 +281,7 @@ int CALLBACK WinMain(
 	gMainSyncedRC().readSubresource(dbgCursor.getInternalPtr(), 0, *cursorPixelData);
 	gMainSyncedRC().submitToGpu(true);
 
-	Cursor::setCustomCursor(*cursorPixelData, Int2(0, 0));
+	//Cursor::setCustomCursor(*cursorPixelData, Int2(0, 0));
 
 	dbgCursor.reset();