Revision: 7521
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7521&view=rev
Author:   hofman
Date:     2011-10-20 22:12:24 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
add shadow to selected freehand notes so we can see which strokes are included

Modified Paths:
--------------
    trunk/PDFAnnotationInk_SKExtensions.m
    trunk/PDFAnnotation_SKExtensions.h
    trunk/PDFAnnotation_SKExtensions.m
    trunk/SKPDFView.m

Modified: trunk/PDFAnnotationInk_SKExtensions.m
===================================================================
--- trunk/PDFAnnotationInk_SKExtensions.m       2011-10-20 09:36:32 UTC (rev 
7520)
+++ trunk/PDFAnnotationInk_SKExtensions.m       2011-10-20 22:12:24 UTC (rev 
7521)
@@ -45,11 +45,32 @@
 #import "NSGeometry_SKExtensions.h"
 #import "NSData_SKExtensions.h"
 #import "NSBezierPath_SKExtensions.h"
+#import "SKRuntime.h"
 
 NSString *SKPDFAnnotationScriptingPointListsKey = @"scriptingPointLists";
 
 @implementation PDFAnnotationInk (SKExtensions)
 
+static void (*original_drawWithBox)(id, SEL, PDFDisplayBox) = NULL;
+
+- (void)replacement_drawWithBox:(PDFDisplayBox)box {
+    if ([PDFAnnotation currentActiveAnnotation] == self) {
+        [NSGraphicsContext saveGraphicsState];
+        NSShadow *shade = [[[NSShadow alloc] init] autorelease];
+        [shade setShadowBlurRadius:2.0];
+        [shade setShadowOffset:NSMakeSize(0.0, -2.0)];
+        [shade set];
+        original_drawWithBox(self, _cmd, box);
+        [NSGraphicsContext restoreGraphicsState];
+    } else {
+        original_drawWithBox(self, _cmd, box);
+    }
+}
+
++ (void)load {
+    original_drawWithBox = (void (*)(id, SEL, 
PDFDisplayBox))SKReplaceInstanceMethodImplementationFromSelector(self, 
@selector(drawWithBox:), @selector(replacement_drawWithBox:));
+}
+
 - (id)initSkimNoteWithBounds:(NSRect)bounds {   
     self = [super initSkimNoteWithBounds:bounds];
     if (self) {         

Modified: trunk/PDFAnnotation_SKExtensions.h
===================================================================
--- trunk/PDFAnnotation_SKExtensions.h  2011-10-20 09:36:32 UTC (rev 7520)
+++ trunk/PDFAnnotation_SKExtensions.h  2011-10-20 22:12:24 UTC (rev 7521)
@@ -45,9 +45,13 @@
 extern NSString *SKPDFAnnotationScriptingModificationDateKey;
 extern NSString *SKPDFAnnotationScriptingUserNameKey;
 
+@class SKPDFView;
 
 @interface PDFAnnotation (SKExtensions)
 
++ (PDFAnnotation *)currentActiveAnnotation;
++ (void)setCurrentActiveAnnotation:(PDFAnnotation *)annotation;
+
 - (NSString *)fdfString;
 
 - (PDFDestination *)destination;

Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m  2011-10-20 09:36:32 UTC (rev 7520)
+++ trunk/PDFAnnotation_SKExtensions.m  2011-10-20 22:12:24 UTC (rev 7521)
@@ -70,6 +70,19 @@
 
 @implementation PDFAnnotation (SKExtensions)
 
+static PDFAnnotation *currentActiveAnnotation = nil;
+
++ (PDFAnnotation *)currentActiveAnnotation {
+    return currentActiveAnnotation;
+}
+
++ (void)setCurrentActiveAnnotation:(PDFAnnotation *)annotation {
+    if (currentActiveAnnotation != annotation) {
+        [currentActiveAnnotation release];
+        currentActiveAnnotation = [annotation retain];
+    }
+}
+
 - (NSString *)fdfString {
     NSMutableString *fdfString = [NSMutableString string];
     NSRect bounds = [self bounds];

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2011-10-20 09:36:32 UTC (rev 7520)
+++ trunk/SKPDFView.m   2011-10-20 22:12:24 UTC (rev 7521)
@@ -345,13 +345,23 @@
         interpolation = NSImageInterpolationHigh;
     [[NSGraphicsContext currentContext] setImageInterpolation:interpolation];
     
+    [PDFAnnotation setCurrentActiveAnnotation:activeAnnotation];
+    
     // Let PDFView do most of the hard work.
     [super drawPage: pdfPage];
+    
+    [PDFAnnotation setCurrentActiveAnnotation:nil];
        
     [pdfPage transformContextForBox:[self displayBox]];
     
     if (bezierPath && pathPageIndex == [pdfPage pageIndex]) {
         [NSGraphicsContext saveGraphicsState];
+        if ([[activeAnnotation type] isEqualToString:SKNInkString]) {
+            NSShadow *shade = [[[NSShadow alloc] init] autorelease];
+            [shade setShadowBlurRadius:2.0];
+            [shade setShadowOffset:NSMakeSize(0.0, -2.0)];
+            [shade set];
+        }
         [pathColor setStroke];
         [bezierPath stroke];
         [NSGraphicsContext restoreGraphicsState];

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


------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn 
about Cisco certifications, training, and career opportunities. 
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to