Skip to content
Snippets Groups Projects
Commit 14cf193a authored by George Nachman's avatar George Nachman
Browse files

Clean up PSMTabBar code a bit. Replace deprecated dragging delegate methods with more modern ones.

parent f0afc876
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1371,7 +1371,7 @@ const NSInteger kPSMStartResizeAnimation = 0;
return YES;
}
 
// NSDraggingSource
#pragma mark NSDraggingSource
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
return (isLocal ? NSDragOperationMove : NSDragOperationNone);
Loading
Loading
@@ -1382,19 +1382,17 @@ const NSInteger kPSMStartResizeAnimation = 0;
return YES;
}
 
- (void)draggedImage:(NSImage *)anImage beganAt:(NSPoint)screenPoint
{
- (void)draggingSession:(NSDraggingSession *)session willBeginAtPoint:(NSPoint)screenPoint {
[[PSMTabDragAssistant sharedDragAssistant] draggingBeganAt:screenPoint];
}
 
- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint
{
- (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint {
[[PSMTabDragAssistant sharedDragAssistant] draggingMovedTo:screenPoint];
}
 
// NSDraggingDestination
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
#pragma mark NSDraggingDestination
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
if ([[[sender draggingPasteboard] types] indexOfObject:@"com.iterm2.psm.controlitem"] != NSNotFound) {
if ([[self delegate] respondsToSelector:@selector(tabView:shouldDropTabViewItem:inTabBar:)] &&
![[self delegate] tabView:[[sender draggingSource] tabView]
Loading
Loading
@@ -1417,8 +1415,7 @@ const NSInteger kPSMStartResizeAnimation = 0;
}
}
 
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender {
PSMTabBarCell *cell = [self cellForPoint:[self convertPoint:[sender draggingLocation] fromView:nil] cellFrame:nil];
 
if ([[[sender draggingPasteboard] types] indexOfObject:@"com.iterm2.psm.controlitem"] != NSNotFound) {
Loading
Loading
@@ -1445,13 +1442,11 @@ const NSInteger kPSMStartResizeAnimation = 0;
return NSDragOperationNone;
}
 
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
- (void)draggingExited:(id <NSDraggingInfo>)sender {
[[PSMTabDragAssistant sharedDragAssistant] draggingExitedTabBar:self];
}
 
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender {
// validate the drag operation only if there's a valid tab bar to drop into
BOOL badType = [[[sender draggingPasteboard] types] indexOfObject:@"com.iterm2.psm.controlitem"] == NSNotFound;
if (badType && [[self delegate] respondsToSelector:@selector(tabView:shouldAcceptDragFromSender:)] &&
Loading
Loading
@@ -1462,14 +1457,12 @@ const NSInteger kPSMStartResizeAnimation = 0;
[[PSMTabDragAssistant sharedDragAssistant] destinationTabBar] != nil;
}
 
- (BOOL)_delegateAcceptsSender:(id <NSDraggingInfo>)sender
{
- (BOOL)_delegateAcceptsSender:(id <NSDraggingInfo>)sender {
return [[self delegate] respondsToSelector:@selector(tabView:shouldAcceptDragFromSender:)] &&
[[self delegate] tabView:_tabView shouldAcceptDragFromSender:sender];
}
 
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
if ([[[sender draggingPasteboard] types] indexOfObject:@"com.iterm2.psm.controlitem"] != NSNotFound ||
[self _delegateAcceptsSender:sender]) {
[[PSMTabDragAssistant sharedDragAssistant] performDragOperation:sender];
Loading
Loading
@@ -1480,8 +1473,7 @@ const NSInteger kPSMStartResizeAnimation = 0;
return YES;
}
 
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
{
- (void)draggingSession:(NSDraggingSession *)session endedAtPoint:(NSPoint)aPoint operation:(NSDragOperation)operation {
if (operation != NSDragOperationNone) {
[self removeTabForCell:[[PSMTabDragAssistant sharedDragAssistant] draggedCell]];
[[PSMTabDragAssistant sharedDragAssistant] finishDrag];
Loading
Loading
@@ -1490,11 +1482,6 @@ const NSInteger kPSMStartResizeAnimation = 0;
}
}
 
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
}
#pragma mark -
#pragma mark Actions
 
Loading
Loading
Loading
Loading
@@ -20,25 +20,6 @@
#define PI 3.1417
 
@interface PSMTabDragAssistant : NSObject
{
PSMTabBarControl *_sourceTabBar;
PSMTabBarControl *_destinationTabBar;
NSMutableSet *_participatingTabBars;
PSMTabBarCell *_draggedCell;
int _draggedCellIndex; // for snap back
BOOL _isDragging;
// Support for dragging into new windows
PSMTabDragWindow *_dragTabWindow, *_dragViewWindow;
NSSize _dragWindowOffset;
NSTimer *_fadeTimer;
// Animation
NSTimer *_animationTimer;
NSMutableArray *_sineCurveWidths;
NSPoint _currentMouseLoc;
PSMTabBarCell *_targetCell;
}
 
// Creation/destruction
+ (PSMTabDragAssistant *)sharedDragAssistant;
Loading
Loading
Loading
Loading
@@ -11,40 +11,55 @@
#import "PSMTabStyle.h"
#import "PSMTabDragWindow.h"
 
@implementation PSMTabDragAssistant
@interface PSMTabDragAssistant()
@property (nonatomic, retain) PSMTabBarControl *sourceTabBar;
@property (nonatomic, retain) PSMTabBarControl *destinationTabBar;
@property (nonatomic, retain) PSMTabBarCell *draggedCell;
@property (nonatomic) int draggedCellIndex; // for snap back
@property (nonatomic) BOOL isDragging;
@property (nonatomic) NSPoint currentMouseLoc;
@property (nonatomic, retain) PSMTabBarCell *targetCell;
@end
@implementation PSMTabDragAssistant {
PSMTabBarControl *_destinationTabBar;
NSMutableSet *_participatingTabBars;
// Support for dragging into new windows
PSMTabDragWindow *_dragTabWindow, *_dragViewWindow;
NSSize _dragWindowOffset;
NSTimer *_fadeTimer;
 
static PSMTabDragAssistant *sharedDragAssistant = nil;
// Animation
NSTimer *_animationTimer;
NSMutableArray *_sineCurveWidths;
NSPoint _currentMouseLoc;
PSMTabBarCell *_targetCell;
}
 
#pragma mark -
#pragma mark Creation/Destruction
 
+ (PSMTabDragAssistant *)sharedDragAssistant
{
if (!sharedDragAssistant){
+ (PSMTabDragAssistant *)sharedDragAssistant {
static dispatch_once_t onceToken;
static PSMTabDragAssistant *sharedDragAssistant = nil;
dispatch_once(&onceToken, ^{
sharedDragAssistant = [[PSMTabDragAssistant alloc] init];
}
});
return sharedDragAssistant;
}
 
- (id)init
{
if ( (self = [super init]) ) {
_sourceTabBar = nil;
_destinationTabBar = nil;
- (instancetype)init {
self = [super init];
if (self) {
_participatingTabBars = [[NSMutableSet alloc] init];
_draggedCell = nil;
_animationTimer = nil;
_sineCurveWidths = [[NSMutableArray alloc] initWithCapacity:kPSMTabDragAnimationSteps];
_targetCell = nil;
_isDragging = NO;
}
 
return self;
}
 
- (void)dealloc
{
- (void)dealloc {
[_sourceTabBar release];
[_destinationTabBar release];
[_participatingTabBars release];
Loading
Loading
@@ -55,107 +70,31 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[super dealloc];
}
 
#pragma mark -
#pragma mark Accessors
- (PSMTabBarControl *)sourceTabBar
{
return _sourceTabBar;
}
- (void)setSourceTabBar:(PSMTabBarControl *)tabBar
{
[tabBar retain];
[_sourceTabBar release];
_sourceTabBar = tabBar;
}
- (PSMTabBarControl *)destinationTabBar
{
return _destinationTabBar;
}
- (void)setDestinationTabBar:(PSMTabBarControl *)tabBar
{
[tabBar retain];
[_destinationTabBar release];
_destinationTabBar = tabBar;
}
- (PSMTabBarCell *)draggedCell {
return _draggedCell;
}
- (void)setDraggedCell:(PSMTabBarCell *)cell {
[cell retain];
[_draggedCell release];
_draggedCell = cell;
}
- (int)draggedCellIndex
{
return _draggedCellIndex;
}
- (void)setDraggedCellIndex:(int)value
{
_draggedCellIndex = value;
}
- (BOOL)isDragging
{
return _isDragging;
}
- (void)setIsDragging:(BOOL)value
{
_isDragging = value;
}
- (NSPoint)currentMouseLoc
{
return _currentMouseLoc;
}
- (void)setCurrentMouseLoc:(NSPoint)point
{
_currentMouseLoc = point;
}
- (PSMTabBarCell *)targetCell
{
return _targetCell;
}
- (void)setTargetCell:(PSMTabBarCell *)cell
{
[cell retain];
[_targetCell release];
_targetCell = cell;
}
#pragma mark -
#pragma mark Functionality
 
- (void)addSineCurveWidthsWithOrientation:(PSMTabBarOrientation)orientation size:(NSSize)size
{
- (void)addSineCurveWidthsWithOrientation:(PSMTabBarOrientation)orientation size:(NSSize)size {
float cellStepSize = (orientation == PSMTabBarHorizontalOrientation) ? (size.width + 6) : (size.height + 1);
for (int i = 0; i < kPSMTabDragAnimationSteps - 1; i++) {
int thisWidth = (int)(cellStepSize - ((cellStepSize/2.0) + ((sin((PI/2.0) + ((float)i/(float)kPSMTabDragAnimationSteps)*PI) * cellStepSize) / 2.0)));
[_sineCurveWidths addObject:[NSNumber numberWithInt:thisWidth]];
[_sineCurveWidths addObject:@(thisWidth)];
}
[_sineCurveWidths addObject:[NSNumber numberWithInt:(orientation == PSMTabBarHorizontalOrientation) ? size.width : size.height]];
int width = (orientation == PSMTabBarHorizontalOrientation) ? size.width : size.height;
[_sineCurveWidths addObject:@(width)];
}
 
- (void)startAnimation
{
_animationTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0/30.0) target:self selector:@selector(animateDrag:) userInfo:nil repeats:YES];
- (void)startAnimation {
_animationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0
target:self
selector:@selector(animateDrag:)
userInfo:nil
repeats:YES];
}
 
- (void)startAnimationWithOrientation:(PSMTabBarOrientation)orientation width:(CGFloat)width
{
if ([_sineCurveWidths count] == 0) {
[self addSineCurveWidthsWithOrientation:orientation size:NSMakeSize(width, kPSMTabBarControlHeight)];
- (void)startAnimationWithOrientation:(PSMTabBarOrientation)orientation width:(CGFloat)width {
if (_sineCurveWidths.count == 0) {
[self addSineCurveWidthsWithOrientation:orientation
size:NSMakeSize(width, kPSMTabBarControlHeight)];
}
[self startAnimation];
}
Loading
Loading
@@ -184,13 +123,14 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[[cell indicator] removeFromSuperview];
[self distributePlaceholdersInTabBar:control withDraggedCell:cell];
 
if([control isFlipped]){
if ([control isFlipped]) {
cellFrame.origin.y += cellFrame.size.height;
}
[cell setHighlighted:NO];
[self startAnimation];
 
[[NSNotificationCenter defaultCenter] postNotificationName:PSMTabDragDidBeginNotification object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:PSMTabDragDidBeginNotification
object:nil];
 
// Retain the control in case the drag operation causes the control to be released
[control retain];
Loading
Loading
@@ -202,7 +142,9 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
NSImage *imageToDrag;
NSRect draggingRect;
 
_dragTabWindow = [[PSMTabDragWindow dragWindowWithTabBarCell:cell image:dragImage styleMask:NSBorderlessWindowMask] retain];
_dragTabWindow = [[PSMTabDragWindow dragWindowWithTabBarCell:cell
image:dragImage
styleMask:NSBorderlessWindowMask] retain];
[_dragTabWindow setAlphaValue:kPSMTabDragWindowAlpha];
[_dragTabWindow orderFront:nil];
 
Loading
Loading
@@ -225,8 +167,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[control release];
}
 
- (void)draggingEnteredTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc
{
- (void)draggingEnteredTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc {
if (!_animationTimer) {
[self startAnimation];
}
Loading
Loading
@@ -235,11 +176,12 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
// hide UI buttons
[[control overflowPopUpButton] setHidden:YES];
[[control addTabButton] setHidden:YES];
if([[control cells] count] == 0 || ![[[control cells] objectAtIndex:0] isPlaceholder])
if ([[control cells] count] == 0 || ![[[control cells] objectAtIndex:0] isPlaceholder]) {
[self distributePlaceholdersInTabBar:control];
}
[_participatingTabBars addObject:control];
 
//tell the drag window to display only the header if there is one
// Tell the drag window to display only the header if there is one.
if (_dragViewWindow) {
if (_fadeTimer) {
[_fadeTimer invalidate];
Loading
Loading
@@ -250,10 +192,10 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)draggingUpdatedInTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc
{
if([self destinationTabBar] != control)
- (void)draggingUpdatedInTabBar:(PSMTabBarControl *)control atPoint:(NSPoint)mouseLoc {
if ([self destinationTabBar] != control) {
[self setDestinationTabBar:control];
}
[self setCurrentMouseLoc:mouseLoc];
}
 
Loading
Loading
@@ -306,7 +248,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
 
[viewImage unlockFocus];
} else {
// the delegate doesn't give a custom image, so use an image of the view
// The delegate doesn't give a custom image, so use an image of the view.
NSView *tabView = [[[self draggedCell] representedObject] view];
viewImage = [[[NSImage alloc] initWithSize:[tabView frame].size] autorelease];
[viewImage lockFocus];
Loading
Loading
@@ -330,8 +272,9 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[_dragViewWindow setFrameTopLeftPoint:windowOrigin];
[_dragViewWindow orderWindow:NSWindowBelow relativeTo:[_dragTabWindow windowNumber]];
 
// set the window's alpha mask to zero if the last tab is being dragged
// don't fade out the old window if the delegate doesn't respond to the new tab bar method, just to be safe
// Set the window's alpha mask to zero if the last tab is being dragged.
// Don't fade out the old window if the delegate doesn't respond to the new tab bar method,
// just to be safe.
if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1 &&
[self sourceTabBar] == control &&
[[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:newTabBarForDraggedTabViewItem:atPoint:)]) {
Loading
Loading
@@ -351,7 +294,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
 
- (void)performDragOperation:(id<NSDraggingInfo>)sender {
// move cell
// Move cell.
int destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]];
 
//there is the slight possibility of the targetCell now being set properly, so avoid errors
Loading
Loading
@@ -373,7 +316,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
after = [cells objectAtIndex:destinationIndex + 1];
}
 
NSTabViewItem *newTabViewItem = [[[self destinationTabBar] delegate] tabView:[[self destinationTabBar] tabView] unknownObjectWasDropped:sender];
NSTabViewItem *newTabViewItem = [[[self destinationTabBar] delegate] tabView:[[self destinationTabBar] tabView]
unknownObjectWasDropped:sender];
cells = [[self destinationTabBar] cells];
if (!after) {
insertIndex = [cells count];
Loading
Loading
@@ -551,10 +495,11 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)finishDrag
{
if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 0 && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:closeWindowForLastTabViewItem:)]) {
[[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView] closeWindowForLastTabViewItem:[[self draggedCell] representedObject]];
- (void)finishDrag {
if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 0 &&
[[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:closeWindowForLastTabViewItem:)]) {
[[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView]
closeWindowForLastTabViewItem:[[self draggedCell] representedObject]];
}
 
if (_dragTabWindow) {
Loading
Loading
@@ -586,8 +531,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[self setTargetCell:nil];
}
 
- (void)draggingBeganAt:(NSPoint)aPoint
{
- (void)draggingBeganAt:(NSPoint)aPoint {
if (_dragTabWindow) {
[_dragTabWindow setFrameTopLeftPoint:aPoint];
 
Loading
Loading
@@ -598,8 +542,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)draggingMovedTo:(NSPoint)aPoint
{
- (void)draggingMovedTo:(NSPoint)aPoint {
if (_dragTabWindow) {
[_dragTabWindow setFrameTopLeftPoint:aPoint];
 
Loading
Loading
@@ -616,8 +559,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)fadeInDragWindow:(NSTimer *)timer
{
- (void)fadeInDragWindow:(NSTimer *)timer {
float value = [_dragViewWindow alphaValue];
if (value >= kPSMTabDragWindowAlpha || _dragTabWindow == nil) {
[timer invalidate];
Loading
Loading
@@ -628,8 +570,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)fadeOutDragWindow:(NSTimer *)timer
{
- (void)fadeOutDragWindow:(NSTimer *)timer {
float value = [_dragViewWindow alphaValue];
if (value <= 0.0) {
[_dragViewWindow setAlphaValue:0.0];
Loading
Loading
@@ -648,20 +589,22 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
#pragma mark -
#pragma mark Animation
 
- (void)animateDrag:(NSTimer *)timer
{
- (void)animateDrag:(NSTimer *)timer {
NSArray* objects = [_participatingTabBars allObjects];
for (int i = 0; i < [objects count]; ++i) {
PSMTabBarControl* tabBar = [objects objectAtIndex:i];
if ([_participatingTabBars containsObject:tabBar]) {
[self calculateDragAnimationForTabBar:tabBar];
[[NSRunLoop currentRunLoop] performSelector:@selector(display) target:tabBar argument:nil order:1 modes:[NSArray arrayWithObjects:@"NSEventTrackingRunLoopMode", @"NSDefaultRunLoopMode", nil]];
[[NSRunLoop currentRunLoop] performSelector:@selector(display)
target:tabBar
argument:nil
order:1
modes:@[ NSEventTrackingRunLoopMode, NSDefaultRunLoopMode ]];
}
}
}
 
- (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control
{
- (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control {
BOOL removeFlag = YES;
NSMutableArray *cells = [control cells];
int i, cellCount = [cells count];
Loading
Loading
@@ -677,7 +620,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
} else {
NSRect overCellRect;
PSMTabBarCell *overCell = [control cellForPoint:mouseLoc cellFrame:&overCellRect];
if(overCell){
if (overCell) {
// mouse among cells - placeholder
if ([overCell isPlaceholder]) {
[self setTargetCell:overCell];
Loading
Loading
@@ -709,12 +652,12 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
[self setTargetCell:nil];
}
 
for(i = 0; i < cellCount; i++){
for (i = 0; i < cellCount; i++) {
PSMTabBarCell *cell = [cells objectAtIndex:i];
NSRect newRect = [cell frame];
if(![cell isInOverflowMenu]){
if (![cell isInOverflowMenu]) {
if([cell isPlaceholder]){
if(cell == [self targetCell]){
if (cell == [self targetCell]) {
[cell setCurrentStep:([cell currentStep] + 1)];
} else {
[cell setCurrentStep:([cell currentStep] - 1)];
Loading
Loading
@@ -744,7 +687,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
if([cell indicator])
[[cell indicator] setFrame:[[control style] indicatorRectForTabCell:cell]];
}
if(removeFlag){
if (removeFlag) {
[_participatingTabBars removeObject:control];
[self removeAllPlaceholdersFromTabBar:control];
}
Loading
Loading
@@ -753,8 +696,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
#pragma mark -
#pragma mark Placeholders
 
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control withDraggedCell:(PSMTabBarCell *)cell
{
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control
withDraggedCell:(PSMTabBarCell *)cell {
// called upon first drag - must distribute placeholders
[self distributePlaceholdersInTabBar:control];
// replace dragged cell with a placeholder, and clean up surrounding cells
Loading
Loading
@@ -767,9 +710,9 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
return;
}
 
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control
{
int i, numVisibleTabs = [control numberOfVisibleTabs];
- (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control {
int i;
int numVisibleTabs = [control numberOfVisibleTabs];
PSMTabBarCell *draggedCell = [self draggedCell];
NSRect draggedCellFrame;
NSLineBreakMode truncationStyle;
Loading
Loading
@@ -780,7 +723,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
draggedCellFrame = [[[control cells] objectAtIndex:0] frame];
truncationStyle = [[[control cells] objectAtIndex:0] truncationStyle];
}
for(i = 0; i < numVisibleTabs; i++) {
for (i = 0; i < numVisibleTabs; i++) {
PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:draggedCellFrame expanded:NO inControlView:control] autorelease];
pc.truncationStyle = truncationStyle;
[[control cells] insertObject:pc atIndex:(2 * i)];
Loading
Loading
@@ -795,24 +738,30 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
}
 
- (void)removeAllPlaceholdersFromTabBar:(PSMTabBarControl *)control
{
- (void)removeAllPlaceholdersFromTabBar:(PSMTabBarControl *)control {
int i, cellCount = [[control cells] count];
for(i = (cellCount - 1); i >= 0; i--){
for (i = (cellCount - 1); i >= 0; i--) {
PSMTabBarCell *cell = [[control cells] objectAtIndex:i];
if([cell isPlaceholder])
if ([cell isPlaceholder])
[[control cells] removeObject:cell];
}
// redraw
[[NSRunLoop currentRunLoop] performSelector:@selector(update) target:control argument:nil order:1 modes:[NSArray arrayWithObjects:@"NSEventTrackingRunLoopMode", @"NSDefaultRunLoopMode", nil]];
[[NSRunLoop currentRunLoop] performSelector:@selector(display) target:control argument:nil order:1 modes:[NSArray arrayWithObjects:@"NSEventTrackingRunLoopMode", @"NSDefaultRunLoopMode", nil]];
[[NSRunLoop currentRunLoop] performSelector:@selector(update)
target:control
argument:nil
order:1
modes:@[ NSEventTrackingRunLoopMode, NSDefaultRunLoopMode ]];
[[NSRunLoop currentRunLoop] performSelector:@selector(display)
target:control
argument:nil
order:1
modes:@[ NSEventTrackingRunLoopMode, NSDefaultRunLoopMode ]];
}
 
#pragma mark -
#pragma mark Archiving
 
- (void)encodeWithCoder:(NSCoder *)aCoder {
//[super encodeWithCoder:aCoder];
if ([aCoder allowsKeyedCoding]) {
[aCoder encodeObject:_sourceTabBar forKey:@"sourceTabBar"];
[aCoder encodeObject:_destinationTabBar forKey:@"destinationTabBar"];
Loading
Loading
@@ -828,8 +777,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
}
 
- (id)initWithCoder:(NSCoder *)aDecoder {
//self = [super initWithCoder:aDecoder];
//if (self) {
self = [super init];
if (self) {
if ([aDecoder allowsKeyedCoding]) {
_sourceTabBar = [[aDecoder decodeObjectForKey:@"sourceTabBar"] retain];
_destinationTabBar = [[aDecoder decodeObjectForKey:@"destinationTabBar"] retain];
Loading
Loading
@@ -842,7 +791,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil;
_currentMouseLoc = [aDecoder decodePointForKey:@"currentMouseLoc"];
_targetCell = [[aDecoder decodeObjectForKey:@"targetCell"] retain];
}
//}
}
return self;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment