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

Side by Side Diff: chrome/browser/cocoa/location_bar/bubble_decoration.mm

Issue 3086006: Merge 54410 - [Mac] Un-tweak omnibox height and spacing and font.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 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
« no previous file with comments | « chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <cmath> 5 #include <cmath>
6 6
7 #import "chrome/browser/cocoa/location_bar/bubble_decoration.h" 7 #import "chrome/browser/cocoa/location_bar/bubble_decoration.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "chrome/browser/cocoa/image_utils.h" 10 #import "chrome/browser/cocoa/image_utils.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Padding between the icon/label and bubble edges. 14 // Padding between the icon/label and bubble edges.
15 const CGFloat kBubblePadding = 3.0; 15 const CGFloat kBubblePadding = 3.0;
16 16
17 // The image needs to be in the same position as for the location 17 // The image needs to be in the same position as for the location
18 // icon, which implies that the bubble's padding in the Omnibox needs 18 // icon, which implies that the bubble's padding in the Omnibox needs
19 // to differ from the location icon's. Indeed, that's how the views 19 // to differ from the location icon's. Indeed, that's how the views
20 // implementation handles the problem. This draws the bubble edge a 20 // implementation handles the problem. This draws the bubble edge a
21 // little bit further left, which is easier but no less hacky. 21 // little bit further left, which is easier but no less hacky.
22 const CGFloat kLeftSideOverdraw = 1.0; 22 const CGFloat kLeftSideOverdraw = 2.0;
23 23
24 // Omnibox corner radius is |4.0|, this needs to look tight WRT that. 24 // Omnibox corner radius is |4.0|, this needs to look tight WRT that.
25 const CGFloat kBubbleCornerRadius = 2.0; 25 const CGFloat kBubbleCornerRadius = 2.0;
26 26
27 // How far to inset the bubble from the top and bottom of the drawing 27 // How far to inset the bubble from the top and bottom of the drawing
28 // frame. 28 // frame.
29 // TODO(shess): Would be nicer to have the drawing code factor out the 29 // TODO(shess): Would be nicer to have the drawing code factor out the
30 // space outside the border, and perhaps the border. Then this could 30 // space outside the border, and perhaps the border. Then this could
31 // reflect the single pixel space w/in that. 31 // reflect the single pixel space w/in that.
32 const CGFloat kBubbleYInset = 4.0; 32 const CGFloat kBubbleYInset = 4.0;
33 33
34 // How far to inset the text from the edge of the bubble.
35 const CGFloat kTextYInset = 1.0;
36
37 } // namespace 34 } // namespace
38 35
39 BubbleDecoration::BubbleDecoration(NSFont* font) { 36 BubbleDecoration::BubbleDecoration(NSFont* font) {
40 DCHECK(font); 37 DCHECK(font);
41 if (font) { 38 if (font) {
42 NSDictionary* attributes = 39 NSDictionary* attributes =
43 [NSDictionary dictionaryWithObject:font 40 [NSDictionary dictionaryWithObject:font
44 forKey:NSFontAttributeName]; 41 forKey:NSFontAttributeName];
45 attributes_.reset([attributes retain]); 42 attributes_.reset([attributes retain]);
46 } 43 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 fraction:1.0 119 fraction:1.0
123 neverFlipped:YES]; 120 neverFlipped:YES];
124 } else { 121 } else {
125 imageRect.size = NSZeroSize; 122 imageRect.size = NSZeroSize;
126 } 123 }
127 124
128 if (label_) { 125 if (label_) {
129 NSRect textRect = decorationFrame; 126 NSRect textRect = decorationFrame;
130 textRect.origin.x = NSMaxX(imageRect); 127 textRect.origin.x = NSMaxX(imageRect);
131 textRect.size.width = NSMaxX(decorationFrame) - NSMinX(textRect); 128 textRect.size.width = NSMaxX(decorationFrame) - NSMinX(textRect);
132 textRect.origin.y += kTextYInset;
133 [label_ drawInRect:textRect withAttributes:attributes_]; 129 [label_ drawInRect:textRect withAttributes:attributes_];
134 } 130 }
135 } 131 }
136 132
137 NSImage* BubbleDecoration::GetImage() { 133 NSImage* BubbleDecoration::GetImage() {
138 return image_; 134 return image_;
139 } 135 }
140 136
141 void BubbleDecoration::SetImage(NSImage* image) { 137 void BubbleDecoration::SetImage(NSImage* image) {
142 image_.reset([image retain]); 138 image_.reset([image retain]);
(...skipping 10 matching lines...) Expand all
153 void BubbleDecoration::SetColors(NSColor* border_color, 149 void BubbleDecoration::SetColors(NSColor* border_color,
154 NSColor* background_color, 150 NSColor* background_color,
155 NSColor* text_color) { 151 NSColor* text_color) {
156 border_color_.reset([border_color retain]); 152 border_color_.reset([border_color retain]);
157 background_color_.reset([background_color retain]); 153 background_color_.reset([background_color retain]);
158 154
159 scoped_nsobject<NSMutableDictionary> attributes([attributes_ mutableCopy]); 155 scoped_nsobject<NSMutableDictionary> attributes([attributes_ mutableCopy]);
160 [attributes setObject:text_color forKey:NSForegroundColorAttributeName]; 156 [attributes setObject:text_color forKey:NSForegroundColorAttributeName];
161 attributes_.reset([attributes copy]); 157 attributes_.reset([attributes copy]);
162 } 158 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698