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

Side by Side Diff: chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.mm

Issue 2644903004: Move around more vector icons. (Closed)
Patch Set: fix comment Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/device_chooser_content_view_cocoa.h" 5 #import "chrome/browser/ui/cocoa/device_chooser_content_view_cocoa.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #include "chrome/app/vector_icons/vector_icons.h"
12 #include "chrome/browser/chooser_controller/chooser_controller.h" 13 #include "chrome/browser/chooser_controller/chooser_controller.h"
13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h"
14 #include "chrome/browser/ui/cocoa/spinner_view.h" 15 #include "chrome/browser/ui/cocoa/spinner_view.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
16 #include "skia/ext/skia_utils_mac.h" 17 #include "skia/ext/skia_utils_mac.h"
17 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 18 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
18 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" 19 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
19 #include "ui/base/l10n/l10n_util_mac.h" 20 #include "ui/base/l10n/l10n_util_mac.h"
20 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/color_palette.h" 22 #include "ui/gfx/color_palette.h"
22 #include "ui/gfx/image/image_skia_util_mac.h" 23 #include "ui/gfx/image/image_skia_util_mac.h"
23 #include "ui/gfx/paint_vector_icon.h" 24 #include "ui/gfx/paint_vector_icon.h"
24 #include "ui/gfx/vector_icons_public.h"
25 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Chooser width. 29 // Chooser width.
30 const CGFloat kChooserWidth = 390.0f; 30 const CGFloat kChooserWidth = 390.0f;
31 31
32 // Chooser height. 32 // Chooser height.
33 const CGFloat kChooserHeight = 330.0f; 33 const CGFloat kChooserHeight = 330.0f;
34 34
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 isConnected:(bool)isConnected 140 isConnected:(bool)isConnected
141 isPaired:(bool)isPaired 141 isPaired:(bool)isPaired
142 rowHeight:(CGFloat)rowHeight 142 rowHeight:(CGFloat)rowHeight
143 textNeedIndentation:(bool)textNeedIndentation { 143 textNeedIndentation:(bool)textNeedIndentation {
144 if ((self = [super initWithFrame:NSZeroRect])) { 144 if ((self = [super initWithFrame:NSZeroRect])) {
145 // Create the views. 145 // Create the views.
146 // Image. 146 // Image.
147 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 147 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
148 NSImage* image = nullptr; 148 NSImage* image = nullptr;
149 if (isConnected) { 149 if (isConnected) {
150 image = gfx::NSImageFromImageSkia(gfx::CreateVectorIcon( 150 image = gfx::NSImageFromImageSkia(
151 gfx::VectorIconId::BLUETOOTH_CONNECTED, gfx::kChromeIconGrey)); 151 gfx::CreateVectorIcon(kBluetoothConnectedIcon, gfx::kChromeIconGrey));
152 } else if (level != -1) { 152 } else if (level != -1) {
153 DCHECK_GE(level, 0); 153 DCHECK_GE(level, 0);
154 DCHECK_LT(level, base::checked_cast<NSInteger>( 154 DCHECK_LT(level, base::checked_cast<NSInteger>(
155 arraysize(kSignalStrengthLevelImageIds))); 155 arraysize(kSignalStrengthLevelImageIds)));
156 image = rb.GetNativeImageNamed(kSignalStrengthLevelImageIds[level]) 156 image = rb.GetNativeImageNamed(kSignalStrengthLevelImageIds[level])
157 .ToNSImage(); 157 .ToNSImage();
158 } 158 }
159 159
160 CGFloat imageOriginX = kTableRowViewHorizontalPadding; 160 CGFloat imageOriginX = kTableRowViewHorizontalPadding;
161 CGFloat imageOriginY = (rowHeight - kRowViewImageSize) / 2; 161 CGFloat imageOriginY = (rowHeight - kRowViewImageSize) / 2;
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // Update the color of the text. 849 // Update the color of the text.
850 [[self tableRowViewText:rowIndex] 850 [[self tableRowViewText:rowIndex]
851 setTextColor:(isSelected ? [NSColor whiteColor] 851 setTextColor:(isSelected ? [NSColor whiteColor]
852 : [NSColor blackColor])]; 852 : [NSColor blackColor])];
853 853
854 // Update the color of the image. 854 // Update the color of the image.
855 if (chooserController_->ShouldShowIconBeforeText()) { 855 if (chooserController_->ShouldShowIconBeforeText()) {
856 if (chooserController_->IsConnected(rowIndex)) { 856 if (chooserController_->IsConnected(rowIndex)) {
857 [[self tableRowViewImage:rowIndex] 857 [[self tableRowViewImage:rowIndex]
858 setImage:gfx::NSImageFromImageSkia(gfx::CreateVectorIcon( 858 setImage:gfx::NSImageFromImageSkia(gfx::CreateVectorIcon(
859 gfx::VectorIconId::BLUETOOTH_CONNECTED, 859 kBluetoothConnectedIcon,
860 isSelected ? SK_ColorWHITE : gfx::kChromeIconGrey))]; 860 isSelected ? SK_ColorWHITE : gfx::kChromeIconGrey))];
861 } else { 861 } else {
862 int signalStrengthLevel = 862 int signalStrengthLevel =
863 chooserController_->GetSignalStrengthLevel(rowIndex); 863 chooserController_->GetSignalStrengthLevel(rowIndex);
864 if (signalStrengthLevel != -1) { 864 if (signalStrengthLevel != -1) {
865 int imageId = 865 int imageId =
866 isSelected 866 isSelected
867 ? kSignalStrengthLevelImageSelectedIds[signalStrengthLevel] 867 ? kSignalStrengthLevelImageSelectedIds[signalStrengthLevel]
868 : kSignalStrengthLevelImageIds[signalStrengthLevel]; 868 : kSignalStrengthLevelImageIds[signalStrengthLevel];
869 [[self tableRowViewImage:rowIndex] 869 [[self tableRowViewImage:rowIndex]
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 902
903 - (void)drawRect:(NSRect)rect { 903 - (void)drawRect:(NSRect)rect {
904 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill]; 904 [[NSColor colorWithCalibratedWhite:245.0f / 255.0f alpha:1.0f] setFill];
905 NSRect footnoteFrame = 905 NSRect footnoteFrame =
906 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_); 906 NSMakeRect(0.0f, 0.0f, kChooserWidth, separatorOriginY_);
907 NSRectFill(footnoteFrame); 907 NSRectFill(footnoteFrame);
908 [super drawRect:footnoteFrame]; 908 [super drawRect:footnoteFrame];
909 } 909 }
910 910
911 @end 911 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698