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/views/controls/menu/menu_item_view.h" | 5 #include "ui/views/controls/menu/menu_item_view.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "ui/accessibility/ax_view_state.h" | 13 #include "ui/accessibility/ax_view_state.h" |
14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/material_design/material_design_controller.h" | |
16 #include "ui/base/models/menu_model.h" | 15 #include "ui/base/models/menu_model.h" |
17 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
19 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
20 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
21 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/text_utils.h" | 21 #include "ui/gfx/text_utils.h" |
23 #include "ui/native_theme/common_theme.h" | 22 #include "ui/native_theme/common_theme.h" |
24 #include "ui/resources/grit/ui_resources.h" | 23 #include "ui/resources/grit/ui_resources.h" |
25 #include "ui/strings/grit/ui_strings.h" | 24 #include "ui/strings/grit/ui_strings.h" |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 ui::NativeTheme::kColorId_DisabledEmphasizedMenuItemForegroundColor : | 790 ui::NativeTheme::kColorId_DisabledEmphasizedMenuItemForegroundColor : |
792 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor; | 791 ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor; |
793 } | 792 } |
794 SkColor fg_color = native_theme->GetSystemColor(color_id); | 793 SkColor fg_color = native_theme->GetSystemColor(color_id); |
795 SkColor override_foreground_color; | 794 SkColor override_foreground_color; |
796 if (delegate && delegate->GetForegroundColor(GetCommand(), | 795 if (delegate && delegate->GetForegroundColor(GetCommand(), |
797 render_selection, | 796 render_selection, |
798 &override_foreground_color)) { | 797 &override_foreground_color)) { |
799 fg_color = override_foreground_color; | 798 fg_color = override_foreground_color; |
800 } | 799 } |
801 SkColor icon_color = | 800 SkColor icon_color = color_utils::DeriveDefaultIconColor(fg_color); |
802 render_selection && !ui::MaterialDesignController::IsModeMaterial() | |
803 ? fg_color | |
804 : color_utils::DeriveDefaultIconColor(fg_color); | |
805 | 801 |
806 // Render the check. | 802 // Render the check. |
807 if (type_ == CHECKBOX && delegate->IsItemChecked(GetCommand())) { | 803 if (type_ == CHECKBOX && delegate->IsItemChecked(GetCommand())) { |
808 gfx::ImageSkia check = GetMenuCheckImage(icon_color); | 804 gfx::ImageSkia check = GetMenuCheckImage(icon_color); |
809 // Don't use config.check_width here as it's padded | 805 // Don't use config.check_width here as it's padded |
810 // to force more padding (AURA). | 806 // to force more padding (AURA). |
811 gfx::Rect check_bounds(icon_x, | 807 gfx::Rect check_bounds(icon_x, |
812 top_margin + (available_height - check.height()) / 2, | 808 top_margin + (available_height - check.height()) / 2, |
813 check.width(), | 809 check.width(), |
814 check.height()); | 810 check.height()); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 } else { | 1077 } else { |
1082 const Type& type = menu_item->GetType(); | 1078 const Type& type = menu_item->GetType(); |
1083 if (type == CHECKBOX || type == RADIO) | 1079 if (type == CHECKBOX || type == RADIO) |
1084 return true; | 1080 return true; |
1085 } | 1081 } |
1086 } | 1082 } |
1087 return false; | 1083 return false; |
1088 } | 1084 } |
1089 | 1085 |
1090 } // namespace views | 1086 } // namespace views |
OLD | NEW |