Revision: 14801
          http://sourceforge.net/p/skim-app/code/14801
Author:   hofman
Date:     2024-12-09 15:52:27 +0000 (Mon, 09 Dec 2024)
Log Message:
-----------
explicitly try to notify update for some anchored note properties, as these do 
not use setValue:forAnnotationKey:, and therefore don't automaticaally pass on 
the update

Modified Paths:
--------------
    trunk/PDFView_SKExtensions.h
    trunk/PDFView_SKExtensions.m
    trunk/SKMainWindowController.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m

Modified: trunk/PDFView_SKExtensions.h
===================================================================
--- trunk/PDFView_SKExtensions.h        2024-12-09 14:55:07 UTC (rev 14800)
+++ trunk/PDFView_SKExtensions.h        2024-12-09 15:52:27 UTC (rev 14801)
@@ -38,6 +38,8 @@
 
 #import <Cocoa/Cocoa.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 extern const NSPoint SKUnspecifiedPoint;
 
 typedef struct _SKDestination {
@@ -45,6 +47,12 @@
     NSPoint point;
 } SKDestination;
 
+@protocol SKPDFPageView
+- (void)addAnnotation:(PDFAnnotation *)annotation;
+- (void)updateAnnotation:(PDFAnnotation *)annotation;
+- (void)removeAnnotation:(PDFAnnotation *)annotation;
+@end
+
 @interface PDFView (SKExtensions) <NSDraggingSource>
 
 @property (nonatomic) CGFloat physicalScaleFactor;
@@ -64,9 +72,9 @@
 - (void)doDragWithEvent:(NSEvent *)theEvent;
 - (BOOL)doDragTextWithEvent:(NSEvent *)theEvent;
 
-- (PDFPage *)pageAndPoint:(NSPoint *)point forEvent:(NSEvent *)event 
nearest:(BOOL)nearest;
+- (PDFPage *)pageAndPoint:(NSPoint * _Nullable)point forEvent:(NSEvent *)event 
nearest:(BOOL)nearest;
 
-- (SKDestination)currentDestinationRotated:(BOOL *)rotated;
+- (SKDestination)currentDestinationRotated:(BOOL * _Nullable)rotated;
 - (void)goToCurrentDestination:(SKDestination)destination;
 
 - (void)goToCurrentPage:(PDFPage *)page;
@@ -76,6 +84,8 @@
 @property (class, nonatomic, readonly) NSColor *defaultBackgroundColor;
 @property (class, nonatomic, readonly) NSColor 
*defaultFullScreenBackgroundColor;
 
+- (nullable NSView<SKPDFPageView> *)safePageViewForPage:(PDFPage *)page;
+
 @end
 
 
@@ -85,3 +95,5 @@
 - (BOOL)hasEnabledSwipeGestures;
 - (void)enableSwipeGestures:(BOOL)flag;
 @end
+
+NS_ASSUME_NONNULL_END

Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m        2024-12-09 14:55:07 UTC (rev 14800)
+++ trunk/PDFView_SKExtensions.m        2024-12-09 15:52:27 UTC (rev 14801)
@@ -58,12 +58,6 @@
 - (id)pageViewForPageAtIndex:(NSUInteger)index;
 @end
 
-@interface NSView (SKPrivatePageViewDeclarations)
-- (void)addAnnotation:(PDFAnnotation *)annotation;
-- (void)updateAnnotation:(PDFAnnotation *)annotation;
-- (void)removeAnnotation:(PDFAnnotation *)annotation;
-@end
-
 #define PAGE_BREAK_MARGIN 4.0
 
 @implementation PDFView (SKExtensions)
@@ -95,10 +89,10 @@
     return [self descendantOfClass:[NSScrollView class]];
 }
 
