Revision: 23996
          http://sourceforge.net/p/bibdesk/svn/23996
Author:   hofman
Date:     2019-07-11 12:58:59 +0000 (Thu, 11 Jul 2019)
Log Message:
-----------
Use status progress indicator style for (in)determinate rather than 
spinning/bar. Cover accessors for doubleValue. Automatically start/stop 
animation.

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m
    trunk/bibdesk/BDSKFindController.m
    trunk/bibdesk/BDSKStatusBar.h
    trunk/bibdesk/BDSKStatusBar.m
    trunk/bibdesk/BibDocument_DataSource.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2019-07-11 06:30:24 UTC (rev 23995)
+++ trunk/bibdesk/BDSKEditor.m  2019-07-11 12:58:59 UTC (rev 23996)
@@ -289,14 +289,12 @@
     for (BDSKItemDownload *download in [publication downloads]) {
         CGFloat progress = [download progress];
         if ([download index] == NSNotFound) {
-            [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorSpinningStyle];
             if (progress < 0.0) {
-                [[statusBar progressIndicator] setIndeterminate:YES];
+                [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleIndeterminate];
             } else {
-                [[statusBar progressIndicator] setIndeterminate:NO];
-                [[statusBar progressIndicator] setDoubleValue:progress];
+                [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleDeterminate];
+                [statusBar setProgressIndicatorValue:progress];
             }
-            [statusBar startAnimation:nil];
         } else {
             [fileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
         }
@@ -2582,15 +2580,14 @@
     if (index != NSNotFound) {
         [fileView updateProgressIndicator:progress forURL:[download URL] 
atIndex:index];
     } else {
-        if ([statusBar progressIndicatorStyle] != 
BDSKProgressIndicatorSpinningStyle) {
-            [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorSpinningStyle];
-            [statusBar startAnimation:nil];
-        }
+        BDSKProgressIndicatorStyle style = [statusBar progressIndicatorStyle];
         if (progress < 0.0) {
-            [[statusBar progressIndicator] setIndeterminate:YES];
+            if (style != BDSKProgressIndicatorStyleIndeterminate)
+                [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleIndeterminate];
         } else {
-            [[statusBar progressIndicator] setIndeterminate:NO];
-            [[statusBar progressIndicator] setDoubleValue:progress];
+            if (style != BDSKProgressIndicatorStyleDeterminate)
+                [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleDeterminate];
+            [statusBar setProgressIndicatorValue:progress];
         }
     }
 }
@@ -2601,8 +2598,7 @@
     if (index != NSNotFound) {
         [fileView removeProgressIndicatorForURL:[download URL] atIndex:index];
     } else {
-        [statusBar stopAnimation:nil];
-        [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorNone];
+        [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorStyleNone];
     }
 }
 

Modified: trunk/bibdesk/BDSKFindController.m
===================================================================
--- trunk/bibdesk/BDSKFindController.m  2019-07-11 06:30:24 UTC (rev 23995)
+++ trunk/bibdesk/BDSKFindController.m  2019-07-11 12:58:59 UTC (rev 23996)
@@ -827,8 +827,7 @@
         return;
        }
        
-    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorSpinningStyle];
-       [statusBar startAnimation:nil];
+    [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleIndeterminate];
 
     NSArray *publications;
     NSArray *shownPublications = [theDocument shownPublications];
@@ -843,8 +842,7 @@
     
        [self findAndReplaceInItems:publications ofDocument:theDocument];
        
-       [statusBar stopAnimation:nil];
-    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorNone];
+    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorStyleNone];
 }
 
 - (AGRegex *)currentRegex{

Modified: trunk/bibdesk/BDSKStatusBar.h
===================================================================
--- trunk/bibdesk/BDSKStatusBar.h       2019-07-11 06:30:24 UTC (rev 23995)
+++ trunk/bibdesk/BDSKStatusBar.h       2019-07-11 12:58:59 UTC (rev 23996)
@@ -39,9 +39,9 @@
 #import <Cocoa/Cocoa.h>
 
 typedef NS_ENUM(NSInteger, BDSKProgressIndicatorStyle) {
-   BDSKProgressIndicatorNone = -1,
-   BDSKProgressIndicatorBarStyle = NSProgressIndicatorBarStyle,
-   BDSKProgressIndicatorSpinningStyle = NSProgressIndicatorSpinningStyle
+   BDSKProgressIndicatorStyleNone = 0,
+   BDSKProgressIndicatorStyleIndeterminate = 1,
+   BDSKProgressIndicatorStyleDeterminate = 2
 };
 
 
@@ -87,20 +87,20 @@
 
 /*!
        @method progressIndicatorStyle
-       @abstract Returns whether the receiver is present and if it is, whether 
it is a bar indicator or spinning. 
+       @abstract Returns whether the receiver is present and if it is, whether 
it is indeterminate.
        @discussion -
 */
 - (BDSKProgressIndicatorStyle)progressIndicatorStyle;
 
 /*!
-       @method isVisible
-       @abstract Sets whetherthe receiver has an indicator, and if so whether 
to use a bar indicator or spinning. 
-       @discussion Use this rather than setStyle on the progressIndicator 
directly.
+       @method setProgressIndicatorStyle
+       @abstract Sets whetherthe receiver has an indicator, and if so whether 
to be indeterminate.
+       @discussion Use this rather than setStyle on the progressIndicator 
directly. Authomatically starts and stops the animation.
 */
 - (void)setProgressIndicatorStyle:(BDSKProgressIndicatorStyle)style;
 
-- (void)startAnimation:(id)sender;
-- (void)stopAnimation:(id)sender;
+- (double)progressIndicatorValue;
+- (void)setProgressIndicatorValue:(double)value;
 
 - (NSArray *)iconIdentifiers;
 - (void)addIcon:(NSImage *)icon withIdentifier:(NSString *)identifier;

Modified: trunk/bibdesk/BDSKStatusBar.m
===================================================================
--- trunk/bibdesk/BDSKStatusBar.m       2019-07-11 06:30:24 UTC (rev 23995)
+++ trunk/bibdesk/BDSKStatusBar.m       2019-07-11 12:58:59 UTC (rev 23996)
@@ -328,15 +328,16 @@
 
 - (BDSKProgressIndicatorStyle)progressIndicatorStyle {
        if (progressIndicator == nil)
-               return BDSKProgressIndicatorNone;
+               return BDSKProgressIndicatorStyleNone;
        else
-               return [progressIndicator style];
+        return [progressIndicator isIndeterminate] ? 
BDSKProgressIndicatorStyleIndeterminate : BDSKProgressIndicatorStyleDeterminate;
 }
 
 - (void)setProgressIndicatorStyle:(BDSKProgressIndicatorStyle)style {
-       if (style == BDSKProgressIndicatorNone) {
+       if (style == BDSKProgressIndicatorStyleNone) {
                if (progressIndicator == nil)
                        return;
+        [progressIndicator stopAnimation:nil];
                [progressIndicator removeFromSuperview];
                progressIndicator = nil;
        } else {
@@ -349,10 +350,10 @@
             [progressIndicator removeFromSuperview];
                }
         [progressIndicator setAutoresizingMask:NSViewMinXMargin | 
NSViewMinYMargin | NSViewMaxYMargin];
-               [progressIndicator setStyle:style];
+               [progressIndicator setStyle:NSProgressIndicatorSpinningStyle];
                [progressIndicator setControlSize:NSSmallControlSize];
         [progressIndicator setMaxValue:1.0];
-        [progressIndicator setIndeterminate:YES];
+        [progressIndicator setIndeterminate:style == 
BDSKProgressIndicatorStyleIndeterminate];
                [progressIndicator setDisplayedWhenStopped:NO];
                [progressIndicator sizeToFit];
                
@@ -364,17 +365,19 @@
                
         [self addSubview:progressIndicator];
                [progressIndicator release];
+        
+        [progressIndicator startAnimation:nil];
        }
        [self rebuildToolTips];
        [[self superview] setNeedsDisplayInRect:[self frame]];
 }
 
-- (void)startAnimation:(id)sender {
-       [progressIndicator startAnimation:sender];
+- (double)progressIndicatorValue {
+    return progressIndicator ? [progressIndicator doubleValue] : 0.0;
 }
 
-- (void)stopAnimation:(id)sender {
-       [progressIndicator stopAnimation:sender];
+- (void)setProgressIndicatorValue:(double)value {
+    [progressIndicator setDoubleValue:value];
 }
 
 #pragma mark Accessibility

Modified: trunk/bibdesk/BibDocument_DataSource.m
===================================================================
--- trunk/bibdesk/BibDocument_DataSource.m      2019-07-11 06:30:24 UTC (rev 
23995)
+++ trunk/bibdesk/BibDocument_DataSource.m      2019-07-11 12:58:59 UTC (rev 
23996)
@@ -1469,13 +1469,11 @@
 
 - (void)pasteboardHelperWillBeginGenerating:(BDSKItemPasteboardHelper *)helper{
     [self setStatus:[NSLocalizedString(@"Generating data. Please wait", 
@"Status message when generating drag/paste data") stringByAppendingEllipsis]];
-    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorSpinningStyle];
-    [statusBar startAnimation:nil];
+    [statusBar 
setProgressIndicatorStyle:BDSKProgressIndicatorStyleIndeterminate];
 }
 
 - (void)pasteboardHelperDidEndGenerating:(BDSKItemPasteboardHelper *)helper{
-    [statusBar stopAnimation:nil];
-    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorNone];
+    [statusBar setProgressIndicatorStyle:BDSKProgressIndicatorStyleNone];
     [self updateStatus];
 }
 

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to