Ticket #4830: Deskbar Autoexpand 2.diff

File Deskbar Autoexpand 2.diff, 9.4 KB (added by jscipione, 14 years ago)

Slightly updated patch that calls UpdatePlacement when a new team gets launched so that it will get automatically expanded.

  • src/apps/deskbar/BarApp.cpp

    diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
    index 532e1bc..331abbc 100644
    a b TBarApp::SaveSettings()  
    206206            fSettings.sortRunningApps);
    207207        storedSettings.AddBool("superExpando",
    208208            fSettings.superExpando);
    209         storedSettings.AddBool("expandNewTeams",
    210             fSettings.expandNewTeams);
     209        storedSettings.AddBool("autoExpandTeams",
     210            fSettings.autoExpandTeams);
    211211        storedSettings.AddBool("autoRaise",
    212212            fSettings.autoRaise);
    213213        storedSettings.AddBool("recentAppsEnabled",
    TBarApp::InitSettings()  
    243243    settings.trackerAlwaysFirst = false;
    244244    settings.sortRunningApps = false;
    245245    settings.superExpando = false;
    246     settings.expandNewTeams = false;
     246    settings.autoExpandTeams = false;
    247247    settings.autoRaise = false;
    248248    settings.recentAppsEnabled = true;
    249249    settings.recentDocsEnabled = true;
    TBarApp::InitSettings()  
    293293                &settings.sortRunningApps);
    294294            storedSettings.FindBool("superExpando",
    295295                &settings.superExpando);
    296             storedSettings.FindBool("expandNewTeams",
    297                 &settings.expandNewTeams);
     296            storedSettings.FindBool("autoExpandTeams",
     297                &settings.autoExpandTeams);
    298298            storedSettings.FindBool("autoRaise",
    299299                &settings.autoRaise);
    300300            storedSettings.FindBool("recentAppsEnabled",
    TBarApp::MessageReceived(BMessage* message)  
    384384            message->FindRef("be:ref", &ref);
    385385
    386386            AddTeam(team, flags, sig, &ref);
     387
     388            TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
     389            fBarWindow->Lock();
     390            barView->UpdatePlacement();
     391            fBarWindow->Unlock();
     392
    387393            break;
    388394        }
    389395
    TBarApp::MessageReceived(BMessage* message)  
    441447        {
    442448            fSettings.sortRunningApps = !fSettings.sortRunningApps;
    443449
    444             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    445             fBarWindow->Lock();
     450            TBarView* barView = static_cast<TBarApp*>(be_app)->BarView(); fBarWindow->Lock();
    446451            barView->UpdatePlacement();
    447452            fBarWindow->Unlock();
    448453            break;
    TBarApp::MessageReceived(BMessage* message)  
    467472            break;
    468473        }
    469474
    470         case kExpandNewTeams:
     475        case kAutoExpandTeams:
    471476        {
    472             fSettings.expandNewTeams = !fSettings.expandNewTeams;
     477            fSettings.autoExpandTeams = !fSettings.autoExpandTeams;
    473478
    474479            TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    475480            fBarWindow->Lock();
    476             barView->UpdatePlacement();
     481            barView->ToggleExpandedItems();
    477482            fBarWindow->Unlock();
    478483            break;
    479484        }
  • src/apps/deskbar/BarApp.h

    diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
    index 6f15838..8985133 100644
    a b const uint32 kShutDown = 'ShDn';  
    7979const uint32 kTrackerFirst = 'TkFt';
    8080const uint32 kSortRunningApps = 'SAps';
    8181const uint32 kSuperExpando = 'SprE';
    82 const uint32 kExpandNewTeams = 'ExTm';
     82const uint32 kAutoExpandTeams = 'ExTm';
    8383const uint32 kAutoRaise = 'AtRs';
    8484const uint32 kRestartTracker = 'Trak';
    8585
    struct desk_settings {  
    108108    bool trackerAlwaysFirst;
    109109    bool sortRunningApps;
    110110    bool superExpando;
    111     bool expandNewTeams;
     111    bool autoExpandTeams;
    112112    bool autoRaise;
    113113    bool recentAppsEnabled;
    114114    bool recentDocsEnabled;
  • src/apps/deskbar/BarView.cpp

    diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
    index f113e6a..3777ae1 100644
    a b TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)  
    469469    Window()->UpdateIfNeeded();
    470470
    471471    // Re-expand those apps.
    472     if (expandedItems.CountItems() > 0) {
     472    if (static_cast<TBarApp*>(be_app)->Settings()->superExpando
     473        && static_cast<TBarApp*>(be_app)->Settings()->autoExpandTeams)
     474        ToggleExpandedItems();
     475    else if (expandedItems.CountItems() > 0) {
    473476        for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) {
    474477            signature = static_cast<BString*>(expandedItems.ItemAt(sigIndex));
    475478            if (signature == NULL)
    TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)  
    499502}
    500503
    501504
     505void
     506TBarView::ToggleExpandedItems()
     507{
     508    if (fExpando && fVertical && Expando()
     509        && static_cast<TBarApp*>(be_app)->Settings()->superExpando) {
     510        for (int32 teamIndex = fExpando->CountItems(); teamIndex-- > 0;) {
     511            TTeamMenuItem* teamItem
     512                = dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(teamIndex));
     513            if (teamItem != NULL
     514                && static_cast<TBarApp*>(be_app)->Settings()->autoExpandTeams !=
     515                    teamItem->IsExpanded())
     516                teamItem->ToggleExpandState(false);
     517        }
     518
     519        fExpando->SizeWindow();
     520    }
     521}
     522
     523
    502524//  window placement functions
    503525
    504526bool
  • src/apps/deskbar/BarView.h

    diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
    index a481445..3e96ec3 100644
    a b class TBarView : public BView {  
    135135        TExpandoMenuBar* ExpandoMenuBar() const;
    136136        TBarMenuBar* BarMenuBar() const;
    137137        TDragRegion* DragRegion() const { return fDragRegion; }
     138        void ToggleExpandedItems();
    138139
    139140    private:
    140141        friend class TBeMenu;
  • src/apps/deskbar/ExpandoMenuBar.cpp

    diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
    index 0fd4483..e13f6cd 100644
    a b TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,  
    8080    fDrawLabel(drawLabel),
    8181    fIsScrolling(false),
    8282    fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando),
    83     fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams),
     83    fAutoExpandTeams(static_cast<TBarApp*>(be_app)->Settings()->autoExpandTeams),
    8484    fBeMenuWidth(kDefaultBeMenuWidth),
    8585    fBarView(bar),
    8686    fFirstApp(0),
    TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,  
    535535        AddItem(item);
    536536
    537537    if (fVertical) {
    538         if (item && fShowTeamExpander && fExpandNewTeams)
     538        if (item && fShowTeamExpander && fAutoExpandTeams)
    539539            item->ToggleExpandState(false);
    540540
    541541        fBarView->SizeWindow(BScreen(Window()).Frame());
  • src/apps/deskbar/ExpandoMenuBar.h

    diff --git a/src/apps/deskbar/ExpandoMenuBar.h b/src/apps/deskbar/ExpandoMenuBar.h
    index 928555c..86f8cd3 100644
    a b class TExpandoMenuBar : public BMenuBar {  
    9797        bool fDrawLabel : 1;
    9898        bool fIsScrolling : 1;
    9999        bool fShowTeamExpander : 1;
    100         bool fExpandNewTeams : 1;
     100        bool fAutoExpandTeams : 1;
    101101
    102102        float fBeMenuWidth;
    103103
  • src/apps/deskbar/PreferencesWindow.cpp

    diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
    index e8fdf07..eff7ab3 100644
    a b PreferencesWindow::PreferencesWindow(BRect frame)  
    5555    fAppsShowExpanders = new BCheckBox(
    5656        B_TRANSLATE("Show application expander"),
    5757        new BMessage(kSuperExpando));
    58     fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
    59         new BMessage(kExpandNewTeams));
     58    fAppsAutoExpand = new BCheckBox(B_TRANSLATE("Auto-expand applications"),
     59        new BMessage(kAutoExpandTeams));
    6060
    6161    fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
    6262        new BMessage(kShowSeconds));
    PreferencesWindow::PreferencesWindow(BRect frame)  
    8888    fAppsSort->SetValue(appSettings->sortRunningApps);
    8989    fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
    9090    fAppsShowExpanders->SetValue(appSettings->superExpando);
    91     fAppsExpandNew->SetValue(appSettings->expandNewTeams);
     91    fAppsAutoExpand->SetValue(appSettings->autoExpandTeams);
    9292
    9393    int32 docCount = appSettings->recentDocsCount;
    9494    int32 appCount = appSettings->recentAppsCount;
    PreferencesWindow::PreferencesWindow(BRect frame)  
    130130    // Targets
    131131    fAppsSort->SetTarget(be_app);
    132132    fAppsSortTrackerFirst->SetTarget(be_app);
    133     fAppsExpandNew->SetTarget(be_app);
     133    fAppsAutoExpand->SetTarget(be_app);
    134134
    135135    fClockSeconds->SetTarget(replicantTray);
    136136
    PreferencesWindow::PreferencesWindow(BRect frame)  
    177177            .Add(fAppsShowExpanders)
    178178            .AddGroup(B_HORIZONTAL, 0)
    179179                .SetInsets(20, 0, 0, 0)
    180                 .Add(fAppsExpandNew)
     180                .Add(fAppsAutoExpand)
    181181                .End()
    182182            .AddGlue()
    183183            .SetInsets(10, 10, 10, 10)
    void  
    276276PreferencesWindow::_EnableDisableDependentItems()
    277277{
    278278    if (fAppsShowExpanders->Value())
    279         fAppsExpandNew->SetEnabled(true);
     279        fAppsAutoExpand->SetEnabled(true);
    280280    else
    281         fAppsExpandNew->SetEnabled(false);
     281        fAppsAutoExpand->SetEnabled(false);
    282282
    283283    if (fMenuRecentDocuments->Value())
    284284        fMenuRecentDocumentCount->SetEnabled(true);
  • src/apps/deskbar/PreferencesWindow.h

    diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h
    index 77f641b..6b4b031 100644
    a b private:  
    5050            BCheckBox*      fAppsSort;
    5151            BCheckBox*      fAppsSortTrackerFirst;
    5252            BCheckBox*      fAppsShowExpanders;
    53             BCheckBox*      fAppsExpandNew;
     53            BCheckBox*      fAppsAutoExpand;
    5454
    5555            BCheckBox*      fClockSeconds;
    5656
  • src/apps/deskbar/TeamMenuItem.cpp

    diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
    index cbd669f..0e61613 100644
    a b TTeamMenuItem::ToggleExpandState(bool resizeWindow)  
    497497        TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu()));
    498498        if (sub) {
    499499            // force the menu to update it's contents.
    500             bool locked = sub->LockLooper();
     500            if (sub->LockLooper()) {
    501501                // if locking the looper failed, the menu is just not visible
    502             sub->AttachedToWindow();
    503             if (locked)
     502                sub->AttachedToWindow();
    504503                sub->UnlockLooper();
     504            }
    505505
    506506            if (sub->CountItems() > 1){
    507507                TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());