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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm

Issue 1997473006: [Material][Mac]Move the Omnibox left icons 1px to the right (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « chrome/browser/ui/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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/omnibox/omnibox_popup_cell.h" 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 12 matching lines...) Expand all
23 #include "components/omnibox/browser/omnibox_popup_model.h" 23 #include "components/omnibox/browser/omnibox_popup_model.h"
24 #include "components/omnibox/browser/suggestion_answer.h" 24 #include "components/omnibox/browser/suggestion_answer.h"
25 #include "skia/ext/skia_utils_mac.h" 25 #include "skia/ext/skia_utils_mac.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/material_design/material_design_controller.h" 27 #include "ui/base/material_design/material_design_controller.h"
28 #include "ui/gfx/color_palette.h" 28 #include "ui/gfx/color_palette.h"
29 #include "ui/gfx/font.h" 29 #include "ui/gfx/font.h"
30 30
31 namespace { 31 namespace {
32 32
33 // How far to offset image column from the left.
34 const CGFloat kImageXOffset = 5.0;
35
36 // How far to offset text. 33 // How far to offset text.
37 const CGFloat kVerticalTextPadding = 3.0; 34 const CGFloat kVerticalTextPadding = 3.0;
38 35
39 const CGFloat kVerticalImagePadding = 3.0; 36 const CGFloat kVerticalImagePadding = 3.0;
40 const CGFloat kMaterialVerticalImagePadding = 5.0; 37 const CGFloat kMaterialVerticalImagePadding = 5.0;
41 38
42 const CGFloat kTextStartOffset = 28.0; 39 const CGFloat kTextStartOffset = 28.0;
43 const CGFloat kMaterialTextStartOffset = 26.0; 40 const CGFloat kMaterialTextStartOffset = 27.0;
44 41
45 // Rounding radius of selection and hover background on popup items. 42 // Rounding radius of selection and hover background on popup items.
46 const CGFloat kCellRoundingRadius = 2.0; 43 const CGFloat kCellRoundingRadius = 2.0;
47 44
48 // How far to offset the image. 45 // How far to offset the image.
49 CGFloat VerticalImagePadding() { 46 CGFloat VerticalImagePadding() {
50 if (!ui::MaterialDesignController::IsModeMaterial()) { 47 if (!ui::MaterialDesignController::IsModeMaterial()) {
51 return kVerticalImagePadding; 48 return kVerticalImagePadding;
52 } 49 }
53 return kMaterialVerticalImagePadding; 50 return kMaterialVerticalImagePadding;
54 } 51 }
55 52
53 // How far to offset the image column from the left.
54 CGFloat ImageXOffset() {
55 const CGFloat kImageXOffset = 5.0;
56 const CGFloat kMaterialImageXOffset = 6.0;
57 if (!ui::MaterialDesignController::IsModeMaterial()) {
58 return kImageXOffset;
59 }
60 return kMaterialImageXOffset;
61 }
62
56 // How far to offset the text column from the left. 63 // How far to offset the text column from the left.
57 CGFloat TextStartOffset() { 64 CGFloat TextStartOffset() {
58 if (!ui::MaterialDesignController::IsModeMaterial()) { 65 if (!ui::MaterialDesignController::IsModeMaterial()) {
59 return kTextStartOffset; 66 return kTextStartOffset;
60 } 67 }
61 return kMaterialTextStartOffset; 68 return kMaterialTextStartOffset;
62 } 69 }
63 70
64 // Flips the given |rect| in context of the given |frame|. 71 // Flips the given |rect| in context of the given |frame|.
65 NSRect FlipIfRTL(NSRect rect, NSRect frame) { 72 NSRect FlipIfRTL(NSRect rect, NSRect frame) {
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 !AutocompleteMatch::IsSearchType([cellData matchType]), 510 !AutocompleteMatch::IsSearchType([cellData matchType]),
504 &contentsMaxWidth, 511 &contentsMaxWidth,
505 &descriptionMaxWidth); 512 &descriptionMaxWidth);
506 513
507 NSWindow* parentWindow = [[controlView window] parentWindow]; 514 NSWindow* parentWindow = [[controlView window] parentWindow];
508 BOOL isDarkTheme = [parentWindow hasDarkTheme]; 515 BOOL isDarkTheme = [parentWindow hasDarkTheme];
509 NSRect imageRect = cellFrame; 516 NSRect imageRect = cellFrame;
510 NSImage* theImage = 517 NSImage* theImage =
511 isDarkTheme ? [cellData incognitoImage] : [cellData image]; 518 isDarkTheme ? [cellData incognitoImage] : [cellData image];
512 imageRect.size = [theImage size]; 519 imageRect.size = [theImage size];
513 imageRect.origin.x += kImageXOffset + [tableView contentLeftPadding]; 520 imageRect.origin.x += ImageXOffset() + [tableView contentLeftPadding];
514 imageRect.origin.y += VerticalImagePadding(); 521 imageRect.origin.y += VerticalImagePadding();
515 [theImage drawInRect:FlipIfRTL(imageRect, cellFrame) 522 [theImage drawInRect:FlipIfRTL(imageRect, cellFrame)
516 fromRect:NSZeroRect 523 fromRect:NSZeroRect
517 operation:NSCompositeSourceOver 524 operation:NSCompositeSourceOver
518 fraction:1.0 525 fraction:1.0
519 respectFlipped:YES 526 respectFlipped:YES
520 hints:nil]; 527 hints:nil];
521 528
522 NSPoint origin = NSMakePoint( 529 NSPoint origin = NSMakePoint(
523 TextStartOffset() + [tableView contentLeftPadding], kVerticalTextPadding); 530 TextStartOffset() + [tableView contentLeftPadding], kVerticalTextPadding);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset; 709 return base::i18n::IsRTL() ? (inputWidth - glyphOffset) : glyphOffset;
703 } 710 }
704 711
705 + (NSAttributedString*)createSeparatorStringForDarkTheme:(BOOL)isDarkTheme { 712 + (NSAttributedString*)createSeparatorStringForDarkTheme:(BOOL)isDarkTheme {
706 base::string16 raw_separator = 713 base::string16 raw_separator =
707 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); 714 l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR);
708 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme)); 715 return CreateAttributedString(raw_separator, DimTextColor(isDarkTheme));
709 } 716 }
710 717
711 @end 718 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/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