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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm

Issue 1608001: [Mac] Line up omnibox popup under field. (Closed)
Patch Set: Wordsmith and test fix. Created 10 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.mm » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/text_elider.h" 8 #include "app/text_elider.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_edit.h" 10 #include "chrome/browser/autocomplete/autocomplete_edit.h"
11 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" 11 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
13 #include "chrome/browser/bubble_positioner.h" 13 #include "chrome/browser/bubble_positioner.h"
14 #include "chrome/browser/cocoa/event_utils.h" 14 #include "chrome/browser/cocoa/event_utils.h"
15 #include "gfx/rect.h" 15 #include "gfx/rect.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 17 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
18 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
18 19
19 namespace { 20 namespace {
20 21
21 // The size delta between the font used for the edit and the result 22 // The size delta between the font used for the edit and the result
22 // rows. 23 // rows.
23 const int kEditFontAdjust = -1; 24 const int kEditFontAdjust = -1;
24 25
25 // How much to adjust the cell sizing up from the default determined 26 // How much to adjust the cell sizing up from the default determined
26 // by the font. 27 // by the font.
27 const int kCellHeightAdjust = 7.0; 28 const int kCellHeightAdjust = 7.0;
28 29
29 // How to round off the popup's corners. Goal is to match star and go 30 // How to round off the popup's corners. Goal is to match star and go
30 // buttons. 31 // buttons.
31 const CGFloat kPopupRoundingRadius = 3.5; 32 const CGFloat kPopupRoundingRadius = 3.5;
32 33
33 // Gap between the field and the popup. 34 // Gap between the field and the popup.
34 const CGFloat kPopupFieldGap = 2.0; 35 const CGFloat kPopupFieldGap = 0.0;
35 36
36 // How opaque the popup window should be. This matches Windows (see 37 // How opaque the popup window should be. This matches Windows (see
37 // autocomplete_popup_contents_view.cc, kGlassPopupTransparency). 38 // autocomplete_popup_contents_view.cc, kGlassPopupTransparency).
38 const CGFloat kPopupAlpha = 240.0 / 255.0; 39 const CGFloat kPopupAlpha = 240.0 / 255.0;
39 40
40 // How much space to leave for the left and right margins. 41 // How much space to leave for the left and right margins.
41 const CGFloat kLeftRightMargin = 8.0; 42 const CGFloat kLeftRightMargin = 8.0;
42 43
43 // How far to offset the text column from the left. 44 // How far to offset the text column from the left.
44 const CGFloat kTextXOffset = 33.0; 45 const CGFloat kTextXOffset = 33.0;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 return -1; 659 return -1;
659 } 660 }
660 661
661 - (BOOL)isOpaque { 662 - (BOOL)isOpaque {
662 return NO; 663 return NO;
663 } 664 }
664 665
665 // This handles drawing the decorations of the rounded popup window, 666 // This handles drawing the decorations of the rounded popup window,
666 // calling on NSMatrix to draw the actual contents. 667 // calling on NSMatrix to draw the actual contents.
667 - (void)drawRect:(NSRect)rect { 668 - (void)drawRect:(NSRect)rect {
669 // Apparently this expects flipped coordinates, because in order to
670 // round the bottom corners visually, I need to specify the top
671 // corners here.
668 NSBezierPath* path = 672 NSBezierPath* path =
669 [NSBezierPath bezierPathWithRoundedRect:[self bounds] 673 [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
670 xRadius:kPopupRoundingRadius 674 topLeftCornerRadius:kPopupRoundingRadius
671 yRadius:kPopupRoundingRadius]; 675 topRightCornerRadius:kPopupRoundingRadius
676 bottomLeftCornerRadius:0.0
677 bottomRightCornerRadius:0.0];
672 678
673 // Draw the matrix clipped to our border. 679 // Draw the matrix clipped to our border.
674 [NSGraphicsContext saveGraphicsState]; 680 [NSGraphicsContext saveGraphicsState];
675 [path addClip]; 681 [path addClip];
676 [super drawRect:rect]; 682 [super drawRect:rect];
677 [NSGraphicsContext restoreGraphicsState]; 683 [NSGraphicsContext restoreGraphicsState];
678 } 684 }
679 685
680 @end 686 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698