Ticket #3637: filetypes.patch

File filetypes.patch, 3.0 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

     
    2323#include <Window.h>
    2424
    2525#include <MenuPrivate.h>
     26#include <BMCPrivate.h>
    2627
    2728#include "utf8_functions.h"
    2829
     
    398399
    399400    fSuper->SetDrawingMode(B_OP_OVER);
    400401
     402    float frameWidth = fBounds.Width();
     403    if( MenuPrivate(fSuper).State() == MENU_STATE_CLOSED ) {
     404        frameWidth = fSuper->Frame().Width();
     405        _BMCMenuBar_* menuBar = dynamic_cast<_BMCMenuBar_*>(fSuper);
     406        if (menuBar and menuBar->IsPopUpMarkerShown())
     407            frameWidth-=15;
     408                //-15 for popup indicator , see BMCMenuBar::Draw()
     409    }
     410
    401411    // truncate if needed
    402     // TODO: Actually, this is still never triggered
    403     if (fBounds.Width() > labelWidth)
     412    if (frameWidth > labelWidth)
    404413        fSuper->DrawString(fLabel);
    405414    else {
    406415        char *truncatedLabel = new char[strlen(fLabel) + 4];
    407         TruncateLabel(fBounds.Width(), truncatedLabel);
     416        TruncateLabel(frameWidth, truncatedLabel);
    408417        fSuper->DrawString(truncatedLabel);
    409418        delete[] truncatedLabel;
    410419    }