From 6fdc5d75e246d205ea97d65e7ddd8305df5003d8 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 3 Mar 2011 01:52:27 +0000 Subject: - Fix all warnings in the PSMTabBar framework, including a fix for a 10.5 dragging issue and implementing Safari-style fadeout of previous window shell when dragging the last miniwindow out of a tab bar --- Frameworks/PSMTabBar/NSBezierPath_AMShading.m | 4 +- Frameworks/PSMTabBar/PSMOverflowPopUpButton.h | 8 + Frameworks/PSMTabBar/PSMOverflowPopUpButton.m | 2 +- Frameworks/PSMTabBar/PSMProgressIndicator.h | 2 +- Frameworks/PSMTabBar/PSMRolloverButton.h | 3 +- Frameworks/PSMTabBar/PSMTabBarCell.m | 24 ++- Frameworks/PSMTabBar/PSMTabBarControl.h | 13 +- Frameworks/PSMTabBar/PSMTabBarControl.m | 62 ++++--- Frameworks/PSMTabBar/PSMTabBarController.h | 16 +- Frameworks/PSMTabBar/PSMTabBarController.m | 50 ++--- Frameworks/PSMTabBar/PSMTabDragAssistant.h | 5 +- Frameworks/PSMTabBar/PSMTabDragAssistant.m | 47 ++--- Frameworks/PSMTabBar/PSMTabDragView.m | 2 +- Frameworks/PSMTabBar/PSMTabDragWindowController.h | 5 +- Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m | 205 ++++++++++----------- 15 files changed, 244 insertions(+), 204 deletions(-) (limited to 'Frameworks') diff --git a/Frameworks/PSMTabBar/NSBezierPath_AMShading.m b/Frameworks/PSMTabBar/NSBezierPath_AMShading.m index 73213f3b..b878688d 100755 --- a/Frameworks/PSMTabBar/NSBezierPath_AMShading.m +++ b/Frameworks/PSMTabBar/NSBezierPath_AMShading.m @@ -23,7 +23,7 @@ static void linearShadedColor(void *info, const CGFloat *in, CGFloat *out) static void bilinearShadedColor(void *info, const CGFloat *in, CGFloat *out) { CGFloat *colors = (CGFloat *)info; - CGFloat factor = (*in)*2.0; + CGFloat factor = (*in)*2.0f; if (*in > 0.5) { factor = 2-factor; } @@ -87,7 +87,7 @@ static void bilinearShadedColor(void *info, const CGFloat *in, CGFloat *out) // draw gradient colorspace = CGColorSpaceCreateDeviceRGB(); size_t components = 1 + CGColorSpaceGetNumberOfComponents(colorspace); - static const CGFloat domain[2] = {0.0, 1.0}; + static const CGFloat domain[2] = {0.0f, 1.0f}; static const CGFloat range[10] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; //static const CGFunctionCallbacks callbacks = {0, &bilinearShadedColor, NULL}; diff --git a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h index 19ce95f1..b513865e 100644 --- a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h +++ b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.h @@ -22,6 +22,14 @@ - (BOOL)animatingAlternateImage; - (void)setAnimatingAlternateImage:(BOOL)flag; +// Notifications +- (void)notificationReceived:(NSNotification *)notification; + +// Animations +- (void)setAnimatingAlternateImage:(BOOL)flag; +- (BOOL)animatingAlternateImage; +- (void)animateStep:(NSTimer *)timer; + // archiving - (void)encodeWithCoder:(NSCoder *)aCoder; - (id)initWithCoder:(NSCoder *)aDecoder; diff --git a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m index bef8b4ff..8ce50464 100644 --- a/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m +++ b/Frameworks/PSMTabBar/PSMOverflowPopUpButton.m @@ -63,7 +63,7 @@ drawPoint.y += altImageSize.height; } - [[self alternateImage] compositeToPoint:drawPoint operation:NSCompositeSourceOver fraction:sin(_animationValue * M_PI)]; + [[self alternateImage] compositeToPoint:drawPoint operation:NSCompositeSourceOver fraction:sinf(_animationValue * (float)M_PI)]; } } diff --git a/Frameworks/PSMTabBar/PSMProgressIndicator.h b/Frameworks/PSMTabBar/PSMProgressIndicator.h index 8f56bd73..8c34e444 100644 --- a/Frameworks/PSMTabBar/PSMProgressIndicator.h +++ b/Frameworks/PSMTabBar/PSMProgressIndicator.h @@ -20,4 +20,4 @@ - (void)update; -@end \ No newline at end of file +@end diff --git a/Frameworks/PSMTabBar/PSMRolloverButton.h b/Frameworks/PSMTabBar/PSMRolloverButton.h index d78b47c2..3c175119 100644 --- a/Frameworks/PSMTabBar/PSMRolloverButton.h +++ b/Frameworks/PSMTabBar/PSMRolloverButton.h @@ -24,6 +24,7 @@ - (NSImage *)rolloverImage; // tracking rect for mouse events +- (void)rolloverFrameDidChange:(NSNotification *)inNotification; - (void)addTrackingRect; - (void)removeTrackingRect; -@end \ No newline at end of file +@end diff --git a/Frameworks/PSMTabBar/PSMTabBarCell.m b/Frameworks/PSMTabBar/PSMTabBarCell.m index 5d585359..809d9061 100644 --- a/Frameworks/PSMTabBar/PSMTabBarCell.m +++ b/Frameworks/PSMTabBar/PSMTabBarCell.m @@ -28,7 +28,7 @@ _cellTrackingTag = 0; _closeButtonOver = NO; _closeButtonPressed = NO; - _indicator = [[PSMProgressIndicator alloc] initWithFrame:NSMakeRect(0.0,0.0,kPSMTabBarIndicatorWidth,kPSMTabBarIndicatorWidth)]; + _indicator = [[PSMProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f,0.0f,kPSMTabBarIndicatorWidth,kPSMTabBarIndicatorWidth)]; [_indicator setStyle:NSProgressIndicatorSpinningStyle]; [_indicator setAutoresizingMask:NSViewMinYMargin]; _hasCloseButton = YES; @@ -48,9 +48,9 @@ _isPlaceholder = YES; if (!value) { if ([controlView orientation] == PSMTabBarHorizontalOrientation) { - frame.size.width = 0.0; + frame.size.width = 0.0f; } else { - frame.size.height = 0.0; + frame.size.height = 0.0f; } } [self setFrame:frame]; @@ -348,7 +348,7 @@ { if (_isPlaceholder) { if (![_controlView usesSafariStyleDragging]) { - [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2f] set]; + [[NSColor colorWithCalibratedWhite:0.0f alpha:0.2f] set]; NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop); } return; @@ -373,7 +373,7 @@ // scrubtastic if ([_controlView allowsScrubbing] && ([theEvent modifierFlags] & NSAlternateKeyMask)) - [_controlView performSelector:@selector(tabClick:) withObject:self]; + [_controlView tabClick:self]; // tell the control we only need to redraw the affected tab [_controlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)]; @@ -410,7 +410,13 @@ // Draw the tab into a new image NSImage *image = [[[NSImage alloc] initWithSize:cellFrame.size] autorelease]; + +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + [image setFlipped:YES]; + [image lockFocus]; +#else [image lockFocusFlipped:YES]; +#endif [self setFrame:tabDrawFrame]; [(id )[(PSMTabBarControl *)_controlView style] drawTabCell:self]; [self setFrame:oldFrame]; @@ -418,12 +424,12 @@ // Add the indicator if appropriate if (![[self indicator] isHidden]) { - NSImage *pi = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"pi"]]; + NSImage *pieImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"pi"]]; [image lockFocus]; NSPoint indicatorPoint = NSMakePoint([self frame].size.width - MARGIN_X - kPSMTabBarIndicatorWidth, MARGIN_Y); - [pi compositeToPoint:indicatorPoint operation:NSCompositeSourceOver fraction:1.0]; + [pieImage compositeToPoint:indicatorPoint operation:NSCompositeSourceOver fraction:1.0f]; [image unlockFocus]; - [pi release]; + [pieImage release]; } return image; @@ -528,7 +534,7 @@ - (void)accessibilityPerformAction:(NSString *)action { if ([action isEqualToString:NSAccessibilityPressAction]) { // this tab was selected - [_controlView performSelector:@selector(tabClick:) withObject:self]; + [_controlView tabClick:self]; } } diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h index 2ac8474a..cd2b5025 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.h +++ b/Frameworks/PSMTabBar/PSMTabBarControl.h @@ -23,9 +23,9 @@ #define kPSMTabBarCellPadding 4 // fixed size objects #define kPSMMinimumTitleWidth 30 -#define kPSMTabBarIndicatorWidth 16.0 -#define kPSMTabBarIconWidth 16.0 -#define kPSMHideAnimationSteps 3.0 +#define kPSMTabBarIndicatorWidth 16.0f +#define kPSMTabBarIconWidth 16.0f +#define kPSMHideAnimationSteps 3.0f // Value used in _currentStep to indicate that resizing operation is not in progress #define kPSMIsNotBeingResized -1 @@ -185,9 +185,13 @@ enum { - (PSMRolloverButton *)addTabButton; - (PSMOverflowPopUpButton *)overflowPopUpButton; +// actions +- (void)tabClick:(id)sender; +- (void)overflowMenuAction:(id)sender; + // tab information - (NSMutableArray *)representedTabViewItems; -- (NSInteger)numberOfVisibleTabs; +- (NSUInteger)numberOfVisibleTabs; - (PSMTabBarCell *)lastVisibleTab; // special effects @@ -221,6 +225,7 @@ enum { - (BOOL)tabView:(NSTabView *)aTabView shouldAllowTabViewItem:(NSTabViewItem *)tabViewItem toLeaveTabBar:(PSMTabBarControl *)tabBarControl; - (void)tabView:(NSTabView*)aTabView didDropTabViewItem:(NSTabViewItem *)tabViewItem inTabBar:(PSMTabBarControl *)tabBarControl; - (void)draggingEvent:(id )dragEvent enteredTabBar:(PSMTabBarControl *)tabBarControl tabView:(NSTabViewItem *)tabViewItem; +- (void)tabViewDragWindowCreated:(NSWindow *)dragWindow; //Tear-off tabs methods - (NSImage *)tabView:(NSTabView *)aTabView imageForTabViewItem:(NSTabViewItem *)tabViewItem offset:(NSSize *)offset styleMask:(NSUInteger *)styleMask; diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m index 8debd774..231f3e3c 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.m +++ b/Frameworks/PSMTabBar/PSMTabBarControl.m @@ -44,15 +44,14 @@ - (void)_checkWindowFrame; // actions -- (void)overflowMenuAction:(id)sender; - (void)closeTabClick:(id)sender; -- (void)tabClick:(id)sender; - (void)tabNothing:(id)sender; // notification handlers - (void)frameDidChange:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)aNotification; - (void)windowDidUpdate:(NSNotification *)notification; +- (void)windowStatusDidChange:(NSNotification *)notification; // NSTabView delegate - (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem; @@ -68,6 +67,8 @@ - (void)_bindPropertiesForCell:(PSMTabBarCell *)cell andTabViewItem:(NSTabViewItem *)item; - (id)cellForPoint:(NSPoint)point cellFrame:(NSRectPointer)outFrame; +- (void)fireSpring:(NSTimer *)timer; +- (void)animateShowHide:(NSTimer *)timer; - (void)_animateCells:(NSTimer *)timer; @end @@ -105,7 +106,7 @@ { NSRect aRect=[self frame]; aRect.origin.x = [style leftMarginForTabBarControl]; - aRect.origin.y = 0.0; + aRect.origin.y = 0.0f; aRect.size.width = [self availableCellWidth]; aRect.size.height = [style tabCellHeight]; return aRect; @@ -153,7 +154,7 @@ [self _positionOverflowMenu]; // new tab button - NSRect addTabButtonRect = NSMakeRect([self frame].size.width - [style rightMarginForTabBarControl] + 1, 3.0, 16.0, 16.0); + NSRect addTabButtonRect = NSMakeRect([self frame].size.width - [style rightMarginForTabBarControl] + 1, 3.0f, 16.0f, 16.0f); _addTabButton = [[PSMRolloverButton alloc] initWithFrame:addTabButtonRect]; if (_addTabButton) { NSImage *newButtonImage = [style addTabButtonImage]; @@ -682,7 +683,7 @@ // add to collection [_cells addObject:cell]; [cell release]; - if ([_cells count] == [tabView numberOfTabViewItems]) { + if ((NSInteger)[_cells count] == [tabView numberOfTabViewItems]) { [self update]; // don't update unless all are accounted for! } } @@ -714,7 +715,7 @@ } if ([item identifier] != nil) { - if ([[item identifier] respondsToSelector:@selector(objectCount)]) { + if ([[item identifier] respondsToSelector:@selector(count)]) { [[item identifier] removeObserver:cell forKeyPath:@"objectCount"]; } } @@ -947,10 +948,10 @@ // moves the frame of the tab bar and window (or partner view) linearly to hide or show the tab bar NSRect myFrame = [self frame]; NSDictionary *userInfo = [timer userInfo]; - CGFloat myCurrentOrigin = ([[userInfo objectForKey:@"myOriginalOrigin"] doubleValue] + (([[userInfo objectForKey:@"myTargetOrigin"] doubleValue] - [[userInfo objectForKey:@"myOriginalOrigin"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat myCurrentSize = ([[userInfo objectForKey:@"myOriginalSize"] doubleValue] + (([[userInfo objectForKey:@"myTargetSize"] doubleValue] - [[userInfo objectForKey:@"myOriginalSize"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat partnerCurrentOrigin = ([[userInfo objectForKey:@"partnerOriginalOrigin"] doubleValue] + (([[userInfo objectForKey:@"partnerTargetOrigin"] doubleValue] - [[userInfo objectForKey:@"partnerOriginalOrigin"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); - CGFloat partnerCurrentSize = ([[userInfo objectForKey:@"partnerOriginalSize"] doubleValue] + (([[userInfo objectForKey:@"partnerTargetSize"] doubleValue] - [[userInfo objectForKey:@"partnerOriginalSize"] doubleValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat myCurrentOrigin = ([[userInfo objectForKey:@"myOriginalOrigin"] floatValue] + (([[userInfo objectForKey:@"myTargetOrigin"] floatValue] - [[userInfo objectForKey:@"myOriginalOrigin"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat myCurrentSize = ([[userInfo objectForKey:@"myOriginalSize"] floatValue] + (([[userInfo objectForKey:@"myTargetSize"] floatValue] - [[userInfo objectForKey:@"myOriginalSize"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat partnerCurrentOrigin = ([[userInfo objectForKey:@"partnerOriginalOrigin"] floatValue] + (([[userInfo objectForKey:@"partnerTargetOrigin"] floatValue] - [[userInfo objectForKey:@"partnerOriginalOrigin"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); + CGFloat partnerCurrentSize = ([[userInfo objectForKey:@"partnerOriginalSize"] floatValue] + (([[userInfo objectForKey:@"partnerTargetSize"] floatValue] - [[userInfo objectForKey:@"partnerOriginalSize"] floatValue]) * (_currentStep/kPSMHideAnimationSteps))); NSRect myNewFrame; if ([self orientation] == PSMTabBarHorizontalOrientation) { @@ -1053,7 +1054,7 @@ { // make sure all of our tabs are accounted for before updating, // or only proceed if a drag is in progress (where counts may mismatch) - if ([[self tabView] numberOfTabViewItems] != [_cells count] && ![[PSMTabDragAssistant sharedDragAssistant] isDragging]) { + if ([[self tabView] numberOfTabViewItems] != (NSInteger)[_cells count] && ![[PSMTabDragAssistant sharedDragAssistant] isDragging]) { return; } @@ -1082,7 +1083,7 @@ if (animate) { NSMutableArray *targetFrames = [NSMutableArray arrayWithCapacity:[_cells count]]; - for (NSInteger i = 0; i < [_cells count]; i++) { + for (NSUInteger i = 0; i < [_cells count]; i++) { currentCell = [_cells objectAtIndex:i]; //we're going from NSRect -> NSValue -> NSRect -> NSValue here - oh well @@ -1104,7 +1105,7 @@ [self _animateCells:_animationTimer]; } else { - for (NSInteger i = 0; i < [_cells count]; i++) { + for (NSUInteger i = 0; i < [_cells count]; i++) { currentCell = [_cells objectAtIndex:i]; [currentCell setFrame:[_controller cellFrameAtIndex:i]]; @@ -1124,11 +1125,11 @@ NSAnimation *animation = [[timer userInfo] objectAtIndex:1]; NSArray *targetFrames = [[timer userInfo] objectAtIndex:0]; PSMTabBarCell *currentCell; - NSInteger cellCount = [_cells count]; + NSUInteger cellCount = (NSUInteger)[_cells count]; if ((cellCount > 0) && [animation isAnimating]) { //compare our target position with the current position and move towards the target - for (NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { + for (NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { currentCell = [_cells objectAtIndex:i]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; CGFloat sizeChange; @@ -1164,8 +1165,8 @@ } else { //put all the cells where they should be in their final position if (cellCount > 0) { - for (NSInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { - PSMTabBarCell *currentCell = [_cells objectAtIndex:i]; + for (NSUInteger i = 0; i < [targetFrames count] && i < cellCount; i++) { + currentCell = [_cells objectAtIndex:i]; NSRect cellFrame = [currentCell frame], targetFrame = [[targetFrames objectAtIndex:i] rectValue]; if ([self orientation] == PSMTabBarHorizontalOrientation) { @@ -1196,7 +1197,7 @@ [_animationTimer invalidate]; [_animationTimer release]; _animationTimer = nil; - for (NSInteger i = 0; i < cellCount; i++) { + for (NSUInteger i = 0; i < cellCount; i++) { currentCell = [_cells objectAtIndex:i]; //we've hit the cells that are in overflow, stop setting up tracking rects @@ -1217,8 +1218,9 @@ // Skip tracking rects for placeholders - not required. if ([cell isPlaceholder]) return; - NSInteger tag, index = [_cells indexOfObject:cell]; - NSRect cellTrackingRect = [_controller cellTrackingRectAtIndex:index]; + NSInteger tag; + NSUInteger anIndex = [_cells indexOfObject:cell]; + NSRect cellTrackingRect = [_controller cellTrackingRectAtIndex:anIndex]; NSPoint mousePoint = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil]; BOOL mouseInCell = NSMouseInRect(mousePoint, cellTrackingRect, [self isFlipped]); @@ -1232,7 +1234,7 @@ [cell setHighlighted:mouseInCell]; if ([cell hasCloseButton] && ![cell isCloseButtonSuppressed]) { - NSRect closeRect = [_controller closeButtonTrackingRectAtIndex:index]; + NSRect closeRect = [_controller closeButtonTrackingRectAtIndex:anIndex]; BOOL mouseInCloseRect = NSMouseInRect(mousePoint, closeRect, [self isFlipped]); //set the close button tracking rect @@ -1390,9 +1392,9 @@ return; } - CGFloat dx = fabs(currentPoint.x - trackingStartPoint.x); - CGFloat dy = fabs(currentPoint.y - trackingStartPoint.y); - CGFloat distance = sqrt(dx * dx + dy * dy); + CGFloat dx = fabsf(currentPoint.x - trackingStartPoint.x); + CGFloat dy = fabsf(currentPoint.y - trackingStartPoint.y); + CGFloat distance = sqrtf(dx * dx + dy * dy); if (distance >= 10 && !_didDrag && ![[PSMTabDragAssistant sharedDragAssistant] isDragging] && [self delegate] && [[self delegate] respondsToSelector:@selector(tabView:shouldDragTabViewItem:fromTabBar:)] && @@ -1815,7 +1817,7 @@ // message, thus I can end up updating when there are no cells, if no tabs were (yet) present NSInteger tabIndex = [aTabView indexOfTabViewItem:tabViewItem]; - if ([_cells count] > 0 && tabIndex < [_cells count]) { + if ([_cells count] > 0 && tabIndex < (NSInteger)[_cells count]) { PSMTabBarCell *thisCell = [_cells objectAtIndex:tabIndex]; if (_alwaysShowActiveTab && [thisCell isInOverflowMenu]) { @@ -2002,12 +2004,12 @@ - (NSSize)minimumFrameSizeFromKnobPosition:(NSInteger)position { - return NSMakeSize(100.0, 22.0); + return NSMakeSize(100.0f, 22.0f); } - (NSSize)maximumFrameSizeFromKnobPosition:(NSInteger)knobPosition { - return NSMakeSize(10000.0, 22.0); + return NSMakeSize(10000.0f, 22.0f); } - (void)placeView:(NSRect)newFrame @@ -2056,7 +2058,7 @@ // bind for the existence of a counter [cell setCount:0]; if ([item identifier] != nil) { - if ([[[cell representedObject] identifier] respondsToSelector:@selector(objectCount)]) { + if ([[[cell representedObject] identifier] respondsToSelector:@selector(count)]) { [cell bind:@"count" toObject:[item identifier] withKeyPath:@"objectCount" options:nil]; [[item identifier] addObserver:cell forKeyPath:@"objectCount" options:0 context:nil]; } @@ -2138,9 +2140,9 @@ return [_cells objectAtIndex:(cellCount - 1)]; } -- (NSInteger)numberOfVisibleTabs +- (NSUInteger)numberOfVisibleTabs { - NSInteger i, cellCount = 0; + NSUInteger i, cellCount = 0; PSMTabBarCell *nextCell; for (i = 0; i < [_cells count]; i++) { diff --git a/Frameworks/PSMTabBar/PSMTabBarController.h b/Frameworks/PSMTabBar/PSMTabBarController.h index c675b981..3f8b4787 100644 --- a/Frameworks/PSMTabBar/PSMTabBarController.h +++ b/Frameworks/PSMTabBar/PSMTabBarController.h @@ -22,12 +22,22 @@ - (NSRect)addButtonRect; - (NSMenu *)overflowMenu; -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index; -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index; -- (NSRect)cellFrameAtIndex:(NSInteger)index; +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)anIndex; +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)anIndex; +- (NSRect)cellFrameAtIndex:(NSUInteger)anIndex; - (void)setSelectedCell:(PSMTabBarCell *)cell; - (void)layoutCells; @end + +@interface NSObject (TabRepresentedObjectIdentifierMethods) + +// Method for generating a tooltip for a tab +- (NSString *)tabTitleForTooltip; + +// Retrieving whether a tab is working +- (BOOL)isProcessing; + +@end diff --git a/Frameworks/PSMTabBar/PSMTabBarController.m b/Frameworks/PSMTabBar/PSMTabBarController.m index 04e1ec69..4ab2c1ef 100644 --- a/Frameworks/PSMTabBar/PSMTabBarController.m +++ b/Frameworks/PSMTabBar/PSMTabBarController.m @@ -83,13 +83,13 @@ @returns The tracking rect of the cell at the requested index. */ -- (NSRect)cellTrackingRectAtIndex:(NSInteger)index +- (NSRect)cellTrackingRectAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_cellTrackingRects count]) { - rect = [[_cellTrackingRects objectAtIndex:index] rectValue]; + if (anIndex < [_cellTrackingRects count]) { + rect = [[_cellTrackingRects objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"cellTrackingRectAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -103,13 +103,13 @@ @returns The close button tracking rect of the cell at the requested index. */ -- (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index +- (NSRect)closeButtonTrackingRectAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_closeButtonTrackingRects count]) { - rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue]; + if (anIndex < [_closeButtonTrackingRects count]) { + rect = [[_closeButtonTrackingRects objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -123,14 +123,14 @@ @returns The frame of the cell at the requested index. */ -- (NSRect)cellFrameAtIndex:(NSInteger)index +- (NSRect)cellFrameAtIndex:(NSUInteger)anIndex { NSRect rect; - if (index > -1 && index < [_cellFrames count]) { - rect = [[_cellFrames objectAtIndex:index] rectValue]; + if (anIndex < [_cellFrames count]) { + rect = [[_cellFrames objectAtIndex:anIndex] rectValue]; } else { - NSLog(@"cellFrameAtIndex: Invalid index (%ld)", (long)index); + NSLog(@"cellFrameAtIndex: Invalid index (%lu)", (unsigned long)anIndex); rect = NSZeroRect; } return rect; @@ -169,7 +169,7 @@ [cell setTabState:PSMTab_SelectedMask]; if (![cell isInOverflowMenu]) { - NSInteger cellIndex = [cells indexOfObject:cell]; + NSUInteger cellIndex = [cells indexOfObject:cell]; if (cellIndex > 0) { nextCell = [cells objectAtIndex:cellIndex - 1]; @@ -214,10 +214,10 @@ _addButtonRect.size = [[_control addTabButton] frame].size; if ([_control orientation] == PSMTabBarHorizontalOrientation) { _addButtonRect.origin.y = MARGIN_Y; - _addButtonRect.origin.x += [[cellWidths valueForKeyPath:@"@sum.floatValue"] doubleValue] + MARGIN_X; + _addButtonRect.origin.x += [[cellWidths valueForKeyPath:@"@sum.floatValue"] floatValue] + MARGIN_X; } else { _addButtonRect.origin.x = 0; - _addButtonRect.origin.y = [[cellWidths lastObject] doubleValue]; + _addButtonRect.origin.y = [[cellWidths lastObject] floatValue]; } } @@ -241,7 +241,7 @@ NSInteger q = 0; for (q = (count - 1); q >= 0; q--) { - CGFloat cellWidth = [[newWidths objectAtIndex:q] doubleValue]; + CGFloat cellWidth = [[newWidths objectAtIndex:q] floatValue]; if (cellWidth - 1 >= minimum) { cellWidth--; totalWidths--; @@ -296,7 +296,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) NSInteger cellCount = [cells count], i, numberOfVisibleCells = ([_control orientation] == PSMTabBarHorizontalOrientation) ? 1 : 0; NSMutableArray *newWidths = [NSMutableArray arrayWithCapacity:cellCount]; id style = [_control style]; - CGFloat availableWidth = [_control availableCellWidth], currentOrigin = 0, totalOccupiedWidth = 0.0, width; + CGFloat availableWidth = [_control availableCellWidth], currentOrigin = 0, totalOccupiedWidth = 0.0f, width; NSRect cellRect = [_control genericCellRect], controlRect = [_control frame]; PSMTabBarCell *currentCell; @@ -329,7 +329,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) width = [_control cellOptimumWidth]; } - width = ceil(width); + width = ceilf(width); //check to see if there is not enough space to place all tabs as preferred if (totalOccupiedWidth + width >= availableWidth) { @@ -498,11 +498,11 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) cellWidth = [NSNumber numberWithDouble:[cell1 desiredWidthOfCell] < availableWidth * 0.5f ? [cell1 desiredWidthOfCell] : availableWidth * 0.5f]; [newWidths addObject:cellWidth]; - totalOccupiedWidth += [cellWidth doubleValue]; + totalOccupiedWidth += [cellWidth floatValue]; cellWidth = [NSNumber numberWithDouble:[cell2 desiredWidthOfCell] < (availableWidth - totalOccupiedWidth) ? [cell2 desiredWidthOfCell] : (availableWidth - totalOccupiedWidth)]; [newWidths addObject:cellWidth]; - totalOccupiedWidth += [cellWidth doubleValue]; + totalOccupiedWidth += [cellWidth floatValue]; if (totalOccupiedWidth < availableWidth) { [newWidths replaceObjectAtIndex:0 withObject:[NSNumber numberWithDouble:availableWidth - [cellWidth doubleValue]]]; @@ -523,7 +523,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) - (void)_setupCells:(NSArray *)cells withWidths:(NSArray *)widths { - NSInteger i, tabState, cellCount = [cells count]; + NSUInteger i, tabState, cellCount = [cells count]; NSRect cellRect = [_control genericCellRect]; PSMTabBarCell *cell; NSTabViewItem *selectedTabViewItem = [[_control tabView] selectedTabViewItem]; @@ -539,10 +539,10 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) // set cell frame if ([_control orientation] == PSMTabBarHorizontalOrientation) { - cellRect.size.width = [[widths objectAtIndex:i] doubleValue]; + cellRect.size.width = [[widths objectAtIndex:i] floatValue]; } else { cellRect.size.width = [_control frame].size.width; - cellRect.origin.y = [[widths objectAtIndex:i] doubleValue]; + cellRect.origin.y = [[widths objectAtIndex:i] floatValue]; cellRect.origin.x = 0; } @@ -589,7 +589,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) } // next... - cellRect.origin.x += [[widths objectAtIndex:i] doubleValue]; + cellRect.origin.x += [[widths objectAtIndex:i] floatValue]; } else { [cell setState:NSOffState]; [cell setIsInOverflowMenu:YES]; @@ -625,7 +625,7 @@ static NSInteger potentialMinimumForArray(NSArray *array, NSInteger minimum) } } -- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)menuItem atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel +- (BOOL)menu:(NSMenu *)menu updateItem:(NSMenuItem *)menuItem atIndex:(NSInteger)anIndex shouldCancel:(BOOL)shouldCancel { if (menu == _overflowMenu) { if ([[[menuItem representedObject] identifier] respondsToSelector:@selector(icon)]) { diff --git a/Frameworks/PSMTabBar/PSMTabDragAssistant.h b/Frameworks/PSMTabBar/PSMTabDragAssistant.h index 2f42c573..92a8d4d8 100644 --- a/Frameworks/PSMTabBar/PSMTabDragAssistant.h +++ b/Frameworks/PSMTabBar/PSMTabDragAssistant.h @@ -70,6 +70,9 @@ - (void)draggingBeganAt:(NSPoint)aPoint; - (void)draggingMovedTo:(NSPoint)aPoint; +- (void)fadeInDragWindow:(NSTimer *)timer; +- (void)fadeOutDragWindow:(NSTimer *)timer; + // Animation - (void)animateDrag:(NSTimer *)timer; - (void)calculateDragAnimationForTabBar:(PSMTabBarControl *)control; @@ -88,7 +91,7 @@ - (void)setControlView:(id)view; - (id)cellForPoint:(NSPoint)point cellFrame:(NSRectPointer)outFrame; - (PSMTabBarCell *)lastVisibleTab; -- (NSInteger)numberOfVisibleTabs; +- (NSUInteger)numberOfVisibleTabs; @end diff --git a/Frameworks/PSMTabBar/PSMTabDragAssistant.m b/Frameworks/PSMTabBar/PSMTabDragAssistant.m index 2b670b67..5d5b7fcc 100644 --- a/Frameworks/PSMTabBar/PSMTabDragAssistant.m +++ b/Frameworks/PSMTabBar/PSMTabDragAssistant.m @@ -21,6 +21,7 @@ - (NSImage *)_imageForViewOfCell:(PSMTabBarCell *)cell styleMask:(NSUInteger *)outMask; - (NSImage *)_miniwindowImageOfWindow:(NSWindow *)window; - (void)_expandWindow:(NSWindow *)window atPoint:(NSPoint)point; +- (void)_expandWindowTimerFired:(NSTimer *)timer; @end @implementation PSMTabDragAssistant @@ -284,7 +285,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; } [self setDestinationTabBar:nil]; - [self setCurrentMouseLoc:NSMakePoint(-1.0, -1.0)]; + [self setCurrentMouseLoc:NSMakePoint(-1.0f, -1.0f)]; if (_fadeTimer) { [_fadeTimer invalidate]; @@ -297,7 +298,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSImage *viewImage = [self _imageForViewOfCell:[self draggedCell] styleMask:&styleMask]; _draggedView = [[PSMTabDragWindowController alloc] initWithImage:viewImage styleMask:styleMask tearOffStyle:PSMTabBarTearOffAlphaWindow initialAlpha:[control usesSafariStyleDragging]?1:kPSMTabDragWindowAlpha]; - [[_draggedView window] setAlphaValue:0.0]; + [[_draggedView window] setAlphaValue:0.0f]; // Inform the delegate a new drag window was created to allow any changes if ([control delegate] && [[control delegate] respondsToSelector:@selector(tabViewDragWindowCreated:)]) { @@ -335,12 +336,13 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; //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:)]) { - [[[self sourceTabBar] window] setAlphaValue:0.0]; + [[[self sourceTabBar] window] setAlphaValue:0.0f]; if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { [[_draggedView window] setAlphaValue:kPSMTabDragWindowAlpha]; } else { - #warning fix me - what should we do when the last tab is dragged as a miniwindow? + [_draggedTab switchImages]; + _centersDragWindows = YES; } } else { if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { @@ -356,7 +358,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; - (void)performDragOperation { // move cell - NSInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]]; + NSUInteger destinationIndex = [[[self destinationTabBar] cells] indexOfObject:[self targetCell]]; //there is the slight possibility of the targetCell now being set properly, so avoid errors if (destinationIndex >= [[[self destinationTabBar] cells] count]) { @@ -374,7 +376,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; [[self sourceTabBar] removeTrackingRect:[[self draggedCell] cellTrackingTag]]; [[self sourceTabBar] removeTabForCell:[self draggedCell]]; - NSInteger i, insertIndex; + NSUInteger i; + NSInteger insertIndex; NSArray *cells = [[self destinationTabBar] cells]; //find the index of where the dragged cell was just dropped @@ -409,25 +412,25 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSTabView *tabView = [[self sourceTabBar] tabView]; NSTabViewItem *item = [[self draggedCell] representedObject]; BOOL reselect = ([tabView selectedTabViewItem] == item); - NSInteger index; + NSUInteger anIndex; NSArray *cells = [[self sourceTabBar] cells]; //find the index of where the dragged cell was just dropped - for (index = 0; index < [cells count] && [cells objectAtIndex:index] != [self draggedCell]; index++); + for (anIndex = 0; anIndex < [cells count] && [cells objectAtIndex:anIndex] != [self draggedCell]; anIndex++); //temporarily disable the delegate in order to move the tab to a different index id tempDelegate = [tabView delegate]; [tabView setDelegate:nil]; [item retain]; [tabView removeTabViewItem:item]; - [tabView insertTabViewItem:item atIndex:index]; + [tabView insertTabViewItem:item atIndex:anIndex]; if (reselect) { [tabView selectTabViewItem:item]; } [tabView setDelegate:tempDelegate]; } - if (([self sourceTabBar] != [self destinationTabBar] || [[[self sourceTabBar] cells] indexOfObject:[self draggedCell]] != _draggedCellIndex) && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:didDropTabViewItem:inTabBar:)]) { + if (([self sourceTabBar] != [self destinationTabBar] || (NSInteger)[[[self sourceTabBar] cells] indexOfObject:[self draggedCell]] != _draggedCellIndex) && [[[self sourceTabBar] delegate] respondsToSelector:@selector(tabView:didDropTabViewItem:inTabBar:)]) { [[[self sourceTabBar] delegate] tabView:[[self sourceTabBar] tabView] didDropTabViewItem:[[self draggedCell] representedObject] inTabBar:[self destinationTabBar]]; } @@ -504,7 +507,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; // Restore the window alpha if appropriate if ([[[self sourceTabBar] tabView] numberOfTabViewItems]) { - [[[self sourceTabBar] window] setAlphaValue:1.0]; + [[[self sourceTabBar] window] setAlphaValue:1.0f]; } } @@ -562,7 +565,9 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; if ([[[self sourceTabBar] tabView] numberOfTabViewItems] == 1) { [self draggingExitedTabBar:[self sourceTabBar]]; - [[_draggedTab window] setAlphaValue:0.0]; + if ([_sourceTabBar tearOffStyle] == PSMTabBarTearOffAlphaWindow) { + [[_draggedTab window] setAlphaValue:0.0f]; + } } } } @@ -633,7 +638,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; float tabWindowAlphaValue = [[self destinationTabBar] usesSafariStyleDragging]?1:kPSMTabDragWindowAlpha; if (value <= 0.0) { - [viewWindow setAlphaValue:0.0]; + [viewWindow setAlphaValue:0.0f]; [tabWindow setAlphaValue:tabWindowAlphaValue]; [timer invalidate]; @@ -711,12 +716,12 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; { NSRect frame = [window frame]; [window setFrameTopLeftPoint:NSMakePoint(point.x - frame.size.width / 2, point.y + frame.size.height / 2)]; - [window setAlphaValue:0.0]; + [window setAlphaValue:0.0f]; [window makeKeyAndOrderFront:nil]; NSAnimation *animation = [[NSAnimation alloc] initWithDuration:0.25 animationCurve:NSAnimationEaseInOut]; [animation setAnimationBlockingMode:NSAnimationNonblocking]; - [animation setCurrentProgress:0.1]; + [animation setCurrentProgress:0.1f]; [animation startAnimation]; NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1.0 / 30.0 target:self selector:@selector(_expandWindowTimerFired:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:window, @"Window", animation, @"Animation", nil] repeats:YES]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; @@ -730,10 +735,10 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSPoint translation; NSRect winFrame = [window frame]; - translation.x = (winFrame.size.width / 2.0); - translation.y = (winFrame.size.height / 2.0); + translation.x = (winFrame.size.width / 2.0f); + translation.y = (winFrame.size.height / 2.0f); transform = CGAffineTransformMakeTranslation(translation.x, translation.y); - transform = CGAffineTransformScale(transform, 1.0 / [animation currentValue], 1.0 / [animation currentValue]); + transform = CGAffineTransformScale(transform, 1.0f / [animation currentValue], 1.0f / [animation currentValue]); transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y); translation.x = -winFrame.origin.x; @@ -781,8 +786,8 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; NSRect controlWindowFrame = [[control window] contentRectForFrameRect:[[control window] frame]]; NSPoint tabTopLeftInWindowCoords = NSMakePoint(draggedTabWindowFrame.origin.x - controlWindowFrame.origin.x, controlWindowFrame.origin.y + (2*controlWindowFrame.size.height) - draggedTabWindowFrame.origin.y); targetPoint = [control convertPoint:tabTopLeftInWindowCoords fromView:nil]; - targetPoint.x += (draggedTabWindowFrame.size.width / 2.0); - targetPoint.y = 0 - (draggedTabWindowFrame.size.height / 2.0) - targetPoint.y; + targetPoint.x += (draggedTabWindowFrame.size.width / 2.0f); + targetPoint.y = 0 - (draggedTabWindowFrame.size.height / 2.0f) - targetPoint.y; } else { targetPoint = [self currentMouseLoc]; } @@ -926,7 +931,7 @@ static PSMTabDragAssistant *sharedDragAssistant = nil; - (void)distributePlaceholdersInTabBar:(PSMTabBarControl *)control { - NSInteger i, numVisibleTabs = [control numberOfVisibleTabs]; + NSUInteger i, numVisibleTabs = [control numberOfVisibleTabs]; for (i = 0; i < numVisibleTabs; i++) { PSMTabBarCell *pc = [[[PSMTabBarCell alloc] initPlaceholderWithFrame:[[self draggedCell] frame] expanded:NO inControlView:control] autorelease]; [[control cells] insertObject:pc atIndex:(2 * i)]; diff --git a/Frameworks/PSMTabBar/PSMTabDragView.m b/Frameworks/PSMTabBar/PSMTabDragView.m index 259116ae..5be56b10 100644 --- a/Frameworks/PSMTabBar/PSMTabDragView.m +++ b/Frameworks/PSMTabBar/PSMTabDragView.m @@ -13,7 +13,7 @@ - (id)initWithFrame:(NSRect)frame { if ( (self = [super initWithFrame:frame]) ) { - _alpha = 1.0; + _alpha = 1.0f; } return self; } diff --git a/Frameworks/PSMTabBar/PSMTabDragWindowController.h b/Frameworks/PSMTabBar/PSMTabDragWindowController.h index babfb1a7..380a2bab 100644 --- a/Frameworks/PSMTabBar/PSMTabDragWindowController.h +++ b/Frameworks/PSMTabBar/PSMTabDragWindowController.h @@ -9,8 +9,8 @@ #import #import "PSMTabBarControl.h" -#define kPSMTabDragWindowAlpha 0.75 -#define kPSMTabDragAlphaInterval 0.15 +#define kPSMTabDragWindowAlpha 0.75f +#define kPSMTabDragAlphaInterval 0.15f @class PSMTabDragView; @@ -30,4 +30,5 @@ - (void)setAlternateImage:(NSImage *)image; - (BOOL)isAnimating; - (void)switchImages; +- (void)animateTimer:(NSTimer *)timer; @end diff --git a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m index 48db93c3..ece10a76 100644 --- a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m +++ b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m @@ -28,9 +28,9 @@ #import "NSBezierPath_AMShading.h" #import "PSMTabDragAssistant.h" -#define kPSMSequelProObjectCounterRadius 7.0 +#define kPSMSequelProObjectCounterRadius 7.0f #define kPSMSequelProCounterMinWidth 20 -#define kPSMSequelProTabCornerRadius 4.5 +#define kPSMSequelProTabCornerRadius 4.5f #define MARGIN_X 6 @implementation PSMSequelProTabStyle @@ -58,8 +58,8 @@ _addTabButtonPressedImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"AddTabButtonPushed"]]; _addTabButtonRolloverImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"AddTabButtonRollover"]]; - _objectCountStringAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Helvetica" size:11.0] toHaveTrait:NSBoldFontMask], NSFontAttributeName, - [[NSColor whiteColor] colorWithAlphaComponent:0.85], NSForegroundColorAttributeName, + _objectCountStringAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[[NSFontManager sharedFontManager] convertFont:[NSFont fontWithName:@"Helvetica" size:11.0f] toHaveTrait:NSBoldFontMask], NSFontAttributeName, + [[NSColor whiteColor] colorWithAlphaComponent:0.85f], NSForegroundColorAttributeName, nil, nil]; } return self; @@ -134,13 +134,13 @@ if ([cell tabState] & PSMTab_SelectedMask) { if (tabOrientation == PSMTabBarHorizontalOrientation) { - dragRect.origin.x -= 5.0; - dragRect.size.width += 10.0; + dragRect.origin.x -= 5.0f; + dragRect.size.width += 10.0f; } else { - dragRect.size.height += 1.0; - dragRect.origin.y -= 1.0; - dragRect.origin.x += 2.0; - dragRect.size.width -= 3.0; + dragRect.size.height += 1.0f; + dragRect.origin.y -= 1.0f; + dragRect.origin.x += 2.0f; + dragRect.size.width -= 3.0f; } } else if (tabOrientation == PSMTabBarVerticalOrientation) { dragRect.origin.x--; @@ -158,7 +158,7 @@ NSRect result; result.size = [sequelProCloseButton size]; result.origin.x = cellFrame.origin.x + MARGIN_X; - result.origin.y = cellFrame.origin.y + MARGIN_Y + 2.0; + result.origin.y = cellFrame.origin.y + MARGIN_Y + 2.0f; return result; } @@ -208,7 +208,7 @@ } CGFloat countWidth = [[self attributedObjectCountValueForTabCell:cell] size].width; - countWidth += (2 * kPSMSequelProObjectCounterRadius - 6.0); + countWidth += (2 * kPSMSequelProObjectCounterRadius - 6.0f); if (countWidth < kPSMSequelProCounterMinWidth) { countWidth = kPSMSequelProCounterMinWidth; } @@ -216,7 +216,7 @@ NSRect result; result.size = NSMakeSize(countWidth, 2 * kPSMSequelProObjectCounterRadius); // temp result.origin.x = cellFrame.origin.x + cellFrame.size.width - MARGIN_X - result.size.width; - result.origin.y = cellFrame.origin.y + MARGIN_Y + 1.0; + result.origin.y = cellFrame.origin.y + MARGIN_Y + 1.0f; if (![[cell indicator] isHidden]) { result.origin.x -= kPSMTabBarIndicatorWidth + kPSMTabBarCellPadding; @@ -228,7 +228,7 @@ - (CGFloat)minimumWidthOfTabCell:(PSMTabBarCell *)cell { - CGFloat resultWidth = 0.0; + CGFloat resultWidth = 0.0f; // left margin resultWidth = MARGIN_X; @@ -258,12 +258,12 @@ // right margin resultWidth += MARGIN_X; - return ceil(resultWidth); + return ceilf(resultWidth); } - (CGFloat)desiredWidthOfTabCell:(PSMTabBarCell *)cell { - CGFloat resultWidth = 0.0; + CGFloat resultWidth = 0.0f; // left margin resultWidth = MARGIN_X; @@ -292,7 +292,7 @@ // right margin resultWidth += MARGIN_X; - return ceil(resultWidth); + return ceilf(resultWidth); } - (CGFloat)tabCellHeight @@ -317,22 +317,22 @@ NSRange range = NSMakeRange(0, [contents length]); // Add font attribute - [attrStr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:11.0] range:range]; - [attrStr addAttribute:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:0.75] range:range]; + [attrStr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:11.0f] range:range]; + [attrStr addAttribute:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:0.75f] range:range]; // Add shadow attribute - NSShadow* shadow; - shadow = [[[NSShadow alloc] init] autorelease]; + NSShadow* textShadow; + textShadow = [[[NSShadow alloc] init] autorelease]; CGFloat shadowAlpha; if (([cell state] == NSOnState) || [cell isHighlighted]) { - shadowAlpha = 0.8; + shadowAlpha = 0.8f; } else { - shadowAlpha = 0.5; + shadowAlpha = 0.5f; } - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:shadowAlpha]]; - [shadow setShadowOffset:NSMakeSize(0, -1)]; - [shadow setShadowBlurRadius:1.0]; - [attrStr addAttribute:NSShadowAttributeName value:shadow range:range]; + [textShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:shadowAlpha]]; + [textShadow setShadowOffset:NSMakeSize(0, -1)]; + [textShadow setShadowBlurRadius:1.0f]; + [attrStr addAttribute:NSShadowAttributeName value:textShadow range:range]; // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; @@ -365,13 +365,13 @@ // no tab view == not connected if (![bar tabView]) { NSRect labelRect = rect; - labelRect.size.height -= 4.0; - labelRect.origin.y += 4.0; + labelRect.size.height -= 4.0f; + labelRect.origin.y += 4.0f; NSMutableAttributedString *attrStr; NSString *contents = @"PSMTabBarControl"; attrStr = [[[NSMutableAttributedString alloc] initWithString:contents] autorelease]; NSRange range = NSMakeRange(0, [contents length]); - [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range]; + [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0f] range:range]; NSMutableParagraphStyle *centeredParagraphStyle = nil; if (!centeredParagraphStyle) { @@ -404,42 +404,42 @@ [NSGraphicsContext saveGraphicsState]; [[NSGraphicsContext currentContext] setShouldAntialias:NO]; - float backgroundCalibratedWhite = 0.495; + float backgroundCalibratedWhite = 0.495f; float lineCalibratedWhite = [[NSColor darkGrayColor] whiteComponent]; - float shadowAlpha = 0.4; + float shadowAlpha = 0.4f; // When the window is in the background, tone down the colours if (![[tabBar window] isMainWindow] || ![NSApp isActive]) { - backgroundCalibratedWhite = 0.73; - lineCalibratedWhite = 0.49; - shadowAlpha = 0.3; + backgroundCalibratedWhite = 0.73f; + lineCalibratedWhite = 0.49f; + shadowAlpha = 0.3f; } // fill in background of tab bar - [[NSColor colorWithCalibratedWhite:backgroundCalibratedWhite alpha:1.0] set]; + [[NSColor colorWithCalibratedWhite:backgroundCalibratedWhite alpha:1.0f] set]; NSRectFillUsingOperation(rect, NSCompositeSourceAtop); // Draw horizontal line across bottom edge, with a slight bottom glow - [[NSColor colorWithCalibratedWhite:lineCalibratedWhite alpha:1.0] set]; + [[NSColor colorWithCalibratedWhite:lineCalibratedWhite alpha:1.0f] set]; [NSGraphicsContext saveGraphicsState]; - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:1]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.2]]; - [shadow setShadowOffset:NSMakeSize(0,1)]; - [shadow set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + rect.size.height - 0.5) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - 0.5)]; - [shadow release]; + NSShadow *lineGlow = [[NSShadow alloc] init]; + [lineGlow setShadowBlurRadius:1]; + [lineGlow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:0.2f]]; + [lineGlow setShadowOffset:NSMakeSize(0,1)]; + [lineGlow set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + rect.size.height - 0.5f) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - 0.5f)]; + [lineGlow release]; [NSGraphicsContext restoreGraphicsState]; // Add a shadow before drawing the top edge [NSGraphicsContext saveGraphicsState]; - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:shadowAlpha]]; - [shadow setShadowOffset:NSMakeSize(0,0)]; - [shadow set]; - [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + 0.5) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + 0.5)]; - [shadow release]; + NSShadow *edgeShadow = [[NSShadow alloc] init]; + [edgeShadow setShadowBlurRadius:4]; + [edgeShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.0f alpha:shadowAlpha]]; + [edgeShadow setShadowOffset:NSMakeSize(0,0)]; + [edgeShadow set]; + [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + 0.5f) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + 0.5f)]; + [edgeShadow release]; [NSGraphicsContext restoreGraphicsState]; [NSGraphicsContext restoreGraphicsState]; @@ -456,7 +456,6 @@ NSColor *shadowColor = nil; NSBezierPath *outlineBezier = [NSBezierPath bezierPath]; NSBezierPath *fillBezier = [NSBezierPath bezierPath]; - NSPoint center = NSZeroPoint; NSPoint topLeftArcCenter, bottomLeftArcCenter, topRightArcCenter, bottomRightArcCenter; BOOL drawRightEdge = YES; BOOL drawLeftEdge = YES; @@ -503,20 +502,20 @@ if ([[tabBar window] isMainWindow] && [NSApp isActive]) { lineColor = [NSColor darkGrayColor]; if ([cell state] == NSOnState) { - fillColor = [NSColor colorWithCalibratedWhite:0.59 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.7]; + fillColor = [NSColor colorWithCalibratedWhite:0.59f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; } else { - fillColor = [NSColor colorWithCalibratedWhite:0.495 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:1.0]; + fillColor = [NSColor colorWithCalibratedWhite:0.495f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:1.0f]; } } else { - lineColor = [NSColor colorWithCalibratedWhite:0.49 alpha:1.0]; + lineColor = [NSColor colorWithCalibratedWhite:0.49f alpha:1.0f]; if ([cell state] == NSOnState) { - fillColor = [NSColor colorWithCalibratedWhite:0.81 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.4]; + fillColor = [NSColor colorWithCalibratedWhite:0.81f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.4f]; } else { - fillColor = [NSColor colorWithCalibratedWhite:0.73 alpha:1.0]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.7]; + fillColor = [NSColor colorWithCalibratedWhite:0.73f alpha:1.0f]; + shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; } } @@ -531,10 +530,10 @@ } // Set up the corner bezier paths arc centers - topLeftArcCenter = NSMakePoint(aRect.origin.x - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + kPSMSequelProTabCornerRadius); - topRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + kPSMSequelProTabCornerRadius); - bottomLeftArcCenter = NSMakePoint(aRect.origin.x + kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); - bottomRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); + topLeftArcCenter = NSMakePoint(aRect.origin.x - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + kPSMSequelProTabCornerRadius); + topRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + kPSMSequelProTabCornerRadius); + bottomLeftArcCenter = NSMakePoint(aRect.origin.x + kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); + bottomRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius); // Construct the outline path if (drawLeftEdge) { @@ -551,21 +550,21 @@ // If one edge is missing, apply a local fill to the other edge if (drawRightEdge && !drawLeftEdge) { - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y)]; - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + aRect.size.height)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height)]; } else if (!drawRightEdge && drawLeftEdge) { - [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + 0.5 + kPSMSequelProTabCornerRadius, aRect.origin.y)]; + [fillBezier lineToPoint:NSMakePoint(aRect.origin.x + 0.5f + kPSMSequelProTabCornerRadius, aRect.origin.y)]; } // Set the tab outer shadow and draw the shadow [NSGraphicsContext saveGraphicsState]; - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:shadowColor]; - [shadow setShadowOffset:NSMakeSize(0, 0)]; - [shadow set]; + NSShadow *cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:4]; + [cellShadow setShadowColor:shadowColor]; + [cellShadow setShadowOffset:NSMakeSize(0, 0)]; + [cellShadow set]; [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; [NSGraphicsContext restoreGraphicsState]; // Fill the tab with a solid colour @@ -582,20 +581,20 @@ if (drawLeftEdge) { [outlineBezier appendBezierPathWithArcWithCenter:bottomLeftArcCenter radius:kPSMSequelProTabCornerRadius startAngle:145 endAngle:90 clockwise:YES]; } else { - [outlineBezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y + aRect.size.height - 0.5)]; + [outlineBezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y + aRect.size.height - 0.5f)]; } if (drawRightEdge) { [outlineBezier appendBezierPathWithArcWithCenter:bottomRightArcCenter radius:kPSMSequelProTabCornerRadius startAngle:90 endAngle:35 clockwise:YES]; } else { - [outlineBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width, aRect.origin.y + aRect.size.height - 0.5)]; + [outlineBezier lineToPoint:NSMakePoint(aRect.origin.x + aRect.size.width, aRect.origin.y + aRect.size.height - 0.5f)]; } - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:1]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.4]]; - [shadow setShadowOffset:NSMakeSize(0, 1)]; - [shadow set]; + cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:1]; + [cellShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:0.4f]]; + [cellShadow setShadowOffset:NSMakeSize(0, 1)]; + [cellShadow set]; [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; // Add the shadow over the tops of background tabs } else if (drawLeftEdge || drawRightEdge) { @@ -604,37 +603,37 @@ CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; CGContextSaveGState(context); NSPoint topLeft, topRight; - CGFloat drawAlpha = ([[tabBar window] isMainWindow] && [NSApp isActive])? 1.0 : 0.7; + CGFloat drawAlpha = ([[tabBar window] isMainWindow] && [NSApp isActive])? 1.0f : 0.7f; outlineBezier = [NSBezierPath bezierPath]; // Calculate the endpoints of the line if (drawLeftEdge) { - topLeft = NSMakePoint(aRect.origin.x + 0.5 - kPSMSequelProTabCornerRadius + 2, aRect.origin.y + 0.5); + topLeft = NSMakePoint(aRect.origin.x + 0.5f - kPSMSequelProTabCornerRadius + 2, aRect.origin.y + 0.5f); } else { - topLeft = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5, aRect.origin.y + 0.5); + topLeft = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + 0.5f); } if (drawRightEdge) { - topRight = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5 - 2, aRect.origin.y + 0.5); + topRight = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5f - 2, aRect.origin.y + 0.5f); } else { - topRight = NSMakePoint(aRect.origin.x + 0.5 + kPSMSequelProTabCornerRadius, aRect.origin.y + 0.5); + topRight = NSMakePoint(aRect.origin.x + 0.5f + kPSMSequelProTabCornerRadius, aRect.origin.y + 0.5f); } // Set up the line and clipping point CGContextClipToRect(context, CGRectMake(topLeft.x, topLeft.y, topRight.x-topLeft.x, aRect.size.height)); - [[NSColor colorWithCalibratedWhite:0.2 alpha:drawAlpha] set]; + [[NSColor colorWithCalibratedWhite:0.2f alpha:drawAlpha] set]; [outlineBezier moveToPoint:topLeft]; [outlineBezier lineToPoint:topRight]; // Set up the shadow - shadow = [[NSShadow alloc] init]; - [shadow setShadowBlurRadius:4]; - [shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.2 alpha:drawAlpha]]; - [shadow setShadowOffset:NSMakeSize(0,0)]; - [shadow set]; + cellShadow = [[NSShadow alloc] init]; + [cellShadow setShadowBlurRadius:4]; + [cellShadow setShadowColor:[NSColor colorWithCalibratedWhite:0.2f alpha:drawAlpha]]; + [cellShadow setShadowOffset:NSMakeSize(0,0)]; + [cellShadow set]; // Draw, and then restore the previous graphics state [outlineBezier stroke]; - [shadow release]; + [cellShadow release]; CGContextRestoreGState(context); } @@ -679,7 +678,7 @@ closeButtonRect.origin.y += closeButtonRect.size.height; } - [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0]; + [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0f]; } // icon @@ -693,13 +692,13 @@ // center in available space (in case icon image is smaller than kPSMTabBarIconWidth) if ([icon size].width < kPSMTabBarIconWidth) { - iconRect.origin.x += (kPSMTabBarIconWidth - [icon size].width)/2.0; + iconRect.origin.x += (kPSMTabBarIconWidth - [icon size].width)/2.0f; } if ([icon size].height < kPSMTabBarIconWidth) { - iconRect.origin.y -= (kPSMTabBarIconWidth - [icon size].height)/2.0; + iconRect.origin.y -= (kPSMTabBarIconWidth - [icon size].height)/2.0f; } - [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0]; + [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0f]; // scoot label over insetLabelWidth += iconRect.size.width + kPSMTabBarCellPadding; @@ -720,7 +719,7 @@ // object counter if ([cell count] > 0) { - [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set]; + [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3f alpha:0.6f] set]; NSBezierPath *path = [NSBezierPath bezierPath]; NSRect myRect = [self objectCounterRectForTabCell:cell]; if ([cell state] == NSOnState) { @@ -728,17 +727,17 @@ } [path moveToPoint:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y)]; [path lineToPoint:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y)]; - [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:270.0 endAngle:90.0]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:270.0f endAngle:90.0f]; [path lineToPoint:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + myRect.size.height)]; - [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:90.0 endAngle:270.0]; + [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMSequelProObjectCounterRadius, myRect.origin.y + kPSMSequelProObjectCounterRadius) radius:kPSMSequelProObjectCounterRadius startAngle:90.0f endAngle:270.0f]; [path fill]; // draw attributed string centered in area NSRect counterStringRect; NSAttributedString *counterString = [self attributedObjectCountValueForTabCell:cell]; counterStringRect.size = [counterString size]; - counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0) + 0.25; - counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0) + 0.5; + counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0f) + 0.25f; + counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0f) + 0.5f; [counterString drawInRect:counterStringRect]; // shrink label width to make room for object counter -- cgit v1.2.3