diff --git a/Medianno.xcodeproj/project.pbxproj b/Medianno.xcodeproj/project.pbxproj index 8448ee2..ea7b36c 100644 --- a/Medianno.xcodeproj/project.pbxproj +++ b/Medianno.xcodeproj/project.pbxproj @@ -33,6 +33,7 @@ 95CB69711400112A005A0346 /* MATagWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95CB69701400112A005A0346 /* MATagWindow.mm */; }; 95CB6975140012FE005A0346 /* MATag.xib in Resources */ = {isa = PBXBuildFile; fileRef = 95CB6973140012FE005A0346 /* MATag.xib */; }; 95CB697814001F26005A0346 /* MAColorForTag.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95CB697714001F26005A0346 /* MAColorForTag.mm */; }; + 95D8038B14012D7A000C0779 /* MADragging.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95D8038A14012D7A000C0779 /* MADragging.mm */; }; 95E2027D13FE9BF500369B31 /* MAMovieWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 95E2027C13FE9BF500369B31 /* MAMovieWindow.m */; }; 95E2028113FE9C6C00369B31 /* MAMovie.xib in Resources */ = {isa = PBXBuildFile; fileRef = 95E2027F13FE9C6C00369B31 /* MAMovie.xib */; }; 95E8C26713FD72D2004E9839 /* MAColorForURL.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95E8C26613FD72D2004E9839 /* MAColorForURL.mm */; }; @@ -80,6 +81,8 @@ 95CB6974140012FE005A0346 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = Medianno/en.lproj/MATag.xib; sourceTree = ""; }; 95CB697614001F26005A0346 /* MAColorForTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAColorForTag.h; sourceTree = ""; }; 95CB697714001F26005A0346 /* MAColorForTag.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MAColorForTag.mm; sourceTree = ""; }; + 95D8038914012D7A000C0779 /* MADragging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MADragging.h; sourceTree = ""; }; + 95D8038A14012D7A000C0779 /* MADragging.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MADragging.mm; sourceTree = ""; }; 95E2027B13FE9BF500369B31 /* MAMovieWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAMovieWindow.h; sourceTree = ""; }; 95E2027C13FE9BF500369B31 /* MAMovieWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MAMovieWindow.m; sourceTree = ""; }; 95E2028013FE9C6C00369B31 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = Medianno/en.lproj/MAMovie.xib; sourceTree = ""; }; @@ -206,6 +209,8 @@ 95CB697714001F26005A0346 /* MAColorForTag.mm */, 95E2027B13FE9BF500369B31 /* MAMovieWindow.h */, 95E2027C13FE9BF500369B31 /* MAMovieWindow.m */, + 95D8038914012D7A000C0779 /* MADragging.h */, + 95D8038A14012D7A000C0779 /* MADragging.mm */, ); name = Classes; sourceTree = ""; @@ -297,6 +302,7 @@ 95E2027D13FE9BF500369B31 /* MAMovieWindow.m in Sources */, 95CB69711400112A005A0346 /* MATagWindow.mm in Sources */, 95CB697814001F26005A0346 /* MAColorForTag.mm in Sources */, + 95D8038B14012D7A000C0779 /* MADragging.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index 276c5a0..9703030 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -18,6 +18,7 @@ #import "MAMovieWindow.h" #import "MATagWindow.h" #import "MAAppController.h" +#import "MADragging.h" static const char * kMADocWindowObserver = "MADocWindowObserver"; @@ -43,6 +44,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver"; [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateMovieTime:) userInfo:nil repeats:YES]; [mediaController addObserver:self forKeyPath:@"selection.media" options:0 context:&kMADocWindowObserver]; [mediaController addObserver:self forKeyPath:@"selection.name" options:0 context:&kMADocWindowObserver]; + [self registerOurDragTypes]; } - (void)dealloc diff --git a/Medianno/MADragging.h b/Medianno/MADragging.h new file mode 100644 index 0000000..b6dbe53 --- /dev/null +++ b/Medianno/MADragging.h @@ -0,0 +1,23 @@ +// +// MADragging.h +// Medianno +// +// Created by Matthias Neeracher on 8/21/11. +// Copyright 2011 Matthias Neeracher. All rights reserved. +// + +#import +#import "MADocWindow.h" +#import "MATagWindow.h" + +@interface MADocWindow (Dragging) + +- (void)registerOurDragTypes; + +@end + +@interface MATagWindow (Dragging) + +- (void)registerOurDragTypes; + +@end \ No newline at end of file diff --git a/Medianno/MADragging.mm b/Medianno/MADragging.mm new file mode 100644 index 0000000..d2bf814 --- /dev/null +++ b/Medianno/MADragging.mm @@ -0,0 +1,92 @@ +// +// MADragging.mm +// Medianno +// +// Created by Matthias Neeracher on 8/21/11. +// Copyright 2011 Matthias Neeracher. All rights reserved. +// + +#import "MADragging.h" +#import "MATagDescription.h" +#import "MAAnno.h" +#import "MAMedia.h" + +#define kMADragType @"org.aereperennius.medianno" + +@interface MAPasteboardData : NSObject { + NSArray * contents; +} + +- (id)initWithArray:(NSArray *)array; ++ (id)pasteboardDataWithArray:(NSArray *)array; + +@end + +@implementation MAPasteboardData + +- (id)initWithArray:(NSArray *)array +{ + self = [super init]; + contents = array; + + return self; +} + ++ (id)pasteboardDataWithArray:(NSArray *)array +{ + return [[[MAPasteboardData alloc] initWithArray:array] autorelease]; +} + +- (NSArray *)writableTypesForPasteboard:(NSPasteboard *)pasteboard +{ + return [NSArray arrayWithObjects:kMADragType, kUTTypeUTF8PlainText, nil]; +} + +- (NSPasteboardWritingOptions)writingOptionsForType:(NSString *)type pasteboard:(NSPasteboard *)pasteboard +{ + return NSPasteboardWritingPromised; +} + +- (id)pasteboardPropertyListForType:(NSString *)type +{ + if ([type isEqual:kMADragType]) { + return contents; + } else if ([type isEqual:(NSString *)kUTTypeUTF8PlainText]) { + NSMutableString * stringBuffer = [NSMutableString string]; + for (id obj in contents) + [stringBuffer appendFormat:@"%@\n", [obj exportText]]; + return stringBuffer; + } + return nil; +} + +@end + +@implementation MADocWindow (Dragging) + +- (void)registerOurDragTypes +{ + +} + +@end + +@implementation MATagWindow (Dragging) + +- (void)registerOurDragTypes +{ + [tagTable setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; + [tagTable setVerticalMotionCanBeginDrag:NO]; + [tagTable registerForDraggedTypes: + [NSArray arrayWithObjects:kMADragType, NSStringPboardType, nil]]; +} + +- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard +{ + NSArray * objects = [[tagController arrangedObjects] objectsAtIndexes:rowIndexes]; + [pboard clearContents]; + [pboard writeObjects:[NSArray arrayWithObject:[MAPasteboardData pasteboardDataWithArray:objects]]]; + + return YES; +} +@end diff --git a/Medianno/MATagWindow.h b/Medianno/MATagWindow.h index 3a9fec4..374b171 100644 --- a/Medianno/MATagWindow.h +++ b/Medianno/MATagWindow.h @@ -9,6 +9,8 @@ #import @interface MATagWindow : NSWindowController { + IBOutlet NSTableView * tagTable; + IBOutlet NSArrayController *tagController; } @property (assign) NSDocument * currentDocument; diff --git a/Medianno/MATagWindow.mm b/Medianno/MATagWindow.mm index d4c90e9..7c39b63 100644 --- a/Medianno/MATagWindow.mm +++ b/Medianno/MATagWindow.mm @@ -7,6 +7,7 @@ // #import "MATagWindow.h" +#import "MADragging.h" @implementation MATagWindow @@ -22,8 +23,7 @@ - (void)windowDidLoad { [super windowDidLoad]; - - // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. + [self registerOurDragTypes]; } - (IBAction)toggleWindow:(id)sender diff --git a/Medianno/en.lproj/MADocument.xib b/Medianno/en.lproj/MADocument.xib index 0a9d73d..003d361 100644 --- a/Medianno/en.lproj/MADocument.xib +++ b/Medianno/en.lproj/MADocument.xib @@ -99,7 +99,7 @@ {1279, 183} - + _NS:1197 YES @@ -339,7 +339,7 @@ {1281, 201} - + _NS:1193 133682 @@ -401,7 +401,7 @@ {1278, 565} - + _NS:1197 YES @@ -548,6 +548,7 @@ {{1, 566}, {1279, 15}} + _NS:1216 1 @@ -573,7 +574,7 @@ {1280, 583} - + _NS:1193 133682 @@ -1331,6 +1332,22 @@ 100248 + + + dataSource + + + + 100261 + + + + dataSource + + + + 100262 + @@ -1877,7 +1894,7 @@ - 100260 + 100262 @@ -1897,7 +1914,6 @@ mediaSkipBackward: mediaSkipForward: toggleMediaPlay: - toggleMoviePanel: YES @@ -1909,7 +1925,6 @@ id id id - id @@ -1924,7 +1939,6 @@ mediaSkipBackward: mediaSkipForward: toggleMediaPlay: - toggleMoviePanel: YES @@ -1960,10 +1974,6 @@ toggleMediaPlay: id - - toggleMoviePanel: - id - @@ -2049,6 +2059,17 @@ MAMovieWindow NSWindowController + + toggleWindow: + id + + + toggleWindow: + + toggleWindow: + id + + panelMovieView QTMovieView diff --git a/Medianno/en.lproj/MATag.xib b/Medianno/en.lproj/MATag.xib index 0ac6be5..6cc9d9d 100644 --- a/Medianno/en.lproj/MATag.xib +++ b/Medianno/en.lproj/MATag.xib @@ -37,7 +37,7 @@ YES - NSObject + MATagWindow FirstResponder @@ -282,7 +282,7 @@ _NS:2837 - {{0, 0}, {2560, 1418}} + {{0, 0}, {1440, 878}} {250, 116} {10000000000000, 10000000000000} YES @@ -411,6 +411,30 @@ 37 + + + dataSource + + + + 38 + + + + tagTable + + + + 39 + + + + tagController + + + + 40 + @@ -587,9 +611,64 @@ - 37 + 40 + + + + YES + + MATagWindow + NSWindowController + + toggleWindow: + id + + + toggleWindow: + + toggleWindow: + id + + + + YES + + YES + tagController + tagTable + + + YES + NSArrayController + NSTableView + + + + YES + + YES + tagController + tagTable + + + YES + + tagController + NSArrayController + + + tagTable + NSTableView + + + + + IBProjectSource + ./Classes/MATagWindow.h + + + - 0 IBCocoaFramework