Revision: 7314 http://skim-app.svn.sourceforge.net/skim-app/?rev=7314&view=rev Author: hofman Date: 2011-07-03 10:10:58 +0000 (Sun, 03 Jul 2011)
Log Message: ----------- Validate physical scale menu item according to current physical scale Modified Paths: -------------- trunk/SKMainWindowController_UI.m trunk/SKPDFView.h trunk/SKPDFView.m trunk/SKSnapshotPDFView.h trunk/SKSnapshotPDFView.m trunk/SKSnapshotWindowController.m Modified: trunk/SKMainWindowController_UI.m =================================================================== --- trunk/SKMainWindowController_UI.m 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKMainWindowController_UI.m 2011-07-03 10:10:58 UTC (rev 7314) @@ -1459,7 +1459,7 @@ } else if (action == @selector(doZoomToActualSize:)) { return [[self pdfDocument] isLocked] == NO && fabs([pdfView scaleFactor] - 1.0 ) > 0.01; } else if (action == @selector(doZoomToPhysicalSize:)) { - return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO; + return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && fabs([pdfView physicalScaleFactor] - 1.0 ) > 0.01; } else if (action == @selector(doZoomToSelection:)) { return [self interactionMode] != SKPresentationMode && [[self pdfDocument] isLocked] == NO && NSIsEmptyRect([pdfView currentSelectionRect]) == NO; } else if (action == @selector(doZoomToFit:)) { Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKPDFView.h 2011-07-03 10:10:58 UTC (rev 7314) @@ -158,6 +158,7 @@ - (void)toggleAutoActualSize:(id)sender; - (void)exitFullScreen:(id)sender; +- (CGFloat)physicalScaleFactor; - (void)setPhysicalScaleFactor:(CGFloat)scale; - (void)addAnnotation:(id)sender; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKPDFView.m 2011-07-03 10:10:58 UTC (rev 7314) @@ -1016,6 +1016,18 @@ isZooming = NO; } +- (CGFloat)physicalScaleFactor { + CGFloat scale = [self scaleFactor]; + NSScreen *screen = [[self window] screen]; + CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + CGSize physicalSize = CGDisplayScreenSize(displayID); + NSSize resolution = [[[screen deviceDescription] objectForKey:NSDeviceResolution] sizeValue]; + + if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO) + scale *= (physicalSize.width * resolution.width) / (CGDisplayPixelsWide(displayID) * 25.4f); + return scale; +} + - (void)setPhysicalScaleFactor:(CGFloat)scale { NSScreen *screen = [[self window] screen]; CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; Modified: trunk/SKSnapshotPDFView.h =================================================================== --- trunk/SKSnapshotPDFView.h 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKSnapshotPDFView.h 2011-07-03 10:10:58 UTC (rev 7314) @@ -49,6 +49,7 @@ } @property (nonatomic) BOOL autoFits; +@property (nonatomic) CGFloat physicalScaleFactor; - (void)setAutoFits:(BOOL)newAuto adjustPopup:(BOOL)flag; - (void)setScaleFactor:(CGFloat)factor adjustPopup:(BOOL)flag; - (void)scalePopUpAction:(id)sender; Modified: trunk/SKSnapshotPDFView.m =================================================================== --- trunk/SKSnapshotPDFView.m 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKSnapshotPDFView.m 2011-07-03 10:10:58 UTC (rev 7314) @@ -51,7 +51,7 @@ @implementation SKSnapshotPDFView @synthesize autoFits, scalePopUpButton; -@dynamic scrollView; +@dynamic scrollView, physicalScaleFactor; static NSString *SKDefaultScaleMenuLabels[] = {@"Auto", @"10%", @"20%", @"25%", @"35%", @"50%", @"60%", @"71%", @"85%", @"100%", @"120%", @"141%", @"170%", @"200%", @"300%", @"400%", @"600%", @"800%"}; static CGFloat SKDefaultScaleMenuFactors[] = {0.0, 0.1, 0.2, 0.25, 0.35, 0.5, 0.6, 0.71, 0.85, 1.0, 1.2, 1.41, 1.7, 2.0, 3.0, 4.0, 6.0, 8.0}; @@ -272,6 +272,29 @@ - (void)setAutoScales:(BOOL)newAuto {} +- (CGFloat)physicalScaleFactor { + CGFloat scale = [self scaleFactor]; + NSScreen *screen = [[self window] screen]; + CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + CGSize physicalSize = CGDisplayScreenSize(displayID); + NSSize resolution = [[[screen deviceDescription] objectForKey:NSDeviceResolution] sizeValue]; + + if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO) + scale *= (physicalSize.width * resolution.width) / (CGDisplayPixelsWide(displayID) * 25.4f); + return scale; +} + +- (void)setPhysicalScaleFactor:(CGFloat)scale { + NSScreen *screen = [[self window] screen]; + CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + CGSize physicalSize = CGDisplayScreenSize(displayID); + NSSize resolution = [[[screen deviceDescription] objectForKey:NSDeviceResolution] sizeValue]; + + if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO) + scale *= CGDisplayPixelsWide(displayID) * 25.4f / (physicalSize.width * resolution.width); + [self setScaleFactor:scale]; +} + - (IBAction)zoomIn:(id)sender{ if([self autoFits]){ [super zoomIn:sender]; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2011-07-03 09:59:09 UTC (rev 7313) +++ trunk/SKSnapshotWindowController.m 2011-07-03 10:10:58 UTC (rev 7314) @@ -323,15 +323,7 @@ } - (IBAction)doZoomToPhysicalSize:(id)sender { - CGFloat scaleFactor = 1.0; - NSScreen *screen = [[self window] screen]; - CGDirectDisplayID displayID = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; - CGSize physicalSize = CGDisplayScreenSize(displayID); - NSSize resolution = [[[screen deviceDescription] objectForKey:NSDeviceResolution] sizeValue]; - - if (CGSizeEqualToSize(physicalSize, CGSizeZero) == NO) - scaleFactor = CGDisplayPixelsWide(displayID) * 25.4f / (physicalSize.width * resolution.width); - [pdfView setScaleFactor:scaleFactor]; + [pdfView setPhysicalScaleFactor:1.0]; } - (IBAction)doZoomToActualSize:(id)sender { @@ -351,7 +343,7 @@ } else if (action == @selector(doZoomToActualSize:)) { return fabs([pdfView scaleFactor] - 1.0 ) > 0.01; } else if (action == @selector(doZoomToPhysicalSize:)) { - return YES; + return fabs([pdfView physicalScaleFactor] - 1.0 ) > 0.01; } else if (action == @selector(toggleAutoScale:)) { [menuItem setState:[pdfView autoFits] ? NSOnState : NSOffState]; return YES; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2d-c2 _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit