* As with other controls, for BeOS compatibly behavior, don't shrink
a BTextView via GetPreferredSize() if it is large enough. (Have not confirmed this is necessary... gut feeling.) * Calculate a minimum line height even if the BTextView is empty yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27828 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2549,11 +2549,23 @@ BTextView::GetPreferredSize(float* _width, float* _height)
|
|||||||
|
|
||||||
_ValidateLayoutData();
|
_ValidateLayoutData();
|
||||||
|
|
||||||
if (_width)
|
if (_width) {
|
||||||
*_width = fLayoutData->min.width;
|
float width = Bounds().Width();
|
||||||
|
if (width < fLayoutData->min.width
|
||||||
|
|| (Flags() & B_SUPPORTS_LAYOUT) != 0) {
|
||||||
|
width = fLayoutData->min.width;
|
||||||
|
}
|
||||||
|
*_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
if (_height)
|
if (_height) {
|
||||||
*_height = fLayoutData->min.height;
|
float height = Bounds().Height();
|
||||||
|
if (height < fLayoutData->min.height
|
||||||
|
|| (Flags() & B_SUPPORTS_LAYOUT) != 0) {
|
||||||
|
height = fLayoutData->min.height;
|
||||||
|
}
|
||||||
|
*_height = height;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2673,6 +2685,19 @@ BTextView::_ValidateLayoutData()
|
|||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
float lineHeight = ceilf(LineHeight(0));
|
float lineHeight = ceilf(LineHeight(0));
|
||||||
|
if (lineHeight == 0.0) {
|
||||||
|
// We probably don't have text content yet. Take the initial
|
||||||
|
// style's font height or fall back to the plain font.
|
||||||
|
const BFont* font;
|
||||||
|
fStyles->GetNullStyle(&font, NULL);
|
||||||
|
if (font == NULL)
|
||||||
|
font = be_plain_font;
|
||||||
|
|
||||||
|
font_height fontHeight;
|
||||||
|
font->GetHeight(&fontHeight);
|
||||||
|
// This is how the height is calculated in _RecalculateLineBreaks().
|
||||||
|
lineHeight = ceilf(fontHeight.ascent + fontHeight.descent) + 1;
|
||||||
|
}
|
||||||
TRACE("line height: %.2f\n", lineHeight);
|
TRACE("line height: %.2f\n", lineHeight);
|
||||||
|
|
||||||
// compute our minimal size
|
// compute our minimal size
|
||||||
|
|||||||
Reference in New Issue
Block a user