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
This commit is contained in:
Ryan Leavengood
2006-04-25 06:10:26 +00:00
parent d59df8688e
commit 69eee339ba
5 changed files with 37 additions and 25 deletions
+2 -2
View File
@@ -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;
+2 -2
View File
@@ -189,8 +189,8 @@ public:
enum operation {
kRotateClockwise,
kRotateAntiClockwise,
kFlipSideways,
kFlipUpsideDown,
kFlipLeftToRight,
kFlipTopToBottom,
kInvert,
kNumberOfAffineTransformations = 4
};
+2 -2
View File
@@ -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';
+27 -15
View File
@@ -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);
}
}
+4 -4
View File
@@ -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: