Remove cell size adjustment
[GitX.git] / PBGitRevisionCell.m
blobd9621ea92e7650f2f07ce63cf80a10fd7abe2e04
1 //
2 //  PBGitRevisionCell.m
3 //  GitX
4 //
5 //  Created by Pieter de Bie on 17-06-08.
6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
7 //
9 #import "PBGitRevisionCell.h"
12 @implementation PBGitRevisionCell
14 @synthesize cellInfo;
15 -(void) setCellInfo: (PBGraphCellInfo*) info
17         isReady = YES;
18         cellInfo = info;
21 - (id) initWithCoder: (id) coder
23         self = [super initWithCoder:coder];
24         if (self != nil) {
25                 isReady = NO;
26         }
27         return self;
30 - (NSArray*) colors
32         return  [NSArray arrayWithObjects:[NSColor redColor], [NSColor blueColor],
33                         [NSColor orangeColor], [NSColor blackColor], [NSColor greenColor], nil];
36 - (void) drawLineFromColumn: (int) from toColumn: (int) to inRect: (NSRect) r offset: (int) offset
39         int columnWidth = 10;
40         NSPoint origin = r.origin;
41         
42         NSPoint source = NSMakePoint(origin.x + columnWidth* from, origin.y + offset);
43         NSPoint center = NSMakePoint( origin.x + columnWidth * to, origin.y + r.size.height * 0.5);
45         // Just use red for now.
46         [[[self colors] objectAtIndex:0] set];
47         
48         NSBezierPath * path = [NSBezierPath bezierPath];
49         [path setLineWidth:2];
50         
51         [path moveToPoint: source];
52         [path lineToPoint: center];
53         [path stroke];
54         
57 - (void) drawCircleForColumn: (int) c inRect: (NSRect) r
59         NSArray* col = [NSArray arrayWithObjects:[NSColor redColor], [NSColor blueColor],
60         [NSColor orangeColor], [NSColor blackColor], [NSColor greenColor], nil];
62         int columnWidth = 10;
63         NSPoint origin = r.origin;
64         NSPoint columnOrigin = { origin.x + columnWidth * c, origin.y};
65         
66         NSRect oval = { columnOrigin.x - 5, columnOrigin.y + r.size.height * 0.5 - 5, 10, 10};
68         
69         NSBezierPath * path = [NSBezierPath bezierPath];
70         path = [NSBezierPath bezierPathWithOvalInRect:oval];
71         //[[col objectAtIndex:cellInfo.columns[c].color] set];
72         [path fill];
73         
74         NSRect smallOval = { columnOrigin.x - 3, columnOrigin.y + r.size.height * 0.5 - 3, 6, 6};
75         [[NSColor whiteColor] set];
76         path = [NSBezierPath bezierPathWithOvalInRect:smallOval];
77         [path fill];    
80 - (void) drawWithFrame: (NSRect) rect inView:(NSView *)view
82         if (!isReady)
83                 return [super drawWithFrame:rect inView:view];
85         float pathWidth = 10 + 10 * cellInfo.numColumns;
87         NSRect ownRect;
88         NSDivideRect(rect, &ownRect, &rect, pathWidth, NSMinXEdge);
90         for (PBLine* line in cellInfo.lines) {
91                 if (line.upper == 0)
92                         [self drawLineFromColumn: line.from toColumn: line.to inRect:ownRect offset: ownRect.size.height];
93                 else
94                         [self drawLineFromColumn:line.from toColumn: line.to inRect:ownRect offset: 0];
95         }
97         [self drawCircleForColumn: cellInfo.position inRect: ownRect];
99         
100         [super drawWithFrame:rect inView:view];
101         isReady = NO;
104 @end