diff --git a/IJInventoryView.h b/IJInventoryView.h index c3a872e..5802c4d 100644 --- a/IJInventoryView.h +++ b/IJInventoryView.h @@ -12,6 +12,8 @@ extern NSString * const IJPasteboardTypeInventoryItem; @protocol IJInventoryViewDelegate; @class IJInventoryItem; +@class IJItemPropertiesViewController; +@class MAAttachedWindow; @interface IJInventoryView : NSView { int rows; @@ -21,7 +23,12 @@ extern NSString * const IJPasteboardTypeInventoryItem; NSArray *items; + IJItemPropertiesViewController *propertiesViewController; + MAAttachedWindow *propertiesWindow; + id delegate; + + BOOL dragging; } @property (nonatomic, assign) id delegate; diff --git a/IJInventoryView.m b/IJInventoryView.m index d11fbf8..1d8c4a6 100644 --- a/IJInventoryView.m +++ b/IJInventoryView.m @@ -8,6 +8,8 @@ #import "IJInventoryView.h" #import "IJInventoryItem.h" +#import "IJItemPropertiesViewController.h" +#import "MAAttachedWindow.h" NSString * const IJPasteboardTypeInventoryItem = @"net.adampreble.insidejob.inventoryitem"; @@ -32,6 +34,7 @@ const static CGFloat cellOffset = 40; { [items release]; [mouseDownEvent release]; + [propertiesViewController release]; [super dealloc]; } @@ -39,6 +42,23 @@ const static CGFloat cellOffset = 40; { } +- (BOOL)acceptsFirstResponder +{ + return YES; +} +- (void)removePropertiesWindow +{ + [self.window removeChildWindow:propertiesWindow]; + [propertiesWindow orderOut:nil]; + [propertiesWindow release]; + propertiesWindow = nil; +} +- (BOOL)resignFirstResponder +{ + [self removePropertiesWindow]; + return YES; +} + - (void)setRows:(int)numberOfRows columns:(int)numberOfColumns { CALayer *layer = [CALayer layer]; @@ -114,6 +134,7 @@ const static CGFloat cellOffset = 40; [theEvent retain]; [mouseDownEvent release]; mouseDownEvent = theEvent; + dragging = NO; } - (void)mouseDragged:(NSEvent *)theEvent @@ -124,6 +145,8 @@ const static CGFloat cellOffset = 40; if (dragDistance < 3) return; + dragging = YES; + // Find the IJInventoryItem: NSPoint pointInView = [self convertPoint:mouseDownPoint fromView:nil]; int itemIndex = [self itemIndexForPoint:pointInView]; @@ -154,6 +177,38 @@ const static CGFloat cellOffset = 40; slideBack:YES]; } +- (void)mouseUp:(NSEvent *)theEvent +{ + if (!dragging) + { + // Show the properties window for this item. + + [self removePropertiesWindow]; + + NSPoint mouseDownPoint = [mouseDownEvent locationInWindow]; + NSPoint pointInView = [self convertPoint:mouseDownPoint fromView:nil]; + + int itemIndex = [self itemIndexForPoint:pointInView]; + IJInventoryItem *item = [items objectAtIndex:itemIndex]; + if (item.itemId == 0) + return; // can't show info on nothing + + if (!propertiesViewController) + { + propertiesViewController = [[IJItemPropertiesViewController alloc] initWithNibName:@"ItemPropertiesView" bundle:nil]; + } + propertiesViewController.item = item; + propertiesWindow = [[MAAttachedWindow alloc] initWithView:propertiesViewController.view + attachedToPoint:mouseDownPoint + inWindow:self.window + onSide:MAPositionRight + atDistance:0]; + [propertiesWindow setViewMargin:10.0]; + [propertiesWindow setAlphaValue:0.0]; + [[propertiesWindow animator] setAlphaValue:1.0]; + [[self window] addChildWindow:propertiesWindow ordered:NSWindowAbove]; + } +} - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { diff --git a/IJItemPropertiesViewController.h b/IJItemPropertiesViewController.h new file mode 100644 index 0000000..a182c1f --- /dev/null +++ b/IJItemPropertiesViewController.h @@ -0,0 +1,17 @@ +// +// IJItemPropertiesViewController.h +// InsideJob +// +// Created by Adam Preble on 10/9/10. +// Copyright 2010 Adam Preble. All rights reserved. +// + +#import + +@class IJInventoryItem; + +@interface IJItemPropertiesViewController : NSViewController { + IJInventoryItem *item; +} +@property (nonatomic, retain) IJInventoryItem *item; +@end diff --git a/IJItemPropertiesViewController.m b/IJItemPropertiesViewController.m new file mode 100644 index 0000000..6d69fdd --- /dev/null +++ b/IJItemPropertiesViewController.m @@ -0,0 +1,43 @@ +// +// IJItemPropertiesViewController.m +// InsideJob +// +// Created by Adam Preble on 10/9/10. +// Copyright 2010 Adam Preble. All rights reserved. +// + +#import "IJItemPropertiesViewController.h" +#import "IJInventoryItem.h" + +@implementation IJItemPropertiesViewController + +@synthesize item; + +- (NSSet *)keyPathsForValuesAffectingCountNumber +{ + return [NSSet setWithObject:@"item"]; +} +- (NSSet *)keyPathsForValuesAffectingDamageNumber +{ + return [NSSet setWithObject:@"item"]; +} + +- (NSNumber *)countNumber +{ + return [NSNumber numberWithShort:item.count]; +} +- (void)setCountNumber:(NSNumber *)number +{ + item.count = [number shortValue]; +} + +- (NSNumber *)damageNumber +{ + return [NSNumber numberWithShort:item.damage]; +} +- (void)setDamageNumber:(NSNumber *)number +{ + item.damage = [number shortValue]; +} + +@end diff --git a/InsideJob.xcodeproj/project.pbxproj b/InsideJob.xcodeproj/project.pbxproj index b9ea616..1028b62 100644 --- a/InsideJob.xcodeproj/project.pbxproj +++ b/InsideJob.xcodeproj/project.pbxproj @@ -21,6 +21,8 @@ 66BC00031260215C005A23F4 /* IJInventoryView.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC00021260215C005A23F4 /* IJInventoryView.m */; }; 66BC000E12602359005A23F4 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66BC000D12602359005A23F4 /* QuartzCore.framework */; }; 66BC033B1260CC59005A23F4 /* MAAttachedWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC033A1260CC59005A23F4 /* MAAttachedWindow.m */; }; + 66BC03621260D095005A23F4 /* IJItemPropertiesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC03611260D095005A23F4 /* IJItemPropertiesViewController.m */; }; + 66BC03641260D0B3005A23F4 /* ItemPropertiesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */; }; 66BCFC2B125E9A51005A23F4 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFC2A125E9A51005A23F4 /* Credits.rtf */; }; 66BCFC36125EA53E005A23F4 /* InsideJob.icns in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFC35125EA53E005A23F4 /* InsideJob.icns */; }; 66BCFE62125FCEC6005A23F4 /* DataValuesV110Transparent.png in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFE61125FCEC6005A23F4 /* DataValuesV110Transparent.png */; }; @@ -60,6 +62,9 @@ 66BC000D12602359005A23F4 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 66BC03391260CC59005A23F4 /* MAAttachedWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAAttachedWindow.h; sourceTree = ""; }; 66BC033A1260CC59005A23F4 /* MAAttachedWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAAttachedWindow.m; sourceTree = ""; }; + 66BC03601260D095005A23F4 /* IJItemPropertiesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJItemPropertiesViewController.h; sourceTree = ""; }; + 66BC03611260D095005A23F4 /* IJItemPropertiesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJItemPropertiesViewController.m; sourceTree = ""; }; + 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ItemPropertiesView.xib; sourceTree = ""; }; 66BCFC2A125E9A51005A23F4 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = ""; }; 66BCFC35125EA53E005A23F4 /* InsideJob.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = InsideJob.icns; sourceTree = ""; }; 66BCFE61125FCEC6005A23F4 /* DataValuesV110Transparent.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DataValuesV110Transparent.png; sourceTree = ""; }; @@ -154,6 +159,7 @@ 668B297B125E5DF00060BF71 /* ItemPicker.xib */, 668B28D8125E370A0060BF71 /* Items.csv */, 66BCFC2A125E9A51005A23F4 /* Credits.rtf */, + 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */, ); name = Resources; sourceTree = ""; @@ -198,6 +204,8 @@ 668B2978125E5DD40060BF71 /* IJItemPickerWindowController.m */, 66BC00011260215C005A23F4 /* IJInventoryView.h */, 66BC00021260215C005A23F4 /* IJInventoryView.m */, + 66BC03601260D095005A23F4 /* IJItemPropertiesViewController.h */, + 66BC03611260D095005A23F4 /* IJItemPropertiesViewController.m */, ); name = Interface; sourceTree = ""; @@ -271,6 +279,7 @@ 66BCFC2B125E9A51005A23F4 /* Credits.rtf in Resources */, 66BCFC36125EA53E005A23F4 /* InsideJob.icns in Resources */, 66BCFE62125FCEC6005A23F4 /* DataValuesV110Transparent.png in Resources */, + 66BC03641260D0B3005A23F4 /* ItemPropertiesView.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -291,6 +300,7 @@ 668B2979125E5DD40060BF71 /* IJItemPickerWindowController.m in Sources */, 66BC00031260215C005A23F4 /* IJInventoryView.m in Sources */, 66BC033B1260CC59005A23F4 /* MAAttachedWindow.m in Sources */, + 66BC03621260D095005A23F4 /* IJItemPropertiesViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ItemPropertiesView.xib b/ItemPropertiesView.xib new file mode 100644 index 0000000..c372a87 --- /dev/null +++ b/ItemPropertiesView.xib @@ -0,0 +1,964 @@ + + + + 1060 + 10F569 + 804 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 804 + + + YES + + + + YES + com.apple.InterfaceBuilder.CocoaPlugin + + + YES + + YES + + + YES + + + + YES + + IJItemPropertiesViewController + + + FirstResponder + + + NSApplication + + + + 268 + + YES + + + 268 + {{74, 11}, {51, 22}} + + YES + + -1804468671 + 272630784 + + LucidaGrande + 13 + 1044 + + + + YES + + YES + allowsFloats + formatterBehavior + locale + negativeInfinitySymbol + nilSymbol + numberStyle + positiveInfinitySymbol + + + YES + + + + + + -∞ + + + +∞ + + + #,##0.### + #,##0.### + + + + + + + + NaN + + YES + + + YES + + + + + 0 + 0 + YES + NO + 1 + AAAAAAAAAAAAAAAAAAAAAA + + + + 3 + YES + YES + YES + + . + , + YES + NO + YES + + + YES + + 6 + System + textBackgroundColor + + 3 + MQA + + + + 6 + System + textColor + + 3 + MAA + + + + + + + 268 + {{74, 38}, {51, 22}} + + YES + + -1804468671 + 272630784 + + + + YES + + YES + allowsFloats + formatterBehavior + locale + negativeInfinitySymbol + nilSymbol + numberStyle + positiveInfinitySymbol + + + YES + + + + -∞ + + + +∞ + + + #,##0.### + #,##0.### + + + + + + + + NaN + + + + + + 3 + YES + YES + YES + + . + , + YES + NO + YES + + + YES + + + + + + + 268 + {{3, 13}, {66, 17}} + + YES + + 68288064 + 71304192 + Damage: + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + + + + + + 268 + {{3, 40}, {66, 17}} + + YES + + 68288064 + 71304192 + Count: + + + + + + + + {135, 69} + + NSView + + + + + YES + + + view + + + + 2 + + + + value: countNumber + + + + + + value: countNumber + value + countNumber + 2 + + + 13 + + + + value: damageNumber + + + + + + value: damageNumber + value + damageNumber + 2 + + + 14 + + + + + YES + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 1 + + + YES + + + + + + + + + 3 + + + YES + + + + + + 4 + + + + + 5 + + + YES + + + + + + 6 + + + + + 7 + + + YES + + + + + + 8 + + + YES + + + + + + 9 + + + + + 10 + + + YES + + + + + + 11 + + + YES + + + + + + 12 + + + + + + + YES + + YES + 1.IBEditorWindowLastContentRect + 1.IBPluginDependency + 1.WindowOrigin + 1.editorWindowContentRectSynchronizationRect + 10.IBPluginDependency + 10.IBViewBoundsToFrameTransform + 11.IBPluginDependency + 12.IBNumberFormatterBehaviorMetadataKey + 12.IBNumberFormatterLocalizesFormatMetadataKey + 12.IBPluginDependency + 3.IBPluginDependency + 3.IBViewBoundsToFrameTransform + 4.IBPluginDependency + 5.IBPluginDependency + 5.IBViewBoundsToFrameTransform + 6.IBPluginDependency + 7.IBPluginDependency + 7.IBViewBoundsToFrameTransform + 8.IBPluginDependency + 9.IBNumberFormatterBehaviorMetadataKey + 9.IBNumberFormatterLocalizesFormatMetadataKey + 9.IBPluginDependency + + + YES + {{550, 459}, {135, 69}} + com.apple.InterfaceBuilder.CocoaPlugin + {628, 654} + {{217, 442}, {480, 272}} + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCvgAAwrgAAA + + com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBwAAAwuoAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABBwAAAwrgAAA + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + P4AAAL+AAABCvgAAwu4AAA + + com.apple.InterfaceBuilder.CocoaPlugin + + + com.apple.InterfaceBuilder.CocoaPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 14 + + + + YES + + IJItemPropertiesViewController + NSViewController + + IBProjectSource + IJItemPropertiesViewController.h + + + + + YES + + NSActionCell + NSCell + + IBFrameworkSource + AppKit.framework/Headers/NSActionCell.h + + + + NSApplication + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSApplication.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSApplicationScripting.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSColorPanel.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSHelpManager.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSPageLayout.h + + + + NSApplication + + IBFrameworkSource + AppKit.framework/Headers/NSUserInterfaceItemSearching.h + + + + NSCell + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSCell.h + + + + NSControl + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSControl.h + + + + NSFormatter + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFormatter.h + + + + NSMenu + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSMenu.h + + + + NSNumberFormatter + NSFormatter + + IBFrameworkSource + Foundation.framework/Headers/NSNumberFormatter.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSAccessibility.h + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDictionaryController.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSDragging.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontManager.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSFontPanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSKeyValueBinding.h + + + + NSObject + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSNibLoading.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSOutlineView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSPasteboard.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSSavePanel.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSTableView.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSToolbarItem.h + + + + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSView.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObjectScripting.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPortCoder.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptClassDescription.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptObjectSpecifiers.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSScriptWhoseTests.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLDownload.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CAAnimation.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CALayer.h + + + + NSObject + + IBFrameworkSource + QuartzCore.framework/Headers/CIImageProvider.h + + + + NSResponder + + IBFrameworkSource + AppKit.framework/Headers/NSInterfaceStyle.h + + + + NSResponder + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSResponder.h + + + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + + + NSTextFieldCell + NSActionCell + + IBFrameworkSource + AppKit.framework/Headers/NSTextFieldCell.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSClipView.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSMenuItem.h + + + + NSView + + IBFrameworkSource + AppKit.framework/Headers/NSRulerView.h + + + + NSView + NSResponder + + + + NSViewController + NSResponder + + view + NSView + + + view + + view + NSView + + + + IBFrameworkSource + AppKit.framework/Headers/NSViewController.h + + + + + 0 + IBCocoaFramework + + com.apple.InterfaceBuilder.CocoaPlugin.macosx + + + + com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 + + + YES + InsideJob.xcodeproj + 3 + +