mirror of
https://review.haiku-os.org/haiku
synced 2025-02-01 03:06:08 +01:00
Shortcut characters are aligned even if there's a submenu, like
discussed in the thread in haiku-development. I added a fSubmenus member to BMenu, to be able to tell from BMenuItem if there are other items with a submenu (maintained in BMenuItem::SetSuper()). If you don't like this solution, let's just revert. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21395 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fbe2f227ca
commit
37ddfd14ab
@ -292,7 +292,9 @@ static bool sAltAsCommandKey;
|
||||
BPoint *fInitMatrixSize;
|
||||
_ExtraMenuData_ *fExtraMenuData;
|
||||
|
||||
uint32 _reserved[2];
|
||||
uint32 _reserved[1];
|
||||
|
||||
int32 fSubmenus;
|
||||
|
||||
char fTrigger;
|
||||
bool fResizeToFit;
|
||||
|
@ -160,6 +160,7 @@ BMenu::BMenu(const char *name, menu_layout layout)
|
||||
fMaxContentWidth(0.0f),
|
||||
fInitMatrixSize(NULL),
|
||||
fExtraMenuData(NULL),
|
||||
fSubmenus(0),
|
||||
fTrigger(0),
|
||||
fResizeToFit(true),
|
||||
fUseCachedMenuLayout(false),
|
||||
@ -193,6 +194,7 @@ BMenu::BMenu(const char *name, float width, float height)
|
||||
fMaxContentWidth(0.0f),
|
||||
fInitMatrixSize(NULL),
|
||||
fExtraMenuData(NULL),
|
||||
fSubmenus(0),
|
||||
fTrigger(0),
|
||||
fResizeToFit(true),
|
||||
fUseCachedMenuLayout(false),
|
||||
@ -238,6 +240,7 @@ BMenu::BMenu(BMessage *archive)
|
||||
fMaxContentWidth(0.0f),
|
||||
fInitMatrixSize(NULL),
|
||||
fExtraMenuData(NULL),
|
||||
fSubmenus(0),
|
||||
fTrigger(0),
|
||||
fResizeToFit(true),
|
||||
fUseCachedMenuLayout(false),
|
||||
@ -983,6 +986,7 @@ BMenu::BMenu(BRect frame, const char *name, uint32 resizingMode, uint32 flags,
|
||||
fMaxContentWidth(0.0f),
|
||||
fInitMatrixSize(NULL),
|
||||
fExtraMenuData(NULL),
|
||||
fSubmenus(0),
|
||||
fTrigger(0),
|
||||
fResizeToFit(resizeToFit),
|
||||
fUseCachedMenuLayout(false),
|
||||
@ -1594,7 +1598,7 @@ BMenu::_ComputeColumnLayout(int32 index, bool bestFit, bool moveItems, BRect &fr
|
||||
item->fBounds.top = frame.bottom;
|
||||
item->fBounds.bottom = item->fBounds.top + iHeight + fPad.top + fPad.bottom;
|
||||
|
||||
if (item->fSubmenu != NULL)
|
||||
if (fSubmenus)
|
||||
iWidth += item->Frame().Height();
|
||||
|
||||
frame.right = max_c(frame.right, iWidth + fPad.left + fPad.right);
|
||||
|
@ -649,11 +649,16 @@ BMenuItem::SetSuper(BMenu *super)
|
||||
{
|
||||
if (fSuper != NULL && super != NULL)
|
||||
debugger("Error - can't add menu or menu item to more than 1 container (either menu or menubar).");
|
||||
|
||||
fSuper = super;
|
||||
|
||||
if (fSubmenu != NULL)
|
||||
if (fSubmenu != NULL) {
|
||||
if (super)
|
||||
super->fSubmenus++;
|
||||
else if (fSuper)
|
||||
fSuper->fSubmenus--;
|
||||
fSubmenu->fSuper = super;
|
||||
}
|
||||
|
||||
fSuper = super;
|
||||
}
|
||||
|
||||
|
||||
@ -708,12 +713,13 @@ BMenuItem::_DrawMarkSymbol(rgb_color bgColor)
|
||||
void
|
||||
BMenuItem::_DrawShortcutSymbol()
|
||||
{
|
||||
BMenu *menu = Menu();
|
||||
BFont font;
|
||||
Menu()->GetFont(&font);
|
||||
menu->GetFont(&font);
|
||||
BPoint where = ContentLocation();
|
||||
where.x += fBounds.Width() - 28;
|
||||
if (fSubmenu)
|
||||
where.x -= fBounds.Height();
|
||||
where.x = fBounds.right - font.Size();
|
||||
if (menu->fSubmenus)
|
||||
where.x -= fBounds.Height() - 4;
|
||||
|
||||
switch (fShortcutChar) {
|
||||
case B_DOWN_ARROW:
|
||||
@ -730,8 +736,8 @@ BMenuItem::_DrawShortcutSymbol()
|
||||
}
|
||||
|
||||
where.y += (fBounds.Height() - 11) / 2 - 1;
|
||||
where.x -= 5;
|
||||
|
||||
where.x -= 4;
|
||||
|
||||
if (fModifiers & B_COMMAND_KEY) {
|
||||
BRect rect(0,0,16,10);
|
||||
BBitmap control(rect, B_CMAP8);
|
||||
@ -775,6 +781,7 @@ BMenuItem::_DrawSubmenuSymbol(rgb_color bgColor)
|
||||
BRect r(fBounds);
|
||||
r.left = r.right - r.Height();
|
||||
r.InsetBy(2.0, 2.0);
|
||||
//r.OffsetBy(2.0, 0.0);
|
||||
|
||||
fSuper->SetHighColor(tint_color(bgColor, kLightBGTint));
|
||||
fSuper->FillRect(r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user