Revision: 15245
http://sourceforge.net/p/skim-app/code/15245
Author: hofman
Date: 2025-05-21 09:10:14 +0000 (Wed, 21 May 2025)
Log Message:
-----------
Redisplay presentation when page bounds changes. Add some convenience method to
transform points in presentation view
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKPresentationView.h
trunk/SKPresentationView.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2025-05-21 08:49:31 UTC (rev 15244)
+++ trunk/SKMainWindowController.m 2025-05-21 09:10:14 UTC (rev 15245)
@@ -2157,6 +2157,9 @@
[secondaryPdfView setNeedsDisplay:YES];
+ if ([self interactionMode] == SKPresentationMode)
+ [presentationView setNeedsDisplayForPage:page];
+
if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKDisplayPageBoundsKey])
[self updateRightStatus];
Modified: trunk/SKPresentationView.h
===================================================================
--- trunk/SKPresentationView.h 2025-05-21 08:49:31 UTC (rev 15244)
+++ trunk/SKPresentationView.h 2025-05-21 09:10:14 UTC (rev 15245)
@@ -117,7 +117,7 @@
- (void)didOpen;
- (void)willClose;
-- (void)setNeedsDisplayForPage:(PDFPage *)aPage;
+- (void)setNeedsDisplayForPage:(nullable PDFPage *)aPage;
@end
Modified: trunk/SKPresentationView.m
===================================================================
--- trunk/SKPresentationView.m 2025-05-21 08:49:31 UTC (rev 15244)
+++ trunk/SKPresentationView.m 2025-05-21 09:10:14 UTC (rev 15245)
@@ -543,16 +543,66 @@
}
- (void)setNeedsDisplayForPage:(PDFPage *)aPage {
- [self removePredrawnImageAtIndex:[aPage pageIndex]];
- if (page == aPage) {
- [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(displayCurrentPage:) object:nil];
- [self performSelector:@selector(displayCurrentPage:) withObject:nil
afterDelay:0.0];
- } else if (page && [page pageIndex] + 1 == [aPage pageIndex]) {
- [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(predrawNextPage) object:nil];
- [self performSelector:@selector(predrawNextPage) withObject:nil
afterDelay:0.0];
+ if (page) {
+ [self removePredrawnImageAtIndex:aPage ? [aPage pageIndex] :
NSNotFound];
+ if (page == aPage || aPage == nil) {
+ [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(displayCurrentPage:) object:nil];
+ [self performSelector:@selector(displayCurrentPage:)
withObject:nil afterDelay:0.0];
+ } else if ([page pageIndex] + 1 == [aPage pageIndex]) {
+ [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(predrawNextPage) object:nil];
+ [self performSelector:@selector(predrawNextPage) withObject:nil
afterDelay:0.0];
+ }
}
}
+#pragma mark Transforms
+
+- (NSPoint)convertPointToPage:(NSPoint)point {
+ if (page == nil)
+ return point;
+
+ NSRect bounds = [self bounds];
+ NSRect pageBounds = [page boundsForBox:kPDFDisplayBoxCropBox];
+ CGFloat scale;
+ if (pvFlags.autoScales == NO)
+ scale = 1.0;
+ else if (([page rotation] % 180))
+ scale = fmin(NSHeight(bounds) / NSWidth(pageBounds), NSWidth(bounds) /
NSHeight(pageBounds));
+ else
+ scale = fmin(NSHeight(bounds) / NSHeight(pageBounds), NSWidth(bounds)
/ NSWidth(pageBounds));
+
+ NSAffineTransform *transform = [NSAffineTransform transform];
+ [transform translateXBy:NSMidX(pageBounds) yBy:NSMidY(pageBounds)];
+ [transform rotateByDegrees:[page rotation]];
+ [transform scaleBy:1.0 / scale];
+ [transform translateXBy:-NSMidX(bounds) yBy:-NSMidY(bounds)];
+
+ return [transform transformPoint:point];
+}
+
+- (NSPoint)convertPointFromPage:(NSPoint)point {
+ if (page == nil)
+ return point;
+
+ NSRect bounds = [self bounds];
+ NSRect pageBounds = [page boundsForBox:kPDFDisplayBoxCropBox];
+ CGFloat scale;
+ if (pvFlags.autoScales == NO)
+ scale = 1.0;
+ else if (([page rotation] % 180))
+ scale = fmin(NSHeight(bounds) / NSWidth(pageBounds), NSWidth(bounds) /
NSHeight(pageBounds));
+ else
+ scale = fmin(NSHeight(bounds) / NSHeight(pageBounds), NSWidth(bounds)
/ NSWidth(pageBounds));
+
+ NSAffineTransform *transform = [NSAffineTransform transform];
+ [transform translateXBy:NSMidX(bounds) yBy:NSMidY(bounds)];
+ [transform scaleBy:scale];
+ [transform rotateByDegrees:-[page rotation]];
+ [transform translateXBy:-NSMidX(pageBounds) yBy:-NSMidY(pageBounds)];
+
+ return [transform transformPoint:point];
+}
+
#pragma mark Accessors
- (BOOL)canBecomeKeyView {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit