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 = ...@@ -127,7 +127,7 @@ const SkColor kDefaultColorToolbarButtonStrokeInactive =
SkColorSetARGB(75, 99, 99, 99); SkColorSetARGB(75, 99, 99, 99);
const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204); const SkColor kDefaultColorToolbarBezel = SkColorSetRGB(204, 204, 204);
const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103); const SkColor kDefaultColorToolbarStroke = SkColorSetRGB(103, 103, 103);
const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(123, 123, 123); const SkColor kDefaultColorToolbarStrokeInactive = SkColorSetRGB(163, 163, 163);
#endif #endif
// Default tints. // Default tints.
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
namespace {
// Adjust the overlay position relative to the top right of the button image. // Adjust the overlay position relative to the top right of the button image.
const CGFloat kOverlayOffsetX = -3; const CGFloat kOverlayOffsetX = -3;
const CGFloat kOverlayOffsetY = 5; const CGFloat kOverlayOffsetY = 5;
...@@ -20,8 +18,6 @@ const CGFloat kOverlayOffsetY = 5; ...@@ -20,8 +18,6 @@ const CGFloat kOverlayOffsetY = 5;
// slightly lighter color. We do this by just reducing the alpha. // slightly lighter color. We do this by just reducing the alpha.
const CGFloat kImageNoFocusAlpha = 0.65; const CGFloat kImageNoFocusAlpha = 0.65;
} // namespace
@interface ImageButtonCell (Private) @interface ImageButtonCell (Private)
- (void)sharedInit; - (void)sharedInit;
- (image_button_cell::ButtonState)currentButtonState; - (image_button_cell::ButtonState)currentButtonState;
......
...@@ -222,7 +222,7 @@ NSImage* ApplyMask(NSImage* image, NSImage* mask) { ...@@ -222,7 +222,7 @@ NSImage* ApplyMask(NSImage* image, NSImage* mask) {
} }
// Paints |overlay| on top of |ground|. // 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].width, [overlay size].width);
DCHECK_EQ([ground size].height, [overlay size].height); DCHECK_EQ([ground size].height, [overlay size].height);
...@@ -236,7 +236,7 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) { ...@@ -236,7 +236,7 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
[overlay drawAtPoint:NSZeroPoint [overlay drawAtPoint:NSZeroPoint
fromRect:NSMakeRect(0, 0, width, height) fromRect:NSMakeRect(0, 0, width, height)
operation:NSCompositeSourceOver operation:NSCompositeSourceOver
fraction:1.0]; fraction:alpha];
}) autorelease]; }) autorelease];
} }
...@@ -2204,20 +2204,21 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) { ...@@ -2204,20 +2204,21 @@ NSImage* Overlay(NSImage* ground, NSImage* overlay) {
NSImage* foreground = ApplyMask( NSImage* foreground = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND, true), mask); 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]; forButtonState:image_button_cell::kDefaultState];
[[newTabButton_ cell] setImage:Overlay(foreground, hover) [[newTabButton_ cell] setImage:Overlay(foreground, hover, 1.0)
forButtonState:image_button_cell::kHoverState]; forButtonState:image_button_cell::kHoverState];
[[newTabButton_ cell] setImage:Overlay(foreground, pressed) [[newTabButton_ cell] setImage:Overlay(foreground, pressed, 1.0)
forButtonState:image_button_cell::kPressedState]; forButtonState:image_button_cell::kPressedState];
// IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme. // IDR_THEME_TAB_BACKGROUND_INACTIVE is only used with the default theme.
if (theme->UsingDefaultTheme()) { if (theme->UsingDefaultTheme()) {
const CGFloat alpha = tabs::kImageNoFocusAlpha;
NSImage* background = ApplyMask( NSImage* background = ApplyMask(
theme->GetNSImageNamed(IDR_THEME_TAB_BACKGROUND_INACTIVE, true), mask); 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]; forButtonState:image_button_cell::kDefaultStateBackground];
[[newTabButton_ cell] setImage:Overlay(background, hover) [[newTabButton_ cell] setImage:Overlay(background, hover, alpha)
forButtonState:image_button_cell::kHoverStateBackground]; forButtonState:image_button_cell::kHoverStateBackground];
} else { } else {
[[newTabButton_ cell] setImage:nil [[newTabButton_ cell] setImage:nil
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#import "chrome/browser/ui/cocoa/new_tab_button.h" #import "chrome/browser/ui/cocoa/new_tab_button.h"
#import "chrome/browser/ui/cocoa/nsview_additions.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_strip_controller.h"
#import "chrome/browser/ui/cocoa/tabs/tab_view.h"
#import "chrome/browser/ui/cocoa/view_id_util.h" #import "chrome/browser/ui/cocoa/view_id_util.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
...@@ -75,8 +76,11 @@ ...@@ -75,8 +76,11 @@
borderRect.size.height = [image size].height; borderRect.size.height = [image size].height;
borderRect.origin.y = 0; borderRect.origin.y = 0;
NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/NO, BOOL focused = [[self window] isKeyWindow] || [[self window] isMainWindow];
NSCompositeSourceOver, 1.0, /*flipped=*/NO); NSDrawThreePartImage(borderRect, nil, image, nil, /*vertical=*/ NO,
NSCompositeSourceOver,
focused ? 1.0 : tabs::kImageNoFocusAlpha,
/*flipped=*/ NO);
} }
- (void)drawRect:(NSRect)rect { - (void)drawRect:(NSRect)rect {
......
...@@ -30,6 +30,10 @@ enum AlertState { ...@@ -30,6 +30,10 @@ enum AlertState {
kAlertFalling 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 } // namespace tabs
@class TabController, TabWindowController; @class TabController, TabWindowController;
......
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
@end @end
#endif #endif
namespace {
const int kMaskHeight = 29; // Height of the mask bitmap. const int kMaskHeight = 29; // Height of the mask bitmap.
const int kFillHeight = 25; // Height of the "mask on" part 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; ...@@ -52,8 +50,6 @@ const NSTimeInterval kGlowUpdateInterval = 0.025;
// has moved less than the threshold, we want to close the tab. // has moved less than the threshold, we want to close the tab.
const CGFloat kRapidCloseDist = 2.5; const CGFloat kRapidCloseDist = 2.5;
} // namespace
@interface TabView(Private) @interface TabView(Private)
- (void)resetLastGlowUpdateTime; - (void)resetLastGlowUpdateTime;
...@@ -327,6 +323,11 @@ const CGFloat kRapidCloseDist = 2.5; ...@@ -327,6 +323,11 @@ const CGFloat kRapidCloseDist = 2.5;
bool selected = [self state]; 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(); bool usingDefaultTheme = themeProvider && themeProvider->UsingDefaultTheme();
NSColor* backgroundImageColor = [self backgroundColorForSelected:selected]; NSColor* backgroundImageColor = [self backgroundColorForSelected:selected];
...@@ -405,6 +406,9 @@ const CGFloat kRapidCloseDist = 2.5; ...@@ -405,6 +406,9 @@ const CGFloat kRapidCloseDist = 2.5;
// Draws the tab outline. // Draws the tab outline.
- (void)drawStroke:(NSRect)dirtyRect { - (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(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
float height = float height =
[rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage() size].height; [rb.GetNativeImageNamed(IDR_TAB_ACTIVE_LEFT).ToNSImage() size].height;
...@@ -415,7 +419,7 @@ const CGFloat kRapidCloseDist = 2.5; ...@@ -415,7 +419,7 @@ const CGFloat kRapidCloseDist = 2.5;
rb.GetNativeImageNamed(IDR_TAB_ACTIVE_RIGHT).ToNSImage(), rb.GetNativeImageNamed(IDR_TAB_ACTIVE_RIGHT).ToNSImage(),
/*vertical=*/NO, /*vertical=*/NO,
NSCompositeSourceOver, NSCompositeSourceOver,
1.0, alpha,
/*flipped=*/NO); /*flipped=*/NO);
} else { } else {
NSDrawThreePartImage(NSMakeRect(0, 0, NSWidth([self bounds]), height), NSDrawThreePartImage(NSMakeRect(0, 0, NSWidth([self bounds]), height),
...@@ -424,7 +428,7 @@ const CGFloat kRapidCloseDist = 2.5; ...@@ -424,7 +428,7 @@ const CGFloat kRapidCloseDist = 2.5;
rb.GetNativeImageNamed(IDR_TAB_INACTIVE_RIGHT).ToNSImage(), rb.GetNativeImageNamed(IDR_TAB_INACTIVE_RIGHT).ToNSImage(),
/*vertical=*/NO, /*vertical=*/NO,
NSCompositeSourceOver, NSCompositeSourceOver,
1.0, alpha,
/*flipped=*/NO); /*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