From 13b895c5c665203a8990f2a6f7cf5776cd248937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 3 Apr 2008 09:04:07 +0000 Subject: [PATCH] Applied patch by Christof Lutteroth: * The count/info view in Tracker truncates the text in a better way when it does not fit, and also used the space of the barber pool when it isn't displayed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24764 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/CountView.cpp | 28 ++++++++++++++++++++-------- src/kits/tracker/CountView.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index 56d76211d2..0fe095d3af 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -73,9 +73,12 @@ BCountView::TrySpinningBarberPole() if (fStartSpinningAfter && system_time() < fStartSpinningAfter) return; + // When the barber pole just starts spinning we need to invalidate + // the whole rectangle of text and barber pole. + // After this the text needs no updating since only the pole changes. if (fStartSpinningAfter) { fStartSpinningAfter = 0; - Invalidate(BarberPoleOuterRect()); + Invalidate(TextAndBarberPoleRect()); } else Invalidate(BarberPoleInnerRect()); } @@ -133,7 +136,19 @@ BCountView::TextInvalRect() const { BRect result = Bounds(); result.InsetBy(4, 2); - result.right -= 10; + + // if the barber pole is not present, use its space for text + if(fShowingBarberPole) + result.right -= 10; + + return result; +} + +BRect +BCountView::TextAndBarberPoleRect() const +{ + BRect result = Bounds(); + result.InsetBy(4, 2); return result; } @@ -154,7 +169,6 @@ void BCountView::Draw(BRect) { BRect bounds(Bounds()); - BRect barberPoleRect; BString itemString; if (!IsTypingAhead()) { if (fLastCount == 0) @@ -166,14 +180,10 @@ BCountView::Draw(BRect) } else itemString << TypeAhead(); - BString string(itemString); BRect textRect(TextInvalRect()); - if (fShowingBarberPole && !fStartSpinningAfter) { - barberPoleRect = BarberPoleOuterRect(); - TruncateString(&string, B_TRUNCATE_END, textRect.Width()); - } + TruncateString(&string, B_TRUNCATE_END, textRect.Width()); if (IsTypingAhead()) // use a muted gray for the typeahead @@ -202,6 +212,8 @@ BCountView::Draw(BRect) EndLineArray(); return; } + + BRect barberPoleRect(BarberPoleOuterRect()); AddLine(barberPoleRect.LeftTop(), barberPoleRect.RightTop(), shadow); AddLine(barberPoleRect.LeftTop(), barberPoleRect.LeftBottom(), shadow); diff --git a/src/kits/tracker/CountView.h b/src/kits/tracker/CountView.h index 1822375a90..0172978ad2 100644 --- a/src/kits/tracker/CountView.h +++ b/src/kits/tracker/CountView.h @@ -66,6 +66,7 @@ private: BRect BarberPoleInnerRect() const; BRect BarberPoleOuterRect() const; BRect TextInvalRect() const; + BRect TextAndBarberPoleRect() const; void TrySpinningBarberPole(); int32 fLastCount;