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 b2e7037728154d845362e1ef3e0abd9867a00c1a..3d94222545170cdd12a8ee61bc678c0b8fc9b1e2 100644 |
| --- a/ui/views/controls/button/menu_button.cc |
| +++ b/ui/views/controls/button/menu_button.cc |
| @@ -133,24 +133,27 @@ bool MenuButton::Activate() { |
| return true; |
| } |
| +void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { |
|
sky
2013/10/03 23:23:11
In general smaller patches are preferable. They ma
noms (inactive)
2013/10/07 21:18:15
Done.
|
| + const gfx::Insets insets = GetInsets(); |
| + |
| + // We can not use the views' mirroring infrastructure for mirroring a |
| + // MenuButton control (see TextButton::OnPaint() for a detailed explanation |
| + // regarding why we can not flip the canvas). Therefore, we need to |
| + // 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()); |
| + arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds)); |
| + canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y()); |
| +} |
| + |
| void MenuButton::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) { |
| TextButton::PaintButton(canvas, mode); |
| - if (show_menu_marker_) { |
| - gfx::Insets insets = GetInsets(); |
| - |
| - // We can not use the views' mirroring infrastructure for mirroring a |
| - // MenuButton control (see TextButton::OnPaint() for a detailed explanation |
| - // regarding why we can not flip the canvas). Therefore, we need to |
| - // 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()); |
| - arrow_bounds.set_x(GetMirroredXForRect(arrow_bounds)); |
| - canvas->DrawImageInt(*menu_marker_, arrow_bounds.x(), arrow_bounds.y()); |
| - } |
| + if (show_menu_marker_) |
| + PaintMenuMarker(canvas); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |