Commit 8d320036 authored by thakis@chromium.org's avatar thakis@chromium.org

mac: New asset for the tabstrip border, tweak drawning.

Paint the tab outline, new tab button outline, and the tabstrip border
at 0.65 opacity in non-focused windows, like image_button_cell does already.
Also change inactive tabs to not paint on top of the tabstrip.

BUG=166403,52468
TEST=look at tab strip, it now has a white line below the grey line
again. With themes, the theme color shines through the separator line
again.

Review URL: https://codereview.chromium.org/11791030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175402 0039d316-1c4b-4281-b951-d872f2087c98
parent fcdda953
......@@ -127,7 +127,7 @@ const SkColor kDefaultColorToolbarButtonStrokeInactive =
SkColorSetARGB(75, 99, 99, 99);
const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204);
const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103);
const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(123, 123, 123);
const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163);
#endif
// Default tints.
......
......@@ -10,8 +10,6 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
namespace {
// Adjust the overlay position relative to the top right of the button image.
const CGFloat kOverlayOffsetX = -3;
const CGFloat kOverlayOffsetY = 5;
......@@ -20,8 +18,6 @@ const CGFloat kOverlayOffsetY = 5;
// slightly lighter color. We do this by just reducing the alpha.
const CGFloat kImageNoFocusAlpha = 0.65;
} // namespace
@interface ImageButtonCell (Private)
- (void)sharedInit;
- (image_button_cell::ButtonState)currentButtonState;
......
......@@ -222,7 +222,7 @@ NSImage* ApplyMask(NSImage* image, NSImage* mask) {
}
// Paints |overlay| on top of |ground|.
NSImage* Overlay(NSImage* ground, NSImage* overlay) {
NSImage* Overlay(NSImage* ground, NSImage* overlay, CGFloat alpha) {
DCHECK_EQ([ground size].width, [overlay size].width);
DCHECK_EQ([ground size].height, [overlay size].height);
......@@ -236,7 +236,7 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
[overlay drawAtPoint:NSZeroPoint
fromRect:NSMakeRect(0, 0, width, height)
operation:NSCompositeSourceOver
fraction:1.0];
fraction:alpha];
}) autorelease];
}
......@@ -2204,20 +2204,21 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
NSImage* foreground = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask);
[[newTabButton_ cell] setImage:Overlay(foreground, normal)
[[newTabButton_ cell] setImage:Overlay(foreground, normal, 1.0)
forButtonState:image_button_cell::kDefaultState];
[[newTabButton_ cell] setImage:Overlay(foreground, hover)
[[newTabButton_ cell] setImage:Overlay(foreground, hover, 1.0)
forButtonState:image_button_cell::kHoverState];
[[newTabButton_ cell] setImage:Overlay(foreground, pressed)
[[newTabButton_ cell] setImage:Overlay(foreground, pressed, 1.0)
forButtonState:image_button_cell::kPressedState];
// IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme.
if (theme->UsingDefaultTheme()) {
const CGFloat alpha = tabs::kImageNoFocusAlpha;
NSImage* background = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask);
[[newTabButton_ cell] setImage:Overlay(background, normal)
[[newTabButton_ cell] setImage:Overlay(background, normal, alpha)
forButtonState:image_button_cell::kDefaultStateBackground];
[[newTabButton_ cell] setImage:Overlay(background, hover)
[[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
forButtonState:image_button_cell::kHoverStateBackground];
} else {
[[newTabButton_ cell] setImage:nil
......
......@@ -13,6 +13,7 @@
#import "chrome/browser/ui/cocoa/new_tab_button.h"
#import "chrome/browser/ui/cocoa/nsview_additions.h"
#import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_view.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
......@@ -75,8 +76,11 @@
borderRect.size.height = [image size].height;
borderRect.origin.y = 0;
NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/NO,
NSCompositeSourceOver, 1.0, /*flipped=*/NO);
BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow];
NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO,
NSCompositeSourceOver,
focused ? 1.0 : tabs::kImageNoFocusAlpha,
/*flipped=*/ NO);
}
- (void)drawRect:(NSRect)rect {
......
......@@ -30,6 +30,10 @@ enum AlertState {
kAlertFalling
};
// When the window doesn't have focus then we want to draw the button with a
// slightly lighter color. We do this by just reducing the alpha.
const CGFloat kImageNoFocusAlpha = 0.65;
} // namespace tabs
@class TabController, TabWindowController;
......
......@@ -24,8 +24,6 @@
@end
#endif
namespace {
const int kMaskHeight = 29; // Height of the mask bitmap.
const int kFillHeight = 25; // Height of the "mask on" part of the mask bitmap.
......@@ -52,8 +50,6 @@ const NSTimeInterval kGlowUpdateInterval = 0.025;
// has moved less than the threshold, we want to close the tab.
const CGFloat kRapidCloseDist = 2.5;
} // namespace
@interface TabView(Private)
- (void)resetLastGlowUpdateTime;
......@@ -327,6 +323,11 @@ const CGFloat kRapidCloseDist = 2.5;
bool selected = [self state];
// Background tabs should not paint over the tab strip separator, which is
// two pixels high in both lodpi and hidpi.
if (!selected && dirtyRect.origin.y < 1)
dirtyRect.origin.y = 2 * [self cr_lineWidth];
bool usingDefaultTheme = themeProvider && themeProvider->UsingDefaultTheme();
NSColor* backgroundImageColor = [self backgroundColorForSelected:selected];
......@@ -405,6 +406,9 @@ const CGFloat kRapidCloseDist = 2.5;
// Draws the tab outline.
- (void)drawStroke:(NSRect)dirtyRect {
BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow];
CGFloat alpha = focused ? 1.0 : tabs::kImageNoFocusAlpha;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
float height =
[rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage() size].height;
......@@ -415,7 +419,7 @@ const CGFloat kRapidCloseDist = 2.5;
rb.GetNativeImageNamed(IDR_TAB_ACTIVE_RIGHT).ToNSImage(),
/*vertical=*/NO,
NSCompositeSourceOver,
1.0,
alpha,
/*flipped=*/NO);
} else {
NSDrawThreePartImage(NSMakeRect(0, 0, NSWidth([self bounds]), height),
......@@ -424,7 +428,7 @@ const CGFloat kRapidCloseDist = 2.5;
rb.GetNativeImageNamed(IDR_TAB_INACTIVE_RIGHT).ToNSImage(),
/*vertical=*/NO,
NSCompositeSourceOver,
1.0,
alpha,
/*flipped=*/NO);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment