diff --git a/MacPass/Base.lproj/EntryInspectorView.xib b/MacPass/Base.lproj/EntryInspectorView.xib
index d3a83eca..35685cff 100644
--- a/MacPass/Base.lproj/EntryInspectorView.xib
+++ b/MacPass/Base.lproj/EntryInspectorView.xib
@@ -68,13 +68,13 @@
@@ -930,7 +930,7 @@
-
+
diff --git a/MacPass/Base.lproj/GroupInspectorView.xib b/MacPass/Base.lproj/GroupInspectorView.xib
index 9a074d18..80a3f07a 100644
--- a/MacPass/Base.lproj/GroupInspectorView.xib
+++ b/MacPass/Base.lproj/GroupInspectorView.xib
@@ -1,8 +1,8 @@
-
+
-
+
@@ -30,7 +30,6 @@
-
@@ -39,7 +38,6 @@
-
@@ -54,7 +52,6 @@
-
@@ -64,14 +61,13 @@
-
+
-
+
-
-
+
-
+
@@ -80,7 +76,6 @@
-
@@ -92,7 +87,6 @@
-
@@ -102,18 +96,16 @@
-
-
-
+
+
-
-
-
+
+
@@ -122,7 +114,6 @@
-
@@ -134,7 +125,6 @@
-
@@ -170,7 +160,6 @@
-
@@ -179,18 +168,14 @@
-
-
-
-
diff --git a/MacPass/MPCustomFieldTableViewDelegate.m b/MacPass/MPCustomFieldTableViewDelegate.m
index 12d5e2ef..a3e62ecf 100644
--- a/MacPass/MPCustomFieldTableViewDelegate.m
+++ b/MacPass/MPCustomFieldTableViewDelegate.m
@@ -21,7 +21,6 @@
//
#import "MPCustomFieldTableViewDelegate.h"
-#import "MPDocument.h"
#import "MPCustomFieldTableCellView.h"
#import "MPEntryInspectorViewController.h"
@@ -30,31 +29,21 @@
@implementation MPCustomFieldTableViewDelegate
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
- MPDocument *document = [[[tableView window] windowController] document];
-
- KPKEntry *entry = document.selectedEntry;
MPCustomFieldTableCellView *view = [tableView makeViewWithIdentifier:@"SelectedCell" owner:tableView];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_customFieldFrameChanged:)
- name:NSViewFrameDidChangeNotification
- object:view];
-
- NSAssert([entry.customAttributes count] > row, @"Count of custom attributes must match row");
- KPKAttribute *attribute = entry.customAttributes[row];
- NSDictionary *validateOptions = @{ NSValidatesImmediatelyBindingOption: @YES };
- [view.labelTextField bind:NSValueBinding toObject:attribute withKeyPath:@"key" options:validateOptions];
- [view.valueTextField bind:NSValueBinding toObject:attribute withKeyPath:@"value" options:nil];
- [view.removeButton setTarget:self.viewController];
- [view.removeButton setAction:@selector(removeCustomField:)];
- [view.removeButton setTag:row];
+ [view.labelTextField bind:NSValueBinding
+ toObject:view
+ withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(key))]
+ options:@{ NSValidatesImmediatelyBindingOption: @YES }];
+ [view.valueTextField bind:NSValueBinding
+ toObject:view
+ withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(value))]
+ options:nil];
+ view.removeButton.target = self.viewController;
+ view.removeButton.action = @selector(removeCustomField:);
+ view.removeButton.tag = row;
return view;
}
-- (void)_customFieldFrameChanged:(NSNotification *)notification {
- // NSView *sender = [notification object];
- // NSLog(@"didChangeFrameFor: %@ to: %@", sender, NSStringFromRect([sender frame]));
-}
-
@end
diff --git a/MacPass/MPOverlayView.m b/MacPass/MPOverlayView.m
index 7c99c57b..87064985 100644
--- a/MacPass/MPOverlayView.m
+++ b/MacPass/MPOverlayView.m
@@ -13,9 +13,9 @@
- (void)drawRect:(NSRect)dirtyRect {
[[NSGraphicsContext currentContext] saveGraphicsState];
[[NSColor clearColor] set];
- NSRectFill([self bounds]);
+ NSRectFill(self.bounds);
NSColor *backgroundColor = [NSColor colorWithCalibratedWhite:0 alpha:0.7];
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:10 yRadius:10];
+ NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:self.bounds xRadius:10 yRadius:10];
[backgroundColor set];
[path fill];
[[NSGraphicsContext currentContext] restoreGraphicsState];
diff --git a/MacPass/MPShadowBox.m b/MacPass/MPShadowBox.m
index 919c44bc..c57d0301 100644
--- a/MacPass/MPShadowBox.m
+++ b/MacPass/MPShadowBox.m
@@ -6,11 +6,12 @@
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
-#define ELIPSIS_OFFSET 0
-#define ELIPSIS_HEIGHT 20
-#define SHADOW_OFFSET 10
+static CGFloat kMPElipsisOffset = 0.0;
+static CGFloat kMPElipsisHeight = 20.0;
+static CGFloat kMPShadowOffset = 10.0;
#import "MPShadowBox.h"
+#import "MPFlagsHelper.h"
@implementation MPShadowBox
@@ -28,7 +29,7 @@
- (void)drawRect:(NSRect)dirtyRect {
- dirtyRect = [self bounds];
+ dirtyRect = self.bounds;
[[NSGraphicsContext currentContext] saveGraphicsState];
NSColor *topColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1];
@@ -37,19 +38,20 @@
[gradient drawInRect:dirtyRect angle:-90];
NSShadow *dropShadow = [[NSShadow alloc] init];
- [dropShadow setShadowColor:[NSColor colorWithCalibratedWhite:0 alpha:0.5]];
- [dropShadow setShadowBlurRadius:10];
+ dropShadow.shadowColor = [NSColor colorWithCalibratedWhite:0 alpha:0.5];
+ dropShadow.shadowBlurRadius = 10;
[dropShadow set];
[[NSColor redColor] set]; // Use red to show visual errors
- if(0 != (self.shadowDisplay & MPShadowTop)) {
- [dropShadow setShadowOffset:NSMakeSize(0, -SHADOW_OFFSET)];
- NSRect topElispis = NSMakeRect(0, dirtyRect.size.height + ELIPSIS_OFFSET, dirtyRect.size.width, ELIPSIS_HEIGHT);
+
+ if(MPIsFlagSetInOptions(MPShadowTop, self.shadowDisplay)) {
+ dropShadow.shadowOffset = NSMakeSize(0, -kMPShadowOffset);
+ NSRect topElispis = NSMakeRect(0, dirtyRect.size.height + kMPElipsisOffset, dirtyRect.size.width, kMPElipsisHeight);
[[NSBezierPath bezierPathWithOvalInRect:topElispis] fill];
}
- if(0 != (self.shadowDisplay & MPShadowBottom)) {
- NSRect bottomElipsis = NSMakeRect(0, - ( ELIPSIS_OFFSET + ELIPSIS_HEIGHT ), dirtyRect.size.width, ELIPSIS_HEIGHT);
- [dropShadow setShadowOffset:NSMakeSize(0, SHADOW_OFFSET)];
+ if(MPIsFlagSetInOptions(MPShadowBottom, self.shadowDisplay)) {
+ NSRect bottomElipsis = NSMakeRect(0, - ( kMPElipsisOffset + kMPElipsisHeight ), dirtyRect.size.width, kMPElipsisHeight);
+ dropShadow.shadowOffset = NSMakeSize(0, kMPShadowOffset);
[[NSBezierPath bezierPathWithOvalInRect:bottomElipsis] fill];
}
@@ -59,7 +61,7 @@
- (void)setShadowDisplay:(MPShadowDisplay)shadowDisplay {
if(_shadowDisplay != shadowDisplay) {
_shadowDisplay = shadowDisplay;
- [self setNeedsDisplay:YES];
+ self.needsDisplay = YES;
}
}