diff options
author | Michael Vrhel <michael.vrhel@artifex.com> | 2013-05-28 00:12:55 -0700 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-06-03 15:23:27 +0100 |
commit | 16b8e2856cdfed478039dc29f6a2c6645c14fe69 (patch) | |
tree | ba3113d24cb47698ed90bfb8ac7887877cfb8b61 /winrt | |
parent | eeac55c6d5df2f841ae72327fa5347feecbdba60 (diff) | |
download | mupdf-16b8e2856cdfed478039dc29f6a2c6645c14fe69.tar.xz |
Fix for issue of link rectangle display when device is rotated.
The links rectangles need to be recomputed when we have a device orientation
change occur. When a change in orientation occurs, the current rects are
marked as being invalid and will be redrawn when needed.
Diffstat (limited to 'winrt')
-rw-r--r-- | winrt/mupdf_cpp/DocumentPage.h | 1 | ||||
-rw-r--r-- | winrt/mupdf_cpp/MainPage.xaml.cpp | 36 | ||||
-rw-r--r-- | winrt/mupdf_cpp/MainPage.xaml.h | 2 |
3 files changed, 27 insertions, 12 deletions
diff --git a/winrt/mupdf_cpp/DocumentPage.h b/winrt/mupdf_cpp/DocumentPage.h index 1ea1f669..41c83bc3 100644 --- a/winrt/mupdf_cpp/DocumentPage.h +++ b/winrt/mupdf_cpp/DocumentPage.h @@ -13,6 +13,7 @@ typedef enum { FULL_RESOLUTION = 0, THUMBNAIL, DUMMY, + OLD_RESOLUTION, NOTSET } Page_Content_t; diff --git a/winrt/mupdf_cpp/MainPage.xaml.cpp b/winrt/mupdf_cpp/MainPage.xaml.cpp index d5fb96b5..86d06f49 100644 --- a/winrt/mupdf_cpp/MainPage.xaml.cpp +++ b/winrt/mupdf_cpp/MainPage.xaml.cpp @@ -1017,10 +1017,13 @@ void mupdf_cpp::MainPage::GridSizeChanged() if (m_num_pages > 0 && old_flip != m_curr_flipView && old_flip != nullptr) { - if ((this->m_curr_flipView->SelectedIndex == this->m_currpage) && this->m_links_on) - FlipView_SelectionChanged(nullptr, nullptr); - else - this->m_curr_flipView->SelectedIndex = this->m_currpage; + /* If links are on or off, we need to invalidate */ + ClearLinks(); + InvalidateLinks(); + auto doc = this->m_docPages->GetAt(m_currpage); + doc->Content = OLD_RESOLUTION; /* To force a rerender */ + this->m_curr_flipView->SelectedIndex = this->m_currpage; + FlipView_SelectionChanged(nullptr, nullptr); } } @@ -1057,22 +1060,31 @@ void mupdf_cpp::MainPage::Linker(Platform::Object^ sender, Windows::UI::Xaml::Ro if (m_links_on) AddLinkCanvas(); else + ClearLinks(); +} + +void mupdf_cpp::MainPage::ClearLinks() +{ + /* Make sure surrounding render pages lose their links */ + for (int k = m_currpage - LOOK_AHEAD; k <= m_currpage + LOOK_AHEAD; k++) { - /* Make sure surrounding render pages lose their links */ - for (int k = m_currpage - LOOK_AHEAD; k <= m_currpage + LOOK_AHEAD; k++) + if (k >= 0 && k < m_num_pages) { - if (k >= 0 && k < m_num_pages) + auto doc_page = this->m_docPages->GetAt(k); + if (doc_page->Content == FULL_RESOLUTION) { - auto doc_page = this->m_docPages->GetAt(k); - if (doc_page->Content == FULL_RESOLUTION) - { - doc_page->LinkBox = nullptr; - } + doc_page->LinkBox = nullptr; } } } } +void mupdf_cpp::MainPage::InvalidateLinks() +{ + for (int k = 0; k < m_num_pages; k++) + m_linkset->SetAt(k, false); +} + /* Add in the link rects. If we have not already computed them then do that now */ void mupdf_cpp::MainPage::AddLinkCanvas() { diff --git a/winrt/mupdf_cpp/MainPage.xaml.h b/winrt/mupdf_cpp/MainPage.xaml.h index 96476361..162e0985 100644 --- a/winrt/mupdf_cpp/MainPage.xaml.h +++ b/winrt/mupdf_cpp/MainPage.xaml.h @@ -133,6 +133,8 @@ namespace mupdf_cpp void ReleasePages(int old_page, int new_page); void Linker(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void AddLinkCanvas(); + void ClearLinks(); + void InvalidateLinks(); void ContentDisplay(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void FlattenOutline(fz_outline *outline, int level); void ListView_Single_Tap(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); |