fix drawing artefacts when the caret is being clipped, which lead

to parts of the caret being inverted:
* instead of always inverting the caret rect, we now invalidate when the
  caret should be hidden



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2010-04-11 14:13:57 +00:00
parent 2365cde279
commit 575625f155
2 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -336,7 +336,7 @@ private:
void _RequestDrawLines(int32 startLine, void _RequestDrawLines(int32 startLine,
int32 endLine); int32 endLine);
void _DrawCaret(int32 offset); void _DrawCaret(int32 offset, bool visible);
void _ShowCaret(); void _ShowCaret();
void _HideCaret(); void _HideCaret();
void _InvertCaret(); void _InvertCaret();
+9 -6
View File
@@ -4473,7 +4473,7 @@ BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset,
Highlight(fSelStart, fSelEnd); Highlight(fSelStart, fSelEnd);
} else { } else {
if (fCaretVisible) if (fCaretVisible)
_DrawCaret(fSelStart); _DrawCaret(fSelStart, true);
} }
} }
@@ -4512,7 +4512,7 @@ BTextView::_RequestDrawLines(int32 startLine, int32 endLine)
void void
BTextView::_DrawCaret(int32 offset) BTextView::_DrawCaret(int32 offset, bool visible)
{ {
float lineHeight; float lineHeight;
BPoint caretPoint = PointAt(offset, &lineHeight); BPoint caretPoint = PointAt(offset, &lineHeight);
@@ -4523,7 +4523,10 @@ BTextView::_DrawCaret(int32 offset)
caretRect.top = caretPoint.y; caretRect.top = caretPoint.y;
caretRect.bottom = caretPoint.y + lineHeight - 1; caretRect.bottom = caretPoint.y + lineHeight - 1;
InvertRect(caretRect); if (visible)
InvertRect(caretRect);
else
Invalidate(caretRect);
} }
@@ -4549,8 +4552,8 @@ BTextView::_HideCaret()
void void
BTextView::_InvertCaret() BTextView::_InvertCaret()
{ {
_DrawCaret(fSelStart);
fCaretVisible = !fCaretVisible; fCaretVisible = !fCaretVisible;
_DrawCaret(fSelStart, fCaretVisible);
fCaretTime = system_time(); fCaretTime = system_time();
} }
@@ -4568,7 +4571,7 @@ BTextView::_DragCaret(int32 offset)
// hide the previous drag caret // hide the previous drag caret
if (fDragOffset != -1) if (fDragOffset != -1)
_DrawCaret(fDragOffset); _DrawCaret(fDragOffset, false);
// do we have a new location? // do we have a new location?
if (offset != -1) { if (offset != -1) {
@@ -4580,7 +4583,7 @@ BTextView::_DragCaret(int32 offset)
} }
} }
_DrawCaret(offset); _DrawCaret(offset, true);
} }
fDragOffset = offset; fDragOffset = offset;