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..3249b866f4cb2e6d64c4674975be108b137badf2 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,14 @@ 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()); |
| + set_background(PlatformStyle::CreateMenuButtonBackground().release()); |
|
tapted
2016/04/21 06:06:46
e.g. maybe this just needs to be conditional on `s
Elly Fong-Jones
2016/04/21 15:30:26
Done.
|
| } |
| MenuButton::~MenuButton() { |
| @@ -199,9 +200,7 @@ void MenuButton::OnPaint(gfx::Canvas* canvas) { |
| gfx::Size MenuButton::GetPreferredSize() const { |
| gfx::Size prefsize = LabelButton::GetPreferredSize(); |
| if (show_menu_marker_) { |
|
tapted
2016/04/21 06:06:46
nit: no curlies
Elly Fong-Jones
2016/04/21 15:30:26
Done.
|
| - prefsize.Enlarge(menu_marker_->width() + kMenuMarkerPaddingLeft + |
| - kMenuMarkerPaddingRight, |
| - 0); |
| + prefsize.Enlarge(PlatformStyle::GetMenuButtonArrowWidth(), 0); |
| } |
| return prefsize; |
| } |
| @@ -316,21 +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::GetMenuButtonArrowWidth(), 0, |
| + PlatformStyle::GetMenuButtonArrowWidth(), height()); |
| + gfx::ImageSkia marker = PlatformStyle::CreateMenuButtonArrow(enabled()); |
|
tapted
2016/04/21 06:06:46
`Create` here makes it sound more heavyweight than
Elly Fong-Jones
2016/04/21 15:30:26
I named it with "Create" in case at some point it
|
| + 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_) { |
|
tapted
2016/04/21 06:06:46
nit: no curlies
Elly Fong-Jones
2016/04/21 15:30:26
Done.
|
| - s.set_width(s.width() - menu_marker_->width() - kMenuMarkerPaddingLeft - |
| - kMenuMarkerPaddingRight); |
| + s.set_width(s.width() - PlatformStyle::GetMenuButtonArrowWidth()); |
| } |
| return gfx::Rect(s); |