Revision: 5524
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5524&view=rev
Author:   hofman
Date:     2009-08-09 13:51:44 +0000 (Sun, 09 Aug 2009)

Log Message:
-----------
allow the context for a PDF tooltip to be a page, in which case we show a 128px 
thumbnail

Modified Paths:
--------------
    trunk/SKMainWindowController_UI.m
    trunk/SKPDFToolTipWindow.h
    trunk/SKPDFToolTipWindow.m
    trunk/SKPDFView.m

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2009-08-08 12:59:10 UTC (rev 5523)
+++ trunk/SKMainWindowController_UI.m   2009-08-09 13:51:44 UTC (rev 5524)
@@ -132,7 +132,7 @@
                 break;
         }
         [annotation setDestination:[[[PDFDestination alloc] initWithPage:[dest 
page] atPoint:point] autorelease]];
-        [[SKPDFToolTipWindow sharedToolTipWindow] showForAnnotation:annotation 
atPoint:NSZeroPoint];
+        [[SKPDFToolTipWindow sharedToolTipWindow] showForPDFContext:annotation 
atPoint:NSZeroPoint];
     }
 }
 

Modified: trunk/SKPDFToolTipWindow.h
===================================================================
--- trunk/SKPDFToolTipWindow.h  2009-08-08 12:59:10 UTC (rev 5523)
+++ trunk/SKPDFToolTipWindow.h  2009-08-09 13:51:44 UTC (rev 5524)
@@ -39,20 +39,19 @@
 #import <Cocoa/Cocoa.h>
 #import "SKAnimatedBorderlessWindow.h"
 
-...@class PDFAnnotation;
 
 @interface SKPDFToolTipWindow : SKAnimatedBorderlessWindow {
     NSFont *font;
     NSColor *backgroundColor;
     NSFont *labelFont;
     NSColor *labelColor;
-    PDFAnnotation *annotation;
+    id context;
     NSPoint point;
 }
 
 + (id)sharedToolTipWindow;
 
-- (void)showForAnnotation:(PDFAnnotation *)annotation atPoint:(NSPoint)aPoint;
+- (void)showForPDFContext:(id)annotationOrPage atPoint:(NSPoint)aPoint;
 
 - (void)handleApplicationWillResignActiveNotification:(NSNotification 
*)notification;
 

Modified: trunk/SKPDFToolTipWindow.m
===================================================================
--- trunk/SKPDFToolTipWindow.m  2009-08-08 12:59:10 UTC (rev 5523)
+++ trunk/SKPDFToolTipWindow.m  2009-08-09 13:51:44 UTC (rev 5524)
@@ -97,7 +97,7 @@
         labelFont = [[NSFont boldSystemFontOfSize:11.0] retain];
         labelColor = [[NSColor colorWithCalibratedWhite:0.5 alpha:0.8] retain];
         
-        annotation = nil;
+        context = nil;
         point = NSZeroPoint;
         
         [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleApplicationWillResignActiveNotification:) 
@@ -176,8 +176,8 @@
 - (NSTimeInterval)autoHideTimeInterval { return AUTO_HIDE_TIME_INTERVAL; }
 
 - (void)willClose {
-    [annotation release];
-    annotation = nil;
+    [context release];
+    context = nil;
     point = NSZeroPoint;
 }
 
@@ -196,9 +196,13 @@
     
     [self cancelDelayedAnimations];
     
-    if ([annotation isLink]) {
+    if ([context isKindOfClass:[PDFPage class]]) {
         
-        PDFDestination *dest = [annotation destination];
+        image = [[context thumbnailWithSize:128.0 forBox:kPDFDisplayBoxCropBox 
shadowBlurRadius:0.0 shadowOffset:NSZeroSize readingBarRect:NSZeroRect] retain];
+        
+    } else if ([context isLink]) {
+        
+        PDFDestination *dest = [context destination];
         PDFPage *page = [dest page];
         
         if (page) {
@@ -272,13 +276,13 @@
             
         } else {
             
-            string = [[(PDFAnnotationLink *)annotation URL] absoluteString];
+            string = [[(PDFAnnotationLink *)context URL] absoluteString];
             
         }
         
     } else {
         
-        text = [annotation text];
+        text = [context text];
         string = [text string];
         NSUInteger i = 0, l = [string length];
         NSRange r = NSMakeRange(0, l);
@@ -299,8 +303,8 @@
         
         if ([text length] == 0) {
             text = nil;
-            if ([[annotation string] length])
-                string = [annotation string];
+            if ([[context string] length])
+                string = [context string];
         }
         // we release text later
         [text retain];
@@ -363,14 +367,14 @@
     [[self class] cancelPreviousPerformRequestsWithTarget:self 
selector:@selector(showDelayed) object:nil];
 }
 
-- (void)showForAnnotation:(PDFAnnotation *)note atPoint:(NSPoint)aPoint {
+- (void)showForPDFContext:(id)annotationOrPage atPoint:(NSPoint)aPoint {
     point = aPoint;
     
-    if ([note isEqual:annotation] == NO) {
+    if ([annotationOrPage isEqual:context] == NO) {
         [self stopAnimation];
         
-        [annotation release];
-        annotation = [note retain];
+        [context release];
+        context = [annotationOrPage retain];
         
         [self performSelector:@selector(showDelayed) withObject:nil 
afterDelay:[self isVisible] ? ALT_SHOW_DELAY : DEFAULT_SHOW_DELAY];
     }

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2009-08-08 12:59:10 UTC (rev 5523)
+++ trunk/SKPDFView.m   2009-08-09 13:51:44 UTC (rev 5524)
@@ -713,11 +713,13 @@
 
 - (void)animateTransitionForNextPage:(BOOL)next {
     NSUInteger idx = [[self currentPage] pageIndex];
-    BOOL shouldAnimate = [[[self currentPage] label] isEqualToString:[[[self 
document] pageAtIndex:next ? ++idx : --idx] label]] == NO;
+    BOOL shouldAnimate = [transitionController pageTransitions] || [[[self 
currentPage] label] isEqualToString:[[[self document] pageAtIndex:next ? ++idx 
: --idx] label]] == NO;
     NSRect rect;
     if (shouldAnimate) {
+        if (next == NO) idx--;
+        NSDictionary *info = idx < [[transitionController pageTransitions] 
count] ? [[transitionController pageTransitions] objectAtIndex:idx] : nil;
         rect = [self convertRect:[[self currentPage] boundsForBox:[self 
displayBox]] fromPage:[self currentPage]];
-        [[self transitionController] prepareAnimationForRect:rect];
+        [[self transitionController] prepareAnimation:info forRect:rect];
     }
     if (next)
         [super goToNextPage:self];
@@ -732,14 +734,16 @@
 }
 
 - (IBAction)goToNextPage:(id)sender {
-    if (interactionMode == SKPresentationMode && transitionController && 
[transitionController transitionStyle] != SKNoTransition && [self 
canGoToNextPage])
+    if (interactionMode == SKPresentationMode && [self canGoToNextPage] && 
transitionController &&
+        ([transitionController transitionStyle] != SKNoTransition || 
[transitionController pageTransitions]))
         [self animateTransitionForNextPage:YES];
     else
         [super goToNextPage:sender];
 }
 
 - (IBAction)goToPreviousPage:(id)sender {
-    if (interactionMode == SKPresentationMode && transitionController && 
[transitionController transitionStyle] != SKNoTransition && [self 
canGoToPreviousPage])
+    if (interactionMode == SKPresentationMode && [self canGoToPreviousPage] && 
transitionController &&
+        ([transitionController transitionStyle] != SKNoTransition || 
[transitionController pageTransitions]))
         [self animateTransitionForNextPage:NO];
     else
         [super goToPreviousPage:sender];
@@ -1499,7 +1503,7 @@
     if (trackingNumber == trackingRect) {
         [[self window] setAcceptsMouseMovedEvents:YES];
     } else if ([NSApp isActive] && -1 != 
CFArrayGetFirstIndexOfValue(PDFToolTipRects, CFRangeMake(0, 
CFArrayGetCount(PDFToolTipRects)), (void *)trackingNumber)) {
-        [[SKPDFToolTipWindow sharedToolTipWindow] 
showForAnnotation:(id)[theEvent userData] atPoint:NSZeroPoint];
+        [[SKPDFToolTipWindow sharedToolTipWindow] 
showForPDFContext:(id)[theEvent userData] atPoint:NSZeroPoint];
         PDFToolTipRect = trackingNumber;
     }
 }
@@ -1559,7 +1563,8 @@
 }
 
 - (void)swipeWithEvent:(NSEvent *)theEvent {
-    if (interactionMode == SKPresentationMode && transitionController && 
[transitionController transitionStyle] != SKNoTransition) {
+    if (interactionMode == SKPresentationMode && transitionController &&
+        ([transitionController transitionStyle] != SKNoTransition || 
[transitionController pageTransitions])) {
         if ([theEvent deltaX] < 0.0 || [theEvent deltaY] < 0.0) {
             if ([self canGoToNextPage])
                 [self goToNextPage:nil];
@@ -2225,7 +2230,7 @@
             NSPoint point = NSMakePoint(NSMinX(bounds) + 0.3 * 
NSWidth(bounds), NSMinY(bounds) + 0.3 * NSHeight(bounds));
             point = [self convertPoint:[self convertPoint:point 
fromPage:[annotation page]] toView:nil];
             point = [[self window] 
convertBaseToScreen:NSMakePoint(SKRound(point.x), SKRound(point.y))];
-            [[SKPDFToolTipWindow sharedToolTipWindow] 
showForAnnotation:annotation atPoint:point];
+            [[SKPDFToolTipWindow sharedToolTipWindow] 
showForPDFContext:annotation atPoint:point];
         } else {
             [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self];
         }
@@ -2274,7 +2279,7 @@
             NSPoint point = NSMakePoint(NSMinX(bounds) + 0.3 * 
NSWidth(bounds), NSMinY(bounds) + 0.3 * NSHeight(bounds));
             point = [self convertPoint:[self convertPoint:point 
fromPage:[annotation page]] toView:nil];
             point = [[self window] 
convertBaseToScreen:NSMakePoint(SKRound(point.x), SKRound(point.y))];
-            [[SKPDFToolTipWindow sharedToolTipWindow] 
showForAnnotation:annotation atPoint:point];
+            [[SKPDFToolTipWindow sharedToolTipWindow] 
showForPDFContext:annotation atPoint:point];
         } else {
             [[SKPDFToolTipWindow sharedToolTipWindow] orderOut:self];
         }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to