Skip to content

Commit

Permalink
Grapher: draw ref names
Browse files Browse the repository at this point in the history
This simply draws the ref names in the cell, without any markup or correct
rect.
  • Loading branch information
pieter committed Aug 28, 2008
1 parent ae7d15a commit b4d7816
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion PBGitGrapher.m
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ - (void) parseCommits: (NSArray *) commits
previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines];

if (refs && [refs objectForKey:commit.sha])
previous.hasRef = TRUE;
previous.refs = [refs objectForKey:commit.sha];

// If a parent was added, we have room to not indent.
if (addedParent)
Expand Down
6 changes: 5 additions & 1 deletion PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ - (void) readRefs
[newBranches addObject: branch];
}

[newRefs setObject:ref forKey:sha];
NSMutableArray* curRefs;
if (curRefs = [newRefs objectForKey:sha])
[curRefs addObject:ref];
else
[newRefs setObject:[NSMutableArray arrayWithObject:ref] forKey:sha];
}
self.branches = newBranches;
self.refs = newRefs;
Expand Down
15 changes: 14 additions & 1 deletion PBGitRevisionCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r of

- (void) drawCircleForColumn: (int) c inRect: (NSRect) r
{
if (!cellInfo.hasRef)
if (!cellInfo.refs)
[[NSColor blackColor] set];
else
[[NSColor redColor] set];
Expand All @@ -86,6 +86,17 @@ - (void) drawCircleForColumn: (int) c inRect: (NSRect) r
[path fill];
}

- (void) drawRefsInRect: (NSRect*) rect
{
int pathWidth = 40 * [cellInfo.refs count];
NSRect ownRect;
NSDivideRect(*rect, &ownRect, rect, pathWidth, NSMinXEdge);
for (NSString* ref in cellInfo.refs) {
NSString* newRef = [[ref componentsSeparatedByString:@"/"] lastObject];
[newRef drawInRect: ownRect withAttributes:nil];
}
}

- (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
{
if (!isReady)
Expand All @@ -105,6 +116,8 @@ - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view

[self drawCircleForColumn: cellInfo.position inRect: ownRect];

if (cellInfo.refs)
[self drawRefsInRect:&rect];

[super drawWithFrame:rect inView:view];
isReady = NO;
Expand Down
4 changes: 2 additions & 2 deletions PBGraphCellInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
int position;
NSArray* lines;
int numColumns;
BOOL hasRef;
NSArray* refs;
}
@property(readonly) NSArray* lines;
@property(retain) NSArray* refs;
@property(assign) int position, numColumns;
@property(assign) BOOL hasRef;

- (id)initWithPosition: (int) p andLines: (NSArray*) l;

Expand Down
2 changes: 1 addition & 1 deletion PBGraphCellInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@implementation PBGraphCellInfo
@synthesize lines, position, numColumns, hasRef;
@synthesize lines, position, numColumns, refs;
- (id)initWithPosition: (int) p andLines: (NSArray*) l
{
position = p;
Expand Down

0 comments on commit b4d7816

Please sign in to comment.