General changes:
- Fixed some formatting in the recently added resizing code. - Changed the operation name for rotating counterclockwise to use that name instead of anticlockwise. This makes the code consistent with the GUI. - Reformatted the constants header to use an enum. Also removed the empty constants cpp file. - The QuitRequested handler in the app did not ask the windows to close, which could cause modified images to be closed without prompting the user. Now it does, which makes ShowImage more user friendly. Changes to the image view: - Added a member for keeping track of the type of image. This is mostly used in properly updating the window's status bar when the image is changed (flipped, rotated, etc.) This removes some hacky code I added before :) - Removed the status parameter in the Notify method since it was only used for the above image type status updating. - Removed a redundant if in the mouse up handler. - The key down handlers for moving to the next and previous image did not properly prompt the user if the image had changed. I fixed this by sending a message to the window where the prompting code resides. When adding this I also created a few helper methods for sending messages to the window, which removed some (small) repeated code through-out the class. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19994 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*
|
||||
* Authors:
|
||||
* Michael Pfeiffer, [email protected]
|
||||
* Ryan Leavengood, [email protected]
|
||||
* yellowTAB GmbH
|
||||
* Bernd Korz
|
||||
*/
|
||||
@@ -939,7 +940,7 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */)
|
||||
fWidth = GetSrcImage()->Bounds().IntegerWidth();
|
||||
fHeight = GetSrcImage()->Bounds().IntegerHeight();
|
||||
|
||||
if (fOp == kRotateClockwise || fOp == kRotateAntiClockwise) {
|
||||
if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) {
|
||||
rect.Set(0, 0, fHeight, fWidth);
|
||||
} else {
|
||||
rect.Set(0, 0, fWidth, fHeight);
|
||||
@@ -1056,7 +1057,7 @@ ImageProcessor::Run(int32 i, int32 n)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kRotateAntiClockwise:
|
||||
case kRotateCounterClockwise:
|
||||
for (y = from; y <= to; y ++) {
|
||||
for (x = 0; x <= fWidth; x ++) {
|
||||
destX = y;
|
||||
|
||||
@@ -188,7 +188,7 @@ class ImageProcessor : public Filter {
|
||||
public:
|
||||
enum operation {
|
||||
kRotateClockwise,
|
||||
kRotateAntiClockwise,
|
||||
kRotateCounterClockwise,
|
||||
kFlipLeftToRight,
|
||||
kFlipTopToBottom,
|
||||
kInvert,
|
||||
|
||||
@@ -5,7 +5,6 @@ UsePrivateHeaders tracker ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
Application ShowImage : ShowImageApp.cpp
|
||||
ShowImageConstants.cpp
|
||||
ShowImageSettings.cpp
|
||||
ShowImageStatusView.cpp
|
||||
ShowImageUndo.cpp
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||
* Distributed under the terms of the MIT License.
|
||||
@@ -8,26 +8,10 @@
|
||||
* yellowTAB GmbH
|
||||
* Bernd Korz
|
||||
* Michael Pfeiffer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* Ryan Leavengood
|
||||
*/
|
||||
|
||||
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <CheckBox.h>
|
||||
@@ -41,6 +25,7 @@
|
||||
#include "ResizerWindow.h"
|
||||
#include "ShowImageConstants.h"
|
||||
|
||||
|
||||
static const char* kWidthLabel = "Width:";
|
||||
static const char* kHeightLabel = "Height:";
|
||||
static const char* kKeepAspectRatioLabel = "Keep Original Proportions";
|
||||
@@ -50,6 +35,7 @@ static const float kLineDistance = 5;
|
||||
static const float kHorizontalIndent = 10;
|
||||
static const float kVerticalIndent = 10;
|
||||
|
||||
|
||||
ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
||||
: BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
|
||||
, fOriginalWidth(width)
|
||||
@@ -100,6 +86,7 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
|
||||
ResizeTo(width2, rect.top);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect& rect)
|
||||
{
|
||||
@@ -119,6 +106,7 @@ ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect&
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
|
||||
{
|
||||
@@ -133,6 +121,7 @@ ResizerWindow::AddSeparatorLine(BView* view, BRect& rect)
|
||||
rect.OffsetBy(0, kLineDistance + lineWidth);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResizerWindow::LeftAlign(BControl* control)
|
||||
{
|
||||
@@ -141,6 +130,7 @@ ResizerWindow::LeftAlign(BControl* control)
|
||||
control->MoveTo(left, frame.top);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ResizerWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
@@ -175,7 +165,8 @@ ResizerWindow::MessageReceived(BMessage* message)
|
||||
|
||||
// private actions
|
||||
case kResolutionMsg:
|
||||
{ fAspectRatio->SetValue(B_CONTROL_OFF);
|
||||
{
|
||||
fAspectRatio->SetValue(B_CONTROL_OFF);
|
||||
BString width, height;
|
||||
width << message->FindInt32("w");
|
||||
height << message->FindInt32("h");
|
||||
@@ -184,8 +175,7 @@ ResizerWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
case kWidthModifiedMsg:
|
||||
if (fAspectRatio->Value() == B_CONTROL_ON)
|
||||
{
|
||||
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
||||
int w = atoi(fWidth->Text());
|
||||
int h = (int)((int64)w * (int64) fOriginalHeight / (int64) fOriginalWidth);
|
||||
BString height;
|
||||
@@ -197,8 +187,7 @@ ResizerWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
break;
|
||||
case kHeightModifiedMsg:
|
||||
if (fAspectRatio->Value() == B_CONTROL_ON)
|
||||
{
|
||||
if (fAspectRatio->Value() == B_CONTROL_ON) {
|
||||
int h = atoi(fHeight->Text());
|
||||
int w = (int)((int64)h * (int64) fOriginalWidth / (int64) fOriginalHeight);
|
||||
BString width;
|
||||
@@ -223,13 +212,16 @@ ResizerWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ResizerWindow::~ResizerWindow()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ResizerWindow::QuitRequested()
|
||||
{
|
||||
fTarget.SendMessage(MSG_RESIZER_WINDOW_QUITED);
|
||||
fTarget.SendMessage(MSG_RESIZER_WINDOW_QUIT);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||
* Distributed under the terms of the MIT License.
|
||||
@@ -8,29 +8,12 @@
|
||||
* yellowTAB GmbH
|
||||
* Bernd Korz
|
||||
* Michael Pfeiffer
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* Ryan Leavengood
|
||||
*/
|
||||
|
||||
#ifndef _resizer_window_h
|
||||
#define _resizer_window_h
|
||||
|
||||
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
@@ -38,6 +21,7 @@
|
||||
class BTextControl;
|
||||
class BCheckBox;
|
||||
|
||||
|
||||
class ResizerWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
* Ryan Leavengood
|
||||
*/
|
||||
|
||||
|
||||
@@ -228,10 +229,16 @@ ShowImageApp::CheckClipboard()
|
||||
bool
|
||||
ShowImageApp::QuitRequested()
|
||||
{
|
||||
be_clipboard->StopWatching(be_app_messenger);
|
||||
// tell clipboard we don't want anymore notification
|
||||
// Give the windows a chance to prompt the user if there are changes
|
||||
BMessage msg(B_QUIT_REQUESTED);
|
||||
BroadcastToWindows(&msg);
|
||||
if (CountWindows() <= WINDOWS_TO_IGNORE) {
|
||||
be_clipboard->StopWatching(be_app_messenger);
|
||||
// tell clipboard we don't want anymore notification
|
||||
|
||||
return true;
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
// ShowImageConstants
|
||||
// Written by Fernando Francisco de Oliveira, Michael Wilber
|
||||
//
|
||||
// ShowImageConstants.cpp
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2003 OpenBeOS Project
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "ShowImageConstants.h"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Fernando Francisco de Oliveira
|
||||
* Michael Wilber
|
||||
* Michael Pfeiffer
|
||||
* Ryan Leavengood
|
||||
*/
|
||||
#ifndef SHOW_IMAGE_CONSTANTS_H
|
||||
#define SHOW_IMAGE_CONSTANTS_H
|
||||
@@ -14,51 +15,54 @@
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
const uint32 MSG_CAPTURE_MOUSE = 'mCPM';
|
||||
const uint32 MSG_CHANGE_FOCUS = 'mCFS';
|
||||
const uint32 MSG_FILE_OPEN = 'mFOP';
|
||||
const uint32 MSG_WINDOW_QUIT = 'mWQT';
|
||||
const uint32 MSG_OUTPUT_TYPE = 'BTMN';
|
||||
const uint32 MSG_SAVE_PANEL = 'mFSP';
|
||||
const uint32 MSG_CLEAR_SELECT = 'mCSL';
|
||||
const uint32 MSG_SELECT_ALL = 'mSAL';
|
||||
const uint32 MSG_CLIPBOARD_CHANGED = 'mCLP';
|
||||
const uint32 MSG_DITHER_IMAGE = 'mDIM';
|
||||
const uint32 MSG_MODIFIED = 'mMOD';
|
||||
const uint32 MSG_UPDATE_STATUS = 'mUPS';
|
||||
const uint32 MSG_UNDO_STATE = 'mUNS';
|
||||
const uint32 MSG_SELECTION = 'mSEL';
|
||||
const uint32 MSG_SELECTION_BITMAP = 'mSBT';
|
||||
const uint32 MSG_PAGE_FIRST = 'mPGF';
|
||||
const uint32 MSG_PAGE_LAST = 'mPGL';
|
||||
const uint32 MSG_PAGE_NEXT = 'mPGN';
|
||||
const uint32 MSG_PAGE_PREV = 'mPGP';
|
||||
const uint32 MSG_GOTO_PAGE = 'mGTP';
|
||||
const uint32 MSG_FILE_NEXT = 'mFLN';
|
||||
const uint32 MSG_FILE_PREV = 'mFLP';
|
||||
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_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';
|
||||
const uint32 MSG_FULL_SCREEN = 'mFSC';
|
||||
const uint32 MSG_EXIT_FULL_SCREEN = 'mEFS';
|
||||
const uint32 MSG_SHOW_CAPTION = 'mSCP';
|
||||
const uint32 MSG_PAGE_SETUP = 'mPSU';
|
||||
const uint32 MSG_PREPARE_PRINT = 'mPPT';
|
||||
const uint32 MSG_PRINT = 'mPRT';
|
||||
const uint32 MSG_ZOOM_IN = 'mZIN';
|
||||
const uint32 MSG_ZOOM_OUT = 'mZOU';
|
||||
const uint32 MSG_ORIGINAL_SIZE = 'mOSZ';
|
||||
const uint32 MSG_INVALIDATE = 'mIVD';
|
||||
const uint32 MSG_SCALE_BILINEAR = 'mSBL';
|
||||
const uint32 MSG_DESKTOP_BACKGROUND = 'mDBG';
|
||||
const uint32 MSG_OPEN_RESIZER_WINDOW = 'mORS';
|
||||
const uint32 MSG_RESIZER_WINDOW_QUITED = 'mRSQ';
|
||||
const uint32 MSG_RESIZE = 'mRSZ';
|
||||
enum {
|
||||
MSG_CAPTURE_MOUSE = 'mCPM',
|
||||
MSG_CHANGE_FOCUS = 'mCFS',
|
||||
MSG_FILE_OPEN = 'mFOP',
|
||||
MSG_WINDOW_QUIT = 'mWQT',
|
||||
MSG_OUTPUT_TYPE = 'BTMN',
|
||||
MSG_SAVE_PANEL = 'mFSP',
|
||||
MSG_CLEAR_SELECT = 'mCSL',
|
||||
MSG_SELECT_ALL = 'mSAL',
|
||||
MSG_CLIPBOARD_CHANGED = 'mCLP',
|
||||
MSG_DITHER_IMAGE = 'mDIM',
|
||||
MSG_MODIFIED = 'mMOD',
|
||||
MSG_UPDATE_STATUS = 'mUPS',
|
||||
MSG_UPDATE_STATUS_TEXT = 'mUPT',
|
||||
MSG_UNDO_STATE = 'mUNS',
|
||||
MSG_SELECTION = 'mSEL',
|
||||
MSG_SELECTION_BITMAP = 'mSBT',
|
||||
MSG_PAGE_FIRST = 'mPGF',
|
||||
MSG_PAGE_LAST = 'mPGL',
|
||||
MSG_PAGE_NEXT = 'mPGN',
|
||||
MSG_PAGE_PREV = 'mPGP',
|
||||
MSG_GOTO_PAGE = 'mGTP',
|
||||
MSG_FILE_NEXT = 'mFLN',
|
||||
MSG_FILE_PREV = 'mFLP',
|
||||
MSG_SHRINK_TO_WINDOW = 'mSTW',
|
||||
MSG_ZOOM_TO_WINDOW = 'mZTW',
|
||||
MSG_ROTATE_90 = 'mR90',
|
||||
MSG_ROTATE_270 = 'mR27',
|
||||
MSG_FLIP_LEFT_TO_RIGHT = 'mFLR',
|
||||
MSG_FLIP_TOP_TO_BOTTOM = 'mFTB',
|
||||
MSG_INVERT = 'mINV',
|
||||
MSG_SLIDE_SHOW = 'mSSW',
|
||||
MSG_SLIDE_SHOW_DELAY = 'mSSD',
|
||||
MSG_FULL_SCREEN = 'mFSC',
|
||||
MSG_EXIT_FULL_SCREEN = 'mEFS',
|
||||
MSG_SHOW_CAPTION = 'mSCP',
|
||||
MSG_PAGE_SETUP = 'mPSU',
|
||||
MSG_PREPARE_PRINT = 'mPPT',
|
||||
MSG_PRINT = 'mPRT',
|
||||
MSG_ZOOM_IN = 'mZIN',
|
||||
MSG_ZOOM_OUT = 'mZOU',
|
||||
MSG_ORIGINAL_SIZE = 'mOSZ',
|
||||
MSG_INVALIDATE = 'mIVD',
|
||||
MSG_SCALE_BILINEAR = 'mSBL',
|
||||
MSG_DESKTOP_BACKGROUND = 'mDBG',
|
||||
MSG_OPEN_RESIZER_WINDOW = 'mORS',
|
||||
MSG_RESIZER_WINDOW_QUIT = 'mRSQ',
|
||||
MSG_RESIZE = 'mRSZ',
|
||||
};
|
||||
|
||||
#endif // SHOW_IMAGE_CONSTANTS_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
|
||||
* Copyright 2006 Bernd Korz. All Rights Reserved
|
||||
* Distributed under the terms of the MIT License.
|
||||
@@ -368,20 +368,34 @@ ShowImageView::SetTrackerMessenger(const BMessenger& trackerMessenger)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageView::SendMessageToWindow(BMessage *message)
|
||||
{
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageView::SendMessageToWindow(uint32 code)
|
||||
{
|
||||
BMessage message(code);
|
||||
SendMessageToWindow(&message);
|
||||
}
|
||||
|
||||
|
||||
//! send message to parent about new image
|
||||
void
|
||||
ShowImageView::Notify(const char* status)
|
||||
ShowImageView::Notify()
|
||||
{
|
||||
BMessage msg(MSG_UPDATE_STATUS);
|
||||
if (status != NULL) {
|
||||
msg.AddString("status", status);
|
||||
}
|
||||
|
||||
msg.AddString("status", fImageType.String());
|
||||
msg.AddInt32("width", fBitmap->Bounds().IntegerWidth() + 1);
|
||||
msg.AddInt32("height", fBitmap->Bounds().IntegerHeight() + 1);
|
||||
|
||||
msg.AddInt32("colors", fBitmap->ColorSpace());
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(&msg);
|
||||
SendMessageToWindow(&msg);
|
||||
|
||||
FixupScrollBars();
|
||||
Invalidate();
|
||||
@@ -511,7 +525,7 @@ ShowImageView::SetImage(const entry_ref *ref)
|
||||
DoImageOperation(ImageProcessor::kRotateClockwise, true);
|
||||
break;
|
||||
case k270:
|
||||
DoImageOperation(ImageProcessor::kRotateAntiClockwise, true);
|
||||
DoImageOperation(ImageProcessor::kRotateCounterClockwise, true);
|
||||
break;
|
||||
case k0V:
|
||||
DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true);
|
||||
@@ -524,7 +538,7 @@ ShowImageView::SetImage(const entry_ref *ref)
|
||||
DoImageOperation(ImageProcessor::ImageProcessor::kFlipLeftToRight, true);
|
||||
break;
|
||||
case k270V:
|
||||
DoImageOperation(ImageProcessor::kRotateAntiClockwise, true);
|
||||
DoImageOperation(ImageProcessor::kRotateCounterClockwise, true);
|
||||
DoImageOperation(ImageProcessor::ImageProcessor::kFlipTopToBottom, true);
|
||||
break;
|
||||
}
|
||||
@@ -538,15 +552,17 @@ ShowImageView::SetImage(const entry_ref *ref)
|
||||
else
|
||||
fDocumentCount = 1;
|
||||
|
||||
fImageType = info.name;
|
||||
|
||||
GetPath(&fCaption);
|
||||
if (fDocumentCount > 1)
|
||||
fCaption << ", " << fDocumentIndex << "/" << fDocumentCount;
|
||||
|
||||
fCaption << ", " << info.name;
|
||||
fCaption << ", " << fImageType;
|
||||
|
||||
AddToRecentDocuments();
|
||||
|
||||
Notify(info.name);
|
||||
Notify();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -1104,7 +1120,7 @@ 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);
|
||||
// only use a transparent bitmap on selections less than 400x400 (taking into account scaling)
|
||||
// only use a transparent bitmap on selections less than 400x400 (taking into account zooming)
|
||||
if ((fSelectionRect.Width() * fZoom) < 400.0 && (fSelectionRect.Height() * fZoom) < 400.0)
|
||||
{
|
||||
sourcePoint -= fSelectionRect.LeftTop();
|
||||
@@ -1352,8 +1368,7 @@ ShowImageView::MergeWithBitmap(BBitmap *merge, BRect selection)
|
||||
DeleteBitmap();
|
||||
fBitmap = bitmap;
|
||||
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(MSG_MODIFIED);
|
||||
SendMessageToWindow(MSG_MODIFIED);
|
||||
} else
|
||||
delete bitmap;
|
||||
}
|
||||
@@ -1466,6 +1481,7 @@ ShowImageView::UpdateSelectionRect(BPoint point, bool final)
|
||||
if (fCopyFromRect.Width() < 1.0 && fCopyFromRect.Height() < 1.0)
|
||||
SetHasSelection(false);
|
||||
}
|
||||
|
||||
if (oldSelection != fCopyFromRect || !HasSelection()) {
|
||||
BRect updateRect;
|
||||
updateRect = oldSelection | fCopyFromRect;
|
||||
@@ -1496,8 +1512,7 @@ ShowImageView::MouseUp(BPoint point)
|
||||
fMakesSelection = false;
|
||||
} else if (fMovesImage) {
|
||||
MoveImage();
|
||||
if (fMovesImage)
|
||||
fMovesImage = false;
|
||||
fMovesImage = false;
|
||||
}
|
||||
AnimateSelection(true);
|
||||
}
|
||||
@@ -1593,10 +1608,10 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
||||
ScrollRestrictedBy(10, 0);
|
||||
break;
|
||||
case B_ENTER:
|
||||
NextFile();
|
||||
SendMessageToWindow(MSG_FILE_NEXT);
|
||||
break;
|
||||
case B_BACKSPACE:
|
||||
PrevFile();
|
||||
SendMessageToWindow(MSG_FILE_PREV);
|
||||
break;
|
||||
case B_HOME:
|
||||
break;
|
||||
@@ -1626,8 +1641,7 @@ ShowImageView::KeyDown(const char* bytes, int32 numBytes)
|
||||
if (!NextFile()) {
|
||||
// This is the last (or only file) in this directory,
|
||||
// close the window
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(B_QUIT_REQUESTED);
|
||||
SendMessageToWindow(B_QUIT_REQUESTED);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1889,8 +1903,7 @@ ShowImageView::AddWhiteRect(BRect &rect)
|
||||
DeleteBitmap();
|
||||
fBitmap = bitmap;
|
||||
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(MSG_MODIFIED);
|
||||
SendMessageToWindow(MSG_MODIFIED);
|
||||
} else
|
||||
delete bitmap;
|
||||
}
|
||||
@@ -2006,8 +2019,7 @@ ShowImageView::SetHasSelection(bool bHasSelection)
|
||||
|
||||
BMessage msg(MSG_SELECTION);
|
||||
msg.AddBool("has_selection", fHasSelection);
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(&msg);
|
||||
SendMessageToWindow(&msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -2377,7 +2389,7 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
||||
if (op != ImageProcessor::kInvert) {
|
||||
// Note: If one of these fails, check its definition in class ImageProcessor.
|
||||
ASSERT(ImageProcessor::kRotateClockwise < ImageProcessor::kNumberOfAffineTransformations);
|
||||
ASSERT(ImageProcessor::kRotateAntiClockwise < ImageProcessor::kNumberOfAffineTransformations);
|
||||
ASSERT(ImageProcessor::kRotateCounterClockwise < ImageProcessor::kNumberOfAffineTransformations);
|
||||
ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations);
|
||||
ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations);
|
||||
fImageOrientation = fTransformation[op][fImageOrientation];
|
||||
@@ -2404,19 +2416,7 @@ ShowImageView::DoImageOperation(ImageProcessor::operation op, bool quiet)
|
||||
if (!quiet) {
|
||||
// remove selection
|
||||
SetHasSelection(false);
|
||||
// Pull the image type name from fCaption (hackish?)
|
||||
int32 last_comma_index = fCaption.FindLast(',');
|
||||
if (last_comma_index != B_ERROR) {
|
||||
// The -1 at the end is -2 to get rid of the comma and space, +1 for the \0
|
||||
int32 name_size = fCaption.CountChars() - last_comma_index - 1;
|
||||
char *name = new char[name_size];
|
||||
fCaption.CopyInto(name, last_comma_index + 2, name_size - 1);
|
||||
name[name_size - 1] = '\0';
|
||||
Notify(name);
|
||||
delete name;
|
||||
}
|
||||
else
|
||||
Notify(NULL);
|
||||
Notify();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2436,7 +2436,7 @@ ShowImageView::Rotate(int degree)
|
||||
if (degree == 90) {
|
||||
UserDoImageOperation(ImageProcessor::kRotateClockwise);
|
||||
} else if (degree == 270) {
|
||||
UserDoImageOperation(ImageProcessor::kRotateAntiClockwise);
|
||||
UserDoImageOperation(ImageProcessor::kRotateCounterClockwise);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2483,10 +2483,9 @@ ShowImageView::ResizeImage(int w, int h)
|
||||
DeleteBitmap();
|
||||
fBitmap = scaled;
|
||||
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(MSG_MODIFIED);
|
||||
SendMessageToWindow(MSG_MODIFIED);
|
||||
|
||||
Notify(NULL);
|
||||
Notify();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2562,8 +2561,7 @@ ShowImageView::SetIcon(bool clear)
|
||||
void
|
||||
ShowImageView::ToggleSlideShow()
|
||||
{
|
||||
BMessenger msgr(Window());
|
||||
msgr.SendMessage(MSG_SLIDE_SHOW);
|
||||
SendMessageToWindow(MSG_SLIDE_SHOW);
|
||||
}
|
||||
|
||||
|
||||
@@ -2571,8 +2569,7 @@ void
|
||||
ShowImageView::ExitFullScreen()
|
||||
{
|
||||
be_app->ShowCursor();
|
||||
BMessenger m(Window());
|
||||
m.SendMessage(MSG_EXIT_FULL_SCREEN);
|
||||
SendMessageToWindow(MSG_EXIT_FULL_SCREEN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -133,7 +133,9 @@ class ShowImageView : public BView {
|
||||
bool HasSelection() { return fHasSelection; }
|
||||
void SetHasSelection(bool bHasSelection);
|
||||
void AnimateSelection(bool a);
|
||||
void Notify(const char* status);
|
||||
void SendMessageToWindow(BMessage *message);
|
||||
void SendMessageToWindow(uint32 code);
|
||||
void Notify();
|
||||
void AddToRecentDocuments();
|
||||
void AddWhiteRect(BRect &rect);
|
||||
void GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect);
|
||||
@@ -237,6 +239,8 @@ class ShowImageView : public BView {
|
||||
bool fShowCaption; // display caption?
|
||||
BString fCaption; // caption text
|
||||
|
||||
BString fImageType; // Type of image, for use in status bar and caption
|
||||
|
||||
bool fInverted;
|
||||
|
||||
bool fShowingPopUpMenu;
|
||||
|
||||
@@ -832,7 +832,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
|
||||
fImageView->ResizeImage(w, h);
|
||||
break;
|
||||
}
|
||||
case MSG_RESIZER_WINDOW_QUITED:
|
||||
case MSG_RESIZER_WINDOW_QUIT:
|
||||
fResizerWindowMessenger = NULL;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user