BBox: fix minimal size when using layouted mode.

It is possible to set a custom layout on a BBox, which is then applied
to the children excluding the label. However, the label size must still
be used when computing the minimal size of the BBox in that case.
This commit is contained in:
Adrien Destugues 2014-12-15 11:12:56 +01:00
parent 04c56ae26b
commit 4696958aa4
1 changed files with 6 additions and 6 deletions

View File

@ -119,10 +119,10 @@ BBox::Archive(BMessage* archive, bool deep) const
status_t ret = BView::Archive(archive, deep); status_t ret = BView::Archive(archive, deep);
if (fLabel && ret == B_OK) if (fLabel && ret == B_OK)
ret = archive->AddString("_label", fLabel); ret = archive->AddString("_label", fLabel);
if (fLabelView && ret == B_OK) if (fLabelView && ret == B_OK)
ret = archive->AddBool("_lblview", true); ret = archive->AddBool("_lblview", true);
if (fStyle != B_FANCY_BORDER && ret == B_OK) if (fStyle != B_FANCY_BORDER && ret == B_OK)
ret = archive->AddInt32("_style", fStyle); ret = archive->AddInt32("_style", fStyle);
@ -516,6 +516,8 @@ BBox::MinSize()
_ValidateLayoutData(); _ValidateLayoutData();
BSize size = (GetLayout() ? GetLayout()->MinSize() : fLayoutData->min); BSize size = (GetLayout() ? GetLayout()->MinSize() : fLayoutData->min);
if (size.width < fLayoutData->min.width)
size.width = fLayoutData->min.width;
return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); return BLayoutUtils::ComposeSize(ExplicitMinSize(), size);
} }
@ -583,8 +585,7 @@ BBox::DoLayout()
// don't trigger a relayout // don't trigger a relayout
AddChild(fLabelView, ChildAt(0)); AddChild(fLabelView, ChildAt(0));
EnableLayoutInvalidation(); EnableLayoutInvalidation();
} else }
return;
} }
_ValidateLayoutData(); _ValidateLayoutData();
@ -828,9 +829,8 @@ BBox::_ValidateLayoutData()
BSize size = fLabelView->PreferredSize(); BSize size = fLabelView->PreferredSize();
fLayoutData->label_box.Set(10, 0, 10 + size.width, size.height); fLayoutData->label_box.Set(10, 0, 10 + size.width, size.height);
labelHeight = size.height + 1; labelHeight = size.height + 1;
} else { } else
label = false; label = false;
}
// border // border
switch (fStyle) { switch (fStyle) {