Ticket #7052: Deskbar_TeamMenuItem_cpp_style_fix.diff

File Deskbar_TeamMenuItem_cpp_style_fix.diff, 8.5 KB (added by jscipione, 13 years ago)
  • src/apps/deskbar/TeamMenuItem.cpp

    diff --git a/src/apps/deskbar/TeamMenuItem.cpp b/src/apps/deskbar/TeamMenuItem.cpp
    index 881dfef..a3f3619 100644
    a b Except as contained in this notice, the name of Be Incorporated shall not be  
    2626used in advertising or otherwise to promote the sale, use or other dealings in
    2727this Software without prior written authorization from Be Incorporated.
    2828
    29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
    30 of Be Incorporated in the United States and other countries. Other brand product
    31 names are registered trademarks or trademarks of their respective holders.
     29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
     30trademarks of Be Incorporated in the United States and other countries. Other
     31brand product names are registered trademarks or trademarks of their respective
     32holders.
    3233All rights reserved.
    3334*/
    3435
    TTeamMenuItem::TTeamMenuItem(BList* team, BBitmap* icon, char* name, char* sig,  
    7172}
    7273
    7374
    74 TTeamMenuItem::TTeamMenuItem(float width,float height,bool vertical)
     75TTeamMenuItem::TTeamMenuItem(float width, float height, bool vertical)
    7576    :   BMenuItem("", NULL)
    7677{
    77     InitData(NULL, NULL, strdup(""), strdup(""), width, height, false, vertical);
     78    InitData(NULL, NULL, strdup(""), strdup(""), width, height, false,
     79        vertical);
    7880}
    7981
    8082
    TTeamMenuItem::Invoke(BMessage* message)  
    136138        barview->DragStop();
    137139
    138140    // bring to front or minimize shortcuts
    139     uint32 mods = modifiers(); 
    140     if (mods & B_CONTROL_KEY)
     141    uint32 mods = modifiers();
     142    if (mods & B_CONTROL_KEY) {
    141143        TShowHideMenuItem::TeamShowHideCommon((mods & B_SHIFT_KEY)
    142144                ? B_MINIMIZE_WINDOW : B_BRING_TO_FRONT, Teams());
     145    }
    143146
    144147    return BMenuItem::Invoke(message);
    145148}
    TTeamMenuItem::GetContentSize(float* width, float* height)  
    213216        *width = kHPad + iconBounds.Width() + kLabelOffset + fLabelWidth + kHPad
    214217            + 20;
    215218
    216     if (fOverrideHeight != -1.0f) 
     219    if (fOverrideHeight != -1.0f)
    217220        *height = fOverrideHeight;
    218221    else {
    219222        *height = iconBounds.Height();
    TTeamMenuItem::Draw()  
    233236    BMenu* menu = Menu();
    234237    menu->PushState();
    235238    rgb_color menuColor = menu->LowColor();
    236 
    237239    TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
     240
    238241    bool canHandle = !barview->Dragging()
    239242        || barview->AppCanHandleTypes(Signature());
    240243
    TTeamMenuItem::Draw()  
    314317
    315318        // these continue the dark grey border on the left or top edge
    316319        menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
    317         if (fVertical)
     320        if (fVertical) {
    318321            // dark line at top
    319322            menu->StrokeLine(frame.LeftTop(), frame.RightTop());
    320         else
     323        } else {
    321324            // dark line on the left
    322325            menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
    323     } else
     326        }
     327    } else
    324328        menu->SetLowColor(menuColor);
    325329
    326330    menu->MovePenTo(ContentLocation());
    TTeamMenuItem::DrawContent()  
    337341        if (fIcon->ColorSpace() == B_RGBA32) {
    338342            menu->SetDrawingMode(B_OP_ALPHA);
    339343            menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
    340         } else {
     344        } else
    341345            menu->SetDrawingMode(B_OP_OVER);
    342         }
    343         BRect frame(Frame());
    344346
     347        BRect frame(Frame());
    345348        BRect iconBounds(fIcon->Bounds());
    346349        BRect dstRect(iconBounds);
    347350        float extra = fVertical ? 0.0f : 1.0f;
    348351        BPoint contLoc = ContentLocation();
     352
    349353        dstRect.OffsetTo(BPoint(contLoc.x + kHPad, contLoc.y +
    350354            ((frame.Height() - iconBounds.Height()) / 2) + extra));
    351355        menu->DrawBitmapAsync(fIcon, dstRect);
    TTeamMenuItem::DrawContent()  
    357361        menu->MovePenTo(drawLoc);
    358362    }
    359363
    360     //  set the pen to black so that either method will draw in the same color
    361     //  low color is set in inherited::DrawContent, override makes sure its
    362     //  what we want
     364    // set the pen to black so that either method will draw in the same color
     365    // low color is set in inherited::DrawContent, override makes sure its
     366    // what we want
    363367    if (fDrawLabel) {
    364368        menu->SetDrawingMode(B_OP_OVER);
    365369        menu->SetHighColor(0, 0, 0);
    366370
    367         //  override the drawing of the content when the item is disabled
    368         //  the wrong lowcolor is used when the item is disabled since the
    369         //  text color does not change
    370         DrawContentLabel(); 
     371        // override the drawing of the content when the item is disabled
     372        // the wrong lowcolor is used when the item is disabled since the
     373        // text color does not change
     374        DrawContentLabel();
    371375    }
    372376
    373377    // Draw the expandable icon.
    TTeamMenuItem::DrawContent()  
    387391        } else {
    388392            rgb_color outlineColor = {80, 80, 80, 255};
    389393            rgb_color middleColor = {200, 200, 200, 255};
    390    
     394
    391395            menu->SetDrawingMode(B_OP_OVER);
    392    
     396
    393397            if (!fExpanded) {
    394398                menu->BeginLineArray(6);
    395    
    396                 menu->AddLine(BPoint(rect.left + 3, rect.top + 1), 
     399
     400                menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
    397401                    BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
    398                 menu->AddLine(BPoint(rect.left + 3, rect.top + 1), 
     402                menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
    399403                    BPoint(rect.left + 7, rect.top + 5), outlineColor);
    400                 menu->AddLine(BPoint(rect.left + 7, rect.top + 5), 
     404                menu->AddLine(BPoint(rect.left + 7, rect.top + 5),
    401405                    BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
    402    
    403                 menu->AddLine(BPoint(rect.left + 4, rect.top + 3), 
     406
     407                menu->AddLine(BPoint(rect.left + 4, rect.top + 3),
    404408                    BPoint(rect.left + 4, rect.bottom - 3), middleColor);
    405                 menu->AddLine(BPoint(rect.left + 5, rect.top + 4), 
     409                menu->AddLine(BPoint(rect.left + 5, rect.top + 4),
    406410                    BPoint(rect.left + 5, rect.bottom - 4), middleColor);
    407                 menu->AddLine(BPoint(rect.left + 5, rect.top + 5), 
     411                menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
    408412                    BPoint(rect.left + 6, rect.top + 5), middleColor);
    409413                menu->EndLineArray();
    410414            } else {
    411415                // expanded state
    412    
     416
    413417                menu->BeginLineArray(6);
    414                 menu->AddLine(BPoint(rect.left + 1, rect.top + 3), 
     418                menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
    415419                    BPoint(rect.right - 3, rect.top + 3), outlineColor);
    416                 menu->AddLine(BPoint(rect.left + 1, rect.top + 3), 
     420                menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
    417421                    BPoint(rect.left + 5, rect.top + 7), outlineColor);
    418                 menu->AddLine(BPoint(rect.left + 5, rect.top + 7), 
     422                menu->AddLine(BPoint(rect.left + 5, rect.top + 7),
    419423                    BPoint(rect.right - 3, rect.top + 3), outlineColor);
    420    
    421                 menu->AddLine(BPoint(rect.left + 3, rect.top + 4), 
     424
     425                menu->AddLine(BPoint(rect.left + 3, rect.top + 4),
    422426                    BPoint(rect.right - 5, rect.top + 4), middleColor);
    423                 menu->AddLine(BPoint(rect.left + 4, rect.top + 5), 
     427                menu->AddLine(BPoint(rect.left + 4, rect.top + 5),
    424428                    BPoint(rect.right - 6, rect.top + 5), middleColor);
    425                 menu->AddLine(BPoint(rect.left + 5, rect.top + 5), 
     429                menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
    426430                    BPoint(rect.left + 5, rect.top + 6), middleColor);
    427431                menu->EndLineArray();
    428432            }
    TTeamMenuItem::DrawContentLabel()  
    437441    BMenu* menu = Menu();
    438442    menu->MovePenBy(0, fLabelAscent);
    439443
    440     float cachedWidth = menu->StringWidth(Label()); 
     444    float cachedWidth = menu->StringWidth(Label());
    441445    if (Submenu() && fVertical)
    442446        cachedWidth += 18;
    443447
    444448    const char* label = Label();
    445449    char* truncLabel = NULL;
    446450    float max = 0;
     451
    447452    if (static_cast<TBarApp*>(be_app)->Settings()->superExpando && fVertical)
    448453        max = menu->MaxContentWidth() - kSwitchWidth;
    449454    else
    450455        max = menu->MaxContentWidth();
    451456
    452457    if (max > 0) {
    453         BPoint penloc = menu->PenLocation();
     458        BPoint penloc = menu->PenLocation();
    454459        BRect frame = Frame();
    455460        float offset = penloc.x - frame.left;
    456         if (cachedWidth + offset > max) {
     461        if (cachedWidth + offset > max) {
    457462            truncLabel = (char*)malloc(strlen(label) + 4);
    458463            if (!truncLabel)
    459464                return;
    void  
    491496TTeamMenuItem::ToggleExpandState(bool resizeWindow)
    492497{
    493498    fExpanded = !fExpanded;
    494    
     499
    495500    if (fExpanded) {
    496501        // Populate Menu() with the stuff from SubMenu().
    497502        TWindowMenu* sub = (static_cast<TWindowMenu*>(Submenu()));
    TTeamMenuItem::ToggleExpandState(bool resizeWindow)  
    503508            if (locked)
    504509                sub->UnlockLooper();
    505510
    506             if (sub->CountItems() > 1){
     511            if (sub->CountItems() > 1) {
    507512                TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());
    508513                int myindex = parent->IndexOf(this) + 1;
    509514
    TTeamMenuItem::ToggleExpandState(bool resizeWindow)  
    551556TWindowMenuItem*
    552557TTeamMenuItem::ExpandedWindowItem(int32 id)
    553558{
    554     if (!fExpanded) // Paranoia
     559    if (!fExpanded) {
     560        // Paranoia
    555561        return NULL;
     562    }
    556563
    557564    TExpandoMenuBar* parent = static_cast<TExpandoMenuBar*>(Menu());
    558565    int childIndex = parent->IndexOf(this) + 1;