-- (NSView *)safePageViewForPage:(PDFPage *)page {
+- (NSView<SKPDFPageView> *)safePageViewForPage:(PDFPage *)page {
     if ([self respondsToSelector:@selector(pageViewForPageAtIndex:)] == NO)
         return nil;
-    NSView *pageView = [self pageViewForPageAtIndex:[page pageIndex]];
+    id pageView = [self pageViewForPageAtIndex:[page pageIndex]];
     if ([pageView respondsToSelector:@selector(addAnnotation:)] && [pageView 
respondsToSelector:@selector(updateAnnotation:)] && [pageView 
respondsToSelector:@selector(removeAnnotation:)])
         return pageView;
     return nil;
@@ -114,10 +108,7 @@
 }
 
 - (void)updatedAnnotation:(PDFAnnotation *)annotation {
-    PDFPage *page = [annotation page];
-    NSView *pageView = [self safePageViewForPage:page];
-    if (pageView)
-        [pageView updateAnnotation:annotation];
+    [[self safePageViewForPage:[annotation page]] updateAnnotation:annotation];
 }
 
 - (void)requiresDisplay {
@@ -125,15 +116,11 @@
 }
 
 - (void)addedAnnotation:(PDFAnnotation *)annotation onPage:(PDFPage *)page {
-    NSView *pageView = [self safePageViewForPage:page];
-    if (pageView)
-        [pageView addAnnotation:annotation];
+    [[self safePageViewForPage:page] addAnnotation:annotation];
 }
 
 - (void)removedAnnotation:(PDFAnnotation *)annotation onPage:(PDFPage *)page {
-    NSView *pageView = [self safePageViewForPage:page];
-    if (pageView)
-        [pageView removeAnnotation:annotation];
+    [[self safePageViewForPage:page] removeAnnotation:annotation];
 }
 
 - (void)doPdfsyncWithEvent:(NSEvent *)theEvent {

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-12-09 14:55:07 UTC (rev 14800)
+++ trunk/SKMainWindowController.m      2024-12-09 15:52:27 UTC (rev 14801)
@@ -2699,7 +2699,7 @@
                     }
                 }
                 
-                [pdfView updatedAnnotation:note affectingHighlight:([keyPath 
isEqualToString:SKNPDFAnnotationBoundsKey] || [keyPath 
isEqualToString:SKNPDFAnnotationDrawsImageKey]) fromRect:oldRect];
+                [pdfView updatedAnnotation:note forKey:keyPath 
fromRect:oldRect];
                 [secondaryPdfView updatedAnnotation:note];
                 
                 if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey]) {

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2024-12-09 14:55:07 UTC (rev 14800)
+++ trunk/SKPDFView.h   2024-12-09 15:52:27 UTC (rev 14801)
@@ -256,7 +256,7 @@
 
 - (void)undoManagerDidOpenOrCloseUndoGroup;
 
-- (void)updatedAnnotation:(PDFAnnotation *)annotation 
affectingHighlight:(BOOL)affectingHighlight fromRect:(NSRect)oldRect;
+- (void)updatedAnnotation:(PDFAnnotation *)annotation forKey:(nullable 
NSString *)key fromRect:(NSRect)oldRect;
 
 @end
 

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2024-12-09 14:55:07 UTC (rev 14800)
+++ trunk/SKPDFView.m   2024-12-09 15:52:27 UTC (rev 14801)
@@ -2834,8 +2834,11 @@
     [self goToRect:[annotation bounds] onPage:[annotation page]];
 }
 
-- (void)updatedAnnotation:(PDFAnnotation *)annotation 
affectingHighlight:(BOOL)affectingHighlight fromRect:(NSRect)oldRect {
-    if (affectingHighlight && annotation == currentAnnotation && 
atomic_load(&highlightLayerState) != SKLayerUse) {
+- (void)updatedAnnotation:(PDFAnnotation *)annotation forKey:(NSString *)key 
fromRect:(NSRect)oldRect {
+    BOOL updateHighlight = key == nil || [key 
isEqualToString:SKNPDFAnnotationBoundsKey] || [key 
isEqualToString:SKNPDFAnnotationDrawsImageKey];
+    if ([annotation isNote] && ([key isEqualToString:SKNPDFAnnotationImageKey] 
|| [key isEqualToString:SKNPDFAnnotationDrawsImageKey]))
+        [[self safePageViewForPage:[annotation page]] 
updateAnnotation:annotation];
+    if (updateHighlight && annotation == currentAnnotation && 
atomic_load(&highlightLayerState) != SKLayerUse) {
         PDFPage *page = [annotation page];
         CGFloat margin = (([annotation isResizable] || [annotation isNote]) ? 
HANDLE_SIZE  : 1.0) / [self scaleFactor];
         [self setNeedsDisplayInRect:NSInsetRect([annotation bounds], -margin, 
-margin) ofPage:page];
@@ -2847,7 +2850,7 @@
 }
 
 - (void)updatedAnnotation:(PDFAnnotation *)annotation {
-    [self updatedAnnotation:annotation affectingHighlight:YES 
fromRect:NSZeroRect];
+    [self updatedAnnotation:annotation forKey:nil fromRect:NSZeroRect];
 }
 
 - (void)setNeedsDisplayForReadingBarBounds:(NSRect)rect onPage:(PDFPage *)page 
{

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to