Author: zooey Date: 2010-04-11 16:13:57 +0200 (Sun, 11 Apr 2010) New Revision: 36153 Changeset: http://dev.haiku-os.org/changeset/36153/haiku Modified: haiku/trunk/headers/os/interface/TextView.h haiku/trunk/src/kits/interface/TextView.cpp Log: 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 Modified: haiku/trunk/headers/os/interface/TextView.h =================================================================== --- haiku/trunk/headers/os/interface/TextView.h 2010-04-11 13:56:44 UTC (rev 36152) +++ haiku/trunk/headers/os/interface/TextView.h 2010-04-11 14:13:57 UTC (rev 36153) @@ -336,7 +336,7 @@ void _RequestDrawLines(int32 startLine, int32 endLine); - void _DrawCaret(int32 offset); + void _DrawCaret(int32 offset, bool visible); void _ShowCaret(); void _HideCaret(); void _InvertCaret(); Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2010-04-11 13:56:44 UTC (rev 36152) +++ haiku/trunk/src/kits/interface/TextView.cpp 2010-04-11 14:13:57 UTC (rev 36153) @@ -4473,7 +4473,7 @@ Highlight(fSelStart, fSelEnd); } else { if (fCaretVisible) - _DrawCaret(fSelStart); + _DrawCaret(fSelStart, true); } } @@ -4512,7 +4512,7 @@ void -BTextView::_DrawCaret(int32 offset) +BTextView::_DrawCaret(int32 offset, bool visible) { float lineHeight; BPoint caretPoint = PointAt(offset, &lineHeight); @@ -4523,7 +4523,10 @@ caretRect.top = caretPoint.y; caretRect.bottom = caretPoint.y + lineHeight - 1; - InvertRect(caretRect); + if (visible) + InvertRect(caretRect); + else + Invalidate(caretRect); } @@ -4549,8 +4552,8 @@ void BTextView::_InvertCaret() { - _DrawCaret(fSelStart); fCaretVisible = !fCaretVisible; + _DrawCaret(fSelStart, fCaretVisible); fCaretTime = system_time(); } @@ -4568,7 +4571,7 @@ // hide the previous drag caret if (fDragOffset != -1) - _DrawCaret(fDragOffset); + _DrawCaret(fDragOffset, false); // do we have a new location? if (offset != -1) { @@ -4580,7 +4583,7 @@ } } - _DrawCaret(offset); + _DrawCaret(offset, true); } fDragOffset = offset;