Ticket #7132: Deskbar Resize Team Icons 5.diff

File Deskbar Resize Team Icons 5.diff, 23.4 KB (added by jscipione, 9 years ago)

Make improvements suggested by axeld and collapse to just icon in horizontal mode when the bar gets too wide.

  • src/apps/deskbar/BarApp.cpp

    diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
    index 3a5716a..f0fd9a6 100644
    a b TBarApp::SaveSettings()  
    205205        storedSettings.AddBool("sortRunningApps", fSettings.sortRunningApps);
    206206        storedSettings.AddBool("superExpando", fSettings.superExpando);
    207207        storedSettings.AddBool("expandNewTeams", fSettings.expandNewTeams);
     208        storedSettings.AddInt32("iconSize", fSettings.iconSize);
    208209        storedSettings.AddBool("autoRaise", fSettings.autoRaise);
    209210        storedSettings.AddBool("recentAppsEnabled",
    210211            fSettings.recentAppsEnabled);
    TBarApp::InitSettings()  
    240241    settings.sortRunningApps = false;
    241242    settings.superExpando = false;
    242243    settings.expandNewTeams = false;
     244    settings.iconSize = kMinimumIconSize;
    243245    settings.autoRaise = false;
    244246    settings.recentAppsEnabled = true;
    245247    settings.recentDocsEnabled = true;
    TBarApp::InitSettings()  
    289291                &settings.sortRunningApps);
    290292            storedSettings.FindBool("superExpando", &settings.superExpando);
    291293            storedSettings.FindBool("expandNewTeams", &settings.expandNewTeams);
     294            storedSettings.FindInt32("iconSize", (int32*)&settings.iconSize);
    292295            storedSettings.FindBool("autoRaise", &settings.autoRaise);
    293296            storedSettings.FindBool("recentAppsEnabled",
    294297                &settings.recentAppsEnabled);
    TBarApp::MessageReceived(BMessage* message)  
    461464            fBarWindow->Unlock();
    462465            break;
    463466
     467        case kResizeTeamIcons:
     468        {
     469            int32 iconSize;
     470
     471            if (message->FindInt32("be:value", &iconSize) == B_OK)
     472                fSettings.iconSize = iconSize * 8;
     473
     474            if (fSettings.iconSize < kMinimumIconSize)
     475                fSettings.iconSize = kMinimumIconSize;
     476            else if (fSettings.iconSize > kMaximumIconSize)
     477                fSettings.iconSize = kMaximumIconSize;
     478
     479            ResizeTeamIcons();
     480
     481            fBarWindow->Lock();
     482            BarView()->UpdatePlacement();
     483            fBarWindow->Unlock();
     484            break;
     485        }
     486
    464487        case 'TASK':
    465488            fSwitcherMessenger.SendMessage(message);
    466489            break;
    TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)  
    624647        name = ref->name;
    625648
    626649    BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
    627         new BBitmap(kIconRect, kIconFormat), strdup(name.String()));
     650        new BBitmap(IconRect(), kIconFormat), strdup(ref->name));
     651
     652    if ((barInfo->flags & B_BACKGROUND_APP) == 0
     653        && strcasecmp(barInfo->sig, kDeskbarSignature) != 0)
     654        FetchAppIcon(barInfo->sig, barInfo->icon);
    628655
    629656    barInfo->teams->AddItem((void*)team);
    630     if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
    631         appMime.GetTrackerIcon(barInfo->icon, B_MINI_ICON);
    632657
    633658    sBarTeamInfoList.AddItem(barInfo);
    634659
    TBarApp::RemoveTeam(team_id team)  
    690715
    691716
    692717void
     718TBarApp::ResizeTeamIcons()
     719{
     720    for (int32 i = 0; i < sBarTeamInfoList.CountItems(); i++) {
     721        BarTeamInfo* barInfo = (BarTeamInfo*)sBarTeamInfoList.ItemAt(i);
     722        if ((barInfo->flags & B_BACKGROUND_APP) == 0
     723            && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {
     724            barInfo->icon = new BBitmap(IconRect(), kIconFormat);
     725            FetchAppIcon(barInfo->sig, barInfo->icon);
     726        }
     727    }
     728}
     729
     730
     731void
    693732TBarApp::ShowPreferencesWindow()
    694733{
    695734    if (fPreferencesWindow)
    TBarApp::ShowPreferencesWindow()  
    701740}
    702741
    703742
     743void
     744TBarApp::FetchAppIcon(const char* signature, BBitmap* icon)
     745{
     746    app_info appInfo;
     747
     748    if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) {
     749        BFile file(&appInfo.ref, B_READ_ONLY);
     750        BAppFileInfo appMime(&file);
     751        icon_size size = icon->Bounds().IntegerHeight() >= 31
     752            ? B_LARGE_ICON : B_MINI_ICON;
     753
     754        if (appMime.GetIcon(icon, size) != B_OK)
     755            appMime.GetTrackerIcon(icon, size);
     756    }
     757}
     758
     759
     760const BRect
     761TBarApp::IconRect()
     762{
     763    return BRect(0, 0, fSettings.iconSize - 1, fSettings.iconSize - 1);
     764}
     765
     766
    704767//  #pragma mark -
    705768
    706769
  • src/apps/deskbar/BarApp.h

    diff --git a/src/apps/deskbar/BarApp.h b/src/apps/deskbar/BarApp.h
    index 6996151..4756c0b 100644
    a b const uint32 kTrackerFirst = 'TkFt';  
    8080const uint32 kSortRunningApps = 'SAps';
    8181const uint32 kSuperExpando = 'SprE';
    8282const uint32 kExpandNewTeams = 'ExTm';
     83const uint32 kResizeTeamIcons = 'RTIs';
    8384const uint32 kAutoRaise = 'AtRs';
    8485const uint32 kRestartTracker = 'Trak';
    8586
    const uint32 kShutdownSystem = 301;  
    8889const uint32 kRebootSystem = 302;
    8990const uint32 kSuspendSystem = 304;
    9091
     92// icon size constants
     93const int32 kMinimumIconSize = 16;
     94const int32 kMaximumIconSize = 64;
     95const int32 kIconSizeInterval = 8;
     96
    9197/* --------------------------------------------- */
    9298
    9399struct desk_settings {
    struct desk_settings {  
    109115    bool sortRunningApps;
    110116    bool superExpando;
    111117    bool expandNewTeams;
     118    int32 iconSize;
    112119    bool autoRaise;
    113120    bool recentAppsEnabled;
    114121    bool recentDocsEnabled;
    class TBarApp : public BApplication {  
    126133        TBarApp();
    127134        virtual ~TBarApp();
    128135
    129         virtual bool QuitRequested();
     136        virtual bool QuitRequested();
    130137        virtual void MessageReceived(BMessage* message);
    131138        virtual void RefsReceived(BMessage* refs);
    132139
    class TBarApp : public BApplication {  
    139146
    140147        static void Subscribe(const BMessenger &subscriber, BList*);
    141148        static void Unsubscribe(const BMessenger &subscriber);
     149        void ResizeTeamIcons();
    142150
    143151    private:
    144152        void AddTeam(team_id team, uint32 flags, const char* sig, entry_ref*);
    class TBarApp : public BApplication {  
    148156        void SaveSettings();
    149157
    150158        void ShowPreferencesWindow();
     159        void FetchAppIcon(const char* signature, BBitmap* icon);
     160        const BRect IconRect();
    151161
    152162        TBarWindow* fBarWindow;
    153163        BMessenger fSwitcherMessenger;
  • src/apps/deskbar/BarView.cpp

    diff --git a/src/apps/deskbar/BarView.cpp b/src/apps/deskbar/BarView.cpp
    index cac3472..980e76e 100644
    a b TBarView::PlaceBeMenu()  
    224224        return;
    225225
    226226    float width = sMinimumWindowWidth;
     227    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    227228    BPoint loc(B_ORIGIN);
    228229    BRect menuFrame(fBarMenuBar->Frame());
    229230    if (fState == kFullState) {
    230231        fBarMenuBar->RemoveTeamMenu();
     232        // TODO: Magic constants need explination
    231233        width = 8 + 16 + 8;
    232234        loc = Bounds().LeftTop();
    233235    } else if (fState == kExpandoState) {
    234236        // shows apps below tray
    235237        fBarMenuBar->RemoveTeamMenu();
    236         if (fVertical)
     238        if (fVertical) {
    237239            width += 1;
    238         else
     240            width += settings->iconSize - kMinimumIconSize;
     241        } else
    239242            width = floorf(width) / 2;
    240243        loc = Bounds().LeftTop();
    241244    } else {
    TBarView::PlaceApplicationBar(BRect screenFrame)  
    300303    if (fState == kMiniState)
    301304        return;
    302305
     306    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    303307    BRect expandoFrame(0, 0, 0, 0);
    304308    if (fVertical) {
    305309        // top left/right
    TBarView::PlaceApplicationBar(BRect screenFrame)  
    311315        expandoFrame.bottom = expandoFrame.top + 1;
    312316        if (fState == kFullState)
    313317            expandoFrame.right = fBarMenuBar->Frame().Width();
    314         else
    315             expandoFrame.right = sMinimumWindowWidth;
     318        else {
     319            expandoFrame.right = sMinimumWindowWidth + settings->iconSize
     320                - kMinimumIconSize;
     321        }
    316322    } else {
    317323        // top or bottom
    318324        expandoFrame.top = 0;
    319         expandoFrame.bottom = kHModeHeight;
     325        expandoFrame.bottom = settings->iconSize + 4;
    320326        if (fTrayLocation != 0)
    321327            expandoFrame.right = fDragRegion->Frame().left - 1;
    322328        else
    TBarView::GetPreferredWindowSize(BRect screenFrame, float* width, float* height)  
    338344        windowHeight = screenFrame.bottom;
    339345        windowWidth = fBarMenuBar->Frame().Width();
    340346    } else if (fState == kExpandoState) {
     347        desk_settings* settings = ((TBarApp*)be_app)->Settings();
    341348        if (fVertical) {
    342349            // top left or right
    343350            windowHeight = fExpando->Frame().bottom;
     351            windowWidth += settings->iconSize - kMinimumIconSize;
    344352        } else {
    345353            // top or bottom, full
    346354            fExpando->CheckItemSizes(0);
    347             windowHeight = kHModeHeight;
     355            windowHeight = settings->iconSize + 4;
    348356            windowWidth = screenFrame.Width();
    349357        }
    350358    } else {
    BRect  
    942950TBarView::OffsetIconFrame(BRect rect) const
    943951{
    944952    BRect frame(Frame());
     953    desk_settings* settings = ((TBarApp*)be_app)->Settings();
     954
    945955    frame.left += fDragRegion->Frame().left + fReplicantTray->Frame().left
    946         + rect.left;
     956        + rect.left + settings->iconSize - kMinimumIconSize;
    947957    frame.top += fDragRegion->Frame().top + fReplicantTray->Frame().top
    948958        + rect.top;
    949959
  • src/apps/deskbar/BarView.h

    diff --git a/src/apps/deskbar/BarView.h b/src/apps/deskbar/BarView.h
    index 8f4e5b8..8a60bb5 100644
    a b class TBarView : public BView {  
    136136        TExpandoMenuBar* ExpandoMenuBar() const;
    137137        TBarMenuBar* BarMenuBar() const;
    138138        TDragRegion* DragRegion() const { return fDragRegion; }
     139        TReplicantTray* ReplicantTray() const { return fReplicantTray; }
    139140
    140141    private:
    141142        friend class TBeMenu;
  • src/apps/deskbar/ExpandoMenuBar.cpp

    diff --git a/src/apps/deskbar/ExpandoMenuBar.cpp b/src/apps/deskbar/ExpandoMenuBar.cpp
    index 739f076..adbdaf3 100644
    a b All rights reserved.  
    6161
    6262const float kDefaultBeMenuWidth = 50.0f;
    6363const float kSepItemWidth = 5.0f;
     64const float kIconPadding = 8.0f;
    6465
    6566const uint32 kMinimizeTeam = 'mntm';
    6667const uint32 kBringTeamToFront = 'bftm';
    TExpandoMenuBar::TExpandoMenuBar(TBarView* bar, BRect frame, const char* name,  
    9091{
    9192    SetItemMargins(0.0f, 0.0f, 0.0f, 0.0f);
    9293    SetFont(be_plain_font);
    93     SetMaxContentWidth(sMinimumWindowWidth);
    9494}
    9595
    9696
    TExpandoMenuBar::AttachedToWindow()  
    134134
    135135    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    136136
     137    // Add in the width of the icon
     138    width += settings->iconSize - kMinimumIconSize;
     139
    137140    if (settings->sortRunningApps)
    138141        teamList.SortItems(CompareByName);
    139142
    void  
    499502TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
    500503    char* signature)
    501504{
     505    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    502506    float itemWidth = fVertical ? fBarView->Bounds().Width()
    503         : sMinimumWindowWidth;
     507        : sMinimumWindowWidth + settings->iconSize - kMinimumIconSize;
    504508    float itemHeight = -1.0f;
    505509
    506     desk_settings* settings = ((TBarApp*)be_app)->Settings();
    507510    TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
    508511        itemWidth, itemHeight, fDrawLabel, fVertical);
    509512
    TExpandoMenuBar::RemoveTeam(team_id team, bool partial)  
    606609void
    607610TExpandoMenuBar::CheckItemSizes(int32 delta)
    608611{
    609     float width = Frame().Width();
    610     int32 count = CountItems();
     612    if (fBarView->Vertical())
     613        return;
     614
     615    float iconSize = ((TBarApp*)be_app)->Settings()->iconSize;
     616    float maxContentWidth = sMinimumWindowWidth + iconSize -
     617        kMinimumIconSize;
     618
     619    // There are 2 extra items:
     620    //     The Be Menu
     621    //     The little separator item
     622    int32 count = CountItems() - 2;
     623    float width = Frame().Width() - fBeMenuWidth - kSepItemWidth * 2;
     624    float fullWidth = maxContentWidth * count + fBeMenuWidth + kSepItemWidth;
     625
    611626    bool reset = false;
    612     float newWidth = 0;
    613     float fullWidth = (sMinimumWindowWidth * count);
    614 
    615     if (!fBarView->Vertical()) {
    616         // in this case there are 2 extra items:
    617         //   - The Be Menu
    618         //   - The little separator item
    619         fullWidth = fullWidth - (sMinimumWindowWidth * 2)
    620             + (fBeMenuWidth + kSepItemWidth);
    621         width -= (fBeMenuWidth + kSepItemWidth);
    622         count -= 2;
    623     }
     627    float newWidth = 0.0f;
    624628
    625629    if (delta >= 0 && fullWidth > width) {
    626630        fOverflow = true;
    627631        reset = true;
    628         newWidth = floorf(width / count);
     632        //newWidth = floorf(width / count);
     633        newWidth = kIconPadding + iconSize + kIconPadding;
    629634    } else if (delta < 0 && fOverflow) {
    630635        reset = true;
    631636        if (fullWidth > width)
    632             newWidth = floorf(width / count);
     637            newWidth = kIconPadding + iconSize + kIconPadding;
    633638        else
    634             newWidth = sMinimumWindowWidth;
     639            newWidth = maxContentWidth;
    635640    }
    636     if (newWidth > sMinimumWindowWidth)
    637         newWidth = sMinimumWindowWidth;
     641
     642    if (newWidth > maxContentWidth)
     643        newWidth = maxContentWidth;
    638644
    639645    if (reset) {
    640646        SetMaxContentWidth(newWidth);
    641         if (newWidth == sMinimumWindowWidth)
     647        if (newWidth == maxContentWidth)
    642648            fOverflow = false;
    643649        InvalidateLayout();
    644650
    TExpandoMenuBar::CheckItemSizes(int32 delta)  
    647653            if (!item)
    648654                break;
    649655            item->SetOverrideWidth(newWidth);
     656            item->SetDrawLabel(!fOverflow);
    650657        }
    651658
    652659        Invalidate();
  • src/apps/deskbar/PreferencesWindow.cpp

    diff --git a/src/apps/deskbar/PreferencesWindow.cpp b/src/apps/deskbar/PreferencesWindow.cpp
    index bb378f1..59d369f 100644
    a b  
    1717#include <OpenWithTracker.h>
    1818#include <RadioButton.h>
    1919#include <SeparatorView.h>
     20#include <Slider.h>
    2021
    2122#include <ctype.h>
    2223
    PreferencesWindow::PreferencesWindow(BRect frame)  
    5556        new BMessage(kSuperExpando));
    5657    fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
    5758        new BMessage(kExpandNewTeams));
     59    fAppsIconSizeSlider = new BSlider("icon_size", B_TRANSLATE("Icon size"),
     60        NULL, kMinimumIconSize / kIconSizeInterval,
     61        kMaximumIconSize / kIconSizeInterval, B_HORIZONTAL);
     62    fAppsIconSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
     63    fAppsIconSizeSlider->SetHashMarkCount(((kMaximumIconSize - kMinimumIconSize)
     64        / kIconSizeInterval) + 1);
     65    fAppsIconSizeSlider->SetLimitLabels(B_TRANSLATE("Small"),
     66        B_TRANSLATE("Large"));
     67    fAppsIconSizeSlider->SetModificationMessage(new BMessage(kResizeTeamIcons));
    5868
    5969    fClockSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
    6070        new BMessage(kShowSeconds));
    PreferencesWindow::PreferencesWindow(BRect frame)  
    8797    fAppsSortTrackerFirst->SetValue(appSettings->trackerAlwaysFirst);
    8898    fAppsShowExpanders->SetValue(appSettings->superExpando);
    8999    fAppsExpandNew->SetValue(appSettings->expandNewTeams);
     100    fAppsIconSizeSlider->SetValue(appSettings->iconSize / 8);
    90101
    91102    int32 docCount = appSettings->recentDocsCount;
    92103    int32 appCount = appSettings->recentAppsCount;
    PreferencesWindow::PreferencesWindow(BRect frame)  
    129140    fAppsSort->SetTarget(be_app);
    130141    fAppsSortTrackerFirst->SetTarget(be_app);
    131142    fAppsExpandNew->SetTarget(be_app);
     143    fAppsIconSizeSlider->SetTarget(be_app);
    132144
    133145    fClockSeconds->SetTarget(replicantTray);
    134146
    PreferencesWindow::PreferencesWindow(BRect frame)  
    177189                .SetInsets(20, 0, 0, 0)
    178190                .Add(fAppsExpandNew)
    179191                .End()
     192            .Add(fAppsIconSizeSlider)
    180193            .AddGlue()
    181194            .SetInsets(10, 10, 10, 10)
    182195            .End()
  • src/apps/deskbar/PreferencesWindow.h

    diff --git a/src/apps/deskbar/PreferencesWindow.h b/src/apps/deskbar/PreferencesWindow.h
    index a45005c..92d6450 100644
    a b  
    1010#include <Button.h>
    1111#include <CheckBox.h>
    1212#include <RadioButton.h>
     13#include <Slider.h>
    1314#include <StringView.h>
    1415#include <TextControl.h>
    1516#include <Window.h>
    private:  
    5253            BCheckBox*      fAppsSortTrackerFirst;
    5354            BCheckBox*      fAppsShowExpanders;
    5455            BCheckBox*      fAppsExpandNew;
     56            BSlider*        fAppsIconSizeSlider;
    5557
    5658            BCheckBox*      fClockSeconds;
    5759
  • src/apps/deskbar/StatusView.cpp

    diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp
    index 620e84a..fe1b502 100644
    a b DumpList(BList* itemlist)  
    110110        printf("no items in list\n");
    111111        return;
    112112    }
    113     for (int32 i = count ; i >= 0 ; i--) {
     113    for (int32 i = count; i >= 0; i--) {
    114114        DeskbarItemInfo* item = (DeskbarItemInfo*)itemlist->ItemAt(i);
    115115        if (!item)
    116116            continue;
    TReplicantTray::TReplicantTray(TBarView* parent, bool vertical)  
    137137    fAlignmentSupport(false)
    138138{
    139139    // init the minimum window width according to the logo.
     140    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    140141    const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE,
    141142        R_LeafLogoBitmap);
    142143    if (logoBitmap != NULL) {
    143144        sMinimumWindowWidth = max_c(sMinimumWindowWidth,
    144             2 * (logoBitmap->Bounds().Width() + 8));
     145            2 * (logoBitmap->Bounds().Width() + 8) + settings->iconSize
     146            - kMinimumIconSize);
    145147        fMinimumTrayWidth = sMinimumWindowWidth - kGutter - kDragRegionWidth;
    146148    }
    147149}
    TReplicantTray::DetachedFromWindow()  
    196198void
    197199TReplicantTray::RememberClockSettings()
    198200{
    199     if (fClock) {
     201    if (fClock) {
    200202        desk_settings* settings = ((TBarApp*)be_app)->Settings();
    201203
    202204        settings->timeShowSeconds = fClock->ShowingSeconds();
    TReplicantTray::DealWithClock(bool showClock)  
    243245
    244246/*! Width is set to a minimum of kMinimumReplicantCount by kMaxReplicantWidth
    245247    if not in multirowmode and greater than kMinimumReplicantCount
    246     the width should be calculated based on the actual
    247     replicant widths
     248    the width should be calculated based on the actual replicant widths
    248249*/
    249250void
    250251TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)
    251252{
    252253    float width = 0, height = kMinimumTrayHeight;
     254    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    253255
    254256    if (fMultiRowMode) {
    255257        if (fShelf->CountReplicants() > 0)
    TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)  
    261263        height = kGutter + (rowCount * kMaxReplicantHeight)
    262264            + ((rowCount - 1) * kIconGap) + kGutter;
    263265        height = max(kMinimumTrayHeight, height);
    264         width = fMinimumTrayWidth;
     266
     267        if (fBarView->Expando())
     268            width = fMinimumTrayWidth + settings->iconSize - kMinimumIconSize;
     269        else
     270            width = fMinimumTrayWidth;
    265271    } else {
    266272        // if last replicant overruns clock then resize to accomodate
    267273        if (fShelf->CountReplicants() > 0) {
    268             if (fBarView->ShowingClock()
    269                 && fRightBottomReplicant.right + 6 >= fClock->Frame().left) {
     274            if (fBarView->ShowingClock() && fRightBottomReplicant.right + 6
     275                >= fClock->Frame().left) {
    270276                width = fRightBottomReplicant.right + 6
    271277                    + fClock->Frame().Width();
    272278            } else
    TReplicantTray::GetPreferredSize(float* preferredWidth, float* preferredHeight)  
    275281
    276282        // this view has a fixed minimum width
    277283        width = max(fMinimumTrayWidth, width);
     284        height = kGutter + settings->iconSize + kGutter;
    278285    }
    279286
    280287    *preferredWidth = width;
    TReplicantTray::AcceptAddon(BRect replicantFrame, BMessage* message)  
    12291236BPoint
    12301237TReplicantTray::LocationForReplicant(int32 index, float width)
    12311238{
     1239    desk_settings* settings = ((TBarApp*)be_app)->Settings();
    12321240    BPoint loc(kIconGap + 1, kGutter + 1);
    12331241
    12341242    if (fMultiRowMode) {
    12351243        // try to find free space in every row
    12361244        for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
    12371245            // determine free space in this row
    1238             BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth - kIconGap - 2.0,
     1246            BRect rect(loc.x, loc.y, loc.x + fMinimumTrayWidth
     1247                + settings->iconSize - kMinimumIconSize - kIconGap - 2.0,
    12391248                loc.y + kMaxReplicantHeight);
    12401249            if (row == 0 && fBarView->ShowingClock())
    12411250                rect.right -= fClock->Frame().Width() + kIconGap;
  • src/apps/deskbar/StatusView.h

    diff --git a/src/apps/deskbar/StatusView.h b/src/apps/deskbar/StatusView.h
    index 31fb82f..9989e41 100644
    a b All rights reserved.  
    4848const float kMaxReplicantHeight = 16.0f;
    4949const float kMaxReplicantWidth = 16.0f;
    5050const int32 kMinimumReplicantCount = 6;
    51 const int32 kIconGap = 2;
     51const int32 kIconGap = 2;
    5252const int32 kGutter = 1;
    5353const int32 kDragRegionWidth = 6;
    5454
    55 // 1 pixel left gutter
     55// 1 pixel for left gutter
    5656// space for replicant tray (6 items)
    5757// 6 pixel drag region
    58 const float kMinimumTrayWidth = kIconGap + (kMinimumReplicantCount * kIconGap)
    59     + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
     58const float kMinimumTrayWidth = kIconGap
     59        + (kMinimumReplicantCount * kIconGap)
     60        + (kMinimumReplicantCount * kMaxReplicantWidth) + kGutter;
    6061const float kMinimumTrayHeight = kGutter + kMaxReplicantHeight + kGutter;
    6162
    6263extern float sMinimumWindowWidth;
  • src/apps/deskbar/TeamMenu.cpp

    diff --git a/src/apps/deskbar/TeamMenu.cpp b/src/apps/deskbar/TeamMenu.cpp
    index 3053969..ade9dcb 100644
    a b TTeamMenu::AttachedToWindow()  
    8585        if (((barInfo->flags & B_BACKGROUND_APP) == 0)
    8686            && (strcasecmp(barInfo->sig, kDeskbarSignature) != 0)) {
    8787            TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
    88                 barInfo->icon, barInfo->name, barInfo->sig, -1, -1, true, true);
     88                barInfo->icon, barInfo->name, barInfo->sig, -1, -1, true,
     89                true);
    8990
    9091            if ((settings->trackerAlwaysFirst)
    9192                && (strcmp(barInfo->sig, kTrackerSignature) == 0))
  • src/apps/deskbar/TeamMenuItem.cpp

    diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
    index a3f3619..727eb27 100644
    a b status_t  
    127127TTeamMenuItem::Invoke(BMessage* message)
    128128{
    129129    if ((static_cast<TBarApp*>(be_app))->BarView()->InvokeItem(Signature()))
    130         //  handles drop on application
     130        // handles drop on application
    131131        return B_OK;
    132132
    133     //  if the app could not handle the drag message
    134     //  and we were dragging, then kill the drag
    135     //  should never get here, disabled item will not invoke
     133    // if the app could not handle the drag message
     134    // and we were dragging, then kill the drag
     135    // should never get here, disabled item will not invoke
    136136    TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
    137137    if (barview && barview->Dragging())
    138138        barview->DragStop();
    TTeamMenuItem::Invoke(BMessage* message)  
    141141    uint32 mods = modifiers();
    142142    if (mods & B_CONTROL_KEY) {
    143143        TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
    144                 ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
     144            ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
    145145    }
    146146
    147147    return BMenuItem::Invoke(message);
    TTeamMenuItem::SetOverrideSelected(bool selected)  
    170170}
    171171
    172172
     173void
     174TTeamMenuItem::SetDrawLabel(bool drawLabel)
     175{
     176    fDrawLabel = drawLabel;
     177}
     178
     179
    173180float
    174181TTeamMenuItem::LabelWidth() const
    175182{
    TTeamMenuItem::GetContentSize(float* width, float* height)  
    206213    if (fIcon)
    207214        iconBounds = fIcon->Bounds();
    208215    else
    209         iconBounds = BRect(0, 0, 15, 15);
     216        iconBounds = BRect(0, 0, kMinimumIconSize - 1, kMinimumIconSize - 1);
    210217
    211218    BMenuItem::GetContentSize(width, height);
    212219
    213220    if (fOverrideWidth != -1.0f)
    214221        *width = fOverrideWidth;
    215     else
    216         *width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad
    217             + 20;
     222    else {
     223        *width = kHPad + iconBounds.Width() + kLabelOffset;
     224        if (fDrawLabel)
     225            *width += LabelWidth() + kHPad + 10.0f;
     226    }
    218227
    219228    if (fOverrideHeight != -1.0f)
    220229        *height = fOverrideHeight;
    221230    else {
    222231        *height = iconBounds.Height();
    223         float labelHeight = fLabelAscent + fLabelDescent;
    224         if (labelHeight > *height)
    225             *height = labelHeight;
     232        if (fDrawLabel) {
     233            float labelHeight = fLabelAscent + fLabelDescent;
     234            if (labelHeight > *height)
     235                *height = labelHeight;
     236        }
    226237        *height += (kVPad * 2) + 2;
    227238    }
    228239    *height += 2;
  • src/apps/deskbar/TeamMenuItem.h

    diff --git a/src/apps/deskbar/TeamMenuItem.h b/src/apps/deskbar/TeamMenuItem.h
    index 9bfd28b..851d029 100644
    a b class TTeamMenuItem : public BMenuItem {  
    6262        void SetOverrideWidth(float width);
    6363        void SetOverrideHeight(float height);
    6464        void SetOverrideSelected(bool selected);
     65        void SetDrawLabel(bool drawLabel);
    6566
    6667        bool IsExpanded();
    6768        void ToggleExpandState(bool resizeWindow);
  • src/apps/deskbar/TimeView.cpp

    diff --git a/src/apps/deskbar/TimeView.cpp b/src/apps/deskbar/TimeView.cpp
    index 96a7936..f6d50bb 100644
    a b TTimeView::Pulse()  
    332332            Update();
    333333
    334334        strlcpy(fLastTimeStr, fTimeStr, sizeof(fLastTimeStr));
    335         strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr));
    336335        fNeedToUpdate = true;
    337336    }
    338337
     338    // Update the tooltip if the date has changed
     339    if (strcmp(fDateStr, fLastDateStr) != 0) {
     340        strlcpy(fLastDateStr, fDateStr, sizeof(fLastDateStr));
     341        SetToolTip(fDateStr);
     342    }
     343
    339344    if (fNeedToUpdate) {
    340345        fSeconds = ct->tm_sec;
    341346        fMinute = ct->tm_min;