Skip to content

Commit 6328923

Browse files
committed
new badge
1 parent f0b1b74 commit 6328923

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

PBGitSidebarController.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
223223

224224
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(PBSourceViewCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(PBSourceViewItem *)item
225225
{
226-
cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]];
227-
226+
NSLog(@"%@ -- %d",item.revSpecifier,(item.revSpecifier!=NULL));
227+
if(item.revSpecifier!=NULL){
228+
cell.isCheckedOut = [item.revSpecifier isEqual:[repository headRef]];
229+
cell.behind=[NSNumber numberWithInt:10];
230+
}else{
231+
cell.behind=nil;
232+
}
228233
[cell setImage:[item icon]];
229234
}
230235

PBSourceViewCell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
@interface PBSourceViewCell : PBIconAndTextCell {
1414
BOOL isCheckedOut;
15+
NSNumber *behind;
1516
}
1617

1718
@property (assign) BOOL isCheckedOut;
19+
@property (assign) NSNumber *behind;
1820

1921
@end

PBSourceViewCell.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@
1616
@implementation PBSourceViewCell
1717

1818
@synthesize isCheckedOut;
19+
@synthesize behind;
1920

2021
# pragma mark context menu delegate methods
2122

2223
- (NSMenu *) menuForEvent:(NSEvent *)event inRect:(NSRect)rect ofView:(NSOutlineView *)view
2324
{
2425
NSPoint point = [view convertPoint:[event locationInWindow] fromView:nil];
2526
NSInteger row = [view rowAtPoint:point];
26-
27+
2728
PBGitSidebarController *controller = [view delegate];
28-
29+
2930
return [controller menuForRow:row];
3031
}
3132

@@ -34,21 +35,21 @@ - (NSMenu *) menuForEvent:(NSEvent *)event inRect:(NSRect)rect ofView:(NSOutline
3435

3536
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)outlineView
3637
{
37-
if (isCheckedOut) {
38-
NSImage *checkedOutImage = [PBSourceViewBadge checkedOutBadgeForCell:self];
38+
if(behind){
39+
NSImage *checkedOutImage = [PBSourceViewBadge badge:[NSString stringWithFormat:@"%@-%@",(isCheckedOut?@"":@""),behind] forCell:self];
3940
NSSize imageSize = [checkedOutImage size];
4041
NSRect imageFrame;
4142
NSDivideRect(cellFrame, &imageFrame, &cellFrame, imageSize.width + 3, NSMaxXEdge);
4243
imageFrame.size = imageSize;
43-
44+
4445
if ([outlineView isFlipped])
4546
imageFrame.origin.y += floor((cellFrame.size.height + imageFrame.size.height) / 2);
4647
else
4748
imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
48-
49+
4950
[checkedOutImage compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
5051
}
51-
52+
5253
[super drawWithFrame:cellFrame inView:outlineView];
5354
}
5455

0 commit comments

Comments
 (0)