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

Side by Side Diff: ui/message_center/views/proportional_image_view.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/proportional_image_view.h" 5 #include "ui/message_center/views/proportional_image_view.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/message_center/message_center_style.h" 8 #include "ui/message_center/message_center_style.h"
9 9
10 namespace message_center { 10 namespace message_center {
11 11
12 ProportionalImageView::ProportionalImageView(const gfx::ImageSkia& image, 12 ProportionalImageView::ProportionalImageView(const gfx::ImageSkia& image,
13 const gfx::Size& max_size) 13 const gfx::Size& max_size)
14 : image_(image), max_size_(max_size) {} 14 : image_(image), max_size_(max_size) {}
15 15
16 ProportionalImageView::~ProportionalImageView() {} 16 ProportionalImageView::~ProportionalImageView() {}
17 17
18 gfx::Size ProportionalImageView::GetPreferredSize() { return max_size_; } 18 gfx::Size ProportionalImageView::GetPreferredSize() const { return max_size_; }
19 19
20 int ProportionalImageView::GetHeightForWidth(int width) { 20 int ProportionalImageView::GetHeightForWidth(int width) const {
21 return max_size_.height(); 21 return max_size_.height();
22 } 22 }
23 23
24 void ProportionalImageView::OnPaint(gfx::Canvas* canvas) { 24 void ProportionalImageView::OnPaint(gfx::Canvas* canvas) {
25 views::View::OnPaint(canvas); 25 views::View::OnPaint(canvas);
26 26
27 gfx::Size draw_size = GetImageDrawingSize(); 27 gfx::Size draw_size = GetImageDrawingSize();
28 28
29 if (draw_size.IsEmpty()) 29 if (draw_size.IsEmpty())
30 return; 30 return;
(...skipping 20 matching lines...) Expand all
51 } 51 }
52 52
53 gfx::Size ProportionalImageView::GetImageDrawingSize() { 53 gfx::Size ProportionalImageView::GetImageDrawingSize() {
54 if (!visible()) 54 if (!visible())
55 return gfx::Size(); 55 return gfx::Size();
56 return message_center::GetImageSizeForContainerSize( 56 return message_center::GetImageSizeForContainerSize(
57 GetContentsBounds().size(), image_.size()); 57 GetContentsBounds().size(), image_.size());
58 } 58 }
59 59
60 } // namespace message_center 60 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/proportional_image_view.h ('k') | ui/message_center/views/toast_contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698