Revision: 11402
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11402&view=rev
Author:   hofman
Date:     2007-10-28 04:13:24 -0700 (Sun, 28 Oct 2007)

Log Message:
-----------
Reverse gradients in Leopard. In fact, change the meaning of the NSBezierPath 
and CIImage categories to follow the more sensible Leopard ordering.

Modified Paths:
--------------
    trunk/bibdesk/BDSKFileMatcher.m
    trunk/bibdesk/BDSKGradientView.h
    trunk/bibdesk/BDSKGradientView.m
    trunk/bibdesk/BDSKMainTableView.m
    trunk/bibdesk/BDSKSplitView.m
    trunk/bibdesk/CIImage_BDSKExtensions.m

Modified: trunk/bibdesk/BDSKFileMatcher.m
===================================================================
--- trunk/bibdesk/BDSKFileMatcher.m     2007-10-27 18:42:50 UTC (rev 11401)
+++ trunk/bibdesk/BDSKFileMatcher.m     2007-10-28 11:13:24 UTC (rev 11402)
@@ -793,9 +793,9 @@
 
         NSBezierPath *p = [NSBezierPath bezierPathWithRect:[self 
rectOfRow:rowIndex]];
         if ([self isFlipped])
+            [p fillPathVerticallyWithStartColor:topColor endColor:bottomColor];
+        else
             [p fillPathVerticallyWithStartColor:bottomColor endColor:topColor];
-        else
-            [p fillPathVerticallyWithStartColor:topColor endColor:bottomColor];
     }
     [super drawRow:rowIndex clipRect:clipRect];
 }

Modified: trunk/bibdesk/BDSKGradientView.h
===================================================================
--- trunk/bibdesk/BDSKGradientView.h    2007-10-27 18:42:50 UTC (rev 11401)
+++ trunk/bibdesk/BDSKGradientView.h    2007-10-28 11:13:24 UTC (rev 11402)
@@ -42,8 +42,8 @@
 @interface BDSKGradientView : NSView
 {
     @private
-    CIColor *startColor;
-    CIColor *endColor;
+    CIColor *lowerColor;
+    CIColor *upperColor;
 }
 
 - (void)setLowerColor:(NSColor *)color;

Modified: trunk/bibdesk/BDSKGradientView.m
===================================================================
--- trunk/bibdesk/BDSKGradientView.m    2007-10-27 18:42:50 UTC (rev 11401)
+++ trunk/bibdesk/BDSKGradientView.m    2007-10-28 11:13:24 UTC (rev 11402)
@@ -57,32 +57,32 @@
 
 - (void)dealloc
 {
-    [endColor release];
-    [startColor release];
+    [lowerColor release];
+    [upperColor release];
     [super dealloc];
 }
 
 - (void)drawRect:(NSRect)aRect
 {
     // fill entire view, not just the (possibly clipped) aRect
-    [[NSBezierPath bezierPathWithRect:[self bounds]] 
fillPathVerticallyWithStartColor:[self upperColor] endColor:[self lowerColor]];
+    [[NSBezierPath bezierPathWithRect:[self bounds]] 
fillPathVerticallyWithStartColor:[self lowerColor] endColor:[self upperColor]];
 }
 
 // -[CIColor initWithColor:] fails (returns nil) with +[NSColor gridColor] 
rdar://problem/4789043
 - (void)setLowerColor:(NSColor *)color
 {
-    [endColor autorelease];
-    endColor = [[CIColor colorWithNSColor:color] retain];
+    [lowerColor autorelease];
+    lowerColor = [[CIColor colorWithNSColor:color] retain];
 }
 
 - (void)setUpperColor:(NSColor *)color
 {
-    [startColor autorelease];
-    startColor = [[CIColor colorWithNSColor:color] retain];
+    [upperColor autorelease];
+    upperColor = [[CIColor colorWithNSColor:color] retain];
 }    
 
-- (CIColor *)lowerColor { return endColor; }
-- (CIColor *)upperColor { return startColor; }
+- (CIColor *)lowerColor { return lowerColor; }
+- (CIColor *)upperColor { return upperColor; }
 
 // required in order for redisplay to work properly with the controls
 - (BOOL)isOpaque{  return YES; }

