Clean up BSSplitView
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 16 Jan 2011 06:30:03 +0000 (01:30 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sun, 16 Jan 2011 06:30:03 +0000 (01:30 -0500)
Source/BSSplitView.h
Source/BSSplitView.m

index 5d0fe8f826945725db81070d35823fea363874bd..e2ab6e88d30f4de70dbf27e70b2c54d2d6c794f1 100644 (file)
 
 #import <Cocoa/Cocoa.h>
 
-
+// A split view that performs custom drawing to get a gradient on the divider.
 @interface BSSplitView : NSSplitView
-{
-
-}
-
 @end
index d3963a204dd9b8a9eac7bef9ffaf68342838710b..75497871f3e66a0675f54d52812d9b8e58103c79 100644 (file)
  */
 - (void)drawDividerInRect:(NSRect)rect
 {
-  // draw the gradient
+  // Draw the gradient.
   NSColor* startColor = [NSColor colorWithDeviceRed:0.875 green:0.875 blue:0.875 alpha:1.0];
   NSColor* endColor = [NSColor colorWithDeviceRed:0.812 green:0.812 blue:0.812 alpha:1.0];
   NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor];
   [gradient drawInRect:rect angle:([self isVertical] ? 0.0 : 90.0)];
   [gradient release];
   
-  // draw the stroke
+  // Stroke the divider.
   [[NSColor colorWithDeviceRed:0.667 green:0.667 blue:0.667 alpha:1.0] setStroke];
   [NSBezierPath setDefaultLineWidth:0.5];
   [NSBezierPath strokeRect:rect];
   
-  // draw the dimple
+  // Draw the dimple image.
   NSImage* dimple = [NSImage imageNamed:@"dimple.png"];
   NSSize dmpSize = [dimple size];
-  NSPoint origin = NSMakePoint((rect.size.width / 2) + rect.origin.x - (dmpSize.width / 2), (rect.size.height / 2) + rect.origin.y + (dmpSize.height / 2));
+  NSPoint origin = NSMakePoint(NSMidX(rect) - (dmpSize.width / 2),
+                               NSMidY(rect) + (dmpSize.height / 2));
   [dimple compositeToPoint:origin operation:NSCompositeSourceOver];
 }