* 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
This commit is contained in:
@@ -25,7 +25,6 @@ enum {
|
|||||||
MSG_CLEAR_SELECT = 'mCSL',
|
MSG_CLEAR_SELECT = 'mCSL',
|
||||||
MSG_SELECT_ALL = 'mSAL',
|
MSG_SELECT_ALL = 'mSAL',
|
||||||
MSG_CLIPBOARD_CHANGED = 'mCLP',
|
MSG_CLIPBOARD_CHANGED = 'mCLP',
|
||||||
MSG_DITHER_IMAGE = 'mDIM',
|
|
||||||
MSG_MODIFIED = 'mMOD',
|
MSG_MODIFIED = 'mMOD',
|
||||||
MSG_UPDATE_STATUS = 'mUPS',
|
MSG_UPDATE_STATUS = 'mUPS',
|
||||||
MSG_UPDATE_STATUS_TEXT = 'mUPT',
|
MSG_UPDATE_STATUS_TEXT = 'mUPT',
|
||||||
@@ -45,7 +44,6 @@ enum {
|
|||||||
MSG_ROTATE_270 = 'mR27',
|
MSG_ROTATE_270 = 'mR27',
|
||||||
MSG_FLIP_LEFT_TO_RIGHT = 'mFLR',
|
MSG_FLIP_LEFT_TO_RIGHT = 'mFLR',
|
||||||
MSG_FLIP_TOP_TO_BOTTOM = 'mFTB',
|
MSG_FLIP_TOP_TO_BOTTOM = 'mFTB',
|
||||||
MSG_INVERT = 'mINV',
|
|
||||||
MSG_SLIDE_SHOW = 'mSSW',
|
MSG_SLIDE_SHOW = 'mSSW',
|
||||||
MSG_SLIDE_SHOW_DELAY = 'mSSD',
|
MSG_SLIDE_SHOW_DELAY = 'mSSD',
|
||||||
MSG_FULL_SCREEN = 'mFSC',
|
MSG_FULL_SCREEN = 'mFSC',
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
#if DELAYED_SCALING
|
#if DELAYED_SCALING
|
||||||
fScalingCountDown(SCALING_DELAY_TIME),
|
fScalingCountDown(SCALING_DELAY_TIME),
|
||||||
#endif
|
#endif
|
||||||
fInverted(false),
|
|
||||||
|
|
||||||
fBitmapLocationInView(0.0, 0.0),
|
fBitmapLocationInView(0.0, 0.0),
|
||||||
|
|
||||||
@@ -233,8 +232,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
|
|
||||||
SetViewColor(B_TRANSPARENT_COLOR);
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
SetHighColor(kBorderColor);
|
SetHighColor(kBorderColor);
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetLowColor(0, 0, 0);
|
||||||
SetPenSize(PEN_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -487,12 +485,8 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
// restore orientation
|
// restore orientation
|
||||||
int32 orientation;
|
int32 orientation;
|
||||||
fImageOrientation = k0;
|
fImageOrientation = k0;
|
||||||
fInverted = false;
|
|
||||||
if (file.ReadAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
if (file.ReadAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
||||||
&orientation, sizeof(orientation)) == sizeof(orientation)) {
|
&orientation, sizeof(orientation)) == sizeof(orientation)) {
|
||||||
if (orientation & 256)
|
|
||||||
_DoImageOperation(ImageProcessor::ImageProcessor::kInvert, true);
|
|
||||||
|
|
||||||
orientation &= 255;
|
orientation &= 255;
|
||||||
switch (orientation) {
|
switch (orientation) {
|
||||||
case k0:
|
case k0:
|
||||||
@@ -669,13 +663,7 @@ ShowImageView::SetZoomToBounds(bool enable)
|
|||||||
void
|
void
|
||||||
ShowImageView::SetFullScreen(bool fullScreen)
|
ShowImageView::SetFullScreen(bool fullScreen)
|
||||||
{
|
{
|
||||||
if (fFullScreen != fullScreen) {
|
fFullScreen = fullScreen;
|
||||||
fFullScreen = fullScreen;
|
|
||||||
if (fFullScreen) {
|
|
||||||
SetLowColor(0, 0, 0, 255);
|
|
||||||
} else
|
|
||||||
SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -745,12 +733,12 @@ ShowImageView::_AlignBitmap()
|
|||||||
BRect rect(fBitmap->Bounds());
|
BRect rect(fBitmap->Bounds());
|
||||||
|
|
||||||
// the width/height of the bitmap (in pixels)
|
// the width/height of the bitmap (in pixels)
|
||||||
float bitmapWidth = rect.Width() + 1.0;
|
float bitmapWidth = rect.Width() + 1;
|
||||||
float bitmapHeight = rect.Height() + 1.0;
|
float bitmapHeight = rect.Height() + 1;
|
||||||
|
|
||||||
// the available width/height for layouting the bitmap (in pixels)
|
// the available width/height for layouting the bitmap (in pixels)
|
||||||
float width = Bounds().Width() - 2 * PEN_SIZE + 1.0;
|
float width = Bounds().Width() + 1;
|
||||||
float height = Bounds().Height() - 2 * PEN_SIZE + 1.0;
|
float height = Bounds().Height() + 1;
|
||||||
|
|
||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return rect;
|
return rect;
|
||||||
@@ -789,7 +777,7 @@ ShowImageView::_AlignBitmap()
|
|||||||
if (height > bitmapHeight)
|
if (height > bitmapHeight)
|
||||||
rect.OffsetBy(0, floorf((height - bitmapHeight) / 2.0));
|
rect.OffsetBy(0, floorf((height - bitmapHeight) / 2.0));
|
||||||
}
|
}
|
||||||
rect.OffsetBy(PEN_SIZE, PEN_SIZE);
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -804,7 +792,7 @@ ShowImageView::_Setup(BRect rect)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_DrawBorder(BRect border)
|
ShowImageView::_DrawBackground(BRect border)
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
// top
|
// top
|
||||||
@@ -941,15 +929,7 @@ ShowImageView::Draw(BRect updateRect)
|
|||||||
BRect rect = _AlignBitmap();
|
BRect rect = _AlignBitmap();
|
||||||
_Setup(rect);
|
_Setup(rect);
|
||||||
|
|
||||||
BRect border(rect);
|
_DrawBackground(rect);
|
||||||
border.InsetBy(-PEN_SIZE, -PEN_SIZE);
|
|
||||||
|
|
||||||
_DrawBorder(border);
|
|
||||||
|
|
||||||
// Draw black rectangle around image
|
|
||||||
StrokeRect(border);
|
|
||||||
|
|
||||||
// Draw image
|
|
||||||
_DrawImage(rect);
|
_DrawImage(rect);
|
||||||
|
|
||||||
if (fShowCaption)
|
if (fShowCaption)
|
||||||
@@ -1484,7 +1464,7 @@ ShowImageView::_UpdateSelectionRect(BPoint point, bool final)
|
|||||||
BRect updateRect;
|
BRect updateRect;
|
||||||
updateRect = oldSelection | fCopyFromRect;
|
updateRect = oldSelection | fCopyFromRect;
|
||||||
updateRect = ImageToView(updateRect);
|
updateRect = ImageToView(updateRect);
|
||||||
updateRect.InsetBy(-PEN_SIZE, -PEN_SIZE);
|
updateRect.InsetBy(-1, -1);
|
||||||
Invalidate(updateRect);
|
Invalidate(updateRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1851,10 +1831,8 @@ ShowImageView::FixupScrollBars()
|
|||||||
bitmapRect.OffsetTo(0, 0);
|
bitmapRect.OffsetTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixupScrollBar(B_HORIZONTAL, bitmapRect.Width() + 2 * PEN_SIZE,
|
FixupScrollBar(B_HORIZONTAL, bitmapRect.Width(), viewRect.Width());
|
||||||
viewRect.Width());
|
FixupScrollBar(B_VERTICAL, bitmapRect.Height(), viewRect.Height());
|
||||||
FixupScrollBar(B_VERTICAL, bitmapRect.Height() + 2 * PEN_SIZE,
|
|
||||||
viewRect.Height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2328,7 +2306,7 @@ void
|
|||||||
ShowImageView::ZoomIn(BPoint where)
|
ShowImageView::ZoomIn(BPoint where)
|
||||||
{
|
{
|
||||||
if (fZoom < 16)
|
if (fZoom < 16)
|
||||||
SetZoom(where, fZoom + 0.25);
|
SetZoom(where, fZoom * 1.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2336,7 +2314,7 @@ void
|
|||||||
ShowImageView::ZoomOut(BPoint where)
|
ShowImageView::ZoomOut(BPoint where)
|
||||||
{
|
{
|
||||||
if (fZoom > 0.25)
|
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::kFlipLeftToRight < ImageProcessor::kNumberOfAffineTransformations);
|
||||||
ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations);
|
ASSERT(ImageProcessor::kFlipTopToBottom < ImageProcessor::kNumberOfAffineTransformations);
|
||||||
fImageOrientation = fTransformation[op][fImageOrientation];
|
fImageOrientation = fTransformation[op][fImageOrientation];
|
||||||
} else {
|
|
||||||
fInverted = !fInverted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
// write orientation state
|
// write orientation state
|
||||||
BNode node(&fCurrentRef);
|
BNode node(&fCurrentRef);
|
||||||
int32 orientation = fImageOrientation;
|
int32 orientation = fImageOrientation;
|
||||||
if (fInverted) orientation += 256;
|
|
||||||
if (orientation != k0) {
|
if (orientation != k0) {
|
||||||
node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
node.WriteAttr(SHOW_IMAGE_ORIENTATION_ATTRIBUTE, B_INT32_TYPE, 0,
|
||||||
&orientation, sizeof(orientation));
|
&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
|
void
|
||||||
ShowImageView::ResizeImage(int w, int h)
|
ShowImageView::ResizeImage(int w, int h)
|
||||||
{
|
{
|
||||||
@@ -2493,6 +2457,7 @@ ShowImageView::ResizeImage(int w, int h)
|
|||||||
_Notify();
|
_Notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_SetIcon(bool clear, icon_size which)
|
ShowImageView::_SetIcon(bool clear, icon_size which)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,8 +32,6 @@
|
|||||||
#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
|
||||||
// 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)
|
// the delay time for hiding the cursor in 1/10 seconds (the pulse rate)
|
||||||
#define HIDE_CURSOR_DELAY_TIME 20
|
#define HIDE_CURSOR_DELAY_TIME 20
|
||||||
@@ -75,7 +73,6 @@ public:
|
|||||||
BBitmap* bitmap,
|
BBitmap* bitmap,
|
||||||
const translation_format* format);
|
const translation_format* format);
|
||||||
void SetDither(bool dither);
|
void SetDither(bool dither);
|
||||||
bool GetDither() const { return fDither; }
|
|
||||||
void SetScaleBilinear(bool b);
|
void SetScaleBilinear(bool b);
|
||||||
bool GetScaleBilinear() { return fScaleBilinear; }
|
bool GetScaleBilinear() { return fScaleBilinear; }
|
||||||
void SetShowCaption(bool show);
|
void SetShowCaption(bool show);
|
||||||
@@ -130,7 +127,6 @@ public:
|
|||||||
// Image manipulation
|
// Image manipulation
|
||||||
void Rotate(int degree); // 90 and 270 only
|
void Rotate(int degree); // 90 and 270 only
|
||||||
void Flip(bool vertical);
|
void Flip(bool vertical);
|
||||||
void Invert();
|
|
||||||
void ResizeImage(int width, int height);
|
void ResizeImage(int width, int height);
|
||||||
|
|
||||||
void SetIcon(bool clear);
|
void SetIcon(bool clear);
|
||||||
@@ -212,7 +208,7 @@ private:
|
|||||||
void _ScrollBitmap();
|
void _ScrollBitmap();
|
||||||
uint32 _GetMouseButtons();
|
uint32 _GetMouseButtons();
|
||||||
void _UpdateSelectionRect(BPoint point, bool final);
|
void _UpdateSelectionRect(BPoint point, bool final);
|
||||||
void _DrawBorder(BRect border);
|
void _DrawBackground(BRect aroundFrame);
|
||||||
void _LayoutCaption(BFont& font, BPoint& textPos,
|
void _LayoutCaption(BFont& font, BPoint& textPos,
|
||||||
BRect& background);
|
BRect& background);
|
||||||
void _DrawCaption();
|
void _DrawCaption();
|
||||||
@@ -256,7 +252,6 @@ private:
|
|||||||
#if DELAYED_SCALING
|
#if DELAYED_SCALING
|
||||||
int fScalingCountDown;
|
int fScalingCountDown;
|
||||||
#endif
|
#endif
|
||||||
bool fInverted;
|
|
||||||
|
|
||||||
BPoint fBitmapLocationInView;
|
BPoint fBitmapLocationInView;
|
||||||
|
|
||||||
|
|||||||
@@ -207,7 +207,6 @@ ShowImageWindow::ShowImageWindow(const entry_ref* ref,
|
|||||||
BMenu* menu = new BMenu(B_TRANSLATE("View"));
|
BMenu* menu = new BMenu(B_TRANSLATE("View"));
|
||||||
_BuildViewMenu(menu, false);
|
_BuildViewMenu(menu, false);
|
||||||
fBar->AddItem(menu);
|
fBar->AddItem(menu);
|
||||||
_MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither());
|
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
|
|
||||||
SetPulseRate(100000);
|
SetPulseRate(100000);
|
||||||
@@ -410,8 +409,6 @@ ShowImageWindow::AddMenus(BMenuBar* bar)
|
|||||||
_AddItemMenu(menu, B_TRANSLATE("Flip top to bottom"),
|
_AddItemMenu(menu, B_TRANSLATE("Flip top to bottom"),
|
||||||
MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
|
MSG_FLIP_TOP_TO_BOTTOM, 0, 0, this);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
_AddItemMenu(menu, B_TRANSLATE("Invert colors"), MSG_INVERT, 0, 0, this);
|
|
||||||
menu->AddSeparatorItem();
|
|
||||||
fResizeItem = _AddItemMenu(menu, B_TRANSLATE("Resize" B_UTF8_ELLIPSIS),
|
fResizeItem = _AddItemMenu(menu, B_TRANSLATE("Resize" B_UTF8_ELLIPSIS),
|
||||||
MSG_OPEN_RESIZER_WINDOW, 0, 0, this);
|
MSG_OPEN_RESIZER_WINDOW, 0, 0, this);
|
||||||
bar->AddItem(menu);
|
bar->AddItem(menu);
|
||||||
@@ -454,16 +451,17 @@ ShowImageWindow::_AddDelayItem(BMenu* menu, const char* label, float value)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageWindow::WindowRedimension(BBitmap* pbitmap)
|
ShowImageWindow::WindowRedimension(BBitmap* bitmap)
|
||||||
{
|
{
|
||||||
BScreen screen;
|
BScreen screen;
|
||||||
if (!screen.IsValid())
|
if (!screen.IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BRect r(pbitmap->Bounds());
|
// TODO: use View::GetPreferredSize() instead?
|
||||||
float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
|
BRect r(bitmap->Bounds());
|
||||||
float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
|
float width = r.Width() + B_V_SCROLL_BAR_WIDTH;
|
||||||
B_H_SCROLL_BAR_HEIGHT;
|
float height = r.Height() + 1 + fBar->Frame().Height()
|
||||||
|
+ B_H_SCROLL_BAR_HEIGHT;
|
||||||
|
|
||||||
BRect frame = screen.Frame();
|
BRect frame = screen.Frame();
|
||||||
const float windowBorder = 5;
|
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<int32 *>(&colors));
|
|
||||||
_EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8));
|
|
||||||
|
|
||||||
BString status;
|
BString status;
|
||||||
bool messageProvidesSize = false;
|
bool messageProvidesSize = false;
|
||||||
if (message->FindInt32("width", &fWidth) >= B_OK
|
if (message->FindInt32("width", &fWidth) >= B_OK
|
||||||
@@ -781,10 +772,6 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case MSG_DITHER_IMAGE:
|
|
||||||
fImageView->SetDither(_ToggleMenuItem(message->what));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_SHRINK_TO_WINDOW:
|
case MSG_SHRINK_TO_WINDOW:
|
||||||
_ResizeToWindow(true, message->what);
|
_ResizeToWindow(true, message->what);
|
||||||
break;
|
break;
|
||||||
@@ -819,11 +806,8 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
fImageView->Flip(false);
|
fImageView->Flip(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_INVERT:
|
case MSG_SLIDE_SHOW:
|
||||||
fImageView->Invert();
|
{
|
||||||
break;
|
|
||||||
|
|
||||||
case MSG_SLIDE_SHOW: {
|
|
||||||
BMenuItem* item = fBar->FindItem(message->what);
|
BMenuItem* item = fBar->FindItem(message->what);
|
||||||
if (!item)
|
if (!item)
|
||||||
break;
|
break;
|
||||||
@@ -836,16 +820,19 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
|||||||
fResizeItem->SetEnabled(false);
|
fResizeItem->SetEnabled(false);
|
||||||
fImageView->StartSlideShow();
|
fImageView->StartSlideShow();
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_SLIDE_SHOW_DELAY: {
|
case MSG_SLIDE_SHOW_DELAY:
|
||||||
|
{
|
||||||
float value;
|
float value;
|
||||||
if (message->FindFloat("value", &value) == B_OK) {
|
if (message->FindFloat("value", &value) == B_OK) {
|
||||||
fImageView->SetSlideShowDelay(value);
|
fImageView->SetSlideShowDelay(value);
|
||||||
// in case message is sent from popup menu
|
// in case message is sent from popup menu
|
||||||
_MarkSlideShowDelay(value);
|
_MarkSlideShowDelay(value);
|
||||||
}
|
}
|
||||||
} break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_FULL_SCREEN:
|
case MSG_FULL_SCREEN:
|
||||||
_ToggleFullScreen();
|
_ToggleFullScreen();
|
||||||
|
|||||||
Reference in New Issue
Block a user