| 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/app_resources.h" | 8 #include "grit/app_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 10 matching lines...) Expand all Loading... |
| 21 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 22 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA); | 22 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(0xDC, 0xE4, 0xFA); |
| 23 #else | 23 #else |
| 24 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(246, 249, 253); | 24 static const SkColor kSelectedBackgroundColor = SkColorSetRGB(246, 249, 253); |
| 25 #endif | 25 #endif |
| 26 | 26 |
| 27 gfx::Size MenuItemView::CalculatePreferredSize() { | 27 gfx::Size MenuItemView::CalculatePreferredSize() { |
| 28 const gfx::Font& font = MenuConfig::instance().font; | 28 const gfx::Font& font = MenuConfig::instance().font; |
| 29 // TODO(sky): this is a workaround until I figure out why font.height() | 29 // TODO(sky): this is a workaround until I figure out why font.height() |
| 30 // isn't returning the right thing. We really only want to include | 30 // isn't returning the right thing. We really only want to include |
| 31 // kFavIconSize if we're showing icons. | 31 // kFaviconSize if we're showing icons. |
| 32 int content_height = std::max(kFavIconSize, font.GetHeight()); | 32 int content_height = std::max(kFaviconSize, font.GetHeight()); |
| 33 return gfx::Size( | 33 return gfx::Size( |
| 34 font.GetStringWidth(title_) + label_start_ + | 34 font.GetStringWidth(title_) + label_start_ + |
| 35 item_right_margin_ + GetChildPreferredWidth(), | 35 item_right_margin_ + GetChildPreferredWidth(), |
| 36 content_height + GetBottomMargin() + GetTopMargin()); | 36 content_height + GetBottomMargin() + GetTopMargin()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { | 39 void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { |
| 40 const MenuConfig& config = MenuConfig::instance(); | 40 const MenuConfig& config = MenuConfig::instance(); |
| 41 bool render_selection = | 41 bool render_selection = |
| 42 (mode == PB_NORMAL && IsSelected() && | 42 (mode == PB_NORMAL && IsSelected() && |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 top_margin + (available_height - | 119 top_margin + (available_height - |
| 120 config.arrow_width) / 2, | 120 config.arrow_width) / 2, |
| 121 config.arrow_width, height()); | 121 config.arrow_width, height()); |
| 122 AdjustBoundsForRTLUI(&arrow_bounds); | 122 AdjustBoundsForRTLUI(&arrow_bounds); |
| 123 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), | 123 canvas->DrawBitmapInt(*GetSubmenuArrowImage(), |
| 124 arrow_bounds.x(), arrow_bounds.y()); | 124 arrow_bounds.x(), arrow_bounds.y()); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace views | 128 } // namespace views |
| OLD | NEW |