Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: ui/message_center/views/padded_button.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « ui/message_center/views/padded_button.h ('k') | ui/message_center/views/proportional_image_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698