Revision: 3784
http://skim-app.svn.sourceforge.net/skim-app/?rev=3784&view=rev
Author: hofman
Date: 2008-04-22 04:54:35 -0700 (Tue, 22 Apr 2008)
Log Message:
-----------
Add interaction mode to pdfview, for fullscreen and presentation mode. Hide
fullscreen navigation from API.
Modified Paths:
--------------
trunk/SKMainWindowController.m
trunk/SKPDFView.h
trunk/SKPDFView.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-04-22 11:53:56 UTC (rev 3783)
+++ trunk/SKMainWindowController.m 2008-04-22 11:54:35 UTC (rev 3784)
@@ -2679,7 +2679,7 @@
if ([fullScreenSetup count])
[self applyPDFSettings:fullScreenSetup];
- [pdfView enableNavigationActivatedAtBottom:[[NSUserDefaults
standardUserDefaults] boolForKey:SKActivateFullScreenNavigationAtBottomKey]
autohidesCursor:NO screen:screen];
+ [pdfView setInteractionMode:SKFullScreenMode screen:screen];
[self showSideWindowsOnScreen:screen];
}
@@ -2702,7 +2702,7 @@
else
[self goFullScreen];
- [pdfView enableNavigationActivatedAtBottom:[[NSUserDefaults
standardUserDefaults] boolForKey:SKActivatePresentationNavigationAtBottomKey]
autohidesCursor:YES screen:screen];
+ [pdfView setInteractionMode:SKPresentationMode screen:screen];
}
- (IBAction)exitFullScreen:(id)sender {
@@ -2714,7 +2714,7 @@
if ([[fullScreenWindow firstResponder] isDescendantOf:pdfView])
[fullScreenWindow makeFirstResponder:nil];
- [pdfView disableNavigation];
+ [pdfView setInteractionMode:SKNormalMode screen:[[self window] screen]];
[pdfView setFrame:[[pdfEdgeView contentView] bounds]];
[pdfEdgeView addSubview:pdfView]; // this should be done before
exitPresentationMode to get a smooth transition
Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h 2008-04-22 11:53:56 UTC (rev 3783)
+++ trunk/SKPDFView.h 2008-04-22 11:54:35 UTC (rev 3784)
@@ -81,16 +81,21 @@
SKLineNote
} SKNoteType;
+typedef enum _SKInteractionMode {
+ SKNormalMode,
+ SKFullScreenMode,
+ SKPresentationMode
+} SKInteractionMode;
+
@class SKReadingBar, SKTransitionController, SKTypeSelectHelper;
@interface SKPDFView : PDFView {
SKToolMode toolMode;
SKNoteType annotationMode;
+ SKInteractionMode interactionMode;
BOOL hideNotes;
- BOOL autohidesCursor;
- BOOL hasNavigation;
BOOL activateNavigationAtBottom;
NSTimer *autohideTimer;
SKNavigationWindow *navWindow;
@@ -128,6 +133,9 @@
- (SKNoteType)annotationMode;
- (void)setAnnotationMode:(SKNoteType)newAnnotationMode;
+- (SKInteractionMode)interactionMode;
+- (void)setInteractionMode:(SKInteractionMode)newInteractionMode
screen:(NSScreen *)screen;
+
- (PDFAnnotation *)activeAnnotation;
- (void)setActiveAnnotation:(PDFAnnotation *)newAnnotation;
@@ -174,9 +182,6 @@
- (void)takeSnapshot:(id)sender;
-- (void)enableNavigationActivatedAtBottom:(BOOL)atBottom
autohidesCursor:(BOOL)hideCursor screen:(NSScreen *)screen;
-- (void)disableNavigation;
-
- (void)setNeedsDisplayInRect:(NSRect)rect ofPage:(PDFPage *)page;
- (void)setNeedsDisplayForAnnotation:(PDFAnnotation *)annotation;
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-04-22 11:53:56 UTC (rev 3783)
+++ trunk/SKPDFView.m 2008-04-22 11:54:35 UTC (rev 3784)
@@ -118,6 +118,9 @@
- (void)transformCGContext:(CGContextRef)context forPage:(PDFPage *)page;
+- (void)enableNavigationForScreen:(NSScreen *)screen;
+- (void)disableNavigation;
+
- (void)autohideTimerFired:(NSTimer *)aTimer;
- (void)doAutohide:(BOOL)flag;
@@ -195,6 +198,7 @@
- (void)commonInitialization {
toolMode = [[NSUserDefaults standardUserDefaults]
integerForKey:SKLastToolModeKey];
annotationMode = [[NSUserDefaults standardUserDefaults]
integerForKey:SKLastAnnotationModeKey];
+ interactionMode = SKNormalMode;
transitionController = nil;
@@ -204,8 +208,6 @@
hideNotes = NO;
- autohidesCursor = NO;
- hasNavigation = NO;
autohideTimer = nil;
navWindow = nil;
@@ -500,6 +502,20 @@
}
}
+- (SKInteractionMode)interactionMode {
+ return interactionMode;
+}
+
+- (void)setInteractionMode:(SKInteractionMode)newInteractionMode
screen:(NSScreen *)screen {
+ if (interactionMode != newInteractionMode) {
+ interactionMode = newInteractionMode;
+ if (interactionMode == SKNormalMode)
+ [self disableNavigation];
+ else
+ [self enableNavigationForScreen:screen];
+ }
+}
+
- (PDFAnnotation *)activeAnnotation {
return activeAnnotation;
}
@@ -653,14 +669,14 @@
}
- (void)goToNextPage:(id)sender {
- if (hasNavigation && autohidesCursor && transitionController &&
[transitionController transitionStyle] != SKNoTransition && [self
canGoToNextPage])
+ if (interactionMode == SKPresentationMode && transitionController &&
[transitionController transitionStyle] != SKNoTransition && [self
canGoToNextPage])
[self animateTransitionForNextPage:YES];
else
[super goToNextPage:sender];
}
- (void)goToPreviousPage:(id)sender {
- if (hasNavigation && autohidesCursor && transitionController &&
[transitionController transitionStyle] != SKNoTransition && [self
canGoToPreviousPage])
+ if (interactionMode == SKPresentationMode && transitionController &&
[transitionController transitionStyle] != SKNoTransition && [self
canGoToPreviousPage])
[self animateTransitionForNextPage:NO];
else
[super goToPreviousPage:sender];
@@ -911,7 +927,7 @@
unichar eventChar = [characters length] > 0 ? [characters
characterAtIndex:0] : 0;
unsigned int modifiers = [theEvent modifierFlags] & (NSCommandKeyMask |
NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
- if (hasNavigation && autohidesCursor) {
+ if (interactionMode == SKPresentationMode) {
// Presentation mode
if ([[[self documentView] enclosingScrollView] hasHorizontalScroller]
== NO &&
(eventChar == NSRightArrowFunctionKey) && (modifiers == 0)) {
@@ -995,7 +1011,7 @@
if ([[self document] isLocked]) {
[super mouseDown:theEvent];
return;
- } else if (hasNavigation && autohidesCursor) {
+ } else if (interactionMode == SKPresentationMode) {
if ([self areaOfInterestForMouse:theEvent] & kPDFLinkArea) {
[super mouseDown:theEvent];
} else {
@@ -1144,7 +1160,7 @@
}
// in presentation mode only show the navigation window only by moving the
mouse to the bottom edge
- BOOL shouldShowNavWindow = hasNavigation && (activateNavigationAtBottom ==
NO || [theEvent locationInWindow].y < 5.0);
+ BOOL shouldShowNavWindow = (interactionMode != SKNormalMode) &&
(activateNavigationAtBottom == NO || [theEvent locationInWindow].y < 5.0);
if (activateNavigationAtBottom || shouldShowNavWindow) {
if (shouldShowNavWindow && [navWindow isVisible] == NO) {
[navWindow orderFront:self];
@@ -1173,10 +1189,10 @@
NSMenuItem *item;
// On Leopard the selection is automatically set. In some cases we never
want a selection though.
- if ((hasNavigation && autohidesCursor) || (toolMode != SKTextToolMode &&
[self currentSelection]))
+ if ((interactionMode == SKPresentationMode) || (toolMode != SKTextToolMode
&& [self currentSelection]))
[self setCurrentSelection:nil];
- if (hasNavigation && autohidesCursor)
+ if (interactionMode == SKPresentationMode)
return menu;
[menu insertItem:[NSMenuItem separatorItem] atIndex:0];
@@ -2158,38 +2174,6 @@
}
}
-#pragma mark FullScreen navigation and autohide
-
-- (void)handleWindowWillCloseNotification:(NSNotification *)notification {
- [navWindow orderOut:self];
-}
-
-- (void)enableNavigationActivatedAtBottom:(BOOL)activateAtBottom
autohidesCursor:(BOOL)hideCursor screen:(NSScreen *)screen {
- hasNavigation = YES;
- autohidesCursor = hideCursor;
- activateNavigationAtBottom = activateAtBottom;
-
- // always recreate the navWindow, since moving between screens of
different resolution can mess up the location (in spite of moveToScreen:)
- if (navWindow != nil)
- [navWindow release];
- else
- [[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleWindowWillCloseNotification:)
- name:
NSWindowWillCloseNotification object: [self window]];
- navWindow = [[SKNavigationWindow alloc] initWithPDFView:self];
- [navWindow moveToScreen:screen];
- [navWindow setLevel:[[self window] level] + 1];
-
- [self doAutohide:YES];
-}
-
-- (void)disableNavigation {
- hasNavigation = NO;
- autohidesCursor = NO;
- activateNavigationAtBottom = NO;
-
- [navWindow orderOut:self];
-}
-
#pragma mark Menu validation
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
@@ -2265,16 +2249,6 @@
}
}
-- (void)doAutohide:(BOOL)flag {
- if (autohideTimer) {
- [autohideTimer invalidate];
- [autohideTimer release];
- autohideTimer = nil;
- }
- if (flag)
- autohideTimer = [[NSTimer scheduledTimerWithTimeInterval:3.0
target:self selector:@selector(autohideTimerFired:) userInfo:nil repeats:NO]
retain];
-}
-
- (NSRect)visibleContentRect {
NSView *clipView = [[[self documentView] enclosingScrollView] contentView];
return [clipView convertRect:[clipView visibleRect] toView:self];
@@ -2298,17 +2272,53 @@
return range;
}
-#pragma mark Autohide timer
+#pragma mark FullScreen navigation and autohide
+- (void)handleWindowWillCloseNotification:(NSNotification *)notification {
+ [navWindow orderOut:self];
+}
+
+- (void)enableNavigationForScreen:(NSScreen *)screen {
+ activateNavigationAtBottom = [[NSUserDefaults standardUserDefaults]
boolForKey:interactionMode == SKPresentationMode ?
SKActivatePresentationNavigationAtBottomKey :
SKActivateFullScreenNavigationAtBottomKey];
+
+ // always recreate the navWindow, since moving between screens of
different resolution can mess up the location (in spite of moveToScreen:)
+ if (navWindow != nil)
+ [navWindow release];
+ else
+ [[NSNotificationCenter defaultCenter] addObserver: self selector:
@selector(handleWindowWillCloseNotification:)
+ name:
NSWindowWillCloseNotification object: [self window]];
+ navWindow = [[SKNavigationWindow alloc] initWithPDFView:self];
+ [navWindow moveToScreen:screen];
+ [navWindow setLevel:[[self window] level] + 1];
+
+ [self doAutohide:YES];
+}
+
+- (void)disableNavigation {
+ activateNavigationAtBottom = NO;
+
+ [navWindow orderOut:self];
+}
+
- (void)autohideTimerFired:(NSTimer *)aTimer {
if (NSPointInRect([NSEvent mouseLocation], [navWindow frame]))
return;
- if (autohidesCursor)
+ if (interactionMode == SKPresentationMode)
[NSCursor setHiddenUntilMouseMoves:YES];
- if (hasNavigation)
+ if (interactionMode != SKNormalMode)
[navWindow fadeOut];
}
+- (void)doAutohide:(BOOL)flag {
+ if (autohideTimer) {
+ [autohideTimer invalidate];
+ [autohideTimer release];
+ autohideTimer = nil;
+ }
+ if (flag)
+ autohideTimer = [[NSTimer scheduledTimerWithTimeInterval:3.0
target:self selector:@selector(autohideTimerFired:) userInfo:nil repeats:NO]
retain];
+}
+
#pragma mark Event handling
- (PDFDestination *)destinationForEvent:(NSEvent *)theEvent isLink:(BOOL
*)isLink {
@@ -3701,7 +3711,7 @@
NSCursor *cursor = nil;
if ([[self document] isLocked]) {
- } else if (hasNavigation && autohidesCursor) {
+ } else if (interactionMode == SKPresentationMode) {
if ([self areaOfInterestForMouse:theEvent] & kPDFLinkArea)
cursor = [NSCursor pointingHandCursor];
else
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 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit