Skip to content

Commit

Permalink
HistoryView: Allow dragging of refs to move them
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Nov 1, 2008
1 parent 90db001 commit 4cefe8e
Show file tree
Hide file tree
Showing 12 changed files with 351 additions and 40 deletions.
6 changes: 6 additions & 0 deletions GitX.xcodeproj/project.pbxproj
Expand Up @@ -44,6 +44,7 @@
F56CC7290E65E0AD004307B4 /* PBGitGraphLine.m in Sources */ = {isa = PBXBuildFile; fileRef = F56CC7280E65E0AD004307B4 /* PBGitGraphLine.m */; };
F56CC7320E65E0E5004307B4 /* PBGraphCellInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = F56CC7310E65E0E5004307B4 /* PBGraphCellInfo.m */; };
F57240BB0E9678EA00D8EE66 /* deleted_file.png in Resources */ = {isa = PBXBuildFile; fileRef = F57240BA0E9678EA00D8EE66 /* deleted_file.png */; };
F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */ = {isa = PBXBuildFile; fileRef = F574A2840EAE2EAC003F2CB1 /* PBRefController.m */; };
F574A2910EAE2FF4003F2CB1 /* PBGitConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 93FCCBA80EA8AF450061B02B /* PBGitConfig.m */; };
F57CC3910E05DDF2000472E2 /* PBEasyPipe.m in Sources */ = {isa = PBXBuildFile; fileRef = F57CC3900E05DDF2000472E2 /* PBEasyPipe.m */; };
F57CC4410E05E496000472E2 /* PBGitWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F57CC4400E05E496000472E2 /* PBGitWindowController.m */; };
Expand Down Expand Up @@ -161,6 +162,8 @@
F56CC7300E65E0E5004307B4 /* PBGraphCellInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGraphCellInfo.h; sourceTree = "<group>"; };
F56CC7310E65E0E5004307B4 /* PBGraphCellInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGraphCellInfo.m; sourceTree = "<group>"; };
F57240BA0E9678EA00D8EE66 /* deleted_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = deleted_file.png; path = Images/deleted_file.png; sourceTree = "<group>"; };
F574A2830EAE2EAC003F2CB1 /* PBRefController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRefController.h; sourceTree = "<group>"; };
F574A2840EAE2EAC003F2CB1 /* PBRefController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRefController.m; sourceTree = "<group>"; };
F57CC38F0E05DDF2000472E2 /* PBEasyPipe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBEasyPipe.h; sourceTree = "<group>"; };
F57CC3900E05DDF2000472E2 /* PBEasyPipe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBEasyPipe.m; sourceTree = "<group>"; };
F57CC43F0E05E496000472E2 /* PBGitWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitWindowController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -498,6 +501,8 @@
F565262A0E03D89B00F03B52 /* PBWebHistoryController.m */,
F52BCE050E84211300AA3741 /* PBGitHistoryController.h */,
F52BCE060E84211300AA3741 /* PBGitHistoryController.m */,
F574A2830EAE2EAC003F2CB1 /* PBRefController.h */,
F574A2840EAE2EAC003F2CB1 /* PBRefController.m */,
);
name = History;
sourceTree = "<group>";
Expand Down Expand Up @@ -649,6 +654,7 @@
F5FE6C030EB13BC900F30D12 /* PBServicesController.m in Sources */,
F50A41230EBB875D00208746 /* PBNiceSplitView.m in Sources */,
F5FC41F40EBCBD4300191D80 /* PBGitXProtocol.m in Sources */,
F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
3 changes: 3 additions & 0 deletions PBCommitList.h
Expand Up @@ -14,6 +14,9 @@
IBOutlet WebView* webView;
IBOutlet PBWebHistoryController* webController;
IBOutlet PBGitHistoryController *controller;

NSPoint mouseDownPoint;
}

@property (readonly) NSPoint mouseDownPoint;
@end
42 changes: 41 additions & 1 deletion PBCommitList.m
Expand Up @@ -7,10 +7,17 @@
//

#import "PBCommitList.h"

#import "PBGitRevisionCell.h"

@implementation PBCommitList

@synthesize mouseDownPoint;
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL) local
{
NSLog(@"a");
return NSDragOperationCopy;
}

- (void) keyDown: (id) event
{
NSString* character = [event charactersIgnoringModifiers];
Expand All @@ -33,4 +40,37 @@ - (void) copy:(id)sender
[controller copyCommitInfo];
};

- (void)mouseDown:(NSEvent *)theEvent
{
mouseDownPoint = [[self window] mouseLocationOutsideOfEventStream];
[super mouseDown:theEvent];
}

