5 // Created by Sean Patrick O'Brien on 9/23/06.
6 // Copyright 2006 Sean Patrick O'Brien. All rights reserved.
9 #import "NFHUDSliderCell.h"
10 #import "NSImage+FrameworkImage.h"
12 @implementation NFHUDSliderCell
14 - (void)drawBarInside:(NSRect)cellFrame flipped:(BOOL)flipped
16 NSImage *leftImage = [NSImage frameworkImageNamed:@"HUDSliderTrackLeft.tiff"];
17 NSImage *fillImage = [NSImage frameworkImageNamed:@"HUDSliderTrackFill.tiff"];
18 NSImage *rightImage = [NSImage frameworkImageNamed:@"HUDSliderTrackRight.tiff"];
20 NSSize size = [leftImage size];
21 float addX = size.width / 2.0;
22 float y = NSMaxY(cellFrame) - (cellFrame.size.height-size.height)/2.0 - 1;
23 float x = cellFrame.origin.x+addX;
24 float fillX = x + size.width;
25 float fillWidth = cellFrame.size.width - size.width - addX;
27 [leftImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
29 size = [rightImage size];
30 addX = size.width / 2.0;
31 x = NSMaxX(cellFrame) - size.width - addX;
32 fillWidth -= size.width+addX;
34 [rightImage compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
36 [fillImage setScalesWhenResized:YES];
37 [fillImage setSize:NSMakeSize(fillWidth, [fillImage size].height)];
38 [fillImage compositeToPoint:NSMakePoint(fillX, y) operation:NSCompositeSourceOver];
41 - (void)drawKnob:(NSRect)rect
45 if([self numberOfTickMarks] == 0)
46 knob = [NSImage frameworkImageNamed:@"HUDSliderKnobRound.tiff"];
48 knob = [NSImage frameworkImageNamed:@"HUDSliderKnob.tiff"];
50 float x = rect.origin.x + (rect.size.width - [knob size].width) / 2;
51 float y = NSMaxY(rect) - (rect.size.height - [knob size].height) / 2 ;
53 [knob compositeToPoint:NSMakePoint(x, y) operation:NSCompositeSourceOver];
56 -(NSRect)knobRectFlipped:(BOOL)flipped
58 NSRect rect = [super knobRectFlipped:flipped];
59 if([self numberOfTickMarks] > 0){
61 return NSOffsetRect(rect, 0, flipped ? 2 : -2);
66 - (BOOL)_usesCustomTrackImage