Adjusted a bit BTextView::AutoResize() so that the text rect is more

centered. At least renaming a file in tracker looks a bit better now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22139 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-09-01 14:51:51 +00:00
parent 538abf58b3
commit b33a19a278
+7 -11
View File
@@ -3968,8 +3968,7 @@ BTextView::MessageDropped(BMessage *inMessage, BPoint where, BPoint offset)
ssize_t dataLen = 0; ssize_t dataLen = 0;
const char *text = NULL; const char *text = NULL;
if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &dataLen) == B_OK) { if (inMessage->FindData("text/plain", B_MIME_TYPE, (const void **)&text, &dataLen) == B_OK) {
text_run_array *runArray = NULL; text_run_array *runArray = NULL;
ssize_t runLen = 0; ssize_t runLen = 0;
if (fStylable) if (fStylable)
@@ -4083,27 +4082,24 @@ BTextView::UpdateScrollbars()
void void
BTextView::AutoResize(bool redraw) BTextView::AutoResize(bool redraw)
{ {
// TODO: Review this
if (fResizable) { if (fResizable) {
float oldWidth = Bounds().Width() + 1; float oldWidth = Bounds().Width() + 1;
float newWidth = 0; float newWidth = 3;
for (int32 i = 0; i < CountLines(); i++) for (int32 i = 0; i < CountLines(); i++)
newWidth += LineWidth(i); newWidth += LineWidth(i);
if (newWidth < 3) BRect newRect(0, 0, ceilf(newWidth), ceilf(LineHeight(0)) + 2);
newWidth = 3;
BRect newRect(0, 0, ceilf(newWidth) + 1, ceilf(TextHeight(0, 0)) + 1);
if (fContainerView != NULL) { if (fContainerView != NULL) {
fContainerView->ResizeTo(newRect.Width(), newRect.Height()); fContainerView->ResizeTo(newRect.Width() + 1, newRect.Height());
if (fAlignment == B_ALIGN_CENTER) if (fAlignment == B_ALIGN_CENTER)
fContainerView->MoveBy((oldWidth - newRect.Width()) / 2, 0); fContainerView->MoveBy(ceilf((oldWidth - (newRect.Width() + 1)) / 2), 0);
else if (fAlignment == B_ALIGN_RIGHT) else if (fAlignment == B_ALIGN_RIGHT)
fContainerView->MoveBy(oldWidth - newRect.Width(), 0); fContainerView->MoveBy(oldWidth - (newRect.Width() + 1), 0);
fContainerView->Invalidate(); fContainerView->Invalidate();
} }
fTextRect = newRect.InsetBySelf(1, 1); fTextRect = newRect.InsetBySelf(0, 1);
if (redraw) if (redraw)
DrawLines(0, 0); DrawLines(0, 0);