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

Fixed an issue where input box caret was causing the text to flicker up and down by one pixel on any input

BearishSun 10 лет назад
Родитель
Сommit
7edbbf4ef2
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      BansheeEngine/Source/BsGUIInputBox.cpp

+ 5 - 2
BansheeEngine/Source/BsGUIInputBox.cpp

@@ -956,8 +956,6 @@ namespace BansheeEngine
 		Vector2I caretPos = gGUIManager().getInputCaretTool()->getCaretPosition(textOffset);
 		UINT32 caretHeight = gGUIManager().getInputCaretTool()->getCaretHeight();
 		UINT32 caretWidth = 1;
-		INT32 caretRight = caretPos.x + (INT32)caretWidth;
-		INT32 caretBottom = caretPos.y + (INT32)caretHeight;
 
 		INT32 left = textOffset.x - mTextOffset.x;
 		// Include caret width here because we don't want to scroll if just the caret is outside the bounds
@@ -966,6 +964,11 @@ namespace BansheeEngine
 		INT32 top = textOffset.y - mTextOffset.y;
 		INT32 bottom = top + (INT32)textDesc.height;
 
+		// If caret is too high to display we don't want the offset to keep adjusting itself
+		caretHeight = std::min(caretHeight, (UINT32)(bottom - top));
+		INT32 caretRight = caretPos.x + (INT32)caretWidth;
+		INT32 caretBottom = caretPos.y + (INT32)caretHeight;
+
 		Vector2I offset;
 		if(caretPos.x < left)
 		{