From 69eee339bad0aed4b9c4a99226a2cc0f64fb8513 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Tue, 25 Apr 2006 06:10:26 +0000 Subject: [PATCH] More changes to ShowImage: 1. The newly renamed "Flip Sideways" and "Flip Upside Down" have been renamed again to "Flip Left To Right" and "Flip Top To Bottom". This was after some feedback indicating a preference for the new names. 2. When dragging a selection the standard outlined rectangle is used for the dragging image instead of the alpha-blended bitmap of the selected part of the image if the selection rectangle is larger than 400x400 (taking into account scaling of the image.) This mimics the original ShowImage with the exception of the minimum size. The choice of 400x400 was fairly arbitrary. I may see about turning that value into some kind of hidden option. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17229 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/Filter.cpp | 4 +-- src/apps/showimage/Filter.h | 4 +-- src/apps/showimage/ShowImageConstants.h | 4 +-- src/apps/showimage/ShowImageView.cpp | 42 ++++++++++++++++--------- src/apps/showimage/ShowImageWindow.cpp | 8 ++--- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index b9521bd7f9..dbd78352f4 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -1068,7 +1068,7 @@ ImageProcessor::Run(int32 i, int32 n) } } break; - case kFlipUpsideDown: + case kFlipTopToBottom: for (y = from; y <= to; y ++) { for (x = 0; x <= fWidth; x ++) { destX = x; @@ -1077,7 +1077,7 @@ ImageProcessor::Run(int32 i, int32 n) } } break; - case kFlipSideways: + case kFlipLeftToRight: for (y = from; y <= to; y ++) { for (x = 0; x <= fWidth; x ++) { destX = fWidth - x; diff --git a/src/apps/showimage/Filter.h b/src/apps/showimage/Filter.h index d1faa19d32..86b8b89b6d 100644 --- a/src/apps/showimage/Filter.h +++ b/src/apps/showimage/Filter.h @@ -189,8 +189,8 @@ public: enum operation { kRotateClockwise, kRotateAntiClockwise, - kFlipSideways, - kFlipUpsideDown, + kFlipLeftToRight, + kFlipTopToBottom, kInvert, kNumberOfAffineTransformations = 4 }; diff --git a/src/apps/showimage/ShowImageConstants.h b/src/apps/showimage/ShowImageConstants.h index a8c5bd5ff3..46a8ca5d8c 100644 --- a/src/apps/showimage/ShowImageConstants.h +++ b/src/apps/showimage/ShowImageConstants.h @@ -40,8 +40,8 @@ const uint32 MSG_SHRINK_TO_WINDOW = 'mSTW'; const uint32 MSG_ZOOM_TO_WINDOW = 'mZTW'; const uint32 MSG_ROTATE_90 = 'mR90'; const uint32 MSG_ROTATE_270 = 'mR27'; -const uint32 MSG_FLIP_SIDEWAYS = 'mFSW'; -const uint32 MSG_FLIP_UPSIDE_DOWN = 'mFUD'; +const uint32 MSG_FLIP_LEFT_TO_RIGHT = 'mFLR'; +const uint32 MSG_FLIP_TOP_TO_BOTTOM = 'mFTB'; const uint32 MSG_INVERT = 'mINV'; const uint32 MSG_SLIDE_SHOW = 'mSSW'; const uint32 MSG_SLIDE_SHOW_DELAY = 'mSSD'; diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 40b32cfe0b..736e040116 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -497,18 +497,18 @@ ShowImageView::SetImage(const entry_ref *ref) DoImageOperation(ImageProcessor::kRotateAntiClockwise, true); break; case k0V: - DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true); + DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; case k90V: DoImageOperation(ImageProcessor::kRotateClockwise, true); - DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true); + DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; case k0H: - DoImageOperation(ImageProcessor::ImageProcessor::kFlipSideways, true); + DoImageOperation(ImageProcessor::ImageProcessor::kFlipLeftToRight, true); break; case k270V: DoImageOperation(ImageProcessor::kRotateAntiClockwise, true); - DoImageOperation(ImageProcessor::ImageProcessor::kFlipUpsideDown, true); + DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true); break; } } @@ -1136,7 +1136,6 @@ ShowImageView::BeginDrag(BPoint sourcePoint) return; SetMouseEventMask(B_POINTER_EVENTS); - BPoint leftTop(fSelectionRect.left, fSelectionRect.top); // fill the drag message BMessage drag(B_SIMPLE_DATA); @@ -1150,12 +1149,25 @@ ShowImageView::BeginDrag(BPoint sourcePoint) drag.AddString("be:types", B_FILE_MIME_TYPE); // avoid flickering of dragged bitmap caused by drawing into the window AnimateSelection(false); - sourcePoint -= leftTop; - sourcePoint.x *= fScaleX; - sourcePoint.y *= fScaleY; - // DragMessage takes ownership of bitmap - DragMessage(&drag, bitmap, B_OP_ALPHA, sourcePoint); - bitmap = NULL; + // only use a transparent bitmap on selections less than 400x400 (taking into account scaling) + if ((fSelectionRect.Width() * fScaleX) < 400.0 && (fSelectionRect.Height() * fScaleY) < 400.0) + { + sourcePoint -= fSelectionRect.LeftTop(); + sourcePoint.x *= fScaleX; + sourcePoint.y *= fScaleY; + // DragMessage takes ownership of bitmap + DragMessage(&drag, bitmap, B_OP_ALPHA, sourcePoint); + bitmap = NULL; + } + else + { + delete bitmap; + // Offset and scale the rect + BRect rect(fSelectionRect); + rect = ImageToView(rect); + rect.InsetBy(-1, -1); + DragMessage(&drag, rect); + } } } @@ -2392,8 +2404,8 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet) // Note: If one of these fails, check its definition in class ImageProcessor. ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations); ASSERT(ImageProcessor::kRotateAntiClockwise < ImageProcessor::kNumberOfAffineTransformations); - ASSERT(ImageProcessor::kFlipSideways < ImageProcessor::kNumberOfAffineTransformations); - ASSERT(ImageProcessor::kFlipUpsideDown < ImageProcessor::kNumberOfAffineTransformations); + ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations); + ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations); fImageOrientation = fTransformation[op][fImageOrientation]; } else { fInverted = !fInverted; @@ -2447,9 +2459,9 @@ void ShowImageView::Flip(bool vertical) { if (vertical) { - UserDoImageOperation(ImageProcessor::kFlipSideways); + UserDoImageOperation(ImageProcessor::kFlipLeftToRight); } else { - UserDoImageOperation(ImageProcessor::kFlipUpsideDown); + UserDoImageOperation(ImageProcessor::kFlipTopToBottom); } } diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 7ec4aaa3cd..9d9ef205ed 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -329,8 +329,8 @@ ShowImageWindow::AddMenus(BMenuBar *bar) AddItemMenu(menu, "Rotate -90°", MSG_ROTATE_270, '[', 0, 'W', true); AddItemMenu(menu, "Rotate +90°", MSG_ROTATE_90, ']', 0, 'W', true); menu->AddSeparatorItem(); - AddItemMenu(menu, "Flip Sideways", MSG_FLIP_SIDEWAYS, 0, 0, 'W', true); - AddItemMenu(menu, "Flip Upside Down", MSG_FLIP_UPSIDE_DOWN, 0, 0, 'W', true); + AddItemMenu(menu, "Flip Left To Right", MSG_FLIP_LEFT_TO_RIGHT, 0, 0, 'W', true); + AddItemMenu(menu, "Flip Top To Bottom", MSG_FLIP_TOP_TO_BOTTOM, 0, 0, 'W', true); menu->AddSeparatorItem(); AddItemMenu(menu, "Invert", MSG_INVERT, 0, 0, 'W', true); bar->AddItem(menu); @@ -717,10 +717,10 @@ ShowImageWindow::MessageReceived(BMessage *message) case MSG_ROTATE_270: fImageView->Rotate(270); break; - case MSG_FLIP_SIDEWAYS: + case MSG_FLIP_LEFT_TO_RIGHT: fImageView->Flip(true); break; - case MSG_FLIP_UPSIDE_DOWN: + case MSG_FLIP_TOP_TO_BOTTOM: fImageView->Flip(false); break; case MSG_INVERT: