|
@@ -549,6 +549,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
}
|
|
|
|
|
|
[menu insertItem:[NSMenuItem separatorItem] atIndex:0];
|
|
|
+ NSMenuItem *itemPhysical = [menu insertItemWithTitle:NSLocalizedString(@"Physical Size", nil) action:@selector(zoomToPhysicalSize:) target:self atIndex:0];
|
|
|
+ [itemPhysical setKeyEquivalentModifierMask:NSAlternateKeyMask];
|
|
|
+ [itemPhysical setAlternate:YES];
|
|
|
[menu insertItem:actualSizeItem atIndex:0];
|
|
|
[menu insertItem:zoomOutItem atIndex:0];
|
|
|
[menu insertItem:zoomInItem atIndex:0];
|
|
@@ -880,6 +883,9 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
NSArray *pageAnnotationArray = page.annotations;
|
|
|
return ![annotation isEqual:pageAnnotationArray.firstObject];
|
|
|
}
|
|
|
+ } else if (action == @selector(zoomToPhysicalSize:)) {
|
|
|
+ [menuItem setState:([self autoScales] || fabs([self physicalScaleFactor] - 1.0 ) > 0.01) ? NSOffState : NSOnState];
|
|
|
+ return YES;
|
|
|
}
|
|
|
|
|
|
return [super validateMenuItem:menuItem];
|
|
@@ -4620,6 +4626,28 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
[self zoomToRect:selRect onPage:page];
|
|
|
}
|
|
|
|
|
|
+- (void)zoomToPhysicalSize:(id)sender {
|
|
|
+ [self setPhysicalScaleFactor:1.0];
|
|
|
+}
|
|
|
+
|
|
|
+static inline CGFloat physicalScaleFactorForView(NSView *view) {
|
|
|
+ NSScreen *screen = [[view window] screen];
|
|
|
+ NSDictionary *deviceDescription = [screen deviceDescription];
|
|
|
+ CGDirectDisplayID displayID = (CGDirectDisplayID)[[deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
|
|
+ CGSize physicalSize = CGDisplayScreenSize(displayID);
|
|
|
+ NSSize resolution = [[deviceDescription objectForKey:NSDeviceResolution] sizeValue];
|
|
|
+ CGFloat backingScaleFactor = [NSScreen instancesRespondToSelector: @selector(backingScaleFactor)] ? [screen backingScaleFactor] : 1.0;
|
|
|
+ return CGSizeEqualToSize(physicalSize, CGSizeZero) ? 1.0 : (physicalSize.width * resolution.width) / (CGDisplayPixelsWide(displayID) * backingScaleFactor * 25.4f);
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setPhysicalScaleFactor:(CGFloat)scale {
|
|
|
+ [self setScaleFactor:scale / physicalScaleFactorForView(self)];
|
|
|
+}
|
|
|
+
|
|
|
+- (CGFloat)physicalScaleFactor {
|
|
|
+ return [self scaleFactor] * physicalScaleFactorForView(self);
|
|
|
+}
|
|
|
+
|
|
|
- (IBAction)menuItemClick_FitPage:(id)sender {
|
|
|
CGFloat pageHeight = self.currentPage.size.height;
|
|
|
CGFloat pdfviewHeight = self.bounds.size.height;
|