BMenu: Make margins/padding more HiDPI-aware.
This greatly improves the appearance of menus under font-scaled systems. The computations are written such that the margins should be unchanged under a 12pt font size.
This commit is contained in:
@@ -228,7 +228,6 @@ BMenu::BMenu(const char* name, menu_layout layout)
|
|||||||
:
|
:
|
||||||
BView(BRect(0, 0, 0, 0), name, 0, B_WILL_DRAW),
|
BView(BRect(0, 0, 0, 0), name, 0, B_WILL_DRAW),
|
||||||
fChosenItem(NULL),
|
fChosenItem(NULL),
|
||||||
fPad(std::max(14.0f, be_plain_font->Size() + 2.0f), 2.0f, 20.0f, 0.0f),
|
|
||||||
fSelected(NULL),
|
fSelected(NULL),
|
||||||
fCachedMenuWindow(NULL),
|
fCachedMenuWindow(NULL),
|
||||||
fSuper(NULL),
|
fSuper(NULL),
|
||||||
@@ -255,6 +254,9 @@ BMenu::BMenu(const char* name, menu_layout layout)
|
|||||||
fHasSubmenus(false),
|
fHasSubmenus(false),
|
||||||
fAttachAborted(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);
|
_InitData(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -741,9 +741,12 @@ BMenuBar::_RestoreFocus()
|
|||||||
void
|
void
|
||||||
BMenuBar::_InitData(menu_layout layout)
|
BMenuBar::_InitData(menu_layout layout)
|
||||||
{
|
{
|
||||||
|
const float fontSize = be_plain_font->Size();
|
||||||
|
float lr = fontSize * 2.0f / 3.0f, tb = fontSize / 6.0f;
|
||||||
|
SetItemMargins(lr, tb, lr, tb);
|
||||||
|
|
||||||
fBorders = BControlLook::B_ALL_BORDERS;
|
fBorders = BControlLook::B_ALL_BORDERS;
|
||||||
fLastBounds = new BRect(Bounds());
|
fLastBounds = new BRect(Bounds());
|
||||||
SetItemMargins(8.0f, 2.0f, 8.0f, 2.0f);
|
|
||||||
_SetIgnoreHidden(true);
|
_SetIgnoreHidden(true);
|
||||||
SetLowUIColor(B_MENU_BACKGROUND_COLOR);
|
SetLowUIColor(B_MENU_BACKGROUND_COLOR);
|
||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
|
|||||||
Reference in New Issue
Block a user