Permalink
Browse files

Fixed tabs to have an inactive style when window isn't main

  • Loading branch information...
1 parent 1e49a66 commit 823eb00c00d3b9233c7dbd27145867be9a4eb341 @zachwaugh committed Feb 24, 2012
Showing with 17 additions and 14 deletions.
  1. +15 −8 source/PSMMetalTabStyle.m
  2. +2 −6 source/PSMTabBarController.m
@@ -309,7 +309,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(PSMTabBarCell *)cell
// 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:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:([[tabBar window] isMainWindow] ? 0.75 : 0.5)] range:range];
// Add shadow attribute
NSShadow* shadow = shadow = [[[NSShadow alloc] init] autorelease];
@@ -337,7 +337,7 @@ - (NSAttributedString *)attributedStringValueForTabCell:(PSMTabBarCell *)cell
- (void)drawTabCell:(PSMTabBarCell *)cell
{
NSRect cellFrame = [cell frame];
- NSColor *lineColor = [NSColor darkGrayColor];
+ NSColor *lineColor = ([[tabBar window] isMainWindow]) ? [NSColor darkGrayColor] : [NSColor grayColor];
NSBezierPath *bezier = [NSBezierPath bezierPath];
if ([cell state] == NSOnState)
@@ -399,15 +399,15 @@ - (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlVie
// close button - only show if mouse over cell
if ([cell hasCloseButton] && ![cell isCloseButtonSuppressed] && [cell isHighlighted])
{
-// NSSize closeButtonSize = NSZeroSize;
+ NSSize closeButtonSize = NSZeroSize;
NSRect closeButtonRect = [cell closeButtonRectForFrame:cellFrame];
NSImage *closeButton = nil;
closeButton = [cell isEdited] ? metalCloseDirtyButton : metalCloseButton;
if ([cell closeButtonOver]) closeButton = [cell isEdited] ? metalCloseDirtyButtonOver : metalCloseButtonOver;
if ([cell closeButtonPressed]) closeButton = [cell isEdited] ? metalCloseDirtyButtonDown : metalCloseButtonDown;
-// closeButtonSize = [closeButton size];
+ closeButtonSize = [closeButton size];
if ([controlView isFlipped]) {
closeButtonRect.origin.y += closeButtonRect.size.height;
}
@@ -487,15 +487,22 @@ - (void)drawBackgroundInRect:(NSRect)rect
[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias:NO];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.1] set];
+ [[NSColor colorWithCalibratedWhite:0.0 alpha:([[tabBar window] isMainWindow] ? 0.1 : 0.05)] set];
NSRectFillUsingOperation(rect, NSCompositeSourceAtop);
- NSGradient *shadow = [[NSGradient alloc ] initWithStartingColor:[NSColor colorWithDeviceWhite:0 alpha:0.15] endingColor:[NSColor clearColor]];
+ NSGradient *shadow = [[NSGradient alloc ] initWithStartingColor:[NSColor colorWithDeviceWhite:0 alpha:([[tabBar window] isMainWindow] ? 0.15 : 0.1)] endingColor:[NSColor clearColor]];
NSRect shadowRect = NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width, 7);
[shadow drawInRect:shadowRect angle:90];
[shadow release];
- [[NSColor darkGrayColor] set];
+ if ([[tabBar window] isMainWindow])
+ {
+ [[NSColor darkGrayColor] set];
+ }
+ else
+ {
+ [[NSColor grayColor] 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)];
[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)];
@@ -525,7 +532,7 @@ - (void)drawTabBar:(PSMTabBarControl *)bar inRect:(NSRect)rect
[attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0] range:range];
NSMutableParagraphStyle *centeredParagraphStyle = nil;
if (!centeredParagraphStyle) {
- centeredParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
+ centeredParagraphStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain];
[centeredParagraphStyle setAlignment:NSCenterTextAlignment];
}
[attrStr addAttribute:NSParagraphStyleAttributeName value:centeredParagraphStyle range:range];
@@ -87,8 +87,6 @@ - (NSRect)cellTrackingRectAtIndex:(NSInteger)index
NSRect rect;
if (index > -1 && index < [_cellTrackingRects count]) {
rect = [[_cellTrackingRects objectAtIndex:index] rectValue];
- } else if (index >= [_cellTrackingRects count]) {
- rect = [[_cellTrackingRects lastObject] rectValue];
} else {
NSLog(@"cellTrackingRectAtIndex: Invalid index (%ld)", (long)index);
rect = NSZeroRect;
@@ -109,8 +107,6 @@ - (NSRect)closeButtonTrackingRectAtIndex:(NSInteger)index
NSRect rect;
if (index > -1 && index < [_closeButtonTrackingRects count]) {
rect = [[_closeButtonTrackingRects objectAtIndex:index] rectValue];
- } else if (index >= [_closeButtonTrackingRects count]) {
- rect = [[_closeButtonTrackingRects lastObject] rectValue];
} else {
NSLog(@"closeButtonTrackingRectAtIndex: Invalid index (%ld)", (long)index);
rect = NSZeroRect;
@@ -346,7 +342,7 @@ - (NSArray *)_generateWidthsFromCells:(NSArray *)cells
[newWidths addObject:[NSNumber numberWithDouble:(desiredWidth < averageWidth && [_control sizeCellsToFit]) ? desiredWidth : averageWidth]];
}
-// totalOccupiedWidth = [[newWidths valueForKeyPath:@"@sum.intValue"] integerValue];
+ totalOccupiedWidth = [[newWidths valueForKeyPath:@"@sum.intValue"] integerValue];
break;
}
@@ -507,7 +503,7 @@ - (NSArray *)_generateWidthsFromCells:(NSArray *)cells
[newWidths replaceObjectAtIndex:0 withObject:[NSNumber numberWithDouble:availableWidth - [cellWidth doubleValue]]];
}
-// numberOfVisibleCells = 2;
+ numberOfVisibleCells = 2;
}
}

0 comments on commit 823eb00

Please sign in to comment.