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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, width, available_height); | 75 gfx::Rect text_bounds(label_start_, top_margin, width, available_height); |
76 text_bounds.set_x(GetMirroredXForRect(text_bounds)); | 76 text_bounds.set_x(GetMirroredXForRect(text_bounds)); |
77 int flags = GetRootMenuItem()->GetDrawStringFlags() | | 77 int flags = GetRootMenuItem()->GetDrawStringFlags(); |
78 gfx::Canvas::TEXT_VALIGN_MIDDLE; | |
79 if (mode == PB_FOR_DRAG) | 78 if (mode == PB_FOR_DRAG) |
80 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; | 79 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; |
81 canvas->DrawStringInt(title(), font, fg_color, | 80 canvas->DrawStringInt(title(), font, fg_color, |
82 text_bounds.x(), text_bounds.y(), text_bounds.width(), | 81 text_bounds.x(), text_bounds.y(), text_bounds.width(), |
83 text_bounds.height(), flags); | 82 text_bounds.height(), flags); |
84 | 83 |
85 PaintAccelerator(canvas); | 84 PaintAccelerator(canvas); |
86 | 85 |
87 // Render the submenu indicator (arrow). | 86 // Render the submenu indicator (arrow). |
88 if (HasSubmenu()) { | 87 if (HasSubmenu()) { |
89 gfx::Rect arrow_bounds(this->width() - config.arrow_width - | 88 gfx::Rect arrow_bounds(this->width() - config.arrow_width - |
90 config.arrow_to_edge_padding, | 89 config.arrow_to_edge_padding, |
91 top_margin + (available_height - | 90 top_margin + (available_height - |
92 config.arrow_width) / 2, | 91 config.arrow_width) / 2, |
93 config.arrow_width, height()); | 92 config.arrow_width, height()); |
94 AdjustBoundsForRTLUI(&arrow_bounds); | 93 AdjustBoundsForRTLUI(&arrow_bounds); |
95 canvas->DrawImageInt(*GetSubmenuArrowImage(), | 94 canvas->DrawImageInt(*GetSubmenuArrowImage(), |
96 arrow_bounds.x(), arrow_bounds.y()); | 95 arrow_bounds.x(), arrow_bounds.y()); |
97 } | 96 } |
98 } | 97 } |
99 | 98 |
100 } // namespace views | 99 } // namespace views |
OLD | NEW |