* Don't set an explicit max size, instead calculate a proper max size in
MaxSize(). This makes sure that MaxSize() returns a proper size when the user "unsets" the explicite max size. * minimum label height is 0 if there is no label. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27583 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -93,7 +93,7 @@ class BMenuField : public BView {
|
||||
protected:
|
||||
virtual void DoLayout();
|
||||
|
||||
private:
|
||||
private:
|
||||
class LabelLayoutItem;
|
||||
class MenuBarLayoutItem;
|
||||
struct LayoutData;
|
||||
|
||||
@@ -673,7 +673,11 @@ BMenuField::MaxSize()
|
||||
CALLED();
|
||||
|
||||
_ValidateLayoutData();
|
||||
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), fLayoutData->min);
|
||||
|
||||
BSize max = fLayoutData->min;
|
||||
max.width = B_SIZE_UNLIMITED;
|
||||
|
||||
return BLayoutUtils::ComposeSize(ExplicitMaxSize(), max);
|
||||
}
|
||||
|
||||
|
||||
@@ -811,9 +815,6 @@ BMenuField::InitObject(const char *label)
|
||||
fDivider = (float)floor(Frame().Width() / 2.0f);
|
||||
else
|
||||
fDivider = 0;
|
||||
|
||||
// default to unlimited maximum width
|
||||
SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
}
|
||||
|
||||
|
||||
@@ -998,8 +999,13 @@ BMenuField::_ValidateLayoutData()
|
||||
font_height& fh = fLayoutData->font_info;
|
||||
GetFontHeight(&fh);
|
||||
|
||||
fLayoutData->label_width = (Label() ? ceilf(StringWidth(Label())) : 0);
|
||||
fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent);
|
||||
if (Label() != NULL) {
|
||||
fLayoutData->label_width = ceilf(StringWidth(Label()));
|
||||
fLayoutData->label_height = ceilf(fh.ascent) + ceilf(fh.descent);
|
||||
} else {
|
||||
fLayoutData->label_width = 0;
|
||||
fLayoutData->label_height = 0;
|
||||
}
|
||||
|
||||
// compute the minimal divider
|
||||
float divider = 0;
|
||||
@@ -1138,7 +1144,7 @@ BMenuField::MenuBarLayoutItem::MenuBarLayoutItem(BMenuField* parent)
|
||||
: fParent(parent),
|
||||
fFrame()
|
||||
{
|
||||
// by default the part left of the divider shall have an unlimited maximum
|
||||
// by default the part right of the divider shall have an unlimited maximum
|
||||
// width
|
||||
SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user