Changeset 356
- Timestamp:
- 04/07/07 16:59:42 (1 year ago)
- Files:
-
- trunk/ILDAInspector/CTGradient.h (modified) (2 diffs)
- trunk/ILDAInspector/CTGradient.m (modified) (10 diffs)
- trunk/ILDAInspector/DarkKit/DKButtonCell.h (added)
- trunk/ILDAInspector/DarkKit/DKButtonCell.m (added)
- trunk/ILDAInspector/DarkKit/DKDefines.c (added)
- trunk/ILDAInspector/DarkKit/DKDefines.h (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Info.plist (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/MacOS (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/MacOS/DKPalette (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/English.lproj (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/English.lproj/DKPalette.nib (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/English.lproj/DKPalette.nib/classes.nib (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/English.lproj/DKPalette.nib/info.nib (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/English.lproj/DKPalette.nib/keyedobjects.nib (added)
- trunk/ILDAInspector/DarkKit/DKPalette.palette/Contents/Resources/palette.table (added)
- trunk/ILDAInspector/DarkKit/DKPanel.h (added)
- trunk/ILDAInspector/DarkKit/DKPanel.m (added)
- trunk/ILDAInspector/DarkKit/DKSlider.m (modified) (1 diff)
- trunk/ILDAInspector/DarkKit/DKSliderCell.m (modified) (1 diff)
- trunk/ILDAInspector/DarkKit/DKThemeFrame.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ILDAInspector/CTGradient.h
r97 r356 2 2 // CTGradient.h 3 3 // 4 // Created by Chad Weider on 12/3/05.5 // Copyright (c) 200 6Cotingent.4 // Created by Chad Weider on 2/14/07. 5 // Copyright (c) 2007 Cotingent. 6 6 // Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 7 7 // 8 // Version: 1. 58 // Version: 1.6 9 9 10 10 #import <Cocoa/Cocoa.h> … … 67 67 - (void)radialFillRect:(NSRect)rect; //fills rect with radial gradient 68 68 // gradient from center outwards 69 - (void)fillBezierPath:(NSBezierPath *)path angle:(float)angle; 70 - (void)radialFillBezierPath:(NSBezierPath *)path; 71 69 72 @end trunk/ILDAInspector/CTGradient.m
r97 r356 2 2 // CTGradient.m 3 3 // 4 // Created by Chad Weider on 12/3/05.5 // Copyright (c) 200 6Cotingent.4 // Created by Chad Weider on 2/14/07. 5 // Copyright (c) 2007 Cotingent. 6 6 // Some rights reserved: <http://creativecommons.org/licenses/by/2.5/> 7 7 // 8 // Version: 1. 58 // Version: 1.6 9 9 10 10 #import "CTGradient.h" … … 22 22 23 23 //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);24 static void linearEvaluation (void *info, const float *in, float *out); 25 static void chromaticEvaluation(void *info, const float *in, float *out); 26 static void inverseChromaticEvaluation(void *info, const float *in, float *out); 27 static void transformRGB_HSV(float *components); 28 static void transformHSV_RGB(float *components); 29 static void resolveHSV(float *color1, float *color2); 30 30 31 31 … … 36 36 self = [super init]; 37 37 38 if (self != nil)38 if(self != nil) 39 39 { 40 40 [self _commonInit]; … … 127 127 return self; 128 128 } 129 130 131 129 #pragma mark - 132 130 … … 602 600 { 603 601 case CTLinearBlendingMode: 604 linearEvaluation(&elementList, &position, components); break;602 linearEvaluation(&elementList, &position, components); break; 605 603 case CTChromaticBlendingMode: 606 604 chromaticEvaluation(&elementList, &position, components); break; … … 693 691 CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 694 692 #endif 695 696 693 CGShadingRef myCGShading = CGShadingCreateAxial(colorspace, startPoint, endPoint, gradientFunction, false, false); 697 694 698 CGContextClipToRect (currentContext, *(CGRect *)&rect); //This is where the action happens695 CGContextClipToRect (currentContext, *(CGRect *)&rect); //This is where the action happens 699 696 CGContextDrawShading(currentContext, myCGShading); 700 697 701 CGShadingRelease (myCGShading);698 CGShadingRelease(myCGShading); 702 699 CGColorSpaceRelease(colorspace ); 703 700 CGContextRestoreGState(currentContext); … … 706 703 - (void)radialFillRect:(NSRect)rect 707 704 { 708 CGPoint startPoint , endPoint;705 CGPoint startPoint, endPoint; 709 706 float startRadius, endRadius; 707 float scalex, scaley, transx, transy; 710 708 711 709 startPoint = endPoint = CGPointMake(NSMidX(rect), NSMidY(rect)); 712 710 713 startRadius = 1; 714 711 startRadius = -1; 715 712 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; 716 718 endRadius = NSHeight(rect)/2; 719 } 717 720 else 721 { 722 scalex = 1; 723 transx = 1; 724 scaley = NSHeight(rect)/NSWidth(rect); 725 transy = (NSWidth(rect)-NSHeight(rect))/2; 718 726 endRadius = NSWidth(rect)/2; 719 727 } 728 720 729 //Calls to CoreGraphics 721 730 CGContextRef currentContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; … … 726 735 CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); 727 736 #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 730 743 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); 736 746 CGContextRestoreGState(currentContext); 737 747 } 738 748 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 } 739 774 #pragma mark - 740 775 … … 774 809 775 810 - (void)addElement:(CTGradientElement *)newElement 776 {811 { 777 812 if(elementList == nil || newElement->position < elementList->position) //inserting at beginning of list 778 813 { … … 1148 1183 1149 1184 1150 1151 1152 1153 1154 1155 1156 1157 1185 void transformRGB_HSV(float *components) //H,S,B -> R,G,B 1158 1186 { trunk/ILDAInspector/DarkKit/DKSlider.m
r97 r356 17 17 } 18 18 19 20 19 21 @end trunk/ILDAInspector/DarkKit/DKSliderCell.m
r99 r356 12 12 13 13 @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 16 14 - (void)drawKnob:(NSRect)knobRect 17 15 { 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; 32 21 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 } 33 33 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; 37 42 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 } 42 63 43 [backgroundGradient fillRect:knobRect angle:90.0]; 44 [currentContext restoreGraphicsState]; 64 knobWidth = floorf(NSWidth(knobRect) - 2*knobXPad); 45 65 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]; 60 91 } 61 92 62 93 - (void)drawBarInside:(NSRect)frame flipped:(BOOL)flipped 63 94 { 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 } 73 129 74 130 - (BOOL)_usesCustomTrackImage 75 {76 return YES;77 }131 { 132 return YES; 133 } 78 134 79 135 @end trunk/ILDAInspector/DarkKit/DKThemeFrame.m
r97 r356 17 17 } 18 18 19 - (id)frameColor 20 { 21 return [NSColor greenColor]; 22 } 23 19 24 - (void)_drawTitleBar:(NSRect)rect 20 25 { 21 26 NSRect titleRect, divider; 22 27 NSDivideRect([self titlebarRect], ÷r, &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 { 24 37 id path = [NSBezierPath bezierPath]; 25 38 float radius = 8; … … 32 45 [path lineToPoint:NSMakePoint(NSMinX(titleRect),NSMaxY(titleRect)-radius)]; 33 46 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); 41 49 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); 45 55 } 46 56
