The size of the selection rectangle is now shown in the status bar. Useful for

cropping an image to a certain size or taking similar sized croppings from
various images (as I need to do.)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20012 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2007-01-29 20:29:16 +00:00
parent 923ce6f922
commit 8f5fd23f60
4 changed files with 45 additions and 9 deletions

View File

@ -402,6 +402,25 @@ ShowImageView::Notify()
}
void
ShowImageView::UpdateStatusText()
{
BMessage msg(MSG_UPDATE_STATUS_TEXT);
BString status_to_send = fImageType;
if (fHasSelection) {
char size[50];
sprintf(size, " (%.0fx%.0f)",
fSelectionRect.Width()+1.0,
fSelectionRect.Height()+1.0);
status_to_send << size;
}
msg.AddString("status", status_to_send.String());
SendMessageToWindow(&msg);
}
void
ShowImageView::AddToRecentDocuments()
{
@ -1480,7 +1499,8 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final)
// selection must be at least 2 pixels wide or 2 pixels tall
if (fCopyFromRect.Width() < 1.0 && fCopyFromRect.Height() < 1.0)
SetHasSelection(false);
}
} else
UpdateStatusText();
if (oldSelection != fCopyFromRect || !HasSelection()) {
BRect updateRect;
@ -1866,9 +1886,9 @@ ShowImageView::Undo()
if (!undoSelection)
SetHasSelection(false);
else {
SetHasSelection(true);
fCopyFromRect = BRect();
fSelectionRect = fUndo.GetRect();
SetHasSelection(true);
fSelBitmap = undoSelection;
}
@ -1952,10 +1972,10 @@ ShowImageView::PasteBitmap(BBitmap *bitmap, BPoint point)
if (bitmap && bitmap->IsValid()) {
MergeSelection();
SetHasSelection(true);
fSelBitmap = bitmap;
fCopyFromRect = BRect();
fSelectionRect = bitmap->Bounds();
SetHasSelection(true);
fSelBitmap = bitmap;
BRect offsetRect = fSelectionRect;
offsetRect.OffsetBy(point);
@ -2016,6 +2036,8 @@ ShowImageView::SetHasSelection(bool bHasSelection)
{
DeleteSelBitmap();
fHasSelection = bHasSelection;
UpdateStatusText();
BMessage msg(MSG_SELECTION);
msg.AddBool("has_selection", fHasSelection);

View File

@ -136,6 +136,7 @@ class ShowImageView : public BView {
void SendMessageToWindow(BMessage *message);
void SendMessageToWindow(uint32 code);
void Notify();
void UpdateStatusText();
void AddToRecentDocuments();
void AddWhiteRect(BRect &rect);
void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect);

View File

@ -97,6 +97,7 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
fImageView = NULL;
fSlideShowDelay = NULL;
fResizerWindowMessenger = NULL;
fHeight = fWidth = 0;
LoadSettings();
@ -591,10 +592,9 @@ ShowImageWindow::MessageReceived(BMessage *message)
BString status;
bool messageProvidesSize = false;
int32 width, height;
if (message->FindInt32("width", &width) >= B_OK
&& message->FindInt32("height", &height) >= B_OK) {
status << width << "x" << height;
if (message->FindInt32("width", &fWidth) >= B_OK
&& message->FindInt32("height", &fHeight) >= B_OK) {
status << fWidth << "x" << fHeight;
messageProvidesSize = true;
}
@ -606,7 +606,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
}
if (messageProvidesSize) {
UpdateResizerWindow(width, height);
UpdateResizerWindow(fWidth, fHeight);
}
fStatusView->SetText(status);
@ -615,6 +615,18 @@ ShowImageWindow::MessageReceived(BMessage *message)
break;
}
case MSG_UPDATE_STATUS_TEXT:
{
BString status;
status << fWidth << "x" << fHeight;
BString str;
if (message->FindString("status", &str) == B_OK && str.Length() > 0) {
status << ", " << str;
fStatusView->SetText(status);
}
break;
}
case MSG_SELECTION:
{
// The view sends this message when a selection is

View File

@ -98,6 +98,7 @@ class ShowImageWindow : public BWindow {
BMessage *fPrintSettings;
PrintOptions fPrintOptions;
BMessenger* fResizerWindowMessenger;
int32 fHeight, fWidth;
};
#endif // SHOW_IMAGE_WINDOW_H