From 08edea662badba1b3ef30ad22414e53de28beca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 16 Sep 2008 10:45:27 +0000 Subject: [PATCH] * 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 --- headers/os/interface/MenuField.h | 2 +- src/kits/interface/MenuField.cpp | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h index 13e8bf51ea..70bf7a6746 100644 --- a/headers/os/interface/MenuField.h +++ b/headers/os/interface/MenuField.h @@ -93,7 +93,7 @@ class BMenuField : public BView { protected: virtual void DoLayout(); - private: +private: class LabelLayoutItem; class MenuBarLayoutItem; struct LayoutData; diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index ad801e4439..eef16b2c8c 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -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)); }