| 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/native_theme/native_theme.h" | 10 #include "ui/base/native_theme/native_theme.h" | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65   } | 65   } | 
| 66 | 66 | 
| 67   // Render the foreground. | 67   // Render the foreground. | 
| 68   SkColor fg_color = ui::NativeTheme::instance()->GetSystemColor( | 68   SkColor fg_color = ui::NativeTheme::instance()->GetSystemColor( | 
| 69       enabled() ? ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor | 69       enabled() ? ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor | 
| 70           : ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); | 70           : ui::NativeTheme::kColorId_DisabledMenuItemForegroundColor); | 
| 71 | 71 | 
| 72   const gfx::Font& font = GetFont(); | 72   const gfx::Font& font = GetFont(); | 
| 73   int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); | 73   int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); | 
| 74   int width = this->width() - item_right_margin_ - label_start_ - accel_width; | 74   int width = this->width() - item_right_margin_ - label_start_ - accel_width; | 
| 75   gfx::Rect text_bounds(label_start_, top_margin + | 75   gfx::Rect text_bounds(label_start_, top_margin, width, available_height); | 
| 76                         (available_height - font.GetHeight() + 1) / 2, width, |  | 
| 77                         font.GetHeight()); |  | 
| 78   text_bounds.set_x(GetMirroredXForRect(text_bounds)); | 76   text_bounds.set_x(GetMirroredXForRect(text_bounds)); | 
| 79   int flags = GetRootMenuItem()->GetDrawStringFlags(); | 77   int flags = GetRootMenuItem()->GetDrawStringFlags() | | 
|  | 78               gfx::Canvas::TEXT_VALIGN_MIDDLE; | 
| 80   if (mode == PB_FOR_DRAG) | 79   if (mode == PB_FOR_DRAG) | 
| 81     flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; | 80     flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; | 
| 82   canvas->DrawStringInt(title(), font, fg_color, | 81   canvas->DrawStringInt(title(), font, fg_color, | 
| 83                         text_bounds.x(), text_bounds.y(), text_bounds.width(), | 82                         text_bounds.x(), text_bounds.y(), text_bounds.width(), | 
| 84                         text_bounds.height(), flags); | 83                         text_bounds.height(), flags); | 
| 85 | 84 | 
| 86   PaintAccelerator(canvas); | 85   PaintAccelerator(canvas); | 
| 87 | 86 | 
| 88   // Render the icon. |  | 
| 89   if (icon_.width() > 0) { |  | 
| 90     gfx::Rect icon_bounds(config.item_left_margin, |  | 
| 91                           top_margin + (height() - top_margin - |  | 
| 92                           bottom_margin - icon_.height()) / 2, |  | 
| 93                           icon_.width(), |  | 
| 94                           icon_.height()); |  | 
| 95     icon_bounds.set_x(GetMirroredXForRect(icon_bounds)); |  | 
| 96     if (!enabled()) { |  | 
| 97       SkPaint paint; |  | 
| 98       paint.setAlpha(120); |  | 
| 99       canvas->DrawImageInt(icon_, icon_bounds.x(), icon_bounds.y(), paint); |  | 
| 100     } else { |  | 
| 101       canvas->DrawImageInt(icon_, icon_bounds.x(), icon_bounds.y()); |  | 
| 102     } |  | 
| 103   } |  | 
| 104 |  | 
| 105   // Render the submenu indicator (arrow). | 87   // Render the submenu indicator (arrow). | 
| 106   if (HasSubmenu()) { | 88   if (HasSubmenu()) { | 
| 107     gfx::Rect arrow_bounds(this->width() - config.arrow_width - | 89     gfx::Rect arrow_bounds(this->width() - config.arrow_width - | 
| 108                                config.arrow_to_edge_padding, | 90                                config.arrow_to_edge_padding, | 
| 109                            top_margin + (available_height - | 91                            top_margin + (available_height - | 
| 110                                          config.arrow_width) / 2, | 92                                          config.arrow_width) / 2, | 
| 111                            config.arrow_width, height()); | 93                            config.arrow_width, height()); | 
| 112     AdjustBoundsForRTLUI(&arrow_bounds); | 94     AdjustBoundsForRTLUI(&arrow_bounds); | 
| 113     canvas->DrawImageInt(*GetSubmenuArrowImage(), | 95     canvas->DrawImageInt(*GetSubmenuArrowImage(), | 
| 114                          arrow_bounds.x(), arrow_bounds.y()); | 96                          arrow_bounds.x(), arrow_bounds.y()); | 
| 115   } | 97   } | 
| 116 } | 98 } | 
| 117 | 99 | 
| 118 }  // namespace views | 100 }  // namespace views | 
| OLD | NEW | 
|---|