From 92ee758b8c2d75782ed4b83ac56068606ef5b27a Mon Sep 17 00:00:00 2001 From: Abhi Beckert Date: Fri, 18 Mar 2016 16:48:10 +1000 Subject: #346 Work on new tab bar design --- Artwork/Tab Bar.sketch | Bin 0 -> 65536 bytes Frameworks/PSMTabBar/Images/AddTabButton.png | Bin 160 -> 141 bytes Frameworks/PSMTabBar/Images/AddTabButtonPushed.png | Bin 160 -> 116 bytes .../PSMTabBar/Images/AddTabButtonRollover.png | Bin 160 -> 116 bytes Frameworks/PSMTabBar/Images/SequelProTabClose.png | Bin 305 -> 231 bytes .../PSMTabBar/Images/SequelProTabClose@2x.png | Bin 754 -> 344 bytes .../PSMTabBar/Images/SequelProTabClose_Pressed.png | Bin 309 -> 275 bytes .../Images/SequelProTabClose_Pressed@2x.png | Bin 726 -> 476 bytes .../Images/SequelProTabClose_Rollover.png | Bin 309 -> 275 bytes .../Images/SequelProTabClose_Rollover@2x.png | Bin 736 -> 476 bytes Frameworks/PSMTabBar/Images/SequelProTabDirty.png | Bin 282 -> 185 bytes .../PSMTabBar/Images/SequelProTabDirty@2x.png | Bin 717 -> 307 bytes .../PSMTabBar/Images/SequelProTabDirty_Pressed.png | Bin 276 -> 226 bytes .../Images/SequelProTabDirty_Pressed@2x.png | Bin 666 -> 415 bytes .../Images/SequelProTabDirty_Rollover.png | Bin 275 -> 226 bytes .../Images/SequelProTabDirty_Rollover@2x.png | Bin 685 -> 415 bytes Frameworks/PSMTabBar/PSMTabBarControl.h | 7 +- Frameworks/PSMTabBar/PSMTabBarControl.m | 23 +- Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m | 403 ++++++------------- Interfaces/English.lproj/MainWindow.xib | 441 +++------------------ Source/SPDatabaseDocument.h | 3 +- Source/SPDatabaseDocument.m | 7 +- Source/SPWindowController.h | 1 + Source/SPWindowController.m | 25 +- 24 files changed, 215 insertions(+), 695 deletions(-) create mode 100644 Artwork/Tab Bar.sketch diff --git a/Artwork/Tab Bar.sketch b/Artwork/Tab Bar.sketch new file mode 100644 index 00000000..11e4c1de Binary files /dev/null and b/Artwork/Tab Bar.sketch differ diff --git a/Frameworks/PSMTabBar/Images/AddTabButton.png b/Frameworks/PSMTabBar/Images/AddTabButton.png index 3818b106..ee762312 100644 Binary files a/Frameworks/PSMTabBar/Images/AddTabButton.png and b/Frameworks/PSMTabBar/Images/AddTabButton.png differ diff --git a/Frameworks/PSMTabBar/Images/AddTabButtonPushed.png b/Frameworks/PSMTabBar/Images/AddTabButtonPushed.png index d78febb1..633d0d51 100644 Binary files a/Frameworks/PSMTabBar/Images/AddTabButtonPushed.png and b/Frameworks/PSMTabBar/Images/AddTabButtonPushed.png differ diff --git a/Frameworks/PSMTabBar/Images/AddTabButtonRollover.png b/Frameworks/PSMTabBar/Images/AddTabButtonRollover.png index ced6a993..633d0d51 100644 Binary files a/Frameworks/PSMTabBar/Images/AddTabButtonRollover.png and b/Frameworks/PSMTabBar/Images/AddTabButtonRollover.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose.png b/Frameworks/PSMTabBar/Images/SequelProTabClose.png index 1b68f75f..355fffcb 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabClose@2x.png index da429832..7e5d610f 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose@2x.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed.png b/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed.png index 520cfb0b..0303b744 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed@2x.png index a81b9b4b..e9f4e553 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose_Pressed@2x.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover.png b/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover.png index 9ee43e19..0303b744 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover@2x.png index dcc764d5..e9f4e553 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabClose_Rollover@2x.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty.png index e5269d34..e5d3c850 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty@2x.png index 0b2c0796..c06b5955 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty@2x.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed.png index ed074ef9..d0befe12 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed@2x.png index 14e5b566..06d74af2 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Pressed@2x.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover.png index 7966b7e9..d0befe12 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover.png differ diff --git a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover@2x.png b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover@2x.png index bff7efac..06d74af2 100644 Binary files a/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover@2x.png and b/Frameworks/PSMTabBar/Images/SequelProTabDirty_Rollover@2x.png differ diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h index 9aebddad..ad9de748 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.h +++ b/Frameworks/PSMTabBar/PSMTabBarControl.h @@ -15,11 +15,11 @@ #define PSMTabDragDidEndNotification @"PSMTabDragDidEndNotification" #define PSMTabDragDidBeginNotification @"PSMTabDragDidBeginNotification" -#define kPSMTabBarControlHeight 22 -#define kPSMTabBarControlHeightCollapsed 1 +#define kPSMTabBarControlHeight 34 +#define kPSMTabBarControlDefaultHeightCollapsed 0 // can be changed with a property // internal cell border #define MARGIN_X 6 -#define MARGIN_Y 3 +#define MARGIN_Y 5 // padding between objects #define kPSMTabBarCellPadding 4 // fixed size objects @@ -185,6 +185,7 @@ enum { - (void)setUsesSafariStyleDragging:(BOOL)value; - (PSMTabBarTearOffStyle)tearOffStyle; - (void)setTearOffStyle:(PSMTabBarTearOffStyle)tearOffStyle; +@property CGFloat heightCollapsed; // accessors - (NSTabView *)tabView; diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m index 7c1b059c..9b38d6d1 100644 --- a/Frameworks/PSMTabBar/PSMTabBarControl.m +++ b/Frameworks/PSMTabBar/PSMTabBarControl.m @@ -145,6 +145,9 @@ _cellMaxWidth = 280; _cellOptimumWidth = 130; _tearOffStyle = PSMTabBarTearOffAlphaWindow; + + self.heightCollapsed = kPSMTabBarControlDefaultHeightCollapsed; + style = [[PSMSequelProTabStyle alloc] init]; // the overflow button/menu @@ -795,7 +798,7 @@ - (void)hideTabBar:(BOOL)hide animate:(BOOL)animate { - if (!_awakenedFromNib || (_isHidden && hide) || (!_isHidden && !hide)) { + if (!_awakenedFromNib/* || (_isHidden && hide) || (!_isHidden && !hide)*/) { return; } @@ -832,7 +835,7 @@ // Determine the target sizes if (_isHidden) { - myTargetSize = kPSMTabBarControlHeightCollapsed; + myTargetSize = self.heightCollapsed; } else { myTargetSize = kPSMTabBarControlHeight; } @@ -1069,7 +1072,7 @@ // hide/show? (these return if already in desired state) if ( (_hideForSingleTab) && ([_cells count] <= 1) ) { [self hideTabBar:YES animate:YES]; - return; +// return; } else { [self hideTabBar:NO animate:YES]; } @@ -1763,22 +1766,22 @@ if (partnerView) { NSRect partnerFrame = [partnerView frame]; // above or below me? - if (myFrame.origin.y - 22 > [partnerView frame].origin.y) { + if (myFrame.origin.y - kPSMTabBarControlHeight > [partnerView frame].origin.y) { // partner is below me - [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y + 21, myFrame.size.width, myFrame.size.height - 21)]; - [partnerView setFrame:NSMakeRect(partnerFrame.origin.x, partnerFrame.origin.y, partnerFrame.size.width, partnerFrame.size.height + 21)]; + [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y + (kPSMTabBarControlHeight - 1), myFrame.size.width, myFrame.size.height - (kPSMTabBarControlHeight - 1))]; + [partnerView setFrame:NSMakeRect(partnerFrame.origin.x, partnerFrame.origin.y, partnerFrame.size.width, partnerFrame.size.height + (kPSMTabBarControlHeight - 1))]; } else { // partner is above me - [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y, myFrame.size.width, myFrame.size.height - 21)]; - [partnerView setFrame:NSMakeRect(partnerFrame.origin.x, partnerFrame.origin.y - 21, partnerFrame.size.width, partnerFrame.size.height + 21)]; + [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y, myFrame.size.width, myFrame.size.height - (kPSMTabBarControlHeight - 1))]; + [partnerView setFrame:NSMakeRect(partnerFrame.origin.x, partnerFrame.origin.y - (kPSMTabBarControlHeight - 1), partnerFrame.size.width, partnerFrame.size.height + (kPSMTabBarControlHeight - 1))]; } [partnerView setNeedsDisplay:YES]; [self setNeedsDisplay:YES]; } else { // for window movement NSRect windowFrame = [[self window] frame]; - [[self window] setFrame:NSMakeRect(windowFrame.origin.x, windowFrame.origin.y + 21, windowFrame.size.width, windowFrame.size.height - 21) display:YES]; - [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y, myFrame.size.width, myFrame.size.height - 21)]; + [[self window] setFrame:NSMakeRect(windowFrame.origin.x, windowFrame.origin.y + (kPSMTabBarControlHeight - 1), windowFrame.size.width, windowFrame.size.height - (kPSMTabBarControlHeight - 1)) display:YES]; + [self setFrame:NSMakeRect(myFrame.origin.x, myFrame.origin.y, myFrame.size.width, myFrame.size.height - (kPSMTabBarControlHeight - 1))]; } } else { if (partnerView) { diff --git a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m index 5bc8aa3b..619ad953 100644 --- a/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m +++ b/Frameworks/PSMTabBar/Styles/PSMSequelProTabStyle.m @@ -30,7 +30,7 @@ #define kPSMSequelProObjectCounterRadius 7.0f #define kPSMSequelProCounterMinWidth 20 -#define kPSMSequelProTabCornerRadius 4.5f +#define kPSMSequelProTabCornerRadius 0 #define MARGIN_X 6 #ifndef __MAC_10_10 @@ -126,12 +126,12 @@ typedef struct { - (CGFloat)leftMarginForTabBarControl { - return 5.0f; + return 0.0f; } - (CGFloat)rightMarginForTabBarControl { - return 24.0f; + return 10.0f; // enough to fit plus button } - (CGFloat)topMarginForTabBarControl @@ -356,7 +356,7 @@ typedef struct { NSRange range = NSMakeRange(0, [contents length]); // Add font attribute - [attrStr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:11.0f] range:range]; + [attrStr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:11.0f] range:range]; [attrStr addAttribute:NSForegroundColorAttributeName value:[[NSColor textColor] colorWithAlphaComponent:0.75f] range:range]; // Add shadow attribute @@ -371,8 +371,8 @@ typedef struct { [textShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0f alpha:shadowAlpha]]; [textShadow setShadowOffset:NSMakeSize(0, -1)]; [textShadow setShadowBlurRadius:1.0f]; - [attrStr addAttribute:NSShadowAttributeName value:textShadow range:range]; - +// [attrStr addAttribute:NSShadowAttributeName value:textShadow range:range]; + // Paragraph Style for Truncating Long Text static NSMutableParagraphStyle *TruncatingTailParagraphStyle = nil; if (!TruncatingTailParagraphStyle) { @@ -440,77 +440,49 @@ typedef struct { //Draw for our whole bounds; it'll be automatically clipped to fit the appropriate drawing area rect = [tabBar bounds]; + // find active cell + PSMTabBarCell *selectedCell = nil; + for (PSMTabBarCell *aCell in [tabBar cells]) { + if (aCell.tabState & PSMTab_SelectedMask) { + selectedCell = aCell; + break; + } + } + + [NSGraphicsContext saveGraphicsState]; [[NSGraphicsContext currentContext] setShouldAntialias:NO]; - float backgroundCalibratedWhite = 0.495f; - if (systemVersionIsAtLeast10_7_0) backgroundCalibratedWhite = 0.55f; - if (systemVersionIsAtLeast10_10_0) backgroundCalibratedWhite = 0.68f; + float backgroundCalibratedWhite = 0.73f; - float lineCalibratedWhite = [[NSColor darkGrayColor] whiteComponent]; + float lineCalibratedWhite = [[NSColor grayColor] whiteComponent]; float shadowAlpha = 0.4f; // When the window is in the background, tone down the colours if ((![[tabBar window] isMainWindow] && ![[[tabBar window] attachedSheet] isMainWindow]) || ![NSApp isActive]) { - backgroundCalibratedWhite = 0.73f; - if (systemVersionIsAtLeast10_7_0) backgroundCalibratedWhite = 0.79f; - if (systemVersionIsAtLeast10_10_0) backgroundCalibratedWhite = 0.86f; + backgroundCalibratedWhite = 0.86f; lineCalibratedWhite = 0.49f; shadowAlpha = 0.3f; } - + // fill in background of tab bar [[NSColor colorWithCalibratedWhite:backgroundCalibratedWhite alpha:1.0f] set]; - NSRectFillUsingOperation(rect, NSCompositeSourceAtop); + NSRectFill(NSMakeRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height - 10)); - //draw tab bar cells background color - NSColor *fillColor; - NSUInteger currentIndex = -1; - for (PSMTabBarCell *aCell in [tabBar cells]) { - currentIndex++; - //ignore tabs without color - if(![aCell backgroundColor]) - continue; - // Set up colours - if (([[tabBar window] isMainWindow] || [[[tabBar window] attachedSheet] isMainWindow]) && [NSApp isActive]) { - //active window, background cell - fillColor = [[aCell backgroundColor] shadowWithLevel:0.15]; - } else { - //background window, background cell - NSColor *dark = [[aCell backgroundColor] shadowWithLevel:0.15]; - fillColor = [NSColor colorWithCalibratedHue:[dark hueComponent] saturation:[dark saturationComponent] brightness:([dark brightnessComponent] * 1.28) alpha:1.0f]; - } - [fillColor set]; - NSRect frame = [aCell frame]; - //the leftmost cell has no left border when inactive so we need to expand it's area to the left window edge - if(currentIndex == 0 && [aCell state] == NSOffState) { - frame = NSMakeRect(0.0, frame.origin.y, frame.size.width + kPSMSequelProTabCornerRadius + 0.5f, frame.size.height); - } - NSRectFillUsingOperation(frame, NSCompositeSourceAtop); - } + + // fill active tab strip + [[self fillColorForCell:selectedCell] set]; + NSRectFill(NSMakeRect(rect.origin.x, rect.origin.y + rect.size.height - 9, rect.size.width, 8)); - // Draw horizontal line across bottom edge, with a slight bottom glow + // Draw horizontal line across the top edge [[NSColor colorWithCalibratedWhite:lineCalibratedWhite alpha:1.0f] set]; - [NSGraphicsContext saveGraphicsState]; - 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]; - 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]; + + // Draw horizontal line across the baseline for each tab + [NSBezierPath strokeLineFromPoint:NSMakePoint(rect.origin.x, rect.origin.y + rect.size.height - 9.5f) toPoint:NSMakePoint(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height - 9.5f)]; + + // Draw horizontal line across the bottom edge + [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)]; [NSGraphicsContext restoreGraphicsState]; } @@ -518,234 +490,47 @@ typedef struct { // Step 3 - (void)drawTabCell:(PSMTabBarCell *)cell { - NSRect cellFrame = [cell frame]; - NSColor *lineColor = nil; - NSColor *fillColor = nil; - NSColor *shadowColor = nil; - NSBezierPath *outlineBezier = [NSBezierPath bezierPath]; - NSBezierPath *fillBezier = [NSBezierPath bezierPath]; - NSPoint topLeftArcCenter, bottomLeftArcCenter, topRightArcCenter, bottomRightArcCenter; - BOOL drawRightEdge = YES; - BOOL drawLeftEdge = YES; - - // For cells in the off state, determine whether to draw the edges. - if ([cell state] == NSOffState) { - NSUInteger selectedCellIndex = NSUIntegerMax; - NSUInteger drawingCellIndex = NSUIntegerMax; - NSUInteger firstOverflowedCellIndex = NSUIntegerMax; - - NSUInteger currentIndex = 0; - for (PSMTabBarCell *aCell in [tabBar cells]) { - if (aCell == cell) drawingCellIndex = currentIndex; - if ([aCell state] == NSOnState || ([aCell isPlaceholder] && [aCell currentStep] > 1)) { - selectedCellIndex = currentIndex; - } - if ([aCell isInOverflowMenu]) { - firstOverflowedCellIndex = currentIndex; - break; - } - currentIndex++; - } - - // Draw the left edge if the cell is to the left of the active tab, or if the preceding cell is - // being dragged, and not for the very first cell. - if ((!drawingCellIndex || (drawingCellIndex == 1 && [[[tabBar cells] objectAtIndex:0] isPlaceholder])) - || (drawingCellIndex > selectedCellIndex - && (drawingCellIndex != selectedCellIndex + 1 || ![[[tabBar cells] objectAtIndex:selectedCellIndex] isPlaceholder]))) - { - drawLeftEdge = NO; - } - - // Draw the right edge for tabs to the right, the last tab in the bar, and where the following - // cell is being dragged. - if (drawingCellIndex < selectedCellIndex - && drawingCellIndex != firstOverflowedCellIndex - 1 - && (drawingCellIndex >= selectedCellIndex + 1 || ![[[tabBar cells] objectAtIndex:selectedCellIndex] isPlaceholder])) - { - drawRightEdge = NO; - } + // don't draw cells when collapsed + if (tabBar.isTabBarHidden) { + return; } + + NSRect cellFrame = cell.frame; + NSColor *lineColor = nil; + NSColor *fillColor = [self fillColorForCell:cell]; // Set up colours if (([[tabBar window] isMainWindow] || [[[tabBar window] attachedSheet] isMainWindow]) && [NSApp isActive]) { - lineColor = [NSColor darkGrayColor]; - if ([cell state] == NSOnState) { //active window, active cell - float tabWhiteComponent = 0.59f; - if (systemVersionIsAtLeast10_7_0) tabWhiteComponent = 0.63f; // 160/255 - if (systemVersionIsAtLeast10_10_0) tabWhiteComponent = 0.795f; // 202/255 - - if (![[[tabBar window] toolbar] isVisible]) tabWhiteComponent += 0.02f; - - fillColor = [cell backgroundColor] ? [cell backgroundColor] : [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; - } else { //active window, background cell - float tabWhiteComponent = 0.495f; - if (systemVersionIsAtLeast10_7_0) tabWhiteComponent = 0.55f; - if (systemVersionIsAtLeast10_10_0) tabWhiteComponent = 0.68f; // 173/255 - fillColor = [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; - - if([cell backgroundColor]) - //should be a slightly darker variant of the color - fillColor = [[cell backgroundColor] shadowWithLevel:0.15]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:1.0f]; - } + lineColor = [NSColor grayColor]; + } else { lineColor = [NSColor colorWithCalibratedWhite:0.49f alpha:1.0f]; - if ([cell state] == NSOnState) { //background window, active cell - float tabWhiteComponent = 0.81f; - if (systemVersionIsAtLeast10_7_0) tabWhiteComponent = 0.85f; - if (systemVersionIsAtLeast10_10_0) tabWhiteComponent = 0.957f; // 244/255 - - if (![[[tabBar window] toolbar] isVisible]) tabWhiteComponent += 0.01f; - - //create a slightly desaturated variant (gray can't be desaturated so we instead make it brighter) - fillColor = [cell backgroundColor] ? [NSColor colorWithCalibratedHue:[[cell backgroundColor] hueComponent] saturation:[[cell backgroundColor] saturationComponent] brightness:([[cell backgroundColor] brightnessComponent] * 1.28 ) alpha:1.0f] : [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; - shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.4f]; - } else { //background window, background cell - float tabWhiteComponent = 0.73f; - if(systemVersionIsAtLeast10_7_0) tabWhiteComponent = 0.79f; - if(systemVersionIsAtLeast10_10_0) tabWhiteComponent = 0.86f; // 219/255 - fillColor = [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; - - //make it dark first, then desaturate - if([cell backgroundColor]) { - NSColor *dark = [[cell backgroundColor] shadowWithLevel:0.15]; - fillColor = [NSColor colorWithCalibratedHue:[dark hueComponent] saturation:[dark saturationComponent] brightness:([dark brightnessComponent] * 1.28) alpha:1.0f]; - } - shadowColor = [NSColor colorWithCalibratedWhite:0.0f alpha:0.7f]; - } + } - [NSGraphicsContext saveGraphicsState]; + // setup fill rect + NSRect fillRect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y + 1, cellFrame.size.width, cellFrame.size.height - 10); - NSRect aRect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height); - - // If the tab bar is hidden, don't draw the top pixel - if ([tabBar isTabBarHidden] && [tabBar frame].size.height == kPSMTabBarControlHeightCollapsed) { - aRect.origin.y++; - aRect.size.height--; - } - - // Set up the corner bezier paths arc centers - 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 -0.5f); - bottomRightArcCenter = NSMakePoint(aRect.origin.x + aRect.size.width - kPSMSequelProTabCornerRadius + 0.5f, aRect.origin.y + aRect.size.height - kPSMSequelProTabCornerRadius -0.5f); - - // Construct the outline path - if (drawLeftEdge) { - [outlineBezier appendBezierPathWithArcWithCenter:topLeftArcCenter radius:kPSMSequelProTabCornerRadius startAngle:270 endAngle:360 clockwise:NO]; - [outlineBezier appendBezierPathWithArcWithCenter:bottomLeftArcCenter radius:kPSMSequelProTabCornerRadius startAngle:180 endAngle:90 clockwise:YES]; - } - if (drawRightEdge) { - [outlineBezier appendBezierPathWithArcWithCenter:bottomRightArcCenter radius:kPSMSequelProTabCornerRadius startAngle:90 endAngle:0 clockwise:YES]; - [outlineBezier appendBezierPathWithArcWithCenter:topRightArcCenter radius:kPSMSequelProTabCornerRadius startAngle:180 endAngle:270 clockwise:NO]; - } - - // Set up a fill bezier based on the outline path - [fillBezier appendBezierPath:outlineBezier]; - - // 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.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.5f + kPSMSequelProTabCornerRadius, aRect.origin.y)]; - } - - // Set the tab outer shadow and draw the shadow + + // draw [NSGraphicsContext saveGraphicsState]; - NSShadow *cellShadow = [[NSShadow alloc] init]; - [cellShadow setShadowBlurRadius:4]; - [cellShadow setShadowColor:shadowColor]; - [cellShadow setShadowOffset:NSMakeSize(0, 0)]; - [cellShadow set]; - [outlineBezier stroke]; - [cellShadow release]; - [NSGraphicsContext restoreGraphicsState]; - // Fill the tab with a solid colour [fillColor set]; - [fillBezier fill]; + NSRectFill(fillRect); - //if we use a non-standard color draw a little highlight along the top edge - if([cell backgroundColor] && [cell state] == NSOnState) { - NSColor *highlightColor = [[cell backgroundColor] highlightWithLevel:0.5f]; - [highlightColor set]; - - NSBezierPath *highlightBezier = [NSBezierPath bezierPath]; - [highlightBezier moveToPoint:NSMakePoint(aRect.origin.x - kPSMSequelProTabCornerRadius+2.5f, aRect.origin.y+0.5f)]; - [highlightBezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width+kPSMSequelProTabCornerRadius-1.0f, aRect.origin.y+0.5f)]; - [highlightBezier setLineWidth:1.0f]; - [highlightBezier stroke]; + // stroke left edge + [lineColor setStroke]; + NSPoint point1 = NSMakePoint(fillRect.origin.x + fillRect.size.width - 0.5, fillRect.origin.y); + NSPoint point2 = NSMakePoint(fillRect.origin.x + fillRect.size.width - 0.5, fillRect.origin.y + fillRect.size.height); + [NSBezierPath strokeLineFromPoint:point1 toPoint:point2]; + + // stroke bottom edge unless active cell + if (cell.state != NSOnState) { + point1 = NSMakePoint(fillRect.origin.x, fillRect.origin.y + fillRect.size.height - 0.5); + point2 = NSMakePoint(fillRect.origin.x + fillRect.size.width, fillRect.origin.y + fillRect.size.height - 0.5); + [NSBezierPath strokeLineFromPoint:point1 toPoint:point2]; } - // Re-stroke without shadow over the fill. - [lineColor set]; - [outlineBezier stroke]; - - // Add a bottom line to the active tab, with a slight inner glow - if ([cell state] == NSOnState) { - outlineBezier = [NSBezierPath bezierPath]; - 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.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.5f)]; - } - 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]; - [cellShadow release]; - - // Add the shadow over the tops of background tabs - } else if (drawLeftEdge || drawRightEdge) { - - // Set up a CGContext so that drawing can be clipped (to prevent shadow issues) - CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextSaveGState(context); - NSPoint topLeft, topRight; - CGFloat drawAlpha = (([[tabBar window] isMainWindow] || [[[tabBar window] attachedSheet] isMainWindow]) && [NSApp isActive])? 1.0f : 0.7f; - outlineBezier = [NSBezierPath bezierPath]; - - // Calculate the endpoints of the line - if (drawLeftEdge) { - 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.5f, aRect.origin.y + 0.5f); - } - if (drawRightEdge) { - topRight = NSMakePoint(aRect.origin.x + aRect.size.width + kPSMSequelProTabCornerRadius + 0.5f - 2, aRect.origin.y + 0.5f); - } else { - 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.2f alpha:drawAlpha] set]; - [outlineBezier moveToPoint:topLeft]; - [outlineBezier lineToPoint:topRight]; - - // Set up the shadow - 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]; - [cellShadow release]; - CGContextRestoreGState(context); - } - [NSGraphicsContext restoreGraphicsState]; [self drawInteriorWithTabCell:cell inView:[cell customControlView]]; @@ -801,18 +586,11 @@ typedef struct { labelRect.size.height = cellFrame.size.height; labelRect.origin.y = cellFrame.origin.y + MARGIN_Y; - if ([cell state] == NSOnState) { - //labelRect.origin.y -= 1; - } - // object counter if ([cell count] > 0) { [[cell countColor] ?: [NSColor colorWithCalibratedWhite:0.3f alpha:0.6f] set]; NSBezierPath *path = [NSBezierPath bezierPath]; NSRect myRect = [self objectCounterRectForTabCell:cell]; - if ([cell state] == NSOnState) { - //myRect.origin.y -= 1.0; - } [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.0f endAngle:90.0f]; @@ -831,11 +609,68 @@ typedef struct { // shrink label width to make room for object counter labelRect.size.width -= myRect.size.width + kPSMTabBarCellPadding; } - - // draw label - [[cell attributedStringValue] drawInRect:labelRect]; + + // determine text colour + NSAttributedString *labelString = cell.attributedStringValue; + if (cell.state != NSOnState) { + NSMutableAttributedString *newLabelString = labelString.mutableCopy; + + [newLabelString addAttribute:NSForegroundColorAttributeName value:[NSColor darkGrayColor] range:NSMakeRange(0, newLabelString.length)]; + + labelString = newLabelString.copy; + } + + // draw label + [labelString drawInRect:labelRect]; +} + +- (NSColor *)fillColorForCell:(PSMTabBarCell *)cell +{ + NSColor *fillColor = nil; + + // Set up colours + if (([[tabBar window] isMainWindow] || [[[tabBar window] attachedSheet] isMainWindow]) && [NSApp isActive]) { + if ([cell state] == NSOnState) { //active window, active cell + float tabWhiteComponent = 0.795f; + + if (!tabBar.window.toolbar.isVisible) tabWhiteComponent += 0.02f; + + fillColor = [cell backgroundColor] ? [cell backgroundColor] : [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; + } else { //active window, background cell + float tabWhiteComponent = 0.68f; + fillColor = [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; + + if([cell backgroundColor]) { + //should be a slightly darker variant of the color + fillColor = [[cell backgroundColor] shadowWithLevel:0.15]; + } + } + } else { + if ([cell state] == NSOnState) { //background window, active cell + float tabWhiteComponent = 0.957f; + if (!tabBar.window.toolbar.isVisible) tabWhiteComponent += 0.01f; + + //create a slightly desaturated variant (gray can't be desaturated so we instead make it brighter) + if (cell.backgroundColor) { + fillColor = [NSColor colorWithCalibratedHue:cell.backgroundColor.hueComponent saturation:cell.backgroundColor.saturationComponent brightness:(cell.backgroundColor.brightnessComponent * 1.28) alpha:1.0f]; + } else { + fillColor = [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; + } + + } else { //background window, background cell + float tabWhiteComponent = 0.86f; + fillColor = [NSColor colorWithCalibratedWhite:tabWhiteComponent alpha:1.0f]; + + //make it dark first, then desaturate + if (cell.backgroundColor) { + NSColor *dark = [[cell backgroundColor] shadowWithLevel:0.15]; + fillColor = [NSColor colorWithCalibratedHue:dark.hueComponent saturation:dark.saturationComponent brightness:(dark.brightnessComponent * 1.28) alpha:1.0f]; + } + } + } + + return fillColor; } - #pragma mark - #pragma mark Archiving diff --git a/Interfaces/English.lproj/MainWindow.xib b/Interfaces/English.lproj/MainWindow.xib index 6bd632c8..ed58bf1a 100644 --- a/Interfaces/English.lproj/MainWindow.xib +++ b/Interfaces/English.lproj/MainWindow.xib @@ -1,392 +1,49 @@ - - - - 1060 - 13F34 - 6254 - 1265.21 - 698.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 6254 - - - NSCustomObject - NSCustomView - NSTabView - NSView - NSWindowTemplate - - - com.apple.InterfaceBuilder.CocoaPlugin - - - PluginDependencyRecalculationVersion - - - - - SPWindowController - - - FirstResponder - - - NSApplication - - - 15 - 2 - {{238, 168}, {948, 555}} - 544735232 - Window - SPWindow - - - {800, 400} - - - 256 - - - - 266 - {{0, 533}, {948, 22}} - - - PSMTabBarControl - - - - 274 - {948, 533} - - - - - YES - 13 - 1044 - - 6 - YES - - - {948, 555} - - - - {{0, 0}, {1440, 878}} - {705, 422} - {10000000000000, 10000000000000} - YES - - - - NO - - - - tabBar - - - - 13 - - - - tabView - - - - 14 - - - - window - - - - 15 - - - - tabView - - - - 9 - - - - partnerView - - - - 10 - - - - delegate - - - - 12 - - - - delegate - - - - 16 - - - - - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 1 - - - - - - - - 2 - - - - - - - - - 3 - - - - - 4 - - - - - - - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{54, 246}, {948, 555}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - - - - - - - PSMTabBarControl - NSControl - - id - id - NSTabView - - - - delegate - id - - - partnerView - id - - - tabView - NSTabView - - - - IBProjectSource - ../Frameworks/PSMTabBar/PSMTabBarControl.h - - - - SPWindow - NSWindow - - IBProjectSource - ../Source/SPWindow.h - - - - SPWindowController - NSWindowController - - id - id - id - id - id - id - - - - addNewConnection: - id - - - closeTab: - id - - - moveSelectedTabInNewWindow: - id - - - selectNextDocumentTab: - id - - - selectPreviousDocumentTab: - id - - - toggleTabBarShown: - id - - - - PSMTabBarControl - NSTabView - - - - tabBar - PSMTabBarControl - - - tabView - NSTabView - - - - IBProjectSource - ../Source/SPWindowController.h - - - - SPWindowController - - id - id - id - id - id - id - - - - addNewConnection: - id - - - closeTab: - id - - - moveSelectedTabInNewWindow: - id - - - selectNextDocumentTab: - id - - - selectPreviousDocumentTab: - id - - - toggleTabBarShown: - id - - - - IBProjectSource - ../Source/SPWindowController.m - - - - - - PSMTabBarControl - NSControl - - id - id - NSTabView - - - - delegate - id - - - partnerView - id - - - tabView - NSTabView - - - - IBFrameworkSource - PSMTabBar.framework/Headers/PSMTabBarControl.h - - - - - 0 - IBCocoaFramework - YES - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - 3 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index e36b4a58..62aa11d7 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -522,9 +522,10 @@ - (void)restoreSession; #endif +- (SPConnectionController*)connectionController; + #ifdef SP_CODA /* method decls */ - (SPConnectionController*)createConnectionController; -- (SPConnectionController*)connectionController; - (void)connect; - (void)setTableSourceInstance:(SPTableStructure*)source; - (void)setTableContentInstance:(SPTableContent*)content; diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 21f774e5..ab7f2a5d 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -3886,6 +3886,8 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; // Set the titles [parentTabViewItem setLabel:tabTitle]; [parentTabViewItem setColor:tabColor]; + [parentWindowController updateTabBar]; + if ([parentWindowController selectedTableDocument] == self) { [parentWindow setTitle:windowTitle]; } @@ -5163,14 +5165,13 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; #endif } - -#ifdef SP_CODA - - (SPConnectionController*)connectionController { return connectionController; } +#ifdef SP_CODA + - (void)databaseDocumentConnectionFailed:(id)sender { if ( delegate && [delegate respondsToSelector:@selector(databaseDocumentConnectionFailed:)] ) diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h index 528c1c84..8700019c 100644 --- a/Source/SPWindowController.h +++ b/Source/SPWindowController.h @@ -71,5 +71,6 @@ - (NSArray *)documents; - (void)selectTabAtIndex:(NSInteger)index; - (void)setHideForSingleTab:(BOOL)hide; +- (void)updateTabBar; @end diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 963919d0..d9214ada 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -34,6 +34,7 @@ #import "SPDatabaseViewController.h" #import "SPAppController.h" #import "PSMTabDragAssistant.h" +#import "SPConnectionController.h" #import #import @@ -181,6 +182,7 @@ enum { // If there are multiple tabs, close the front tab. if ([tabView numberOfTabViewItems] > 1) { [tabView removeTabViewItem:[tabView selectedTabViewItem]]; + } else { [[self window] performClose:self]; @@ -358,6 +360,23 @@ enum { } } +#pragma mark - +#pragma mark Tab Bar +- (void)updateTabBar +{ + BOOL collapse = NO; + + if (selectedTableDocument.getConnection) { + if (selectedTableDocument.connectionController.colorIndex != -1) { + collapse = YES; + } + } + + tabBar.heightCollapsed = collapse ? 8 : 1; + + [tabBar update]; +} + #pragma mark - #pragma mark First responder forwarding to active tab @@ -453,8 +472,8 @@ enum { [tabBar setShowAddTabButton:YES]; [tabBar setSizeCellsToFit:NO]; [tabBar setCellMinWidth:100]; - [tabBar setCellMaxWidth:250]; - [tabBar setCellOptimumWidth:250]; + [tabBar setCellMaxWidth:25000]; + [tabBar setCellOptimumWidth:25000]; [tabBar setSelectsTabsOnMouseDown:YES]; [tabBar setCreatesTabOnDoubleClick:YES]; [tabBar setTearOffStyle:PSMTabBarTearOffAlphaWindow]; @@ -552,6 +571,8 @@ enum { [nc addObserver:self selector:@selector(_selectedTableDocumentDeallocd:) name:SPDocumentWillCloseNotification object:newDoc]; selectedTableDocument = newDoc; } + + [self updateTabBar]; } - (void)_selectedTableDocumentDeallocd:(NSNotification *)notification -- cgit v1.2.3