Chromium Code Reviews| Index: ui/views/controls/button/menu_button.cc |
| diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc |
| index 4d1a1b9728157e8581a4ec725a94de28183a7715..283ab88ebfb070eb0c6058f4bc9c7a80fdbf5d98 100644 |
| --- a/ui/views/controls/button/menu_button.cc |
| +++ b/ui/views/controls/button/menu_button.cc |
| @@ -21,8 +21,10 @@ |
| #include "ui/views/animation/ink_drop_delegate.h" |
| #include "ui/views/controls/button/button.h" |
| #include "ui/views/controls/button/menu_button_listener.h" |
| +#include "ui/views/controls/focusable_border.h" |
| #include "ui/views/mouse_constants.h" |
| #include "ui/views/resources/grit/views_resources.h" |
| +#include "ui/views/style/platform_style.h" |
| #include "ui/views/widget/root_view.h" |
| #include "ui/views/widget/widget.h" |
| @@ -73,15 +75,15 @@ MenuButton::MenuButton(const base::string16& text, |
| menu_offset_(kDefaultMenuOffsetX, kDefaultMenuOffsetY), |
| listener_(menu_button_listener), |
| show_menu_marker_(show_menu_marker), |
| - menu_marker_(ui::ResourceBundle::GetSharedInstance() |
| - .GetImageNamed(IDR_MENU_DROPARROW) |
| - .ToImageSkia()), |
| destroyed_flag_(nullptr), |
| pressed_lock_count_(0), |
| increment_pressed_lock_called_(nullptr), |
| should_disable_after_press_(false), |
| weak_factory_(this) { |
| SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + SetBorder(PlatformStyle::CreateMenuButtonBorder()); |
|
tapted
2016/04/22 13:46:52
won't this still affect the OIB in a way that we d
Elly Fong-Jones
2016/04/25 14:30:50
What is an OIB?
tapted
2016/04/26 05:05:57
OIB is origin info bubble :). Which is the "offici
|
| + if (show_menu_marker_) |
| + set_background(PlatformStyle::CreateMenuButtonBackground().release()); |
| } |
| MenuButton::~MenuButton() { |
| @@ -198,11 +200,8 @@ void MenuButton::OnPaint(gfx::Canvas* canvas) { |
| gfx::Size MenuButton::GetPreferredSize() const { |
| gfx::Size prefsize = LabelButton::GetPreferredSize(); |
| - if (show_menu_marker_) { |
| - prefsize.Enlarge(menu_marker_->width() + kMenuMarkerPaddingLeft + |
| - kMenuMarkerPaddingRight, |
| - 0); |
| - } |
| + if (show_menu_marker_) |
| + prefsize.Enlarge(PlatformStyle::GetMenuButtonShoulderWidth(), 0); |
| return prefsize; |
| } |
| @@ -316,22 +315,20 @@ void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { |
| // Using the Views mirroring infrastructure incorrectly flips icon content. |
| // Instead, manually mirror the position of the down arrow. |
| - gfx::Rect arrow_bounds(width() - insets.right() - |
| - menu_marker_->width() - kMenuMarkerPaddingRight, |
| - height() / 2 - menu_marker_->height() / 2, |
| - menu_marker_->width(), |
| - menu_marker_->height()); |
| + gfx::Rect arrow_bounds( |
| + width() - insets.right() - PlatformStyle::GetMenuButtonShoulderWidth(), 0, |
| + PlatformStyle::GetMenuButtonShoulderWidth(), height()); |
| + gfx::ImageSkia marker = PlatformStyle::CreateMenuButtonArrow(enabled()); |
| + arrow_bounds.ClampToCenteredSize(marker.size()); |
| arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds)); |
| - canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y()); |
| + canvas->DrawImageInt(marker, arrow_bounds.x(), arrow_bounds.y()); |
| } |
| gfx::Rect MenuButton::GetChildAreaBounds() { |
| gfx::Size s = size(); |
| - if (show_menu_marker_) { |
| - s.set_width(s.width() - menu_marker_->width() - kMenuMarkerPaddingLeft - |
| - kMenuMarkerPaddingRight); |
| - } |
| + if (show_menu_marker_) |
| + s.set_width(s.width() - PlatformStyle::GetMenuButtonShoulderWidth()); |
| return gfx::Rect(s); |
| } |