* Coding style cleanup

* Some cleanup in member sorting
 * Some renaming of members for improved clarity
 * Removed _HasSelection() and use fHasSelection directly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37159 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-06-16 21:29:09 +00:00
parent e48ec1b5e7
commit 4fa7e62e8d
2 changed files with 320 additions and 265 deletions
+69 -67
View File
@@ -184,34 +184,37 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
uint32 flags) uint32 flags)
: :
BView(rect, name, resizingMode, flags), BView(rect, name, resizingMode, flags),
fDither(BScreen().ColorSpace() == B_CMAP8),
fDocumentIndex(1), fDocumentIndex(1),
fDocumentCount(1), fDocumentCount(1),
fBitmap(NULL), fBitmap(NULL),
fDisplayBitmap(NULL), fDisplayBitmap(NULL),
fSelectionBitmap(NULL), fSelectionBitmap(NULL),
fZoom(1.0), fZoom(1.0),
fDither(BScreen().ColorSpace() == B_CMAP8),
fScaleBilinear(true), fScaleBilinear(true),
fScaler(NULL), fScaler(NULL),
#if DELAYED_SCALING
fScalingCountDown(SCALING_DELAY_TIME),
#endif
fInverted(false),
fBitmapLocationInView(0.0, 0.0),
fShrinkToBounds(false), fShrinkToBounds(false),
fZoomToBounds(false), fZoomToBounds(false),
fShrinkOrZoomToBounds(false), fShrinkOrZoomToBounds(false),
fFullScreen(false), fFullScreen(false),
fLeft(0.0), fDraggingBitmap(false),
fTop(0.0), fCreatingSelection(false),
fMovesImage(false),
fMakesSelection(false),
fFirstPoint(0.0, 0.0), fFirstPoint(0.0, 0.0),
fAnimateSelection(true), fAnimateSelection(true),
fHasSelection(false), fHasSelection(false),
fSlideShow(false), fSlideShow(false),
fSlideShowDelay(3 * 10), // 3 seconds fSlideShowDelay(3 * 10), // 3 seconds
fSlideShowCountDown(0), fSlideShowCountDown(0),
#if DELAYED_SCALING
fScalingCountDown(SCALING_DELAY_TIME),
#endif
fShowCaption(false), fShowCaption(false),
fInverted(false),
fShowingPopUpMenu(false), fShowingPopUpMenu(false),
fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME), fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME),
fIsActiveWin(true), fIsActiveWin(true),
@@ -253,11 +256,10 @@ ShowImageView::_InitPatterns()
for (int i = 0; i <= 7; i ++) { for (int i = 0; i <= 7; i ++) {
fPatternLeft.data[i] = p1; fPatternLeft.data[i] = p1;
fPatternRight.data[i] = p2; fPatternRight.data[i] = p2;
if ((i / 2) % 2 == 0) { if ((i / 2) % 2 == 0)
p = 255; p = 255;
} else { else
p = 0; p = 0;
}
fPatternUp.data[i] = p; fPatternUp.data[i] = p;
fPatternDown.data[i] = ~p; fPatternDown.data[i] = ~p;
} }
@@ -267,37 +269,33 @@ ShowImageView::_InitPatterns()
void void
ShowImageView::_RotatePatterns() ShowImageView::_RotatePatterns()
{ {
int i;
uchar p;
bool set;
// rotate up // rotate up
p = fPatternUp.data[0]; uchar p = fPatternUp.data[0];
for (i = 0; i <= 6; i ++) { for (int i = 0; i <= 6; i ++)
fPatternUp.data[i] = fPatternUp.data[i+1]; fPatternUp.data[i] = fPatternUp.data[i + 1];
}
fPatternUp.data[7] = p; fPatternUp.data[7] = p;
// rotate down // rotate down
p = fPatternDown.data[7]; p = fPatternDown.data[7];
for (i = 7; i >= 1; i --) { for (int i = 7; i >= 1; i --)
fPatternDown.data[i] = fPatternDown.data[i-1]; fPatternDown.data[i] = fPatternDown.data[i - 1];
}
fPatternDown.data[0] = p; fPatternDown.data[0] = p;
// rotate to left // rotate to left
p = fPatternLeft.data[0]; p = fPatternLeft.data[0];
set = (p & 0x80) != 0; bool set = (p & 0x80) != 0;
p <<= 1; p <<= 1;
p &= 0xfe; p &= 0xfe;
if (set) p |= 1; if (set)
p |= 1;
memset(fPatternLeft.data, p, 8); memset(fPatternLeft.data, p, 8);
// rotate to right // rotate to right
p = fPatternRight.data[0]; p = fPatternRight.data[0];
set = (p & 1) != 0; set = (p & 1) != 0;
p >>= 1; p >>= 1;
if (set) p |= 0x80; if (set)
p |= 0x80;
memset(fPatternRight.data, p, 8); memset(fPatternRight.data, p, 8);
} }
@@ -313,7 +311,7 @@ void
ShowImageView::Pulse() ShowImageView::Pulse()
{ {
// animate marching ants // animate marching ants
if (_HasSelection() && fAnimateSelection && fIsActiveWin) { if (fHasSelection && fAnimateSelection && fIsActiveWin) {
_RotatePatterns(); _RotatePatterns();
_DrawSelectionBox(); _DrawSelectionBox();
} }
@@ -328,7 +326,7 @@ ShowImageView::Pulse()
} }
// Hide cursor in full screen mode // Hide cursor in full screen mode
if (fFullScreen && !_HasSelection() && !fShowingPopUpMenu && fIsActiveWin) { if (fFullScreen && !fHasSelection && !fShowingPopUpMenu && fIsActiveWin) {
if (fHideCursorCountDown <= 0) if (fHideCursorCountDown <= 0)
be_app->ObscureCursor(); be_app->ObscureCursor();
else else
@@ -537,7 +535,7 @@ ShowImageView::SetImage(const entry_ref *ref)
// and clear everything // and clear everything
fUndo.Clear(); fUndo.Clear();
_SetHasSelection(false); _SetHasSelection(false);
fMakesSelection = false; fCreatingSelection = false;
_DeleteBitmap(); _DeleteBitmap();
fBitmap = newBitmap; fBitmap = newBitmap;
fCurrentRef = *ref; fCurrentRef = *ref;
@@ -818,17 +816,17 @@ ShowImageView::_AlignBitmap()
void void
ShowImageView::_Setup(BRect rect) ShowImageView::_Setup(BRect rect)
{ {
fLeft = floorf(rect.left); fBitmapLocationInView.x = floorf(rect.left);
fTop = floorf(rect.top); fBitmapLocationInView.y = floorf(rect.top);
fZoom = (rect.Width()+1.0) / (fBitmap->Bounds().Width()+1.0); fZoom = (rect.Width() + 1.0) / (fBitmap->Bounds().Width() + 1.0);
} }
BPoint BPoint
ShowImageView::_ImageToView(BPoint p) const ShowImageView::_ImageToView(BPoint p) const
{ {
p.x = floorf(fZoom * p.x + fLeft); p.x = floorf(fZoom * p.x + fBitmapLocationInView.x);
p.y = floorf(fZoom * p.y + fTop); p.y = floorf(fZoom * p.y + fBitmapLocationInView.y);
return p; return p;
} }
@@ -836,8 +834,8 @@ ShowImageView::_ImageToView(BPoint p) const
BPoint BPoint
ShowImageView::_ViewToImage(BPoint p) const ShowImageView::_ViewToImage(BPoint p) const
{ {
p.x = floorf((p.x - fLeft) / fZoom); p.x = floorf((p.x - fBitmapLocationInView.x) / fZoom);
p.y = floorf((p.y - fTop) / fZoom); p.y = floorf((p.y - fBitmapLocationInView.y) / fZoom);
return p; return p;
} }
@@ -1006,7 +1004,7 @@ ShowImageView::Draw(BRect updateRect)
if (fShowCaption) if (fShowCaption)
_DrawCaption(); _DrawCaption();
if (_HasSelection()) { if (fHasSelection) {
if (fSelectionBitmap != NULL) { if (fSelectionBitmap != NULL) {
BRect srcRect; BRect srcRect;
BRect dstRect; BRect dstRect;
@@ -1022,21 +1020,25 @@ ShowImageView::Draw(BRect updateRect)
void void
ShowImageView::_DrawSelectionBox() ShowImageView::_DrawSelectionBox()
{ {
if (fSelectionRect.Height() > 0.0 && fSelectionRect.Width() > 0.0) { if (fSelectionRect.Height() <= 0.0 || fSelectionRect.Width() <= 0.0)
BRect r(fSelectionRect); return;
_ConstrainToImage(r);
r = _ImageToView(r); BRect r(fSelectionRect);
// draw selection box *around* selection _ConstrainToImage(r);
r.InsetBy(-1, -1); r = _ImageToView(r);
PushState(); // draw selection box *around* selection
rgb_color white = {255, 255, 255}; r.InsetBy(-1, -1);
SetLowColor(white); PushState();
StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top), fPatternLeft); SetLowColor(255, 255, 255);
StrokeLine(BPoint(r.right, r.top+1), BPoint(r.right, r.bottom-1), fPatternUp); StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top),
StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), fPatternRight); fPatternLeft);
StrokeLine(BPoint(r.left, r.top+1), BPoint(r.left, r.bottom-1), fPatternDown); StrokeLine(BPoint(r.right, r.top + 1), BPoint(r.right, r.bottom - 1),
PopState(); fPatternUp);
} StrokeLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom),
fPatternRight);
StrokeLine(BPoint(r.left, r.top + 1), BPoint(r.left, r.bottom - 1),
fPatternDown);
PopState();
} }
@@ -1089,7 +1091,7 @@ ShowImageView::_CopySelection(uchar alpha, bool imageSize)
{ {
bool hasAlpha = alpha != 255; bool hasAlpha = alpha != 255;
if (!_HasSelection()) if (!fHasSelection)
return NULL; return NULL;
BRect rect(0, 0, fSelectionRect.Width(), fSelectionRect.Height()); BRect rect(0, 0, fSelectionRect.Width(), fSelectionRect.Height());
@@ -1381,7 +1383,7 @@ ShowImageView::_MoveImage()
// in case we miss MouseUp // in case we miss MouseUp
if ((_GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0) if ((_GetMouseButtons() & B_TERTIARY_MOUSE_BUTTON) == 0)
fMovesImage = false; fDraggingBitmap = false;
} }
@@ -1467,7 +1469,7 @@ ShowImageView::_MergeWithBitmap(BBitmap* merge, BRect selection)
void void
ShowImageView::_MergeSelection() ShowImageView::_MergeSelection()
{ {
if (!_HasSelection()) if (!fHasSelection)
return; return;
if (fSelectionBitmap == NULL) { if (fSelectionBitmap == NULL) {
@@ -1494,7 +1496,7 @@ ShowImageView::MouseDown(BPoint position)
point = _ViewToImage(position); point = _ViewToImage(position);
buttons = _GetMouseButtons(); buttons = _GetMouseButtons();
if (_HasSelection() && fSelectionRect.Contains(point) if (fHasSelection && fSelectionRect.Contains(point)
&& (buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON))) { && (buttons & (B_PRIMARY_MOUSE_BUTTON | B_SECONDARY_MOUSE_BUTTON))) {
if (!fSelectionBitmap) if (!fSelectionBitmap)
fSelectionBitmap = _CopySelection(); fSelectionBitmap = _CopySelection();
@@ -1536,7 +1538,7 @@ ShowImageView::MouseDown(BPoint position)
// begin new selection // begin new selection
_SetHasSelection(true); _SetHasSelection(true);
fMakesSelection = true; fCreatingSelection = true;
SetMouseEventMask(B_POINTER_EVENTS); SetMouseEventMask(B_POINTER_EVENTS);
_ConstrainToImage(point); _ConstrainToImage(point);
fFirstPoint = point; fFirstPoint = point;
@@ -1548,7 +1550,7 @@ ShowImageView::MouseDown(BPoint position)
} else if (buttons == B_TERTIARY_MOUSE_BUTTON) { } else if (buttons == B_TERTIARY_MOUSE_BUTTON) {
// move image in window // move image in window
SetMouseEventMask(B_POINTER_EVENTS); SetMouseEventMask(B_POINTER_EVENTS);
fMovesImage = true; fDraggingBitmap = true;
fFirstPoint = ConvertToScreen(position); fFirstPoint = ConvertToScreen(position);
} }
} }
@@ -1573,7 +1575,7 @@ ShowImageView::_UpdateSelectionRect(BPoint point, bool final)
} else } else
_UpdateStatusText(); _UpdateStatusText();
if (oldSelection != fCopyFromRect || !_HasSelection()) { if (oldSelection != fCopyFromRect || !fHasSelection) {
BRect updateRect; BRect updateRect;
updateRect = oldSelection | fCopyFromRect; updateRect = oldSelection | fCopyFromRect;
updateRect = _ImageToView(updateRect); updateRect = _ImageToView(updateRect);
@@ -1587,9 +1589,9 @@ void
ShowImageView::MouseMoved(BPoint point, uint32 state, const BMessage *message) ShowImageView::MouseMoved(BPoint point, uint32 state, const BMessage *message)
{ {
fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME; fHideCursorCountDown = HIDE_CURSOR_DELAY_TIME;
if (fMakesSelection) { if (fCreatingSelection) {
_UpdateSelectionRect(point, false); _UpdateSelectionRect(point, false);
} else if (fMovesImage) { } else if (fDraggingBitmap) {
_MoveImage(); _MoveImage();
} }
} }
@@ -1598,12 +1600,12 @@ ShowImageView::MouseMoved(BPoint point, uint32 state, const BMessage *message)
void void
ShowImageView::MouseUp(BPoint point) ShowImageView::MouseUp(BPoint point)
{ {
if (fMakesSelection) { if (fCreatingSelection) {
_UpdateSelectionRect(point, true); _UpdateSelectionRect(point, true);
fMakesSelection = false; fCreatingSelection = false;
} else if (fMovesImage) { } else if (fDraggingBitmap) {
_MoveImage(); _MoveImage();
fMovesImage = false; fDraggingBitmap = false;
} }
_AnimateSelection(true); _AnimateSelection(true);
} }
@@ -2031,7 +2033,7 @@ ShowImageView::_AddWhiteRect(BRect &rect)
void void
ShowImageView::_RemoveSelection(bool toClipboard, bool neverCutBackground) ShowImageView::_RemoveSelection(bool toClipboard, bool neverCutBackground)
{ {
if (!_HasSelection()) if (!fHasSelection)
return; return;
BRect rect = fSelectionRect; BRect rect = fSelectionRect;
@@ -2161,7 +2163,7 @@ ShowImageView::_SetHasSelection(bool hasSelection)
void void
ShowImageView::CopySelectionToClipboard() ShowImageView::CopySelectionToClipboard()
{ {
if (!_HasSelection() || !be_clipboard->Lock()) if (!fHasSelection || !be_clipboard->Lock())
return; return;
be_clipboard->Clear(); be_clipboard->Clear();
+251 -198
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
* Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd.
* Copyright 2006 Bernd Korz. All Rights Reserved * Copyright 2006 Bernd Korz. All Rights Reserved
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
@@ -26,7 +26,8 @@
#include <View.h> #include <View.h>
// delay scaling operation, so that a sequence of zoom in/out operations works smoother // Delay scaling operation, so that a sequence of zoom in/out operations works
// smoother
#define DELAYED_SCALING 1 #define DELAYED_SCALING 1
// the delay time in 1/10 seconds // the delay time in 1/10 seconds
#define SCALING_DELAY_TIME 3 #define SCALING_DELAY_TIME 3
@@ -39,223 +40,275 @@
class ProgressWindow; class ProgressWindow;
class ShowImageView : public BView { class ShowImageView : public BView {
public: public:
ShowImageView(BRect rect, const char *name, uint32 resizingMode, ShowImageView(BRect rect, const char* name,
uint32 flags); uint32 resizingMode, uint32 flags);
virtual ~ShowImageView(); virtual ~ShowImageView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
virtual void Draw(BRect updateRect); virtual void Draw(BRect updateRect);
virtual void FrameResized(float width, float height); virtual void FrameResized(float width, float height);
virtual void MouseDown(BPoint point); virtual void MouseDown(BPoint point);
virtual void MouseMoved(BPoint point, uint32 state, const BMessage *message); virtual void MouseMoved(BPoint point, uint32 state,
virtual void MouseUp(BPoint point); const BMessage* dragMessage);
virtual void KeyDown(const char *bytes, int32 numBytes); virtual void MouseUp(BPoint point);
virtual void Pulse(); virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void Pulse();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage* message);
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);
void SetTrackerMessenger(const BMessenger& trackerMessenger); void SetTrackerMessenger(
status_t SetImage(const entry_ref *ref); const BMessenger& trackerMessenger);
const entry_ref* Image() const { return &fCurrentRef; } status_t SetImage(const entry_ref* ref);
const entry_ref* Image() const { return &fCurrentRef; }
void SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap, void SaveToFile(BDirectory* dir, const char* name,
const translation_format* format); BBitmap* bitmap,
void SetDither(bool dither); const translation_format* format);
bool GetDither() const { return fDither; } void SetDither(bool dither);
void SetShowCaption(bool show); bool GetDither() const { return fDither; }
void SetShrinkToBounds(bool enable); void SetScaleBilinear(bool b);
bool GetShrinkToBounds() const { return fShrinkToBounds; } bool GetScaleBilinear() { return fScaleBilinear; }
void SetZoomToBounds(bool enable); void SetShowCaption(bool show);
bool GetZoomToBounds() const { return fZoomToBounds; } void SetShrinkToBounds(bool enable);
void SetFullScreen(bool fullScreen); bool GetShrinkToBounds() const
BBitmap *GetBitmap(); { return fShrinkToBounds; }
void GetName(BString *name); void SetZoomToBounds(bool enable);
void GetPath(BString *name); bool GetZoomToBounds() const
void SetScaleBilinear(bool b); { return fZoomToBounds; }
bool GetScaleBilinear() { return fScaleBilinear; } void SetFullScreen(bool fullScreen);
void FixupScrollBar(orientation o, float bitmapLength, float viewLength); BBitmap* GetBitmap();
void FixupScrollBars(); void GetName(BString* name);
void GetPath(BString* name);
int32 CurrentPage(); void FixupScrollBar(enum orientation orientation,
int32 PageCount(); float bitmapLength, float viewLength);
void FixupScrollBars();
void Undo(); void Undo();
void Cut(); void Cut();
void Paste(); void Paste();
void SelectAll(); void SelectAll();
void ClearSelection(); void ClearSelection();
void CopySelectionToClipboard(); void CopySelectionToClipboard();
void FirstPage(); int32 CurrentPage();
void LastPage(); int32 PageCount();
void NextPage();
void PrevPage();
void GoToPage(int32 page);
bool NextFile();
bool PrevFile();
bool HasNextFile();
bool HasPrevFile();
void SetSlideShowDelay(float seconds);
float GetSlideShowDelay() const { return fSlideShowDelay / 10.0; }
bool SlideShowStarted() const { return fSlideShow; }
void StartSlideShow();
void StopSlideShow();
void SetZoom(float zoom);
void ZoomIn();
void ZoomOut();
// Image manipulation void FirstPage();
void Rotate(int degree); // 90 and 270 only void LastPage();
void Flip(bool vertical); void NextPage();
void Invert(); void PrevPage();
void ResizeImage(int w, int h); void GoToPage(int32 page);
void SetIcon(bool clear); bool NextFile();
bool PrevFile();
bool HasNextFile();
bool HasPrevFile();
private: void SetSlideShowDelay(float seconds);
ShowImageUndo fUndo; float GetSlideShowDelay() const
enum image_orientation { { return fSlideShowDelay / 10.0; }
k0, // 0 bool SlideShowStarted() const { return fSlideShow; }
k90, // 1 void StartSlideShow();
k180, // 2 void StopSlideShow();
k270, // 3 void SetZoom(float zoom);
k0V, // 4 void ZoomIn();
k90V, // 5 void ZoomOut();
k0H, // 6
k270V, // 7
kNumberOfOrientations,
};
void _InitPatterns();
void _RotatePatterns();
void _RemoveSelection(bool bToClipboard, bool neverCutBackground = false);
bool _HasSelection() { return fHasSelection; }
void _SetHasSelection(bool bHasSelection);
void _AnimateSelection(bool a);
void _SendMessageToWindow(BMessage *message);
void _SendMessageToWindow(uint32 code);
void _Notify();
void _UpdateStatusText();
void _AddToRecentDocuments();
void _AddWhiteRect(BRect &rect);
void _GetMergeRects(BBitmap *merge, BRect selection, BRect &srcBits, BRect &destRect);
void _GetSelectionMergeRects(BRect &srcBits, BRect &destRect);
status_t _SetSelection(const entry_ref *pref, BPoint point);
status_t _PasteBitmap(BBitmap *bitmap, BPoint point);
void _MergeWithBitmap(BBitmap *merge, BRect selection);
void _MergeSelection();
void _DeleteScaler();
void _DeleteBitmap();
void _DeleteSelectionBitmap();
int32 _BytesPerPixel(color_space cs) const;
void _CopyPixel(uchar* dest, int32 destX, int32 destY, int32 destBPR,
uchar* src, int32 x, int32 y, int32 bpr, int32 bpp);
void _InvertPixel(int32 x, int32 y, uchar* dest, int32 destBPR, uchar* src,
int32 bpr, int32 bpp);
void _DoImageOperation(enum ImageProcessor::operation op, bool quiet = false);
void _UserDoImageOperation(enum ImageProcessor::operation op, bool quiet = false);
BRect _AlignBitmap();
void _Setup(BRect r);
BPoint _ImageToView(BPoint p) const;
BPoint _ViewToImage(BPoint p) const;
BRect _ImageToView(BRect r) const;
bool _IsImage(const entry_ref* pref);
static int _CompareEntries(const void* a, const void* b);
void _FreeEntries(BList* entries);
void _SetTrackerSelectionToCurrent();
bool _FindNextImage(entry_ref *in_current, entry_ref *out_image,
bool next, bool rewind);
bool _ShowNextImage(bool next, bool rewind);
bool _FirstFile();
void _ConstrainToImage(BPoint &point);
void _ConstrainToImage(BRect &rect);
BBitmap* _CopyFromRect(BRect srcRect);
BBitmap* _CopySelection(uchar alpha = 255, bool imageSize = true);
bool _AddSupportedTypes(BMessage* msg, BBitmap* bitmap);
void _BeginDrag(BPoint sourcePoint);
void _SendInMessage(BMessage* msg, BBitmap* bitmap, translation_format* format);
bool _OutputFormatForType(BBitmap* bitmap, const char* type,
translation_format* format);
void _HandleDrop(BMessage* msg);
void _MoveImage();
uint32 _GetMouseButtons();
void _UpdateSelectionRect(BPoint point, bool final);
void _DrawBorder(BRect border);
void _LayoutCaption(BFont &font, BPoint &textPos, BRect &background);
void _DrawCaption();
void _UpdateCaption();
void _DrawSelectionBox();
Scaler* _GetScaler(BRect rect);
void _DrawImage(BRect rect);
float _LimitToRange(float v, orientation o, bool absolute);
void _ScrollRestricted(float x, float y, bool absolute);
void _ScrollRestrictedTo(float x, float y);
void _ScrollRestrictedBy(float x, float y);
void _MouseWheelChanged(BMessage* msg);
void _ShowPopUpMenu(BPoint screen);
void _SettingsSetBool(const char* name, bool value);
void _SetIcon(bool clear, icon_size which);
void _ToggleSlideShow();
void _ExitFullScreen();
BMessenger fTrackerMessenger; // of the window that this was launched from // Image manipulation
entry_ref fCurrentRef; // of the image void Rotate(int degree); // 90 and 270 only
bool fDither; // dither the image void Flip(bool vertical);
int32 fDocumentIndex; // of the image in the file void Invert();
int32 fDocumentCount; // number of images in the file void ResizeImage(int width, int height);
BBitmap *fBitmap; // the original image
BBitmap *fDisplayBitmap; void SetIcon(bool clear);
// the image to be displayed
// (== fBitmap if the bitmap can be displayed as is) private:
BBitmap *fSelectionBitmap; // the bitmap in the selection enum image_orientation {
float fZoom; // factor to be used to display the image k0, // 0
bool fScaleBilinear; // use bilinear scaling? k90, // 1
Scaler* fScaler; // holds the scaled image if bilinear scaling is enabled k180, // 2
bool fShrinkToBounds; k270, // 3
bool fZoomToBounds; k0V, // 4
bool fShrinkOrZoomToBounds; k90V, // 5
bool fFullScreen; // is the image displayed fullscreen? k0H, // 6
float fLeft; // the origin of the image in the view k270V, // 7
float fTop; kNumberOfOrientations,
bool fMovesImage; // is the image being moved with the mouse };
bool fMakesSelection; // is a selection being made
BPoint fFirstPoint; // first point in image space of selection void _InitPatterns();
bool fAnimateSelection; // marching ants void _RotatePatterns();
bool fHasSelection; // is fSelectionRect valid void _RemoveSelection(bool bToClipboard,
BRect fSelectionRect; // the current location of the selection rectangle bool neverCutBackground = false);
BRect fCopyFromRect; void _SetHasSelection(bool bHasSelection);
// the portion of the background bitmap the selection is made from void _AnimateSelection(bool a);
pattern fPatternUp, fPatternDown, fPatternLeft, fPatternRight; void _SendMessageToWindow(BMessage *message);
void _SendMessageToWindow(uint32 code);
bool fSlideShow; // is slide show enabled? void _Notify();
int fSlideShowDelay; // in pulse rate units void _UpdateStatusText();
int fSlideShowCountDown; // shows next image if it reaches zero void _AddToRecentDocuments();
void _AddWhiteRect(BRect& rect);
void _GetMergeRects(BBitmap* merge,
BRect selection, BRect& srcRect,
BRect& dstRect);
void _GetSelectionMergeRects(BRect& srcRect,
BRect& dstRect);
status_t _SetSelection(const entry_ref* ref,
BPoint point);
status_t _PasteBitmap(BBitmap* bitmap, BPoint point);
void _MergeWithBitmap(BBitmap* merge,
BRect selection);
void _MergeSelection();
void _DeleteScaler();
void _DeleteBitmap();
void _DeleteSelectionBitmap();
int32 _BytesPerPixel(color_space cs) const;
void _CopyPixel(uchar* dest, int32 destX,
int32 destY, int32 destBPR, uchar* src,
int32 x, int32 y, int32 bpr, int32 bpp);
void _InvertPixel(int32 x, int32 y, uchar* dest,
int32 destBPR, uchar* src, int32 bpr,
int32 bpp);
void _DoImageOperation(
enum ImageProcessor::operation op,
bool quiet = false);
void _UserDoImageOperation(
enum ImageProcessor::operation op,
bool quiet = false);
BRect _AlignBitmap();
void _Setup(BRect r);
BPoint _ImageToView(BPoint p) const;
BPoint _ViewToImage(BPoint p) const;
BRect _ImageToView(BRect r) const;
bool _IsImage(const entry_ref* pref);
static int _CompareEntries(const void* a, const void* b);
void _FreeEntries(BList* entries);
void _SetTrackerSelectionToCurrent();
bool _FindNextImage(entry_ref* inCurrent,
entry_ref* outImage, bool next,
bool rewind);
bool _ShowNextImage(bool next, bool rewind);
bool _FirstFile();
void _ConstrainToImage(BPoint& point);
void _ConstrainToImage(BRect& rect);
BBitmap* _CopyFromRect(BRect srcRect);
BBitmap* _CopySelection(uchar alpha = 255,
bool imageSize = true);
bool _AddSupportedTypes(BMessage* message,
BBitmap* bitmap);
void _BeginDrag(BPoint sourcePoint);
void _SendInMessage(BMessage* message,
BBitmap* bitmap,
translation_format* format);
bool _OutputFormatForType(BBitmap* bitmap,
const char* type,
translation_format* format);
void _HandleDrop(BMessage* message);
void _MoveImage();
uint32 _GetMouseButtons();
void _UpdateSelectionRect(BPoint point, bool final);
void _DrawBorder(BRect border);
void _LayoutCaption(BFont& font, BPoint& textPos,
BRect& background);
void _DrawCaption();
void _UpdateCaption();
void _DrawSelectionBox();
Scaler* _GetScaler(BRect rect);
void _DrawImage(BRect rect);
float _LimitToRange(float v, orientation o,
bool absolute);
void _ScrollRestricted(float x, float y,
bool absolute);
void _ScrollRestrictedTo(float x, float y);
void _ScrollRestrictedBy(float x, float y);
void _MouseWheelChanged(BMessage* message);
void _ShowPopUpMenu(BPoint screen);
void _SettingsSetBool(const char* name, bool value);
void _SetIcon(bool clear, icon_size which);
void _ToggleSlideShow();
void _ExitFullScreen();
private:
ShowImageUndo fUndo;
BMessenger fTrackerMessenger;
// of the window that this was launched from
entry_ref fCurrentRef;
int32 fDocumentIndex;
// of the image in the file
int32 fDocumentCount;
// number of images in the file
BBitmap* fBitmap;
BBitmap* fDisplayBitmap;
BBitmap* fSelectionBitmap;
float fZoom;
bool fDither;
bool fScaleBilinear;
Scaler* fScaler;
#if DELAYED_SCALING #if DELAYED_SCALING
int fScalingCountDown; int fScalingCountDown;
#endif #endif
bool fInverted;
BPoint fBitmapLocationInView;
bool fShrinkToBounds;
bool fZoomToBounds;
bool fShrinkOrZoomToBounds;
bool fFullScreen;
bool fDraggingBitmap;
bool fCreatingSelection;
BPoint fFirstPoint;
// first point in image space of selection
bool fAnimateSelection;
bool fHasSelection;
BRect fSelectionRect;
BRect fCopyFromRect;
// the portion of the background bitmap the selection is made
// from
pattern fPatternUp;
pattern fPatternDown;
pattern fPatternLeft;
pattern fPatternRight;
bool fShowCaption; // display caption? bool fSlideShow;
BString fCaption; // caption text int fSlideShowDelay;
// in pulse rate units
int fSlideShowCountDown;
// shows next image if it reaches zero
bool fShowCaption;
BString fCaption;
BString fImageType; // Type of image, for use in status bar and caption BString fImageType;
BString fImageMime; // Type of image, for use in status bar and caption
BString fImageMime;
bool fInverted; bool fShowingPopUpMenu;
bool fShowingPopUpMenu; int fHideCursorCountDown;
// Hides the cursor when it reaches zero
bool fIsActiveWin;
// Is the parent window the active window?
int fHideCursorCountDown; // Hides the cursor when it reaches zero ProgressWindow* fProgressWindow;
bool fIsActiveWin; // Is the parent window the active window?
ProgressWindow* fProgressWindow; image_orientation fImageOrientation;
static image_orientation fTransformation[
enum image_orientation fImageOrientation; ImageProcessor
static enum image_orientation fTransformation[ ::kNumberOfAffineTransformations]
ImageProcessor::kNumberOfAffineTransformations][kNumberOfOrientations]; [kNumberOfOrientations];
}; };
#endif // SHOW_IMAGE_VIEW_H #endif // SHOW_IMAGE_VIEW_H