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
This commit is contained in:
Matthew Wilber 2003-12-11 01:33:50 +00:00
parent 187f0b8a33
commit 664c5b6911
2 changed files with 11 additions and 16 deletions

View File

@ -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);
}

View File

@ -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