| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "ui/native_theme/native_theme_mac.h" | 5 #include "ui/native_theme/native_theme_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 // static | 121 // static |
| 122 SkColor NativeThemeMac::ApplySystemControlTint(SkColor color) { | 122 SkColor NativeThemeMac::ApplySystemControlTint(SkColor color) { |
| 123 if ([NSColor currentControlTint] == NSGraphiteControlTint) | 123 if ([NSColor currentControlTint] == NSGraphiteControlTint) |
| 124 return ColorToGrayscale(color); | 124 return ColorToGrayscale(color); |
| 125 return color; | 125 return color; |
| 126 } | 126 } |
| 127 | 127 |
| 128 SkColor NativeThemeMac::GetSystemColor(ColorId color_id) const { | 128 SkColor NativeThemeMac::GetSystemColor(ColorId color_id) const { |
| 129 // Even with --secondary-ui-md, menus use the platform colors and styling. |
| 130 switch (color_id) { |
| 131 case kColorId_EnabledMenuItemForegroundColor: |
| 132 return NSSystemColorToSkColor([NSColor controlTextColor]); |
| 133 case kColorId_DisabledMenuItemForegroundColor: |
| 134 case kColorId_DisabledEmphasizedMenuItemForegroundColor: |
| 135 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); |
| 136 case kColorId_SelectedMenuItemForegroundColor: |
| 137 return NSSystemColorToSkColor([NSColor selectedMenuItemTextColor]); |
| 138 case kColorId_FocusedMenuItemBackgroundColor: |
| 139 case kColorId_HoverMenuItemBackgroundColor: |
| 140 return NSSystemColorToSkColor([NSColor selectedMenuItemColor]); |
| 141 case kColorId_MenuBackgroundColor: |
| 142 return kMenuPopupBackgroundColor; |
| 143 case kColorId_MenuSeparatorColor: |
| 144 return base::mac::IsOS10_9() ? kMenuSeparatorColorMavericks |
| 145 : kMenuSeparatorColor; |
| 146 case kColorId_MenuBorderColor: |
| 147 return kMenuBorderColor; |
| 148 default: |
| 149 break; |
| 150 } |
| 151 |
| 129 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 152 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 130 return ApplySystemControlTint(GetAuraColor(color_id, this)); | 153 return ApplySystemControlTint(GetAuraColor(color_id, this)); |
| 131 | 154 |
| 132 // TODO(tapted): Add caching for these, and listen for | 155 // TODO(tapted): Add caching for these, and listen for |
| 133 // NSSystemColorsDidChangeNotification. | 156 // NSSystemColorsDidChangeNotification. |
| 134 switch (color_id) { | 157 switch (color_id) { |
| 135 case kColorId_WindowBackground: | 158 case kColorId_WindowBackground: |
| 136 return NSSystemColorToSkColor([NSColor windowBackgroundColor]); | 159 return NSSystemColorToSkColor([NSColor windowBackgroundColor]); |
| 137 case kColorId_DialogBackground: | 160 case kColorId_DialogBackground: |
| 138 return kDialogBackgroundColor; | 161 return kDialogBackgroundColor; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 161 case kColorId_LabelDisabledColor: | 184 case kColorId_LabelDisabledColor: |
| 162 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); | 185 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); |
| 163 case kColorId_ButtonHighlightColor: | 186 case kColorId_ButtonHighlightColor: |
| 164 // Although the NSColor documentation names "selectedControlTextColor" as | 187 // Although the NSColor documentation names "selectedControlTextColor" as |
| 165 // the color for a "text in a .. control being clicked or dragged", it | 188 // the color for a "text in a .. control being clicked or dragged", it |
| 166 // remains black, and text on Yosemite-style pressed buttons is white. | 189 // remains black, and text on Yosemite-style pressed buttons is white. |
| 167 return SK_ColorWHITE; | 190 return SK_ColorWHITE; |
| 168 case kColorId_ButtonHoverColor: | 191 case kColorId_ButtonHoverColor: |
| 169 return NSSystemColorToSkColor([NSColor selectedControlTextColor]); | 192 return NSSystemColorToSkColor([NSColor selectedControlTextColor]); |
| 170 | 193 |
| 171 // Menus. | |
| 172 case kColorId_EnabledMenuItemForegroundColor: | |
| 173 return NSSystemColorToSkColor([NSColor controlTextColor]); | |
| 174 case kColorId_DisabledMenuItemForegroundColor: | |
| 175 case kColorId_DisabledEmphasizedMenuItemForegroundColor: | |
| 176 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); | |
| 177 case kColorId_SelectedMenuItemForegroundColor: | |
| 178 return NSSystemColorToSkColor([NSColor selectedMenuItemTextColor]); | |
| 179 case kColorId_FocusedMenuItemBackgroundColor: | |
| 180 case kColorId_HoverMenuItemBackgroundColor: | |
| 181 return NSSystemColorToSkColor([NSColor selectedMenuItemColor]); | |
| 182 case kColorId_MenuBackgroundColor: | |
| 183 return kMenuPopupBackgroundColor; | |
| 184 case kColorId_MenuSeparatorColor: | |
| 185 return base::mac::IsOS10_9() ? kMenuSeparatorColorMavericks | |
| 186 : kMenuSeparatorColor; | |
| 187 case kColorId_MenuBorderColor: | |
| 188 return kMenuBorderColor; | |
| 189 | |
| 190 // Link. | 194 // Link. |
| 191 case kColorId_LinkDisabled: | 195 case kColorId_LinkDisabled: |
| 192 return SK_ColorBLACK; | 196 return SK_ColorBLACK; |
| 193 case kColorId_LinkEnabled: | 197 case kColorId_LinkEnabled: |
| 194 return SK_ColorBLUE; | 198 return SK_ColorBLUE; |
| 195 case kColorId_LinkPressed: | 199 case kColorId_LinkPressed: |
| 196 return SK_ColorRED; | 200 return SK_ColorRED; |
| 197 | 201 |
| 198 // Text fields. | 202 // Text fields. |
| 199 case kColorId_TextfieldDefaultColor: | 203 case kColorId_TextfieldDefaultColor: |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 canvas->drawDRRect(outer_shape, shape, paint); | 425 canvas->drawDRRect(outer_shape, shape, paint); |
| 422 } | 426 } |
| 423 | 427 |
| 424 NativeThemeMac::NativeThemeMac() { | 428 NativeThemeMac::NativeThemeMac() { |
| 425 } | 429 } |
| 426 | 430 |
| 427 NativeThemeMac::~NativeThemeMac() { | 431 NativeThemeMac::~NativeThemeMac() { |
| 428 } | 432 } |
| 429 | 433 |
| 430 } // namespace ui | 434 } // namespace ui |
| OLD | NEW |