From 1076d97b5a24d203f87ddcb4f16d1310c06a8856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 23 Oct 2010 22:05:59 +0000 Subject: [PATCH] * Removed the ability to invert an image. If you really need that feature, you'll now have to open an image editing application instead. * Removed the black border around the image. * Removed the B_PANEL_BACKGROUND_COLOR background in non-full screen mode - it's now always black. * Made zoom level changes exponential. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39095 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageConstants.h | 2 - src/apps/showimage/ShowImageView.cpp | 65 ++++++------------------- src/apps/showimage/ShowImageView.h | 7 +-- src/apps/showimage/ShowImageWindow.cpp | 41 ++++++---------- 4 files changed, 30 insertions(+), 85 deletions(-) diff --git a/src/apps/showimage/ShowImageConstants.h b/src/apps/showimage/ShowImageConstants.h index 4aacd8380e..6047110630 100644 --- a/src/apps/showimage/ShowImageConstants.h +++ b/src/apps/showimage/ShowImageConstants.h @@ -25,7 +25,6 @@ enum { 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', @@ -45,7 +44,6 @@ enum { 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', diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index 3d86108a47..c6295f9520 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -198,7 +198,6 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, #if DELAYED_SCALING fScalingCountDown(SCALING_DELAY_TIME), #endif - fInverted(false), fBitmapLocationInView(0.0, 0.0), @@ -233,8 +232,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, SetViewColor(B_TRANSPARENT_COLOR); SetHighColor(kBorderColor); - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - SetPenSize(PEN_SIZE); + SetLowColor(0, 0, 0); } @@ -487,12 +485,8 @@ ShowImageView::SetImage(const entry_ref *ref) // restore orientation int32 orientation; fImageOrientation = k0; - fInverted = false; if (file.ReadAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0, &orientation, sizeof(orientation)) == sizeof(orientation)) { - if (orientation & 256) - _DoImageOperation(ImageProcessor::ImageProcessor::kInvert, true); - orientation &= 255; switch (orientation) { case k0: @@ -669,13 +663,7 @@ ShowImageView::SetZoomToBounds(bool enable) void ShowImageView::SetFullScreen(bool fullScreen) { - if (fFullScreen != fullScreen) { - fFullScreen = fullScreen; - if (fFullScreen) { - SetLowColor(0, 0, 0, 255); - } else - SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - } + fFullScreen = fullScreen; } @@ -745,12 +733,12 @@ ShowImageView::_AlignBitmap() BRect rect(fBitmap->Bounds()); // the width/height of the bitmap (in pixels) - float bitmapWidth = rect.Width() + 1.0; - float bitmapHeight = rect.Height() + 1.0; + float bitmapWidth = rect.Width() + 1; + float bitmapHeight = rect.Height() + 1; // the available width/height for layouting the bitmap (in pixels) - float width = Bounds().Width() - 2 * PEN_SIZE + 1.0; - float height = Bounds().Height() - 2 * PEN_SIZE + 1.0; + float width = Bounds().Width() + 1; + float height = Bounds().Height() + 1; if (width == 0 || height == 0) return rect; @@ -789,7 +777,7 @@ ShowImageView::_AlignBitmap() if (height > bitmapHeight) rect.OffsetBy(0, floorf((height - bitmapHeight) / 2.0)); } - rect.OffsetBy(PEN_SIZE, PEN_SIZE); + return rect; } @@ -804,7 +792,7 @@ ShowImageView::_Setup(BRect rect) void -ShowImageView::_DrawBorder(BRect border) +ShowImageView::_DrawBackground(BRect border) { BRect bounds(Bounds()); // top @@ -941,15 +929,7 @@ ShowImageView::Draw(BRect updateRect) BRect rect = _AlignBitmap(); _Setup(rect); - BRect border(rect); - border.InsetBy(-PEN_SIZE, -PEN_SIZE); - - _DrawBorder(border); - - // Draw black rectangle around image - StrokeRect(border); - - // Draw image + _DrawBackground(rect); _DrawImage(rect); if (fShowCaption) @@ -1484,7 +1464,7 @@ ShowImageView::_UpdateSelectionRect(BPoint point, bool final) BRect updateRect; updateRect = oldSelection | fCopyFromRect; updateRect = ImageToView(updateRect); - updateRect.InsetBy(-PEN_SIZE, -PEN_SIZE); + updateRect.InsetBy(-1, -1); Invalidate(updateRect); } } @@ -1851,10 +1831,8 @@ ShowImageView::FixupScrollBars() bitmapRect.OffsetTo(0, 0); } - FixupScrollBar(B_HORIZONTAL, bitmapRect.Width() + 2 * PEN_SIZE, - viewRect.Width()); - FixupScrollBar(B_VERTICAL, bitmapRect.Height() + 2 * PEN_SIZE, - viewRect.Height()); + FixupScrollBar(B_HORIZONTAL, bitmapRect.Width(), viewRect.Width()); + FixupScrollBar(B_VERTICAL, bitmapRect.Height(), viewRect.Height()); } @@ -2328,7 +2306,7 @@ void ShowImageView::ZoomIn(BPoint where) { if (fZoom < 16) - SetZoom(where, fZoom + 0.25); + SetZoom(where, fZoom * 1.2); } @@ -2336,7 +2314,7 @@ void ShowImageView::ZoomOut(BPoint where) { if (fZoom > 0.25) - SetZoom(where, fZoom - 0.25); + SetZoom(where, fZoom * 0.8); } @@ -2397,15 +2375,12 @@ ShowImageView::_DoImageOperation(ImageProcessor::operation op, bool quiet) ASSERT(ImageProcessor::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations); ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations); fImageOrientation = fTransformation[op][fImageOrientation]; - } else { - fInverted = !fInverted; } if (!quiet) { // write orientation state BNode node(&fCurrentRef); int32 orientation = fImageOrientation; - if (fInverted) orientation += 256; if (orientation != k0) { node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0, &orientation, sizeof(orientation)); @@ -2457,17 +2432,6 @@ ShowImageView::Flip(bool vertical) } -void -ShowImageView::Invert() -{ - if (fBitmap->ColorSpace() != B_CMAP8) { - // Only allow an invert operation if the - // bitmap color space is supported by the - // invert algorithm - _UserDoImageOperation(ImageProcessor::kInvert); - } -} - void ShowImageView::ResizeImage(int w, int h) { @@ -2493,6 +2457,7 @@ ShowImageView::ResizeImage(int w, int h) _Notify(); } + void ShowImageView::_SetIcon(bool clear, icon_size which) { diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index aa3dbb2cbf..44bae2414b 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -32,8 +32,6 @@ #define DELAYED_SCALING 1 // the delay time in 1/10 seconds #define SCALING_DELAY_TIME 3 -// width of the black border stroked arround the bitmap -#define PEN_SIZE 1.0f // the delay time for hiding the cursor in 1/10 seconds (the pulse rate) #define HIDE_CURSOR_DELAY_TIME 20 @@ -75,7 +73,6 @@ public: BBitmap* bitmap, const translation_format* format); void SetDither(bool dither); - bool GetDither() const { return fDither; } void SetScaleBilinear(bool b); bool GetScaleBilinear() { return fScaleBilinear; } void SetShowCaption(bool show); @@ -130,7 +127,6 @@ public: // Image manipulation void Rotate(int degree); // 90 and 270 only void Flip(bool vertical); - void Invert(); void ResizeImage(int width, int height); void SetIcon(bool clear); @@ -212,7 +208,7 @@ private: void _ScrollBitmap(); uint32 _GetMouseButtons(); void _UpdateSelectionRect(BPoint point, bool final); - void _DrawBorder(BRect border); + void _DrawBackground(BRect aroundFrame); void _LayoutCaption(BFont& font, BPoint& textPos, BRect& background); void _DrawCaption(); @@ -256,7 +252,6 @@ private: #if DELAYED_SCALING int fScalingCountDown; #endif - bool fInverted; BPoint fBitmapLocationInView; diff --git a/src/apps/showimage/ShowImageWindow.cpp b/src/apps/showimage/ShowImageWindow.cpp index 37f92737a8..a251f2ea8d 100644 --- a/src/apps/showimage/ShowImageWindow.cpp +++ b/src/apps/showimage/ShowImageWindow.cpp @@ -207,7 +207,6 @@ ShowImageWindow::ShowImageWindow(const entry_ref* ref, BMenu* menu = new BMenu(B_TRANSLATE("View")); _BuildViewMenu(menu, false); fBar->AddItem(menu); - _MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither()); UpdateTitle(); SetPulseRate(100000); @@ -410,8 +409,6 @@ ShowImageWindow::AddMenus(BMenuBar* bar) _AddItemMenu(menu, B_TRANSLATE("Flip top to bottom"), MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this); menu->AddSeparatorItem(); - _AddItemMenu(menu, B_TRANSLATE("Invert colors"), MSG_INVERT, 0, 0, this); - menu->AddSeparatorItem(); fResizeItem = _AddItemMenu(menu, B_TRANSLATE("Resize" B_UTF8_ELLIPSIS), MSG_OPEN_RESIZER_WINDOW, 0, 0, this); bar->AddItem(menu); @@ -454,16 +451,17 @@ ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, float value) void -ShowImageWindow::WindowRedimension(BBitmap* pbitmap) +ShowImageWindow::WindowRedimension(BBitmap* bitmap) { BScreen screen; if (!screen.IsValid()) return; - BRect r(pbitmap->Bounds()); - float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH; - float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() + - B_H_SCROLL_BAR_HEIGHT; + // TODO: use View::GetPreferredSize() instead? + BRect r(bitmap->Bounds()); + float width = r.Width() + B_V_SCROLL_BAR_WIDTH; + float height = r.Height() + 1 + fBar->Frame().Height() + + B_H_SCROLL_BAR_HEIGHT; BRect frame = screen.Frame(); const float windowBorder = 5; @@ -644,13 +642,6 @@ ShowImageWindow::MessageReceived(BMessage* message) } } - // Disable the Invert menu item if the bitmap color space - // is B_CMAP8. (B_CMAP8 is currently unsupported by the - // invert algorithm) - color_space colors = B_NO_COLOR_SPACE; - message->FindInt32("colors", reinterpret_cast(&colors)); - _EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8)); - BString status; bool messageProvidesSize = false; if (message->FindInt32("width", &fWidth) >= B_OK @@ -781,10 +772,6 @@ ShowImageWindow::MessageReceived(BMessage* message) } } break; - case MSG_DITHER_IMAGE: - fImageView->SetDither(_ToggleMenuItem(message->what)); - break; - case MSG_SHRINK_TO_WINDOW: _ResizeToWindow(true, message->what); break; @@ -819,11 +806,8 @@ ShowImageWindow::MessageReceived(BMessage* message) fImageView->Flip(false); break; - case MSG_INVERT: - fImageView->Invert(); - break; - - case MSG_SLIDE_SHOW: { + case MSG_SLIDE_SHOW: + { BMenuItem* item = fBar->FindItem(message->what); if (!item) break; @@ -836,16 +820,19 @@ ShowImageWindow::MessageReceived(BMessage* message) fResizeItem->SetEnabled(false); fImageView->StartSlideShow(); } - } break; + break; + } - case MSG_SLIDE_SHOW_DELAY: { + case MSG_SLIDE_SHOW_DELAY: + { float value; if (message->FindFloat("value", &value) == B_OK) { fImageView->SetSlideShowDelay(value); // in case message is sent from popup menu _MarkSlideShowDelay(value); } - } break; + break; + } case MSG_FULL_SCREEN: _ToggleFullScreen();