From 0d26bf1b12f74c91b9cfcdb02d84889b02878eac Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 29 Apr 2011 01:10:24 -0400 Subject: [PATCH] Use the same shape for the PC as with breakpoints --- Source/BSLineNumberRulerView.mm | 55 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/Source/BSLineNumberRulerView.mm b/Source/BSLineNumberRulerView.mm index 73bfc5e..63630e4 100644 --- a/Source/BSLineNumberRulerView.mm +++ b/Source/BSLineNumberRulerView.mm @@ -27,6 +27,9 @@ - (NSDictionary*)fontAttributes; - (void)drawBreakpointInRect:(NSRect)rect; - (void)drawProgramCounterInRect:(NSRect)rect; +- (void)drawMarkerInRect:(NSRect)rect + fillColor:(NSColor*)fill + strokeColor:(NSColor*)stroke; @end // Constants {{ @@ -248,6 +251,28 @@ const CGFloat kRulerRightPadding = 2.5; * Draws a breakpoint (a blue arrow) in the specified rectangle. */ - (void)drawBreakpointInRect:(NSRect)rect +{ + [self drawMarkerInRect:rect + fillColor:[NSColor colorWithDeviceRed:0.004 green:0.557 blue:0.851 alpha:1.0] + strokeColor:[NSColor colorWithDeviceRed:0.0 green:0.404 blue:0.804 alpha:1.0]]; +} + +/** + * Draws the program counter (a red arrow) in the specified rectangle. + */ +- (void)drawProgramCounterInRect:(NSRect)rect +{ + [self drawMarkerInRect:rect + fillColor:[[NSColor redColor] colorWithAlphaComponent:0.5] + strokeColor:[NSColor redColor]]; +} + +/** + * Draws the arrow shape in a given color. + */ +- (void)drawMarkerInRect:(NSRect)rect + fillColor:(NSColor*)fill + strokeColor:(NSColor*)stroke { [[NSGraphicsContext currentContext] saveGraphicsState]; @@ -266,40 +291,14 @@ const CGFloat kRulerRightPadding = 2.5; [path lineToPoint:NSMakePoint(minX, NSMaxY(rect) - kPadding)]; // lower left [path lineToPoint:NSMakePoint(minX, minY - 1)]; // upper left - [[NSColor colorWithDeviceRed:0.004 green:0.557 blue:0.851 alpha:1.0] set]; + [fill set]; [path fill]; - [[NSColor colorWithDeviceRed:0.0 green:0.404 blue:0.804 alpha:1.0] set]; + [stroke set]; [path setLineWidth:2]; [path stroke]; [[NSGraphicsContext currentContext] restoreGraphicsState]; } -/** - * Draws the program counter (a red arrow) in the specified rectangle. - */ -- (void)drawProgramCounterInRect:(NSRect)rect -{ - [[NSGraphicsContext currentContext] saveGraphicsState]; - - const CGFloat kArrowWidth = 10.0; - const CGFloat kMaxX = NSMaxX(rect); - const CGFloat kMidY = NSMidY(rect); - - NSBezierPath* path = [NSBezierPath bezierPath]; - [path moveToPoint:NSMakePoint(kMaxX, kMidY)]; - [path lineToPoint:NSMakePoint(kMaxX - kArrowWidth, NSMaxY(rect))]; - [path lineToPoint:NSMakePoint(kMaxX - kArrowWidth, NSMinY(rect))]; - [path lineToPoint:NSMakePoint(kMaxX, kMidY)]; - - [[[NSColor redColor] colorWithAlphaComponent:0.5] set]; - [path fill]; - - [[NSColor redColor] setStroke]; - [path stroke]; - - [[NSGraphicsContext currentContext] restoreGraphicsState]; -} - @end -- 2.43.5