Revision: 12931
          http://sourceforge.net/p/skim-app/code/12931
Author:   hofman
Date:     2022-06-20 17:16:59 +0000 (Mon, 20 Jun 2022)
Log Message:
-----------
Remove reading bar when removing syncdot when it was added by syncing, but 
leave reading bar when the user already added or interacted with it in the UI.

Modified Paths:
--------------
    trunk/SKPDFView.m
    trunk/SKSyncDot.h
    trunk/SKSyncDot.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2022-06-19 23:07:50 UTC (rev 12930)
+++ trunk/SKPDFView.m   2022-06-20 17:16:59 UTC (rev 12931)
@@ -536,6 +536,7 @@
 - (void)setDocument:(PDFDocument *)document {
     SKDESTROY(rewindPage);
     
+    BOOL shouldHideReadingBar = [syncDot shouldHideReadingBar];
     [syncDot invalidate];
     [self setSyncDot:nil];
     
@@ -551,8 +552,10 @@
     NSInteger readingBarLine = -1;
     [self stopPacer];
     if ([self hasReadingBar]) {
-        readingBarPageIndex = [[readingBar page] pageIndex];
-        readingBarLine = [readingBar currentLine];
+        if (shouldHideReadingBar == NO) {
+            readingBarPageIndex = [[readingBar page] pageIndex];
+            readingBarLine = [readingBar currentLine];
+        }
         [self setReadingBar:nil];
     }
     
@@ -2930,6 +2933,7 @@
         NSRect rect = lineRect;
         NSRect visibleRect;
         BOOL wasPageDisplayed = [self isPageAtIndexDisplayed:pageIndex];
+        BOOL shouldHideReadingBar = NO;
         
         if (wasPageDisplayed == NO)
             [self goToPage:page];
@@ -2936,6 +2940,8 @@
         
         if (interactionMode != SKPresentationMode) {
             if (showBar) {
+                if ([self hasReadingBar] == NO || [syncDot 
shouldHideReadingBar])
+                    shouldHideReadingBar = YES;
                 [self stopPacer];
                 BOOL invert = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKReadingBarInvertKey];
                 PDFPage *oldPage = nil;
@@ -2985,9 +2991,13 @@
         [syncDot invalidate];
         [self setSyncDot:[[[SKSyncDot alloc] initWithPoint:point page:page 
updateHandler:^(BOOL finished){
                 [self setNeedsDisplayInRect:[syncDot bounds] ofPage:[syncDot 
page]];
-                if (finished)
-                    [self setSyncDot:nil];
+            if (finished) {
+                if ([syncDot shouldHideReadingBar] && [self hasReadingBar])
+                    [self toggleReadingBar];
+                [self setSyncDot:nil];
+            }
             }] autorelease]];
+        [syncDot setShouldHideReadingBar:shouldHideReadingBar];
     }
 }
 
@@ -3756,6 +3766,7 @@
         NSDictionary *userInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:oldPage, SKPDFViewOldPageKey, newPage, 
SKPDFViewNewPageKey, nil];
         [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
     }
+    [syncDot setShouldHideReadingBar:NO];
 }
 
 - (void)doResizeReadingBarForKey:(unichar)eventChar {
@@ -3773,6 +3784,7 @@
         [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self
             userInfo:[NSDictionary dictionaryWithObjectsAndKeys:page, 
SKPDFViewOldPageKey, page, SKPDFViewNewPageKey, nil]];
     }
+    [syncDot setShouldHideReadingBar:NO];
 }
 
 - (void)doMoveAnnotationWithEvent:(NSEvent *)theEvent offset:(NSPoint)offset {
@@ -4579,6 +4591,7 @@
     [NSEvent stopPeriodicEvents];
     
     [self updatePacer];
+    [syncDot setShouldHideReadingBar:NO];
     
     [NSCursor pop];
     // ??? PDFView's delayed layout seems to reset the cursor to an arrow
@@ -4615,6 +4628,8 @@
         }
     }
     
+    [syncDot setShouldHideReadingBar:NO];
+    
     [NSCursor pop];
     // ??? PDFView's delayed layout seems to reset the cursor to an arrow
     [self performSelector:@selector(setCursorForMouse:) withObject:theEvent 
afterDelay:0];

Modified: trunk/SKSyncDot.h
===================================================================
--- trunk/SKSyncDot.h   2022-06-19 23:07:50 UTC (rev 12930)
+++ trunk/SKSyncDot.h   2022-06-20 17:16:59 UTC (rev 12931)
@@ -48,11 +48,13 @@
     NSTimer *timer;
     volatile int32_t phase;
     SKSyncDotUpdateBlock handler;
+    BOOL shouldHideReadingBar;
 }
 
 @property (nonatomic, readonly) NSPoint point;
 @property (nonatomic, readonly) PDFPage *page;
 @property (nonatomic, readonly) NSRect bounds;
+@property (nonatomic) BOOL shouldHideReadingBar;
 
 - (id)initWithPoint:(NSPoint)aPoint page:(PDFPage *)aPage 
updateHandler:(SKSyncDotUpdateBlock)aHandler;
 

Modified: trunk/SKSyncDot.m
===================================================================
--- trunk/SKSyncDot.m   2022-06-19 23:07:50 UTC (rev 12930)
+++ trunk/SKSyncDot.m   2022-06-20 17:16:59 UTC (rev 12931)
@@ -50,7 +50,7 @@
 
 @implementation SKSyncDot
 
-@synthesize point, page;
+@synthesize point, page, shouldHideReadingBar;
 @dynamic bounds;
 
 - (id)initWithPoint:(NSPoint)aPoint page:(PDFPage *)aPage 
updateHandler:(SKSyncDotUpdateBlock)aHandler {

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



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to