Revision: 14814
          http://sourceforge.net/p/skim-app/code/14814
Author:   hofman
Date:     2024-12-10 17:05:36 +0000 (Tue, 10 Dec 2024)
Log Message:
-----------
Combine two methods to update display for reading bar changes

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

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2024-12-10 17:01:44 UTC (rev 14813)
+++ trunk/SKPDFView.m   2024-12-10 17:05:36 UTC (rev 14814)
@@ -195,8 +195,7 @@
 - (void)stopPacer;
 - (void)updatePacer;
 
-- (void)setNeedsDisplayForReadingBarBounds:(NSRect)rect onPage:(PDFPage *)page;
-- (void)setNeedsDisplayForReadingBar;
+- (void)setNeedsDisplay:(BOOL)needsDisplay forReadingBarBounds:(NSRect)rect 
onPage:(PDFPage *)page;
 
 - (void)doMoveCurrentAnnotationForKey:(unichar)eventChar 
byAmount:(CGFloat)delta;
 - (void)doResizeCurrentAnnotationForKey:(unichar)eventChar 
byAmount:(CGFloat)delta;
@@ -968,10 +967,7 @@
         userInfo = [NSDictionary dictionaryWithObjectsAndKeys:page, 
SKPDFViewNewPageKey, nil];
     }
     [self updatePacer];
-    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKReadingBarInvertKey])
-        [self setNeedsDisplayForReadingBar];
-    else
-        [self setNeedsDisplayForReadingBarBounds:bounds onPage:page];
+    [self setNeedsDisplay:[[NSUserDefaults standardUserDefaults] 
boolForKey:SKReadingBarInvertKey] forReadingBarBounds:bounds onPage:page];
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
 }
 
@@ -1012,9 +1008,9 @@
     }
     
     if (oldPage)
-        [self setNeedsDisplayForReadingBarBounds:oldBounds onPage:oldPage];
+        [self setNeedsDisplay:NO forReadingBarBounds:oldBounds onPage:oldPage];
     if (newPage)
-        [self setNeedsDisplayForReadingBarBounds:newBounds onPage:newPage];
+        [self setNeedsDisplay:NO forReadingBarBounds:newBounds onPage:newPage];
     
     NSDictionary *userInfo = newPage ? [NSDictionary 
dictionaryWithObjectsAndKeys:newPage, SKPDFViewNewPageKey, oldPage, 
SKPDFViewOldPageKey, nil] : [NSDictionary dictionaryWithObjectsAndKeys:oldPage, 
SKPDFViewOldPageKey, nil];
     [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
@@ -2854,15 +2850,15 @@
     [self updatedAnnotation:annotation forKey:nil fromValue:nil];
 }
 
-- (void)setNeedsDisplayForReadingBarBounds:(NSRect)rect onPage:(PDFPage *)page 
{
-    [self setNeedsDisplayInRect:[SKReadingBar bounds:rect forBox:[self 
displayBox] onPage:page] ofPage:page];
+- (void)setNeedsDisplay:(BOOL)needsDisplay forReadingBarBounds:(NSRect)rect 
onPage:(PDFPage *)page {
+    if (needsDisplay) {
+        [self setNeedsDisplay:YES];
+        [loupeController updateContents];
+    } else {
+        [self setNeedsDisplayInRect:[SKReadingBar bounds:rect forBox:[self 
displayBox] onPage:page] ofPage:page];
+    }
 }
 
-- (void)setNeedsDisplayForReadingBar {
-    [self setNeedsDisplay:YES];
-    [loupeController updateContents];
-}
-
 - (void)setNeedsDisplayInRect:(NSRect)rect ofPage:(PDFPage *)page {
     if ([self isPageAtIndexDisplayed:[page pageIndex]]) {
         rect = NSIntegralRect([self convertRect:NSInsetRect(rect, -1.0, -1.0) 
fromPage:page]);
@@ -2900,10 +2896,7 @@
             if ([self hasReadingBar] == NO) {
                 SKReadingBar *aReadingBar = [[SKReadingBar alloc] 
initWithPage:page line:line delegate:self];
                 [self setReadingBar:aReadingBar];
-                if (invert)
-                    [self setNeedsDisplayForReadingBar];
-                else
-                    [self setNeedsDisplayForReadingBarBounds:[readingBar 
currentBounds] onPage:[readingBar page]];
+                [self setNeedsDisplay:invert forReadingBarBounds:[readingBar 
currentBounds] onPage:[readingBar page]];
                 NSDictionary *userInfo = [NSDictionary 
dictionaryWithObjectsAndKeys:[readingBar page], SKPDFViewNewPageKey, nil];
                 [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification object:self 
userInfo:userInfo];
             } else {
@@ -3247,10 +3240,7 @@
         if ([keyPath isEqualToString:SKReadingBarColorKey] || [keyPath 
isEqualToString:SKReadingBarInvertKey]) {
             if (readingBar) {
                 PDFPage *page = [readingBar page];
-                if ([keyPath isEqualToString:SKReadingBarInvertKey] || 
[[NSUserDefaults standardUserDefaults] boolForKey:SKReadingBarInvertKey])
-                    [self setNeedsDisplayForReadingBar];
-                else
-                    [self setNeedsDisplayForReadingBarBounds:[readingBar 
currentBounds] onPage:page];
+                [self setNeedsDisplay:([keyPath 
isEqualToString:SKReadingBarInvertKey] || [[NSUserDefaults 
standardUserDefaults] boolForKey:SKReadingBarInvertKey]) 
forReadingBarBounds:[readingBar currentBounds] onPage:page];
                 [[NSNotificationCenter defaultCenter] 
postNotificationName:SKPDFViewReadingBarDidChangeNotification
                     object:self userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:page, SKPDFViewOldPageKey, page, 
SKPDFViewNewPageKey, nil]];
             }

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