From 4ac9b7d786b8433b8a915c04390c8207b6e14545 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 12 Jan 2011 13:44:28 -0500 Subject: [PATCH] Pad and vertically center the line numbers --- Source/BSLineNumberRulerView.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/BSLineNumberRulerView.mm b/Source/BSLineNumberRulerView.mm index 7be18c1..554183a 100644 --- a/Source/BSLineNumberRulerView.mm +++ b/Source/BSLineNumberRulerView.mm @@ -29,6 +29,9 @@ // The default width of the ruler. const CGFloat kDefaultWidth = 30.0; +// Padding between the right edge of the ruler and the line number string. +const CGFloat kRulerRightPadding = 2.5; + // }} @@ -104,10 +107,11 @@ const CGFloat kDefaultWidth = 30.0; NSSize stringSize = [lineNumberString size]; CGFloat yCoord = yOffset + NSMinY(frameRects[0]) - NSMinY(visibleRect); - [lineNumberString drawInRect:NSMakeRect(NSWidth(rect) - stringSize.width, - yCoord, - NSWidth(rect), - NSHeight(frameRects[0]))]; + NSRect drawRect = NSMakeRect(NSWidth(rect) - stringSize.width - kRulerRightPadding, + yCoord + (NSHeight(frameRects[0]) - stringSize.height) / 2.0, + NSWidth(rect) - kRulerRightPadding, + NSHeight(frameRects[0])); + [lineNumberString drawInRect:drawRect]; } } } -- 2.43.5