Revision: 4884
http://skim-app.svn.sourceforge.net/skim-app/?rev=4884&view=rev
Author: hofman
Date: 2008-10-27 22:55:27 +0000 (Mon, 27 Oct 2008)
Log Message:
-----------
Add an extra setting to match the zoom of the secondary PDF view to that of the
main PDF view. Use this by default.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.m
trunk/SKSecondaryPDFView.h
trunk/SKSecondaryPDFView.m
trunk/SKStringConstants.h
trunk/SKStringConstants.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKMainWindowController.m 2008-10-27 22:55:27 UTC (rev 4884)
@@ -2270,12 +2270,10 @@
[secondaryPdfView release];
[pdfSplitView addSubview:secondaryPdfEdgeView];
// Because of a PDFView bug, display properties can not be changed
before it is placed in a window
+ [secondaryPdfView setSynchronizedPDFView:pdfView];
[secondaryPdfView setBackgroundColor:[pdfView backgroundColor]];
[secondaryPdfView setDisplaysPageBreaks:NO];
- if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKSplitPDFCopiesZoomKey])
- [secondaryPdfView setScaleFactor:[pdfView scaleFactor]];
- else
- [secondaryPdfView setAutoScales:YES];
+ [secondaryPdfView setSynchronizeZoom:YES];
[secondaryPdfView setDocument:[pdfView document]];
} else {
[secondaryPdfEdgeView setFrame:frame2];
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKMainWindowController_UI.m 2008-10-27 22:55:27 UTC (rev 4884)
@@ -1407,9 +1407,6 @@
[zoomInActualOutButton setEnabled:fabsf([pdfView scaleFactor] - 1.0 ) >
0.01 forSegment:1];
[zoomInActualOutButton setEnabled:[pdfView canZoomIn] forSegment:2];
[zoomActualButton setEnabled:fabsf([pdfView scaleFactor] - 1.0 ) > 0.01];
-
- if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKSplitPDFCopiesZoomKey])
- [secondaryPdfView setScaleFactor:[pdfView scaleFactor]];
}
- (void)handleToolModeChangedNotification:(NSNotification *)notification {
Modified: trunk/SKSecondaryPDFView.h
===================================================================
--- trunk/SKSecondaryPDFView.h 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKSecondaryPDFView.h 2008-10-27 22:55:27 UTC (rev 4884)
@@ -43,22 +43,23 @@
@interface SKSecondaryPDFView : PDFView {
NSPopUpButton *scalePopUpButton;
NSPopUpButton *pagePopUpButton;
+ PDFView *synchronizedPDFView;
+ BOOL synchronizeZoom;
}
-- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag;
-- (void)setScaleFactor:(float)factor adjustPopup:(BOOL)flag;
+- (PDFView *)synchronizedPDFView;
+- (void)setSynchronizedPDFView:(PDFView *)newSynchronizedPDFView;
+
+- (BOOL)synchronizeZoom;
+- (void)setSynchronizeZoom:(BOOL)newSync;
+
- (void)scalePopUpAction:(id)sender;
- (void)pagePopUpAction:(id)sender;
+
- (NSScrollView *)scrollView;
- (void)setScrollerSize:(NSControlSize)controlSize;
-- (void)dragWithEvent:(NSEvent *)theEvent;
-- (void)reloadPagePopUpButton;
-- (void)handlePageChangedNotification:(NSNotification *)notification;
-- (void)handleDocumentDidUnlockNotification:(NSNotification *)notification;
+
- (void)setNeedsDisplayInRect:(NSRect)aRect ofPage:(PDFPage *)page;
- (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation
onPage:(PDFPage *)page;
-- (void)makePopUpButtons;
-- (void)reloadPagePopUpButton;
-
@end
Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKSecondaryPDFView.m 2008-10-27 22:55:27 UTC (rev 4884)
@@ -44,9 +44,28 @@
#import "SKStringConstants.h"
[EMAIL PROTECTED] SKSecondaryPDFView (SKPrivate)
+
+- (void)makePopUpButtons;
+- (void)reloadPagePopUpButton;
+
+- (void)setSynchronizeZoom:(BOOL)newSync adjustPopup:(BOOL)flag;
+- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag;
+- (void)setScaleFactor:(float)factor adjustPopup:(BOOL)flag;
+
+- (void)startObservingSynchronizedPDFView;
+- (void)stopObservingSynchronizedPDFView;
+
+- (void)handleSynchronizedScaleChangedNotification:(NSNotification
*)notification;
+- (void)handlePageChangedNotification:(NSNotification *)notification;
+- (void)handleDocumentDidUnlockNotification:(NSNotification *)notification;
+
[EMAIL PROTECTED]
+
@implementation SKSecondaryPDFView
/* For genstrings:
+ NSLocalizedStringFromTable(@"=", @"ZoomValues", @"Zoom popup entry")
NSLocalizedStringFromTable(@"Auto", @"ZoomValues", @"Zoom popup entry")
NSLocalizedStringFromTable(@"10%", @"ZoomValues", @"Zoom popup entry")
NSLocalizedStringFromTable(@"20%", @"ZoomValues", @"Zoom popup entry")
@@ -66,37 +85,42 @@
NSLocalizedStringFromTable(@"600%", @"ZoomValues", @"Zoom popup entry")
NSLocalizedStringFromTable(@"800%", @"ZoomValues", @"Zoom popup entry")
*/
-static NSString *SKDefaultScaleMenuLabels[] = {@"Auto", @"10%", @"20%",
@"25%", @"35%", @"50%", @"60%", @"71%", @"85%", @"100%", @"120%", @"141%",
@"170%", @"200%", @"300%", @"400%", @"600%", @"800%"};
-static float 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};
+static NSString *SKDefaultScaleMenuLabels[] = {@"=", @"Auto", @"10%", @"20%",
@"25%", @"35%", @"50%", @"60%", @"71%", @"85%", @"100%", @"120%", @"141%",
@"170%", @"200%", @"300%", @"400%", @"600%", @"800%"};
+static float SKDefaultScaleMenuFactors[] = {0.0, 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};
static float SKPopUpMenuFontSize = 11.0;
+- (void)commonInitialization {
+ scalePopUpButton = nil;
+ pagePopUpButton = nil;
+ synchronizedPDFView = nil;
+ synchronizeZoom = NO;
+
+ [self makePopUpButtons];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handlePageChangedNotification:)
+
name:PDFViewPageChangedNotification object:self];
+}
- (id)initWithFrame:(NSRect)frameRect {
if (self = [super initWithFrame:frameRect]) {
- scalePopUpButton = nil;
- pagePopUpButton = nil;
-
- [self makePopUpButtons];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handlePageChangedNotification:)
-
name:PDFViewPageChangedNotification object:self];
+ [self commonInitialization];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
- scalePopUpButton = nil;
- pagePopUpButton = nil;
-
- [self makePopUpButtons];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handlePageChangedNotification:)
-
name:PDFViewPageChangedNotification object:self];
+ [self commonInitialization];
}
return self;
}
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [synchronizedPDFView release];
+ [super dealloc];
+}
+
- (void)setDocument:(PDFDocument *)document {
if ([self document])
[[NSNotificationCenter defaultCenter] removeObserver:self
name:PDFViewPageChangedNotification object:[self document]];
@@ -167,7 +191,7 @@
[scrollView setHasHorizontalScroller:YES];
NSControlSize controlSize = [[scrollView horizontalScroller] controlSize];
- if (scalePopUpButton == nil && [[NSUserDefaults standardUserDefaults]
boolForKey:SKSplitPDFCopiesZoomKey] == NO) {
+ if (scalePopUpButton == nil) {
// create it
scalePopUpButton = [[BDSKHeaderPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
@@ -246,8 +270,10 @@
- (void)scalePopUpAction:(id)sender {
NSNumber *selectedFactorObject = [[sender selectedItem] representedObject];
- if(selectedFactorObject)
+ if (selectedFactorObject)
[self setScaleFactor:[selectedFactorObject floatValue] adjustPopup:NO];
+ else if ([sender indexOfSelectedItem] == 0)
+ [self setSynchronizeZoom:YES adjustPopup:NO];
else
[self setAutoScales:YES adjustPopup:NO];
}
@@ -256,33 +282,72 @@
[self goToPage:[[self document] pageAtIndex:[sender indexOfSelectedItem]]];
}
+- (PDFView *)synchronizedPDFView {
+ return synchronizedPDFView;
+}
+
+- (void)setSynchronizedPDFView:(PDFView *)newSynchronizedPDFView {
+ if (synchronizedPDFView != newSynchronizedPDFView) {
+ if ([self synchronizeZoom])
+ [self stopObservingSynchronizedPDFView];
+ [synchronizedPDFView release];
+ synchronizedPDFView = [newSynchronizedPDFView retain];
+ if ([self synchronizeZoom])
+ [self startObservingSynchronizedPDFView];
+ }
+}
+
+- (BOOL)synchronizeZoom {
+ return synchronizeZoom;
+}
+
+- (void)setSynchronizeZoom:(BOOL)newSync {
+ [self setSynchronizeZoom:newSync adjustPopup:YES];
+}
+
+- (void)setSynchronizeZoom:(BOOL)newSync adjustPopup:(BOOL)flag {
+ if (synchronizeZoom != newSync) {
+ synchronizeZoom = newSync;
+ if (newSync) {
+ [super setAutoScales:NO];
+ [self startObservingSynchronizedPDFView];
+ [super setScaleFactor:synchronizedPDFView ? [synchronizedPDFView
scaleFactor] : 1.0];
+ if (flag)
+ [scalePopUpButton selectItemAtIndex:0];
+ } else {
+ [self stopObservingSynchronizedPDFView];
+ [self setScaleFactor:[self scaleFactor]];
+ }
+ }
+}
+
- (void)setAutoScales:(BOOL)newAuto {
- if (scalePopUpButton)
+ if ([self synchronizeZoom])
+ [super setAutoScales:newAuto];
+ else
[self setAutoScales:newAuto adjustPopup:YES];
- else
- [super setAutoScales:newAuto];
}
- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag {
+ [self setSynchronizeZoom:NO adjustPopup:NO];
[super setAutoScales:newAuto];
if (newAuto && flag)
- [scalePopUpButton selectItemAtIndex:0];
+ [scalePopUpButton selectItemAtIndex:1];
}
- (void)setScaleFactor:(float)newScaleFactor {
- if (scalePopUpButton)
+ if ([self synchronizeZoom])
+ [super setScaleFactor:newScaleFactor];
+ else
[self setScaleFactor:newScaleFactor adjustPopup:YES];
- else
- [super setScaleFactor:newScaleFactor];
}
- (void)setScaleFactor:(float)newScaleFactor adjustPopup:(BOOL)flag {
-
if (flag) {
if (newScaleFactor < 0.01) {
newScaleFactor = 0.0;
} else {
- unsigned cnt = 1, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
+ unsigned cnt = 2, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
// We only work with some preset zoom values, so choose one of the
appropriate values
while (cnt < numberOfDefaultItems - 1 && newScaleFactor > 0.5 *
(SKDefaultScaleMenuFactors[cnt] + SKDefaultScaleMenuFactors[cnt + 1])) cnt++;
@@ -291,6 +356,7 @@
}
}
+ [self setSynchronizeZoom:NO adjustPopup:NO];
if (newScaleFactor < 0.01) {
[self setAutoScales:YES];
} else {
@@ -300,7 +366,10 @@
}
- (IBAction)zoomIn:(id)sender{
- int cnt = 1, numberOfDefaultItems = (sizeof(SKDefaultScaleMenuFactors) /
sizeof(float));
+ if ([self synchronizeZoom])
+ return;
+
+ int cnt = 2, numberOfDefaultItems = (sizeof(SKDefaultScaleMenuFactors) /
sizeof(float));
float scaleFactor = [self scaleFactor];
// We only work with some preset zoom values, so choose one of the
appropriate values (Fudge a little for floating point == to work)
@@ -311,34 +380,41 @@
}
- (IBAction)zoomOut:(id)sender{
- int cnt = 1, numberOfDefaultItems = (sizeof(SKDefaultScaleMenuFactors) /
sizeof(float));
+ if ([self synchronizeZoom])
+ return;
+
+ int cnt = 2, numberOfDefaultItems = (sizeof(SKDefaultScaleMenuFactors) /
sizeof(float));
float scaleFactor = [self scaleFactor];
// We only work with some preset zoom values, so choose one of the
appropriate values (Fudge a little for floating point == to work)
while (cnt < numberOfDefaultItems && scaleFactor * .99 >
SKDefaultScaleMenuFactors[cnt]) cnt++;
cnt--;
- while (cnt < 1) cnt++;
+ while (cnt < 2) cnt++;
[self setScaleFactor:SKDefaultScaleMenuFactors[cnt]];
}
- (BOOL)canZoomIn{
- if ([super canZoomIn] == NO)
+ if ([super canZoomIn] == NO || [self synchronizeZoom])
return NO;
- unsigned cnt = 1, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
+
+ unsigned cnt = 2, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
float scaleFactor = [self scaleFactor];
+
// We only work with some preset zoom values, so choose one of the
appropriate values (Fudge a little for floating point == to work)
while (cnt < numberOfDefaultItems && scaleFactor * .99 >
SKDefaultScaleMenuFactors[cnt]) cnt++;
return cnt < numberOfDefaultItems - 1;
}
- (BOOL)canZoomOut{
- if ([super canZoomOut] == NO)
+ if ([super canZoomOut] == NO || [self synchronizeZoom])
return NO;
- unsigned cnt = 1, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
+
+ unsigned cnt = 2, numberOfDefaultItems =
(sizeof(SKDefaultScaleMenuFactors) / sizeof(float));
float scaleFactor = [self scaleFactor];
+
// We only work with some preset zoom values, so choose one of the
appropriate values (Fudge a little for floating point == to work)
while (cnt < numberOfDefaultItems && scaleFactor * .99 >
SKDefaultScaleMenuFactors[cnt]) cnt++;
- return cnt > 1;
+ return cnt > 2;
}
@@ -359,11 +435,13 @@
}
- (NSMenu *)menuForEvent:(NSEvent *)theEvent {
- static NSSet *selectionActions = nil;
- if (selectionActions == nil)
- selectionActions = [[NSSet alloc]
initWithObjects:@"_searchInSpotlight:", @"_searchInGoogle:",
@"_searchInDictionary:", nil];
NSMenu *menu = [super menuForEvent:theEvent];
NSMenuItem *item;
+ NSSet *selectionActions = nil;
+ if ([self synchronizeZoom])
+ selectionActions = [NSSet setWithObjects:@"_searchInSpotlight:",
@"_searchInGoogle:", @"_searchInDictionary:", @"_setActualSize:",
@"_setAutoSize:", @"zoomIn:", @"zoomOut:", nil];
+ else
+ selectionActions = [NSSet setWithObjects:@"_searchInSpotlight:",
@"_searchInGoogle:", @"_searchInDictionary:", nil];
[self setCurrentSelection:nil];
while ([menu numberOfItems]) {
@@ -450,12 +528,6 @@
}
- (void)mouseDragged:(NSEvent *)theEvent {
- [self dragWithEvent:theEvent];
- // ??? PDFView's delayed layout seems to reset the cursor to an arrow
- [self performSelector:@selector(mouseMoved:) withObject:theEvent
afterDelay:0];
-}
-
-- (void)dragWithEvent:(NSEvent *)theEvent {
NSPoint initialLocation = [theEvent locationInWindow];
NSRect visibleRect = [[self documentView] visibleRect];
BOOL keepGoing = YES;
@@ -489,14 +561,32 @@
break;
} // end of switch (event type)
} // end of mouse-tracking loop
+ // ??? PDFView's delayed layout seems to reset the cursor to an arrow
+ [self performSelector:@selector(mouseMoved:) withObject:theEvent
afterDelay:0];
}
#pragma mark Notification handling
+- (void)startObservingSynchronizedPDFView {
+ if (synchronizedPDFView)
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleSynchronizedScaleChangedNotification:)
+
name:PDFViewScaleChangedNotification object:synchronizedPDFView];
+}
+
+- (void)stopObservingSynchronizedPDFView {
+ if (synchronizedPDFView)
+ [[NSNotificationCenter defaultCenter] removeObserver:self
name:PDFViewScaleChangedNotification object:synchronizedPDFView];
+}
+
- (void)handlePageChangedNotification:(NSNotification *)notification {
[pagePopUpButton selectItemAtIndex:[[self document] indexForPage:[self
currentPage]]];
}
+- (void)handleSynchronizedScaleChangedNotification:(NSNotification
*)notification {
+ if ([self synchronizeZoom])
+ [super setScaleFactor:[synchronizedPDFView scaleFactor]];
+}
+
- (void)handleDocumentDidUnlockNotification:(NSNotification *)notification {
[self reloadPagePopUpButton];
[[self scrollView] tile];
Modified: trunk/SKStringConstants.h
===================================================================
--- trunk/SKStringConstants.h 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKStringConstants.h 2008-10-27 22:55:27 UTC (rev 4884)
@@ -120,4 +120,3 @@
extern NSString *SKShouldSetCreatorCodeKey;
extern NSString *SKTableFontSizeKey;
extern NSString *SKSequentialPageNumberingKey;
-extern NSString *SKSplitPDFCopiesZoomKey;
Modified: trunk/SKStringConstants.m
===================================================================
--- trunk/SKStringConstants.m 2008-10-27 18:53:05 UTC (rev 4883)
+++ trunk/SKStringConstants.m 2008-10-27 22:55:27 UTC (rev 4884)
@@ -121,4 +121,3 @@
NSString *SKShouldSetCreatorCodeKey = @"SKShouldSetCreatorCode";
NSString *SKTableFontSizeKey = @"SKTableFontSize";
NSString *SKSequentialPageNumberingKey = @"SKSequentialPageNumbering";
-NSString *SKSplitPDFCopiesZoomKey = @"SKSplitPDFCopiesZoom";
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit