Beautified the Tracker job status window:
* Centered icon in available space. * Improved button layout. * Pause button remains pressed when paused. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29668 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,6 +37,7 @@ All rights reserved.
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MessageFilter.h>
|
#include <MessageFilter.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
@@ -109,18 +110,24 @@ TCustomButton::Draw(BRect updateRect)
|
|||||||
|
|
||||||
if (Message()->what == kStopButton) {
|
if (Message()->what == kStopButton) {
|
||||||
updateRect = Bounds();
|
updateRect = Bounds();
|
||||||
updateRect.InsetBy(9, 7);
|
updateRect.InsetBy(9, 8);
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
|
if (Value() == B_CONTROL_ON)
|
||||||
|
updateRect.OffsetBy(1, 1);
|
||||||
FillRect(updateRect);
|
FillRect(updateRect);
|
||||||
} else {
|
} else {
|
||||||
updateRect = Bounds();
|
updateRect = Bounds();
|
||||||
updateRect.InsetBy(9, 6);
|
updateRect.InsetBy(9, 7);
|
||||||
BRect rect(updateRect);
|
BRect rect(updateRect);
|
||||||
rect.right -= 3;
|
rect.right -= 3;
|
||||||
|
|
||||||
updateRect.left += 3;
|
updateRect.left += 3;
|
||||||
updateRect.OffsetBy(1, 0);
|
updateRect.OffsetBy(1, 0);
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
|
if (Value() == B_CONTROL_ON) {
|
||||||
|
updateRect.OffsetBy(1, 1);
|
||||||
|
rect.OffsetBy(1, 1);
|
||||||
|
}
|
||||||
FillRect(updateRect);
|
FillRect(updateRect);
|
||||||
FillRect(rect);
|
FillRect(rect);
|
||||||
}
|
}
|
||||||
@@ -386,10 +393,13 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
|
|||||||
SetHighColor(20, 20, 20);
|
SetHighColor(20, 20, 20);
|
||||||
SetDrawingMode(B_OP_OVER);
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
|
const float buttonWidth = 22;
|
||||||
|
const float buttonHeight = 20;
|
||||||
|
|
||||||
BRect rect(bounds);
|
BRect rect(bounds);
|
||||||
rect.OffsetTo(B_ORIGIN);
|
rect.OffsetTo(B_ORIGIN);
|
||||||
rect.left += 40;
|
rect.left += 40;
|
||||||
rect.right -= 50;
|
rect.right -= buttonWidth * 2 + 12;
|
||||||
rect.top += 6;
|
rect.top += 6;
|
||||||
rect.bottom = rect.top + 15;
|
rect.bottom = rect.top + 15;
|
||||||
|
|
||||||
@@ -457,20 +467,19 @@ BStatusView::BStatusView(BRect bounds, thread_id thread, StatusWindowState type)
|
|||||||
if (id)
|
if (id)
|
||||||
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id, &fBitmap);
|
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, id, &fBitmap);
|
||||||
|
|
||||||
|
|
||||||
rect = Bounds();
|
rect = Bounds();
|
||||||
rect.left = rect.right - 46;
|
rect.left = rect.right - buttonWidth * 2 - 7;
|
||||||
rect.right = rect.left + 17;
|
rect.right = rect.left + buttonWidth;
|
||||||
rect.top += 17;
|
rect.top = floorf((rect.top + rect.bottom) / 2 + 0.5) - buttonHeight / 2;
|
||||||
rect.bottom = rect.top + 10;
|
rect.bottom = rect.top + buttonHeight;
|
||||||
|
|
||||||
fPauseButton = new TCustomButton(rect, kPauseButton);
|
fPauseButton = new TCustomButton(rect, kPauseButton);
|
||||||
fPauseButton->ResizeTo(22, 18);
|
fPauseButton->ResizeTo(buttonWidth, buttonHeight);
|
||||||
AddChild(fPauseButton);
|
AddChild(fPauseButton);
|
||||||
|
|
||||||
rect.OffsetBy(20, 0);
|
rect.OffsetBy(buttonWidth + 2, 0);
|
||||||
fStopButton = new TCustomButton(rect, kStopButton);
|
fStopButton = new TCustomButton(rect, kStopButton);
|
||||||
fStopButton->ResizeTo(22, 18);
|
fStopButton->ResizeTo(buttonWidth, buttonHeight);
|
||||||
AddChild(fStopButton);
|
AddChild(fStopButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +587,8 @@ BStatusView::UpdateStatus(const char *curItem, off_t itemSize, bool optional)
|
|||||||
const char *statusItem = curItem != NULL
|
const char *statusItem = curItem != NULL
|
||||||
? curItem : fPendingStatusString;
|
? curItem : fPendingStatusString;
|
||||||
|
|
||||||
fStatusBar->Update((float)fItemSize / fTotalSize, statusItem, buffer.String());
|
fStatusBar->Update((float)fItemSize / fTotalSize, statusItem,
|
||||||
|
buffer.String());
|
||||||
|
|
||||||
// we already displayed this item, clear the stash
|
// we already displayed this item, clear the stash
|
||||||
fPendingStatusString[0] = '\0';
|
fPendingStatusString[0] = '\0';
|
||||||
@@ -609,6 +619,7 @@ BStatusView::MessageReceived(BMessage *message)
|
|||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kPauseButton:
|
case kPauseButton:
|
||||||
fIsPaused = !fIsPaused;
|
fIsPaused = !fIsPaused;
|
||||||
|
fPauseButton->SetValue(fIsPaused ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
if (!fIsPaused) {
|
if (!fIsPaused) {
|
||||||
|
|
||||||
// force window update
|
// force window update
|
||||||
@@ -641,43 +652,50 @@ BStatusView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BStatusView::Draw(BRect)
|
BStatusView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (fBitmap)
|
if (fBitmap) {
|
||||||
DrawBitmap(fBitmap, BPoint(4, 10));
|
BPoint location;
|
||||||
|
location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2;
|
||||||
|
location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2;
|
||||||
|
DrawBitmap(fBitmap, location);
|
||||||
|
}
|
||||||
|
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
|
|
||||||
// draw a frame, which also separates multiple BStatusViews
|
if (be_control_look != NULL) {
|
||||||
rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT);
|
be_control_look->DrawRaisedBorder(this, bounds, updateRect,
|
||||||
rgb_color shadow = tint_color(ViewColor(), B_DARKEN_1_TINT);
|
ViewColor());
|
||||||
BeginLineArray(4);
|
} else {
|
||||||
AddLine(BPoint(bounds.left, bounds.bottom - 1.0f),
|
// draw a frame, which also separates multiple BStatusViews
|
||||||
BPoint(bounds.left, bounds.top), light);
|
rgb_color light = tint_color(ViewColor(), B_LIGHTEN_MAX_TINT);
|
||||||
AddLine(BPoint(bounds.left + 1.0f, bounds.top),
|
rgb_color shadow = tint_color(ViewColor(), B_DARKEN_1_TINT);
|
||||||
BPoint(bounds.right, bounds.top), light);
|
BeginLineArray(4);
|
||||||
AddLine(BPoint(bounds.right, bounds.top + 1.0f),
|
AddLine(BPoint(bounds.left, bounds.bottom - 1.0f),
|
||||||
BPoint(bounds.right, bounds.bottom), shadow);
|
BPoint(bounds.left, bounds.top), light);
|
||||||
AddLine(BPoint(bounds.right - 1.0f, bounds.bottom),
|
AddLine(BPoint(bounds.left + 1.0f, bounds.top),
|
||||||
BPoint(bounds.left, bounds.bottom), shadow);
|
BPoint(bounds.right, bounds.top), light);
|
||||||
EndLineArray();
|
AddLine(BPoint(bounds.right, bounds.top + 1.0f),
|
||||||
|
BPoint(bounds.right, bounds.bottom), shadow);
|
||||||
|
AddLine(BPoint(bounds.right - 1.0f, bounds.bottom),
|
||||||
|
BPoint(bounds.left, bounds.bottom), shadow);
|
||||||
|
EndLineArray();
|
||||||
|
}
|
||||||
|
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
|
|
||||||
BPoint tp = fStatusBar->Frame().LeftBottom();
|
BPoint tp = fStatusBar->Frame().LeftBottom();
|
||||||
font_height fh;
|
font_height fh;
|
||||||
GetFontHeight(&fh);
|
GetFontHeight(&fh);
|
||||||
tp.x += 2;
|
tp.y += ceilf(fh.leading) + ceilf(fh.ascent);
|
||||||
tp.y += fh.leading + fh.ascent;
|
|
||||||
MovePenTo(tp);
|
|
||||||
|
|
||||||
if (IsPaused())
|
if (IsPaused())
|
||||||
DrawString("Paused: click to resume or stop");
|
DrawString("Paused: click to resume or stop", tp);
|
||||||
else if (fDestDir.Length()) {
|
else if (fDestDir.Length()) {
|
||||||
BString buffer;
|
BString buffer;
|
||||||
buffer << "To: " << fDestDir;
|
buffer << "To: " << fDestDir;
|
||||||
SetHighColor(0, 0, 0);
|
SetHighColor(0, 0, 0);
|
||||||
DrawString(buffer.String());
|
DrawString(buffer.String(), tp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user