/
CWTableCellView.mm
39 lines (31 loc) · 1.81 KB
/
CWTableCellView.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "CWTableCellView.h"
#import "CWStatusStringTransformer.h"
#import <OakAppKit/OakUIConstructionFunctions.h>
@implementation CWTableCellView
- (id)init
{
if((self = [super init]))
{
NSTextField* textField = OakCreateLabel(@"", [NSFont controlContentFontOfSize:0]);
self.textField = textField;
NSButton* commitCheckBox = OakCreateCheckBox(@"");
[commitCheckBox.cell setControlSize:NSControlSizeSmall];
_commitCheckBox = commitCheckBox;
NSTextField* statusTextField = OakCreateLabel();
_statusTextField = statusTextField;
NSButton* diffButton = OakCreateButton(@"Diff", NSRoundedBezelStyle);
diffButton.font = [NSFont messageFontOfSize:9];
[diffButton.cell setControlSize: NSControlSizeMini];
_diffButton = diffButton;
[textField bind:NSValueBinding toObject:self withKeyPath:@"objectValue.path" options:0];
[_commitCheckBox bind:NSValueBinding toObject:self withKeyPath:@"objectValue.commit" options:0];
[_statusTextField bind:NSValueBinding toObject:self withKeyPath:@"objectValue.scmStatus" options:@{ NSValueTransformerNameBindingOption : @"CWStatusStringTransformer" }];
NSDictionary* views = @{ @"commit" : _commitCheckBox, @"status" : _statusTextField, @"textField" : textField, @"diff" : _diffButton };
OakAddAutoLayoutViewsToSuperview([views allValues], self);
[_commitCheckBox setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
[_statusTextField setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(5)-[commit]-(5)-[status]-(5)-[textField]-(>=5)-[diff(==40)]-(5)-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views]];
}
return self;
}
@end