diff --git a/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.m b/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.m index 4778f98..471f296 100644 --- a/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.m +++ b/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.m @@ -41,6 +41,7 @@ @interface XCActionBarWindowController () action = self.searchResults[row]; NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:TRSafeString(action.title)]; - + [title addAttribute:NSForegroundColorAttributeName value:(action.enabled ? [NSColor blackColor] : [NSColor darkGrayColor]) range:NSMakeRange(0, title.length)]; - + for(NSValue *rangeValue in action.searchQueryMatchRanges) { [title addAttributes:@{NSBackgroundColorAttributeName:[NSColor colorWithCalibratedRed:1.000 green:1.000 blue:0.519 alpha:0.250], NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSUnderlineColorAttributeName: [NSColor yellowColor]} range:rangeValue.rangeValue]; } - + cell.textField.allowsEditingTextAttributes = YES; - + cell.textField.attributedStringValue = title; cell.hintTextField.stringValue = TRSafeString(action.hint); if([action acceptsArguments] == YES) { -// NSString *summaryWithMarker = [NSString stringWithFormat:@"%@ %@", @"\uf11c", TRSafeString(action.subtitle)]; -// NSMutableAttributedString *summary = [[NSMutableAttributedString alloc] initWithString:summaryWithMarker]; -// [summary addAttributes:@{NSFontAttributeName: XCFontAwesomeWithSize(12.0)} -// range:NSMakeRange(0, 1)]; -// cell.subtitleTextField.allowsEditingTextAttributes = YES; -// cell.subtitleTextField.attributedStringValue = summary; - - cell.subtitleTextField.stringValue = [NSString stringWithFormat:@"%@ %@", @"\u21e5", TRSafeString(action.subtitle)]; + cell.subtitleTextField.stringValue = TRSafeString(action.subtitle); + cell.iconImageView.image = action.icon; } - else cell.subtitleTextField.stringValue = TRSafeString(action.subtitle); - +} + +- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row +{ + if (self.prototypeResultCell == nil) + { + self.prototypeResultCell = [self.searchResultsTable makeViewWithIdentifier:NSStringFromClass([XCSearchResultCell class]) owner:self]; + } + + [self configureCell:self.prototypeResultCell forRow:row]; + [self.prototypeResultCell layoutSubtreeIfNeeded]; - return cell; + return self.prototypeResultCell.fittingSize.height; } #pragma mark - Public Methods - //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// - (void)updateSearchResults:(NSArray *)results @@ -420,13 +431,16 @@ - (void)selectSearchResultAtIndex:(NSInteger)indexToSelect - (void)resizeWindowToAccomodateSearchResults { if(TRCheckIsEmpty(self.searchResults) == NO) { - [[self.searchResultsTable animator] setAlphaValue:1.0]; - self.searchResultsTable.hidden = NO; - self.searchResultsTableBottomConstraint.constant = 10.0; - self.searchResultsTableHeightConstraint.constant = 250.0; - - [self.searchField layoutSubtreeIfNeeded]; + self.searchResultsTableBottomConstraint.constant = 0.0; + + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + context.duration = 0.26; + self.searchResultsTable.animator.alphaValue = 1.0; + self.searchResultsTableHeightConstraint.animator.constant = MIN(self.searchResultsTable.rowHeight * self.searchResults.count, self.searchResultsTable.rowHeight * 6); + + [self.searchField layoutSubtreeIfNeeded]; + } completionHandler:nil]; } else [self restoreWindowSize]; } @@ -435,13 +449,18 @@ - (void)resizeWindowToAccomodateSearchResults //////////////////////////////////////////////////////////////////////////////// - (void)restoreWindowSize { - [[self.searchResultsTable animator] setAlphaValue:0.0]; - - self.searchResultsTable.hidden = YES; - self.searchResultsTableBottomConstraint.constant = 0.0; - self.searchResultsTableHeightConstraint.constant = 0.0; - - [self.window.contentView layoutSubtreeIfNeeded]; + [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { + context.duration = 0.16; + self.searchResultsTable.animator.alphaValue = 0.0; + self.searchResultsTableHeightConstraint.constant = 0.0; + [self.window.contentView layoutSubtreeIfNeeded]; + + } completionHandler:^{ + self.searchResultsTableBottomConstraint.constant = 0.0; + self.searchResultsTable.hidden = YES; + + [self.window.contentView layoutSubtreeIfNeeded]; + }]; } //////////////////////////////////////////////////////////////////////////////// diff --git a/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.xib b/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.xib index 15f1a5e..c99c6d2 100644 --- a/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.xib +++ b/PGXcodeActionBrowser/Controllers/XCActionBarWindowController.xib @@ -1,12 +1,13 @@ - + - + + @@ -18,41 +19,37 @@ - - + + - - + + - - - - - - - - - - + + + - + - - - - + + + + - + @@ -66,44 +63,44 @@ - + - - - - - + + + + + - - - - + + + + - - - + + + - - - - - - - - - + + + + + + + + + @@ -120,7 +117,7 @@ - + @@ -134,17 +131,35 @@ + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + diff --git a/PGXcodeActionBrowser/Model/XCCodeSnippetProvider.m b/PGXcodeActionBrowser/Model/XCCodeSnippetProvider.m index fdbd125..b5d37c3 100644 --- a/PGXcodeActionBrowser/Model/XCCodeSnippetProvider.m +++ b/PGXcodeActionBrowser/Model/XCCodeSnippetProvider.m @@ -107,7 +107,14 @@ - (void)buildAvailableActions XCExpandCodeSnippetAction *action = [[XCExpandCodeSnippetAction alloc] initWithCodeSnippet:snippet]; action.group = [self actionGroupName]; - + action.enabled = YES; + action.group = [self actionGroupName]; + action.representedObject = snippet; + + NSBundle *IDEKItBundle = [NSBundle bundleWithIdentifier:@"com.apple.dt.IDEKit"]; + NSImage *snippetIcon = [IDEKItBundle imageForResource:@"CS_System"]; + action.icon = snippetIcon; + [actions addObject:action]; //////////////////////////////////////////////////////////////////////////////// diff --git a/PGXcodeActionBrowser/UI/XCRoundCornerWindow.m b/PGXcodeActionBrowser/UI/XCRoundCornerWindow.m index a6828f9..c6bc6f1 100644 --- a/PGXcodeActionBrowser/UI/XCRoundCornerWindow.m +++ b/PGXcodeActionBrowser/UI/XCRoundCornerWindow.m @@ -36,11 +36,11 @@ - (BOOL)canBecomeKeyWindow //////////////////////////////////////////////////////////////////////////////// - (void)setContentView:(NSView *)contentView { - contentView.wantsLayer = YES; - contentView.layer.frame = contentView.frame; - contentView.layer.cornerRadius = 10.0; + contentView.wantsLayer = YES; + contentView.layer.frame = contentView.frame; + contentView.layer.cornerRadius = 3.0; contentView.layer.masksToBounds = YES; - + [super setContentView:contentView]; } diff --git a/PGXcodeActionBrowser/UI/XCSearchResultCell.h b/PGXcodeActionBrowser/UI/XCSearchResultCell.h index 7c5db65..4e7b15d 100644 --- a/PGXcodeActionBrowser/UI/XCSearchResultCell.h +++ b/PGXcodeActionBrowser/UI/XCSearchResultCell.h @@ -14,5 +14,6 @@ @property (strong) IBOutlet NSTextField *hintTextField; @property (strong) IBOutlet NSTextField *subtitleTextField; +@property (strong) IBOutlet NSImageView *iconImageView; @end diff --git a/PGXcodeActionBrowser/UI/XCSearchResultCell.xib b/PGXcodeActionBrowser/UI/XCSearchResultCell.xib deleted file mode 100644 index 4ae2ba0..0000000 --- a/PGXcodeActionBrowser/UI/XCSearchResultCell.xib +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/XCActionBar.xcodeproj/project.pbxproj b/XCActionBar.xcodeproj/project.pbxproj index 9b0bf11..3cf19a1 100644 --- a/XCActionBar.xcodeproj/project.pbxproj +++ b/XCActionBar.xcodeproj/project.pbxproj @@ -27,7 +27,6 @@ 421D37081AB790D900FF8338 /* XCSurroundWithActions.plist in Resources */ = {isa = PBXBuildFile; fileRef = 421D37071AB790D900FF8338 /* XCSurroundWithActions.plist */; }; 421D370B1AB7982300FF8338 /* XCAddPrefixToLinesAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 421D370A1AB7982300FF8338 /* XCAddPrefixToLinesAction.m */; }; 421D370E1AB7982F00FF8338 /* XCAddSuffixToLinesAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 421D370D1AB7982F00FF8338 /* XCAddSuffixToLinesAction.m */; }; - 4228E3E81AB1B7D100918EAA /* XCSearchResultCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4228E3E71AB1B7D100918EAA /* XCSearchResultCell.xib */; }; 4228E3EB1AB1B82A00918EAA /* XCSearchResultCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4228E3EA1AB1B82A00918EAA /* XCSearchResultCell.m */; }; 422DB1BF1AB60134007D13F9 /* XCCodeSnippetProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 422DB1BE1AB60134007D13F9 /* XCCodeSnippetProvider.m */; }; 423986FB1AC0DEB300559D29 /* XCTextSelectionStorage.m in Sources */ = {isa = PBXBuildFile; fileRef = 423986FA1AC0DEB300559D29 /* XCTextSelectionStorage.m */; }; @@ -108,7 +107,6 @@ 421E215B1AB321DC000893ED /* _IDETestableState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _IDETestableState.h; sourceTree = ""; }; 421F53561AB9CFF600509103 /* XCSearchStrategy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCSearchStrategy.h; sourceTree = ""; }; 422781921AB05883003CDD79 /* XCActionBar-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "XCActionBar-Prefix.pch"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 4228E3E71AB1B7D100918EAA /* XCSearchResultCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XCSearchResultCell.xib; sourceTree = ""; }; 4228E3E91AB1B82A00918EAA /* XCSearchResultCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = XCSearchResultCell.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 4228E3EA1AB1B82A00918EAA /* XCSearchResultCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = XCSearchResultCell.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 422DB1BA1AB5FAF5007D13F9 /* IDECodeSnippet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDECodeSnippet.h; sourceTree = ""; }; @@ -563,7 +561,6 @@ children = ( 42FD3C0D1AB0ABE900F0A442 /* XCRoundCornerWindow.h */, 42FD3C0E1AB0ABE900F0A442 /* XCRoundCornerWindow.m */, - 4228E3E71AB1B7D100918EAA /* XCSearchResultCell.xib */, 4228E3E91AB1B82A00918EAA /* XCSearchResultCell.h */, 4228E3EA1AB1B82A00918EAA /* XCSearchResultCell.m */, ); @@ -659,7 +656,6 @@ 421D37081AB790D900FF8338 /* XCSurroundWithActions.plist in Resources */, 4214C9A01ACDC33A009FA602 /* fontawesome-webfont.ttf in Resources */, 426782EB1ABA37E8006F4E53 /* XCActionBarConfiguration.plist in Resources */, - 4228E3E81AB1B7D100918EAA /* XCSearchResultCell.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };