@@ -93,7 +93,7 @@ - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
9393 NSPoint location = mouseDownPoint;
9494 NSInteger row = [self rowAtPoint: location];
9595 NSInteger column = [self columnAtPoint: location];
96- PBGitRevisionCell *cell = (PBGitRevisionCell *)[self preparedCellAtColumn : column row: row];
96+ PBGitRevisionCell *cell = (PBGitRevisionCell *)[self viewAtColumn : column row: row makeIfNecessary: NO ];
9797 NSRect cellFrame = [self frameOfCellAtColumn: column row: row];
9898
9999 int index = -1 ;
@@ -120,66 +120,42 @@ - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
120120}
121121
122122
123- #pragma mark Row highlighting
123+ #pragma mark Menu
124124
125- - (NSColor *)searchResultHighlightColorForRow : ( NSInteger ) rowIndex
125+ - (NSMenu *)menuForEvent : ( NSEvent *) event
126126{
127- // if the row is selected use default colors
128- if ([self isRowSelected: rowIndex]) {
129- if ([[self window ] isKeyWindow ]) {
130- if ([[self window ] firstResponder ] == self) {
131- return [NSColor alternateSelectedControlColor ];
132- }
133- return [NSColor selectedControlColor ];
134- }
135- return [NSColor secondarySelectedControlColor ];
127+ [super menuForEvent: event];
128+ NSInteger index = self.clickedRow ;
129+
130+ NSInteger column = [self columnWithIdentifier: @" SubjectColumn" ];
131+ PBGitRevisionCell *cell = [self viewAtColumn: column row: index makeIfNecessary: NO ];
132+ PBGitCommit *commit = cell.objectValue ;
133+
134+ NSPoint point = [self .window.contentView convertPoint: [event locationInWindow ] toView: cell];
135+ int i = [cell indexAtX: point.x];
136+ PBGitRef *clickedRef = (i >= 0 ? commit.refs [0 ] : nil );
137+
138+ NSArray <PBGitCommit*>* selectedCommits = controller.selectedCommits ;
139+ NSArray <NSMenuItem *>* items;
140+
141+ if (clickedRef) {
142+ items = [contextMenuDelegate menuItemsForRef: clickedRef];
143+ } else if ([selectedCommits containsObject: commit]) {
144+ items = [contextMenuDelegate menuItemsForCommits: controller.selectedCommits];
145+ } else {
146+ items = [contextMenuDelegate menuItemsForCommits: @[commit]];
136147 }
137148
138- // light blue color highlighting search results
139- return [NSColor colorWithCalibratedRed: 0 .751f green: 0 .831f blue: 0 .943f alpha: 0 .800f ];
140- }
141-
142- - (NSColor *)searchResultHighlightStrokeColorForRow : (NSInteger )rowIndex
143- {
144- if ([self isRowSelected: rowIndex])
145- return [NSColor colorWithCalibratedWhite: 0 .0f alpha: 0 .30f ];
149+ NSMenu *menu = [[NSMenu alloc ] init ];
150+ [menu setAutoenablesItems: NO ];
151+ for (NSMenuItem *item in items)
152+ [menu addItem: item];
146153
147- return [ NSColor colorWithCalibratedWhite: 0 . 0f alpha: 0 . 05f ] ;
154+ return menu ;
148155}
149156
150- - (void )drawRow : (NSInteger )rowIndex clipRect : (NSRect )tableViewClipRect
151- {
152- NSRect rowRect = [self rectOfRow: rowIndex];
153- BOOL isRowVisible = NSIntersectsRect (rowRect, tableViewClipRect);
154-
155- // draw special highlighting if the row is part of search results
156- if (isRowVisible && [searchController isRowInSearchResults: rowIndex]) {
157- NSRect highlightRect = NSInsetRect (rowRect, 1 .0f , 1 .0f );
158- CGFloat radius = highlightRect.size .height / 2 .0f ;
159-
160- NSBezierPath *highlightPath = [NSBezierPath bezierPathWithRoundedRect: highlightRect xRadius: radius yRadius: radius];
161-
162- [[self searchResultHighlightColorForRow: rowIndex] set ];
163- [highlightPath fill ];
164-
165- [[self searchResultHighlightStrokeColorForRow: rowIndex] set ];
166- [highlightPath stroke ];
167- }
168-
169- // draws the content inside the row
170- [super drawRow: rowIndex clipRect: tableViewClipRect];
171- }
172-
173- - (void )highlightSelectionInClipRect : (NSRect )tableViewClipRect
174- {
175- // disable highlighting if the selected row is part of search results
176- // instead do the highlighting in drawRow:clipRect: above
177- if ([searchController isRowInSearchResults: [self selectedRow ]])
178- return ;
179-
180- [super highlightSelectionInClipRect: tableViewClipRect];
181- }
182157
158+ #pragma mark Row highlighting
183159
184160- (IBAction )performFindPanelAction : (id )sender
185161{
0 commit comments