Ticket #7052: Deskbar Style Changes and Refactoring.diff

File Deskbar Style Changes and Refactoring.diff, 8.8 KB (added by jscipione, 13 years ago)

Please review this patch, if you approve the changes, apply the patch and close this ticket, if you don't tell me what is wrong. Thanks

  • src/apps/deskbar/BarApp.cpp

    diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
    index 532e1bc..7640f43 100644
    a b All rights reserved.  
    6060#include "PublicCommands.h"
    6161#include "ResourceSet.h"
    6262#include "Switcher.h"
    63 #include "TeamMenu.h"
    64 #include "WindowMenuItem.h"
    6563
    6664
    6765BLocker TBarApp::sSubscriberLock;
    BList TBarApp::sSubscribers;  
    7270const uint32 kShowBeMenu = 'BeMn';
    7371const uint32 kShowTeamMenu = 'TmMn';
    7472
    75 const BRect kIconSize(0.0f, 0.0f, 15.0f, 15.0f);
    7673
     74const BRect kIconRect(0.0f, 0.0f, 15.0f, 15.0f);
    7775static const color_space kIconFormat = B_RGBA32;
    7876
    7977
    TBarApp::TBarApp()  
    119117    fBarWindow = new TBarWindow();
    120118    fBarWindow->Show();
    121119
     120    fBarView = static_cast<TBarApp*>(be_app)->BarView();
     121
    122122    // this messenger now targets the barview instead of the
    123123    // statusview so that all additions to the tray
    124124    // follow the same path
    TBarApp::InitSettings()  
    313313void
    314314TBarApp::MessageReceived(BMessage* message)
    315315{
    316     int32 count;
    317     bool enabled;
    318316    switch (message->what) {
    319317        case 'gloc':
    320318        case 'sloc':
    TBarApp::MessageReceived(BMessage* message)  
    349347            break;
    350348
    351349        case kUpdateRecentCounts:
     350            int32 count;
     351            bool enabled;
     352
    352353            if (message->FindInt32("applications", &count) == B_OK)
    353354                fSettings.recentAppsCount = count;
    354355            if (message->FindBool("applicationsEnabled", &enabled) == B_OK)
    TBarApp::MessageReceived(BMessage* message)  
    419420        {
    420421            fSettings.autoRaise = !fSettings.autoRaise;
    421422
    422             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    423423            fBarWindow->Lock();
    424             barView->UpdateAutoRaise();
     424            fBarView->UpdateAutoRaise();
    425425            fBarWindow->Unlock();
    426426            break;
    427427        }
    TBarApp::MessageReceived(BMessage* message)  
    430430        {
    431431            fSettings.trackerAlwaysFirst = !fSettings.trackerAlwaysFirst;
    432432
    433             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    434433            fBarWindow->Lock();
    435             barView->UpdatePlacement();
     434            fBarView->UpdatePlacement();
    436435            fBarWindow->Unlock();
    437436            break;
    438437        }
    TBarApp::MessageReceived(BMessage* message)  
    441440        {
    442441            fSettings.sortRunningApps = !fSettings.sortRunningApps;
    443442
    444             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    445443            fBarWindow->Lock();
    446             barView->UpdatePlacement();
     444            fBarView->UpdatePlacement();
    447445            fBarWindow->Unlock();
    448446            break;
    449447        }
    TBarApp::MessageReceived(BMessage* message)  
    460458        {
    461459            fSettings.superExpando = !fSettings.superExpando;
    462460
    463             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    464461            fBarWindow->Lock();
    465             barView->UpdatePlacement();
     462            fBarView->UpdatePlacement();
    466463            fBarWindow->Unlock();
    467464            break;
    468465        }
    TBarApp::MessageReceived(BMessage* message)  
    471468        {
    472469            fSettings.expandNewTeams = !fSettings.expandNewTeams;
    473470
    474             TBarView* barView = static_cast<TBarApp*>(be_app)->BarView();
    475471            fBarWindow->Lock();
    476             barView->UpdatePlacement();
     472            fBarView->UpdatePlacement();
    477473            fBarWindow->Unlock();
    478474            break;
    479475        }
    TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)  
    632628    BAppFileInfo appMime(&file);
    633629
    634630    BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
    635         new BBitmap(kIconSize, kIconFormat), strdup(ref->name));
     631        new BBitmap(kIconRect, kIconFormat), strdup(ref->name));
    636632
    637633    barInfo->teams->AddItem((void*)team);
    638634    if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
  • src/apps/deskbar/BarApp.h

    diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
    index 6f15838..55bf6e1 100644
    a b class TBarApp : public BApplication {  
    150150        void ShowPreferencesWindow();
    151151
    152152        TBarWindow* fBarWindow;
     153        TBarView* fBarView;
    153154        BMessenger fSwitcherMessenger;
    154155        BMessenger fStatusViewMessenger;
    155156        BFile* fSettingsFile;
  • src/apps/deskbar/BarMenuTitle.h

    diff --git a/src/apps/deskbar/BarMenuTitle.h b/src/apps/deskbar/BarMenuTitle.h
    index be7aa99..870c6f7 100644
    a b class BMenu;  
    4646
    4747class TBarMenuTitle : public BMenuItem {
    4848public:
    49     TBarMenuTitle(float width,float height, const BBitmap* icon,
     49    TBarMenuTitle(float width, float height, const BBitmap* icon,
    5050        BMenu* menu, bool inexpando = false);
    5151    virtual ~TBarMenuTitle();
    5252
  • src/apps/deskbar/BarView.cpp

    diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
    index f113e6a..fd753d3 100644
    a b TBarView::UpdateAutoRaise()  
    424424void
    425425TBarView::UpdatePlacement()
    426426{
    427     ChangeState(fState, fVertical, fLeft, fTop);   
     427    ChangeState(fState, fVertical, fLeft, fTop);
    428428}
    429429
    430430
    TBarView::DragStart()  
    628628            if (item == fLastDragItem)
    629629                return B_OK;
    630630
    631             fLastDragItem = item;       
    632         }                   
     631            fLastDragItem = item;
     632        }
    633633    }
    634634
    635635    return B_OK;
  • src/apps/deskbar/BarWindow.cpp

    diff --git a/src/apps/deskbar/BarWindow.cpp b/src/apps/deskbar/BarWindow.cpp
    index 98dc43a..a5027a5 100644
    a b TBarWindow::ShowBeMenu()  
    312312    if (menuBar == NULL)
    313313        return;
    314314
    315     BMenuBar_StartMenuBar_Hack(menuBar,0,true,true,NULL);
     315    BMenuBar_StartMenuBar_Hack(menuBar, 0, true, true, NULL);
    316316}
    317317
    318318
    TBarWindow::ShowTeamMenu()  
    326326    if (KeyMenuBar() == NULL)
    327327        return;
    328328
    329     BMenuBar_StartMenuBar_Hack(KeyMenuBar(),index,true,true,NULL);
     329    BMenuBar_StartMenuBar_Hack(KeyMenuBar(), index, true, true, NULL);
    330330}
    331331
    332332
  • src/apps/deskbar/ExpandoMenuBar.cpp

    diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
    index b390f06..eb869e9 100644
    a b void  
    713713TExpandoMenuBar::CheckForSizeOverrun()
    714714{
    715715    BRect screenFrame = (BScreen(Window())).Frame();
    716     if (fVertical)
    717         fIsScrolling = Window()->Frame().bottom > screenFrame.bottom;
    718     else
    719         fIsScrolling = false;
     716
     717    fIsScrolling = fVertical ? Window()->Frame().bottom > screenFrame.bottom
     718                             : false;
    720719}
    721720
    722721
    TExpandoMenuBar::monitor_team_windows(void* arg)  
    744743            // Set all WindowMenuItems to require an update.
    745744            TWindowMenuItem* item = NULL;
    746745            for (int32 i = 0; i < totalItems; i++) {
    747                 if (!teamMenu->SubmenuAt(i)){
     746                if (!teamMenu->SubmenuAt(i)) {
    748747                    item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i));
    749748                    item->SetRequireUpdate();
    750749                }
    TExpandoMenuBar::monitor_team_windows(void* arg)  
    814813
    815814            // Remove any remaining items which require an update.
    816815            for (int32 i = 0; i < totalItems; i++) {
    817                 if (!teamMenu->SubmenuAt(i)){
     816                if (!teamMenu->SubmenuAt(i)) {
    818817                    item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i));
    819818                    if (item && item->RequiresUpdate()) {
    820819                        item = static_cast<TWindowMenuItem*>
  • src/apps/deskbar/PreferencesWindow.cpp

    diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
    index e8fdf07..c7e6daa 100644
    a b PreferencesWindow::PreferencesWindow(BRect frame)  
    8383
    8484    // Values
    8585    TBarApp* barApp = static_cast<TBarApp*>(be_app);
    86     desk_settings* appSettings = barApp->Settings();;
     86    desk_settings* appSettings = barApp->Settings();
    8787
    8888    fAppsSort->SetValue(appSettings->sortRunningApps);
    8989    fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
  • src/apps/deskbar/Switcher.cpp

    diff --git a/src/apps/deskbar/Switcher.cpp b/src/apps/deskbar/Switcher.cpp
    index 86df52d..30eaaa0 100644
    a b TIconView::CacheIcons(TTeamGroup* teamGroup)  
    18931893void
    18941894TIconView::AnimateIcon(BBitmap* startIcon, BBitmap* endIcon)
    18951895{
    1896     BRect centerRect(kCenterSlot*kSlotSize, 0,
     1896    BRect centerRect(kCenterSlot * kSlotSize, 0,
    18971897        (kCenterSlot + 1) * kSlotSize - 1, kSlotSize - 1);
    18981898    BRect startIconBounds = startIcon->Bounds();
    18991899    BRect bounds = Bounds();
  • src/apps/deskbar/TeamMenuItem.cpp

    diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
    index cbd669f..1610105 100644
    a b TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,  
    7171}
    7272
    7373
    74 TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical)
     74TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical)
    7575    :   BMenuItem("", NULL)
    7676{
    7777    InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical);
    void  
    491491TTeamMenuItem::ToggleExpandState(bool resizeWindow)
    492492{
    493493    fExpanded = !fExpanded;
    494    
     494
    495495    if (fExpanded) {
    496496        // Populate Menu() with the stuff from SubMenu().
    497497        TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu()));
    TTeamMenuItem::ToggleExpandState(bool resizeWindow)  
    503503            if (locked)
    504504                sub->UnlockLooper();
    505505
    506             if (sub->CountItems() > 1){
     506            if (sub->CountItems() > 1) {
    507507                TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());
    508508                int myindex = parent->IndexOf(this) + 1;
    509509