| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common_theme.h" | 5 #include "ui/native_theme/common_theme.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "ui/base/material_design/material_design_controller.h" | 10 #include "ui/base/material_design/material_design_controller.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 13 #include "ui/gfx/color_palette.h" | 13 #include "ui/gfx/color_palette.h" |
| 14 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
| 18 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 | 21 |
| 22 SkColor GetAuraColor(NativeTheme::ColorId color_id, | 22 SkColor GetAuraColor(NativeTheme::ColorId color_id, |
| 23 const NativeTheme* base_theme) { | 23 const NativeTheme* base_theme) { |
| 24 // Second wave of MD colors (colors that only appear in secondary UI). |
| 25 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 26 static const SkColor kPrimaryTextColor = SkColorSetRGB(0x33, 0x33, 0x33); |
| 27 |
| 28 if (color_id == NativeTheme::kColorId_LabelEnabledColor) |
| 29 return kPrimaryTextColor; |
| 30 if (color_id == NativeTheme::kColorId_UnfocusedBorderColor) |
| 31 return SkColorSetA(SK_ColorBLACK, 0x24); |
| 32 } |
| 33 |
| 24 // MD colors. | 34 // MD colors. |
| 25 if (ui::MaterialDesignController::IsModeMaterial()) { | 35 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 26 // Dialogs: | 36 // Dialogs: |
| 27 static const SkColor kDialogBackgroundColorMd = SK_ColorWHITE; | 37 static const SkColor kDialogBackgroundColorMd = SK_ColorWHITE; |
| 28 // Buttons: | 38 // Buttons: |
| 29 static const SkColor kButtonEnabledColorMd = gfx::kChromeIconGrey; | 39 static const SkColor kButtonEnabledColorMd = gfx::kChromeIconGrey; |
| 30 // MenuItem: | 40 // MenuItem: |
| 31 static const SkColor kMenuHighlightBackgroundColorMd = | 41 static const SkColor kMenuHighlightBackgroundColorMd = |
| 32 SkColorSetARGB(0x14, 0x00, 0x00, 0x00); | 42 SkColorSetARGB(0x14, 0x00, 0x00, 0x00); |
| 33 static const SkColor kSelectedMenuItemForegroundColorMd = SK_ColorBLACK; | 43 static const SkColor kSelectedMenuItemForegroundColorMd = SK_ColorBLACK; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 61 | 71 |
| 62 // Link | 72 // Link |
| 63 case NativeTheme::kColorId_LinkEnabled: | 73 case NativeTheme::kColorId_LinkEnabled: |
| 64 case NativeTheme::kColorId_LinkPressed: | 74 case NativeTheme::kColorId_LinkPressed: |
| 65 // Normal and pressed share a color. | 75 // Normal and pressed share a color. |
| 66 return kLinkEnabledColorMd; | 76 return kLinkEnabledColorMd; |
| 67 | 77 |
| 68 // FocusableBorder | 78 // FocusableBorder |
| 69 case NativeTheme::kColorId_FocusedBorderColor: | 79 case NativeTheme::kColorId_FocusedBorderColor: |
| 70 return gfx::kGoogleBlue500; | 80 return gfx::kGoogleBlue500; |
| 81 // TODO(estade): I'm not sure why this one is here but it should be |
| 82 // removed in favor of the value in the SecondaryUiMaterial block. |
| 71 case NativeTheme::kColorId_UnfocusedBorderColor: | 83 case NativeTheme::kColorId_UnfocusedBorderColor: |
| 72 return SkColorSetA(SK_ColorBLACK, 0x66); | 84 return SkColorSetA(SK_ColorBLACK, 0x66); |
| 73 | 85 |
| 74 // Results Tables | 86 // Results Tables |
| 75 case NativeTheme::kColorId_ResultsTableHoveredBackground: | 87 case NativeTheme::kColorId_ResultsTableHoveredBackground: |
| 76 return SkColorSetA(base_theme->GetSystemColor( | 88 return SkColorSetA(base_theme->GetSystemColor( |
| 77 NativeTheme::kColorId_ResultsTableNormalText), | 89 NativeTheme::kColorId_ResultsTableNormalText), |
| 78 0x0D); | 90 0x0D); |
| 79 case NativeTheme::kColorId_ResultsTableSelectedBackground: | 91 case NativeTheme::kColorId_ResultsTableSelectedBackground: |
| 80 return SkColorSetA(base_theme->GetSystemColor( | 92 return SkColorSetA(base_theme->GetSystemColor( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 97 case NativeTheme::kColorId_TooltipBackground: | 109 case NativeTheme::kColorId_TooltipBackground: |
| 98 return kTooltipBackgroundMd; | 110 return kTooltipBackgroundMd; |
| 99 case NativeTheme::kColorId_TooltipText: | 111 case NativeTheme::kColorId_TooltipText: |
| 100 return kTooltipTextColorMd; | 112 return kTooltipTextColorMd; |
| 101 | 113 |
| 102 default: | 114 default: |
| 103 break; | 115 break; |
| 104 } | 116 } |
| 105 } | 117 } |
| 106 | 118 |
| 107 // Second wave of MD colors (colors that only appear in secondary UI). | |
| 108 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { | |
| 109 static const SkColor kPrimaryTextColor = SkColorSetRGB(0x33, 0x33, 0x33); | |
| 110 | |
| 111 if (color_id == NativeTheme::kColorId_LabelEnabledColor) | |
| 112 return kPrimaryTextColor; | |
| 113 } | |
| 114 | |
| 115 // Pre-MD colors. | 119 // Pre-MD colors. |
| 116 // Windows: | 120 // Windows: |
| 117 static const SkColor kWindowBackgroundColor = SK_ColorWHITE; | 121 static const SkColor kWindowBackgroundColor = SK_ColorWHITE; |
| 118 // Dialogs: | 122 // Dialogs: |
| 119 static const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251); | 123 static const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251); |
| 120 // FocusableBorder: | 124 // FocusableBorder: |
| 121 static const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE); | 125 static const SkColor kFocusedBorderColor = SkColorSetRGB(0x4D, 0x90, 0xFE); |
| 122 static const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9); | 126 static const SkColor kUnfocusedBorderColor = SkColorSetRGB(0xD9, 0xD9, 0xD9); |
| 123 // Button: | 127 // Button: |
| 124 static const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE); | 128 static const SkColor kButtonBackgroundColor = SkColorSetRGB(0xDE, 0xDE, 0xDE); |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 } | 452 } |
| 449 if (menu_item.corner_radius > 0) { | 453 if (menu_item.corner_radius > 0) { |
| 450 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); | 454 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); |
| 451 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); | 455 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); |
| 452 return; | 456 return; |
| 453 } | 457 } |
| 454 canvas->drawRect(gfx::RectToSkRect(rect), paint); | 458 canvas->drawRect(gfx::RectToSkRect(rect), paint); |
| 455 } | 459 } |
| 456 | 460 |
| 457 } // namespace ui | 461 } // namespace ui |
| OLD | NEW |