Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24770 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9a87228642
commit
70f87b87d9
@ -34,36 +34,42 @@ All rights reserved.
|
|||||||
|
|
||||||
// defines the status area drawn in the bottom left corner of a Tracker window
|
// defines the status area drawn in the bottom left corner of a Tracker window
|
||||||
|
|
||||||
|
#include "CountView.h"
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
|
||||||
#include "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
#include "Bitmaps.h"
|
#include "Bitmaps.h"
|
||||||
#include "CountView.h"
|
|
||||||
#include "ContainerWindow.h"
|
#include "ContainerWindow.h"
|
||||||
#include "DirMenu.h"
|
#include "DirMenu.h"
|
||||||
#include "PoseView.h"
|
#include "PoseView.h"
|
||||||
|
|
||||||
|
|
||||||
|
const bigtime_t kBarberPoleDelay = 500000;
|
||||||
|
|
||||||
|
|
||||||
BCountView::BCountView(BRect bounds, BPoseView* view)
|
BCountView::BCountView(BRect bounds, BPoseView* view)
|
||||||
: BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM,
|
: BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM,
|
||||||
B_PULSE_NEEDED | B_WILL_DRAW),
|
B_PULSE_NEEDED | B_WILL_DRAW),
|
||||||
fLastCount(-1),
|
fLastCount(-1),
|
||||||
fPoseView(view),
|
fPoseView(view),
|
||||||
fShowingBarberPole(false),
|
fShowingBarberPole(false),
|
||||||
fBarberPoleMap(NULL),
|
fBarberPoleMap(NULL),
|
||||||
fLastBarberPoleOffset(5),
|
fLastBarberPoleOffset(5),
|
||||||
fStartSpinningAfter(0),
|
fStartSpinningAfter(0),
|
||||||
fTypeAheadString("")
|
fTypeAheadString("")
|
||||||
|
|
||||||
{
|
{
|
||||||
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, kResBarberPoleBitmap,
|
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE,
|
||||||
&fBarberPoleMap);
|
kResBarberPoleBitmap, &fBarberPoleMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BCountView::~BCountView()
|
BCountView::~BCountView()
|
||||||
{
|
{
|
||||||
delete fBarberPoleMap;
|
delete fBarberPoleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::TrySpinningBarberPole()
|
BCountView::TrySpinningBarberPole()
|
||||||
{
|
{
|
||||||
@ -83,25 +89,26 @@ BCountView::TrySpinningBarberPole()
|
|||||||
Invalidate(BarberPoleInnerRect());
|
Invalidate(BarberPoleInnerRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
|
void
|
||||||
BCountView::Pulse()
|
BCountView::Pulse()
|
||||||
{
|
{
|
||||||
TrySpinningBarberPole();
|
TrySpinningBarberPole();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
|
void
|
||||||
BCountView::EndBarberPole()
|
BCountView::EndBarberPole()
|
||||||
{
|
{
|
||||||
if (!fShowingBarberPole)
|
if (!fShowingBarberPole)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fShowingBarberPole = false;
|
fShowingBarberPole = false;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bigtime_t kBarberPoleDelay = 500000;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::StartBarberPole()
|
BCountView::StartBarberPole()
|
||||||
{
|
{
|
||||||
AutoLock<BWindow> lock(Window());
|
AutoLock<BWindow> lock(Window());
|
||||||
@ -113,7 +120,8 @@ BCountView::StartBarberPole()
|
|||||||
// wait a bit before showing the barber pole
|
// wait a bit before showing the barber pole
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect
|
|
||||||
|
BRect
|
||||||
BCountView::BarberPoleInnerRect() const
|
BCountView::BarberPoleInnerRect() const
|
||||||
{
|
{
|
||||||
BRect result = Bounds();
|
BRect result = Bounds();
|
||||||
@ -123,7 +131,8 @@ BCountView::BarberPoleInnerRect() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect
|
|
||||||
|
BRect
|
||||||
BCountView::BarberPoleOuterRect() const
|
BCountView::BarberPoleOuterRect() const
|
||||||
{
|
{
|
||||||
BRect result(BarberPoleInnerRect());
|
BRect result(BarberPoleInnerRect());
|
||||||
@ -131,6 +140,7 @@ BCountView::BarberPoleOuterRect() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BCountView::TextInvalRect() const
|
BCountView::TextInvalRect() const
|
||||||
{
|
{
|
||||||
@ -138,12 +148,13 @@ BCountView::TextInvalRect() const
|
|||||||
result.InsetBy(4, 2);
|
result.InsetBy(4, 2);
|
||||||
|
|
||||||
// if the barber pole is not present, use its space for text
|
// if the barber pole is not present, use its space for text
|
||||||
if(fShowingBarberPole)
|
if (fShowingBarberPole)
|
||||||
result.right -= 10;
|
result.right -= 10;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BRect
|
BRect
|
||||||
BCountView::TextAndBarberPoleRect() const
|
BCountView::TextAndBarberPoleRect() const
|
||||||
{
|
{
|
||||||
@ -153,6 +164,7 @@ BCountView::TextAndBarberPoleRect() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::CheckCount()
|
BCountView::CheckCount()
|
||||||
{
|
{
|
||||||
@ -165,6 +177,7 @@ BCountView::CheckCount()
|
|||||||
TrySpinningBarberPole();
|
TrySpinningBarberPole();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::Draw(BRect)
|
BCountView::Draw(BRect)
|
||||||
{
|
{
|
||||||
@ -179,17 +192,18 @@ BCountView::Draw(BRect)
|
|||||||
itemString << fLastCount << " items";
|
itemString << fLastCount << " items";
|
||||||
} else
|
} else
|
||||||
itemString << TypeAhead();
|
itemString << TypeAhead();
|
||||||
|
|
||||||
BString string(itemString);
|
BString string(itemString);
|
||||||
BRect textRect(TextInvalRect());
|
BRect textRect(TextInvalRect());
|
||||||
|
|
||||||
TruncateString(&string, B_TRUNCATE_END, textRect.Width());
|
TruncateString(&string, B_TRUNCATE_END, textRect.Width());
|
||||||
|
|
||||||
if (IsTypingAhead())
|
if (IsTypingAhead()) {
|
||||||
// use a muted gray for the typeahead
|
// use a muted gray for the typeahead
|
||||||
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_4_TINT));
|
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_4_TINT));
|
||||||
else
|
} else
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
|
|
||||||
MovePenTo(textRect.LeftBottom());
|
MovePenTo(textRect.LeftBottom());
|
||||||
DrawString(string.String());
|
DrawString(string.String());
|
||||||
|
|
||||||
@ -212,7 +226,7 @@ BCountView::Draw(BRect)
|
|||||||
EndLineArray();
|
EndLineArray();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect barberPoleRect(BarberPoleOuterRect());
|
BRect barberPoleRect(BarberPoleOuterRect());
|
||||||
|
|
||||||
AddLine(barberPoleRect.LeftTop(), barberPoleRect.RightTop(), shadow);
|
AddLine(barberPoleRect.LeftTop(), barberPoleRect.RightTop(), shadow);
|
||||||
@ -237,6 +251,7 @@ BCountView::Draw(BRect)
|
|||||||
DrawBitmap(fBarberPoleMap, destRect);
|
DrawBitmap(fBarberPoleMap, destRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::MouseDown(BPoint)
|
BCountView::MouseDown(BPoint)
|
||||||
{
|
{
|
||||||
@ -266,6 +281,7 @@ BCountView::MouseDown(BPoint)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BCountView::AttachedToWindow()
|
BCountView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@ -278,20 +294,23 @@ BCountView::AttachedToWindow()
|
|||||||
CheckCount();
|
CheckCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
|
void
|
||||||
BCountView::SetTypeAhead(const char *string)
|
BCountView::SetTypeAhead(const char *string)
|
||||||
{
|
{
|
||||||
fTypeAheadString = string;
|
fTypeAheadString = string;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
BCountView::TypeAhead() const
|
BCountView::TypeAhead() const
|
||||||
{
|
{
|
||||||
return fTypeAheadString.String();
|
return fTypeAheadString.String();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
|
bool
|
||||||
BCountView::IsTypingAhead() const
|
BCountView::IsTypingAhead() const
|
||||||
{
|
{
|
||||||
return fTypeAheadString.Length() != 0;
|
return fTypeAheadString.Length() != 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user