From cb0165c41d9142e1c7343bfdaba9527ce72e7a01 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 25 Aug 2022 16:50:42 -0400 Subject: [PATCH] BMenu: Adjust padding computation logic. Instead of applying scaling factors to the font size, use the label spacing value instead. Also, perform the computation in _InitData(), which all constructors call, rather than in BMenu. --- src/kits/interface/Menu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index bfc7b1936e..eee774758f 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -254,9 +254,6 @@ BMenu::BMenu(const char* name, menu_layout layout) fHasSubmenus(false), fAttachAborted(false) { - const float fontSize = be_plain_font->Size(); - fPad = BRect(fontSize * 1.15f, fontSize / 6.0f, fontSize * 1.7f, 0.0f); - _InitData(NULL); } @@ -265,7 +262,6 @@ BMenu::BMenu(const char* name, float width, float height) : BView(BRect(0.0f, 0.0f, 0.0f, 0.0f), name, 0, B_WILL_DRAW), fChosenItem(NULL), - fPad(14.0f, 2.0f, 20.0f, 0.0f), fSelected(NULL), fCachedMenuWindow(NULL), fSuper(NULL), @@ -300,7 +296,6 @@ BMenu::BMenu(BMessage* archive) : BView(archive), fChosenItem(NULL), - fPad(14.0f, 2.0f, 20.0f, 0.0f), fSelected(NULL), fCachedMenuWindow(NULL), fSuper(NULL), @@ -1508,6 +1503,10 @@ BMenu::_InitData(BMessage* archive) fExtraMenuData = new (nothrow) BPrivate::ExtraMenuData(); + const float labelSpacing = be_control_look->DefaultLabelSpacing(); + fPad = BRect(ceilf(labelSpacing * 2.3f), ceilf(labelSpacing / 3.0f), + ceilf((labelSpacing / 3.0f) * 10.0f), 0.0f); + fLayoutData = new LayoutData; fLayoutData->lastResizingMode = ResizingMode();