Made double buffering a compile time option (disabled by default as there is some issues with it)

Made widthbuffer a compile time option (disabled by default).
Some minor changes.
Updated the "known bugs" section


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10225 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-11-25 11:00:50 +00:00
parent 12a8acf64d
commit 8b7faba29f
+46 -22
View File
@@ -35,14 +35,14 @@
// to refresh only changed parts of text (currently we often redraw the whole text) // to refresh only changed parts of text (currently we often redraw the whole text)
// Known Bugs: // Known Bugs:
// - visual artifacts appears when you highlight some text which spans between // - Line wrapping doesn't work well with multi byte charachters
// multiple lines and with mixed sizes/styles (could be something in GetTextRegion()) // - Andrew reported some issue with beshare in _BWidthBuffer_::HashEscapements()
// (that's why its use is disabled by default), though I couldn't reproduce it
// - Double buffering doesn't work well (disabled by default too)
// Standard Includes -----------------------------------------------------------
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
// System Includes -------------------------------------------------------------
#include <Application.h> #include <Application.h>
#include <Beep.h> #include <Beep.h>
#include <Bitmap.h> #include <Bitmap.h>
@@ -57,7 +57,6 @@
#include <TextView.h> #include <TextView.h>
#include <Window.h> #include <Window.h>
// Local Includes --------------------------------------------------------------
#include "InlineInput.h" #include "InlineInput.h"
#include "LineBuffer.h" #include "LineBuffer.h"
#include "StyleBuffer.h" #include "StyleBuffer.h"
@@ -65,7 +64,7 @@
#include "UndoBuffer.h" #include "UndoBuffer.h"
#include "WidthBuffer.h" #include "WidthBuffer.h"
// Local Defines ---------------------------------------------------------------
//#define TRACE_TEXTVIEW //#define TRACE_TEXTVIEW
#ifdef TRACE_TEXTVIEW #ifdef TRACE_TEXTVIEW
#define CALLED() printf("%s\n", __PRETTY_FUNCTION__) #define CALLED() printf("%s\n", __PRETTY_FUNCTION__)
@@ -74,10 +73,14 @@
#endif #endif
#define USE_WIDTHBUFFER 0
#define USE_DOUBLEBUFFERING 0
struct flattened_text_run { struct flattened_text_run {
int32 offset; int32 offset;
char family[64]; font_family family;
char style[64]; font_style style;
float size; float size;
float shear; /* typically 90.0 */ float shear; /* typically 90.0 */
uint16 face; /* typically 0 */ uint16 face; /* typically 0 */
@@ -1145,6 +1148,9 @@ BTextView::Insert(int32 startOffset, const char *inText, int32 inLength,
{ {
CALLED(); CALLED();
if (!fEditable)
return;
CancelInputMethod(); CancelInputMethod();
// do we really need to do anything? // do we really need to do anything?
@@ -1423,6 +1429,7 @@ void
BTextView::Clear() BTextView::Clear()
{ {
CALLED(); CALLED();
delete fUndo; delete fUndo;
fUndo = new _BClearUndoBuffer_(this); fUndo = new _BClearUndoBuffer_(this);
@@ -1570,7 +1577,12 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode,
const rgb_color *inColor) const rgb_color *inColor)
{ {
CALLED(); CALLED();
if (!fEditable)
return;
CancelInputMethod(); CancelInputMethod();
// hide the caret/unhilite the selection // hide the caret/unhilite the selection
if (fActive) { if (fActive) {
if (fSelStart != fSelEnd) if (fSelStart != fSelEnd)
@@ -1614,6 +1626,9 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset,
{ {
CALLED(); CALLED();
if (!fEditable)
return;
// hide the caret/unhilite the selection // hide the caret/unhilite the selection
if (fActive) { if (fActive) {
if (startOffset != endOffset) if (startOffset != endOffset)
@@ -1676,6 +1691,9 @@ BTextView::SetRunArray(int32 startOffset, int32 endOffset,
{ {
CALLED(); CALLED();
if (!fEditable)
return;
CancelInputMethod(); CancelInputMethod();
// pin offsets at reasonable values // pin offsets at reasonable values
@@ -1784,9 +1802,7 @@ BTextView::LineAt(BPoint point) const
BPoint BPoint
BTextView::PointAt(int32 inOffset, float *outHeight) const BTextView::PointAt(int32 inOffset, float *outHeight) const
{ {
// TODO: when alignment is != than B_ALIGN_LEFT, // TODO: Cleanup.
// this function's still a bit broken.
// Cleanup.
CALLED(); CALLED();
BPoint result; BPoint result;
@@ -2115,7 +2131,6 @@ BTextView::TextHeight(int32 startLine, int32 endLine) const
if (endLine > numLines - 1) if (endLine > numLines - 1)
endLine = numLines - 1; endLine = numLines - 1;
// TODO: This looks broken as well. What do we do if there's only one line ?
float height = (*fLines)[endLine + 1]->origin - (*fLines)[startLine]->origin; float height = (*fLines)[endLine + 1]->origin - (*fLines)[startLine]->origin;
if (endLine == numLines - 1 && (*fText)[fText->Length() - 1] == '\n') if (endLine == numLines - 1 && (*fText)[fText->Length() - 1] == '\n')
@@ -2751,6 +2766,9 @@ BTextView::InsertText(const char *inText, int32 inLength, int32 inOffset,
const text_run_array *inRuns) const text_run_array *inRuns)
{ {
CALLED(); CALLED();
if (!fEditable)
return;
// why add nothing? // why add nothing?
if (inLength < 1) if (inLength < 1)
return; return;
@@ -3615,13 +3633,15 @@ BTextView::StyledWidth(int32 fromOffset, int32 length, float *outAscent,
while ((numChars = fStyles->Iterate(fromOffset, length, fInline, &font, NULL, &ascent, &descent)) != 0) { while ((numChars = fStyles->Iterate(fromOffset, length, fInline, &font, NULL, &ascent, &descent)) != 0) {
maxAscent = max_c(ascent, maxAscent); maxAscent = max_c(ascent, maxAscent);
maxDescent = max_c(descent, maxDescent); maxDescent = max_c(descent, maxDescent);
// Use _BWidthBuffer_ if possible (TODO: reenable this when it's fixed) #if USE_WIDTHBUFFER
if (false && (sWidths != NULL)) { // Use _BWidthBuffer_ if possible
if (sWidths != NULL) {
LockWidthBuffer(); LockWidthBuffer();
result += sWidths->StringWidth(*fText, fromOffset, numChars, font); result += sWidths->StringWidth(*fText, fromOffset, numChars, font);
UnlockWidthBuffer(); UnlockWidthBuffer();
} else } else
#endif
result += font->StringWidth(fText->Text() + fromOffset, numChars); result += font->StringWidth(fText->Text() + fromOffset, numChars);
fromOffset += numChars; fromOffset += numChars;
@@ -3838,8 +3858,7 @@ void
BTextView::DrawCaret(int32 offset) BTextView::DrawCaret(int32 offset)
{ {
CALLED(); CALLED();
//long lineNum = LineAt(offset);
//STELinePtr line = (*fLines)[lineNum];
float lineHeight; float lineHeight;
BPoint caretPoint = PointAt(offset, &lineHeight); BPoint caretPoint = PointAt(offset, &lineHeight);
caretPoint.x = min_c(caretPoint.x, fTextRect.right); caretPoint.x = min_c(caretPoint.x, fTextRect.right);
@@ -3916,7 +3935,8 @@ BTextView::PerformMouseUp(BPoint where)
} }
bool BTextView::PerformMouseMoved(BPoint where, uint32 code) bool
BTextView::PerformMouseMoved(BPoint where, uint32 code)
{ {
CALLED(); CALLED();
return false; return false;
@@ -3936,7 +3956,7 @@ BTextView::TrackMouse(BPoint where, const BMessage *message, bool force)
BRegion textRegion; BRegion textRegion;
GetTextRegion(fSelStart, fSelEnd, &textRegion); GetTextRegion(fSelStart, fSelEnd, &textRegion);
if (AcceptsDrop(message)) if (message && AcceptsDrop(message))
TrackDrag(where); TrackDrag(where);
else if (!textRegion.Contains(where)) else if (!textRegion.Contains(where))
SetViewCursor(B_CURSOR_I_BEAM, force); SetViewCursor(B_CURSOR_I_BEAM, force);
@@ -4000,7 +4020,8 @@ bool
BTextView::MessageDropped(BMessage *inMessage, BPoint where, BPoint offset) BTextView::MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
{ {
CALLED(); CALLED();
ASSERT(inMessage);
void *from = NULL; void *from = NULL;
bool internalDrop = false; bool internalDrop = false;
if (inMessage->FindPointer("be:originator", &from) == B_OK if (inMessage->FindPointer("be:originator", &from) == B_OK
@@ -4115,7 +4136,8 @@ BTextView::NewOffscreen(float padding)
CALLED(); CALLED();
if (fOffscreen != NULL) if (fOffscreen != NULL)
DeleteOffscreen(); DeleteOffscreen();
#if USE_DOUBLEBUFFERING
BRect bitmapRect(0, 0, fTextRect.Width() + padding, fTextRect.Height()); BRect bitmapRect(0, 0, fTextRect.Width() + padding, fTextRect.Height());
fOffscreen = new BBitmap(bitmapRect, fColorSpace, true, false); fOffscreen = new BBitmap(bitmapRect, fColorSpace, true, false);
if (fOffscreen != NULL && fOffscreen->Lock()) { if (fOffscreen != NULL && fOffscreen->Lock()) {
@@ -4123,6 +4145,7 @@ BTextView::NewOffscreen(float padding)
fOffscreen->AddChild(bufferView); fOffscreen->AddChild(bufferView);
fOffscreen->Unlock(); fOffscreen->Unlock();
} }
#endif
} }
@@ -4176,7 +4199,8 @@ BTextView::Deactivate()
fActive = false; fActive = false;
CancelInputMethod(); CancelInputMethod();
DeleteOffscreen();
if (fSelStart != fSelEnd) { if (fSelStart != fSelEnd) {
if (fSelectable) if (fSelectable)
Highlight(fSelStart, fSelEnd); Highlight(fSelStart, fSelEnd);