some more work on menus... fixed bug #953 and some more stuff

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19827 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2007-01-16 14:43:01 +00:00
parent 0013964388
commit ebd1a3a130
3 changed files with 32 additions and 17 deletions
+12 -4
View File
@@ -1321,9 +1321,11 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
} }
if (fSuper != NULL) { if (fSuper != NULL) {
// Give supermenu the chance to continue tracking
*action = fState; *action = fState;
if (locked) if (locked)
UnlockLooper(); UnlockLooper();
return NULL; return NULL;
} }
} }
@@ -1349,7 +1351,7 @@ BMenu::_track(int *action, bigtime_t trackTime, long start)
if (IsStickyMode()) if (IsStickyMode())
SetStickyMode(false); SetStickyMode(false);
// delete the menu window recycled for all the child menus // delete the menu window recycled for all the child menus
DeleteMenuWindow(); DeleteMenuWindow();
@@ -1770,7 +1772,13 @@ BMenu::DrawItems(BRect updateRect)
int int
BMenu::State(BMenuItem **item) const BMenu::State(BMenuItem **item) const
{ {
return 0; if (fState == MENU_STATE_TRACKING || fState == MENU_STATE_CLOSED)
return fState;
if (fSelected != NULL && fSelected->Submenu() != NULL)
return fSelected->Submenu()->State(item);
return fState;
} }
@@ -1933,7 +1941,7 @@ BMenu::_SelectItem(BMenuItem* menuItem, bool showSubmenu, bool selectFirstItem)
fSelected->Select(false); fSelected->Select(false);
BMenu *subMenu = fSelected->Submenu(); BMenu *subMenu = fSelected->Submenu();
if (subMenu != NULL && subMenu->Window() != NULL) if (subMenu != NULL && subMenu->Window() != NULL)
subMenu->_hide(); subMenu->_hide();
} }
fSelected = menuItem; fSelected = menuItem;
+19 -11
View File
@@ -382,7 +382,7 @@ BMenuBar::TrackTask(void *arg)
receive_data(&id, &data, sizeof(data)); receive_data(&id, &data, sizeof(data));
BMenuBar *menuBar = data.menuBar; BMenuBar *menuBar = data.menuBar;
if (data.useRect) if (data.useRect)
menuBar->fExtraRect = &data.rect; menuBar->fExtraRect = &data.rect;
menuBar->SetStickyMode(data.sticky); menuBar->SetStickyMode(data.sticky);
@@ -433,7 +433,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
BPoint where; BPoint where;
ulong buttons; ulong buttons;
GetMouse(&where, &buttons, true); GetMouse(&where, &buttons, true);
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN); BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
if (menuItem != NULL) { if (menuItem != NULL) {
// Select item if: // Select item if:
@@ -474,17 +474,24 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
menu->SetStickyMode(true); menu->SetStickyMode(true);
int localAction; int localAction;
fChosenItem = menu->_track(&localAction, system_time()); fChosenItem = menu->_track(&localAction, system_time());
if (menu->State(NULL) == MENU_STATE_TRACKING && menu->IsStickyMode())
menu->SetStickyMode(false);
// check if the user started holding down a mouse button in a submenu // check if the user started holding down a mouse button in a submenu
if (wasSticky && !IsStickyMode()) if (wasSticky && !IsStickyMode())
buttons = 1; buttons = 1;
// buttons must have been pressed in the meantime // buttons must have been pressed in the meantime
if (localAction == MENU_STATE_CLOSED) {
if (fExtraRect != NULL && fExtraRect->Contains(where)) {
SetStickyMode(true);
fExtraRect = NULL;
} else
fState = MENU_STATE_CLOSED;
}
if (localAction == MENU_STATE_CLOSED) } else if (menuItem == NULL && fSelected != NULL
fState = MENU_STATE_CLOSED; && !IsStickyMode() /*&& Bounds().Contains(where)*/ && fState != MENU_STATE_TRACKING_SUBMENU) {
} else if (menuItem == NULL && fSelected != NULL
&& !IsStickyMode() && fState != MENU_STATE_TRACKING_SUBMENU) {
_SelectItem(NULL); _SelectItem(NULL);
fState = MENU_STATE_TRACKING; fState = MENU_STATE_TRACKING;
} }
@@ -506,10 +513,11 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
if (snoozeAmount > 0) if (snoozeAmount > 0)
snooze(snoozeAmount); snooze(snoozeAmount);
} }
if (window->Lock()) { if (window->Lock()) {
if (fSelected != NULL) if (fSelected != NULL)
_SelectItem(NULL); _SelectItem(NULL);
if (fChosenItem != NULL) if (fChosenItem != NULL)
fChosenItem->Invoke(); fChosenItem->Invoke();
RestoreFocus(); RestoreFocus();
@@ -534,7 +542,7 @@ BMenuBar::StealFocus()
// We already stole the focus, don't do anything // We already stole the focus, don't do anything
if (fPrevFocusToken != -1) if (fPrevFocusToken != -1)
return; return;
BWindow *window = Window(); BWindow *window = Window();
if (window != NULL && window->Lock()) { if (window != NULL && window->Lock()) {
BView *focus = window->CurrentFocus(); BView *focus = window->CurrentFocus();
+1 -2
View File
@@ -282,8 +282,7 @@ BMenuField::MouseDown(BPoint where)
fMenuBar->StartMenuBar(-1, false, true, &bounds); fMenuBar->StartMenuBar(-1, false, true, &bounds);
fMenuTaskID = spawn_thread((thread_func)MenuTask, "_m_task_", fMenuTaskID = spawn_thread((thread_func)MenuTask, "_m_task_", B_NORMAL_PRIORITY, this);
B_NORMAL_PRIORITY, this);
if (fMenuTaskID) if (fMenuTaskID)
resume_thread(fMenuTaskID); resume_thread(fMenuTaskID);
} }