Modified: trunk/bibdesk/BDSKMainTableView.m
===================================================================
--- trunk/bibdesk/BDSKMainTableView.m   2007-10-27 18:42:50 UTC (rev 11401)
+++ trunk/bibdesk/BDSKMainTableView.m   2007-10-28 11:13:24 UTC (rev 11402)
@@ -629,8 +629,8 @@
 }
 
 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{
-    float startWhite = [self isHighlighted] ? 0.95 : 0.9;
-    float endWhite = [self isHighlighted] ? 0.9 : 1.0;
+    float startWhite = [self isHighlighted] ? 0.9 : 1.0;
+    float endWhite = [self isHighlighted] ? 0.95 : 0.9;
     float alpha = [self isEnabled] ? 1.0 : 0.6;
     NSRect rect = cellFrame;
     rect.size.height -= 1.0;

Modified: trunk/bibdesk/BDSKSplitView.m
===================================================================
--- trunk/bibdesk/BDSKSplitView.m       2007-10-27 18:42:50 UTC (rev 11401)
+++ trunk/bibdesk/BDSKSplitView.m       2007-10-28 11:13:24 UTC (rev 11402)
@@ -59,14 +59,14 @@
 + (CIColor *)startColor{
     static CIColor *startColor = nil;
     if (startColor == nil)
-        startColor = [[CIColor colorWithNSColor:[NSColor 
colorWithCalibratedWhite:0.85 alpha:1.0]] retain];
+        startColor = [[CIColor colorWithNSColor:[NSColor 
colorWithCalibratedWhite:0.95 alpha:1.0]] retain];
     return startColor;
 }
 
 + (CIColor *)endColor{
     static CIColor *endColor = nil;
     if (endColor == nil)
-        endColor = [[CIColor colorWithNSColor:[NSColor 
colorWithCalibratedWhite:0.95 alpha:1.0]] retain];
+        endColor = [[CIColor colorWithNSColor:[NSColor 
colorWithCalibratedWhite:0.85 alpha:1.0]] retain];
    return endColor;
 }
 
@@ -79,11 +79,12 @@
 
 - (void)drawBlendedJoinEndAtBottomInRect:(NSRect)rect {
     // this blends us smoothly with the status bar
+    // note that we are flipped, so we have to reverse the status bar colors
     [[NSBezierPath bezierPathWithRect:rect] 
fillPathWithHorizontalGradientFromColor:[[self class] startColor]
                                                                             
toColor:[[self class] endColor]
                                                                          
blendedAtTop:NO
-                                                        
ofVerticalGradientFromColor:[BDSKStatusBar lowerColor]
-                                                                            
toColor:[BDSKStatusBar upperColor]];
+                                                        
ofVerticalGradientFromColor:[BDSKStatusBar upperColor]
+                                                                            
toColor:[BDSKStatusBar lowerColor]];
 }
 
 - (void)drawDividerInRect:(NSRect)aRect {
@@ -96,7 +97,7 @@
             [self drawBlendedJoinEndAtBottomInRect:endRect];
         } else {
             NSDivideRect(aRect, &endRect, &ignored, END_JOIN_WIDTH, 
NSMinXEdge);
-            [[NSBezierPath bezierPathWithRect:endRect] 
fillPathVertically:[self isVertical] withStartColor:[CIColor clearColor] 
endColor:[[self class] startColor]];
+            [[NSBezierPath bezierPathWithRect:endRect] 
fillPathVertically:[self isVertical] withStartColor:[[self class] endColor] 
endColor:[CIColor clearColor]];
         }
     }
     // Draw dimple

Modified: trunk/bibdesk/CIImage_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/CIImage_BDSKExtensions.m      2007-10-27 18:42:50 UTC (rev 
11401)
+++ trunk/bibdesk/CIImage_BDSKExtensions.m      2007-10-28 11:13:24 UTC (rev 
11402)
@@ -41,6 +41,21 @@
 
 @implementation CIImage (BDSKExtensions)
 
+static NSString *startColorKey = nil;
+static NSString *endColorKey = nil;
+
++ (void)initialize {
+    OBINITIALIZE;
+    if (floor(NSAppKitVersionNumber) <= 824) {
+        // in Tiger the input colors are reversed
+        startColorKey = [@"inputColor1" retain];
+        endColorKey = [@"inputColor0" retain];
+    } else {
+        startColorKey = [@"inputColor0" retain];
+        endColorKey = [@"inputColor1" retain];
+    }
+}
+
 + (CIImage *)imageWithConstantColor:(CIColor *)color;
 {
     static CIFilter *colorFilter = nil;
@@ -58,8 +73,8 @@
     if (linearFilter == nil)
         linearFilter = [[CIFilter filterWithName:@"CILinearGradient"] retain]; 
   
     
-    [linearFilter setValue:startColor forKey:@"inputColor0"];
-    [linearFilter setValue:endColor forKey:@"inputColor1"];
+    [linearFilter setValue:startColor forKey:startColorKey];
+    [linearFilter setValue:endColor forKey:endColorKey];
     
     [linearFilter setValue:[CIVector vectorWithX:startPoint.x Y:startPoint.y] 
forKey:@"inputPoint0"];
     [linearFilter setValue:[CIVector vectorWithX:endPoint.x Y:endPoint.y] 
forKey:@"inputPoint1"];


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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to