5 // Created by 柳 on 09/09/12.
6 // Copyright 2009 __MyCompanyName__. All rights reserved.
9 #import "ElisTimeLineView.h"
12 @implementation ElisTimeLineView
16 [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
17 leftCursorRect = NSZeroRect;
18 rightCursorRect = NSZeroRect;
21 // ここにドラッグし終えた時の処理を書く。
22 - (BOOL)performDragOperation:(id)sender
24 // [compositionView draggingEndFromBrowser];
26 [_timeLineController draggingDone];
30 // 何かがドラッグされてきた。ここではその準備。
31 - (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
33 NSPasteboard* board = [sender draggingPasteboard];
35 NSString *path, *errorDescription;
36 NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
38 data = [board dataForType:NSFilenamesPboardType];
40 NSArray *filenames = [NSPropertyListSerialization propertyListFromData:data
41 mutabilityOption:kCFPropertyListImmutable
43 errorDescription:&errorDescription];
45 path = [filenames objectAtIndex:0];
46 [_timeLineController addMedia:path];
50 - (unsigned int)draggingUpdated:(id <NSDraggingInfo>)sender
52 [_timeLineController dragging:[sender draggingLocation]];
56 - (void)draggingExited:(id <NSDraggingInfo>)sender
58 [_mainController deleteSelectLayer:nil];
61 - (void)mouseDown:(NSEvent *)theEvent
63 NSPoint event_location = [theEvent locationInWindow];
64 NSPoint local_point = [self convertPoint:event_location fromView:nil];
66 if([self isInclude:leftCursorRect point:local_point])
67 [_timeLineController stretchLeft];
68 else if([self isInclude:rightCursorRect point:local_point])
69 [_timeLineController stretchRight];
71 [_timeLineController clicked:local_point];
74 - (void)mouseDragged:(NSEvent *)theEvent
76 NSPoint event_location = [theEvent locationInWindow];
77 NSPoint local_point = [self convertPoint:event_location fromView:nil];
78 [_timeLineController dragging:local_point];
81 - (void)mouseUp:(NSEvent *)theEvent
83 NSPoint event_location = [theEvent locationInWindow];
84 NSPoint local_point = [self convertPoint:event_location fromView:nil];
85 if([theEvent clickCount] == 2)
86 [_timeLineController doubleClicked];
88 [_timeLineController draggingDone];
91 - (void)setCursorRect:(CGRect)rect
93 leftCursorRect = NSMakeRect(rect.origin.x-4, rect.origin.y, 9, rect.size.height);
94 rightCursorRect = NSMakeRect(rect.origin.x+rect.size.width-4, rect.origin.y, 9, rect.size.height);
95 [self resetCursorRects];
98 - (void)resetCursorRects
100 [self addCursorRect:rightCursorRect cursor:[NSCursor resizeLeftRightCursor]];
101 [self addCursorRect:leftCursorRect cursor:[NSCursor resizeLeftRightCursor]];
104 - (BOOL)isInclude:(NSRect)r point:(NSPoint)point
106 return r.origin.x <= point.x && point.x <= r.origin.x + r.size.width
107 && r.origin.y <= point.y && point.y <= r.origin.y + r.size.height;