summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 17:34:58 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-14 17:34:58 +0000
commit7baf46862541a89e11d95bbf4cf43f280f70aa18 (patch)
tree9d6c13e1cd2e04c95c008bfd4370ac4c539d70ee
parentd74fc80f7b879c62b3e53a2f22f323c07c36efbf (diff)
downloadchromium_src-7baf46862541a89e11d95bbf4cf43f280f70aa18.zip
chromium_src-7baf46862541a89e11d95bbf4cf43f280f70aa18.tar.gz
chromium_src-7baf46862541a89e11d95bbf4cf43f280f70aa18.tar.bz2
[Mac] Fix search icon in keyword search to be right-side-up.
The search icon (magnifying glass) in the keyword-search bubble was inverted. The icon was shared with other code which called |-setFlipped:| incompatibly. Also line up the icon above the popup icons, and match the text baseline with the field's baseline. BUG=41012 TEST=Type "google.com" then TAB. Mag glass is upright (like in popup). Review URL: http://codereview.chromium.org/1574026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44492 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm31
1 files changed, 27 insertions, 4 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index ab9f7c8..ae9777f 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -9,6 +9,19 @@
#include "gfx/font.h"
#include "grit/theme_resources.h"
+@interface AutocompleteTextAttachmentCell : NSTextAttachmentCell {
+}
+
+// TODO(shess):
+// Override -cellBaselineOffset to allow the image to be shifted up or
+// down relative to the containing text's baseline.
+
+// Draw the image using |DrawImageInRect()| helper function for
+// |-setFlipped:| consistency with other image drawing.
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)aView;
+
+@end
+
namespace {
const CGFloat kBaselineAdjust = 2.0;
@@ -38,7 +51,7 @@ const NSInteger kKeywordHintImageBaseline = -6;
// Drops the magnifying glass icon so that it looks centered in the
// keyword-search bubble.
-const NSInteger kKeywordSearchImageBaseline = -4;
+const NSInteger kKeywordSearchImageBaseline = -5;
// The amount of padding on either side reserved for drawing an icon.
const NSInteger kIconHorizontalPad = 3;
@@ -85,8 +98,8 @@ void DrawImageInRect(NSImage* image, NSView* view, const NSRect& rect) {
// it down.
NSAttributedString* AttributedStringForImage(NSImage* anImage,
CGFloat baselineAdjustment) {
- scoped_nsobject<NSTextAttachmentCell> attachmentCell(
- [[NSTextAttachmentCell alloc] initImageCell:anImage]);
+ scoped_nsobject<AutocompleteTextAttachmentCell> attachmentCell(
+ [[AutocompleteTextAttachmentCell alloc] initImageCell:anImage]);
scoped_nsobject<NSTextAttachment> attachment(
[[NSTextAttachment alloc] init]);
[attachment setAttachmentCell:attachmentCell];
@@ -103,6 +116,16 @@ NSAttributedString* AttributedStringForImage(NSImage* anImage,
} // namespace
+@implementation AutocompleteTextAttachmentCell
+
+- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)aView {
+ // Draw image with |DrawImageInRect()| to get consistent
+ // |-setFlipped:| treatment.
+ DrawImageInRect([self image], aView, cellFrame);
+}
+
+@end
+
@implementation AutocompleteTextFieldIcon
@synthesize rect = rect_;
@@ -470,7 +493,7 @@ NSAttributedString* AttributedStringForImage(NSImage* anImage,
[path stroke];
// Draw text w/in the rectangle.
- infoFrame.origin.x += 4.0;
+ infoFrame.origin.x += 3.0;
[keywordString_.get() drawInRect:infoFrame];
}