Revision: 14074
http://sourceforge.net/p/skim-app/code/14074
Author: hofman
Date: 2024-02-28 18:41:20 +0000 (Wed, 28 Feb 2024)
Log Message:
-----------
Override scrollPageUp: and scrollPageDown: because Apple scrolls by too much,
especially when the contentInset is set manually or the toolbar style is
expanded
Modified Paths:
--------------
trunk/SKBasePDFView.m
Modified: trunk/SKBasePDFView.m
===================================================================
--- trunk/SKBasePDFView.m 2024-02-27 22:17:58 UTC (rev 14073)
+++ trunk/SKBasePDFView.m 2024-02-28 18:41:20 UTC (rev 14074)
@@ -311,6 +311,54 @@
[super goToDestination:destination];
}
+- (void)scrollPageUp:(id)sender {
+ NSClipView *clipView = nil;
+ NSRect bounds = NSZeroRect;
+ CGFloat bottom = 0.0;
+
+ // Apple scrolls by too much, so correct for it
+ if (hasVerticalLayout(self)) {
+ clipView = [[self scrollView] contentView];
+ bounds = [clipView bounds];
+ NSView *docView = [self documentView];
+ bottom = NSMinY([docView convertRect:[docView bounds]
toView:clipView]);
+ }
+
+ // always call super, as it also updates the current page
+ [super scrollPageUp:sender];
+
+ // check whether our assumptions are still correct
+ if (clipView && [clipView isFlipped] == NO && NSMinY([clipView bounds]) <
NSMinY(bounds)) {
+ CGFloat height = NSHeight(bounds) - [clipView contentInsets].top;
+ bounds.origin.y = fmax(bottom, NSMinY(bounds) - height + 10.0);
+ [clipView scrollToPoint:bounds.origin];
+ }
+}
+
+- (void)scrollPageDown:(id)sender {
+ NSClipView *clipView = nil;
+ NSRect bounds = NSZeroRect;
+ CGFloat top = 0.0;
+
+ // Apple scrolls by too much, so correct for it
+ if (hasVerticalLayout(self)) {
+ clipView = [[self scrollView] contentView];
+ bounds = [clipView bounds];
+ NSView *docView = [self documentView];
+ top = NSMaxY([docView convertRect:[docView bounds] toView:clipView]);
+ }
+
+ // always call super, as it also updates the current page
+ [super scrollPageDown:sender];
+
+ // check whether our assumptions are still correct
+ if (clipView && [clipView isFlipped] == NO && NSMinY([clipView bounds]) >
NSMinY(bounds)) {
+ CGFloat height = NSHeight(bounds) - [clipView contentInsets].top;
+ bounds.origin.y = fmin(top - height, NSMinY(bounds) + height - 10.0);
+ [clipView scrollToPoint:bounds.origin];
+ }
+}
+
static inline CGRect SKPixelAlignedRect(CGRect rect, CGContextRef context) {
CGRect r;
rect = CGContextConvertRectToDeviceSpace(context, rect);
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