summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-19 20:45:43 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-19 20:45:43 +0000
commit0c6d4720bcf39de80d35cad305a8d20d3d59882e (patch)
tree3f29e9bf014d857b1e5438f5a3113047dad148d1 /chrome/browser/ui
parentec13a8376e73638316155bacf3f57abc2044aea0 (diff)
downloadchromium_src-0c6d4720bcf39de80d35cad305a8d20d3d59882e.zip
chromium_src-0c6d4720bcf39de80d35cad305a8d20d3d59882e.tar.gz
chromium_src-0c6d4720bcf39de80d35cad305a8d20d3d59882e.tar.bz2
Make panel titlebars more tab-like on Mac.
When using the default theme, we try to match the default titlebar look-and-feel. When using custom themes, we use the selected/unselected tab resources instead. The .xib update is to change the panel window to be a textured window, so we can retrieve the NSColor to use to paint the titlebar when using the default Chrome theme. BUG=none TEST=Open panels and see what they look like. Review URL: http://codereview.chromium.org/7875011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101817 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.h3
-rw-r--r--chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm65
2 files changed, 62 insertions, 6 deletions
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
index 7e5c475..b8b478b 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.h
@@ -7,7 +7,6 @@
#import <Cocoa/Cocoa.h>
-#import "chrome/browser/ui/cocoa/background_gradient_view.h"
#import "chrome/browser/ui/cocoa/tracking_area.h"
@class CrTrackingArea;
@@ -33,7 +32,7 @@ enum PanelDragState {
PANEL_DRAG_SUPPRESSED // Ignore drag events until PANEL_DRAG_CAN_START.
};
-@interface PanelTitlebarViewCocoa : BackgroundGradientView {
+@interface PanelTitlebarViewCocoa : NSView {
@private
IBOutlet PanelWindowControllerCocoa* controller_;
IBOutlet NSTextField* title_;
diff --git a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
index 9ab230e..08fdc1b 100644
--- a/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm
@@ -11,14 +11,16 @@
#include "base/mac/scoped_nsautorelease_pool.h"
#include "chrome/browser/themes/theme_service.h"
#import "chrome/browser/ui/cocoa/hover_image_button.h"
+#import "chrome/browser/ui/cocoa/nsview_additions.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#import "chrome/browser/ui/cocoa/tracking_area.h"
#import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
+#include "grit/theme_resources_standard.h"
#import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
-#include "ui/base/theme_provider.h"
#include "ui/gfx/mac/nsimage_cache.h"
+#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
-const int kRoundedCornerSize = 6;
+const int kRoundedCornerSize = 3;
const int kCloseButtonLeftPadding = 8;
// Used to implement TestingAPI
@@ -72,11 +74,66 @@ static NSEvent* MakeMouseEvent(NSEventType type, NSPoint point) {
bottomLeftCornerRadius:0.0
bottomRightCornerRadius:0.0];
[path addClip];
+
NSPoint phase = [[self window] themePatternPhase];
[[NSGraphicsContext currentContext] setPatternPhase:phase];
- [self drawBackgroundWithOpaque:YES];
- ui::ThemeProvider* theme = [[self window] themeProvider];
+ ThemeService* theme =
+ static_cast<ThemeService*>([[self window] themeProvider]);
+
+ NSColor* backgroundColor = nil;
+ // When using the default theme, we fall back to the default system colors
+ // instead of trying to use the tab coloring, since using the tab coloring
+ // results in focused panel titlebars that are light and unfocused panel
+ // titlebars that are dark, which is the opposite of all other window
+ // titlebars on Mac.
+ if (theme && !theme->UsingDefaultTheme()) {
+ if ([[self window] isMainWindow]) {
+ backgroundColor = theme->GetNSImageColorNamed(IDR_THEME_TOOLBAR, true);
+ } else {
+ // Based on -[TabView drawRect:], we need to make sure the theme has an
+ // IDR_THEME_TAB_BACKGROUND or IDR_THEME_FRAME resource; otherwise,
+ // we'll potentially end up with a bizarre looking blue background for
+ // inactive tabs, which looks really out of place on a Mac.
+ BOOL hasBackgroundImage =
+ (theme->HasCustomImage(IDR_THEME_TAB_BACKGROUND) ||
+ theme->HasCustomImage(IDR_THEME_FRAME));
+ if (hasBackgroundImage) {
+ backgroundColor =
+ theme->GetNSImageColorNamed(IDR_THEME_TAB_BACKGROUND, true);
+ }
+ }
+ }
+
+ if (backgroundColor) {
+ [backgroundColor set];
+ NSRectFillUsingOperation([self bounds], NSCompositeSourceOver);
+ } else {
+ // Temporarily reset the pattern phase to (0, 0). We want to anchor the
+ // titlebar gradient to match the default system look.
+ gfx::ScopedNSGraphicsContextSaveGState scopedGState;
+ [[NSGraphicsContext currentContext] setPatternPhase:NSMakePoint(0, 0)];
+ [[[self window] backgroundColor] set];
+ NSRectFillUsingOperation([self bounds], NSCompositeSourceOver);
+ }
+
+
+ // Draw the divider stroke.
+ NSColor* strokeColor = nil;
+ if (theme) {
+ strokeColor = [[self window] isMainWindow]
+ ? theme->GetNSColor(ThemeService::COLOR_TOOLBAR_STROKE, true)
+ : theme->GetNSColor(ThemeService::COLOR_TOOLBAR_STROKE_INACTIVE, true);
+ } else {
+ strokeColor = [NSColor blackColor];
+ }
+ NSRect borderRect, contentRect;
+ NSDivideRect([self bounds], &borderRect, &contentRect, [self cr_lineWidth],
+ NSMinYEdge);
+ [strokeColor set];
+ NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
+
+ // Update the panel title text color as appropriate.
NSColor* titleColor = nil;
if (theme)
titleColor = [[self window] isMainWindow]