Revision: 5701
http://skim-app.svn.sourceforge.net/skim-app/?rev=5701&view=rev
Author: hofman
Date: 2009-09-07 10:08:39 +0000 (Mon, 07 Sep 2009)
Log Message:
-----------
fix alternateZoomToFit action, on 10.6 some extra margin is used that made the
wrong scrollers visible after this action. Also make sure we scroll to the top
of the page after this.
Modified Paths:
--------------
trunk/SKMainWindowController_Actions.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m 2009-09-07 00:34:38 UTC (rev
5700)
+++ trunk/SKMainWindowController_Actions.m 2009-09-07 10:08:39 UTC (rev
5701)
@@ -482,24 +482,23 @@
[pdfView setAutoScales:NO];
}
-- (IBAction)alternateZoomToFit:(id)sender {
+- (IBAction)alternateZoomToFit:(id)sender {log_method();
PDFDisplayMode displayMode = [pdfView displayMode];
NSRect frame = [pdfView frame];
+ NSRect pageRect = [[pdfView currentPage] boundsForBox:[pdfView
displayBox]];
+ NSRect normalPageRect = [pdfView convertRect:pageRect fromPage:[pdfView
currentPage]];
CGFloat scaleFactor = [pdfView scaleFactor];
+ CGFloat margin = [pdfView displaysPageBreaks] == NO ? 0.0 :
floor(NSAppKitVersionNumber) > 949 ? 20.0 : 10.0;
if (displayMode == kPDFDisplaySinglePage || displayMode ==
kPDFDisplayTwoUp) {
// zoom to width
- CGFloat width = NSWidth([pdfView convertRect:[[pdfView documentView]
bounds] fromView:[pdfView documentView]]) / scaleFactor;
- [pdfView setScaleFactor:NSWidth(frame) / width];
+ scaleFactor = NSWidth(frame) / ( margin + NSWidth(normalPageRect) /
scaleFactor );
} else {
// zoom to height
- NSRect pageRect = [[pdfView currentPage] boundsForBox:[pdfView
displayBox]];
- CGFloat height = NSHeight([pdfView convertRect:pageRect
fromPage:[pdfView currentPage]]) / scaleFactor;
- if ([pdfView displaysPageBreaks])
- height += 10.0;
- [pdfView setScaleFactor:NSHeight(frame) / height];
- [pdfView layoutDocumentView];
- [pdfView scrollRect:pageRect inPageToVisible:[pdfView currentPage]];
+ scaleFactor = NSHeight(frame) / ( margin + NSHeight(normalPageRect) /
scaleFactor );
}
+ [pdfView setScaleFactor:scaleFactor];
+ [pdfView layoutDocumentView];
+ [pdfView scrollPageToVisible:[pdfView currentPage]];
}
- (IBAction)zoomInActualOut:(id)sender {
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2009-09-07 00:34:38 UTC (rev 5700)
+++ trunk/SKPDFView.h 2009-09-07 10:08:39 UTC (rev 5701)
@@ -196,6 +196,7 @@
- (void)scrollAnnotationToVisible:(PDFAnnotation *)annotation;
- (void)scrollRect:(NSRect)rect inPageToVisible:(PDFPage *)page;
+- (void)scrollPageToVisible:(PDFPage *)page;
- (void)displayLineAtPoint:(NSPoint)point inPageAtIndex:(NSUInteger)pageIndex
showReadingBar:(BOOL)showBar;
- (void)takeSnapshot:(id)sender;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2009-09-07 00:34:38 UTC (rev 5700)
+++ trunk/SKPDFView.m 2009-09-07 10:08:39 UTC (rev 5701)
@@ -2230,6 +2230,16 @@
[[self documentView] scrollRectToVisible:rect];
}
+- (void)scrollPageToVisible:(PDFPage *)page {
+ NSRect ignored, rect = [page boundsForBox:[self displayBox]];
+ rect = [self convertRect:[self convertRect:rect fromPage:page]
toView:[self documentView]];
+ if ([[self currentPage] isEqual:page] == NO)
+ [self goToPage:page];
+ [[self documentView] scrollRectToVisible:rect];
+ NSDivideRect(rect, &rect, &ignored, 1.0, NSMaxYEdge);
+ [[self documentView] scrollRectToVisible:rect];
+}
+
- (void)scrollAnnotationToVisible:(PDFAnnotation *)annotation {
[self scrollRect:[annotation bounds] inPageToVisible:[annotation page]];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit