| 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 "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
| 8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/message_center/message_center_style.h" | 10 #include "ui/message_center/message_center_style.h" |
| 11 #include "ui/views/controls/button/image_button.h" | 11 #include "ui/views/controls/button/image_button.h" |
| 12 #include "ui/views/painter.h" | 12 #include "ui/views/painter.h" |
| 13 | 13 |
| 14 namespace message_center { | 14 namespace message_center { |
| 15 | 15 |
| 16 PaddedButton::PaddedButton(views::ButtonListener* listener) | 16 PaddedButton::PaddedButton(views::ButtonListener* listener) |
| 17 : views::ImageButton(listener) { | 17 : views::ImageButton(listener) { |
| 18 set_focusable(true); | 18 SetFocusable(true); |
| 19 set_request_focus_on_press(false); | 19 set_request_focus_on_press(false); |
| 20 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 20 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 21 kFocusBorderColor, | 21 kFocusBorderColor, |
| 22 gfx::Insets(1, 2, 2, 2))); | 22 gfx::Insets(1, 2, 2, 2))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 PaddedButton::~PaddedButton() { | 25 PaddedButton::~PaddedButton() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { | 28 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 if (padding_.top() == 0 && padding_.bottom() == 0) | 91 if (padding_.top() == 0 && padding_.bottom() == 0) |
| 92 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. | 92 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. |
| 93 else if (padding_.bottom() > 0) | 93 else if (padding_.bottom() > 0) |
| 94 offset.set_y(bounds.height() - image.height()); // Bottom align. | 94 offset.set_y(bounds.height() - image.height()); // Bottom align. |
| 95 | 95 |
| 96 return bounds.origin() + offset; | 96 return bounds.origin() + offset; |
| 97 } | 97 } |
| 98 | 98 |
| 99 } // namespace message_center | 99 } // namespace message_center |
| OLD | NEW |