From 0cd4ecd8b24054bb29c3fa5a1ebec590eae3823f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 29 Sep 2004 19:47:18 +0000 Subject: [PATCH] cosmetical improvements to status view, it also shows the image size now git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9113 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageStatusView.cpp | 44 +++++++++++++++++++++- src/apps/showimage/ShowImageView.cpp | 3 ++ src/apps/showimage/ShowImageWindow.cpp | 13 ++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/apps/showimage/ShowImageStatusView.cpp b/src/apps/showimage/ShowImageStatusView.cpp index e030ddd24c..1b2713714f 100644 --- a/src/apps/showimage/ShowImageStatusView.cpp +++ b/src/apps/showimage/ShowImageStatusView.cpp @@ -32,12 +32,54 @@ ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) : BView(rect, name, resizingMode, flags) { + SetViewColor(B_TRANSPARENT_32_BIT); + SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + SetHighColor(0, 0, 0, 255); + + BFont font; + GetFont(&font); + font.SetSize(10.0); + SetFont(&font); } void ShowImageStatusView::Draw(BRect updateRect) { - DrawString(fText.String(), BPoint(3, 11)); + rgb_color darkShadow = tint_color(LowColor(), B_DARKEN_2_TINT); + rgb_color shadow = tint_color(LowColor(), B_DARKEN_1_TINT); + rgb_color light = tint_color(LowColor(), B_LIGHTEN_MAX_TINT); + + BRect b(Bounds()); + + BeginLineArray(5); + AddLine(BPoint(b.left, b.top), + BPoint(b.right, b.top), darkShadow); + b.top += 1.0; + AddLine(BPoint(b.left, b.top), + BPoint(b.right, b.top), light); + AddLine(BPoint(b.right, b.top + 1.0), + BPoint(b.right, b.bottom), shadow); + AddLine(BPoint(b.right - 1.0, b.bottom), + BPoint(b.left + 1.0, b.bottom), shadow); + AddLine(BPoint(b.left, b.bottom), + BPoint(b.left, b.top + 1.0), light); + EndLineArray(); + + b.InsetBy(1.0, 1.0); + + // truncate and layout text + BString truncated(fText); + BFont font; + GetFont(&font); + font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, b.Width() - 4.0); + font_height fh; + font.GetHeight(&fh); + + FillRect(b, B_SOLID_LOW); + SetDrawingMode(B_OP_OVER); + DrawString(truncated.String(), BPoint(b.left + 2.0, + floorf(b.top + b.Height() / 2.0 + + fh.ascent / 2.0))); } void diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 29ee16bf6e..c49e4c5486 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -288,6 +288,9 @@ ShowImageView::Notify(const char* status) if (status != NULL) { msg.AddString("status", status); } + msg.AddInt32("width", fBitmap->Bounds().IntegerWidth() + 1); + msg.AddInt32("height", fBitmap->Bounds().IntegerHeight() + 1); + msg.AddInt32("colors", fBitmap->ColorSpace()); BMessenger msgr(Window()); msgr.SendMessage(&msg); diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index a7cfb774e2..761cc25840 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -138,9 +138,9 @@ ShowImageWindow::ShowImageWindow(const entry_ref *pref, const BMessenger& tracke rect.left = 0; rect.right = kstatusWidth - 1; + rect.bottom -= 1; fStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM, B_WILL_DRAW); - fStatusView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); AddChild(fStatusView); rect = Bounds(); @@ -559,9 +559,18 @@ ShowImageWindow::MessageReceived(BMessage *pmsg) pmsg->FindInt32("colors", reinterpret_cast(&colors)); EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8)); + BString status; + int32 width, height; + if (pmsg->FindInt32("width", &width) >= B_OK + && pmsg->FindInt32("height", &height) >= B_OK) { + status << width << "x" << height << ", "; + } + BString str; if (pmsg->FindString("status", &str) == B_OK) - fStatusView->SetText(str); + status << str; + + fStatusView->SetText(status); UpdateTitle(); break;