| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_popup_material_row.h" | 5 #import "ios/chrome/browser/ui/omnibox/omnibox_popup_material_row.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/objc_property_releaser.h" | 8 #include "base/mac/objc_property_releaser.h" |
| 9 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" | 9 #import "ios/chrome/browser/ui/omnibox/truncating_attributed_label.h" |
| 10 #include "ios/chrome/browser/ui/rtl_geometry.h" | 10 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 11 #include "ios/chrome/browser/ui/ui_util.h" | 11 #include "ios/chrome/browser/ui/ui_util.h" |
| 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 13 #include "ios/chrome/grit/ios_theme_resources.h" | 13 #include "ios/chrome/grit/ios_theme_resources.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const CGFloat kImageDimensionLength = 19.0; | 16 const CGFloat kImageDimensionLength = 19.0; |
| 17 const CGFloat kLeadingPaddingIpad = 164; | 17 const CGFloat kLeadingPaddingIpad = 164; |
| 18 const CGFloat kLeadingPaddingIpadCompact = 71; | 18 const CGFloat kLeadingPaddingIpadCompact = 71; |
| 19 const CGFloat kAppendButtonTrailingMargin = 4; | 19 const CGFloat kAppendButtonTrailingMargin = 4; |
| 20 const CGFloat kAppendButtonSize = 48.0; |
| 20 } | 21 } |
| 21 | 22 |
| 22 @interface OmniboxPopupMaterialRow () { | 23 @interface OmniboxPopupMaterialRow () { |
| 23 BOOL _incognito; | 24 BOOL _incognito; |
| 24 base::mac::ObjCPropertyReleaser _propertyReleaser_OmniboxPopupMaterialRow; | 25 base::mac::ObjCPropertyReleaser _propertyReleaser_OmniboxPopupMaterialRow; |
| 25 } | 26 } |
| 26 | 27 |
| 27 // Set the append button normal and highlighted images. | 28 // Set the append button normal and highlighted images. |
| 28 - (void)updateAppendButtonImages; | 29 - (void)updateAppendButtonImages; |
| 29 | 30 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 [self updateAppendButtonImages]; | 72 [self updateAppendButtonImages]; |
| 72 // TODO(justincohen): Consider using the UITableViewCell's accessory view. | 73 // TODO(justincohen): Consider using the UITableViewCell's accessory view. |
| 73 // The current implementation is from before using a UITableViewCell. | 74 // The current implementation is from before using a UITableViewCell. |
| 74 [self addSubview:_appendButton]; | 75 [self addSubview:_appendButton]; |
| 75 | 76 |
| 76 _physicalWebButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; | 77 _physicalWebButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; |
| 77 [_physicalWebButton setContentMode:UIViewContentModeRight]; | 78 [_physicalWebButton setContentMode:UIViewContentModeRight]; |
| 78 [self updatePhysicalWebImage]; | 79 [self updatePhysicalWebImage]; |
| 79 [self addSubview:_physicalWebButton]; | 80 [self addSubview:_physicalWebButton]; |
| 80 | 81 |
| 81 // Left icon is only displayed on iPad. | 82 // Leading icon is only displayed on iPad. |
| 82 if (IsIPadIdiom()) { | 83 if (IsIPadIdiom()) { |
| 83 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; | 84 _imageView = [[UIImageView alloc] initWithFrame:CGRectZero]; |
| 84 _imageView.userInteractionEnabled = NO; | 85 _imageView.userInteractionEnabled = NO; |
| 85 _imageView.contentMode = UIViewContentModeCenter; | 86 _imageView.contentMode = UIViewContentModeCenter; |
| 86 | 87 |
| 87 // TODO(justincohen): Consider using the UITableViewCell's image view. | 88 // TODO(justincohen): Consider using the UITableViewCell's image view. |
| 88 // The current implementation is from before using a UITableViewCell. | 89 // The current implementation is from before using a UITableViewCell. |
| 89 [self addSubview:_imageView]; | 90 [self addSubview:_imageView]; |
| 90 } | 91 } |
| 91 | 92 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 103 } | 104 } |
| 104 | 105 |
| 105 - (void)layoutAccessoryViews { | 106 - (void)layoutAccessoryViews { |
| 106 LayoutRect imageViewLayout = LayoutRectMake( | 107 LayoutRect imageViewLayout = LayoutRectMake( |
| 107 IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad, | 108 IsCompactTablet() ? kLeadingPaddingIpadCompact : kLeadingPaddingIpad, |
| 108 CGRectGetWidth(self.bounds), | 109 CGRectGetWidth(self.bounds), |
| 109 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength, | 110 floor((_rowHeight - kImageDimensionLength) / 2), kImageDimensionLength, |
| 110 kImageDimensionLength); | 111 kImageDimensionLength); |
| 111 _imageView.frame = LayoutRectGetRect(imageViewLayout); | 112 _imageView.frame = LayoutRectGetRect(imageViewLayout); |
| 112 | 113 |
| 113 CGFloat appendButtonDimensionLength = CGRectGetHeight(self.bounds); | 114 LayoutRect trailingAccessoryLayout = LayoutRectMake( |
| 114 DCHECK_GT(appendButtonDimensionLength, 40); | 115 CGRectGetWidth(self.bounds) - kAppendButtonSize - |
| 115 LayoutRect rightAccessoryLayout = | 116 kAppendButtonTrailingMargin, |
| 116 LayoutRectMake(CGRectGetWidth(self.bounds) - appendButtonDimensionLength - | 117 CGRectGetWidth(self.bounds), floor((_rowHeight - kAppendButtonSize) / 2), |
| 117 kAppendButtonTrailingMargin, | 118 kAppendButtonSize, kAppendButtonSize); |
| 118 CGRectGetWidth(self.bounds), | 119 _appendButton.frame = LayoutRectGetRect(trailingAccessoryLayout); |
| 119 floor((_rowHeight - appendButtonDimensionLength) / 2), | 120 _physicalWebButton.frame = LayoutRectGetRect(trailingAccessoryLayout); |
| 120 appendButtonDimensionLength, appendButtonDimensionLength); | |
| 121 _appendButton.frame = LayoutRectGetRect(rightAccessoryLayout); | |
| 122 _physicalWebButton.frame = LayoutRectGetRect(rightAccessoryLayout); | |
| 123 } | 121 } |
| 124 | 122 |
| 125 - (void)updateLeftImage:(int)imageID { | 123 - (void)updateLeadingImage:(int)imageID { |
| 126 _imageView.image = NativeImage(imageID); | 124 _imageView.image = NativeImage(imageID); |
| 127 | 125 |
| 128 // Adjust the vertical position based on the current size of the row. | 126 // Adjust the vertical position based on the current size of the row. |
| 129 CGRect frame = _imageView.frame; | 127 CGRect frame = _imageView.frame; |
| 130 frame.origin.y = floor((_rowHeight - kImageDimensionLength) / 2); | 128 frame.origin.y = floor((_rowHeight - kImageDimensionLength) / 2); |
| 131 _imageView.frame = frame; | 129 _imageView.frame = frame; |
| 132 } | 130 } |
| 133 | 131 |
| 134 - (void)updateHighlightBackground:(BOOL)highlighted { | 132 - (void)updateHighlightBackground:(BOOL)highlighted { |
| 135 // Set the background color to match the color of selected table view cells | 133 // Set the background color to match the color of selected table view cells |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 178 |
| 181 - (NSString*)accessibilityLabel { | 179 - (NSString*)accessibilityLabel { |
| 182 return _textTruncatingLabel.attributedText.string; | 180 return _textTruncatingLabel.attributedText.string; |
| 183 } | 181 } |
| 184 | 182 |
| 185 - (NSString*)accessibilityValue { | 183 - (NSString*)accessibilityValue { |
| 186 return _detailTruncatingLabel.attributedText.string; | 184 return _detailTruncatingLabel.attributedText.string; |
| 187 } | 185 } |
| 188 | 186 |
| 189 @end | 187 @end |
| OLD | NEW |