We have submenus working (still not perfect, though)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10869 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1085,10 +1085,11 @@ BMenu::_hide()
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::_track(int *action, long start)
|
BMenu::_track(int *action, long start)
|
||||||
{
|
{
|
||||||
// TODO: Take Sticky mode into account, handle submenus
|
// TODO: Take Sticky mode into account
|
||||||
BPoint location;
|
BPoint location;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
BMenuItem *item = NULL;
|
BMenuItem *item = NULL;
|
||||||
|
int localAction = 0;
|
||||||
do {
|
do {
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
GetMouse(&location, &buttons);
|
GetMouse(&location, &buttons);
|
||||||
@@ -1102,9 +1103,29 @@ BMenu::_track(int *action, long start)
|
|||||||
// TODO: Sometimes the menu flickers a bit.
|
// TODO: Sometimes the menu flickers a bit.
|
||||||
// try to be smarter and suggest an update area,
|
// try to be smarter and suggest an update area,
|
||||||
// instead of invalidating the whole view.
|
// instead of invalidating the whole view.
|
||||||
if (item != NULL && item != fSelected) {
|
if (item != NULL) {
|
||||||
SelectItem(item);
|
if (item != fSelected) {
|
||||||
Invalidate();
|
SelectItem(item);
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
int submenuAction = 0;
|
||||||
|
BMenuItem *submenuItem = NULL;
|
||||||
|
// TODO: Review this as it doesn't work very well,
|
||||||
|
// BMenu::_track() isn't always called when needed.
|
||||||
|
if (item->Submenu() != NULL) {
|
||||||
|
UnlockLooper();
|
||||||
|
|
||||||
|
submenuItem = item->Submenu()->_track(&submenuAction);
|
||||||
|
if (submenuAction == 5) {
|
||||||
|
item = submenuItem;
|
||||||
|
localAction = submenuAction;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!LockLooper())
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
@@ -1117,13 +1138,16 @@ BMenu::_track(int *action, long start)
|
|||||||
// would be nice. Consider building an enum
|
// would be nice. Consider building an enum
|
||||||
// with the possible actions, and putting it in a
|
// with the possible actions, and putting it in a
|
||||||
// private, shared header (BMenuBar needs to know about them too).
|
// private, shared header (BMenuBar needs to know about them too).
|
||||||
if (action != NULL) {
|
if (localAction == 0) {
|
||||||
if (buttons != 0)
|
if (buttons != 0)
|
||||||
*action = 0;
|
localAction = 0;
|
||||||
else
|
else
|
||||||
*action = 5;
|
localAction = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action != NULL)
|
||||||
|
*action = localAction;
|
||||||
|
|
||||||
if (LockLooper()) {
|
if (LockLooper()) {
|
||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
|||||||
Reference in New Issue
Block a user