Refactor TExpandoMenuBar::MouseDown() style.

No functional change intended.
* Check for NULL fields in the beginning and return decreasing the
  indent level of the rest of the method.
* Move some comments to next line indented
This commit is contained in:
John Scipione
2013-02-24 04:36:58 -05:00
parent da179153e8
commit 88571c9241
+16 -16
View File
@@ -337,26 +337,29 @@ TExpandoMenuBar::MouseDown(BPoint where)
BMenuItem* menuItem; BMenuItem* menuItem;
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem); TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);
// check for three finger salute, a.k.a. Vulcan Death Grip if (message == NULL || item == NULL || fBarView->Dragging()) {
if (message != NULL && item != NULL && !fBarView->Dragging()) { BMenuBar::MouseDown(where);
return;
}
int32 modifiers = 0; int32 modifiers = 0;
message->FindInt32("modifiers", &modifiers); message->FindInt32("modifiers", &modifiers);
// check for three finger salute, a.k.a. Vulcan Death Grip
if ((modifiers & B_COMMAND_KEY) != 0 if ((modifiers & B_COMMAND_KEY) != 0
&& (modifiers & B_CONTROL_KEY) != 0 && (modifiers & B_CONTROL_KEY) != 0
&& (modifiers & B_SHIFT_KEY) != 0) { && (modifiers & B_SHIFT_KEY) != 0) {
const BList* teams = item->Teams(); const BList* teams = item->Teams();
int32 teamCount = teams->CountItems(); int32 teamCount = teams->CountItems();
team_id teamID; team_id teamID;
for (int32 team = 0; team < teamCount; team++) { for (int32 team = 0; team < teamCount; team++) {
teamID = (addr_t)teams->ItemAt(team); teamID = (addr_t)teams->ItemAt(team);
kill_team(teamID); kill_team(teamID);
// remove the team immediately from display
RemoveTeam(teamID, false); RemoveTeam(teamID, false);
// remove the team from display immediately
} }
return; return;
// absorb the message
} }
// control click - show all/hide all shortcut // control click - show all/hide all shortcut
@@ -367,21 +370,19 @@ TExpandoMenuBar::MouseDown(BPoint where)
showMessage.AddInt32("itemIndex", IndexOf(item)); showMessage.AddInt32("itemIndex", IndexOf(item));
Window()->PostMessage(&showMessage, this); Window()->PostMessage(&showMessage, this);
return; return;
// absorb the message
} }
// Check the bounds of the expand Team icon // Check the bounds of the expand Team icon
if (fShowTeamExpander && fVertical) { if (fVertical && fShowTeamExpander) {
BRect expanderRect = item->ExpanderBounds(); if (item->ExpanderBounds().Contains(where)) {
if (expanderRect.Contains(where)) {
// Let the update thread wait...
BAutolock locker(sMonLocker); BAutolock locker(sMonLocker);
// let the update thread wait...
// Toggle the item
item->ToggleExpandState(true); item->ToggleExpandState(true);
// toggle the item
item->Draw(); item->Draw();
// Absorb the message.
return; return;
// absorb the message
} }
} }
@@ -389,14 +390,13 @@ TExpandoMenuBar::MouseDown(BPoint where)
int32 clicks; int32 clicks;
if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1 if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1
&& item == menuItem && item == fLastClickItem) { && item == menuItem && item == fLastClickItem) {
// activate this team
be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0)); be_roster->ActivateApp((addr_t)item->Teams()->ItemAt(0));
// activate this team
return; return;
// absorb the message
} }
fLastClickItem = item; fLastClickItem = item;
}
BMenuBar::MouseDown(where); BMenuBar::MouseDown(where);
} }