* Implemented preloading of the images around he current one; always two in the

direction of the current navigation, and one in the opposite direction.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39377 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-11-09 19:09:18 +00:00
parent 729f344683
commit a569816bb0
5 changed files with 55 additions and 7 deletions
+3 -2
View File
@@ -42,8 +42,9 @@ class ImageCache {
public: public:
static ImageCache& Default() { return sCache; } static ImageCache& Default() { return sCache; }
status_t RetrieveImage(const entry_ref& ref, int32 page, status_t RetrieveImage(const entry_ref& ref,
const BMessenger* target); int32 page = 1,
const BMessenger* target = NULL);
private: private:
ImageCache(); ImageCache();
+15
View File
@@ -470,6 +470,21 @@ ImageFileNavigator::HasPreviousFile()
} }
bool
ImageFileNavigator::GetNextFile(const entry_ref& ref, entry_ref& nextRef)
{
return fNavigator->FindNextImage(ref, nextRef, true, false);
}
bool
ImageFileNavigator::GetPreviousFile(const entry_ref& ref,
entry_ref& previousRef)
{
return fNavigator->FindNextImage(ref, previousRef, false, false);
}
/*! Moves the current file into the trash. /*! Moves the current file into the trash.
Returns true if a new file should be loaded, false if not. Returns true if a new file should be loaded, false if not.
*/ */
+5
View File
@@ -51,6 +51,11 @@ public:
bool HasNextFile(); bool HasNextFile();
bool HasPreviousFile(); bool HasPreviousFile();
bool GetNextFile(const entry_ref& ref,
entry_ref& nextRef);
bool GetPreviousFile(const entry_ref& ref,
entry_ref& previousRef);
bool MoveFileToTrash(); bool MoveFileToTrash();
private: private:
+30 -4
View File
@@ -702,7 +702,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
case MSG_FILE_PREV: case MSG_FILE_PREV:
if (_ClosePrompt() && fNavigator.PreviousFile()) if (_ClosePrompt() && fNavigator.PreviousFile())
_LoadImage(); _LoadImage(false);
break; break;
case MSG_FILE_NEXT: case MSG_FILE_NEXT:
@@ -976,11 +976,37 @@ ShowImageWindow::_ClosePrompt()
status_t status_t
ShowImageWindow::_LoadImage() ShowImageWindow::_LoadImage(bool forward)
{ {
BMessenger us(this); BMessenger us(this);
return ImageCache::Default().RetrieveImage(fNavigator.CurrentRef(), status_t status = ImageCache::Default().RetrieveImage(
fNavigator.CurrentPage(), &us); fNavigator.CurrentRef(), fNavigator.CurrentPage(), &us);
if (status != B_OK)
return status;
// Preload previous/next images - two in the navigation direction, one
// in the opposite direction.
entry_ref nextRef = fNavigator.CurrentRef();
if (_PreloadImage(forward, nextRef))
_PreloadImage(forward, nextRef);
entry_ref previousRef = fNavigator.CurrentRef();
_PreloadImage(!forward, previousRef);
return B_OK;
}
bool
ShowImageWindow::_PreloadImage(bool forward, entry_ref& ref)
{
entry_ref currentRef = ref;
if ((forward && !fNavigator.GetNextFile(currentRef, ref))
|| (!forward && !fNavigator.GetPreviousFile(currentRef, ref)))
return false;
return ImageCache::Default().RetrieveImage(ref) == B_OK;
} }
+2 -1
View File
@@ -64,7 +64,8 @@ private:
void _SaveToFile(BMessage* message); void _SaveToFile(BMessage* message);
// Handle save file panel message // Handle save file panel message
bool _ClosePrompt(); bool _ClosePrompt();
status_t _LoadImage(); status_t _LoadImage(bool forward = true);
bool _PreloadImage(bool forward, entry_ref& ref);
void _ToggleFullScreen(); void _ToggleFullScreen();
void _ApplySettings(); void _ApplySettings();
void _SavePrintOptions(); void _SavePrintOptions();