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 SetFocusBehavior(FocusBehavior::ALWAYS); | 17 Button::ConfigureDefaultFocus(this); |
18 set_request_focus_on_press(false); | 18 set_request_focus_on_press(false); |
19 SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 19 SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
20 kFocusBorderColor, | 20 kFocusBorderColor, |
21 gfx::Insets(1, 2, 2, 2))); | 21 gfx::Insets(1, 2, 2, 2))); |
22 } | 22 } |
23 | 23 |
24 PaddedButton::~PaddedButton() { | 24 PaddedButton::~PaddedButton() { |
25 } | 25 } |
26 | 26 |
27 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { | 27 void PaddedButton::SetPadding(int horizontal_padding, int vertical_padding) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 if (padding_.top() == 0 && padding_.bottom() == 0) | 88 if (padding_.top() == 0 && padding_.bottom() == 0) |
89 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. | 89 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. |
90 else if (padding_.bottom() > 0) | 90 else if (padding_.bottom() > 0) |
91 offset.set_y(bounds.height() - image.height()); // Bottom align. | 91 offset.set_y(bounds.height() - image.height()); // Bottom align. |
92 | 92 |
93 return bounds.origin() + offset; | 93 return bounds.origin() + offset; |
94 } | 94 } |
95 | 95 |
96 } // namespace message_center | 96 } // namespace message_center |
OLD | NEW |