| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/controls/menu/menu_item_view.h" | 5 #include "views/controls/menu/menu_item_view.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "gfx/canvas.h" | 8 #include "gfx/canvas.h" |
| 9 #include "gfx/favicon_size.h" | 9 #include "gfx/favicon_size.h" |
| 10 #include "grit/app_resources.h" | 10 #include "grit/app_resources.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 #if defined(OS_CHROMEOS) | 68 #if defined(OS_CHROMEOS) |
| 69 SkColor fg_color = | 69 SkColor fg_color = |
| 70 IsEnabled() ? SK_ColorBLACK : SkColorSetRGB(0x80, 0x80, 0x80); | 70 IsEnabled() ? SK_ColorBLACK : SkColorSetRGB(0x80, 0x80, 0x80); |
| 71 #else | 71 #else |
| 72 SkColor fg_color = | 72 SkColor fg_color = |
| 73 IsEnabled() ? TextButton::kEnabledColor : TextButton::kDisabledColor; | 73 IsEnabled() ? TextButton::kEnabledColor : TextButton::kDisabledColor; |
| 74 #endif | 74 #endif |
| 75 int width = this->width() - item_right_margin_ - label_start_; | |
| 76 const gfx::Font& font = GetChildViewCount() > 0 ? | 75 const gfx::Font& font = GetChildViewCount() > 0 ? |
| 77 MenuConfig::instance().font_with_controls : MenuConfig::instance().font; | 76 MenuConfig::instance().font_with_controls : MenuConfig::instance().font; |
| 77 int accel_width = parent_menu_item_->GetSubmenu()->max_accelerator_width(); |
| 78 int width = this->width() - item_right_margin_ - label_start_ - accel_width; |
| 78 gfx::Rect text_bounds(label_start_, top_margin + | 79 gfx::Rect text_bounds(label_start_, top_margin + |
| 79 (available_height - font.height()) / 2, width, | 80 (available_height - font.height()) / 2, width, |
| 80 font.height()); | 81 font.height()); |
| 81 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); | 82 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); |
| 82 canvas->DrawStringInt(GetTitle(), font, fg_color, | 83 canvas->DrawStringInt(GetTitle(), font, fg_color, |
| 83 text_bounds.x(), text_bounds.y(), text_bounds.width(), | 84 text_bounds.x(), text_bounds.y(), text_bounds.width(), |
| 84 text_bounds.height(), | 85 text_bounds.height(), |
| 85 GetRootMenuItem()->GetDrawStringFlags()); | 86 GetRootMenuItem()->GetDrawStringFlags()); |
| 86 | 87 |
| 88 PaintAccelerator(canvas); |
| 89 |
| 87 // Render the icon. | 90 // Render the icon. |
| 88 if (icon_.width() > 0) { | 91 if (icon_.width() > 0) { |
| 89 gfx::Rect icon_bounds(config.item_left_margin, | 92 gfx::Rect icon_bounds(config.item_left_margin, |
| 90 top_margin + (height() - top_margin - | 93 top_margin + (height() - top_margin - |
| 91 bottom_margin - icon_.height()) / 2, | 94 bottom_margin - icon_.height()) / 2, |
| 92 icon_.width(), | 95 icon_.width(), |
| 93 icon_.height()); | 96 icon_.height()); |
| 94 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); | 97 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); |
| 95 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); | 98 canvas->DrawBitmapInt(icon_, icon_bounds.x(), icon_bounds.y()); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Render the submenu indicator (arrow). | 101 // Render the submenu indicator (arrow). |
| 99 if (HasSubmenu()) { | 102 if (HasSubmenu()) { |
| 100 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + | 103 gfx::Rect arrow_bounds(this->width() - item_right_margin_ + |
| 101 config.label_to_arrow_padding, | 104 config.label_to_arrow_padding, |
| 102 top_margin + (available_height - | 105 top_margin + (available_height - |
| 103 config.arrow_width) / 2, | 106 config.arrow_width) / 2, |
| 104 config.arrow_width, height()); | 107 config.arrow_width, height()); |
| 105 AdjustBoundsForRTLUI(&arrow_bounds); | 108 AdjustBoundsForRTLUI(&arrow_bounds); |
| 106 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 109 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 107 canvas->DrawBitmapInt(*rb.GetBitmapNamed(IDR_MENU_ARROW), | 110 canvas->DrawBitmapInt(*rb.GetBitmapNamed(IDR_MENU_ARROW), |
| 108 arrow_bounds.x(), arrow_bounds.y()); | 111 arrow_bounds.x(), arrow_bounds.y()); |
| 109 } | 112 } |
| 110 } | 113 } |
| 111 | 114 |
| 112 } // namespace views | 115 } // namespace views |
| OLD | NEW |