1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h"
7 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
8 #import "ui/base/cocoa/nsview_additions.h"
10 @implementation TabStripBackgroundView
12 - (void)drawRect:(NSRect)dirtyRect {
13 // Only the top corners are rounded. For simplicity, round all 4 corners but
14 // draw the bottom corners outside of the visible bounds.
15 float cornerRadius = 4.0;
16 NSRect roundedRect = [self bounds];
17 roundedRect.origin.y -= cornerRadius;
18 roundedRect.size.height += cornerRadius;
19 [[NSBezierPath bezierPathWithRoundedRect:roundedRect
21 yRadius:cornerRadius] addClip];
22 BOOL themed = [FramedBrowserWindow drawWindowThemeInDirtyRect:dirtyRect
25 forceBlackBackground:NO];
27 // Draw a 1px border on the top edge and top corners.
29 CGFloat lineWidth = [self cr_lineWidth];
30 // Inset the vertical lines by 0.5px so that the top line gets a full pixel.
31 // Outset the horizontal lines by 0.5px so that they are not visible, but
32 // still get the rounded corners to get a border.
33 NSRect strokeRect = NSInsetRect(roundedRect, -lineWidth/2, lineWidth/2);
34 NSBezierPath* path = [NSBezierPath bezierPathWithRoundedRect:strokeRect
36 yRadius:cornerRadius];
37 [path setLineWidth:lineWidth];
38 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.5] set];
43 // ThemedWindowDrawing implementation.
45 - (void)windowDidChangeTheme {
46 [self setNeedsDisplay:YES];
49 - (void)windowDidChangeActive {
50 [self setNeedsDisplay:YES];