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/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 Loading... |
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 |
OLD | NEW |