Revision: 12905
          http://sourceforge.net/p/skim-app/code/12905
Author:   hofman
Date:     2022-05-09 17:09:04 +0000 (Mon, 09 May 2022)
Log Message:
-----------
take content insets from possible size view title bar into account for snapshot 
pdfview content

Modified Paths:
--------------
    trunk/SKSnapshotPDFView.h
    trunk/SKSnapshotPDFView.m
    trunk/SKSnapshotWindowController.m

Modified: trunk/SKSnapshotPDFView.h
===================================================================
--- trunk/SKSnapshotPDFView.h   2022-05-09 15:07:07 UTC (rev 12904)
+++ trunk/SKSnapshotPDFView.h   2022-05-09 17:09:04 UTC (rev 12905)
@@ -57,6 +57,7 @@
 
 @property (nonatomic) BOOL autoFits;
 @property (nonatomic) BOOL shouldAutoFit;
+@property (nonatomic, readonly) NSRect visibleContentRect;
 
 - (void)resetHistory;
 

Modified: trunk/SKSnapshotPDFView.m
===================================================================
--- trunk/SKSnapshotPDFView.m   2022-05-09 15:07:07 UTC (rev 12904)
+++ trunk/SKSnapshotPDFView.m   2022-05-09 17:09:04 UTC (rev 12905)
@@ -73,6 +73,7 @@
 @implementation SKSnapshotPDFView
 
 @synthesize autoFits, shouldAutoFit;
+@dynamic visibleContentRect;
 
 #define SKPDFContentViewChangedNotification 
@"SKPDFContentViewChangedNotification"
 
@@ -253,10 +254,17 @@
     [super setDelegate:newDelegate];
 }
 
+- (NSRect)visibleContentRect {
+    NSScrollView *scrollView = [self scrollView];
+    NSView *clipView = [scrollView contentView];
+    NSRect rect = [self convertRect:[clipView bounds] fromView:clipView];
+    rect.size.height -= [scrollView contentInsets].top;
+    return rect;
+}
+
 - (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification {
     if ([self autoFits]) {
-        NSView *clipView = [[self scrollView] contentView];
-        NSRect clipRect = [self convertRect:[clipView visibleRect] 
fromView:clipView];
+        NSRect clipRect = [self visibleContentRect];
         NSRect rect = [self convertRect:autoFitRect fromPage:autoFitPage];
         CGFloat factor = fmin(NSWidth(clipRect) / NSWidth(rect), 
NSHeight(clipRect) / NSHeight(rect));
         rect = [self convertRect:NSInsetRect(rect, 0.5 * (NSWidth(rect) - 
NSWidth(clipRect) / factor), 0.5 * (NSHeight(rect) - NSHeight(clipRect) / 
factor)) toPage:autoFitPage];
@@ -284,9 +292,8 @@
 
 - (void)resetAutoFitRectIfNeeded {
     if ([self autoFits]) {
-        NSView *clipView = [[self scrollView] contentView];
         autoFitPage = [self currentPage];
-        autoFitRect = [self convertRect:[self convertRect:[clipView 
visibleRect] fromView:clipView] toPage:autoFitPage];
+        autoFitRect = [self convertRect:[self visibleContentRect] 
toPage:autoFitPage];
     }
 }
 

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2022-05-09 15:07:07 UTC (rev 12904)
+++ trunk/SKSnapshotWindowController.m  2022-05-09 17:09:04 UTC (rev 12905)
@@ -167,8 +167,7 @@
 
 - (void)updateString {
     NSMutableString *mutableString = [NSMutableString string];
-    NSView *clipView = [[pdfView scrollView] contentView];
-    NSRect rect = [clipView convertRect:[clipView visibleRect] toView:pdfView];
+    NSRect rect = [pdfView visibleContentRect];
     
     for (PDFPage *page in [pdfView displayedPages]) {
         PDFSelection *sel = [page selectionForRect:[pdfView convertRect:rect 
toPage:page]];
@@ -376,8 +375,7 @@
 #pragma mark Acessors
 
 - (NSRect)bounds {
-    NSView *clipView = [[pdfView scrollView] contentView];
-    return [pdfView convertRect:[pdfView convertRect:[clipView bounds] 
fromView:clipView] toPage:[pdfView currentPage]];
+    return [pdfView convertRect:[pdfView visibleContentRect] toPage:[pdfView 
currentPage]];
 }
 
 - (NSUInteger)pageIndex {
@@ -480,9 +478,8 @@
 #pragma mark Thumbnails
 
 - (NSImage *)thumbnailWithSize:(CGFloat)size {
-    NSView *clipView = [[pdfView scrollView] contentView];
-    NSRect bounds = [pdfView convertRect:[clipView bounds] fromView:clipView];
-    NSBitmapImageRep *imageRep = [clipView 
bitmapImageRepCachingDisplayInRect:[clipView bounds]];
+    NSRect bounds = [pdfView visibleContentRect];
+    NSBitmapImageRep *imageRep = [pdfView 
bitmapImageRepCachingDisplayInRect:bounds];
     NSAffineTransform *transform = nil;
     NSSize thumbnailSize = thumbnailSize = bounds.size;
     CGFloat shadowBlurRadius = 0.0;
@@ -564,8 +561,7 @@
 #pragma mark Miniaturize / Deminiaturize
 
 - (NSRect)miniaturizedRectForDockingRect:(NSRect)dockRect {
-    NSView *clipView = [[pdfView scrollView] contentView];
-    NSRect sourceRect = [clipView convertRect:[clipView bounds] toView:nil];
+    NSRect sourceRect = [pdfView convertRect:[pdfView visibleContentRect] 
toView:nil];
     NSRect targetRect;
     NSSize windowSize = [[self window] frame].size;
     NSSize thumbSize = [thumbnail size];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to