Ticket #749: patch-bug#749.diff

File patch-bug#749.diff, 2.3 KB (added by cl21, 17 years ago)

Patch that truncates the text adding an ellipsis if necessary. It also uses the space of the "barber pole" when it is not present.

  • src/kits/tracker/CountView.h

     
    6666    BRect BarberPoleInnerRect() const;
    6767    BRect BarberPoleOuterRect() const;
    6868    BRect TextInvalRect() const;
     69    BRect TextAndBarberPoleRect() const;
    6970    void TrySpinningBarberPole();
    7071
    7172    int32 fLastCount;
  • src/kits/tracker/CountView.cpp

     
    7373    if (fStartSpinningAfter && system_time() < fStartSpinningAfter)
    7474        return;
    7575
     76    // When the barber pole just starts spinning we need to invalidate
     77    // the whole rectangle of text and barber pole.
     78    // After this the text needs no updating since only the pole changes.
    7679    if (fStartSpinningAfter) {
    7780        fStartSpinningAfter = 0;
    78         Invalidate(BarberPoleOuterRect());
     81        Invalidate(TextAndBarberPoleRect());
    7982    } else
    8083        Invalidate(BarberPoleInnerRect());
    8184}
     
    133136{
    134137    BRect result = Bounds();
    135138    result.InsetBy(4, 2);
    136     result.right -= 10;
    137139
     140    // if the barber pole is not present, use its space for text
     141    if(fShowingBarberPole)
     142        result.right -= 10;
     143
    138144    return result;
    139145}
    140146
     147BRect
     148BCountView::TextAndBarberPoleRect() const
     149{
     150    BRect result = Bounds();
     151    result.InsetBy(4, 2);
     152
     153    return result;
     154}
     155
    141156void
    142157BCountView::CheckCount()
    143158{
     
    154169BCountView::Draw(BRect)
    155170{
    156171    BRect bounds(Bounds());
    157     BRect barberPoleRect;
    158172    BString itemString;
    159173    if (!IsTypingAhead()) {
    160174        if (fLastCount == 0)
     
    166180    } else
    167181        itemString << TypeAhead();
    168182       
    169    
    170183    BString string(itemString);
    171184    BRect textRect(TextInvalRect());
    172185
    173     if (fShowingBarberPole && !fStartSpinningAfter) {
    174         barberPoleRect = BarberPoleOuterRect();
    175         TruncateString(&string, B_TRUNCATE_END, textRect.Width());
    176     }
     186    TruncateString(&string, B_TRUNCATE_END, textRect.Width());
    177187
    178188    if (IsTypingAhead())
    179189        // use a muted gray for the typeahead
     
    202212        EndLineArray();
    203213        return;
    204214    }
     215   
     216    BRect barberPoleRect(BarberPoleOuterRect());
    205217
    206218    AddLine(barberPoleRect.LeftTop(), barberPoleRect.RightTop(), shadow);
    207219    AddLine(barberPoleRect.LeftTop(), barberPoleRect.LeftBottom(), shadow);