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

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

Issue 11103042: New custom styling for action box menu on Os X. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Answered shess final round of comments. Created 8 years, 2 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 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" 9 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
10 10
11 @implementation InfoBubbleView 11 @implementation InfoBubbleView
12 12
13 @synthesize arrowLocation = arrowLocation_; 13 @synthesize arrowLocation = arrowLocation_;
14 @synthesize alignment = alignment_; 14 @synthesize alignment = alignment_;
15 @synthesize cornerFlags = cornerFlags_; 15 @synthesize cornerFlags = cornerFlags_;
16 16
17 - (id)initWithFrame:(NSRect)frameRect { 17 - (id)initWithFrame:(NSRect)frameRect {
18 if ((self = [super initWithFrame:frameRect])) { 18 if ((self = [super initWithFrame:frameRect])) {
19 arrowLocation_ = info_bubble::kTopLeft; 19 arrowLocation_ = info_bubble::kTopLeft;
20 alignment_ = info_bubble::kAlignArrowToAnchor; 20 alignment_ = info_bubble::kAlignArrowToAnchor;
21 cornerFlags_ = info_bubble::kRoundedAllCorners; 21 cornerFlags_ = info_bubble::kRoundedAllCorners;
22 backgroundColor_.reset([[NSColor whiteColor] retain]);
22 } 23 }
23 return self; 24 return self;
24 } 25 }
25 26
26 - (void)drawRect:(NSRect)rect { 27 - (void)drawRect:(NSRect)rect {
27 // Make room for the border to be seen. 28 // Make room for the border to be seen.
28 NSRect bounds = [self bounds]; 29 NSRect bounds = [self bounds];
29 if (arrowLocation_ != info_bubble::kNoArrow) { 30 if (arrowLocation_ != info_bubble::kNoArrow) {
30 bounds.size.height -= info_bubble::kBubbleArrowHeight; 31 bounds.size.height -= info_bubble::kBubbleArrowHeight;
31 } 32 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; 65 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)];
65 if (arrowLocation_ != info_bubble::kNoArrow) { 66 if (arrowLocation_ != info_bubble::kNoArrow) {
66 [bezier lineToPoint:NSMakePoint(arrowStart.x + 67 [bezier lineToPoint:NSMakePoint(arrowStart.x +
67 info_bubble::kBubbleArrowWidth / 2.0, 68 info_bubble::kBubbleArrowWidth / 2.0,
68 arrowStart.y + 69 arrowStart.y +
69 info_bubble::kBubbleArrowHeight)]; 70 info_bubble::kBubbleArrowHeight)];
70 } 71 }
71 [bezier lineToPoint:NSMakePoint(arrowStart.x + info_bubble::kBubbleArrowWidth, 72 [bezier lineToPoint:NSMakePoint(arrowStart.x + info_bubble::kBubbleArrowWidth,
72 arrowStart.y)]; 73 arrowStart.y)];
73 [bezier closePath]; 74 [bezier closePath];
74 [[NSColor whiteColor] set]; 75 [backgroundColor_ set];
75 [bezier fill]; 76 [bezier fill];
76 } 77 }
77 78
78 - (NSPoint)arrowTip { 79 - (NSPoint)arrowTip {
79 NSRect bounds = [self bounds]; 80 NSRect bounds = [self bounds];
80 CGFloat tipXOffset = 81 CGFloat tipXOffset =
81 info_bubble::kBubbleArrowXOffset + info_bubble::kBubbleArrowWidth / 2.0; 82 info_bubble::kBubbleArrowXOffset + info_bubble::kBubbleArrowWidth / 2.0;
82 CGFloat xOffset = 83 CGFloat xOffset =
83 (arrowLocation_ == info_bubble::kTopRight) ? NSMaxX(bounds) - tipXOffset : 84 (arrowLocation_ == info_bubble::kTopRight) ? NSMaxX(bounds) - tipXOffset :
84 NSMinX(bounds) + tipXOffset; 85 NSMinX(bounds) + tipXOffset;
85 NSPoint arrowTip = NSMakePoint(xOffset, NSMaxY(bounds)); 86 NSPoint arrowTip = NSMakePoint(xOffset, NSMaxY(bounds));
86 return arrowTip; 87 return arrowTip;
87 } 88 }
88 89
90 - (NSColor*)backgroundColor {
91 return backgroundColor_;
92 }
93
94 - (void)setBackgroundColor:(NSColor*)backgroundColor {
95 backgroundColor_.reset([backgroundColor retain]);
96 }
97
89 @end 98 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/info_bubble_view.h ('k') | chrome/browser/ui/cocoa/location_bar/action_box_menu_bubble_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698