From 0b1db200dfa7afd69c576aa1db9093a8db753b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 3 Aug 2009 14:35:27 +0000 Subject: [PATCH] * The preferred size is now actually the preferred size - the size that is needed to show all of the text view's contents. No idea what the previous solution was about. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32075 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index ec819887c4..29d60590d6 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -2797,9 +2797,19 @@ BTextView::_ValidateLayoutData() fLayoutData->min = min; // compute our preferred size - fLayoutData->preferred = min; - fLayoutData->preferred.width += lineHeight * 6; - fLayoutData->preferred.height += lineHeight * 2; + fLayoutData->preferred.height = fTextRect.Height() + + fLayoutData->topInset + fLayoutData->bottomInset; + float maxWidth = 0; + for (int i = 0; i < fLines->NumLines(); i++) { + float width = LineWidth(0); + if (maxWidth < width) + maxWidth = width; + } + if (maxWidth < min.width) + maxWidth = min.width; + + fLayoutData->preferred.width + = maxWidth + fLayoutData->leftInset + fLayoutData->rightInset; fLayoutData->valid = true;