- (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows
tableColumns:(NSArray *)tableColumns
event:(NSEvent *)dragEvent
offset:(NSPointPointer)dragImageOffset
{
NSPoint location = [self convertPointFromBase:mouseDownPoint];
int row = [self rowAtPoint:location];
int column = [self columnAtPoint:location];
PBGitRevisionCell *cell = (PBGitRevisionCell *)[self preparedCellAtColumn:column row:row];

int index = [cell indexAtX:location.x];
if (index == -1)
return [super dragImageForRowsWithIndexes:dragRows tableColumns:tableColumns event:dragEvent offset:dragImageOffset];

NSRect rect = [cell rectAtIndex:index];

NSImage *newImage = [[NSImage alloc] initWithSize:NSMakeSize(rect.size.width + 3, rect.size.height + 3)];
rect.origin = NSMakePoint(0.5, 0.5);

[newImage lockFocus];
[cell drawLabelAtIndex:index inRect:rect];
[newImage unlockFocus];

*dragImageOffset = NSMakePoint(rect.size.width / 2 + 10, 0);
return newImage;

}
@end
7 changes: 5 additions & 2 deletions PBGitCommit.h
Expand Up @@ -17,7 +17,7 @@
NSString* details;
NSString *_patch;
NSArray* parents;
NSArray* refs;
NSMutableArray* refs;
NSDate* date;
char sign;
id lineInfo;
Expand All @@ -26,10 +26,13 @@

- initWithRepository:(PBGitRepository*) repo andSha:(NSString*) sha;

- (void)addRef:(id)ref;

@property (copy) NSString* sha;
@property (copy) NSString* subject;
@property (copy) NSString* author;
@property (retain) NSArray* parents, *refs;
@property (retain) NSArray* parents;
@property (retain) NSMutableArray* refs;
@property (copy) NSDate* date;
@property (readonly) NSString* dateString;
@property (readonly) NSString* patch;
Expand Down
8 changes: 8 additions & 0 deletions PBGitCommit.m
Expand Up @@ -62,6 +62,14 @@ - (PBGitTree*) tree
return [PBGitTree rootForCommit: self];
}

- (void)addRef:(id)ref
{
if (!self.refs)
self.refs = [NSMutableArray arrayWithObject:ref];
else
[self.refs addObject:ref];
}

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{
return NO;
Expand Down
1 change: 1 addition & 0 deletions PBGitHistoryController.h
Expand Up @@ -18,6 +18,7 @@
IBOutlet NSTreeController* treeController;
IBOutlet NSOutlineView* fileBrowser;
IBOutlet NSTableView* commitList;

IBOutlet id webView;
int selectedTab;

Expand Down
3 changes: 2 additions & 1 deletion PBGitHistoryController.m
Expand Up @@ -10,6 +10,7 @@
#import "CWQuickLook.h"
#import "PBGitGrapher.h"
#import "PBGitRevisionCell.h"
#import "PBCommitList.h"
#define QLPreviewPanel NSClassFromString(@"QLPreviewPanel")


Expand Down Expand Up @@ -38,7 +39,7 @@ - (void)awakeFromNib
// Set a sort descriptor for the subject column in the history list, as
// It can't be sorted by default (because it's bound to a PBGitCommit)
[[commitList tableColumnWithIdentifier:@"subject"] setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:@"subject" ascending:YES]];

[super awakeFromNib];
// We bind this ourselves because otherwise we would lose our selection
[branchesController bind:@"selectionIndexes" toObject:repository withKeyPath:@"currentBranch" options:nil];
Expand Down
82 changes: 78 additions & 4 deletions PBGitHistoryView.xib
Expand Up @@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="9"/>
<integer value="3"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -1344,6 +1344,9 @@
<reference key="NSSuperview"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomObject" id="892732705">
<string key="NSClassName">PBRefController</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
Expand Down Expand Up @@ -1866,6 +1869,38 @@
</object>
<int key="connectionID">230</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">commitController</string>
<reference key="source" ref="892732705"/>
<reference key="destination" ref="391209158"/>
</object>
<int key="connectionID">232</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">commitList</string>
<reference key="source" ref="892732705"/>
<reference key="destination" ref="254268962"/>
</object>
<int key="connectionID">233</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">historyController</string>
<reference key="source" ref="892732705"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">234</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="254268962"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">235</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -2366,6 +2401,11 @@
<reference key="object" ref="882172208"/>
<reference key="parent" ref="604026377"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">231</int>
<reference key="object" ref="892732705"/>
<reference key="parent" ref="1002"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand Down Expand Up @@ -2411,6 +2451,7 @@
<string>224.IBPluginDependency</string>
<string>225.IBPluginDependency</string>
<string>23.IBPluginDependency</string>
<string>231.IBPluginDependency</string>
<string>24.IBPluginDependency</string>
<string>25.IBPluginDependency</string>
<string>26.IBPluginDependency</string>
Expand Down Expand Up @@ -2502,6 +2543,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>PBCommitList</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="0" id="8"/>
Expand Down Expand Up @@ -2567,7 +2609,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">230</int>
<int key="maxID">235</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -2696,6 +2738,29 @@
<string key="minorKey">PBQLOutlineView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBRefController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>commitController</string>
<string>commitList</string>
<string>historyController</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSArrayController</string>
<string>PBCommitList</string>
<string>PBGitHistoryController</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBRefController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">PBUnsortableTableHeader</string>
<string key="superclassName">NSTableHeaderView</string>
Expand Down Expand Up @@ -2724,8 +2789,17 @@
<string key="className">PBWebController</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">view</string>
<string key="NS.object.0">WebView</string>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>repository</string>
<string>view</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>WebView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down
4 changes: 4 additions & 0 deletions PBGitRevisionCell.h
Expand Up @@ -18,5 +18,9 @@
IBOutlet PBGitHistoryController *controller;
}

- (int) indexAtX:(float)x;
- (NSRect) rectAtIndex:(int)index;
- (void) drawLabelAtIndex:(int)index inRect:(NSRect)rect;

@property(retain) PBGitCommit* objectValue;
@end

0 comments on commit 4cefe8e

Please sign in to comment.