Peter Hosey avatar Peter Hosey committed b4ef006

Made the fields' backgrounds partially transparent, further making it easier to compare the actual hashes to a source's hash.

Comments (0)

Files changed (5)

EasyHash.xcodeproj/project.pbxproj

 /* Begin PBXBuildFile section */
 		31136DAC0BBCA6BE00DCAE3A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 31136DAB0BBCA6BE00DCAE3A /* AppDelegate.m */; };
 		31136DD10BBCA8C600DCAE3A /* EasyHashDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = 31136DD00BBCA8C600DCAE3A /* EasyHashDocumentController.m */; };
+		3129B07914FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3129B07814FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.m */; };
 		31969AD4146A75F0003F9DBF /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31969AD3146A75F0003F9DBF /* Security.framework */; };
 		31969AD7146A83E6003F9DBF /* PRHHexadecimalTransform.m in Sources */ = {isa = PBXBuildFile; fileRef = 31969AD6146A83E6003F9DBF /* PRHHexadecimalTransform.m */; };
 		31F8AE3A14A59483002C14C1 /* EasyHash.icns in Resources */ = {isa = PBXBuildFile; fileRef = 31F8AE3914A59483002C14C1 /* EasyHash.icns */; };
 		31136DAB0BBCA6BE00DCAE3A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
 		31136DCF0BBCA8C600DCAE3A /* EasyHashDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EasyHashDocumentController.h; sourceTree = "<group>"; };
 		31136DD00BBCA8C600DCAE3A /* EasyHashDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EasyHashDocumentController.m; sourceTree = "<group>"; };
+		3129B07714FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PRHBackgroundWithHolesInItView.h; sourceTree = "<group>"; };
+		3129B07814FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PRHBackgroundWithHolesInItView.m; sourceTree = "<group>"; };
 		31969AD3146A75F0003F9DBF /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
 		31969AD5146A83E6003F9DBF /* PRHHexadecimalTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PRHHexadecimalTransform.h; sourceTree = "<group>"; };
 		31969AD6146A83E6003F9DBF /* PRHHexadecimalTransform.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PRHHexadecimalTransform.m; sourceTree = "<group>"; };
 				31136DD00BBCA8C600DCAE3A /* EasyHashDocumentController.m */,
 				31969AD5146A83E6003F9DBF /* PRHHexadecimalTransform.h */,
 				31969AD6146A83E6003F9DBF /* PRHHexadecimalTransform.m */,
+				3129B07714FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.h */,
+				3129B07814FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.m */,
 			);
 			name = Classes;
 			sourceTree = "<group>";
 				31136DAC0BBCA6BE00DCAE3A /* AppDelegate.m in Sources */,
 				31136DD10BBCA8C600DCAE3A /* EasyHashDocumentController.m in Sources */,
 				31969AD7146A83E6003F9DBF /* PRHHexadecimalTransform.m in Sources */,
