diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
index f113e6a..d14b1df 100644
a
|
b
|
const int32 kDefaultRecentAppCount = 10;
|
67 | 67 | |
68 | 68 | const int32 kMenuTrackMargin = 20; |
69 | 69 | |
| 70 | BList TBarView::sExpandedItems; |
| 71 | |
| 72 | |
70 | 73 | TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, |
71 | 74 | bool showInterval, uint32 state, float, bool showTime) |
72 | 75 | : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), |
… |
… |
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
91 | 94 | fDragRegion->AddChild(fReplicantTray); |
92 | 95 | if (fTrayLocation != 0) |
93 | 96 | AddChild(fDragRegion); |
| 97 | |
| 98 | sExpandedItems.MakeEmpty(); |
94 | 99 | } |
95 | 100 | |
96 | 101 | |
… |
… |
TBarView::~TBarView()
|
98 | 103 | { |
99 | 104 | delete fDragMessage; |
100 | 105 | delete fCachedTypesList; |
| 106 | |
| 107 | // Clean up the expanded items list |
| 108 | while (!sExpandedItems.IsEmpty()) |
| 109 | delete static_cast<BString*>(sExpandedItems.RemoveItem((int32)0)); |
| 110 | sExpandedItems.MakeEmpty(); |
101 | 111 | } |
102 | 112 | |
103 | 113 | |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
445 | 455 | PlaceTray(vertSwap, leftSwap, screenFrame); |
446 | 456 | |
447 | 457 | // We need to keep track of what apps are expanded. |
448 | | BList expandedItems; |
449 | | BString* signature = NULL; |
450 | | if (fVertical && Expando() |
451 | | && static_cast<TBarApp*>(be_app)->Settings()->superExpando) { |
| 458 | SaveExpandedItems(); |
| 459 | |
| 460 | PlaceApplicationBar(screenFrame); |
| 461 | SizeWindow(screenFrame); |
| 462 | PositionWindow(screenFrame); |
| 463 | Window()->UpdateIfNeeded(); |
| 464 | |
| 465 | // Re-expand those apps. |
| 466 | ExpandItems(); |
| 467 | Invalidate(); |
| 468 | } |
| 469 | |
| 470 | |
| 471 | void |
| 472 | TBarView::SaveExpandedItems() |
| 473 | { |
| 474 | if (fExpando) { |
452 | 475 | // Get a list of the signatures of expanded apps. Can't use |
453 | 476 | // team_id because there can be more than one team per application |
454 | | if (fVertical && Expando() && vertical && fExpando) { |
455 | | for (int index = 0; index < fExpando->CountItems(); index++) { |
456 | | TTeamMenuItem* item |
457 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(index)); |
458 | | if (item != NULL && item->IsExpanded()) { |
459 | | signature = new BString(item->Signature()); |
460 | | expandedItems.AddItem((void*)signature); |
| 477 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 478 | TTeamMenuItem* teamItem |
| 479 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 480 | if (teamItem == NULL || teamItem->Signature() == NULL || |
| 481 | *teamItem->Signature() == '\0') |
| 482 | continue; |
| 483 | |
| 484 | if (teamItem->IsExpanded()) { |
| 485 | // Expanded, if signature is not in the list add it |
| 486 | bool shouldAdd = true; |
| 487 | for (int32 sigIndex = sExpandedItems.CountItems(); |
| 488 | sigIndex-- > 0;) { |
| 489 | BString *signature = |
| 490 | (BString *)sExpandedItems.ItemAt(sigIndex); |
| 491 | if (signature->ICompare(teamItem->Signature()) == 0) { |
| 492 | // already in the list, don't add the signature |
| 493 | shouldAdd = false; |
| 494 | break; |
| 495 | } |
| 496 | } |
| 497 | if (shouldAdd) { |
| 498 | // Add the signature to the list |
| 499 | BString* signature = new BString(teamItem->Signature()); |
| 500 | sExpandedItems.AddItem((void*)signature); |
461 | 501 | } |
462 | 502 | } |
463 | 503 | } |
464 | 504 | } |
| 505 | } |
465 | 506 | |
466 | | PlaceApplicationBar(screenFrame); |
467 | | SizeWindow(screenFrame); |
468 | | PositionWindow(screenFrame); |
469 | | Window()->UpdateIfNeeded(); |
470 | | |
471 | | // Re-expand those apps. |
472 | | if (expandedItems.CountItems() > 0) { |
473 | | for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) { |
474 | | signature = static_cast<BString*>(expandedItems.ItemAt(sigIndex)); |
475 | | if (signature == NULL) |
| 507 | void |
| 508 | TBarView::ExpandItems() |
| 509 | { |
| 510 | if (fExpando && sExpandedItems.CountItems() > 0 && fVertical && Expando() |
| 511 | && static_cast<TBarApp*>(be_app)->Settings()->superExpando) { |
| 512 | // Start at the 'bottom' of the list working up. |
| 513 | // Prevents being thrown off by expanding items. |
| 514 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 515 | TTeamMenuItem* teamItem |
| 516 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 517 | if (teamItem == NULL || teamItem->Signature() == NULL |
| 518 | || *teamItem->Signature() == '\0') |
476 | 519 | continue; |
477 | 520 | |
478 | | // Start at the 'bottom' of the list working up. |
479 | | // Prevents being thrown off by expanding items. |
480 | | for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
481 | | TTeamMenuItem* item |
482 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
483 | | if (item != NULL && !signature->Compare(item->Signature())) { |
484 | | item->ToggleExpandState(false); |
| 521 | for (int32 sigIndex = sExpandedItems.CountItems(); |
| 522 | sigIndex-- > 0;) { |
| 523 | BString* signature = |
| 524 | (BString *)sExpandedItems.ItemAt(sigIndex); |
| 525 | |
| 526 | if (signature->ICompare(teamItem->Signature()) == 0) { |
| 527 | teamItem->ToggleExpandState(false); |
| 528 | sExpandedItems.RemoveItem(sigIndex); |
485 | 529 | break; |
486 | 530 | } |
487 | 531 | } |
488 | 532 | } |
489 | 533 | |
490 | | // Clean up expanded signature list. |
491 | | while (!expandedItems.IsEmpty()) { |
492 | | delete static_cast<BString*>(expandedItems.RemoveItem((int32)0)); |
493 | | } |
| 534 | // Clean up the expanded items list |
| 535 | while (!sExpandedItems.IsEmpty()) |
| 536 | delete static_cast<BString*>(sExpandedItems.RemoveItem((int32)0)); |
| 537 | sExpandedItems.MakeEmpty(); |
494 | 538 | |
495 | 539 | fExpando->SizeWindow(); |
496 | 540 | } |
497 | | |
498 | | Invalidate(); |
499 | 541 | } |
500 | 542 | |
501 | 543 | |
diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
index a481445..4d29c6c 100644
a
|
b
|
class TBarView : public BView {
|
145 | 145 | void PlaceBeMenu(); |
146 | 146 | void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame); |
147 | 147 | void PlaceApplicationBar(BRect screenFrame); |
| 148 | void SaveExpandedItems(); |
| 149 | void ExpandItems(); |
148 | 150 | |
149 | 151 | TBarMenuBar* fBarMenuBar; |
150 | 152 | TExpandoMenuBar* fExpando; |
… |
… |
class TBarView : public BView {
|
171 | 173 | uint32 fMaxRecentApps; |
172 | 174 | |
173 | 175 | TTeamMenuItem* fLastDragItem; |
| 176 | static BList sExpandedItems; |
174 | 177 | }; |
175 | 178 | |
176 | 179 | |