Revision: 7808
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7808&view=rev
Author:   hofman
Date:     2012-11-30 10:58:19 +0000 (Fri, 30 Nov 2012)
Log Message:
-----------
Support for deleting notes using tablet erase device

Modified Paths:
--------------
    trunk/NSEvent_SKExtensions.h
    trunk/NSEvent_SKExtensions.m
    trunk/SKApplication.m
    trunk/SKPDFView.m

Modified: trunk/NSEvent_SKExtensions.h
===================================================================
--- trunk/NSEvent_SKExtensions.h        2012-11-29 18:00:31 UTC (rev 7807)
+++ trunk/NSEvent_SKExtensions.h        2012-11-30 10:58:19 UTC (rev 7808)
@@ -44,6 +44,9 @@
 - (NSUInteger)deviceIndependentModifierFlags;
 - (NSUInteger)standardModifierFlags;
 
++ (NSPointingDeviceType)currentPointingDeviceType;
++ 
(void)setCurrentPointingDeviceType:(NSPointingDeviceType)newCurrentPointingDeviceType;
+
 - (unichar)firstCharacter;
 
 - (NSPoint)locationInView:(NSView *)view;

Modified: trunk/NSEvent_SKExtensions.m
===================================================================
--- trunk/NSEvent_SKExtensions.m        2012-11-29 18:00:31 UTC (rev 7807)
+++ trunk/NSEvent_SKExtensions.m        2012-11-30 10:58:19 UTC (rev 7808)
@@ -42,6 +42,8 @@
 
 @implementation NSEvent (SKExtensions)
 
+static NSPointingDeviceType currentPointingDeviceType = 
NSUnknownPointingDevice;
+
 + (NSUInteger)standardModifierFlags {
     return [self modifierFlags] & SKStandardModifierFlagsMask;
 }
@@ -54,6 +56,14 @@
     return [self modifierFlags] & SKStandardModifierFlagsMask;
 }
 
++ (NSPointingDeviceType)currentPointingDeviceType {
+    return currentPointingDeviceType;
+}
+
++ 
(void)setCurrentPointingDeviceType:(NSPointingDeviceType)newCurrentPointingDeviceType
 {
+    currentPointingDeviceType = newCurrentPointingDeviceType;
+}
+
 - (unichar)firstCharacter {
     NSString *characters = [self charactersIgnoringModifiers];
     return [characters length] > 0 ? [characters characterAtIndex:0] : 0;

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2012-11-29 18:00:31 UTC (rev 7807)
+++ trunk/SKApplication.m       2012-11-30 10:58:19 UTC (rev 7808)
@@ -40,6 +40,7 @@
 #import "NSMenu_SKExtensions.h"
 #import "NSResponder_SKExtensions.h"
 #import "NSDocument_SKExtensions.h"
+#import "NSEvent_SKExtensions.h"
 
 NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
 
@@ -69,6 +70,8 @@
             [target remoteButtonPressed:anEvent];
             return;
         }
+    } else if ([anEvent type] == NSTabletProximity) {
+        [NSEvent setCurrentPointingDeviceType:[anEvent isEnteringProximity] ? 
[anEvent pointingDeviceType] : NSUnknownPointingDevice];
     }
     [super sendEvent:anEvent];
 }

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2012-11-29 18:00:31 UTC (rev 7807)
+++ trunk/SKPDFView.m   2012-11-30 10:58:19 UTC (rev 7808)
@@ -156,6 +156,7 @@
 - (void)doMagnifyWithEvent:(NSEvent *)theEvent;
 - (void)doDragWithEvent:(NSEvent *)theEvent;
 - (void)doDrawFreehandNoteWithEvent:(NSEvent *)theEvent;
+- (void)doEraseAnnotationsWithEvent:(NSEvent *)theEvent;
 - (void)doSelectWithEvent:(NSEvent *)theEvent;
 - (void)doSelectTextWithEvent:(NSEvent *)theEvent;
 - (void)doDragReadingBarWithEvent:(NSEvent *)theEvent;
@@ -1108,7 +1109,7 @@
     if ([[self document] isLocked]) {
         [super mouseDown:theEvent];
     } else if (interactionMode == SKPresentationMode) {
-        if (hideNotes == NO && ([theEvent subtype] == 
NSTabletProximityEventSubtype || [theEvent subtype] == 
NSTabletPointEventSubtype)) {
+        if (hideNotes == NO && ([theEvent subtype] == 
NSTabletProximityEventSubtype || [theEvent subtype] == 
NSTabletPointEventSubtype) && [NSEvent currentPointingDeviceType] == 
NSPenPointingDevice) {
             [self doDrawFreehandNoteWithEvent:theEvent];
             [self setActiveAnnotation:nil];
         } else if ([self areaOfInterestForMouse:theEvent] & kPDFLinkArea) {
@@ -1148,6 +1149,8 @@
         } else if (toolMode == SKMagnifyToolMode) {
             [self setCurrentSelection:nil];                
             [self doMagnifyWithEvent:theEvent];
+        } else if (hideNotes == NO && ([theEvent subtype] == 
NSTabletProximityEventSubtype || [theEvent subtype] == 
NSTabletPointEventSubtype) && [NSEvent currentPointingDeviceType] == 
NSEraserPointingDevice) {
+            [self doEraseAnnotationsWithEvent:theEvent];
         } else if ([self doSelectAnnotationWithEvent:theEvent 
hitAnnotation:&hitAnnotation]) {
             if ([activeAnnotation isLink]) {
                 [self doSelectLinkAnnotationWithEvent:theEvent];
@@ -3389,6 +3392,37 @@
     SKDESTROY(pathColor);
 }
 
+- (void)doEraseAnnotationsWithEvent:(NSEvent *)theEvent {
+    NSPoint mouseDownLoc = [theEvent locationInView:self];
+    PDFPage *page = [self pageForPoint:mouseDownLoc nearest:YES];
+    
+    NSArray *annotations;
+    NSInteger i;
+    NSPoint pagePoint;
+    
+    while (YES) {
+        theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | 
NSLeftMouseDraggedMask];
+        if ([theEvent type] == NSLeftMouseUp)
+            break;
+        
+        NSPoint mouseDownOnPage = [theEvent locationInView:self];
+        page = [self pageForPoint:mouseDownOnPage nearest:YES];
+        pagePoint = [self convertPoint:mouseDownOnPage toPage:page];
+        
+        annotations = [page annotations];
+        i = [annotations count];
+        
+        while (i-- > 0) {
+            PDFAnnotation *annotation = [annotations objectAtIndex:i];
+            if ([annotation isSkimNote] && [annotation hitTest:pagePoint] && 
(editField == nil || annotation != activeAnnotation)) {
+                [self removeAnnotation:annotation];
+                [[self documentUndoManager] 
setActionName:NSLocalizedString(@"Remove Note", @"Undo action name")];
+                break;
+            }
+        }
+    }
+}
+
 - (void)doDragWithEvent:(NSEvent *)theEvent {
        NSPoint initialLocation = [theEvent locationInWindow];
        NSRect visibleRect = [[self documentView] visibleRect];

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


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to