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

Unified Diff: chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm

Issue 2342723002: Reland: Update image and text color when row is selected in the chooser on Mac (Closed)
Patch Set: address comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm b/chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm
index 567c9fe27604ca7c9511ea5707e09a5a35b595d4..a173a716fb29368f4c218801358978c9fb4f8af0 100644
--- a/chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm
+++ b/chrome/browser/ui/cocoa/chooser_content_view_cocoa.mm
@@ -64,6 +64,10 @@ const CGFloat kTableRowViewVerticalPadding = 1.0f;
const int kSignalStrengthLevelImageIds[5] = {IDR_SIGNAL_0_BAR, IDR_SIGNAL_1_BAR,
IDR_SIGNAL_2_BAR, IDR_SIGNAL_3_BAR,
IDR_SIGNAL_4_BAR};
+const int kSignalStrengthLevelImageSelectedIds[5] = {
+ IDR_SIGNAL_0_BAR_SELECTED, IDR_SIGNAL_1_BAR_SELECTED,
+ IDR_SIGNAL_2_BAR_SELECTED, IDR_SIGNAL_3_BAR_SELECTED,
+ IDR_SIGNAL_4_BAR_SELECTED};
// Creates a label with |text|.
base::scoped_nsobject<NSTextField> CreateLabel(NSString* text) {
@@ -75,6 +79,7 @@ base::scoped_nsobject<NSTextField> CreateLabel(NSString* text) {
[label setSelectable:NO];
[label setStringValue:text];
[label setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+ [label setTextColor:[NSColor blackColor]];
[label sizeToFit];
return label;
}
@@ -805,6 +810,49 @@ void ChooserContentViewController::UpdateTableView() {
chooserController_->OpenHelpCenterUrl();
}
+- (void)updateContentRowColor {
+ NSInteger selectedRow = [tableView_ selectedRow];
+ NSInteger numRows = [self numberOfOptions];
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
+ for (NSInteger rowIndex = 0; rowIndex < numRows; ++rowIndex) {
+ // Update the color of the text.
+ [[self tableRowViewText:rowIndex]
+ setTextColor:(rowIndex == selectedRow ? [NSColor whiteColor]
+ : [NSColor blackColor])];
+
+ // Update the color of the image.
+ if (chooserController_->ShouldShowIconBeforeText()) {
+ if (chooserController_->IsConnected(rowIndex)) {
+ [[self tableRowViewImage:rowIndex]
+ setImage:gfx::NSImageFromImageSkia(gfx::CreateVectorIcon(
+ gfx::VectorIconId::BLUETOOTH_CONNECTED,
+ rowIndex == selectedRow ? SK_ColorWHITE
+ : gfx::kChromeIconGrey))];
+ } else {
+ int signalStrengthLevel =
+ chooserController_->GetSignalStrengthLevel(rowIndex);
+ if (signalStrengthLevel != -1) {
+ int imageId =
+ rowIndex == selectedRow
+ ? kSignalStrengthLevelImageSelectedIds[signalStrengthLevel]
+ : kSignalStrengthLevelImageIds[signalStrengthLevel];
+ [[self tableRowViewImage:rowIndex]
+ setImage:rb.GetNativeImageNamed(imageId).ToNSImage()];
+ }
+ }
+ }
+
+ // Update the color of paired status.
+ NSTextField* pairedStatusText = [self tableRowViewPairedStatus:rowIndex];
+ if (pairedStatusText) {
+ [pairedStatusText
+ setTextColor:(skia::SkColorToCalibratedNSColor(
+ rowIndex == selectedRow ? gfx::kGoogleGreen300
+ : gfx::kGoogleGreen700))];
+ }
+ }
+}
+
- (NSImageView*)tableRowViewImage:(NSInteger)row {
ChooserContentTableRowView* tableRowView =
[tableView_ viewAtColumn:0 row:row makeIfNecessary:YES];

Powered by Google App Engine
This is Rietveld 408576698