From 664c5b6911215b2979b1e87fa79ecd53ae5911e0 Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Thu, 11 Dec 2003 01:33:50 +0000 Subject: [PATCH] Removed unneeded calls to Invalidate(), changed minimum size for selection rectangle so that users can click in an empty section of the window to unselect the selection git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5641 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageView.cpp | 23 +++++++++-------------- src/apps/showimage/ShowImageView.h | 4 ++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 42e4cdd109..980ffa89e3 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -188,7 +188,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, fDocumentIndex = 1; fDocumentCount = 1; fAnimateSelection = true; - fbHasSelection = false; + fHasSelection = false; fShrinkToBounds = false; fZoomToBounds = false; fHasBorder = true; @@ -1020,10 +1020,8 @@ ShowImageView::MoveImage() fFirstPoint = point; ScrollRestrictedBy(delta.x, delta.y); // in case we miss MouseUp - if ((GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0) { + if ((GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0) fMovesImage = false; - Invalidate(); - } } uint32 @@ -1167,12 +1165,12 @@ ShowImageView::MouseDown(BPoint position) SetMouseEventMask(B_POINTER_EVENTS); fMovesImage = true; fFirstPoint = ConvertToScreen(position); - Invalidate(); } } void -ShowImageView::UpdateSelectionRect(BPoint point, bool final) { +ShowImageView::UpdateSelectionRect(BPoint point, bool final) +{ BRect oldSelection = fCopyFromRect; point = ViewToImage(point); ConstrainToImage(point); @@ -1182,10 +1180,9 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final) { fCopyFromRect.bottom = max(fFirstPoint.y, point.y); fSelectionRect = fCopyFromRect; if (final) { - // selection must contain a few pixels - if ((fCopyFromRect.Width()+1.0) * (fCopyFromRect.Height()+1.0) < 1) { + // selection must be at least 2 pixels wide or 2 pixels tall + if (fCopyFromRect.Width() < 1.0 && fCopyFromRect.Height() < 1.0) SetHasSelection(false); - } } if (oldSelection != fCopyFromRect || !HasSelection()) { BRect updateRect; @@ -1214,10 +1211,8 @@ ShowImageView::MouseUp(BPoint point) fMakesSelection = false; } else if (fMovesImage) { MoveImage(); - if (fMovesImage) { + if (fMovesImage) fMovesImage = false; - Invalidate(); - } } AnimateSelection(true); } @@ -1543,10 +1538,10 @@ void ShowImageView::SetHasSelection(bool bHasSelection) { DeleteSelBitmap(); - fbHasSelection = bHasSelection; + fHasSelection = bHasSelection; BMessage msg(MSG_SELECTION); - msg.AddBool("has_selection", fbHasSelection); + msg.AddBool("has_selection", fHasSelection); BMessenger msgr(Window()); msgr.SendMessage(&msg); } diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 8ac8c6f0ad..1fb81a2a10 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -126,7 +126,7 @@ private: }; void InitPatterns(); void RotatePatterns(); - bool HasSelection() { return fbHasSelection; } + bool HasSelection() { return fHasSelection; } void SetHasSelection(bool bHasSelection); void AnimateSelection(bool a); void Notify(const char* status); @@ -203,7 +203,7 @@ private: bool fMakesSelection; // is a selection being made BPoint fFirstPoint; // first point in image space of selection bool fAnimateSelection; // marching ants - bool fbHasSelection; // is fSelectionRect valid + bool fHasSelection; // is fSelectionRect valid BRect fSelectionRect; // the current location of the selection rectangle BRect fCopyFromRect; // the portion of the background bitmap the selection is made from