| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "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 17 matching lines...) Expand all Loading... |
| 28 const int kMinTouchHeight = 46; | 28 const int kMinTouchHeight = 46; |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 gfx::Size MenuItemView::CalculatePreferredSize() { | 31 gfx::Size MenuItemView::CalculatePreferredSize() { |
| 32 const gfx::Font& font = GetFont(); | 32 const gfx::Font& font = GetFont(); |
| 33 #if defined(TOUCH_UI) | 33 #if defined(TOUCH_UI) |
| 34 int height = std::max(font.GetHeight(), kMinTouchHeight); | 34 int height = std::max(font.GetHeight(), kMinTouchHeight); |
| 35 #else | 35 #else |
| 36 int height = font.GetHeight(); | 36 int height = font.GetHeight(); |
| 37 #endif | 37 #endif |
| 38 gfx::Size child_size = GetChildPreferredSize(); |
| 38 return gfx::Size( | 39 return gfx::Size( |
| 39 font.GetStringWidth(title_) + label_start_ + | 40 font.GetStringWidth(title_) + label_start_ + |
| 40 item_right_margin_ + GetChildPreferredWidth(), | 41 item_right_margin_ + child_size.width(), |
| 41 height + GetBottomMargin() + GetTopMargin()); | 42 std::max(height, child_size.height()) + GetBottomMargin() + |
| 43 GetTopMargin()); |
| 42 } | 44 } |
| 43 | 45 |
| 44 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 46 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { |
| 45 const MenuConfig& config = MenuConfig::instance(); | 47 const MenuConfig& config = MenuConfig::instance(); |
| 46 bool render_selection = | 48 bool render_selection = |
| 47 (mode == PB_NORMAL && IsSelected() && | 49 (mode == PB_NORMAL && IsSelected() && |
| 48 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && | 50 parent_menu_item_->GetSubmenu()->GetShowSelection(this) && |
| 49 !has_children()); | 51 !has_children()); |
| 50 | 52 |
| 51 int icon_x = config.item_left_margin; | 53 int icon_x = config.item_left_margin; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 top_margin + (available_height - | 126 top_margin + (available_height - |
| 125 config.arrow_width) / 2, | 127 config.arrow_width) / 2, |
| 126 config.arrow_width, height()); | 128 config.arrow_width, height()); |
| 127 AdjustBoundsForRTLUI(&arrow_bounds); | 129 AdjustBoundsForRTLUI(&arrow_bounds); |
| 128 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), | 130 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), |
| 129 arrow_bounds.x(), arrow_bounds.y()); | 131 arrow_bounds.x(), arrow_bounds.y()); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace views | 135 } // namespace views |
| OLD | NEW |