| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/message_center/views/padded_button.h" | 5 #include "ui/message_center/views/padded_button.h" |
| 6 | 6 |
| 7 #include "ui/base/resource/resource_bundle.h" | 7 #include "ui/base/resource/resource_bundle.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/message_center/message_center_style.h" | 9 #include "ui/message_center/message_center_style.h" |
| 10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
| 11 #include "ui/views/painter.h" | 11 #include "ui/views/painter.h" |
| 12 | 12 |
| 13 namespace message_center { | 13 namespace message_center { |
| 14 | 14 |
| 15 PaddedButton::PaddedButton(views::ButtonListener* listener) | 15 PaddedButton::PaddedButton(views::ButtonListener* listener) |
| 16 : views::ImageButton(listener) { | 16 : views::ImageButton(listener) { |
| 17 Button::ConfigureDefaultFocus(this); | 17 Button::ConfigureDefaultFocus(this); |
| 18 set_request_focus_on_press(false); | |
| 19 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 18 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 20 kFocusBorderColor, | 19 kFocusBorderColor, |
| 21 gfx::Insets(1, 2, 2, 2))); | 20 gfx::Insets(1, 2, 2, 2))); |
| 22 } | 21 } |
| 23 | 22 |
| 24 PaddedButton::~PaddedButton() { | 23 PaddedButton::~PaddedButton() { |
| 25 } | 24 } |
| 26 | 25 |
| 27 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { | 26 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { |
| 28 padding_.Set(std::max(vertical_padding, 0), | 27 padding_.Set(std::max(vertical_padding, 0), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 86 |
| 88 if (padding_.top() == 0 && padding_.bottom() == 0) | 87 if (padding_.top() == 0 && padding_.bottom() == 0) |
| 89 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. | 88 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. |
| 90 else if (padding_.bottom() > 0) | 89 else if (padding_.bottom() > 0) |
| 91 offset.set_y(bounds.height() - image.height()); // Bottom align. | 90 offset.set_y(bounds.height() - image.height()); // Bottom align. |
| 92 | 91 |
| 93 return bounds.origin() + offset; | 92 return bounds.origin() + offset; |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace message_center | 95 } // namespace message_center |
| OLD | NEW |