| 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" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 43 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 44 resource_id)); | 44 resource_id)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void PaddedButton::SetPressedImage(int resource_id) { | 47 void PaddedButton::SetPressedImage(int resource_id) { |
| 48 SetImage(views::CustomButton::STATE_PRESSED, | 48 SetImage(views::CustomButton::STATE_PRESSED, |
| 49 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 49 ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 50 resource_id)); | 50 resource_id)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::Size PaddedButton::GetPreferredSize() { | 53 gfx::Size PaddedButton::GetPreferredSize() const { |
| 54 return gfx::Size(message_center::kControlButtonSize, | 54 return gfx::Size(message_center::kControlButtonSize, |
| 55 message_center::kControlButtonSize); | 55 message_center::kControlButtonSize); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void PaddedButton::OnPaint(gfx::Canvas* canvas) { | 58 void PaddedButton::OnPaint(gfx::Canvas* canvas) { |
| 59 // This is the same implementation as ImageButton::OnPaint except | 59 // This is the same implementation as ImageButton::OnPaint except |
| 60 // that it calls ComputePaddedImagePaintPosition() instead of | 60 // that it calls ComputePaddedImagePaintPosition() instead of |
| 61 // ComputeImagePaintPosition(), in effect overriding that private method. | 61 // ComputeImagePaintPosition(), in effect overriding that private method. |
| 62 View::OnPaint(canvas); | 62 View::OnPaint(canvas); |
| 63 gfx::ImageSkia image = GetImageToPaint(); | 63 gfx::ImageSkia image = GetImageToPaint(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 88 | 88 |
| 89 if (padding_.top() == 0 && padding_.bottom() == 0) | 89 if (padding_.top() == 0 && padding_.bottom() == 0) |
| 90 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. | 90 offset.set_y((bounds.height() - image.height()) / 2); // Middle align. |
| 91 else if (padding_.bottom() > 0) | 91 else if (padding_.bottom() > 0) |
| 92 offset.set_y(bounds.height() - image.height()); // Bottom align. | 92 offset.set_y(bounds.height() - image.height()); // Bottom align. |
| 93 | 93 |
| 94 return bounds.origin() + offset; | 94 return bounds.origin() + offset; |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace message_center | 97 } // namespace message_center |
| OLD | NEW |