From a248be1072d3e3223e0a95ca3f723a2ea15441da Mon Sep 17 00:00:00 2001
From: Nathan Kinsinger <[email protected]>
Date: Thu, 25 Feb 2010 21:16:38 -0700
Subject: [PATCH] Fix drawing ref labels on the next tableview column

If there are a large number of refs pointing to a commit, then they may be 
drawn on top of or behind the other columns.

This will not show any labels that don't fit.
---
 PBGitRevisionCell.m |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m
index 579168b..ae76b68 100644
--- a/PBGitRevisionCell.m
+++ b/PBGitRevisionCell.m
@@ -149,8 +149,8 @@
        static const int ref_spacing = 2;
        
        NSRect lastRect = rect;
-       lastRect.origin.x = round(lastRect.origin.x) - 0.5;
-       lastRect.origin.y = round(lastRect.origin.y) - 0.5;
+       lastRect.origin.x = round(lastRect.origin.x) + 0.5;
+       lastRect.origin.y = round(lastRect.origin.y) + 0.5;
        
        for (PBGitRef *ref in self.objectValue.refs) {
                NSMutableDictionary* attributes = [self 
attributesForRefLabelSelected:NO];
@@ -161,9 +161,11 @@
                newRect.size.height = textSize.height;
                newRect.origin.y = rect.origin.y + (rect.size.height - 
newRect.size.height) / 2;
                
-               [array addObject:[NSValue valueWithRect:newRect]];
-               lastRect = newRect;
-               lastRect.origin.x += (int)lastRect.size.width + ref_spacing;
+               if (NSContainsRect(rect, newRect)) {
+                       [array addObject:[NSValue valueWithRect:newRect]];
+                       lastRect = newRect;
+                       lastRect.origin.x += (int)lastRect.size.width + 
ref_spacing;
+               }
        }
        
        return array;
-- 
1.7.0+GitX

Reply via email to