* Removed the delayed scaler code - it's no longer needed (and was trying rather
stupid things like creating a 50000x40000 pixel bitmap if you zoomed in). * Removed dithering in CMAP8 mode. Please use 32 bit mode instead :-) * Cleaned up ShowImageWindow.h. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39098 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -192,12 +192,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
|
|
||||||
fZoom(1.0),
|
fZoom(1.0),
|
||||||
|
|
||||||
fDither(BScreen().ColorSpace() == B_CMAP8),
|
|
||||||
fScaleBilinear(true),
|
fScaleBilinear(true),
|
||||||
fScaler(NULL),
|
|
||||||
#if DELAYED_SCALING
|
|
||||||
fScalingCountDown(SCALING_DELAY_TIME),
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fBitmapLocationInView(0.0, 0.0),
|
fBitmapLocationInView(0.0, 0.0),
|
||||||
|
|
||||||
@@ -222,7 +217,6 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode,
|
|||||||
ShowImageSettings* settings;
|
ShowImageSettings* settings;
|
||||||
settings = my_app->Settings();
|
settings = my_app->Settings();
|
||||||
if (settings->Lock()) {
|
if (settings->Lock()) {
|
||||||
fDither = settings->GetBool("Dither", fDither);
|
|
||||||
fShrinkToBounds = settings->GetBool("ShrinkToBounds", fShrinkToBounds);
|
fShrinkToBounds = settings->GetBool("ShrinkToBounds", fShrinkToBounds);
|
||||||
fZoomToBounds = settings->GetBool("ZoomToBounds", fZoomToBounds);
|
fZoomToBounds = settings->GetBool("ZoomToBounds", fZoomToBounds);
|
||||||
fSlideShowDelay = settings->GetInt32("SlideShowDelay", fSlideShowDelay);
|
fSlideShowDelay = settings->GetInt32("SlideShowDelay", fSlideShowDelay);
|
||||||
@@ -274,17 +268,6 @@ ShowImageView::Pulse()
|
|||||||
else
|
else
|
||||||
fHideCursorCountDown--;
|
fHideCursorCountDown--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DELAYED_SCALING
|
|
||||||
if (fBitmap && (fScaleBilinear || fDither) && fScalingCountDown > 0) {
|
|
||||||
if (fScalingCountDown == 1) {
|
|
||||||
fScalingCountDown = 0;
|
|
||||||
_GetScaler(_AlignBitmap());
|
|
||||||
} else {
|
|
||||||
fScalingCountDown --;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -376,24 +359,9 @@ ShowImageView::_UpdateStatusText()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageView::_DeleteScaler()
|
|
||||||
{
|
|
||||||
if (fScaler) {
|
|
||||||
fScaler->Stop();
|
|
||||||
delete fScaler;
|
|
||||||
fScaler = NULL;
|
|
||||||
}
|
|
||||||
#if DELAYED_SCALING
|
|
||||||
fScalingCountDown = SCALING_DELAY_TIME;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_DeleteBitmap()
|
ShowImageView::_DeleteBitmap()
|
||||||
{
|
{
|
||||||
_DeleteScaler();
|
|
||||||
_DeleteSelectionBitmap();
|
_DeleteSelectionBitmap();
|
||||||
|
|
||||||
if (fDisplayBitmap != fBitmap)
|
if (fDisplayBitmap != fBitmap)
|
||||||
@@ -615,17 +583,6 @@ ShowImageView::_SetSelection(const entry_ref *ref, BPoint point)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageView::SetDither(bool dither)
|
|
||||||
{
|
|
||||||
if (fDither != dither) {
|
|
||||||
_SettingsSetBool("Dither", dither);
|
|
||||||
fDither = dither;
|
|
||||||
Invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::SetShowCaption(bool show)
|
ShowImageView::SetShowCaption(bool show)
|
||||||
{
|
{
|
||||||
@@ -871,40 +828,9 @@ ShowImageView::_UpdateCaption()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Scaler*
|
|
||||||
ShowImageView::_GetScaler(BRect rect)
|
|
||||||
{
|
|
||||||
if (fScaler == NULL || !fScaler->Matches(rect, fDither)) {
|
|
||||||
_DeleteScaler();
|
|
||||||
BMessenger msgr(this, Window());
|
|
||||||
fScaler = new Scaler(fDisplayBitmap, rect, msgr, MSG_INVALIDATE, fDither);
|
|
||||||
fScaler->Start();
|
|
||||||
}
|
|
||||||
return fScaler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::_DrawImage(BRect rect)
|
ShowImageView::_DrawImage(BRect rect)
|
||||||
{
|
{
|
||||||
if (fDither) {
|
|
||||||
#if DELAYED_SCALING
|
|
||||||
Scaler* scaler = fScaler;
|
|
||||||
if (scaler != NULL && !scaler->Matches(rect, fDither)) {
|
|
||||||
_DeleteScaler(); scaler = NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
Scaler* scaler = _GetScaler(rect);
|
|
||||||
#endif
|
|
||||||
if (scaler != NULL && !scaler->IsRunning()) {
|
|
||||||
BBitmap* bitmap = scaler->GetBitmap();
|
|
||||||
|
|
||||||
if (bitmap) {
|
|
||||||
DrawBitmap(bitmap, BPoint(rect.left, rect.top));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: fix composing of fBitmap with other bitmaps
|
// TODO: fix composing of fBitmap with other bitmaps
|
||||||
// with regard to alpha channel
|
// with regard to alpha channel
|
||||||
if (!fDisplayBitmap)
|
if (!fDisplayBitmap)
|
||||||
@@ -2276,9 +2202,6 @@ ShowImageView::_FirstFile()
|
|||||||
void
|
void
|
||||||
ShowImageView::SetZoom(BPoint where, float zoom)
|
ShowImageView::SetZoom(BPoint where, float zoom)
|
||||||
{
|
{
|
||||||
if ((fScaleBilinear || fDither) && fZoom != zoom)
|
|
||||||
_DeleteScaler();
|
|
||||||
|
|
||||||
// Invalidate before scrolling, as that prevents the app_server
|
// Invalidate before scrolling, as that prevents the app_server
|
||||||
// to do the scrolling server side
|
// to do the scrolling server side
|
||||||
Invalidate();
|
Invalidate();
|
||||||
|
|||||||
@@ -27,12 +27,6 @@
|
|||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
// Delay scaling operation, so that a sequence of zoom in/out operations works
|
|
||||||
// smoother
|
|
||||||
#define DELAYED_SCALING 1
|
|
||||||
// the delay time in 1/10 seconds
|
|
||||||
#define SCALING_DELAY_TIME 3
|
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
@@ -72,7 +66,6 @@ public:
|
|||||||
void SaveToFile(BDirectory* dir, const char* name,
|
void SaveToFile(BDirectory* dir, const char* name,
|
||||||
BBitmap* bitmap,
|
BBitmap* bitmap,
|
||||||
const translation_format* format);
|
const translation_format* format);
|
||||||
void SetDither(bool dither);
|
|
||||||
void SetScaleBilinear(bool b);
|
void SetScaleBilinear(bool b);
|
||||||
bool GetScaleBilinear() { return fScaleBilinear; }
|
bool GetScaleBilinear() { return fScaleBilinear; }
|
||||||
void SetShowCaption(bool show);
|
void SetShowCaption(bool show);
|
||||||
@@ -214,7 +207,6 @@ private:
|
|||||||
void _DrawCaption();
|
void _DrawCaption();
|
||||||
void _UpdateCaption();
|
void _UpdateCaption();
|
||||||
|
|
||||||
Scaler* _GetScaler(BRect rect);
|
|
||||||
void _DrawImage(BRect rect);
|
void _DrawImage(BRect rect);
|
||||||
float _LimitToRange(float v, orientation o,
|
float _LimitToRange(float v, orientation o,
|
||||||
bool absolute);
|
bool absolute);
|
||||||
@@ -246,12 +238,7 @@ private:
|
|||||||
|
|
||||||
float fZoom;
|
float fZoom;
|
||||||
|
|
||||||
bool fDither;
|
|
||||||
bool fScaleBilinear;
|
bool fScaleBilinear;
|
||||||
Scaler* fScaler;
|
|
||||||
#if DELAYED_SCALING
|
|
||||||
int fScalingCountDown;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BPoint fBitmapLocationInView;
|
BPoint fBitmapLocationInView;
|
||||||
|
|
||||||
|
|||||||
@@ -1293,10 +1293,3 @@ ShowImageWindow::QuitRequested()
|
|||||||
|
|
||||||
return quit;
|
return quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ShowImageWindow::ScreenChanged(BRect frame, color_space mode)
|
|
||||||
{
|
|
||||||
fImageView->SetDither(mode == B_CMAP8);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2010, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -26,72 +26,78 @@ class ShowImageStatusView;
|
|||||||
|
|
||||||
|
|
||||||
class ShowImageWindow : public BWindow {
|
class ShowImageWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ShowImageWindow(const entry_ref *ref, const BMessenger& trackerMessenger);
|
ShowImageWindow(const entry_ref* ref,
|
||||||
virtual ~ShowImageWindow();
|
const BMessenger& trackerMessenger);
|
||||||
|
virtual ~ShowImageWindow();
|
||||||
|
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void ScreenChanged(BRect frame, color_space mode);
|
|
||||||
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
ShowImageView* GetShowImageView() const { return fImageView; }
|
ShowImageView* GetShowImageView() const { return fImageView; }
|
||||||
|
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
void AddMenus(BMenuBar *bar);
|
void AddMenus(BMenuBar* bar);
|
||||||
void BuildContextMenu(BMenu *menu);
|
void BuildContextMenu(BMenu* menu);
|
||||||
void WindowRedimension(BBitmap *bitmap);
|
void WindowRedimension(BBitmap* bitmap);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class RecentDocumentsMenu;
|
class RecentDocumentsMenu;
|
||||||
|
|
||||||
void _BuildViewMenu(BMenu *menu, bool popupMenu);
|
void _BuildViewMenu(BMenu* menu, bool popupMenu);
|
||||||
BMenuItem* _AddItemMenu(BMenu *menu, const char *label,
|
BMenuItem* _AddItemMenu(BMenu* menu, const char* label,
|
||||||
uint32 what, const char shortcut, uint32 modifier,
|
uint32 what, const char shortcut,
|
||||||
const BHandler *target, bool enabled = true);
|
uint32 modifier, const BHandler* target,
|
||||||
BMenuItem* _AddDelayItem(BMenu *menu, const char *label, float value);
|
bool enabled = true);
|
||||||
|
BMenuItem* _AddDelayItem(BMenu* menu, const char* label,
|
||||||
|
float value);
|
||||||
|
|
||||||
bool _ToggleMenuItem(uint32 what);
|
bool _ToggleMenuItem(uint32 what);
|
||||||
void _EnableMenuItem(BMenu *menu, uint32 what, bool enable);
|
void _EnableMenuItem(BMenu* menu, uint32 what,
|
||||||
void _MarkMenuItem(BMenu *menu, uint32 what, bool marked);
|
bool enable);
|
||||||
void _MarkSlideShowDelay(float value);
|
void _MarkMenuItem(BMenu* menu, uint32 what,
|
||||||
void _ResizeToWindow(bool shrink, uint32 what);
|
bool marked);
|
||||||
|
void _MarkSlideShowDelay(float value);
|
||||||
|
void _ResizeToWindow(bool shrink, uint32 what);
|
||||||
|
|
||||||
void _SaveAs(BMessage *message);
|
void _SaveAs(BMessage* message);
|
||||||
// Handle Save As submenu choice
|
// Handle Save As submenu choice
|
||||||
void _SaveToFile(BMessage *message);
|
void _SaveToFile(BMessage* message);
|
||||||
// Handle save file panel message
|
// Handle save file panel message
|
||||||
bool _ClosePrompt();
|
bool _ClosePrompt();
|
||||||
void _ToggleFullScreen();
|
void _ToggleFullScreen();
|
||||||
void _LoadSettings();
|
void _LoadSettings();
|
||||||
void _SavePrintOptions();
|
void _SavePrintOptions();
|
||||||
bool _PageSetup();
|
bool _PageSetup();
|
||||||
void _PrepareForPrint();
|
void _PrepareForPrint();
|
||||||
void _Print(BMessage *msg);
|
void _Print(BMessage* msg);
|
||||||
|
|
||||||
void _OpenResizerWindow(int32 width, int32 height);
|
void _OpenResizerWindow(int32 width, int32 height);
|
||||||
void _UpdateResizerWindow(int32 width, int32 height);
|
void _UpdateResizerWindow(int32 width, int32 height);
|
||||||
void _CloseResizerWindow();
|
void _CloseResizerWindow();
|
||||||
|
|
||||||
BFilePanel* fSavePanel;
|
private:
|
||||||
BMenuBar* fBar;
|
BFilePanel* fSavePanel;
|
||||||
BMenu* fOpenMenu;
|
BMenuBar* fBar;
|
||||||
BMenu* fBrowseMenu;
|
BMenu* fOpenMenu
|
||||||
BMenu* fGoToPageMenu;
|
; BMenu* fBrowseMenu;
|
||||||
BMenu* fSlideShowDelay;
|
BMenu* fGoToPageMenu;
|
||||||
ShowImageView* fImageView;
|
BMenu* fSlideShowDelay;
|
||||||
ShowImageStatusView* fStatusView;
|
ShowImageView* fImageView;
|
||||||
bool fModified;
|
ShowImageStatusView* fStatusView;
|
||||||
bool fFullScreen;
|
bool fModified;
|
||||||
BRect fWindowFrame;
|
bool fFullScreen;
|
||||||
bool fShowCaption;
|
BRect fWindowFrame;
|
||||||
BMessage* fPrintSettings;
|
bool fShowCaption;
|
||||||
PrintOptions fPrintOptions;
|
BMessage* fPrintSettings;
|
||||||
BMessenger* fResizerWindowMessenger;
|
PrintOptions fPrintOptions;
|
||||||
BMenuItem* fResizeItem;
|
BMessenger* fResizerWindowMessenger;
|
||||||
int32 fHeight;
|
BMenuItem* fResizeItem;
|
||||||
int32 fWidth;
|
int32 fHeight;
|
||||||
|
int32 fWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SHOW_IMAGE_WINDOW_H
|
#endif // SHOW_IMAGE_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user