implemented sticky mode. Let's see how many complaints because it's not perfect at all. Under qemu it's super crappy btw
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17041 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1c9a35ac19
commit
c51421cc0b
@ -1138,7 +1138,7 @@ BMenu::_hide()
|
|||||||
BMenuItem *
|
BMenuItem *
|
||||||
BMenu::_track(int *action, long start)
|
BMenu::_track(int *action, long start)
|
||||||
{
|
{
|
||||||
// TODO: Take Sticky mode into account, cleanup
|
// TODO: cleanup
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
BMenuItem *item = NULL;
|
BMenuItem *item = NULL;
|
||||||
int localAction = MENU_ACT_NONE;
|
int localAction = MENU_ACT_NONE;
|
||||||
@ -1146,13 +1146,27 @@ BMenu::_track(int *action, long start)
|
|||||||
bigtime_t startTime = system_time();
|
bigtime_t startTime = system_time();
|
||||||
bigtime_t delay = 200000; // TODO: Test and reduce if needed.
|
bigtime_t delay = 200000; // TODO: Test and reduce if needed.
|
||||||
|
|
||||||
do {
|
bool okay = true;
|
||||||
if (!LockLooper())
|
while (true) {
|
||||||
|
bool locked = LockLooper();
|
||||||
|
if (!locked)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
bigtime_t snoozeAmount = 50000;
|
bigtime_t snoozeAmount = 50000;
|
||||||
BPoint location;
|
BPoint location;
|
||||||
GetMouse(&location, &buttons, false);
|
GetMouse(&location, &buttons, false);
|
||||||
|
|
||||||
|
if (localAction == MENU_ACT_CLOSE || (buttons != 0 && IsStickyMode())) {
|
||||||
|
UnlockLooper();
|
||||||
|
break;
|
||||||
|
} else if (buttons == 0) {
|
||||||
|
if (IsStickyPrefOn())
|
||||||
|
SetStickyMode(true);
|
||||||
|
else {
|
||||||
|
UnlockLooper();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
BPoint screenLocation = ConvertToScreen(location);
|
BPoint screenLocation = ConvertToScreen(location);
|
||||||
item = HitTestItems(location, B_ORIGIN);
|
item = HitTestItems(location, B_ORIGIN);
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
@ -1169,6 +1183,9 @@ BMenu::_track(int *action, long start)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (OverSuper(screenLocation)) {
|
if (OverSuper(screenLocation)) {
|
||||||
|
okay = false;
|
||||||
|
localAction = MENU_ACT_NONE;
|
||||||
|
item = NULL;
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1178,7 +1195,7 @@ BMenu::_track(int *action, long start)
|
|||||||
|
|
||||||
if (fSelected != NULL && OverSubmenu(fSelected, screenLocation)) {
|
if (fSelected != NULL && OverSubmenu(fSelected, screenLocation)) {
|
||||||
UnlockLooper();
|
UnlockLooper();
|
||||||
|
locked = false;
|
||||||
int submenuAction = MENU_ACT_NONE;
|
int submenuAction = MENU_ACT_NONE;
|
||||||
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction);
|
BMenuItem *submenuItem = fSelected->Submenu()->_track(&submenuAction);
|
||||||
if (submenuAction == MENU_ACT_CLOSE) {
|
if (submenuAction == MENU_ACT_CLOSE) {
|
||||||
@ -1186,17 +1203,15 @@ BMenu::_track(int *action, long start)
|
|||||||
localAction = submenuAction;
|
localAction = submenuAction;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LockLooper())
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockLooper();
|
if (locked)
|
||||||
|
UnlockLooper();
|
||||||
|
|
||||||
snooze(snoozeAmount);
|
snooze(snoozeAmount);
|
||||||
} while (buttons != 0);
|
}
|
||||||
|
|
||||||
if (localAction == MENU_ACT_NONE) {
|
if (localAction == MENU_ACT_NONE && okay) {
|
||||||
if (buttons != 0)
|
if (buttons != 0)
|
||||||
localAction = MENU_ACT_NONE;
|
localAction = MENU_ACT_NONE;
|
||||||
else
|
else
|
||||||
@ -1878,9 +1893,12 @@ BMenu::OkToProceed(BMenuItem* item)
|
|||||||
BPoint where;
|
BPoint where;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
GetMouse(&where, &buttons, false);
|
GetMouse(&where, &buttons, false);
|
||||||
// Quit if user releases the mouse button or moves
|
// Quit if user releases the mouse button (in nonsticky mode)
|
||||||
// the pointer over another item
|
// or click the mouse button (in sticky mode)
|
||||||
if (buttons == 0 || HitTestItems(where) != item)
|
// or moves the pointer over another item
|
||||||
|
if ((buttons == 0 && !IsStickyMode())
|
||||||
|
|| (buttons != 0 && IsStickyMode())
|
||||||
|
|| HitTestItems(where) != item)
|
||||||
proceed = false;
|
proceed = false;
|
||||||
|
|
||||||
return proceed;
|
return proceed;
|
||||||
|
@ -390,7 +390,6 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
BPoint where;
|
BPoint where;
|
||||||
ulong buttons;
|
ulong buttons;
|
||||||
GetMouse(&where, &buttons);
|
GetMouse(&where, &buttons);
|
||||||
|
|
||||||
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
BMenuItem *menuItem = HitTestItems(where, B_ORIGIN);
|
||||||
if (menuItem != NULL && menuItem != fSelected) {
|
if (menuItem != NULL && menuItem != fSelected) {
|
||||||
// only select the item
|
// only select the item
|
||||||
@ -408,7 +407,7 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
BMenu *menu = fSelected->Submenu();
|
BMenu *menu = fSelected->Submenu();
|
||||||
if (menu != NULL) {
|
if (menu != NULL) {
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
if (IsStickyPrefOn())
|
if (IsStickyMode())
|
||||||
menu->SetStickyMode(true);
|
menu->SetStickyMode(true);
|
||||||
snoozeAmount = 0;
|
snoozeAmount = 0;
|
||||||
resultItem = menu->_track(&localAction);
|
resultItem = menu->_track(&localAction);
|
||||||
@ -419,9 +418,15 @@ BMenuBar::Track(int32 *action, int32 startIndex, bool showMenu)
|
|||||||
SelectItem(NULL);
|
SelectItem(NULL);
|
||||||
|
|
||||||
window->Unlock();
|
window->Unlock();
|
||||||
|
|
||||||
if (localAction == MENU_ACT_CLOSE || buttons == 0)
|
if (localAction == MENU_ACT_CLOSE || (buttons != 0 && IsStickyMode()))
|
||||||
break;
|
break;
|
||||||
|
else if (buttons == 0) {
|
||||||
|
if (IsStickyPrefOn())
|
||||||
|
SetStickyMode(true);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (snoozeAmount > 0)
|
if (snoozeAmount > 0)
|
||||||
snooze(snoozeAmount);
|
snooze(snoozeAmount);
|
||||||
|
Loading…
Reference in New Issue
Block a user