ShowImage: Multipage images displayed in sequence.
* The correct page is displayed. * Next/Previous/First/Last page are enabled and disable as Next/Previous File. * Add in the status bar current page/ total page. * Fixes #11959.
This commit is contained in:
parent
35df7c671e
commit
baa27ccb30
@ -503,6 +503,20 @@ ImageFileNavigator::PreviousPage()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ImageFileNavigator::HasNextPage()
|
||||
{
|
||||
return fDocumentIndex < fDocumentCount;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ImageFileNavigator::HasPreviousPage()
|
||||
{
|
||||
return fDocumentIndex > 1;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
ImageFileNavigator::GoToPage(int32 page)
|
||||
{
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
bool LastPage();
|
||||
bool NextPage();
|
||||
bool PreviousPage();
|
||||
bool HasNextPage();
|
||||
bool HasPreviousPage();
|
||||
bool GoToPage(int32 page);
|
||||
|
||||
bool FirstFile();
|
||||
|
@ -150,12 +150,13 @@ ShowImageStatusView::MouseDown(BPoint where)
|
||||
|
||||
void
|
||||
ShowImageStatusView::Update(const entry_ref& ref, const BString& text,
|
||||
const BString& imageType, float zoom)
|
||||
const BString& pages, const BString& imageType, float zoom)
|
||||
{
|
||||
fRef = ref;
|
||||
|
||||
_SetFrameText(text);
|
||||
_SetZoomText(zoom);
|
||||
_SetPagesText(pages);
|
||||
_SetImageTypeText(imageType);
|
||||
|
||||
_ValidatePreferredSize();
|
||||
@ -175,21 +176,28 @@ ShowImageStatusView::SetZoom(float zoom)
|
||||
void
|
||||
ShowImageStatusView::_SetFrameText(const BString& text)
|
||||
{
|
||||
fCellText[0] = text;
|
||||
fCellText[kFrameSizeCell] = text;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageStatusView::_SetZoomText(float zoom)
|
||||
{
|
||||
fCellText[1].SetToFormat("%.0f%%", zoom * 100);
|
||||
fCellText[kZoomCell].SetToFormat("%.0f%%", zoom * 100);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageStatusView::_SetPagesText(const BString& pages)
|
||||
{
|
||||
fCellText[kPagesCell] = pages;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ShowImageStatusView::_SetImageTypeText(const BString& imageType)
|
||||
{
|
||||
fCellText[2] = imageType;
|
||||
fCellText[kImageTypeCell] = imageType;
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
enum {
|
||||
kFrameSizeCell,
|
||||
kZoomCell,
|
||||
kPagesCell,
|
||||
kImageTypeCell,
|
||||
kStatusCellCount
|
||||
};
|
||||
@ -34,12 +35,13 @@ public:
|
||||
virtual void MouseDown(BPoint where);
|
||||
|
||||
void Update(const entry_ref& ref,
|
||||
const BString& text, const BString& imageType,
|
||||
float zoom);
|
||||
const BString& text, const BString& pages,
|
||||
const BString& imageType, float zoom);
|
||||
void SetZoom(float zoom);
|
||||
private:
|
||||
void _SetFrameText(const BString& text);
|
||||
void _SetZoomText(float zoom);
|
||||
void _SetPagesText(const BString& pages);
|
||||
void _SetImageTypeText(const BString& imageType);
|
||||
void _ValidatePreferredSize();
|
||||
BScrollView* fScrollView;
|
||||
|
@ -615,6 +615,15 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
int32 page = message->FindInt32("page");
|
||||
int32 pageCount = message->FindInt32("pageCount");
|
||||
if (!first && page != fNavigator.CurrentPage()) {
|
||||
// ignore older pages
|
||||
if (bitmapOwner != NULL)
|
||||
bitmapOwner->ReleaseReference();
|
||||
break;
|
||||
}
|
||||
|
||||
status_t status = fImageView->SetImage(message);
|
||||
if (status != B_OK) {
|
||||
if (bitmapOwner != NULL)
|
||||
@ -629,8 +638,7 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
fImageType = message->FindString("type");
|
||||
fNavigator.SetTo(ref, message->FindInt32("page"),
|
||||
message->FindInt32("pageCount"));
|
||||
fNavigator.SetTo(ref, page, pageCount);
|
||||
|
||||
fImageView->FitToBounds();
|
||||
if (first) {
|
||||
@ -680,12 +688,12 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
||||
int32 pages = fNavigator.PageCount();
|
||||
int32 currentPage = fNavigator.CurrentPage();
|
||||
|
||||
bool enable = pages > 1 ? true : false;
|
||||
_EnableMenuItem(fBar, MSG_PAGE_FIRST, enable);
|
||||
_EnableMenuItem(fBar, MSG_PAGE_LAST, enable);
|
||||
_EnableMenuItem(fBar, MSG_PAGE_NEXT, enable);
|
||||
_EnableMenuItem(fBar, MSG_PAGE_PREV, enable);
|
||||
fGoToPageMenu->SetEnabled(enable);
|
||||
_EnableMenuItem(fBar, MSG_PAGE_FIRST,
|
||||
fNavigator.HasPreviousPage());
|
||||
_EnableMenuItem(fBar, MSG_PAGE_LAST, fNavigator.HasNextPage());
|
||||
_EnableMenuItem(fBar, MSG_PAGE_NEXT, fNavigator.HasNextPage());
|
||||
_EnableMenuItem(fBar, MSG_PAGE_PREV, fNavigator.HasPreviousPage());
|
||||
fGoToPageMenu->SetEnabled(pages > 1);
|
||||
|
||||
_EnableMenuItem(fBar, MSG_FILE_NEXT, fNavigator.HasNextFile());
|
||||
_EnableMenuItem(fBar, MSG_FILE_PREV, fNavigator.HasPreviousFile());
|
||||
@ -1054,14 +1062,16 @@ ShowImageWindow::MessageReceived(BMessage* message)
|
||||
void
|
||||
ShowImageWindow::_UpdateStatusText(const BMessage* message)
|
||||
{
|
||||
BString status;
|
||||
BString frameText;
|
||||
if (fImageView->Bitmap() != NULL) {
|
||||
BRect bounds = fImageView->Bitmap()->Bounds();
|
||||
status << bounds.IntegerWidth() + 1
|
||||
frameText << bounds.IntegerWidth() + 1
|
||||
<< "x" << bounds.IntegerHeight() + 1;
|
||||
}
|
||||
|
||||
fStatusView->Update(fNavigator.CurrentRef(), status, fImageType,
|
||||
BString pages;
|
||||
if (fNavigator.PageCount() > 1)
|
||||
pages << fNavigator.CurrentPage() << "/" << fNavigator.PageCount();
|
||||
fStatusView->Update(fNavigator.CurrentRef(), frameText, pages, fImageType,
|
||||
fImageView->Zoom());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user