+				3129B07914FF186D00C75FE9 /* PRHBackgroundWithHolesInItView.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

English.lproj/MyDocument.xib

 								</object>
 								<reference key="NSControlView" ref="570847693"/>
 								<bool key="NSDrawsBackground">YES</bool>
-								<object class="NSColor" key="NSBackgroundColor" id="618641788">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textBackgroundColor</string>
-									<object class="NSColor" key="NSColor">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MQA</bytes>
-									</object>
+								<object class="NSColor" key="NSBackgroundColor" id="474744792">
+									<int key="NSColorSpace">4</int>
+									<bytes key="NSWhite">MSAwLjYAA</bytes>
 								</object>
 								<object class="NSColor" key="NSTextColor" id="85366126">
 									<int key="NSColorSpace">6</int>
 								<reference key="NSSupport" ref="340712803"/>
 								<reference key="NSControlView" ref="702413557"/>
 								<bool key="NSDrawsBackground">YES</bool>
-								<reference key="NSBackgroundColor" ref="618641788"/>
+								<reference key="NSBackgroundColor" ref="474744792"/>
 								<reference key="NSTextColor" ref="85366126"/>
 							</object>
 						</object>
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
-						<string key="label">window</string>
-						<reference key="source" ref="69008336"/>
-						<reference key="destination" ref="83426398"/>
-					</object>
-					<int key="connectionID">18</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
 						<string key="label">MD5Field</string>
 						<reference key="source" ref="69008336"/>
 						<reference key="destination" ref="570847693"/>
 				</object>
 				<object class="IBConnectionRecord">
 					<object class="IBOutletConnection" key="connection">
+						<string key="label">window</string>
+						<reference key="source" ref="69008336"/>
+						<reference key="destination" ref="83426398"/>
+					</object>
+					<int key="connectionID">185</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">mainWindow</string>
+						<reference key="source" ref="69008336"/>
+						<reference key="destination" ref="83426398"/>
+					</object>
+					<int key="connectionID">186</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
 						<string key="label">delegate</string>
 						<reference key="source" ref="83426398"/>
 						<reference key="destination" ref="69008336"/>
 					<int key="connectionID">17</int>
 				</object>
 				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">viewToDrawAround0</string>
+						<reference key="source" ref="623123584"/>
+						<reference key="destination" ref="570847693"/>
+					</object>
+					<int key="connectionID">183</int>
+				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBOutletConnection" key="connection">
+						<string key="label">viewToDrawAround1</string>
+						<reference key="source" ref="623123584"/>
+						<reference key="destination" ref="702413557"/>
+					</object>
+					<int key="connectionID">184</int>
+				</object>
+				<object class="IBConnectionRecord">
 					<object class="IBBindingConnection" key="connection">
 						<string key="label">value: MD5Sum</string>
 						<reference key="source" ref="570847693"/>
 								<int key="contentType">2</int>
 								<reference key="containingView" ref="623123584"/>
 							</object>
-							<object class="IBNSLayoutConstraint" id="837403374">
+							<object class="IBNSLayoutConstraint" id="772553043">
 								<reference key="firstItem" ref="570847693"/>
 								<int key="firstAttribute">10</int>
 								<int key="relation">0</int>
 								<int key="contentType">2</int>
 								<reference key="containingView" ref="623123584"/>
 							</object>
-							<object class="IBNSLayoutConstraint" id="864746207">
+							<object class="IBNSLayoutConstraint" id="637006285">
 								<reference key="firstItem" ref="702413557"/>
 								<int key="firstAttribute">10</int>
 								<int key="relation">0</int>
 								<reference key="containingView" ref="623123584"/>
 							</object>
 							<reference ref="1043644425"/>
-							<object class="IBNSLayoutConstraint" id="770384831">
+							<object class="IBNSLayoutConstraint" id="667312245">
 								<reference key="firstItem" ref="1043644425"/>
 								<int key="firstAttribute">5</int>
 								<int key="relation">0</int>
 								<reference key="containingView" ref="623123584"/>
 							</object>
 							<reference ref="571967176"/>
-							<object class="IBNSLayoutConstraint" id="879693085">
+							<object class="IBNSLayoutConstraint" id="784809532">
 								<reference key="firstItem" ref="702413557"/>
 								<int key="firstAttribute">9</int>
 								<int key="relation">0</int>
 								<int key="contentType">2</int>
 								<reference key="containingView" ref="623123584"/>
 							</object>
-							<object class="IBNSLayoutConstraint" id="510311288">
+							<object class="IBNSLayoutConstraint" id="290606975">
 								<reference key="firstItem" ref="623123584"/>
 								<int key="firstAttribute">6</int>
 								<int key="relation">0</int>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">115</int>
-						<reference key="object" ref="837403374"/>
+						<reference key="object" ref="772553043"/>
 						<reference key="parent" ref="623123584"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">116</int>
-						<reference key="object" ref="864746207"/>
+						<reference key="object" ref="637006285"/>
 						<reference key="parent" ref="623123584"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">175</int>
-						<reference key="object" ref="770384831"/>
+						<reference key="object" ref="667312245"/>
 						<reference key="parent" ref="623123584"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">176</int>
-						<reference key="object" ref="879693085"/>
+						<reference key="object" ref="784809532"/>
 						<reference key="parent" ref="623123584"/>
 					</object>
 					<object class="IBObjectRecord">
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">178</int>
-						<reference key="object" ref="510311288"/>
+						<reference key="object" ref="290606975"/>
 						<reference key="parent" ref="623123584"/>
 					</object>
 				</object>
 					<string>5.IBPluginDependency</string>
 					<string>5.IBWindowTemplateEditedContentRect</string>
 					<string>54.IBPluginDependency</string>
+					<string>6.CustomClassName</string>
 					<string>6.IBNSViewMetadataConstraints</string>
 					<string>6.IBPluginDependency</string>
 					<string>62.IBPluginDependency</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>{{0, 875}, {420, 94}}</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+					<string>PRHBackgroundWithHolesInItView</string>
 					<object class="NSMutableArray">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<reference ref="187623227"/>
 						<reference ref="375105222"/>
 						<reference ref="476633695"/>
 						<reference ref="563000025"/>
-						<reference ref="837403374"/>
-						<reference ref="864746207"/>
+						<reference ref="772553043"/>
+						<reference ref="637006285"/>
 						<reference ref="885792815"/>
-						<reference ref="770384831"/>
-						<reference ref="879693085"/>
-						<reference ref="510311288"/>
+						<reference ref="667312245"/>
+						<reference ref="784809532"/>
+						<reference ref="290606975"/>
 					</object>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
 				<reference key="dict.values" ref="0"/>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">178</int>
+			<int key="maxID">186</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>MD5Field</string>
 							<string>SHA1Field</string>
+							<string>mainWindow</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>NSTextField</string>
 							<string>NSTextField</string>
+							<string>NSWindow</string>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>MD5Field</string>
 							<string>SHA1Field</string>
+							<string>mainWindow</string>
 						</object>
 						<object class="NSArray" key="dict.values">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 								<string key="name">SHA1Field</string>
 								<string key="candidateClassName">NSTextField</string>
 							</object>
+							<object class="IBToOneOutletInfo">
+								<string key="name">mainWindow</string>
+								<string key="candidateClassName">NSWindow</string>
+							</object>
 						</object>
 					</object>
 					<object class="IBClassDescriptionSource" key="sourceIdentifier">
 						<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
 					</object>
 				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">PRHBackgroundWithHolesInItView</string>
+					<string key="superclassName">NSView</string>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>viewToDrawAround0</string>
+							<string>viewToDrawAround1</string>
+						</object>
+						<object class="NSArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>NSView</string>
+							<string>NSView</string>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>viewToDrawAround0</string>
+							<string>viewToDrawAround1</string>
+						</object>
+						<object class="NSArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<object class="IBToOneOutletInfo">
+								<string key="name">viewToDrawAround0</string>
+								<string key="candidateClassName">NSView</string>
+							</object>
+							<object class="IBToOneOutletInfo">
+								<string key="name">viewToDrawAround1</string>
+								<string key="candidateClassName">NSView</string>
+							</object>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/PRHBackgroundWithHolesInItView.h</string>
+					</object>
+				</object>
 			</object>
 		</object>
 		<int key="IBDocument.localizationMode">0</int>
 
 @interface MyDocument ()
 
+@property(unsafe_unretained) IBOutlet NSWindow *mainWindow;
 @property(unsafe_unretained) IBOutlet NSTextField *MD5Field, *SHA1Field;
 @property(retain) NSFont *displayFont;
 
 }
 
 @synthesize MD5Sum, SHA1Sum;
+
+@synthesize mainWindow;
 @synthesize MD5Field, SHA1Field;
+
 @synthesize displayFont;
 
 + (BOOL) canConcurrentlyReadDocumentsOfType:(NSString *)type {
 }
 
 - (void) awakeFromNib {
-	dispatch_async(dispatch_get_main_queue(), ^{
-		//Uncomment to debug constraints.
-//		[[self windowForSheet] visualizeConstraints:[self.SHA1Field constraints]];
-	});
+	//Uncomment to debug constraints.
+//	[self.mainWindow visualizeConstraints:[self.SHA1Field constraints]];
+	[self.mainWindow setBackgroundColor:[NSColor clearColor]];
+	[self.mainWindow setOpaque:NO];
 
 	//The reason why we set only the SHA-1 field's CHP is because it's the longer field. If we set both fields' CHPs, then, as of 10.7.3, the shorter field will win, so any longer fields get cut short.
-//		if (self.MD5Sum)
-//			[self.MD5Field setContentHuggingPriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
+//	if (self.MD5Sum)
+//		[self.MD5Field setContentHuggingPriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
 	if (self.SHA1Sum)
 		[self.SHA1Field setContentHuggingPriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
 }

PRHBackgroundWithHolesInItView.h

+//
+//  PRHBackgroundWithHolesInItView.h
+//  EasyHash
+//
+//  Created by Peter Hosey on 2012-02-29.
+//
+
+@interface PRHBackgroundWithHolesInItView : NSView
+
+@property(strong) NSColor *backgroundColor; //Default: [NSColor windowBackgroundColor]
+
+@property(assign) IBOutlet NSView *viewToDrawAround0;
+@property(assign) IBOutlet NSView *viewToDrawAround1;
+
+@end

PRHBackgroundWithHolesInItView.m

+//
+//  PRHBackgroundWithHolesInItView.m
+//  EasyHash
+//
+//  Created by Peter Hosey on 2012-02-29.
+//
+
+#import "PRHBackgroundWithHolesInItView.h"
+
+@implementation PRHBackgroundWithHolesInItView
+
+@synthesize backgroundColor = _backgroundColor;
+
+@synthesize viewToDrawAround0 = _viewToDrawAround0;
+@synthesize viewToDrawAround1 = _viewToDrawAround1;
+
+- (void) commonInit {
+	self.backgroundColor = [NSColor windowBackgroundColor];
+}
+
+- (id) initWithFrame:(NSRect)frame {
+	if ((self = [super initWithFrame:frame])) {
+		[self commonInit];
+	}
+	return self;
+}
+- (id) initWithCoder:(NSCoder *)decoder {
+	if ((self = [super initWithCoder:decoder])) {
+		[self commonInit];
+	}
+	return self;
+}
+
+- (void) cutView:(NSView *)view outOfClipPath:(NSBezierPath *)clipPath {
+	if (view) {
+		[clipPath appendBezierPath:[[NSBezierPath bezierPathWithRect:[self convertRect:[view frame] fromView:[view superview]]] bezierPathByReversingPath]];
+	}
+}
+- (void) drawRect:(NSRect)dirtyRect {
+	NSBezierPath *clipPath = [NSBezierPath bezierPathWithRect:dirtyRect];
+	[self cutView:self.viewToDrawAround0 outOfClipPath:clipPath];
+	[self cutView:self.viewToDrawAround1 outOfClipPath:clipPath];
+	[self.backgroundColor set];
+	[clipPath fill];
+
+	return;
+	NSBezierPath *path = [NSBezierPath bezierPath];
+	NSView *view = self.viewToDrawAround0;
+	if (view)
+		[path appendBezierPathWithRect:[self convertRect:[view frame] fromView:[view superview]]];
+	view = self.viewToDrawAround1;
+	if (view)
+		[path appendBezierPathWithRect:[self convertRect:[view frame] fromView:[view superview]]];
+	NSLog(@"Field's frame: %@", NSStringFromRect([self convertRect:[view frame] fromView:[view superview]]));
+	[[NSColor redColor] set];
+	[path fill];
+}
+
+@end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.