Changeset 356

Show
Ignore:
Timestamp:
04/07/07 16:59:42 (1 year ago)
Author:
cweider2
Message:

DarkKit Upgrade

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ILDAInspector/CTGradient.h

    r97 r356  
    22//  CTGradient.h 
    33// 
    4 //  Created by Chad Weider on 12/3/05
    5 //  Copyright (c) 2006 Cotingent. 
     4//  Created by Chad Weider on 2/14/07
     5//  Copyright (c) 2007 Cotingent. 
    66//  Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 
    77// 
    8 //  Version: 1.5 
     8//  Version: 1.6 
    99 
    1010#import <Cocoa/Cocoa.h> 
     
    6767- (void)radialFillRect:(NSRect)rect;                                                            //fills rect with radial gradient 
    6868                                                                                                                                        //  gradient from center outwards 
     69- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; 
     70- (void)radialFillBezierPath:(NSBezierPath *)path; 
     71 
    6972@end 
  • trunk/ILDAInspector/CTGradient.m

    r97 r356  
    22//  CTGradient.m 
    33// 
    4 //  Created by Chad Weider on 12/3/05
    5 //  Copyright (c) 2006 Cotingent. 
     4//  Created by Chad Weider on 2/14/07
     5//  Copyright (c) 2007 Cotingent. 
    66//  Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 
    77// 
    8 //  Version: 1.5 
     8//  Version: 1.6 
    99 
    1010#import "CTGradient.h" 
     
    2222 
    2323//C Fuctions for color blending 
    24 void linearEvaluation   (void *info, const float *in, float *out); 
    25 void chromaticEvaluation(void *info, const float *in, float *out); 
    26 void inverseChromaticEvaluation(void *info, const float *in, float *out); 
    27 void transformRGB_HSV(float *components); 
    28 void transformHSV_RGB(float *components); 
    29 void resolveHSV(float *color1, float *color2); 
     24static void linearEvaluation   (void *info, const float *in, float *out); 
     25static void chromaticEvaluation(void *info, const float *in, float *out); 
     26static void inverseChromaticEvaluation(void *info, const float *in, float *out); 
     27static void transformRGB_HSV(float *components); 
     28static void transformHSV_RGB(float *components); 
     29static void resolveHSV(float *color1, float *color2); 
    3030 
    3131 
     
    3636  self = [super init]; 
    3737   
    38   if (self != nil) 
     38  if(self != nil) 
    3939        { 
    4040        [self _commonInit]; 
     
    127127  return self; 
    128128  } 
    129  
    130  
    131129#pragma mark - 
    132130 
     
    602600        { 
    603601        case CTLinearBlendingMode: 
    604                  linearEvaluation(&elementList, &position, components);                 break; 
     602                 linearEvaluation(&elementList, &position, components);                        break; 
    605603        case CTChromaticBlendingMode: 
    606604                 chromaticEvaluation(&elementList, &position, components);                      break; 
     
    693691                CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 
    694692          #endif 
    695            
    696693          CGShadingRef myCGShading = CGShadingCreateAxial(colorspace, startPoint, endPoint, gradientFunction, false, false); 
    697694           
    698           CGContextClipToRect(currentContext , *(CGRect *)&rect);     //This is where the action happens 
     695          CGContextClipToRect (currentContext, *(CGRect *)&rect);     //This is where the action happens 
    699696          CGContextDrawShading(currentContext, myCGShading); 
    700697           
    701           CGShadingRelease   (myCGShading); 
     698          CGShadingRelease(myCGShading); 
    702699          CGColorSpaceRelease(colorspace ); 
    703700  CGContextRestoreGState(currentContext); 
     
    706703- (void)radialFillRect:(NSRect)rect 
    707704  { 
    708   CGPoint startPoint , endPoint; 
     705  CGPoint startPoint, endPoint; 
    709706  float startRadius, endRadius; 
     707  float scalex, scaley, transx, transy; 
    710708   
    711709  startPoint = endPoint = CGPointMake(NSMidX(rect), NSMidY(rect)); 
    712710   
    713   startRadius = 1; 
    714    
     711  startRadius = -1; 
    715712  if(NSHeight(rect)>NSWidth(rect)) 
     713        { 
     714        scalex = NSWidth(rect)/NSHeight(rect); 
     715        transx = (NSHeight(rect)-NSWidth(rect))/2; 
     716        scaley = 1; 
     717        transy = 1; 
    716718        endRadius = NSHeight(rect)/2; 
     719        } 
    717720  else 
     721        { 
     722        scalex = 1; 
     723        transx = 1; 
     724        scaley = NSHeight(rect)/NSWidth(rect); 
     725        transy = (NSWidth(rect)-NSHeight(rect))/2; 
    718726        endRadius = NSWidth(rect)/2; 
    719  
     727        } 
     728   
    720729  //Calls to CoreGraphics 
    721730  CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; 
     
    726735                CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 
    727736          #endif 
    728  
    729           CGShadingRef myCGShading = CGShadingCreateRadial(colorspace, startPoint, startRadius, endPoint, endRadius, gradientFunction, true, true); 
     737          CGShadingRef myCGShading = CGShadingCreateRadial(colorspace, startPoint, startRadius, endPoint, endRadius, gradientFunction, true, true); 
     738 
     739          CGContextClipToRect  (currentContext, *(CGRect *)&rect); 
     740          CGContextScaleCTM    (currentContext, scalex, scaley); 
     741          CGContextTranslateCTM(currentContext, transx, transy); 
     742          CGContextDrawShading (currentContext, myCGShading);           //This is where the action happens 
    730743           
    731           CGContextClipToRect (currentContext , *(CGRect *)&rect); 
    732           CGContextDrawShading(currentContext , myCGShading);           //This is where the action happens 
    733            
    734           CGShadingRelease    (myCGShading); 
    735           CGColorSpaceRelease (colorspace); 
     744          CGShadingRelease(myCGShading); 
     745          CGColorSpaceRelease(colorspace); 
    736746  CGContextRestoreGState(currentContext); 
    737747  } 
    738748 
     749- (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle 
     750  { 
     751  NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; 
     752  [currentContext saveGraphicsState]; 
     753        NSAffineTransform *transform = [[NSAffineTransform alloc] init]; 
     754         
     755        [transform rotateByDegrees:-angle]; 
     756        [path transformUsingAffineTransform:transform]; 
     757        [transform invert]; 
     758        [transform concat]; 
     759         
     760        [path addClip]; 
     761        [self fillRect:[path bounds] angle:0]; 
     762        [path transformUsingAffineTransform:transform]; 
     763        [transform release]; 
     764  [currentContext restoreGraphicsState]; 
     765  } 
     766- (void)radialFillBezierPath:(NSBezierPath *)path 
     767  { 
     768  NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; 
     769  [currentContext saveGraphicsState]; 
     770        [path addClip]; 
     771        [self radialFillRect:[path bounds]]; 
     772  [currentContext restoreGraphicsState]; 
     773  } 
    739774#pragma mark - 
    740775 
     
    774809 
    775810- (void)addElement:(CTGradientElement *)newElement 
    776 
     811 
    777812  if(elementList == nil || newElement->position < elementList->position)        //inserting at beginning of list 
    778813        { 
     
    11481183 
    11491184 
    1150  
    1151  
    1152  
    1153  
    1154  
    1155  
    1156  
    11571185void transformRGB_HSV(float *components) //H,S,B -> R,G,B 
    11581186        { 
  • trunk/ILDAInspector/DarkKit/DKSlider.m

    r97 r356  
    1717  } 
    1818 
     19 
     20 
    1921@end 
  • trunk/ILDAInspector/DarkKit/DKSliderCell.m

    r99 r356  
    1212 
    1313@implementation DKSliderCell 
    14 /* the calculations below are based on a 21 pixel high CustomView, if this gets palettized things will need to be revisited to support normal, small and mini sizes (though I think that normal should be excluded) */ 
    15  
    1614- (void)drawKnob:(NSRect)knobRect 
    1715  { 
    18         float offX, offY, knobWidth; 
    19         float curveRadius = 1.5; 
    20         offX = floorf(knobRect.size.width/4)+.5; 
    21         offY = floorf(knobRect.size.height/4)+.5; 
    22         knobWidth = floorf([self knobThickness]/2); 
    23         NSBezierPath *knobPath = [NSBezierPath bezierPath]; 
    24         [knobPath moveToPoint: NSMakePoint(NSMinX(knobRect)+offX+curveRadius, NSMinY(knobRect)+offY)]; 
    25         [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobWidth+offX-curveRadius, NSMinY(knobRect)+offY)]; 
    26         [knobPath appendBezierPathWithArcFromPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+offX, NSMinY(knobRect)+offY) toPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+offX, NSMinY(knobRect)+offY+curveRadius) radius:curveRadius]; 
    27         [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobWidth+offX, NSMinY(knobRect)+6.5+offY)]; 
    28         [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+(knobWidth/2)+offX, NSMinY(knobRect)+11+offY)]; 
    29         [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+offX, NSMinY(knobRect)+6.5+offY)]; 
    30         [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+offX, NSMinY(knobRect)+offY+curveRadius)]; 
    31         [knobPath appendBezierPathWithArcFromPoint:NSMakePoint(NSMinX(knobRect)+offX, NSMinY(knobRect)+offY) toPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+offX+curveRadius, NSMinY(knobRect)+offY) radius:curveRadius]; 
     16  NSBezierPath *knobPath = [[NSBezierPath alloc] init]; 
     17   
     18  if([self numberOfTickMarks] == 0) 
     19        { 
     20        float knobPad; 
    3221         
     22        switch([self controlSize]) 
     23                { 
     24                case NSRegularControlSize: 
     25                        knobPad = 3.5;  break; 
     26                case NSSmallControlSize: 
     27                        knobPad = 1.5;  break; 
     28                case NSMiniControlSize: 
     29                        knobPad = 1.75; break; 
     30                default: 
     31                        knobPad = 1; 
     32                } 
    3333         
    34         // fill 
    35         NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; 
    36         [currentContext saveGraphicsState]; 
     34        knobRect.origin.x = floor(knobRect.origin.x) + .5; 
     35        [knobPath appendBezierPathWithOvalInRect:NSInsetRect(knobRect, knobPad, knobPad)]; 
     36        } 
     37  else 
     38        { 
     39        float curveRadius; 
     40        float knobXPad,  knobYPad; 
     41        float knobWidth, knobHeight; 
    3742         
    38         [knobPath addClip]; 
    39         NSColor *startColor = [NSColor colorWithCalibratedHue:0.6026 saturation:0.0812 brightness:0.6275 alpha:1.0]; 
    40         NSColor *endColor = [NSColor colorWithCalibratedHue:0.6310 saturation:0.1273 brightness:0.15 alpha:1.0]; 
    41         CTGradient *backgroundGradient = [CTGradient gradientWithBeginningColor:startColor endingColor:endColor]; 
     43        switch([self controlSize]) 
     44                { 
     45                case NSRegularControlSize: 
     46                        knobXPad = 2; 
     47                        knobYPad = 1.5; 
     48                        knobHeight = 10; 
     49                        curveRadius = 2.5;                              break; 
     50                case NSSmallControlSize: 
     51                        knobXPad = .5; 
     52                        knobYPad = .5; 
     53                        knobHeight = 7; 
     54                        curveRadius = 2;                                break; 
     55                case NSMiniControlSize: 
     56                        knobXPad = .5; 
     57                        knobYPad = .5; 
     58                        knobHeight = 7; 
     59                        curveRadius = 1.5;                              break; 
     60                default: 
     61                        curveRadius = 1.5; 
     62                } 
    4263         
    43         [backgroundGradient fillRect:knobRect angle:90.0]; 
    44         [currentContext restoreGraphicsState]; 
     64        knobWidth = floorf(NSWidth(knobRect) - 2*knobXPad); 
    4565         
    46         // and stroke 
    47         [[NSColor colorWithCalibratedWhite:0.97 alpha:0.8] set]; 
    48         [knobPath setLineWidth:0.0]; 
    49         [knobPath setLineJoinStyle:NSRoundLineJoinStyle]; 
    50         [knobPath stroke]; 
    51          
    52         // NSShadow did not display properly, this is pretty dang close 
    53         NSBezierPath *knobShadow = [NSBezierPath bezierPath];    
    54         [knobShadow moveToPoint: NSMakePoint(NSMinX(knobRect)+knobWidth+offX, NSMinY(knobRect)+6+offY+2)]; 
    55         [knobShadow lineToPoint: NSMakePoint(NSMinX(knobRect)+(knobWidth/2)+offX, NSMinY(knobRect)+12+offY+1)]; 
    56         [knobShadow lineToPoint: NSMakePoint(NSMinX(knobRect)+offX, NSMinY(knobRect)+6+offY+2)]; 
    57         [[NSColor colorWithCalibratedWhite:0.0 alpha:0.5] set]; 
    58         [knobShadow setLineWidth:1.0]; 
    59         [knobShadow stroke]; 
     66        //steps: +, --, \, |, /, \, | / 
     67        [knobPath moveToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad+curveRadius, NSMinY(knobRect)+knobYPad)]; 
     68        [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad+knobWidth-curveRadius, NSMinY(knobRect)+knobYPad)]; 
     69        [knobPath appendBezierPathWithArcFromPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+knobXPad, NSMinY(knobRect)+knobYPad) toPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+knobXPad, NSMinY(knobRect)+knobYPad+curveRadius) radius:curveRadius]; 
     70        [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad+knobWidth  , NSMinY(knobRect)+knobYPad+knobHeight)]; 
     71        [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad+knobWidth/2, NSMinY(knobRect)+knobHeight+knobYPad+(knobWidth/2))]; 
     72        [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad, NSMinY(knobRect)+knobYPad+knobHeight)]; 
     73        [knobPath lineToPoint: NSMakePoint(NSMinX(knobRect)+knobXPad, NSMinY(knobRect)+knobYPad+curveRadius)]; 
     74        [knobPath appendBezierPathWithArcFromPoint:NSMakePoint(NSMinX(knobRect)+knobXPad, NSMinY(knobRect)+knobYPad) toPoint:NSMakePoint(NSMinX(knobRect)+knobWidth+knobXPad+curveRadius, NSMinY(knobRect)+knobYPad) radius:curveRadius]; 
     75        } 
     76   
     77  float dim = 1; 
     78  if(_scFlags.isPressed) 
     79        dim = .75; 
     80  
     81  NSColor *startColor = [NSColor colorWithCalibratedHue:0.6026*dim saturation:0.0812*dim brightness:0.6275*dim alpha:1.0]; 
     82  NSColor *endColor = [NSColor colorWithCalibratedHue:0.6310*dim saturation:0.1273*dim brightness:0.15*dim alpha:1.0]; 
     83  CTGradient *backgroundGradient = [CTGradient gradientWithBeginningColor:startColor endingColor:endColor]; 
     84  [backgroundGradient fillBezierPath:knobPath angle:90.0]; 
     85   
     86  // and stroke 
     87  [[NSColor colorWithCalibratedWhite:0.97*dim alpha:0.8] set]; 
     88  [knobPath setLineWidth:1]; 
     89  [knobPath setLineJoinStyle:NSRoundLineJoinStyle]; 
     90  [knobPath stroke]; 
    6091  } 
    6192 
    6293- (void)drawBarInside:(NSRect)frame flipped:(BOOL)flipped 
    6394  { 
    64         float barHeight = [self knobThickness]/2; 
    65         NSRect track = NSMakeRect(barHeight,floorf(frame.size.height/2)-1.5,frame.size.width-[self knobThickness],3.0); 
    66         NSBezierPath *trackPath = [NSBezierPath bezierPathWithRoundedRect:track cornerRadius:1.5];      // what's the right radius? 
    67         [[NSColor colorWithCalibratedHue:0.2179 saturation:0.0884 brightness:0.5765 alpha:1.0] set]; 
    68         [trackPath fill]; 
    69         [trackPath setLineWidth:0.0]; 
    70         [[NSColor whiteColor] set]; 
    71         [trackPath stroke]; 
    72 
     95  float barHeight; 
     96  float cornerRadius; 
     97  float barXPad = 1.5; 
     98   
     99  switch([self controlSize]) 
     100        { 
     101        case NSRegularControlSize: 
     102                barHeight = 5; 
     103                cornerRadius = 2.5;                             break; 
     104        case NSSmallControlSize: 
     105                barHeight = 4; 
     106                cornerRadius = 1.5;                             break; 
     107        case NSMiniControlSize: 
     108                barHeight = 3; 
     109                cornerRadius = 1;                               break; 
     110        default: 
     111                barHeight = [self knobThickness]/2; 
     112                cornerRadius = 1.5; 
     113        } 
     114   
     115  NSRect track = NSInsetRect(frame, barXPad, (NSHeight(frame)-barHeight)/2); 
     116  track.origin.y = floorf(track.origin.y); 
     117  track.origin.y -= flipped ? -.5 : .5; 
     118   
     119  if([self numberOfTickMarks] != 0) 
     120        track.origin.y -= barHeight; 
     121         
     122  NSBezierPath *trackPath = [NSBezierPath bezierPathWithRoundedRect:track cornerRadius:cornerRadius]; 
     123  [[NSColor colorWithCalibratedHue:0.2179 saturation:0.0884 brightness:0.5765 alpha:1.0] set]; 
     124  [trackPath fill]; 
     125  [trackPath setLineWidth:1]; 
     126  [[NSColor whiteColor] set]; 
     127  [trackPath stroke]; 
     128  } 
    73129 
    74130- (BOOL)_usesCustomTrackImage 
    75 
    76        return YES; 
    77 
     131 
     132  return YES; 
     133 
    78134 
    79135@end 
  • trunk/ILDAInspector/DarkKit/DKThemeFrame.m

    r97 r356  
    1717  } 
    1818 
     19- (id)frameColor 
     20  { 
     21  return [NSColor greenColor]; 
     22  } 
     23 
    1924- (void)_drawTitleBar:(NSRect)rect 
    2025  { 
    2126    NSRect titleRect, divider; 
    2227        NSDivideRect([self titlebarRect], &divider, &titleRect, 1, NSMinYEdge); 
    23      
     28         
     29        CTGradient *titleGradient = [CTGradient gradientWithBeginningColor: [NSColor colorWithDeviceWhite:.2 alpha:1] endingColor:[NSColor colorWithDeviceWhite:.45 alpha:1]]; 
     30         
     31  if([self _isUtility]) 
     32        { 
     33        [titleGradient fillRect:titleRect angle:90]; 
     34        } 
     35  else 
     36        { 
    2437        id path = [NSBezierPath bezierPath]; 
    2538        float radius = 8; 
     
    3245        [path lineToPoint:NSMakePoint(NSMinX(titleRect),NSMaxY(titleRect)-radius)]; 
    3346         
    34         NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; 
    35         [currentContext saveGraphicsState]; 
    36                 [[NSColor clearColor] set]; 
    37                 NSRectFill(titleRect); 
    38                 [path addClip]; 
    39                 [[CTGradient gradientWithBeginningColor: [NSColor colorWithDeviceWhite:.2 alpha:1] endingColor:[NSColor colorWithDeviceWhite:.45 alpha:1]] fillRect:titleRect angle:90]; 
    40         [currentContext restoreGraphicsState]; 
     47        [[NSColor clearColor] set]; 
     48        NSRectFill(titleRect); 
    4149         
    42         [[NSColor colorWithDeviceWhite:.18 alpha:1] set]; 
    43         NSRectFill(divider); 
    44          
     50        [titleGradient fillBezierPath:path angle:90]; 
     51        } 
     52   
     53  [[NSColor colorWithDeviceWhite:.18 alpha:1] set]; 
     54  NSRectFill(divider); 
    4555  } 
    4656