| 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 "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // selected. | 38 // selected. |
| 39 if (render_selection) { | 39 if (render_selection) { |
| 40 SkColor bg_color = ui::NativeTheme::instance()->GetSystemColor( | 40 SkColor bg_color = ui::NativeTheme::instance()->GetSystemColor( |
| 41 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); | 41 ui::NativeTheme::kColorId_FocusedMenuItemBackgroundColor); |
| 42 canvas->DrawColor(bg_color, SkXfermode::kSrc_Mode); | 42 canvas->DrawColor(bg_color, SkXfermode::kSrc_Mode); |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Render the check. | 45 // Render the check. |
| 46 if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) { | 46 if (type_ == CHECKBOX && GetDelegate()->IsItemChecked(GetCommand())) { |
| 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 47 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 48 const SkBitmap* check = rb.GetImageNamed(IDR_MENU_CHECK).ToSkBitmap(); | 48 const gfx::ImageSkia* check = rb.GetImageNamed( |
| 49 IDR_MENU_CHECK).ToImageSkia(); |
| 49 // Don't use config.check_width here as it's padded to force more padding. | 50 // Don't use config.check_width here as it's padded to force more padding. |
| 50 gfx::Rect check_bounds(icon_x, icon_y, check->width(), icon_height); | 51 gfx::Rect check_bounds(icon_x, icon_y, check->width(), icon_height); |
| 51 AdjustBoundsForRTLUI(&check_bounds); | 52 AdjustBoundsForRTLUI(&check_bounds); |
| 52 canvas->DrawBitmapInt(*check, check_bounds.x(), check_bounds.y()); | 53 canvas->DrawBitmapInt(*check, check_bounds.x(), check_bounds.y()); |
| 53 } else if (type_ == RADIO) { | 54 } else if (type_ == RADIO) { |
| 54 const SkBitmap* image = | 55 const gfx::ImageSkia* image = |
| 55 GetRadioButtonImage(GetDelegate()->IsItemChecked(GetCommand())); | 56 GetRadioButtonImage(GetDelegate()->IsItemChecked(GetCommand())); |
| 56 gfx::Rect radio_bounds(icon_x, | 57 gfx::Rect radio_bounds(icon_x, |
| 57 top_margin + | 58 top_margin + |
| 58 (height() - top_margin - bottom_margin - | 59 (height() - top_margin - bottom_margin - |
| 59 image->height()) / 2, | 60 image->height()) / 2, |
| 60 image->width(), | 61 image->width(), |
| 61 image->height()); | 62 image->height()); |
| 62 AdjustBoundsForRTLUI(&radio_bounds); | 63 AdjustBoundsForRTLUI(&radio_bounds); |
| 63 canvas->DrawBitmapInt(*image, radio_bounds.x(), radio_bounds.y()); | 64 canvas->DrawBitmapInt(*image, radio_bounds.x(), radio_bounds.y()); |
| 64 } | 65 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 top_margin + (available_height - | 109 top_margin + (available_height - |
| 109 config.arrow_width) / 2, | 110 config.arrow_width) / 2, |
| 110 config.arrow_width, height()); | 111 config.arrow_width, height()); |
| 111 AdjustBoundsForRTLUI(&arrow_bounds); | 112 AdjustBoundsForRTLUI(&arrow_bounds); |
| 112 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), | 113 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), |
| 113 arrow_bounds.x(), arrow_bounds.y()); | 114 arrow_bounds.x(), arrow_bounds.y()); |
| 114 } | 115 } |
| 115 } | 116 } |
| 116 | 117 |
| 117 } // namespace views | 118 } // namespace views |
| OLD | NEW |