* 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:
static ImageCache& Default() { return sCache; }
status_t RetrieveImage(const entry_ref& ref, int32 page,
const BMessenger* target);
status_t RetrieveImage(const entry_ref& ref,
int32 page = 1,
const BMessenger* target = NULL);
private:
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.
Returns true if a new file should be loaded, false if not.
*/
+5
View File
@@ -51,6 +51,11 @@ public:
bool HasNextFile();
bool HasPreviousFile();
bool GetNextFile(const entry_ref& ref,
entry_ref& nextRef);
bool GetPreviousFile(const entry_ref& ref,
entry_ref& previousRef);
bool MoveFileToTrash();
private:
+30 -4
View File
@@ -702,7 +702,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
case MSG_FILE_PREV:
if (_ClosePrompt() && fNavigator.PreviousFile())
_LoadImage();
_LoadImage(false);
break;
case MSG_FILE_NEXT:
@@ -976,11 +976,37 @@ ShowImageWindow::_ClosePrompt()
status_t
ShowImageWindow::_LoadImage()
ShowImageWindow::_LoadImage(bool forward)
{
BMessenger us(this);
return ImageCache::Default().RetrieveImage(fNavigator.CurrentRef(),
fNavigator.CurrentPage(), &us);
status_t status = ImageCache::Default().RetrieveImage(
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);
// Handle save file panel message
bool _ClosePrompt();
status_t _LoadImage();
status_t _LoadImage(bool forward = true);
bool _PreloadImage(bool forward, entry_ref& ref);
void _ToggleFullScreen();
void _ApplySettings();
void _SavePrintOptions();