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

Side by Side Diff: chrome/browser/ui/cocoa/info_bubble_view.mm

Issue 10827029: [Mac] Website settings: Implement custom tab appearance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up visuals, and address rsesek's comments. Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/cocoa/info_bubble_view.h" 5 #import "chrome/browser/ui/cocoa/info_bubble_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 9
10 @implementation InfoBubbleView 10 @implementation InfoBubbleView
11 11
12 @synthesize arrowLocation = arrowLocation_; 12 @synthesize arrowLocation = arrowLocation_;
13 @synthesize alignment = alignment_; 13 @synthesize alignment = alignment_;
14 @synthesize backgroundColor = backgroundColor_;
14 15
15 - (id)initWithFrame:(NSRect)frameRect { 16 - (id)initWithFrame:(NSRect)frameRect {
16 if ((self = [super initWithFrame:frameRect])) { 17 if ((self = [super initWithFrame:frameRect])) {
17 arrowLocation_ = info_bubble::kTopLeft; 18 arrowLocation_ = info_bubble::kTopLeft;
18 alignment_ = info_bubble::kAlignArrowToAnchor; 19 alignment_ = info_bubble::kAlignArrowToAnchor;
20 [self setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.9]];
19 } 21 }
20 return self; 22 return self;
21 } 23 }
22 24
23 - (void)drawRect:(NSRect)rect { 25 - (void)drawRect:(NSRect)rect {
24 // Make room for the border to be seen. 26 // Make room for the border to be seen.
25 NSRect bounds = [self bounds]; 27 NSRect bounds = [self bounds];
26 if (arrowLocation_ != info_bubble::kNoArrow) { 28 if (arrowLocation_ != info_bubble::kNoArrow) {
27 bounds.size.height -= info_bubble::kBubbleArrowHeight; 29 bounds.size.height -= info_bubble::kBubbleArrowHeight;
28 } 30 }
(...skipping 26 matching lines...) Expand all
55 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; 57 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)];
56 if (arrowLocation_ != info_bubble::kNoArrow) { 58 if (arrowLocation_ != info_bubble::kNoArrow) {
57 [bezier lineToPoint:NSMakePoint(arrowStart.x + 59 [bezier lineToPoint:NSMakePoint(arrowStart.x +
58 info_bubble::kBubbleArrowWidth / 2.0, 60 info_bubble::kBubbleArrowWidth / 2.0,
59 arrowStart.y + 61 arrowStart.y +
60 info_bubble::kBubbleArrowHeight)]; 62 info_bubble::kBubbleArrowHeight)];
61 } 63 }
62 [bezier lineToPoint:NSMakePoint(arrowStart.x + info_bubble::kBubbleArrowWidth, 64 [bezier lineToPoint:NSMakePoint(arrowStart.x + info_bubble::kBubbleArrowWidth,
63 arrowStart.y)]; 65 arrowStart.y)];
64 [bezier closePath]; 66 [bezier closePath];
65 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.9] set]; 67 [backgroundColor_ set];
66 [bezier fill]; 68 [bezier fill];
67 } 69 }
68 70
69 - (NSPoint)arrowTip { 71 - (NSPoint)arrowTip {
70 NSRect bounds = [self bounds]; 72 NSRect bounds = [self bounds];
71 CGFloat tipXOffset = 73 CGFloat tipXOffset =
72 info_bubble::kBubbleArrowXOffset + info_bubble::kBubbleArrowWidth / 2.0; 74 info_bubble::kBubbleArrowXOffset + info_bubble::kBubbleArrowWidth / 2.0;
73 CGFloat xOffset = 75 CGFloat xOffset =
74 (arrowLocation_ == info_bubble::kTopRight) ? NSMaxX(bounds) - tipXOffset : 76 (arrowLocation_ == info_bubble::kTopRight) ? NSMaxX(bounds) - tipXOffset :
75 NSMinX(bounds) + tipXOffset; 77 NSMinX(bounds) + tipXOffset;
76 NSPoint arrowTip = NSMakePoint(xOffset, NSMaxY(bounds)); 78 NSPoint arrowTip = NSMakePoint(xOffset, NSMaxY(bounds));
77 return arrowTip; 79 return arrowTip;
78 } 80 }
79 81
80 @end 82 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698