void TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage *message) { if (!message) { // force a cleanup fBarView->DragStop(true); BMenuBar::MouseMoved(where, code, message); return; } uint32 buttons; if (!(Window()->CurrentMessage()) || Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) < B_OK) buttons = 0; switch (code) { case B_ENTERED_VIEW: if (message && buttons != 0) { fBarView->CacheDragData(message); MouseDown(where); } break; case B_EXITED_VIEW: if (fBarView->Dragging() && buttons != 0) { if (!TeamItemAtPoint(where) && !InBeMenu(where) && (fSeparatorItem && !fSeparatorItem->Frame().Contains(where)) && !Frame().Contains(where)) { fBarView->DragStop(); } } break; } BMenuBar::MouseMoved(where, code, message); }
void TExpandoMenuBar::MouseDown(BPoint where) { BMessage* message = Window()->CurrentMessage(); BMenuItem* menuItem; TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); // check for three finger salute, a.k.a. Vulcan Death Grip if (message != NULL && item != NULL && !fBarView->Dragging()) { int32 modifiers = 0; message->FindInt32("modifiers", &modifiers); if ((modifiers & B_COMMAND_KEY) != 0 && (modifiers & B_CONTROL_KEY) != 0 && (modifiers & B_SHIFT_KEY) != 0) { const BList* teams = item->Teams(); int32 teamCount = teams->CountItems(); team_id teamID; for (int32 team = 0; team < teamCount; team++) { teamID = (team_id)teams->ItemAt(team); kill_team(teamID); // remove the team immediately from display RemoveTeam(teamID, false); } return; } // control click - show all/hide all shortcut if ((modifiers & B_CONTROL_KEY) != 0) { // show/hide item's teams BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 ? kMinimizeTeam : kBringTeamToFront); showMessage.AddInt32("itemIndex", IndexOf(item)); Window()->PostMessage(&showMessage, this); return; } // Check the bounds of the expand Team icon if (fShowTeamExpander && fVertical) { BRect expanderRect = item->ExpanderBounds(); if (expanderRect.Contains(where)) { // Let the update thread wait... BAutolock locker(sMonLocker); // Toggle the item item->ToggleExpandState(true); item->Draw(); // Absorb the message. return; } } // double-click on an item brings the team to front int32 clicks; if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 && item == menuItem && item == fLastClickItem) { // activate this team be_roster->ActivateApp((team_id)item->Teams()->ItemAt(0)); return; } fLastClickItem = item; } BMenuBar::MouseDown(where); }
void TExpandoMenuBar::MouseDown(BPoint where) { BMessage *message = Window()->CurrentMessage(); // check for three finger salute, a.k.a. Vulcan Death Grip if (message != NULL) { int32 modifiers = 0; message->FindInt32("modifiers", &modifiers); if ((modifiers & B_COMMAND_KEY) != 0 && (modifiers & B_OPTION_KEY) != 0 && (modifiers & B_SHIFT_KEY) != 0 && !fBarView->Dragging()) { TTeamMenuItem *item = TeamItemAtPoint(where); if (item != NULL) { const BList *teams = item->Teams(); int32 teamCount = teams->CountItems(); team_id teamID; for (int32 team = 0; team < teamCount; team++) { teamID = (team_id)teams->ItemAt(team); kill_team(teamID); // remove the team immediately // from display RemoveTeam(teamID, false); } return; } } } // This feature is broken because the menu bar never receives // the second click #ifdef DOUBLECLICKBRINGSTOFRONT // doubleclick on an item brings all to front for (int32 i = fFirstApp; i < count; i++) { TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(i); if (item->Frame().Contains(where)) { bigtime_t clickSpeed = 0; get_click_speed(&clickSpeed); if ( (fLastClickItem == i) && (clickSpeed > (system_time() - fLastClickTime)) ) { // bring this team's window to the front BMessage showMessage(M_BRING_TEAM_TO_FRONT); showMessage.AddInt32("itemIndex", i); Window()->PostMessage(&showMessage, this); return; } fLastClickItem = i; fLastClickTime = system_time(); break; } } #endif // control click - show all/hide all shortcut if (message != NULL) { int32 modifiers = 0; message->FindInt32("modifiers", &modifiers); if ((modifiers & B_CONTROL_KEY) != 0 && ! fBarView->Dragging()) { TTeamMenuItem *item = TeamItemAtPoint(where); if (item != NULL) { // show/hide item's teams BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 ? M_MINIMIZE_TEAM : M_BRING_TEAM_TO_FRONT); showMessage.AddInt32("itemIndex", IndexOf(item)); Window()->PostMessage(&showMessage, this); return; } } } // Check the bounds of the expand Team icon if (fShowTeamExpander && fVertical && !fBarView->Dragging()) { TTeamMenuItem *item = TeamItemAtPoint(where); if (item != NULL) { BRect expanderRect = item->ExpanderBounds(); if (expanderRect.Contains(where)) { // Let the update thread wait... BAutolock locker(sMonLocker); // Toggle the item item->ToggleExpandState(true); item->Draw(); // Absorb the message. return; } } } BMenuBar::MouseDown(where); }
void TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message) { int32 buttons; BMessage* currentMessage = Window()->CurrentMessage(); if (currentMessage == NULL || currentMessage->FindInt32("buttons", &buttons) != B_OK) { buttons = 0; } if (message == NULL) { // force a cleanup _FinishedDrag(); switch (code) { case B_INSIDE_VIEW: { BMenuItem* menuItem; TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); TWindowMenuItem* windowMenuItem = dynamic_cast<TWindowMenuItem*>(menuItem); if (item == NULL || menuItem == NULL) { // item is NULL, remove the tooltip and break out fLastMousedOverItem = NULL; SetToolTip((const char*)NULL); break; } if (menuItem == fLastMousedOverItem) { // already set the tooltip for this item, break out break; } if (windowMenuItem != NULL && fBarView->Vertical() && fBarView->ExpandoState() && item->IsExpanded()) { // expando mode window menu item fLastMousedOverItem = menuItem; if (strcasecmp(windowMenuItem->TruncatedLabel(), windowMenuItem->Label()) > 0) { // label is truncated, set tooltip SetToolTip(windowMenuItem->Label()); } else SetToolTip((const char*)NULL); break; } if (!dynamic_cast<TBarApp*>(be_app)->Settings()->hideLabels) { // item has a visible label, set tool tip if truncated fLastMousedOverItem = menuItem; if (strcasecmp(item->TruncatedLabel(), item->Label()) > 0) { // label is truncated, set tooltip SetToolTip(item->Label()); } else SetToolTip((const char*)NULL); break; } SetToolTip(item->Label()); // new item, set the tooltip to the item label fLastMousedOverItem = menuItem; // save the current menuitem for the next MouseMoved() call break; } } BMenuBar::MouseMoved(where, code, message); return; } if (buttons == 0) return; switch (code) { case B_ENTERED_VIEW: // fPreviousDragTargetItem should always be NULL here anyways. if (fPreviousDragTargetItem != NULL) _FinishedDrag(); fBarView->CacheDragData(message); fPreviousDragTargetItem = NULL; break; case B_OUTSIDE_VIEW: // NOTE: Should not be here, but for the sake of defensive // programming... fall-through case B_EXITED_VIEW: _FinishedDrag(); break; case B_INSIDE_VIEW: if (fBarView->Dragging()) { TTeamMenuItem* item = NULL; int32 itemCount = CountItems(); for (int32 i = 0; i < itemCount; i++) { BMenuItem* _item = ItemAt(i); if (_item->Frame().Contains(where)) { item = dynamic_cast<TTeamMenuItem*>(_item); break; } } if (item == fPreviousDragTargetItem) break; if (fPreviousDragTargetItem != NULL) fPreviousDragTargetItem->SetOverrideSelected(false); if (item != NULL) item->SetOverrideSelected(true); fPreviousDragTargetItem = item; } break; } }
void TExpandoMenuBar::MouseDown(BPoint where) { BMessage* message = Window()->CurrentMessage(); BMenuItem* menuItem; TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); if (message == NULL || item == NULL || fBarView->Dragging()) { BMenuBar::MouseDown(where); return; } int32 modifiers = 0; message->FindInt32("modifiers", &modifiers); // check for three finger salute, a.k.a. Vulcan Death Grip if ((modifiers & B_COMMAND_KEY) != 0 && (modifiers & B_CONTROL_KEY) != 0 && (modifiers & B_SHIFT_KEY) != 0) { const BList* teams = item->Teams(); int32 teamCount = teams->CountItems(); team_id teamID; for (int32 team = 0; team < teamCount; team++) { teamID = (addr_t)teams->ItemAt(team); kill_team(teamID); RemoveTeam(teamID, false); // remove the team from display immediately } return; // absorb the message } // control click - show all/hide all shortcut if ((modifiers & B_CONTROL_KEY) != 0) { // show/hide item's teams BMessage showMessage((modifiers & B_SHIFT_KEY) != 0 ? kMinimizeTeam : kBringTeamToFront); showMessage.AddInt32("itemIndex", IndexOf(item)); Window()->PostMessage(&showMessage, this); return; // absorb the message } // check if within expander bounds to expand window items if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando && item->ExpanderBounds().Contains(where)) { // start the animation here, finish on mouse up fLastClickedItem = item; MouseDownThread<TExpandoMenuBar>::TrackMouse(this, &TExpandoMenuBar::_DoneTracking, &TExpandoMenuBar::_Track); Invalidate(item->ExpanderBounds()); return; // absorb the message } // double-click on an item brings the team to front int32 clicks; if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 && item == menuItem && item == fLastClickedItem) { be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0)); // activate this team return; // absorb the message } fLastClickedItem = item; BMenuBar::MouseDown(where); }
void TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message) { if (message == NULL) { // force a cleanup _FinishedDrag(); switch (code) { case B_ENTERED_VIEW: case B_INSIDE_VIEW: { TTeamMenuItem* item = TeamItemAtPoint(where); if (item == NULL) { // item is NULL, break out fLastMousedOverItem = NULL; break; } if (item->HasLabel()) { // item has a visible label, set the item and break out fLastMousedOverItem = item; break; } if (item == fLastMousedOverItem) { // already set the tooltip for this item, break out break; } // new item, update the tooltip with the item name SetToolTip(item->Name()); // save the current item for the next MouseMoved() call fLastMousedOverItem = item; break; } case B_OUTSIDE_VIEW: case B_EXITED_VIEW: fLastMousedOverItem = NULL; break; } BMenuBar::MouseMoved(where, code, message); return; } uint32 buttons; if (Window()->CurrentMessage() == NULL || Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons) < B_OK) { buttons = 0; } if (buttons == 0) return; switch (code) { case B_ENTERED_VIEW: // fPreviousDragTargetItem should always be NULL here anyways. if (fPreviousDragTargetItem) _FinishedDrag(); fBarView->CacheDragData(message); fPreviousDragTargetItem = NULL; break; case B_OUTSIDE_VIEW: // NOTE: Should not be here, but for the sake of defensive // programming... case B_EXITED_VIEW: _FinishedDrag(); break; case B_INSIDE_VIEW: if (fBarView->Dragging()) { TTeamMenuItem* item = NULL; int32 itemCount = CountItems(); for (int32 i = 0; i < itemCount; i++) { BMenuItem* _item = ItemAt(i); if (_item->Frame().Contains(where)) { item = dynamic_cast<TTeamMenuItem*>(_item); break; } } if (item == fPreviousDragTargetItem) break; if (fPreviousDragTargetItem != NULL) fPreviousDragTargetItem->SetOverrideSelected(false); if (item != NULL) item->SetOverrideSelected(true); fPreviousDragTargetItem = item; } break; } }