diff --git src/apps/deskbar/BarApp.cpp src/apps/deskbar/BarApp.cpp
index 58664f7..ee02685 100644
|
|
TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
645 | 645 | |
646 | 646 | sBarTeamInfoList.AddItem(barInfo); |
647 | 647 | |
| 648 | // If expandNewTeams is set, add the sig to the expanded items list. |
| 649 | if (fSettings.expandNewTeams) |
| 650 | BarView()->AddExpandedItem(sig); |
| 651 | |
648 | 652 | int32 subsCount = sSubscribers.CountItems(); |
649 | 653 | if (subsCount > 0) { |
650 | 654 | for (int32 i = 0; i < subsCount; i++) { |
diff --git src/apps/deskbar/BarView.cpp src/apps/deskbar/BarView.cpp
index 6e71956..8a62149 100644
|
|
const int32 kDefaultRecentAppCount = 10;
|
68 | 68 | |
69 | 69 | const int32 kMenuTrackMargin = 20; |
70 | 70 | |
| 71 | BList TBarView::sExpandedItems; |
| 72 | |
| 73 | |
71 | 74 | TBarView::TBarView(BRect frame, bool vertical, bool left, bool top, |
72 | 75 | bool showInterval, uint32 state, float, bool showTime) |
73 | 76 | : BView(frame, "BarView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), |
… |
… |
TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
|
92 | 95 | fDragRegion->AddChild(fReplicantTray); |
93 | 96 | if (fTrayLocation != 0) |
94 | 97 | AddChild(fDragRegion); |
| 98 | |
| 99 | sExpandedItems.MakeEmpty(); |
| 100 | |
| 101 | // Add the Tracker to the list of expanded items so that it |
| 102 | // will be expanded on startup. |
| 103 | if (static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams) |
| 104 | AddExpandedItem(kTrackerSignature); |
95 | 105 | } |
96 | 106 | |
97 | 107 | |
… |
… |
TBarView::~TBarView()
|
99 | 109 | { |
100 | 110 | delete fDragMessage; |
101 | 111 | delete fCachedTypesList; |
| 112 | |
| 113 | // Clean up the expanded items list |
| 114 | while (!sExpandedItems.IsEmpty()) |
| 115 | delete static_cast<BString*>(sExpandedItems.RemoveItem((int32)0)); |
| 116 | sExpandedItems.MakeEmpty(); |
102 | 117 | } |
103 | 118 | |
104 | 119 | |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
529 | 544 | PlaceTray(vertSwap, leftSwap, screenFrame); |
530 | 545 | |
531 | 546 | // We need to keep track of what apps are expanded. |
532 | | BList expandedItems; |
533 | | BString* signature = NULL; |
534 | | if (fVertical && Expando() |
535 | | && static_cast<TBarApp*>(be_app)->Settings()->superExpando) { |
536 | | // Get a list of the signatures of expanded apps. Can't use |
537 | | // team_id because there can be more than one team per application |
538 | | if (fVertical && Expando() && vertical && fExpando) { |
539 | | for (int index = 0; index < fExpando->CountItems(); index++) { |
540 | | TTeamMenuItem* item |
541 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(index)); |
542 | | if (item != NULL && item->IsExpanded()) { |
543 | | signature = new BString(item->Signature()); |
544 | | expandedItems.AddItem((void*)signature); |
545 | | } |
546 | | } |
547 | | } |
548 | | } |
| 547 | SaveExpandedItems(); |
549 | 548 | |
550 | 549 | PlaceApplicationBar(screenFrame); |
551 | 550 | SizeWindow(screenFrame); |
… |
… |
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
|
553 | 552 | Window()->UpdateIfNeeded(); |
554 | 553 | |
555 | 554 | // Re-expand those apps. |
556 | | if (expandedItems.CountItems() > 0) { |
557 | | for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) { |
558 | | signature = static_cast<BString*>(expandedItems.ItemAt(sigIndex)); |
559 | | if (signature == NULL) |
560 | | continue; |
561 | | |
562 | | // Start at the 'bottom' of the list working up. |
563 | | // Prevents being thrown off by expanding items. |
564 | | for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
565 | | TTeamMenuItem* item |
566 | | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
567 | | if (item != NULL && !signature->Compare(item->Signature())) { |
568 | | item->ToggleExpandState(false); |
569 | | break; |
570 | | } |
571 | | } |
| 555 | ExpandItems(); |
| 556 | Invalidate(); |
| 557 | } |
| 558 | |
| 559 | |
| 560 | void |
| 561 | TBarView::SaveExpandedItems() |
| 562 | { |
| 563 | if (!fExpando) |
| 564 | return; |
| 565 | |
| 566 | // Get a list of the signatures of expanded apps. Can't use |
| 567 | // team_id because there can be more than one team per application |
| 568 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 569 | TTeamMenuItem* teamItem |
| 570 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 571 | if (teamItem == NULL || teamItem->Signature() == NULL || |
| 572 | *teamItem->Signature() == '\0') |
| 573 | continue; |
| 574 | |
| 575 | if (teamItem->IsExpanded()) { |
| 576 | AddExpandedItem(teamItem->Signature()); |
572 | 577 | } |
| 578 | } |
| 579 | } |
| 580 | |
573 | 581 | |
574 | | // Clean up expanded signature list. |
575 | | while (!expandedItems.IsEmpty()) { |
576 | | delete static_cast<BString*>(expandedItems.RemoveItem((int32)0)); |
| 582 | void |
| 583 | TBarView::ExpandItems() |
| 584 | { |
| 585 | if (!fExpando || !fVertical || !Expando() |
| 586 | || !static_cast<TBarApp*>(be_app)->Settings()->superExpando |
| 587 | || sExpandedItems.CountItems() <= 0) |
| 588 | return; |
| 589 | |
| 590 | // Start at the 'bottom' of the list working up. |
| 591 | // Prevents being thrown off by expanding items. |
| 592 | for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) { |
| 593 | TTeamMenuItem* teamItem |
| 594 | = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex)); |
| 595 | if (teamItem == NULL || teamItem->Signature() == NULL |
| 596 | || *teamItem->Signature() == '\0') |
| 597 | continue; |
| 598 | |
| 599 | for (int32 sigIndex = sExpandedItems.CountItems(); sigIndex-- > 0;) { |
| 600 | BString* itemSig = (BString *)sExpandedItems.ItemAt(sigIndex); |
| 601 | |
| 602 | if (itemSig->ICompare(teamItem->Signature()) == 0) { |
| 603 | teamItem->ToggleExpandState(false); |
| 604 | sExpandedItems.RemoveItem(sigIndex); |
| 605 | break; |
| 606 | } |
577 | 607 | } |
| 608 | } |
| 609 | |
| 610 | // Clean up the expanded items list |
| 611 | while (!sExpandedItems.IsEmpty()) |
| 612 | delete static_cast<BString*>(sExpandedItems.RemoveItem((int32)0)); |
| 613 | sExpandedItems.MakeEmpty(); |
578 | 614 | |
579 | | fExpando->SizeWindow(); |
| 615 | fExpando->SizeWindow(); |
| 616 | } |
| 617 | |
| 618 | void |
| 619 | TBarView::AddExpandedItem(const char* signature) |
| 620 | { |
| 621 | // If signature is not in the list, add it |
| 622 | bool shouldAdd = true; |
| 623 | |
| 624 | for (int32 sigIndex = sExpandedItems.CountItems(); |
| 625 | sigIndex-- > 0;) { |
| 626 | BString *itemSig = (BString *)sExpandedItems.ItemAt(sigIndex); |
| 627 | if (itemSig->ICompare(signature) == 0) { |
| 628 | // already in the list, don't add the signature |
| 629 | shouldAdd = false; |
| 630 | break; |
| 631 | } |
580 | 632 | } |
581 | 633 | |
582 | | Invalidate(); |
| 634 | // Add the signature to the list |
| 635 | if (shouldAdd) { |
| 636 | BString *sigToAdd = new BString(signature); |
| 637 | sExpandedItems.AddItem((void *)sigToAdd); |
| 638 | } |
583 | 639 | } |
584 | 640 | |
585 | 641 | |
diff --git src/apps/deskbar/BarView.h src/apps/deskbar/BarView.h
index 9e165cb..2268fb4 100644
|
|
class TBarView : public BView {
|
141 | 141 | TExpandoMenuBar* ExpandoMenuBar() const; |
142 | 142 | TBarMenuBar* BarMenuBar() const; |
143 | 143 | TDragRegion* DragRegion() const { return fDragRegion; } |
144 | | |
| 144 | void AddExpandedItem(const char* signature); |
| 145 | |
145 | 146 | private: |
146 | 147 | friend class TBeMenu; |
147 | 148 | friend class PreferencesWindow; |
… |
… |
class TBarView : public BView {
|
151 | 152 | void PlaceBeMenu(); |
152 | 153 | void PlaceTray(bool vertSwap, bool leftSwap, BRect screenFrame); |
153 | 154 | void PlaceApplicationBar(BRect screenFrame); |
| 155 | void SaveExpandedItems(); |
| 156 | void ExpandItems(); |
154 | 157 | |
155 | 158 | TBarMenuBar* fBarMenuBar; |
156 | 159 | TExpandoMenuBar* fExpando; |
… |
… |
class TBarView : public BView {
|
177 | 180 | uint32 fMaxRecentApps; |
178 | 181 | |
179 | 182 | TTeamMenuItem* fLastDragItem; |
| 183 | static BList sExpandedItems; |
180 | 184 | }; |
181 | 185 | |
182 | 186 | |