| 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. | 129 // Even with --secondary-ui-md, menus use the platform colors and styling, and |
| 130 // Mac has a couple of specific color overrides. |
| 130 switch (color_id) { | 131 switch (color_id) { |
| 131 case kColorId_EnabledMenuItemForegroundColor: | 132 case kColorId_EnabledMenuItemForegroundColor: |
| 132 return NSSystemColorToSkColor([NSColor controlTextColor]); | 133 return NSSystemColorToSkColor([NSColor controlTextColor]); |
| 133 case kColorId_DisabledMenuItemForegroundColor: | 134 case kColorId_DisabledMenuItemForegroundColor: |
| 134 case kColorId_DisabledEmphasizedMenuItemForegroundColor: | 135 case kColorId_DisabledEmphasizedMenuItemForegroundColor: |
| 135 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); | 136 return NSSystemColorToSkColor([NSColor disabledControlTextColor]); |
| 136 case kColorId_SelectedMenuItemForegroundColor: | 137 case kColorId_SelectedMenuItemForegroundColor: |
| 137 return NSSystemColorToSkColor([NSColor selectedMenuItemTextColor]); | 138 return NSSystemColorToSkColor([NSColor selectedMenuItemTextColor]); |
| 138 case kColorId_FocusedMenuItemBackgroundColor: | 139 case kColorId_FocusedMenuItemBackgroundColor: |
| 139 case kColorId_HoverMenuItemBackgroundColor: | 140 case kColorId_HoverMenuItemBackgroundColor: |
| 140 return NSSystemColorToSkColor([NSColor selectedMenuItemColor]); | 141 return NSSystemColorToSkColor([NSColor selectedMenuItemColor]); |
| 141 case kColorId_MenuBackgroundColor: | 142 case kColorId_MenuBackgroundColor: |
| 142 return kMenuPopupBackgroundColor; | 143 return kMenuPopupBackgroundColor; |
| 143 case kColorId_MenuSeparatorColor: | 144 case kColorId_MenuSeparatorColor: |
| 144 return base::mac::IsOS10_9() ? kMenuSeparatorColorMavericks | 145 return base::mac::IsOS10_9() ? kMenuSeparatorColorMavericks |
| 145 : kMenuSeparatorColor; | 146 : kMenuSeparatorColor; |
| 146 case kColorId_MenuBorderColor: | 147 case kColorId_MenuBorderColor: |
| 147 return kMenuBorderColor; | 148 return kMenuBorderColor; |
| 149 |
| 150 case kColorId_ButtonPressedShade: |
| 151 return SkColorSetA(SK_ColorBLACK, 0x08); |
| 148 default: | 152 default: |
| 149 break; | 153 break; |
| 150 } | 154 } |
| 151 | 155 |
| 152 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 156 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 153 return ApplySystemControlTint(GetAuraColor(color_id, this)); | 157 return ApplySystemControlTint(GetAuraColor(color_id, this)); |
| 154 | 158 |
| 155 // TODO(tapted): Add caching for these, and listen for | 159 // TODO(tapted): Add caching for these, and listen for |
| 156 // NSSystemColorsDidChangeNotification. | 160 // NSSystemColorsDidChangeNotification. |
| 157 switch (color_id) { | 161 switch (color_id) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 canvas->drawDRRect(outer_shape, shape, paint); | 429 canvas->drawDRRect(outer_shape, shape, paint); |
| 426 } | 430 } |
| 427 | 431 |
| 428 NativeThemeMac::NativeThemeMac() { | 432 NativeThemeMac::NativeThemeMac() { |
| 429 } | 433 } |
| 430 | 434 |
| 431 NativeThemeMac::~NativeThemeMac() { | 435 NativeThemeMac::~NativeThemeMac() { |
| 432 } | 436 } |
| 433 | 437 |
| 434 } // namespace ui | 438 } // namespace ui |
| OLD | NEW |