Browse Source

Fixed an issue where scroll area suddenly wasn't big enough after a scrollbar was added, and the other scrollbar got messed up

Marko Pintera 12 years ago
parent
commit
ca02960035
1 changed files with 10 additions and 1 deletions
  1. 10 1
      BansheeEngine/Source/BsGUIScrollArea.cpp

+ 10 - 1
BansheeEngine/Source/BsGUIScrollArea.cpp

@@ -81,18 +81,27 @@ namespace BansheeEngine
 		bool hasScrollbars = false;
 		bool hasScrollbars = false;
 		Rect layoutClipRect = clipRect;
 		Rect layoutClipRect = clipRect;
 
 
+		bool hasHorzScrollbar = false;
 		if(contentWidth > mWidth)
 		if(contentWidth > mWidth)
 		{ 
 		{ 
 			// Make room for scrollbar
 			// Make room for scrollbar
 			mClippedContentHeight = (UINT32)std::max(0, (INT32)height - (INT32)ScrollBarWidth);
 			mClippedContentHeight = (UINT32)std::max(0, (INT32)height - (INT32)ScrollBarWidth);
 			layoutClipRect.height = mClippedContentHeight;
 			layoutClipRect.height = mClippedContentHeight;
+			hasHorzScrollbar = true;
 		}
 		}
 
 
-		if(contentHeight > mHeight)
+		if(contentHeight > mClippedContentHeight)
 		{
 		{
 			// Make room for scrollbar
 			// Make room for scrollbar
 			mClippedContentWidth = (UINT32)std::max(0, (INT32)width - (INT32)ScrollBarWidth);
 			mClippedContentWidth = (UINT32)std::max(0, (INT32)width - (INT32)ScrollBarWidth);
 			layoutClipRect.width = mClippedContentWidth;
 			layoutClipRect.width = mClippedContentWidth;
+
+			if(!hasHorzScrollbar && contentWidth > mClippedContentWidth) // Since width has been reduced, we need to check if we require the horizontal scrollbar
+			{
+				// Make room for scrollbar
+				mClippedContentHeight = (UINT32)std::max(0, (INT32)height - (INT32)ScrollBarWidth);
+				layoutClipRect.height = mClippedContentHeight;
+			}
 		}
 		}
 
 
 		// Add/remove/update vertical scrollbar as needed
 		// Add/remove/update vertical scrollbar as needed