Ticket #3637: filetypes.2.patch

File filetypes.2.patch, 2.9 KB (added by yourpalal, 14 years ago)

patch to enable truncation of BMenuItem's, specifically to fix this bug

  • src/preferences/filetypes/FileTypesWindow.cpp

     
    512512
    513513    innerRect.right = innerRect.left - 6.0f;
    514514    innerRect.left = 8.0f;
    515     BView* constrainingView = new BView(innerRect, NULL, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
    516     constrainingView->SetViewColor(topView->ViewColor());
    517515
    518     fPreferredField = new BMenuField(innerRect.OffsetToCopy(B_ORIGIN), "preferred",
    519         NULL, menu);
     516    fPreferredField = new BMenuField(innerRect, "preferred",
     517        NULL, menu, true, B_FOLLOW_LEFT_RIGHT );
    520518    float width;
    521519    fPreferredField->GetPreferredSize(&width, &height);
    522520    fPreferredField->ResizeTo(innerRect.Width(), height);
    523521    fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f);
    524     constrainingView->AddChild(fPreferredField);
    525         // we embed the menu field in another view to make it behave like
    526         // we want so that it can't obscure other elements with larger
    527         // labels
    528522
    529     fPreferredBox->AddChild(constrainingView);
     523    fPreferredBox->AddChild( fPreferredField );
    530524
    531525    // "Extra Attributes" group
    532526
  • src/kits/interface/Menu.cpp

     
    203203    fAscent(-1.0f),
    204204    fDescent(-1.0f),
    205205    fFontHeight(-1.0f),
    206     fState(0),
     206    fState(MENU_STATE_CLOSED),
    207207    fLayout(layout),
    208208    fExtraRect(NULL),
    209209    fMaxContentWidth(0.0f),
     
    272272    fAscent(-1.0f),
    273273    fDescent(-1.0f),
    274274    fFontHeight(-1.0f),
    275     fState(0),
     275    fState(MENU_STATE_CLOSED),
    276276    fLayout(B_ITEMS_IN_ROW),
    277277    fExtraRect(NULL),
    278278    fMaxContentWidth(0.0f),
     
    12551255    fAscent(-1.0f),
    12561256    fDescent(-1.0f),
    12571257    fFontHeight(-1.0f),
    1258     fState(0),
     1258    fState(MENU_STATE_CLOSED),
    12591259    fLayout(layout),
    12601260    fExtraRect(NULL),
    12611261    fMaxContentWidth(0.0f),
  • src/kits/interface/MenuItem.cpp

     
    398398
    399399    fSuper->SetDrawingMode(B_OP_OVER);
    400400
     401    float frameWidth = fBounds.Width();
     402    if(MenuPrivate(fSuper).State() == MENU_STATE_CLOSED) {
     403        float rightMargin,leftMargin;
     404        MenuPrivate(fSuper).GetItemMargins( &leftMargin,NULL,&rightMargin,NULL);
     405        frameWidth = fSuper->Frame().Width() - (rightMargin+leftMargin);
     406    }
     407
    401408    // truncate if needed
    402     // TODO: Actually, this is still never triggered
    403     if (fBounds.Width() > labelWidth)
     409    if (frameWidth > labelWidth)
    404410        fSuper->DrawString(fLabel);
    405411    else {
    406412        char *truncatedLabel = new char[strlen(fLabel) + 4];
    407         TruncateLabel(fBounds.Width(), truncatedLabel);
     413        TruncateLabel(frameWidth, truncatedLabel);
    408414        fSuper->DrawString(truncatedLabel);
    409415        delete[] truncatedLabel;
    410416    }