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

Side by Side Diff: ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.mm

Issue 2602903002: Factor iOS native image loading into a utility function. (Closed)
Patch Set: Fixed BUILD files. Created 3 years, 11 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
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 "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h" 5 #import "ios/chrome/browser/ui/omnibox/omnibox_text_field_ios.h"
6 6
7 #import <CoreText/CoreText.h> 7 #import <CoreText/CoreText.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 10 matching lines...) Expand all
21 #import "ios/chrome/browser/ui/reversed_animation.h" 21 #import "ios/chrome/browser/ui/reversed_animation.h"
22 #include "ios/chrome/browser/ui/rtl_geometry.h" 22 #include "ios/chrome/browser/ui/rtl_geometry.h"
23 #include "ios/chrome/browser/ui/ui_util.h" 23 #include "ios/chrome/browser/ui/ui_util.h"
24 #import "ios/chrome/browser/ui/uikit_ui_util.h" 24 #import "ios/chrome/browser/ui/uikit_ui_util.h"
25 #import "ios/chrome/common/material_timing.h" 25 #import "ios/chrome/common/material_timing.h"
26 #include "ios/chrome/grit/ios_strings.h" 26 #include "ios/chrome/grit/ios_strings.h"
27 #include "ios/chrome/grit/ios_theme_resources.h" 27 #include "ios/chrome/grit/ios_theme_resources.h"
28 #include "skia/ext/skia_utils_ios.h" 28 #include "skia/ext/skia_utils_ios.h"
29 #include "third_party/google_toolbox_for_mac/src/iPhone/GTMFadeTruncatingLabel.h " 29 #include "third_party/google_toolbox_for_mac/src/iPhone/GTMFadeTruncatingLabel.h "
30 #include "ui/base/l10n/l10n_util_mac.h" 30 #include "ui/base/l10n/l10n_util_mac.h"
31 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/gfx/color_palette.h" 31 #include "ui/gfx/color_palette.h"
33 #include "ui/gfx/image/image.h" 32 #include "ui/gfx/image/image.h"
34 #import "ui/gfx/ios/NSString+CrStringDrawing.h" 33 #import "ui/gfx/ios/NSString+CrStringDrawing.h"
35 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" 34 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h"
36 35
37 namespace { 36 namespace {
38 const CGFloat kFontSize = 16; 37 const CGFloat kFontSize = 16;
39 const CGFloat kEditingRectX = 16; 38 const CGFloat kEditingRectX = 16;
40 const CGFloat kEditingRectWidthInset = 10; 39 const CGFloat kEditingRectWidthInset = 10;
41 const CGFloat kTextInset = 8; 40 const CGFloat kTextInset = 8;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // Only set the chip image if the omnibox is in focus. 400 // Only set the chip image if the omnibox is in focus.
402 if ([self isShowingQueryRefinementChip]) { 401 if ([self isShowingQueryRefinementChip]) {
403 [leftViewButton setTitle:_chipText forState:UIControlStateNormal]; 402 [leftViewButton setTitle:_chipText forState:UIControlStateNormal];
404 [leftViewButton setImage:nil forState:UIControlStateNormal]; 403 [leftViewButton setImage:nil forState:UIControlStateNormal];
405 [leftViewButton 404 [leftViewButton
406 setTitleEdgeInsets:UIEdgeInsetsMake(kChipTextTopInset, 405 setTitleEdgeInsets:UIEdgeInsetsMake(kChipTextTopInset,
407 kChipTextLeftInset, 0, 0)]; 406 kChipTextLeftInset, 0, 0)];
408 // For iPhone, the left view is only updated when not in editing mode (i.e. 407 // For iPhone, the left view is only updated when not in editing mode (i.e.
409 // the text field is not first responder). 408 // the text field is not first responder).
410 } else if (_leftViewImageId && (IsIPadIdiom() || ![self isFirstResponder])) { 409 } else if (_leftViewImageId && (IsIPadIdiom() || ![self isFirstResponder])) {
411 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 410 UIImage* image = [NativeImage(_leftViewImageId)
412 gfx::Image defaultImage = rb.GetNativeImageNamed(_leftViewImageId);
413 UIImage* image = [defaultImage.ToUIImage()
414 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; 411 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
415 UIImageView* imageView = 412 UIImageView* imageView =
416 [[[UIImageView alloc] initWithImage:image] autorelease]; 413 [[[UIImageView alloc] initWithImage:image] autorelease];
417 [leftViewButton setImage:imageView.image forState:UIControlStateNormal]; 414 [leftViewButton setImage:imageView.image forState:UIControlStateNormal];
418 [leftViewButton setTitle:nil forState:UIControlStateNormal]; 415 [leftViewButton setTitle:nil forState:UIControlStateNormal];
419 UIColor* tint = [UIColor whiteColor]; 416 UIColor* tint = [UIColor whiteColor];
420 if (!_incognito) { 417 if (!_incognito) {
421 switch (_leftViewImageId) { 418 switch (_leftViewImageId) {
422 case IDR_IOS_LOCATION_BAR_HTTP: 419 case IDR_IOS_LOCATION_BAR_HTTP:
423 tint = [UIColor darkGrayColor]; 420 tint = [UIColor darkGrayColor];
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 // Disable the RTL arrow menu item. The omnibox sets alignment based on the 1041 // Disable the RTL arrow menu item. The omnibox sets alignment based on the
1045 // text in the field, and should not be overridden. 1042 // text in the field, and should not be overridden.
1046 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) { 1043 if ([NSStringFromSelector(action) hasPrefix:@"makeTextWritingDirection"]) {
1047 return NO; 1044 return NO;
1048 } 1045 }
1049 1046
1050 return [super canPerformAction:action withSender:sender]; 1047 return [super canPerformAction:action withSender:sender];
1051 } 1048 }
1052 1049
1053 @end 1050 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698