Revision: 25445
          http://sourceforge.net/p/bibdesk/svn/25445
Author:   hofman
Date:     2021-01-19 17:02:40 +0000 (Tue, 19 Jan 2021)
Log Message:
-----------
different colors for slider track when it is narrow, also should work in dark 
mode

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m        2021-01-19 
16:03:34 UTC (rev 25444)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVSlider.m        2021-01-19 
17:02:40 UTC (rev 25445)
@@ -47,16 +47,12 @@
 
 - (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped
 {
-    [NSGraphicsContext saveGraphicsState];
-    
-    [[NSColor clearColor] setFill];
-    NSRectFill(aRect);
-    
     CGFloat radius = NSHeight(aRect) / 2;
     NSBezierPath *outerPath = [NSBezierPath bezierPathWithRoundedRect:aRect 
xRadius:radius yRadius:radius];
     CGFloat angle = flipped ? 90 : -90;
-    Class gradientClass = NSClassFromString(@"NSGradient");
     
+    [NSGraphicsContext saveGraphicsState];
+    
     [outerPath addClip];
     
     // @@ Dark mode
@@ -66,29 +62,19 @@
     [outerPath setLineWidth:1.5];
     [outerPath stroke];
     
-    // draw a dark background
-    if (gradientClass) {
-        id gradient = [[[gradientClass alloc] initWithStartingColor:[NSColor 
colorWithCalibratedWhite:0.4 alpha:0.6] endingColor:[NSColor 
colorWithCalibratedWhite:0.0 alpha:0.6]] autorelease];
-        [gradient drawInBezierPath:outerPath angle:angle];
-    } else {
-        [[NSColor colorWithCalibratedWhite:0.1 alpha:0.5] setFill];
-        [outerPath fill];
-    }
-    
     if (NSHeight(aRect) > 8.0) {
         
+        // draw a dark background
+        NSGradient *gradient = [[[NSGradient alloc] 
initWithStartingColor:[NSColor colorWithCalibratedWhite:0.4 alpha:0.6] 
endingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.6]] autorelease];
+        [gradient drawInBezierPath:outerPath angle:angle];
+        
         // draw the track
         NSRect track = NSInsetRect(aRect, 4.0, 4.0);
         radius = NSHeight(track) / 2;
         NSBezierPath *innerPath = [NSBezierPath 
bezierPathWithRoundedRect:track xRadius:radius yRadius:radius];
         [innerPath addClip];
-        if (gradientClass) {
-            id gradient = [[[gradientClass alloc] 
initWithStartingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.3] 
endingColor:[NSColor colorWithCalibratedWhite:0.3 alpha:0.3]] autorelease];
-            [gradient drawInBezierPath:innerPath angle:angle];
-        } else {
-            [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] setFill];
-            [innerPath fill];
-        }
+        gradient = [[[NSGradient alloc] initWithStartingColor:[NSColor 
colorWithCalibratedWhite:0.0 alpha:0.3] endingColor:[NSColor 
colorWithCalibratedWhite:0.3 alpha:0.3]] autorelease];
+        [gradient drawInBezierPath:innerPath angle:angle];
         
         // draw a dark outline for the track
         [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] setStroke];
@@ -96,6 +82,12 @@
         [innerPath stroke];
         [innerPath setLineWidth:1.0];
         
+    } else {
+        
+        // draw a dark background
+        NSGradient *gradient = [[[NSGradient alloc] 
initWithStartingColor:[NSColor colorWithCalibratedWhite:0.2 alpha:0.6] 
endingColor:[NSColor colorWithCalibratedWhite:0.3 alpha:0.6]] autorelease];
+        [gradient drawInBezierPath:outerPath angle:angle];
+        
     }
     
     // if we don't save/restore, the knob gets clipped

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to