diff --git a/English.lproj/RepositoryWindow.xib b/English.lproj/RepositoryWindow.xib index 3b8f28e..25626d8 100644 --- a/English.lproj/RepositoryWindow.xib +++ b/English.lproj/RepositoryWindow.xib @@ -2,13 +2,13 @@ 1050 - 9E17 + 9F33 670 - 949.33 + 949.34 352.00 YES - + YES @@ -1831,22 +1831,6 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ 84 - - - value: arrangedObjects.subject - - - - - - value: arrangedObjects.subject - value - arrangedObjects.subject - 2 - - - 85 - value: arrangedObjects.author @@ -2242,6 +2226,26 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ 233 + + + value: arrangedObjects + + + + + + value: arrangedObjects + value + arrangedObjects + + NSConditionallySetsEditable + + + 2 + + + 243 + @@ -3010,7 +3014,7 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ - 233 + 243 @@ -3094,7 +3098,20 @@ ELIAAAAAAAgACAAIAAgAAQABAAEAAQ PBGitRevisionCell - NSTextFieldCell + NSCell + + YES + + YES + objectValue + value + + + YES + id + id + + IBProjectSource PBGitRevisionCell.h diff --git a/PBDetailController.m b/PBDetailController.m index 3128105..1df8d29 100644 --- a/PBDetailController.m +++ b/PBDetailController.m @@ -160,18 +160,4 @@ int index = [[commitController selectionIndexes] firstIndex]; [commitList scrollRowToVisible: index]; } - -- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex -{ - if (![[aTableColumn identifier] isEqualToString:@"subject"]) - return; - - PBGitRevisionCell* cell = aCell; - if (self.repository.revisionList.grapher && - ![commitController filterPredicate] && - [[commitController sortDescriptors] count] == 0) { - PBGitGrapher* g = self.repository.revisionList.grapher; - [cell setCellInfo: [g cellInfoForRow:rowIndex]]; - } -} @end diff --git a/PBGitCommit.h b/PBGitCommit.h index 2194608..e2c87c2 100644 --- a/PBGitCommit.h +++ b/PBGitCommit.h @@ -16,8 +16,10 @@ NSString* author; NSString* details; NSArray* parents; + NSArray* refs; NSDate* date; char sign; + id lineInfo; PBGitRepository* repository; } @@ -26,7 +28,7 @@ @property (copy) NSString* sha; @property (copy) NSString* subject; @property (copy) NSString* author; -@property (retain) NSArray* parents; +@property (retain) NSArray* parents, *refs; @property (copy) NSDate* date; @property (readonly) NSString* dateString; @property (assign) char sign; @@ -35,4 +37,5 @@ @property (readonly) PBGitTree* tree; @property (readonly) NSArray* treeContents; @property (retain) PBGitRepository* repository; +@property (retain) id lineInfo; @end diff --git a/PBGitCommit.m b/PBGitCommit.m index ff94454..0fef796 100644 --- a/PBGitCommit.m +++ b/PBGitCommit.m @@ -11,7 +11,7 @@ @implementation PBGitCommit -@synthesize sha, repository, subject, author, date, parents, sign; +@synthesize sha, repository, subject, author, date, parents, sign, lineInfo, refs; - (NSString *) dateString diff --git a/PBGitGrapher.h b/PBGitGrapher.h index a4a0d07..806b551 100644 --- a/PBGitGrapher.h +++ b/PBGitGrapher.h @@ -22,12 +22,10 @@ struct PBGitGraphColumn { @interface PBGitGrapher : NSObject { PBGraphCellInfo* previous; NSMutableArray* previousLanes; - NSMutableArray* cellsInfo; NSDictionary* refs; PBGitRepository* repository; } - (id) initWithRepository: (PBGitRepository*) repo; - (void) decorateCommit: (PBGitCommit *) commit; -- (PBGraphCellInfo*) cellInfoForRow: (int) row; @end diff --git a/PBGitGrapher.m b/PBGitGrapher.m index da4794e..2fad4dd 100644 --- a/PBGitGrapher.m +++ b/PBGitGrapher.m @@ -15,9 +15,7 @@ - (id) initWithRepository: (PBGitRepository*) repo { refs = repo.refs; - // We don't know how many commits to parse. - cellsInfo = [NSMutableArray arrayWithCapacity:100]; - + repository = repo; previousLanes = [NSMutableArray array]; return self; @@ -119,8 +117,6 @@ previous = [[PBGraphCellInfo alloc] initWithPosition:newPos andLines:lines]; previous.sign = commit.sign; - if (refs && [refs objectForKey:commit.sha]) - previous.refs = [refs objectForKey:commit.sha]; // If a parent was added, we have room to not indent. if (addedParent) @@ -134,12 +130,7 @@ [currentLanes removeObject:currentLane]; previousLanes = currentLanes; - [cellsInfo addObject: previous]; -} - -- (PBGraphCellInfo*) cellInfoForRow: (int) row -{ - return [cellsInfo objectAtIndex: row]; + commit.lineInfo = previous; } - (void) finalize diff --git a/PBGitRevList.h b/PBGitRevList.h index f587556..cde4418 100644 --- a/PBGitRevList.h +++ b/PBGitRevList.h @@ -11,7 +11,6 @@ @interface PBGitRevList : NSObject { NSArray* commits; - id grapher; id repository; NSString* lastSha; } @@ -20,6 +19,5 @@ - (void) readCommits; @property(retain) NSArray* commits; -@property(retain) id grapher; @end diff --git a/PBGitRevList.m b/PBGitRevList.m index d01cef2..f5db47a 100644 --- a/PBGitRevList.m +++ b/PBGitRevList.m @@ -14,7 +14,7 @@ @implementation PBGitRevList -@synthesize commits, grapher; +@synthesize commits; - initWithRepository: (id) repo { repository = repo; @@ -142,6 +142,7 @@ struct decorateParameters { { NSMutableArray* revisions = params->revisions; PBGitRevSpecifier* rev = params->rev; + NSDictionary* refs = [repository refs]; BOOL decorateCommits = ![rev hasPathLimiter]; NSDate* start = [NSDate date]; @@ -150,8 +151,6 @@ struct decorateParameters { int num = 0; PBGitGrapher* g = [[PBGitGrapher alloc] initWithRepository: repository]; - if (decorateCommits) - [self performSelectorOnMainThread:@selector(setGrapher:) withObject:g waitUntilDone:YES]; while (!([[NSThread currentThread] isCancelled] && [revisions count] == 0)) { if ([revisions count] == 0) @@ -166,6 +165,10 @@ struct decorateParameters { num++; if (decorateCommits) [g decorateCommit: commit]; + + if (refs && [refs objectForKey:commit.sha]) + commit.refs = [refs objectForKey:commit.sha]; + [allRevisions addObject: commit]; if (num % 1000 == 0 || num == 10) [self performSelectorOnMainThread:@selector(setCommits:) withObject:allRevisions waitUntilDone:NO]; diff --git a/PBGitRevisionCell.h b/PBGitRevisionCell.h index def74c8..8bb26ea 100644 --- a/PBGitRevisionCell.h +++ b/PBGitRevisionCell.h @@ -8,11 +8,13 @@ #import #import "PBGitGrapher.h" +#import "PBGraphCellInfo.h" -@interface PBGitRevisionCell : NSTextFieldCell { - PBGraphCellInfo* cellInfo; - BOOL isReady; +@interface PBGitRevisionCell : NSActionCell { + id objectValue; + PBGraphCellInfo* cellInfo; + NSTextFieldCell* textCell; } -@property(assign) PBGraphCellInfo* cellInfo; +@property(retain) PBGitCommit* objectValue; @end diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m index 8a50c03..3d3c0de 100644 --- a/PBGitRevisionCell.m +++ b/PBGitRevisionCell.m @@ -58,19 +58,11 @@ @implementation PBGitRevisionCell -@synthesize cellInfo; --(void) setCellInfo: (PBGraphCellInfo*) info -{ - isReady = YES; - cellInfo = info; -} - (id) initWithCoder: (id) coder { self = [super initWithCoder:coder]; - if (self != nil) { - isReady = NO; - } + textCell = [[NSTextFieldCell alloc] initWithCoder:coder]; return self; } @@ -196,13 +188,14 @@ static const float ref_padding = 10.0f; static const float ref_spacing = 2.0f; + NSArray* refs = [self.objectValue refs]; NSRect refRect = (NSRect){rect->origin, rect->size}; [[NSColor blackColor] setStroke]; int index; - for (index = 0; index < [cellInfo.refs count]; ++index) { - PBGitRef* ref = [cellInfo.refs objectAtIndex:index]; + for (index = 0; index < [refs count]; ++index) { + PBGitRef* ref = [refs objectAtIndex:index]; NSMutableDictionary* attributes = [self attributesForRefLabelSelected:[self isHighlighted]]; NSSize refSize = [[ref shortName] sizeWithAttributes:attributes]; @@ -231,31 +224,44 @@ - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view { - if (!isReady) - return [super drawWithFrame:rect inView:view]; + cellInfo = [self.objectValue lineInfo]; + + if (cellInfo) { + float pathWidth = 10 + 10 * cellInfo.numColumns; - float pathWidth = 10 + 10 * cellInfo.numColumns; + NSRect ownRect; + NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge); - NSRect ownRect; - NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge); + for (PBGitGraphLine* line in cellInfo.lines) { + if (line.upper == 0) + [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height color: line.colorIndex]; + else + [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex]; + } - for (PBGitGraphLine* line in cellInfo.lines) { - if (line.upper == 0) - [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height color: line.colorIndex]; + if (cellInfo.sign == '<' || cellInfo.sign == '>') + [self drawTriangleInRect: ownRect sign: cellInfo.sign]; else - [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: 0 color:line.colorIndex]; + [self drawCircleInRect: ownRect]; } - if (cellInfo.sign == '<' || cellInfo.sign == '>') - [self drawTriangleInRect: ownRect sign: cellInfo.sign]; - else - [self drawCircleInRect: ownRect]; - - if (cellInfo.refs) + if ([self.objectValue refs]) [self drawRefsInRect:&rect]; - - [super drawWithFrame:rect inView:view]; - isReady = NO; + + // Still use this superclass because of hilighting differences + //_contents = [self.objectValue subject]; + //[super drawWithFrame:rect inView:view]; + [textCell setObjectValue: [self.objectValue subject]]; + [textCell setHighlighted: [self isHighlighted]]; + [textCell drawWithFrame:rect inView: view]; +} + +- (void) setObjectValue: (PBGitCommit*)object { + [super setObjectValue:[NSValue valueWithNonretainedObject:object]]; +} + +- (PBGitCommit*) objectValue { + return [[super objectValue] nonretainedObjectValue]; } @end