summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2013-05-07 23:30:46 -0700
committerRobin Watts <robin.watts@artifex.com>2013-05-16 19:25:51 +0100
commitb1d1cad431495900378054fec3981221b17cdcb1 (patch)
tree43c425a30e6c02fa23e863152d02b933fcaf342f
parent085eae5dfc8086694f0ae703a843e8d92db38abe (diff)
downloadmupdf-b1d1cad431495900378054fec3981221b17cdcb1.tar.xz
Fix for crash with rotation of devices. Added rescale for thumb images with device rotation.
-rw-r--r--winrt/mupdf_cpp/MainPage.xaml4
-rw-r--r--winrt/mupdf_cpp/MainPage.xaml.cpp26
2 files changed, 15 insertions, 15 deletions
diff --git a/winrt/mupdf_cpp/MainPage.xaml b/winrt/mupdf_cpp/MainPage.xaml
index abaf7d36..e5083d63 100644
--- a/winrt/mupdf_cpp/MainPage.xaml
+++ b/winrt/mupdf_cpp/MainPage.xaml
@@ -98,7 +98,8 @@
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</FlipView.ItemsPanel>
- <DataTemplate>
+ <FlipView.ItemTemplate>
+ <DataTemplate>
<ScrollViewer
ZoomMode="Enabled"
ViewChanged="ScrollChanged"
@@ -114,6 +115,7 @@
Stretch="Uniform" HorizontalAlignment="Center" Margin="0"/>
</ScrollViewer>
</DataTemplate>
+ </FlipView.ItemTemplate>
</FlipView>
</Canvas>
diff --git a/winrt/mupdf_cpp/MainPage.xaml.cpp b/winrt/mupdf_cpp/MainPage.xaml.cpp
index ffd8bd52..50c6291c 100644
--- a/winrt/mupdf_cpp/MainPage.xaml.cpp
+++ b/winrt/mupdf_cpp/MainPage.xaml.cpp
@@ -972,8 +972,7 @@ void mupdf_cpp::MainPage::SearchInDirection(int dir, String^ textToFind)
}, task_continuation_context::use_current());
}
-/* This is here to handle when we rotate or go into the snapview mode
- ToDo add in data binding to change the scroll direction */
+/* This is here to handle when we rotate or go into the snapview mode */
void mupdf_cpp::MainPage::GridSizeChanged()
{
int height = this->ActualHeight;
@@ -1037,25 +1036,24 @@ void mupdf_cpp::MainPage::GridSizeChanged()
void mupdf_cpp::MainPage::UpDatePageSizes()
{
- /* Render our current pages at the new resolution and rescale the thumbnail
- canvas if needed */
+ /* Reset the thumb view scaling value */
if (m_num_pages > 0)
{
- for (int i = 0; i < m_num_pages; i++)
+ int num_items = m_thumbnails->Size;
+ for (int i = 0; i < num_items; i++)
{
- FlipViewItem ^flipview_temp = (FlipViewItem^) m_curr_flipView->Items->GetAt(i);
- if (flipview_temp != nullptr && flipview_temp->Content != nullptr)
+ DocumentPage ^thumb_page = m_thumbnails->GetAt(i);
+ if (thumb_page != nullptr && thumb_page->Image != nullptr)
{
- Canvas^ curr_canvas = (Canvas^) flipview_temp->Content;
- int curr_canvas_height = curr_canvas->Height;
- int curr_canvas_width = curr_canvas->Width;
+ int curr_height = thumb_page->Height;
+ int curr_width = thumb_page->Width;
- double scale_x = (double) curr_canvas_height / (double) this->xaml_zoomCanvas->Height;
- double scale_y = (double) curr_canvas_width / (double) this->xaml_zoomCanvas->Width;
+ double scale_x = (double) curr_height / (double) this->xaml_zoomCanvas->Height;
+ double scale_y = (double) curr_width / (double) this->xaml_zoomCanvas->Width;
double min_scale = max(scale_x, scale_y);
- curr_canvas->Height = curr_canvas_height / min_scale;
- curr_canvas->Width = curr_canvas_width / min_scale;
+ thumb_page->Height = curr_height / min_scale;
+ thumb_page->Width = curr_width / min_scale;
}
}
}