2011-01-19 23:19:43 +03:00
|
|
|
//
|
|
|
|
// PSMTabDragAssistant.h
|
|
|
|
// PSMTabBarControl
|
|
|
|
//
|
|
|
|
// Created by John Pannell on 4/10/06.
|
|
|
|
// Copyright 2006 Positive Spin Media. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
2011-01-26 13:52:13 +03:00
|
|
|
This class is a sigleton that manages the details of a tab drag and drop. The details were beginning to overwhelm me when keeping all of this in the control and cells :-)
|
2011-01-19 23:19:43 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "PSMTabBarControl.h"
|
|
|
|
|
|
|
|
#define kPSMTabDragAnimationSteps 8
|
|
|
|
|
|
|
|
@class PSMTabBarCell, PSMTabDragWindowController;
|
|
|
|
|
|
|
|
@interface PSMTabDragAssistant : NSObject {
|
2011-01-26 13:52:13 +03:00
|
|
|
PSMTabBarControl *_sourceTabBar;
|
|
|
|
PSMTabBarControl *_destinationTabBar;
|
|
|
|
NSMutableSet *_participatingTabBars;
|
|
|
|
PSMTabBarCell *_draggedCell;
|
2011-01-31 11:33:16 +03:00
|
|
|
NSUInteger _draggedCellIndex; // for snap back
|
2011-01-26 13:52:13 +03:00
|
|
|
BOOL _isDragging;
|
|
|
|
|
2011-01-19 23:19:43 +03:00
|
|
|
// Support for dragging into new windows
|
2011-01-26 13:52:13 +03:00
|
|
|
PSMTabDragWindowController *_draggedTab;
|
|
|
|
PSMTabDragWindowController *_draggedView;
|
|
|
|
NSSize _dragWindowOffset;
|
|
|
|
NSTimer *_fadeTimer;
|
|
|
|
BOOL _centersDragWindows;
|
|
|
|
PSMTabBarTearOffStyle _currentTearOffStyle;
|
|
|
|
|
|
|
|
// Animation
|
|
|
|
NSTimer *_animationTimer;
|
|
|
|
NSMutableArray *_sineCurveWidths;
|
|
|
|
NSPoint _currentMouseLoc;
|
|
|
|
PSMTabBarCell *_targetCell;
|
2011-01-19 23:19:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Creation/destruction
|
|
|
|
+ (PSMTabDragAssistant *)sharedDragAssistant;
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
- (PSMTabBarControl *)sourceTabBar;
|
|
|
|
- (void)setSourceTabBar:(PSMTabBarControl *)tabBar;
|
|
|
|
- (PSMTabBarControl *)destinationTabBar;
|
|
|
|
- (void)setDestinationTabBar:(PSMTabBarControl *)tabBar;
|
|
|
|
- (PSMTabBarCell *)draggedCell;
|
|
|
|
- (void)setDraggedCell:(PSMTabBarCell *)cell;
|
|
|
|
- (NSInteger)draggedCellIndex;
|
|
|
|
- (void)setDraggedCellIndex:(NSInteger)value;
|
|
|
|
- (BOOL)isDragging;
|
|
|
|
- (void)setIsDragging:(BOOL)value;
|
|
|
|
- (NSPoint)currentMouseLoc;
|
|
|
|
- (void)setCurrentMouseLoc:(NSPoint)point;
|
|
|
|
- (PSMTabBarCell *)targetCell;
|
|
|
|
- (void)setTargetCell:(PSMTabBarCell *)cell;
|
|
|
|
|
|
|
|
// Functionality
|
|
|
|
- (void)startDraggingCell:(PSMTabBarCell *)cell fromTabBar:(PSMTabBarControl *)control withMouseDownEvent:(NSEvent *)event;
|
|
|
|
- (void)draggingEnteredTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc;
|
|
|
|
- (void)draggingUpdatedInTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc;
|
|
|
|
- (void)draggingExitedTabBar:(PSMTabBarControl *)control;
|
|
|
|
- (void)performDragOperation;
|
2011-01-26 13:52:13 +03:00
|
|
|
- (void)draggedImageEndedAt:(NSPoint) aPoint operation:(NSDragOperation)operation;
|
2011-01-19 23:19:43 +03:00
|
|
|
- (void)finishDrag;
|
|
|
|
|
|
|
|
- (void)draggingBeganAt:(NSPoint)aPoint;
|
|
|
|
- (void)draggingMovedTo:(NSPoint)aPoint;
|
|
|
|
|
|
|
|
// Animation
|
|
|
|
- (void)animateDrag:(NSTimer *)timer;
|
|
|
|
- (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control;
|
|
|
|
|
|
|
|
// Placeholder
|
|
|
|
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control withDraggedCell:(PSMTabBarCell *)cell;
|
|
|
|
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control;
|
|
|
|
- (void)removeAllPlaceholdersFromTabBar:(PSMTabBarControl *)control;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface PSMTabBarControl (DragAccessors)
|
|
|
|
|
|
|
|
- (id<PSMTabStyle>)style;
|
|
|
|
- (NSMutableArray *)cells;
|
|
|
|
- (void)setControlView:(id)view;
|
2011-01-26 13:52:13 +03:00
|
|
|
- (id)cellForPoint:(NSPoint) point cellFrame:(NSRectPointer)outFrame;
|
2011-01-19 23:19:43 +03:00
|
|
|
- (PSMTabBarCell *)lastVisibleTab;
|
|
|
|
- (NSInteger)numberOfVisibleTabs;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
void CGContextCopyWindowCaptureContentsToRect(void *grafport, CGRect rect, NSInteger cid, NSInteger wid, NSInteger zero);
|
2011-01-26 13:52:13 +03:00
|
|
|
OSStatus CGSSetWindowTransform(NSInteger cid, NSInteger wid, CGAffineTransform transform);
|
2011-01-19 23:19:43 +03:00
|
|
|
|
|
|
|
@interface NSApplication (CoreGraphicsUndocumented)
|
|
|
|
- (NSInteger)contextID;
|
|
|
|
@end
|