From 1f62b22aa02b5e519769a8e3dfad7cdf0945cdf7 Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Thu, 27 Nov 2003 15:00:07 +0000 Subject: [PATCH] Changed Cut behavior to match Be's version so that if the user Cuts a selection before moving it, the selection is cut, and a white rectangle is left in its place. If the selection is dragged before the Cut command is used, a white rectangle is not drawn. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5489 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageView.cpp | 34 ++++++++++++++++++++++++++++ src/apps/showimage/ShowImageView.h | 1 + 2 files changed, 35 insertions(+) diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index b9a318bab9..e5d40b266e 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -1411,11 +1411,45 @@ ShowImageView::PageCount() return fDocumentCount; } +void +ShowImageView::AddWhiteRect(BRect &rect) +{ + // Paint white rectangle, using rect, into the background image + BView view(fBitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW); + BBitmap *bitmap = new BBitmap(fBitmap->Bounds(), fBitmap->ColorSpace(), true); + if (bitmap == NULL) + return; + + if (bitmap->Lock()) { + bitmap->AddChild(&view); + view.DrawBitmap(fBitmap, fBitmap->Bounds()); + + view.FillRect(rect, B_SOLID_LOW); + // draw white rect + + view.Sync(); + bitmap->RemoveChild(&view); + bitmap->Unlock(); + + DeleteBitmap(); + fBitmap = bitmap; + } else + delete bitmap; +} + void ShowImageView::Cut() { + BRect rect = fSelectionRect; + bool bCutBackground = (fSelBitmap) ? false : true; + CopySelectionToClipboard(); ClearSelection(); + + if (bCutBackground) + // If the user hasn't dragged the selection, + // paint a white rectangle where the selection was + AddWhiteRect(rect); } void diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 3acd38dc54..92a50701ca 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -129,6 +129,7 @@ private: void AnimateSelection(bool a); void Notify(const char* status); void AddToRecentDocuments(); + void AddWhiteRect(BRect &rect); void GetSelMergeRects(BRect &srcBits, BRect &destRect); void MergeSelection(); void DeleteScaler();