Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: chrome/browser/ui/panels/panel_titlebar_view_cocoa.mm

Issue 7734003: Implement basic theming for panel titlebars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" 5 #import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/themes/theme_service.h"
11 #import "chrome/browser/ui/cocoa/themed_window.h"
10 #import "chrome/browser/ui/cocoa/tracking_area.h" 12 #import "chrome/browser/ui/cocoa/tracking_area.h"
11 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" 13 #import "chrome/browser/ui/panels/panel_window_controller_cocoa.h"
12 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" 14 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
15 #include "ui/base/theme_provider.h"
13 16
14 const int kRoundedCornerSize = 6; 17 const int kRoundedCornerSize = 6;
15 const int kCloseButtonLeftPadding = 8; 18 const int kCloseButtonLeftPadding = 8;
16 19
17 @implementation PanelTitlebarViewCocoa 20 @implementation PanelTitlebarViewCocoa
18 21
19 - (id)initWithFrame:(NSRect)frame { 22 - (id)initWithFrame:(NSRect)frame {
20 if ((self = [super initWithFrame:frame])) { 23 if ((self = [super initWithFrame:frame])) {
21 // Create standard OSX Close Button. 24 // Create standard OSX Close Button.
22 closeButton_ = [NSWindow standardWindowButton:NSWindowCloseButton 25 closeButton_ = [NSWindow standardWindowButton:NSWindowCloseButton
(...skipping 15 matching lines...) Expand all
38 [[self controller] closePanel]; 41 [[self controller] closePanel];
39 } 42 }
40 43
41 - (void)drawRect:(NSRect)rect { 44 - (void)drawRect:(NSRect)rect {
42 NSBezierPath* path = 45 NSBezierPath* path =
43 [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds] 46 [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
44 topLeftCornerRadius:kRoundedCornerSize 47 topLeftCornerRadius:kRoundedCornerSize
45 topRightCornerRadius:kRoundedCornerSize 48 topRightCornerRadius:kRoundedCornerSize
46 bottomLeftCornerRadius:0.0 49 bottomLeftCornerRadius:0.0
47 bottomRightCornerRadius:0.0]; 50 bottomRightCornerRadius:0.0];
48 // TODO(dimich): paint theme image here. 51 [path addClip];
49 [[NSColor colorWithDeviceRed:1 green:1 blue:0 alpha:0.9] setFill]; 52 NSPoint phase = [[self window] themePatternPhase];
50 [path fill]; 53 [[NSGraphicsContext currentContext] setPatternPhase:phase];
51 [[NSColor colorWithCalibratedWhite:0.4 alpha:1.0] set]; 54 [self drawBackgroundWithOpaque:YES];
Dmitry Titov 2011/08/25 00:08:21 It seems there should be more to it. See, for exam
dcheng 2011/08/25 18:48:54 I agree, but I would be more comfortable splitting
Dmitry Titov 2011/08/25 19:24:51 Ok, I'm fine with smaller patches.
52 NSPoint from = [self bounds].origin;
53 NSPoint to = NSMakePoint(from.x + NSWidth([self bounds]), from.y);
54 [NSBezierPath strokeLineFromPoint:from toPoint:to];
55 } 55 }
56 56
57 - (void)attach { 57 - (void)attach {
58 // Interface Builder can not put a view as a sibling of contentView, 58 // Interface Builder can not put a view as a sibling of contentView,
59 // so need to do it here. Placing the titleView as a last child of 59 // so need to do it here. Placing the titleView as a last child of
60 // internal view allows it to draw on top of the titlebar. 60 // internal view allows it to draw on top of the titlebar.
61 [[[[controller_ window] contentView] superview] addSubview:self]; 61 [[[[controller_ window] contentView] superview] addSubview:self];
62 62
63 // Figure out the rectangle of the titlebar and set us on top of it. 63 // Figure out the rectangle of the titlebar and set us on top of it.
64 // The titlebar covers window's root view where not covered by contentView. 64 // The titlebar covers window's root view where not covered by contentView.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return controller_; 125 return controller_;
126 } 126 }
127 127
128 // (Private/TestingAPI) 128 // (Private/TestingAPI)
129 - (void)simulateCloseButtonClick { 129 - (void)simulateCloseButtonClick {
130 [[closeButton_ cell] performClick:closeButton_]; 130 [[closeButton_ cell] performClick:closeButton_];
131 } 131 }
132 132
133 @end 133 @end
134 134
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698